Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
3c0a9bb5
Kaydet (Commit)
3c0a9bb5
authored
Nis 27, 2013
tarafından
David Ostrovsky
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
fdo#55814 migrate java unit test to python
Change-Id: Ib7ef29354f5d43abd9e67745dd6d3fccaec8612e
üst
efc47616
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
132 additions
and
2 deletions
+132
-2
PythonTest.mk
solenv/gbuild/PythonTest.mk
+2
-0
PythonTest_sw_python.mk
sw/PythonTest_sw_python.mk
+2
-1
var_fields.py
sw/qa/python/var_fields.py
+123
-0
unotest.py
unotest/source/python/org/libreoffice/unotest.py
+5
-1
No files found.
solenv/gbuild/PythonTest.mk
Dosyayı görüntüle @
3c0a9bb5
...
@@ -32,6 +32,7 @@ ifneq ($(DISABLE_PYTHON),TRUE)
...
@@ -32,6 +32,7 @@ ifneq ($(DISABLE_PYTHON),TRUE)
$(call gb_PythonTest_get_target,%) :
$(call gb_PythonTest_get_target,%) :
$(call gb_Output_announce,$*,$(true),PYT,2)
$(call gb_Output_announce,$*,$(true),PYT,2)
$(call gb_Helper_abbreviate_dirs,\
$(call gb_Helper_abbreviate_dirs,\
rm -rf $(dir $(call gb_PythonTest_get_target,$*)) && \
mkdir -p $(dir $(call gb_PythonTest_get_target,$*)) && \
mkdir -p $(dir $(call gb_PythonTest_get_target,$*)) && \
$(if $(gb_CppunitTest__interactive),, \
$(if $(gb_CppunitTest__interactive),, \
$(if $(value gb_CppunitTest_postprocess), \
$(if $(value gb_CppunitTest_postprocess), \
...
@@ -40,6 +41,7 @@ $(call gb_PythonTest_get_target,%) :
...
@@ -40,6 +41,7 @@ $(call gb_PythonTest_get_target,%) :
URE_BOOTSTRAP=vnd.sun.star.pathname:$(gb_DEVINSTALLROOT)/program/fundamentalrc \
URE_BOOTSTRAP=vnd.sun.star.pathname:$(gb_DEVINSTALLROOT)/program/fundamentalrc \
PYTHONPATH=$(PYPATH) \
PYTHONPATH=$(PYPATH) \
UserInstallation="$(call gb_Helper_make_url,$(OUTDIR)/unittest)" \
UserInstallation="$(call gb_Helper_make_url,$(OUTDIR)/unittest)" \
TestUserDir="$(call gb_Helper_make_url,$(dir $(call gb_PythonTest_get_target,$*)))" \
$(gb_CppunitTest_GDBTRACE) $(gb_CppunitTest_VALGRINDTOOL) $(gb_PythonTest_COMMAND) \
$(gb_CppunitTest_GDBTRACE) $(gb_CppunitTest_VALGRINDTOOL) $(gb_PythonTest_COMMAND) \
$(MODULES) \
$(MODULES) \
$(if $(gb_CppunitTest__interactive),, \
$(if $(gb_CppunitTest__interactive),, \
...
...
sw/PythonTest_sw_python.mk
Dosyayı görüntüle @
3c0a9bb5
...
@@ -10,8 +10,9 @@
...
@@ -10,8 +10,9 @@
$(eval $(call gb_PythonTest_PythonTest,sw_python))
$(eval $(call gb_PythonTest_PythonTest,sw_python))
$(eval $(call gb_PythonTest_add_modules,sw_python,$(SRCDIR)/sw/qa/python,\
$(eval $(call gb_PythonTest_add_modules,sw_python,$(SRCDIR)/sw/qa/python,\
set_expression \
get_expression \
get_expression \
set_expression \
var_fields \
))
))
# vim: set noet sw=4 ts=4:
# vim: set noet sw=4 ts=4:
sw/qa/python/var_fields.py
0 → 100644
Dosyayı görüntüle @
3c0a9bb5
import
unittest
import
os
from
org.libreoffice.unotest
import
UnoInProcess
from
com.sun.star.text.ControlCharacter
import
PARAGRAPH_BREAK
class
TestVarFields
(
unittest
.
TestCase
):
_uno
=
None
_xDoc
=
None
@classmethod
def
setUpClass
(
cls
):
cls
.
_uno
=
UnoInProcess
()
cls
.
_uno
.
setUp
()
cls
.
_xDoc
=
cls
.
_uno
.
openEmptyWriterDoc
()
@classmethod
def
tearDownClass
(
cls
):
cls
.
_uno
.
tearDown
()
def
test_var_fields
(
self
):
"""Reproduce fdo#55814.
Note: this test was migrated from java (the steps numbering too)
sw/qa/complex/writer/VarFields.java
Embarrassing, FixMe, TODO:
Unlike in java, this test doesn't overwrite the field condition.
Apparently xDoc.refresh() is somehow broken (from python), because doing the update
manually does overwrite the condition:
1. run the python test with make verbose=t PythonTest_sw_python
2. open created document with
./install/program/soffice.bin workdir/unxlngx6.pro/PythonTest/sw_python/VarFields.odt
3. check that TextSection's condition still has the right value: "foo EQ 1"
4. Update field with Tool=>Update=>Fields (or [F9])
5. check that TextSection's condition was overriden: "0"
"""
xDoc
=
self
.
__class__
.
_xDoc
xBodyText
=
xDoc
.
getText
()
xCursor
=
xBodyText
.
createTextCursor
()
# 0. create text field
xField
=
xDoc
.
createInstance
(
"com.sun.star.text.textfield.SetExpression"
)
# 1. fill it with properties
self
.
__class__
.
_uno
.
setProperties
(
xField
,
{
"Content"
:
"0"
,
"IsVisible"
:
True
,
"Hint"
:
"trying to reproduce fdo#55814"
,
"SubType"
:
0
,
# VAR
"Value"
:
0.0
})
# 2. create master field
xMaster
=
xDoc
.
createInstance
(
"com.sun.star.text.fieldmaster.SetExpression"
)
# 3. set name of the master field to "foo"
xMaster
.
setPropertyValue
(
"Name"
,
"foo"
)
# 4. get Dependent Field
# no op in python ;-)
# 5. connect real field to the master
xField
.
attachTextFieldMaster
(
xMaster
)
# 6. insert text field into the document
xBodyText
.
insertTextContent
(
xCursor
,
xField
,
False
)
# 7. retrieve paragraph cursor
xParagraphCursor
=
xCursor
xParagraphCursor
.
gotoEndOfParagraph
(
False
)
# not selectd
# 8. enter new line
xBodyText
.
insertControlCharacter
(
xCursor
,
PARAGRAPH_BREAK
,
False
)
# 9. create new text section
xTextSection
=
xDoc
.
createInstance
(
"com.sun.star.text.TextSection"
)
# 10. fill the properties of section
self
.
__class__
.
_uno
.
checkProperties
(
xTextSection
,
{
"Condition"
:
"foo EQ 1"
,
"IsVisible"
:
False
,
},
self
)
# 11. Insert some text to be content on the section
xBodyText
.
insertString
(
xCursor
,
"The quick brown fox jumps over the lazy dog"
,
True
)
# 12. insert section
xBodyText
.
insertTextContent
(
xCursor
,
xTextSection
,
True
)
# 12.1 insert new paragraph. Note: that's here the difference
xParagraphCursor
.
gotoEndOfParagraph
(
False
)
# not select
# TODO: how to leave the section now?
xBodyText
.
insertControlCharacter
(
xCursor
,
PARAGRAPH_BREAK
,
False
)
xBodyText
.
insertString
(
xCursor
,
"new paragraph"
,
False
)
# 13. Access fields to refresh the document
xEnumerationAccess
=
xDoc
.
getTextFields
()
# 14. refresh document to update the fields
xDoc
.
refresh
()
# 15. retrieve the field
xFieldEnum
=
xEnumerationAccess
.
createEnumeration
()
# Note: we have only one field here, that why nextElement() is just fine here
xPropSet
=
xFieldEnum
.
nextElement
()
# check
readContent
=
xPropSet
.
getPropertyValue
(
"Content"
)
self
.
assertEqual
(
"0"
,
readContent
)
readContent
=
xPropSet
.
getPropertyValue
(
"Value"
)
self
.
assertEqual
(
0.0
,
readContent
)
# 16. change the value of the field from 0 to 1 and check
self
.
__class__
.
_uno
.
checkProperties
(
xPropSet
,
{
"Value"
:
1.0
,
"Content"
:
"1"
},
self
)
# 17. refresh document to update the fields again
xDoc
.
refresh
()
# 18. store document
url
=
os
.
path
.
join
(
os
.
environ
[
"TestUserDir"
],
"VarFields.odt"
)
xDoc
.
storeToURL
(
url
,
tuple
(
list
(
range
(
0
))))
# 19. retrieve the section
xPropSet
=
xDoc
.
getTextSections
()
.
getByIndex
(
0
)
# 20. retrieve the condition property of that section
readContent
=
xPropSet
.
getPropertyValue
(
"Condition"
)
# 21. check
# expected:
self
.
assertEqual
(
"foo EQ 1"
,
readContent
)
# reality:
#self.assertEqual("0", readContent)
if
__name__
==
'__main__'
:
unittest
.
main
()
unotest/source/python/org/libreoffice/unotest.py
Dosyayı görüntüle @
3c0a9bb5
...
@@ -127,7 +127,7 @@ class OfficeConnection(object):
...
@@ -127,7 +127,7 @@ class OfficeConnection(object):
def
getContext
(
self
):
def
getContext
(
self
):
return
self
.
xContext
return
self
.
xContext
class
UnoConnection
:
class
Uno
Remote
Connection
:
def
__init__
(
self
,
args
):
def
__init__
(
self
,
args
):
self
.
args
=
args
self
.
args
=
args
self
.
connection
=
None
self
.
connection
=
None
...
@@ -187,6 +187,10 @@ class UnoInProcess:
...
@@ -187,6 +187,10 @@ class UnoInProcess:
value
=
obj
.
getPropertyValue
(
k
)
value
=
obj
.
getPropertyValue
(
k
)
test
.
assertEqual
(
value
,
v
)
test
.
assertEqual
(
value
,
v
)
def
setProperties
(
self
,
obj
,
dict
):
for
k
,
v
in
dict
.
items
():
obj
.
setPropertyValue
(
k
,
v
)
def
postTest
(
self
):
def
postTest
(
self
):
assert
(
self
.
xContext
)
assert
(
self
.
xContext
)
def
tearDown
(
self
):
def
tearDown
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment