[Libreoffice-commits] core.git: 18 commits - external/python3 formula/source include/svtools include/vcl solenv/gbuild svtools/inc svtools/source uitest/calc_tests uitest/demo_ui uitest/helper.py uitest/impress_tests uitest/test_main.py uitest/UITest_calc_demo.mk uitest/UITestCase.py uitest/UITest_demo_ui.mk uitest/UITest_impress_demo.mk uitest/UITest_writer_demo.mk uitest/writer_tests vcl/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Wed Jun 22 16:20:19 UTC 2016
external/python3/ExternalPackage_python3.mk | 11 +
formula/source/ui/dlg/structpg.hxx | 2
include/svtools/treelistbox.hxx | 9 -
include/vcl/tabctrl.hxx | 2
include/vcl/uitest/uiobject.hxx | 23 +++
solenv/gbuild/UITest.mk | 15 +-
svtools/inc/uitest/uiobject.hxx | 36 +++++
svtools/source/uitest/uiobject.cxx | 111 ++++++++++++++++
uitest/UITestCase.py | 32 ++++
uitest/UITest_calc_demo.mk | 2
uitest/UITest_demo_ui.mk | 2
uitest/UITest_impress_demo.mk | 2
uitest/UITest_writer_demo.mk | 2
uitest/calc_tests/about_test.py | 22 +--
uitest/calc_tests/calc_demo.txt | 5
uitest/calc_tests/create_chart.py | 190 ++++++++++++----------------
uitest/calc_tests/create_range_name.py | 62 ++++-----
uitest/calc_tests/function_wizard.py | 28 +---
uitest/calc_tests/gridwin.py | 45 ++++++
uitest/calc_tests/gridwindow.py | 46 ++----
uitest/demo_ui/checkbox.py | 24 +--
uitest/demo_ui/combobox.py | 28 ++--
uitest/demo_ui/demo_ui.txt | 13 -
uitest/demo_ui/edit.py | 28 ++--
uitest/demo_ui/gridwin.py | 60 +++-----
uitest/demo_ui/listbox.py | 52 +++----
uitest/demo_ui/radiobutton.py | 24 +--
uitest/demo_ui/spinfield.py | 104 +++++++--------
uitest/demo_ui/tabcontrol.py | 52 +++++++
uitest/demo_ui/tabdialog.py | 48 +++----
uitest/demo_ui/treelist.py | 60 ++++++++
uitest/helper.py | 1
uitest/impress_tests/impress_demo.txt | 4
uitest/impress_tests/start.py | 95 +++-----------
uitest/test_main.py | 100 ++++++++++++++
uitest/writer_tests/start.py | 90 ++++---------
uitest/writer_tests/writer_demo.txt | 4
vcl/source/control/tabctrl.cxx | 6
vcl/source/uitest/uiobject.cxx | 48 +++++++
vcl/source/uitest/uno/uiobject_uno.cxx | 2
40 files changed, 927 insertions(+), 563 deletions(-)
New commits:
commit dd3e8ad79d5a9757c9a0ed2b0fe82f3bb00dbba4
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Jun 22 18:17:25 2016 +0200
uitest: remove debug print statements
Change-Id: I7dc68ef48a69f4878a20e6cb1dd3203dfc3097fd
diff --git a/uitest/helper.py b/uitest/helper.py
index fcb9618..b993041 100644
--- a/uitest/helper.py
+++ b/uitest/helper.py
@@ -46,7 +46,6 @@ class EventListener(XDocumentEventListener,unohelper.Base):
self.xGEB.removeDocumentEventListener(self)
def documentEventOccured(self, event):
- print(str(event.EventName))
if event.EventName in self.eventNames:
self.executed = True
self.eventExecuted.append(event.EventName)
diff --git a/uitest/test_main.py b/uitest/test_main.py
index 2a0fca1..15e5d70 100644
--- a/uitest/test_main.py
+++ b/uitest/test_main.py
@@ -94,7 +94,6 @@ if __name__ == '__main__':
usage()
sys.exit()
test_suite = get_test_suite(opts)
- print(test_suite)
unittest.TextTestRunner().run(test_suite)
commit e41cb9684784bc65733995c1e486b62b647d980c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Jun 22 18:14:59 2016 +0200
uitest: we also need a SolarMutex when deleting the wrapper object
The wrapper has references to vcl objects and the destructor might have
the last reference to a vcl::Window causing a delete. Avoid potential
problems (I have seen one deadlock in the chart wizard code) by taking
the SolarMutex.
Change-Id: I8afcf79842b2f8e8f822b975629d5c8e18a86163
diff --git a/vcl/source/uitest/uno/uiobject_uno.cxx b/vcl/source/uitest/uno/uiobject_uno.cxx
index 7c6ca83..6506c05 100644
--- a/vcl/source/uitest/uno/uiobject_uno.cxx
+++ b/vcl/source/uitest/uno/uiobject_uno.cxx
@@ -20,6 +20,8 @@ UIObjectUnoObj::UIObjectUnoObj(std::unique_ptr<UIObject> pObj):
UIObjectUnoObj::~UIObjectUnoObj()
{
+ SolarMutexGuard aGuard;
+ mpObj.reset();
}
css::uno::Reference<css::ui::test::XUIObject> SAL_CALL UIObjectUnoObj::getChild(const OUString& rID)
commit 6da7ccfc2ac3382c896a679b98061fce4a6d6cf2
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Jun 22 06:36:59 2016 +0200
uitest: remove sleeps and prints from impress and writer parts
Change-Id: Ic4c4ba74701303df1ff38c5ed6ed7d521b369053
diff --git a/uitest/impress_tests/start.py b/uitest/impress_tests/start.py
index 28a3c74..f82eb63 100644
--- a/uitest/impress_tests/start.py
+++ b/uitest/impress_tests/start.py
@@ -29,16 +29,10 @@ class SimpleImpressTest(UITestCase):
self.ui_test.create_doc_in_start_center("impress")
xImpressDoc = self.xUITest.getTopFocusWindow()
- print(get_state_as_dict(xImpressDoc))
- print(xImpressDoc.getChildren())
xEditWin = xImpressDoc.getChild("impress_win")
xEditWin.executeAction("SET", mkPropertyValues({"ZOOM": "200"}))
- print(xEditWin.getChildren())
-
- time.sleep(1)
-
self.ui_test.close_doc()
def test_select_page(self):
@@ -46,20 +40,11 @@ class SimpleImpressTest(UITestCase):
self.ui_test.create_doc_in_start_center("impress")
xImpressDoc = self.xUITest.getTopFocusWindow()
- print(get_state_as_dict(xImpressDoc))
- print(xImpressDoc.getChildren())
xEditWin = xImpressDoc.getChild("impress_win")
- time.sleep(1)
- print(get_state_as_dict(xEditWin))
-
xEditWin.executeAction("GOTO", mkPropertyValues({"PAGE": "2"}))
- time.sleep(1)
-
- print(get_state_as_dict(xEditWin))
-
self.ui_test.close_doc()
def test_select_text(self):
@@ -67,15 +52,9 @@ class SimpleImpressTest(UITestCase):
self.ui_test.create_doc_in_start_center("impress")
xImpressDoc = self.xUITest.getTopFocusWindow()
- print(get_state_as_dict(xImpressDoc))
- print(xImpressDoc.getChildren())
xEditWin = xImpressDoc.getChild("impress_win")
- time.sleep(1)
-
- print(get_state_as_dict(xEditWin))
-
self.ui_test.close_doc()
def test_select_object(self):
@@ -83,19 +62,12 @@ class SimpleImpressTest(UITestCase):
self.ui_test.create_doc_in_start_center("impress")
xImpressDoc = self.xUITest.getTopFocusWindow()
- print(get_state_as_dict(xImpressDoc))
- print(xImpressDoc.getChildren())
xEditWin = xImpressDoc.getChild("impress_win")
xEditWin.executeAction("SELECT", mkPropertyValues({"OBJECT":"Unnamed Drawinglayer object 1"}))
- time.sleep(1)
xEditWin.executeAction("DESELECT", tuple())
- time.sleep(1)
-
- print(get_state_as_dict(xEditWin))
-
self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uitest/writer_tests/start.py b/uitest/writer_tests/start.py
index 51e0d3a..13d99c9 100644
--- a/uitest/writer_tests/start.py
+++ b/uitest/writer_tests/start.py
@@ -30,15 +30,11 @@ class SimpleWriterTest(UITestCase):
self.ui_test.create_doc_in_start_center("writer")
xWriterDoc = self.xUITest.getTopFocusWindow()
- print(xWriterDoc.getChildren())
xWriterEdit = xWriterDoc.getChild("writer_edit")
- print(xWriterEdit.getState())
xWriterEdit.executeAction("SET", mkPropertyValues({"ZOOM": "200"}))
- time.sleep(2)
-
self.ui_test.close_doc()
def test_type_text(self):
@@ -50,8 +46,6 @@ class SimpleWriterTest(UITestCase):
xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "This is my first writer text written through the UI testing"}))
- time.sleep(2)
-
self.ui_test.close_doc()
def test_goto_first_page(self):
@@ -62,14 +56,11 @@ class SimpleWriterTest(UITestCase):
xWriterEdit = xWriterDoc.getChild("writer_edit")
state = get_state_as_dict(xWriterEdit)
- print(state)
while state["CurrentPage"] is "1":
xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
state = get_state_as_dict(xWriterEdit)
xWriterEdit.executeAction("GOTO", mkPropertyValues({"PAGE": "1"}))
- print(state)
- time.sleep(2)
self.ui_test.close_doc()
@@ -83,15 +74,8 @@ class SimpleWriterTest(UITestCase):
xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "This is my first writer text written through the UI testing"}))
- time.sleep(2)
- print(get_state_as_dict(xWriterEdit))
-
xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "0", "END_POS": "4"}))
- print(get_state_as_dict(xWriterEdit))
-
- time.sleep(2)
-
self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 18d64ed6b47c6a39ccef9cd704f135bae390d5a9
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Jun 22 06:34:55 2016 +0200
uitest: remove sleeps from demo ui parts
Change-Id: Ib1fc73c317186ede3f41029aa40b0c6a075c085d
diff --git a/uitest/demo_ui/tabcontrol.py b/uitest/demo_ui/tabcontrol.py
index 9ef9d7b..1f5712d 100644
--- a/uitest/demo_ui/tabcontrol.py
+++ b/uitest/demo_ui/tabcontrol.py
@@ -43,8 +43,6 @@ class TabControlTest(UITestCase):
xTabs = xFunctionDlg.getChild("tabs")
xTabs.executeAction("SELECT", mkPropertyValues({"POS":"1"}))
- time.sleep(1)
-
xCancelBtn = xFunctionDlg.getChild("cancel")
xCancelBtn.executeAction("CLICK", tuple())
diff --git a/uitest/demo_ui/treelist.py b/uitest/demo_ui/treelist.py
index f1681cd..23c1199 100644
--- a/uitest/demo_ui/treelist.py
+++ b/uitest/demo_ui/treelist.py
@@ -50,12 +50,8 @@ class TreeListTest(UITestCase):
xTreeEntry.executeAction("COLLAPSE", tuple())
- time.sleep(1)
-
xTreeEntry.executeAction("EXPAND", tuple())
- time.sleep(1)
-
xCancelBtn = xFunctionDlg.getChild("cancel")
xCancelBtn.executeAction("CLICK", tuple())
commit 16e6889e6291d22f4f8f44f2701e8b315d04a084
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Jun 22 06:33:12 2016 +0200
uitest: remove sleeps and prints from calc demo
These sleeps are only necessary when you want to run them non-headless
and see what is actually happening.
Change-Id: I20bd80c680c8569bc3c885f261e03db494afee06
diff --git a/uitest/calc_tests/create_chart.py b/uitest/calc_tests/create_chart.py
index 6db4d58..1bd8276 100644
--- a/uitest/calc_tests/create_chart.py
+++ b/uitest/calc_tests/create_chart.py
@@ -69,14 +69,10 @@ class CalcChartUIDemo(UITestCase):
self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
xChartDlg = self.xUITest.getTopFocusWindow()
- print(xChartDlg.getChildren())
- time.sleep(2)
xOkBtn = xChartDlg.getChild("finish")
xOkBtn.executeAction("CLICK", tuple())
- time.sleep(2)
-
self.ui_test.close_doc()
def test_create_from_second_page(self):
@@ -88,31 +84,19 @@ class CalcChartUIDemo(UITestCase):
self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
xChartDlg = self.xUITest.getTopFocusWindow()
- print(xChartDlg.getChildren())
- time.sleep(2)
xNextBtn = xChartDlg.getChild("next")
xNextBtn.executeAction("CLICK", tuple())
- print(xChartDlg.getChildren())
-
- time.sleep(2)
-
xDataInRows = xChartDlg.getChild("RB_DATAROWS")
xDataInRows.executeAction("CLICK", tuple())
- time.sleep(2)
-
xDataInCols = xChartDlg.getChild("RB_DATACOLS")
xDataInCols.executeAction("CLICK", tuple())
- time.sleep(2)
-
xCancelBtn = xChartDlg.getChild("finish")
xCancelBtn.executeAction("CLICK", tuple())
- time.sleep(5)
-
self.ui_test.close_doc()
def test_deselect_chart(self):
@@ -154,13 +138,9 @@ class CalcChartUIDemo(UITestCase):
xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
- time.sleep(2)
-
xGridWindow.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
xGridWindow.executeAction("ACTIVATE", tuple())
- time.sleep(2)
-
xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
self.ui_test.close_doc()
@@ -187,7 +167,6 @@ class CalcChartUIDemo(UITestCase):
xGridWindow.executeAction("ACTIVATE", tuple())
xCalcDoc = self.xUITest.getTopFocusWindow()
- print(xCalcDoc.getChildren())
self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uitest/calc_tests/gridwindow.py b/uitest/calc_tests/gridwindow.py
index 1b63fe5..c3b2d1d 100644
--- a/uitest/calc_tests/gridwindow.py
+++ b/uitest/calc_tests/gridwindow.py
@@ -37,8 +37,6 @@ class GridWindowTest(UITestCase):
enter_text_to_cell(xGridWindow, "C3", "=A1")
enter_text_to_cell(xGridWindow, "A1", "2")
- time.sleep(2)
-
self.ui_test.close_doc()
def test_special_keys(self):
@@ -54,8 +52,6 @@ class GridWindowTest(UITestCase):
typeProps = mkPropertyValues({"KEYCODE": "CTRL+DOWN"})
xGridWindow.executeAction("TYPE", typeProps)
- time.sleep(2)
-
self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit f928a9983423be545583269cb8274e9bfc7cf95d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Jun 22 06:07:00 2016 +0200
uitest: convert writer demo to new python unittest framework
Change-Id: Ifff8fe9cb0f005c8a4e892d756ae6b0b95db3544
diff --git a/uitest/UITest_calc_demo.mk b/uitest/UITest_calc_demo.mk
index 96acb49..9869300 100644
--- a/uitest/UITest_calc_demo.mk
+++ b/uitest/UITest_calc_demo.mk
@@ -10,6 +10,6 @@
$(eval $(call gb_UITest_UITest,calc_demo))
$(eval $(call gb_UITest_add_modules,calc_demo,$(SRCDIR)/uitest,\
- calc_tests/calc_demo.txt \
+ calc_tests/ \
))
# vim: set noet sw=4 ts=4:
diff --git a/uitest/UITest_demo_ui.mk b/uitest/UITest_demo_ui.mk
index 03da9bb..11432f9 100644
--- a/uitest/UITest_demo_ui.mk
+++ b/uitest/UITest_demo_ui.mk
@@ -10,7 +10,7 @@
$(eval $(call gb_UITest_UITest,demo_ui))
$(eval $(call gb_UITest_add_modules,demo_ui,$(SRCDIR)/uitest,\
- demo_ui/demo_ui.txt \
+ demo_ui/ \
))
# vim: set noet sw=4 ts=4:
diff --git a/uitest/UITest_impress_demo.mk b/uitest/UITest_impress_demo.mk
index dfabbf9..e13d954 100644
--- a/uitest/UITest_impress_demo.mk
+++ b/uitest/UITest_impress_demo.mk
@@ -10,6 +10,6 @@
$(eval $(call gb_UITest_UITest,impress_demo))
$(eval $(call gb_UITest_add_modules,impress_demo,$(SRCDIR)/uitest,\
- impress_tests/impress_demo.txt \
+ impress_tests/ \
))
# vim: set noet sw=4 ts=4:
diff --git a/uitest/UITest_writer_demo.mk b/uitest/UITest_writer_demo.mk
index c0c7f3d..a95fbd1 100644
--- a/uitest/UITest_writer_demo.mk
+++ b/uitest/UITest_writer_demo.mk
@@ -10,6 +10,6 @@
$(eval $(call gb_UITest_UITest,writer_demo))
$(eval $(call gb_UITest_add_modules,writer_demo,$(SRCDIR)/uitest,\
- writer_tests/writer_demo.txt \
+ writer_tests/ \
))
# vim: set noet sw=4 ts=4:
diff --git a/uitest/writer_tests/start.py b/uitest/writer_tests/start.py
index a5a23ca..51e0d3a 100644
--- a/uitest/writer_tests/start.py
+++ b/uitest/writer_tests/start.py
@@ -9,6 +9,8 @@ from uitest_helper import UITest, get_state_as_dict
from helper import mkPropertyValues
+from UITestCase import UITestCase
+
import time
try:
@@ -21,89 +23,75 @@ except ImportError:
print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
raise
-def start_writer(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
-
- ui_test = UITest(xUITest, xContext)
+class SimpleWriterTest(UITestCase):
- ui_test.create_doc_in_start_center("writer")
+ def test_start_writer(self):
- xWriterDoc = xUITest.getTopFocusWindow()
- print(xWriterDoc.getChildren())
+ self.ui_test.create_doc_in_start_center("writer")
- xWriterEdit = xWriterDoc.getChild("writer_edit")
- print(xWriterEdit.getState())
+ xWriterDoc = self.xUITest.getTopFocusWindow()
+ print(xWriterDoc.getChildren())
- xWriterEdit.executeAction("SET", mkPropertyValues({"ZOOM": "200"}))
+ xWriterEdit = xWriterDoc.getChild("writer_edit")
+ print(xWriterEdit.getState())
- time.sleep(2)
+ xWriterEdit.executeAction("SET", mkPropertyValues({"ZOOM": "200"}))
- ui_test.close_doc()
+ time.sleep(2)
-def type_text(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+ self.ui_test.close_doc()
- ui_test = UITest(xUITest, xContext)
+ def test_type_text(self):
- ui_test.create_doc_in_start_center("writer")
+ self.ui_test.create_doc_in_start_center("writer")
- xWriterDoc = xUITest.getTopFocusWindow()
- xWriterEdit = xWriterDoc.getChild("writer_edit")
+ xWriterDoc = self.xUITest.getTopFocusWindow()
+ xWriterEdit = xWriterDoc.getChild("writer_edit")
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "This is my first writer text written through the UI testing"}))
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "This is my first writer text written through the UI testing"}))
- time.sleep(2)
+ time.sleep(2)
- ui_test.close_doc()
+ self.ui_test.close_doc()
-def goto_first_page(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+ def test_goto_first_page(self):
- ui_test = UITest(xUITest, xContext)
+ self.ui_test.create_doc_in_start_center("writer")
- ui_test.create_doc_in_start_center("writer")
+ xWriterDoc = self.xUITest.getTopFocusWindow()
+ xWriterEdit = xWriterDoc.getChild("writer_edit")
- xWriterDoc = xUITest.getTopFocusWindow()
- xWriterEdit = xWriterDoc.getChild("writer_edit")
-
- state = get_state_as_dict(xWriterEdit)
- print(state)
- while state["CurrentPage"] is "1":
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
state = get_state_as_dict(xWriterEdit)
+ print(state)
+ while state["CurrentPage"] is "1":
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
+ state = get_state_as_dict(xWriterEdit)
- xWriterEdit.executeAction("GOTO", mkPropertyValues({"PAGE": "1"}))
- print(state)
- time.sleep(2)
-
- ui_test.close_doc()
+ xWriterEdit.executeAction("GOTO", mkPropertyValues({"PAGE": "1"}))
+ print(state)
+ time.sleep(2)
+ self.ui_test.close_doc()
-def select_text(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
- ui_test = UITest(xUITest, xContext)
+ def test_select_text(self):
- ui_test.create_doc_in_start_center("writer")
+ self.ui_test.create_doc_in_start_center("writer")
- xWriterDoc = xUITest.getTopFocusWindow()
- xWriterEdit = xWriterDoc.getChild("writer_edit")
+ xWriterDoc = self.xUITest.getTopFocusWindow()
+ xWriterEdit = xWriterDoc.getChild("writer_edit")
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "This is my first writer text written through the UI testing"}))
+ xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "This is my first writer text written through the UI testing"}))
- time.sleep(2)
- print(get_state_as_dict(xWriterEdit))
+ time.sleep(2)
+ print(get_state_as_dict(xWriterEdit))
- xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "0", "END_POS": "4"}))
+ xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "0", "END_POS": "4"}))
- print(get_state_as_dict(xWriterEdit))
+ print(get_state_as_dict(xWriterEdit))
- time.sleep(2)
+ time.sleep(2)
- ui_test.close_doc()
+ self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uitest/writer_tests/writer_demo.txt b/uitest/writer_tests/writer_demo.txt
deleted file mode 100644
index 0045e2a..0000000
--- a/uitest/writer_tests/writer_demo.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-writer_tests.start.start_writer
-writer_tests.start.type_text
-writer_tests.start.goto_first_page
-writer_tests.start.select_text
commit fb821500ed026cfddae99c3695660556c75002d3
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Jun 22 06:02:55 2016 +0200
uitest: convert the impress test to the new python unittest framework
Change-Id: I7a5cf03daac1b0426672a9d6611aa4cab4aaf91c
diff --git a/uitest/impress_tests/impress_demo.txt b/uitest/impress_tests/impress_demo.txt
deleted file mode 100644
index fb38b14..0000000
--- a/uitest/impress_tests/impress_demo.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-impress_tests.start.start_impress
-impress_tests.start.select_page
-impress_tests.start.select_text
-impress_tests.start.select_object
diff --git a/uitest/impress_tests/start.py b/uitest/impress_tests/start.py
index 5b0dfdb..28a3c74 100644
--- a/uitest/impress_tests/start.py
+++ b/uitest/impress_tests/start.py
@@ -9,6 +9,8 @@ from uitest_helper import UITest, get_state_as_dict
from helper import mkPropertyValues
+from UITestCase import UITestCase
+
import time
try:
@@ -21,94 +23,79 @@ except ImportError:
print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
raise
-def start_impress(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
-
- ui_test = UITest(xUITest, xContext)
-
- ui_test.create_doc_in_start_center("impress")
-
- xImpressDoc = xUITest.getTopFocusWindow()
- print(get_state_as_dict(xImpressDoc))
- print(xImpressDoc.getChildren())
-
- xEditWin = xImpressDoc.getChild("impress_win")
- xEditWin.executeAction("SET", mkPropertyValues({"ZOOM": "200"}))
+class SimpleImpressTest(UITestCase):
+ def test_start_impress(self):
- print(xEditWin.getChildren())
+ self.ui_test.create_doc_in_start_center("impress")
- time.sleep(1)
+ xImpressDoc = self.xUITest.getTopFocusWindow()
+ print(get_state_as_dict(xImpressDoc))
+ print(xImpressDoc.getChildren())
- ui_test.close_doc()
+ xEditWin = xImpressDoc.getChild("impress_win")
+ xEditWin.executeAction("SET", mkPropertyValues({"ZOOM": "200"}))
-def select_page(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+ print(xEditWin.getChildren())
- ui_test = UITest(xUITest, xContext)
+ time.sleep(1)
- ui_test.create_doc_in_start_center("impress")
+ self.ui_test.close_doc()
- xImpressDoc = xUITest.getTopFocusWindow()
- print(get_state_as_dict(xImpressDoc))
- print(xImpressDoc.getChildren())
+ def test_select_page(self):
- xEditWin = xImpressDoc.getChild("impress_win")
+ self.ui_test.create_doc_in_start_center("impress")
- time.sleep(1)
- print(get_state_as_dict(xEditWin))
+ xImpressDoc = self.xUITest.getTopFocusWindow()
+ print(get_state_as_dict(xImpressDoc))
+ print(xImpressDoc.getChildren())
- xEditWin.executeAction("GOTO", mkPropertyValues({"PAGE": "2"}))
+ xEditWin = xImpressDoc.getChild("impress_win")
- time.sleep(1)
+ time.sleep(1)
+ print(get_state_as_dict(xEditWin))
- print(get_state_as_dict(xEditWin))
+ xEditWin.executeAction("GOTO", mkPropertyValues({"PAGE": "2"}))
- ui_test.close_doc()
+ time.sleep(1)
-def select_text(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+ print(get_state_as_dict(xEditWin))
- ui_test = UITest(xUITest, xContext)
+ self.ui_test.close_doc()
- ui_test.create_doc_in_start_center("impress")
+ def test_select_text(self):
- xImpressDoc = xUITest.getTopFocusWindow()
- print(get_state_as_dict(xImpressDoc))
- print(xImpressDoc.getChildren())
+ self.ui_test.create_doc_in_start_center("impress")
- xEditWin = xImpressDoc.getChild("impress_win")
+ xImpressDoc = self.xUITest.getTopFocusWindow()
+ print(get_state_as_dict(xImpressDoc))
+ print(xImpressDoc.getChildren())
- time.sleep(1)
+ xEditWin = xImpressDoc.getChild("impress_win")
- print(get_state_as_dict(xEditWin))
+ time.sleep(1)
- ui_test.close_doc()
+ print(get_state_as_dict(xEditWin))
-def select_object(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+ self.ui_test.close_doc()
- ui_test = UITest(xUITest, xContext)
+ def test_select_object(self):
- ui_test.create_doc_in_start_center("impress")
+ self.ui_test.create_doc_in_start_center("impress")
- xImpressDoc = xUITest.getTopFocusWindow()
- print(get_state_as_dict(xImpressDoc))
- print(xImpressDoc.getChildren())
+ xImpressDoc = self.xUITest.getTopFocusWindow()
+ print(get_state_as_dict(xImpressDoc))
+ print(xImpressDoc.getChildren())
- xEditWin = xImpressDoc.getChild("impress_win")
+ xEditWin = xImpressDoc.getChild("impress_win")
- xEditWin.executeAction("SELECT", mkPropertyValues({"OBJECT":"Unnamed Drawinglayer object 1"}))
- time.sleep(1)
- xEditWin.executeAction("DESELECT", tuple())
+ xEditWin.executeAction("SELECT", mkPropertyValues({"OBJECT":"Unnamed Drawinglayer object 1"}))
+ time.sleep(1)
+ xEditWin.executeAction("DESELECT", tuple())
- time.sleep(1)
+ time.sleep(1)
- print(get_state_as_dict(xEditWin))
+ print(get_state_as_dict(xEditWin))
- ui_test.close_doc()
+ self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 19e380cfd980233b71915f34a1ba83d24bd5303e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Jun 22 05:57:06 2016 +0200
uitest: move the demo ui tests to the new unittest approach
Change-Id: I70222d701191f28f9dffb3bfdfbb7510d64d0251
diff --git a/uitest/demo_ui/checkbox.py b/uitest/demo_ui/checkbox.py
index 5cc456b..a15d686 100644
--- a/uitest/demo_ui/checkbox.py
+++ b/uitest/demo_ui/checkbox.py
@@ -9,6 +9,8 @@ from uitest_helper import UITest
from helper import mkPropertyValues
+from UITestCase import UITestCase
+
import time
try:
@@ -21,22 +23,20 @@ except ImportError:
print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
raise
-def toggle_checkbox(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+class CheckBoxTest(UITestCase):
- ui_test = UITest(xUITest, xContext)
+ def test_toggle_checkbox(self):
- ui_test.create_doc_in_start_center("calc")
+ self.ui_test.create_doc_in_start_center("calc")
- ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
- xCellsDlg = xUITest.getTopFocusWindow()
- xNegativeNumRedCB = xCellsDlg.getChild("negnumred")
- xNegativeNumRedCB.executeAction("CLICK",tuple())
+ self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
+ xCellsDlg = self.xUITest.getTopFocusWindow()
+ xNegativeNumRedCB = xCellsDlg.getChild("negnumred")
+ xNegativeNumRedCB.executeAction("CLICK",tuple())
- okBtn = xCellsDlg.getChild("ok")
- okBtn.executeAction("CLICK", tuple())
+ okBtn = xCellsDlg.getChild("ok")
+ okBtn.executeAction("CLICK", tuple())
- ui_test.close_doc()
+ self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uitest/demo_ui/combobox.py b/uitest/demo_ui/combobox.py
index 6df980b..b33644b 100644
--- a/uitest/demo_ui/combobox.py
+++ b/uitest/demo_ui/combobox.py
@@ -9,25 +9,25 @@ from uitest_helper import UITest
from helper import mkPropertyValues
-def select_entry_pos(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+from UITestCase import UITestCase
- ui_test = UITest(xUITest, xContext)
+class ComboBoxTest(UITestCase):
- ui_test.create_doc_in_start_center("calc")
+ def test_select_entry_pos(self):
- ui_test.execute_modeless_dialog_through_command(".uno:AddName")
- xAddNameDlg = xUITest.getTopFocusWindow()
+ self.ui_test.create_doc_in_start_center("calc")
- scopeCB = xAddNameDlg.getChild("scope")
- props = {"POS": "1"}
- actionProps = mkPropertyValues(props)
- scopeCB.executeAction("SELECT", actionProps)
+ self.ui_test.execute_modeless_dialog_through_command(".uno:AddName")
+ xAddNameDlg = self.xUITest.getTopFocusWindow()
- xCancelBtn = xAddNameDlg.getChild("cancel")
- xCancelBtn.executeAction("CLICK", tuple())
+ scopeCB = xAddNameDlg.getChild("scope")
+ props = {"POS": "1"}
+ actionProps = mkPropertyValues(props)
+ scopeCB.executeAction("SELECT", actionProps)
- ui_test.close_doc()
+ xCancelBtn = xAddNameDlg.getChild("cancel")
+ xCancelBtn.executeAction("CLICK", tuple())
+
+ self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uitest/demo_ui/demo_ui.txt b/uitest/demo_ui/demo_ui.txt
deleted file mode 100644
index 512da3f..0000000
--- a/uitest/demo_ui/demo_ui.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-demo_ui.checkbox.toggle_checkbox
-demo_ui.combobox.select_entry_pos
-demo_ui.edit.type_text
-demo_ui.gridwin.select_cell
-demo_ui.gridwin.select_range
-demo_ui.gridwin.extend_range
-demo_ui.listbox.select_entry_pos
-demo_ui.listbox.select_entry_text
-demo_ui.tabcontrol.select_pos
-demo_ui.tabdialog.select_tab_page_pos
-demo_ui.tabdialog.select_tab_page_name
-demo_ui.treelist.expand
-demo_ui.spinfield.up
-demo_ui.spinfield.down
-demo_ui.spinfield.text
diff --git a/uitest/demo_ui/edit.py b/uitest/demo_ui/edit.py
index f418a36..8ddbb1c5 100644
--- a/uitest/demo_ui/edit.py
+++ b/uitest/demo_ui/edit.py
@@ -9,6 +9,8 @@ from uitest_helper import UITest
from helper import mkPropertyValues
+from UITestCase import UITestCase
+
try:
import pyuno
import uno
@@ -19,26 +21,24 @@ except ImportError:
print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
raise
-def type_text(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+class EditTest(UITestCase):
- ui_test = UITest(xUITest, xContext)
+ def test_type_text(self):
- ui_test.create_doc_in_start_center("calc")
+ self.ui_test.create_doc_in_start_center("calc")
- ui_test.execute_modeless_dialog_through_command(".uno:AddName")
- xAddNameDlg = xUITest.getTopFocusWindow()
+ self.ui_test.execute_modeless_dialog_through_command(".uno:AddName")
+ xAddNameDlg = self.xUITest.getTopFocusWindow()
- xEdit = xAddNameDlg.getChild("edit")
+ xEdit = xAddNameDlg.getChild("edit")
- props = {"TEXT": "simpleRangeName"}
- actionProps = mkPropertyValues(props)
- xEdit.executeAction("TYPE", actionProps)
+ props = {"TEXT": "simpleRangeName"}
+ actionProps = mkPropertyValues(props)
+ xEdit.executeAction("TYPE", actionProps)
- xAddBtn = xAddNameDlg.getChild("cancel")
- xAddBtn.executeAction("CLICK", tuple())
+ xAddBtn = xAddNameDlg.getChild("cancel")
+ xAddBtn.executeAction("CLICK", tuple())
- ui_test.close_doc()
+ self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uitest/demo_ui/gridwin.py b/uitest/demo_ui/gridwin.py
index 4ca63ac..5c2fae9 100644
--- a/uitest/demo_ui/gridwin.py
+++ b/uitest/demo_ui/gridwin.py
@@ -9,6 +9,8 @@ from uitest_helper import UITest
from helper import mkPropertyValues
+from UITestCase import UITestCase
+
import time
try:
@@ -21,53 +23,43 @@ except ImportError:
print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
raise
-def select_cell(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
-
- ui_test = UITest(xUITest, xContext)
-
- ui_test.create_doc_in_start_center("calc")
- xCalcDoc = xUITest.getTopFocusWindow()
- xGridWindow = xCalcDoc.getChild("grid_window")
+class GridWinTest(UITestCase):
- selectProps = mkPropertyValues({"CELL": "B10"})
- xGridWindow.executeAction("SELECT", selectProps)
+ def test_select_cell(self):
- ui_test.close_doc()
+ self.ui_test.create_doc_in_start_center("calc")
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ xGridWindow = xCalcDoc.getChild("grid_window")
-def select_range(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+ selectProps = mkPropertyValues({"CELL": "B10"})
+ xGridWindow.executeAction("SELECT", selectProps)
- ui_test = UITest(xUITest, xContext)
+ self.ui_test.close_doc()
- ui_test.create_doc_in_start_center("calc")
- xCalcDoc = xUITest.getTopFocusWindow()
- xGridWindow = xCalcDoc.getChild("grid_window")
+ def test_select_range(self):
- selectProps = mkPropertyValues({"RANGE": "B10:C20"})
- xGridWindow.executeAction("SELECT", selectProps)
+ self.ui_test.create_doc_in_start_center("calc")
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ xGridWindow = xCalcDoc.getChild("grid_window")
- ui_test.close_doc()
+ selectProps = mkPropertyValues({"RANGE": "B10:C20"})
+ xGridWindow.executeAction("SELECT", selectProps)
-def extend_range(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+ self.ui_test.close_doc()
- ui_test = UITest(xUITest, xContext)
+ def test_extend_range(self):
- ui_test.create_doc_in_start_center("calc")
- xTopWindow = xUITest.getTopFocusWindow()
+ self.ui_test.create_doc_in_start_center("calc")
+ xTopWindow = self.xUITest.getTopFocusWindow()
- xGridWindow = xTopWindow.getChild("grid_window")
+ xGridWindow = xTopWindow.getChild("grid_window")
- selectProps = mkPropertyValues({"RANGE": "B10:C20"})
- xGridWindow.executeAction("SELECT", selectProps)
+ selectProps = mkPropertyValues({"RANGE": "B10:C20"})
+ xGridWindow.executeAction("SELECT", selectProps)
- select2Props = mkPropertyValues({"RANGE": "D3:F5", "EXTEND": "true"})
- xGridWindow.executeAction("SELECT", select2Props)
+ select2Props = mkPropertyValues({"RANGE": "D3:F5", "EXTEND": "true"})
+ xGridWindow.executeAction("SELECT", select2Props)
- ui_test.close_doc()
+ self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uitest/demo_ui/listbox.py b/uitest/demo_ui/listbox.py
index 03a4c9e..f6857c2 100644
--- a/uitest/demo_ui/listbox.py
+++ b/uitest/demo_ui/listbox.py
@@ -9,47 +9,43 @@ from uitest_helper import UITest
from helper import mkPropertyValues
-def select_entry_pos(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+from UITestCase import UITestCase
- ui_test = UITest(xUITest, xContext)
+class ListBoxTest(UITestCase):
- ui_test.create_doc_in_start_center("calc")
+ def test_select_entry_pos(self):
- ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
- xCellsDlg = xUITest.getTopFocusWindow()
+ self.ui_test.create_doc_in_start_center("calc")
- categoryLB = xCellsDlg.getChild("categorylb")
- props = {"POS": "4"}
- actionProps = mkPropertyValues(props)
- categoryLB.executeAction("SELECT", actionProps)
+ self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
+ xCellsDlg = self.xUITest.getTopFocusWindow()
- xOkBtn = xCellsDlg.getChild("ok")
- xOkBtn.executeAction("CLICK", tuple())
+ categoryLB = xCellsDlg.getChild("categorylb")
+ props = {"POS": "4"}
+ actionProps = mkPropertyValues(props)
+ categoryLB.executeAction("SELECT", actionProps)
- ui_test.close_doc()
+ xOkBtn = xCellsDlg.getChild("ok")
+ xOkBtn.executeAction("CLICK", tuple())
-def select_entry_text(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+ self.ui_test.close_doc()
- ui_test = UITest(xUITest, xContext)
+ def test_select_entry_text(self):
- ui_test.create_doc_in_start_center("calc")
+ self.ui_test.create_doc_in_start_center("calc")
- ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
- xCellsDlg = xUITest.getTopFocusWindow()
+ self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
+ xCellsDlg = self.xUITest.getTopFocusWindow()
- categoryLB = xCellsDlg.getChild("categorylb")
- props = {"TEXT": "Time"}
+ categoryLB = xCellsDlg.getChild("categorylb")
+ props = {"TEXT": "Time"}
- actionProps = mkPropertyValues(props)
- categoryLB.executeAction("SELECT", actionProps)
+ actionProps = mkPropertyValues(props)
+ categoryLB.executeAction("SELECT", actionProps)
- xOkBtn = xCellsDlg.getChild("ok")
- xOkBtn.executeAction("CLICK", tuple())
+ xOkBtn = xCellsDlg.getChild("ok")
+ xOkBtn.executeAction("CLICK", tuple())
- ui_test.close_doc()
+ self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uitest/demo_ui/radiobutton.py b/uitest/demo_ui/radiobutton.py
index bd8b1db..fef71f5 100644
--- a/uitest/demo_ui/radiobutton.py
+++ b/uitest/demo_ui/radiobutton.py
@@ -9,6 +9,8 @@ from uitest_helper import UITest
from helper import mkPropertyValues
+from UITestCase import UITestCase
+
import time
try:
@@ -21,23 +23,21 @@ except ImportError:
print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
raise
-def toggle_radiobutton(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+class RadioButtonTest(UITestCase):
- ui_test = UITest(xUITest, xContext)
+ def test_toggle_radiobutton(self):
- ui_test.create_doc_in_start_center("calc")
+ self.ui_test.create_doc_in_start_center("calc")
- ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
- xCellsDlg = xUITest.getTopFocusWindow()
- xNegativeNumRedCB = xCellsDlg.getChild("negnumred")
- xNegativeNumRedCB.executeAction("CLICK",tuple())
+ self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
+ xCellsDlg = self.xUITest.getTopFocusWindow()
+ xNegativeNumRedCB = xCellsDlg.getChild("negnumred")
+ xNegativeNumRedCB.executeAction("CLICK",tuple())
- okBtn = xCellsDlg.getChild("ok")
- okBtn.executeAction("CLICK", tuple())
+ okBtn = xCellsDlg.getChild("ok")
+ okBtn.executeAction("CLICK", tuple())
- ui_test.close_doc()
+ self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uitest/demo_ui/spinfield.py b/uitest/demo_ui/spinfield.py
index 4adde0c..761c9ac 100644
--- a/uitest/demo_ui/spinfield.py
+++ b/uitest/demo_ui/spinfield.py
@@ -12,6 +12,8 @@ from uitest_helper import get_state_as_dict
import time
+from UITestCase import UITestCase
+
try:
import pyuno
import uno
@@ -22,82 +24,72 @@ except ImportError:
print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
raise
-def up(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
-
- ui_test = UITest(xUITest, xContext)
-
- ui_test.create_doc_in_start_center("calc")
+class SpinFieldTest(UITestCase):
- ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
- xCellsDlg = xUITest.getTopFocusWindow()
+ def test_up(self):
- # select the numbers tab page
- xCellsDlg.executeAction("SELECT", mkPropertyValues({"POS": "0"}))
-
- xDecimalPlaces = xCellsDlg.getChild("leadzerosed")
- xDecimalPlaces.executeAction("UP", tuple())
+ self.ui_test.create_doc_in_start_center("calc")
- decimal_places_state = get_state_as_dict(xDecimalPlaces)
- assert(decimal_places_state["Text"] == "2")
+ self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
+ xCellsDlg = self.xUITest.getTopFocusWindow()
- okBtn = xCellsDlg.getChild("ok")
- okBtn.executeAction("CLICK", tuple())
+ # select the numbers tab page
+ xCellsDlg.executeAction("SELECT", mkPropertyValues({"POS": "0"}))
+
+ xDecimalPlaces = xCellsDlg.getChild("leadzerosed")
+ xDecimalPlaces.executeAction("UP", tuple())
- ui_test.close_doc()
+ decimal_places_state = get_state_as_dict(xDecimalPlaces)
+ assert(decimal_places_state["Text"] == "2")
-def down(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+ okBtn = xCellsDlg.getChild("ok")
+ okBtn.executeAction("CLICK", tuple())
- ui_test = UITest(xUITest, xContext)
+ self.ui_test.close_doc()
- ui_test.create_doc_in_start_center("calc")
+ def test_down(self):
- ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
- xCellsDlg = xUITest.getTopFocusWindow()
+ self.ui_test.create_doc_in_start_center("calc")
- # select the numbers tab page
- xCellsDlg.executeAction("SELECT", mkPropertyValues({"POS": "0"}))
-
- xDecimalPlaces = xCellsDlg.getChild("leadzerosed")
- xDecimalPlaces.executeAction("UP", tuple())
- xDecimalPlaces.executeAction("UP", tuple())
+ self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
+ xCellsDlg = self.xUITest.getTopFocusWindow()
- decimal_places_state = get_state_as_dict(xDecimalPlaces)
- assert(decimal_places_state["Text"] == "3")
-
- xDecimalPlaces.executeAction("DOWN", tuple())
+ # select the numbers tab page
+ xCellsDlg.executeAction("SELECT", mkPropertyValues({"POS": "0"}))
+
+ xDecimalPlaces = xCellsDlg.getChild("leadzerosed")
+ xDecimalPlaces.executeAction("UP", tuple())
+ xDecimalPlaces.executeAction("UP", tuple())
- decimal_places_state = get_state_as_dict(xDecimalPlaces)
- assert(decimal_places_state["Text"] == "2")
+ decimal_places_state = get_state_as_dict(xDecimalPlaces)
+ assert(decimal_places_state["Text"] == "3")
+
+ xDecimalPlaces.executeAction("DOWN", tuple())
- okBtn = xCellsDlg.getChild("ok")
- okBtn.executeAction("CLICK", tuple())
+ decimal_places_state = get_state_as_dict(xDecimalPlaces)
+ assert(decimal_places_state["Text"] == "2")
- ui_test.close_doc()
+ okBtn = xCellsDlg.getChild("ok")
+ okBtn.executeAction("CLICK", tuple())
-def text(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+ self.ui_test.close_doc()
- ui_test = UITest(xUITest, xContext)
+ def test_text(self):
- ui_test.create_doc_in_start_center("calc")
+ self.ui_test.create_doc_in_start_center("calc")
- ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
- xCellsDlg = xUITest.getTopFocusWindow()
-
- xDecimalPlaces = xCellsDlg.getChild("leadzerosed")
- xDecimalPlaces.executeAction("TYPE", mkPropertyValues({"TEXT": "4"}))
+ self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
+ xCellsDlg = self.xUITest.getTopFocusWindow()
+
+ xDecimalPlaces = xCellsDlg.getChild("leadzerosed")
+ xDecimalPlaces.executeAction("TYPE", mkPropertyValues({"TEXT": "4"}))
- decimal_places_state = get_state_as_dict(xDecimalPlaces)
- assert(decimal_places_state["Text"] == "41")
+ decimal_places_state = get_state_as_dict(xDecimalPlaces)
+ assert(decimal_places_state["Text"] == "41")
- okBtn = xCellsDlg.getChild("ok")
- okBtn.executeAction("CLICK", tuple())
+ okBtn = xCellsDlg.getChild("ok")
+ okBtn.executeAction("CLICK", tuple())
- ui_test.close_doc()
+ self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uitest/demo_ui/tabcontrol.py b/uitest/demo_ui/tabcontrol.py
index b9d79ad..9ef9d7b 100644
--- a/uitest/demo_ui/tabcontrol.py
+++ b/uitest/demo_ui/tabcontrol.py
@@ -13,6 +13,8 @@ from helper import mkPropertyValues
from uihelper.calc import enter_text_to_cell
+from UITestCase import UITestCase
+
try:
import pyuno
import uno
@@ -23,32 +25,30 @@ except ImportError:
print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
raise
-def select_pos(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+class TabControlTest(UITestCase):
- ui_test = UITest(xUITest, xContext)
+ def test_select_pos(self):
- ui_test.create_doc_in_start_center("calc")
+ self.ui_test.create_doc_in_start_center("calc")
- xCalcDoc = xUITest.getTopFocusWindow()
- xGridWindow = xCalcDoc.getChild("grid_window")
- enter_text_to_cell(xGridWindow, "B2", "=2+3+4")
- xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "B2"}))
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ xGridWindow = xCalcDoc.getChild("grid_window")
+ enter_text_to_cell(xGridWindow, "B2", "=2+3+4")
+ xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "B2"}))
- ui_test.execute_modeless_dialog_through_command(".uno:FunctionDialog")
+ self.ui_test.execute_modeless_dialog_through_command(".uno:FunctionDialog")
- xFunctionDlg = xUITest.getTopFocusWindow()
+ xFunctionDlg = self.xUITest.getTopFocusWindow()
- xTabs = xFunctionDlg.getChild("tabs")
- xTabs.executeAction("SELECT", mkPropertyValues({"POS":"1"}))
+ xTabs = xFunctionDlg.getChild("tabs")
+ xTabs.executeAction("SELECT", mkPropertyValues({"POS":"1"}))
- time.sleep(1)
+ time.sleep(1)
- xCancelBtn = xFunctionDlg.getChild("cancel")
- xCancelBtn.executeAction("CLICK", tuple())
+ xCancelBtn = xFunctionDlg.getChild("cancel")
+ xCancelBtn.executeAction("CLICK", tuple())
- ui_test.close_doc()
+ self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uitest/demo_ui/tabdialog.py b/uitest/demo_ui/tabdialog.py
index 09bf600..99e7b9f 100644
--- a/uitest/demo_ui/tabdialog.py
+++ b/uitest/demo_ui/tabdialog.py
@@ -11,44 +11,40 @@ from helper import mkPropertyValues
import time
-def select_tab_page_pos(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+from UITestCase import UITestCase
- ui_test = UITest(xUITest, xContext)
+class TabDialogTest(UITestCase):
- ui_test.create_doc_in_start_center("calc")
+ def test_select_tab_page_pos(self):
- ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
- xCellsDlg = xUITest.getTopFocusWindow()
+ self.ui_test.create_doc_in_start_center("calc")
- props = {"POS": "1"}
- propsUNO = mkPropertyValues(props)
- xCellsDlg.executeAction("SELECT", propsUNO)
+ self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
+ xCellsDlg = self.xUITest.getTopFocusWindow()
- xOkBtn = xCellsDlg.getChild("ok")
- xOkBtn.executeAction("CLICK", tuple())
+ props = {"POS": "1"}
+ propsUNO = mkPropertyValues(props)
+ xCellsDlg.executeAction("SELECT", propsUNO)
- ui_test.close_doc()
+ xOkBtn = xCellsDlg.getChild("ok")
+ xOkBtn.executeAction("CLICK", tuple())
-def select_tab_page_name(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+ self.ui_test.close_doc()
- ui_test = UITest(xUITest, xContext)
+ def test_select_tab_page_name(self):
- ui_test.create_doc_in_start_center("calc")
+ self.ui_test.create_doc_in_start_center("calc")
- ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
- xCellsDlg = xUITest.getTopFocusWindow()
+ self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
+ xCellsDlg = self.xUITest.getTopFocusWindow()
- props = {"NAME": "Borders"}
- propsUNO = mkPropertyValues(props)
- xCellsDlg.executeAction("SELECT", propsUNO)
+ props = {"NAME": "Borders"}
+ propsUNO = mkPropertyValues(props)
+ xCellsDlg.executeAction("SELECT", propsUNO)
- xOkBtn = xCellsDlg.getChild("ok")
- xOkBtn.executeAction("CLICK", tuple())
+ xOkBtn = xCellsDlg.getChild("ok")
+ xOkBtn.executeAction("CLICK", tuple())
- ui_test.close_doc()
+ self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uitest/demo_ui/treelist.py b/uitest/demo_ui/treelist.py
index 4523dca..f1681cd 100644
--- a/uitest/demo_ui/treelist.py
+++ b/uitest/demo_ui/treelist.py
@@ -14,6 +14,8 @@ from uihelper.calc import enter_text_to_cell
from uitest_helper import get_state_as_dict
+from UITestCase import UITestCase
+
try:
import pyuno
import uno
@@ -24,41 +26,39 @@ except ImportError:
print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
raise
-def expand(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+class TreeListTest(UITestCase):
- ui_test = UITest(xUITest, xContext)
+ def test_expand(self):
- ui_test.create_doc_in_start_center("calc")
+ self.ui_test.create_doc_in_start_center("calc")
- xCalcDoc = xUITest.getTopFocusWindow()
- xGridWindow = xCalcDoc.getChild("grid_window")
- enter_text_to_cell(xGridWindow, "B2", "=2+3+4")
- xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "B2"}))
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ xGridWindow = xCalcDoc.getChild("grid_window")
+ enter_text_to_cell(xGridWindow, "B2", "=2+3+4")
+ xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "B2"}))
- ui_test.execute_modeless_dialog_through_command(".uno:FunctionDialog")
+ self.ui_test.execute_modeless_dialog_through_command(".uno:FunctionDialog")
- xFunctionDlg = xUITest.getTopFocusWindow()
+ xFunctionDlg = self.xUITest.getTopFocusWindow()
- xTabs = xFunctionDlg.getChild("tabs")
- xTabs.executeAction("SELECT", mkPropertyValues({"POS":"1"}))
+ xTabs = xFunctionDlg.getChild("tabs")
+ xTabs.executeAction("SELECT", mkPropertyValues({"POS":"1"}))
- xTreelist = xTabs.getChild("struct")
+ xTreelist = xTabs.getChild("struct")
- xTreeEntry = xTreelist.getChild('0')
+ xTreeEntry = xTreelist.getChild('0')
- xTreeEntry.executeAction("COLLAPSE", tuple())
+ xTreeEntry.executeAction("COLLAPSE", tuple())
- time.sleep(1)
+ time.sleep(1)
- xTreeEntry.executeAction("EXPAND", tuple())
+ xTreeEntry.executeAction("EXPAND", tuple())
- time.sleep(1)
+ time.sleep(1)
- xCancelBtn = xFunctionDlg.getChild("cancel")
- xCancelBtn.executeAction("CLICK", tuple())
+ xCancelBtn = xFunctionDlg.getChild("cancel")
+ xCancelBtn.executeAction("CLICK", tuple())
- ui_test.close_doc()
+ self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit d8b376adba93a48e77ec9e81c96744d1e4997d88
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Jun 22 05:46:59 2016 +0200
uitest: convert all calc demos to the unittest based approach
Change-Id: I6ad7898f92c74f37ed2936337d6570904860d535
diff --git a/uitest/calc_tests/calc_demo.txt b/uitest/calc_tests/calc_demo.txt
deleted file mode 100644
index 1c2629e..0000000
--- a/uitest/calc_tests/calc_demo.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-calc_tests.create_range_name.create_range_name
-calc_tests.create_range_name.create_local_range_name
-calc_tests.function_wizard.open_function_wizard
-calc_tests.gridwindow.input
diff --git a/uitest/calc_tests/create_range_name.py b/uitest/calc_tests/create_range_name.py
index a2726a3..01d01fd 100644
--- a/uitest/calc_tests/create_range_name.py
+++ b/uitest/calc_tests/create_range_name.py
@@ -9,6 +9,8 @@ from uitest_helper import UITest
from helper import mkPropertyValues
+from UITestCase import UITestCase
+
try:
import pyuno
import uno
@@ -19,54 +21,48 @@ except ImportError:
print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
raise
-def create_range_name(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
-
- ui_test = UITest(xUITest, xContext)
+class CreateRangeNameTest(UITestCase):
- ui_test.create_doc_in_start_center("calc")
+ def test_create_range_name(self):
- ui_test.execute_modeless_dialog_through_command(".uno:AddName")
+ self.ui_test.create_doc_in_start_center("calc")
- xAddNameDlg = xUITest.getTopFocusWindow()
+ self.ui_test.execute_modeless_dialog_through_command(".uno:AddName")
- props = {"TEXT": "simpleRangeName"}
- actionProps = mkPropertyValues(props)
+ xAddNameDlg = self.xUITest.getTopFocusWindow()
- xEdit = xAddNameDlg.getChild("edit")
- xEdit.executeAction("TYPE", actionProps)
- xAddBtn = xAddNameDlg.getChild("add")
- xAddBtn.executeAction("CLICK", tuple())
+ props = {"TEXT": "simpleRangeName"}
+ actionProps = mkPropertyValues(props)
- ui_test.close_doc()
+ xEdit = xAddNameDlg.getChild("edit")
+ xEdit.executeAction("TYPE", actionProps)
+ xAddBtn = xAddNameDlg.getChild("add")
+ xAddBtn.executeAction("CLICK", tuple())
-def create_local_range_name(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+ self.ui_test.close_doc()
- ui_test = UITest(xUITest, xContext)
+ def test_create_local_range_name(self):
- ui_test.create_doc_in_start_center("calc")
+ self.ui_test.create_doc_in_start_center("calc")
- ui_test.execute_modeless_dialog_through_command(".uno:AddName")
+ self.ui_test.execute_modeless_dialog_through_command(".uno:AddName")
- xAddNameDlg = xUITest.getTopFocusWindow()
+ xAddNameDlg = self.xUITest.getTopFocusWindow()
- props = {"TEXT": "simpleRangeName"}
- actionProps = mkPropertyValues(props)
+ props = {"TEXT": "simpleRangeName"}
+ actionProps = mkPropertyValues(props)
- xEdit = xAddNameDlg.getChild("edit")
- xEdit.executeAction("TYPE", actionProps)
+ xEdit = xAddNameDlg.getChild("edit")
+ xEdit.executeAction("TYPE", actionProps)
- xScope = xAddNameDlg.getChild("scope")
- props = {"POS": "1"}
- scopeProps = mkPropertyValues(props)
- xScope.executeAction("SELECT", scopeProps)
+ xScope = xAddNameDlg.getChild("scope")
+ props = {"POS": "1"}
+ scopeProps = mkPropertyValues(props)
+ xScope.executeAction("SELECT", scopeProps)
- xAddBtn = xAddNameDlg.getChild("add")
- xAddBtn.executeAction("CLICK", tuple())
+ xAddBtn = xAddNameDlg.getChild("add")
+ xAddBtn.executeAction("CLICK", tuple())
- ui_test.close_doc()
+ self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uitest/calc_tests/function_wizard.py b/uitest/calc_tests/function_wizard.py
index 1aadbe5..bbdb0c1 100644
--- a/uitest/calc_tests/function_wizard.py
+++ b/uitest/calc_tests/function_wizard.py
@@ -10,6 +10,8 @@ from uitest_helper import UITest
from helper import mkPropertyValues
import time
+from UITestCase import UITestCase
+
try:
import pyuno
import uno
@@ -20,25 +22,21 @@ except ImportError:
print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
raise
-# tdf#98427
-def open_function_wizard(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
-
- ui_test = UITest(xUITest, xContext)
-
- ui_test.create_doc_in_start_center("calc")
+class FunctionWizardTest(UITestCase):
+ # tdf#98427
+ def test_open_function_wizard(self):
+ self.ui_test.create_doc_in_start_center("calc")
- ui_test.execute_modeless_dialog_through_command(".uno:FunctionDialog")
+ self.ui_test.execute_modeless_dialog_through_command(".uno:FunctionDialog")
- xFunctionDlg = xUITest.getTopFocusWindow()
+ xFunctionDlg = self.xUITest.getTopFocusWindow()
- xArrayChkBox = xFunctionDlg.getChild("array")
- xArrayChkBox.executeAction("CLICK", tuple())
+ xArrayChkBox = xFunctionDlg.getChild("array")
+ xArrayChkBox.executeAction("CLICK", tuple())
- xCancelBtn = xFunctionDlg.getChild("cancel")
- xCancelBtn.executeAction("CLICK", tuple())
+ xCancelBtn = xFunctionDlg.getChild("cancel")
+ xCancelBtn.executeAction("CLICK", tuple())
- ui_test.close_doc()
+ self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uitest/calc_tests/gridwin.py b/uitest/calc_tests/gridwin.py
new file mode 100644
index 0000000..7077f4b
--- /dev/null
+++ b/uitest/calc_tests/gridwin.py
@@ -0,0 +1,45 @@
+# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+from uitest_helper import UITest
+
+from helper import mkPropertyValues
+
+from UITestCase import UITestCase
+
+import time
+
+try:
+ import pyuno
+ import uno
+ import unohelper
+except ImportError:
+ print("pyuno not found: try to set PYTHONPATH and URE_BOOTSTRAP variables")
+ print("PYTHONPATH=/installation/opt/program")
+ print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
+ raise
+
+class GridWinTest(UITestCase):
+
+ def test_select_object(self):
+
+ self.ui_test.create_doc_in_start_center("calc")
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ xGridWindow = xCalcDoc.getChild("grid_window")
+
+ selectProps = mkPropertyValues({"CELL": "B10"})
+ xGridWindow.executeAction("SELECT", selectProps)
+
+ xGridWindow.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
+
+ xGridWindow.executeAction("ACTIVATE", tuple())
+
+ xGridWindow.executeAction("DESELECT", tuple())
+
+ self.ui_test.close_doc()
+
+# vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uitest/calc_tests/gridwindow.py b/uitest/calc_tests/gridwindow.py
index 1f01ec9..1b63fe5 100644
--- a/uitest/calc_tests/gridwindow.py
+++ b/uitest/calc_tests/gridwindow.py
@@ -11,6 +11,8 @@ from helper import mkPropertyValues
from uihelper.calc import enter_text_to_cell
+from UITestCase import UITestCase
+
import time
try:
@@ -23,43 +25,37 @@ except ImportError:
print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
raise
-def input(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
-
- ui_test = UITest(xUITest, xContext)
+class GridWindowTest(UITestCase):
- ui_test.create_doc_in_start_center("calc")
- xTopWindow = xUITest.getTopFocusWindow()
+ def test_input(self):
- xGridWindow = xTopWindow.getChild("grid_window")
+ self.ui_test.create_doc_in_start_center("calc")
+ xTopWindow = self.xUITest.getTopFocusWindow()
- enter_text_to_cell(xGridWindow, "C3", "=A1")
- enter_text_to_cell(xGridWindow, "A1", "2")
+ xGridWindow = xTopWindow.getChild("grid_window")
- time.sleep(2)
+ enter_text_to_cell(xGridWindow, "C3", "=A1")
+ enter_text_to_cell(xGridWindow, "A1", "2")
- ui_test.close_doc()
+ time.sleep(2)
-def special_keys(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+ self.ui_test.close_doc()
- ui_test = UITest(xUITest, xContext)
+ def test_special_keys(self):
- ui_test.create_doc_in_start_center("calc")
- xTopWindow = xUITest.getTopFocusWindow()
+ self.ui_test.create_doc_in_start_center("calc")
+ xTopWindow = self.xUITest.getTopFocusWindow()
- xGridWindow = xTopWindow.getChild("grid_window")
+ xGridWindow = xTopWindow.getChild("grid_window")
- selectProps = mkPropertyValues({"CELL": "C3"})
- xGridWindow.executeAction("SELECT", selectProps)
+ selectProps = mkPropertyValues({"CELL": "C3"})
+ xGridWindow.executeAction("SELECT", selectProps)
- typeProps = mkPropertyValues({"KEYCODE": "CTRL+DOWN"})
- xGridWindow.executeAction("TYPE", typeProps)
+ typeProps = mkPropertyValues({"KEYCODE": "CTRL+DOWN"})
+ xGridWindow.executeAction("TYPE", typeProps)
- time.sleep(2)
+ time.sleep(2)
- ui_test.close_doc()
+ self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 4fa28812f3574efaca42769e9e4ff28f7d545bd8
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Jun 22 05:27:22 2016 +0200
uitest: start the switch to python's unittest
Change-Id: Ic6e0d99a567b7080928accb61ed036b1c25ec7ff
diff --git a/solenv/gbuild/UITest.mk b/solenv/gbuild/UITest.mk
index bbe76f6..dc6ea53 100644
--- a/solenv/gbuild/UITest.mk
+++ b/solenv/gbuild/UITest.mk
@@ -21,7 +21,7 @@ gb_UITest_EXECUTABLE_GDB := $(PYTHON_FOR_BUILD)
gb_UITest_DEPS :=
endif
-gb_UITest_COMMAND := $(gb_UITest_EXECUTABLE) $(SRCDIR)/uitest/main.py
+gb_UITest_COMMAND := $(gb_UITest_EXECUTABLE) $(SRCDIR)/uitest/test_main.py
.PHONY : $(call gb_UITest_get_clean_target,%)
$(call gb_UITest_get_clean_target,%) :
@@ -52,13 +52,12 @@ $(call gb_UITest_get_target,%) :| $(gb_UITest_DEPS)
$(gb_UITest_COMMAND) \
--soffice=path:$(INSTROOT)/$(LIBO_BIN_FOLDER)/soffice \
--userdir=$(call gb_Helper_make_url,$(dir $(call gb_UITest_get_target,$*))user) \
- --file=$(SRCDIR)/uitest/$(strip $(MODULES)) \
- $(if $(gb_CppunitTest__interactive),, \
- > $@.log 2>&1 \
- || ($(if $(value gb_CppunitTest_postprocess), \
- RET=$$?; \
- $(call gb_CppunitTest_postprocess,$(gb_UITest_EXECUTABLE_GDB),$@.core,$$RET) >> $@.log 2>&1;) \
- cat $@.log; $(gb_UITest_UNITTESTFAILED) Python $*))))
+ --dir=$(SRCDIR)/uitest/$(strip $(MODULES)) \
+ > $@.log 2>&1 \
+ || ($(if $(value gb_CppunitTest_postprocess), \
+ RET=$$?; \
+ $(call gb_CppunitTest_postprocess,$(gb_UITest_EXECUTABLE_GDB),$@.core,$$RET) >> $@.log 2>&1;) \
+ cat $@.log; $(gb_UITest_UNITTESTFAILED) Python $*)))
# always use udkapi and URE services
define gb_UITest_UITest
diff --git a/uitest/UITestCase.py b/uitest/UITestCase.py
new file mode 100644
index 0000000..5628d9d
--- /dev/null
+++ b/uitest/UITestCase.py
@@ -0,0 +1,32 @@
+# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+import unittest
+
+from uitest_helper import UITest
+
+from connection import PersistentConnection, OfficeConnection
+
+class UITestCase(unittest.TestCase):
+
+ def __init__(self, test_name, opts):
+ unittest.TestCase.__init__(self, test_name)
+ self.opts = opts
+
+ def setUp(self):
+ self.connection = PersistentConnection(self.opts)
+ self.connection.setUp()
+ self.xContext = self.connection.getContext()
+ self.xUITest = self.xContext.ServiceManager.createInstanceWithContext(
+ "org.libreoffice.uitest.UITest", self.xContext)
+
+ self.ui_test = UITest(self.xUITest, self.xContext)
+
+ def tearDown(self):
+ self.connection.tearDown()
+
+# vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uitest/calc_tests/about_test.py b/uitest/calc_tests/about_test.py
index b512084..df90e7d 100644
--- a/uitest/calc_tests/about_test.py
+++ b/uitest/calc_tests/about_test.py
@@ -5,25 +5,23 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
-import time
-
from uitest_helper import UITest
-def test_about_dlg(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+from UITestCase import UITestCase
+
+class AboutDlgTest(UITestCase):
- ui_test = UITest(xUITest, xContext)
+ def test_about_dlg(self):
- ui_test.create_doc_in_start_center("calc")
+ self.ui_test.create_doc_in_start_center("calc")
- ui_test.execute_dialog_through_command(".uno:About")
+ self.ui_test.execute_dialog_through_command(".uno:About")
- xAboutDlg = xUITest.getTopFocusWindow()
+ xAboutDlg = self.xUITest.getTopFocusWindow()
- xCloseBtn = xAboutDlg.getChild("close")
- xCloseBtn.executeAction("CLICK", tuple())
+ xCloseBtn = xAboutDlg.getChild("close")
+ xCloseBtn.executeAction("CLICK", tuple())
- ui_test.close_doc()
+ self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uitest/calc_tests/calc_demo.txt b/uitest/calc_tests/calc_demo.txt
index 6ff4e22..1c2629e 100644
--- a/uitest/calc_tests/calc_demo.txt
+++ b/uitest/calc_tests/calc_demo.txt
@@ -2,4 +2,3 @@ calc_tests.create_range_name.create_range_name
calc_tests.create_range_name.create_local_range_name
calc_tests.function_wizard.open_function_wizard
calc_tests.gridwindow.input
-calc_tests.about_test.test_about_dlg
diff --git a/uitest/calc_tests/create_chart.py b/uitest/calc_tests/create_chart.py
index 6ec7082..6db4d58 100644
--- a/uitest/calc_tests/create_chart.py
+++ b/uitest/calc_tests/create_chart.py
@@ -9,6 +9,8 @@ from uitest_helper import UITest
from helper import mkPropertyValues
+from UITestCase import UITestCase
+
import time
try:
@@ -21,199 +23,171 @@ except ImportError:
print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
raise
-def add_content_to_cell(gridwin, cell, content):
- selectProps = mkPropertyValues({"CELL": cell})
- gridwin.executeAction("SELECT", selectProps)
-
- contentProps = mkPropertyValues({"TEXT": content})
- gridwin.executeAction("TYPE", contentProps)
-
-
-def fill_spreadsheet(xUITest):
- xCalcDoc = xUITest.getTopFocusWindow()
- xGridWindow = xCalcDoc.getChild("grid_window")
-
- add_content_to_cell(xGridWindow, "A1", "col1")
- add_content_to_cell(xGridWindow, "B1", "col2")
- add_content_to_cell(xGridWindow, "C1", "col3")
- add_content_to_cell(xGridWindow, "A2", "1")
- add_content_to_cell(xGridWindow, "B2", "3")
- add_content_to_cell(xGridWindow, "C2", "5")
-
- xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C2"}))
-
-def cancel_immediately(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
-
- ui_test = UITest(xUITest, xContext)
-
- ui_test.create_doc_in_start_center("calc")
+class CalcChartUIDemo(UITestCase):
- fill_spreadsheet(xUITest)
+ def add_content_to_cell(self, gridwin, cell, content):
+ selectProps = mkPropertyValues({"CELL": cell})
+ gridwin.executeAction("SELECT", selectProps)
- ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
+ contentProps = mkPropertyValues({"TEXT": content})
+ gridwin.executeAction("TYPE", contentProps)
- xChartDlg = xUITest.getTopFocusWindow()
+ def fill_spreadsheet(self):
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ xGridWindow = xCalcDoc.getChild("grid_window")
- xCancelBtn = xChartDlg.getChild("cancel")
- xCancelBtn.executeAction("CLICK", tuple())
+ self.add_content_to_cell(xGridWindow, "A1", "col1")
+ self.add_content_to_cell(xGridWindow, "B1", "col2")
+ self.add_content_to_cell(xGridWindow, "C1", "col3")
+ self.add_content_to_cell(xGridWindow, "A2", "1")
+ self.add_content_to_cell(xGridWindow, "B2", "3")
+ self.add_content_to_cell(xGridWindow, "C2", "5")
- ui_test.close_doc()
+ xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C2"}))
-def create_from_first_page(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+ def test_cancel_immediately(self):
- ui_test = UITest(xUITest, xContext)
+ self.ui_test.create_doc_in_start_center("calc")
- ui_test.create_doc_in_start_center("calc")
+ self.fill_spreadsheet()
- fill_spreadsheet(xUITest)
+ self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
- ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
+ xChartDlg = self.xUITest.getTopFocusWindow()
- xChartDlg = xUITest.getTopFocusWindow()
- print(xChartDlg.getChildren())
- time.sleep(2)
+ xCancelBtn = xChartDlg.getChild("cancel")
+ xCancelBtn.executeAction("CLICK", tuple())
- xOkBtn = xChartDlg.getChild("finish")
- xOkBtn.executeAction("CLICK", tuple())
+ self.ui_test.close_doc()
- time.sleep(2)
+ def test_create_from_first_page(self):
- ui_test.close_doc()
+ self.ui_test.create_doc_in_start_center("calc")
-def create_from_second_page(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+ self.fill_spreadsheet()
- ui_test = UITest(xUITest, xContext)
+ self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
- ui_test.create_doc_in_start_center("calc")
+ xChartDlg = self.xUITest.getTopFocusWindow()
+ print(xChartDlg.getChildren())
+ time.sleep(2)
- fill_spreadsheet(xUITest)
+ xOkBtn = xChartDlg.getChild("finish")
+ xOkBtn.executeAction("CLICK", tuple())
- ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
+ time.sleep(2)
- xChartDlg = xUITest.getTopFocusWindow()
- print(xChartDlg.getChildren())
- time.sleep(2)
+ self.ui_test.close_doc()
- xNextBtn = xChartDlg.getChild("next")
- xNextBtn.executeAction("CLICK", tuple())
+ def test_create_from_second_page(self):
- print(xChartDlg.getChildren())
+ self.ui_test.create_doc_in_start_center("calc")
- time.sleep(2)
+ self.fill_spreadsheet()
- xDataInRows = xChartDlg.getChild("RB_DATAROWS")
- xDataInRows.executeAction("CLICK", tuple())
+ self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
- time.sleep(2)
+ xChartDlg = self.xUITest.getTopFocusWindow()
+ print(xChartDlg.getChildren())
+ time.sleep(2)
- xDataInCols = xChartDlg.getChild("RB_DATACOLS")
- xDataInCols.executeAction("CLICK", tuple())
+ xNextBtn = xChartDlg.getChild("next")
+ xNextBtn.executeAction("CLICK", tuple())
- time.sleep(2)
+ print(xChartDlg.getChildren())
- xCancelBtn = xChartDlg.getChild("finish")
- xCancelBtn.executeAction("CLICK", tuple())
+ time.sleep(2)
- time.sleep(5)
+ xDataInRows = xChartDlg.getChild("RB_DATAROWS")
+ xDataInRows.executeAction("CLICK", tuple())
- ui_test.close_doc()
+ time.sleep(2)
-def deselect_chart(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+ xDataInCols = xChartDlg.getChild("RB_DATACOLS")
+ xDataInCols.executeAction("CLICK", tuple())
- ui_test = UITest(xUITest, xContext)
+ time.sleep(2)
- ui_test.create_doc_in_start_center("calc")
+ xCancelBtn = xChartDlg.getChild("finish")
+ xCancelBtn.executeAction("CLICK", tuple())
- fill_spreadsheet(xUITest)
+ time.sleep(5)
- xCalcDoc = xUITest.getTopFocusWindow()
- xGridWindow = xCalcDoc.getChild("grid_window")
+ self.ui_test.close_doc()
- ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
+ def test_deselect_chart(self):
+ self.ui_test.create_doc_in_start_center("calc")
- xChartDlg = xUITest.getTopFocusWindow()
+ self.fill_spreadsheet()
- xNextBtn = xChartDlg.getChild("finish")
- xNextBtn.executeAction("CLICK", tuple())
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ xGridWindow = xCalcDoc.getChild("grid_window")
- xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
+ self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
- time.sleep(2)
+ xChartDlg = self.xUITest.getTopFocusWindow()
- ui_test.close_doc()
+ xNextBtn = xChartDlg.getChild("finish")
+ xNextBtn.executeAction("CLICK", tuple())
-def activate_chart(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+ xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
- ui_test = UITest(xUITest, xContext)
+ time.sleep(2)
- ui_test.create_doc_in_start_center("calc")
+ self.ui_test.close_doc()
- fill_spreadsheet(xUITest)
+ def test_activate_chart(self):
- xCalcDoc = xUITest.getTopFocusWindow()
- xGridWindow = xCalcDoc.getChild("grid_window")
+ self.ui_test.create_doc_in_start_center("calc")
- ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
+ self.fill_spreadsheet()
- xChartDlg = xUITest.getTopFocusWindow()
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ xGridWindow = xCalcDoc.getChild("grid_window")
- xNextBtn = xChartDlg.getChild("finish")
- xNextBtn.executeAction("CLICK", tuple())
+ self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
- xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
+ xChartDlg = self.xUITest.getTopFocusWindow()
- time.sleep(2)
+ xNextBtn = xChartDlg.getChild("finish")
+ xNextBtn.executeAction("CLICK", tuple())
- xGridWindow.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
- xGridWindow.executeAction("ACTIVATE", tuple())
+ xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
- time.sleep(2)
+ time.sleep(2)
- xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
+ xGridWindow.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
+ xGridWindow.executeAction("ACTIVATE", tuple())
- ui_test.close_doc()
+ time.sleep(2)
-def select_chart_element(xContext):
- xUITest = xContext.ServiceManager.createInstanceWithContext(
- "org.libreoffice.uitest.UITest", xContext)
+ xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
- ui_test = UITest(xUITest, xContext)
+ self.ui_test.close_doc()
- ui_test.create_doc_in_start_center("calc")
+ def select_chart_element(self):
- fill_spreadsheet(xUITest)
+ self.ui_test.create_doc_in_start_center("calc")
- xCalcDoc = xUITest.getTopFocusWindow()
- xGridWindow = xCalcDoc.getChild("grid_window")
+ self.fill_spreadsheet()
- ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ xGridWindow = xCalcDoc.getChild("grid_window")
- xChartDlg = xUITest.getTopFocusWindow()
+ self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
- xNextBtn = xChartDlg.getChild("finish")
- xNextBtn.executeAction("CLICK", tuple())
+ xChartDlg = self.xUITest.getTopFocusWindow()
- xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
+ xNextBtn = xChartDlg.getChild("finish")
+ xNextBtn.executeAction("CLICK", tuple())
- time.sleep(2)
+ xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
- xGridWindow.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
- xGridWindow.executeAction("ACTIVATE", tuple())
+ xGridWindow.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
+ xGridWindow.executeAction("ACTIVATE", tuple())
- time.sleep(2)
- xCalcDoc = xUITest.getTopFocusWindow()
- print(xCalcDoc.getChildren())
- time.sleep(1)
- ui_test.close_doc()
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ print(xCalcDoc.getChildren())
+ self.ui_test.close_doc()
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uitest/test_main.py b/uitest/test_main.py
new file mode 100644
index 0000000..2a0fca1
--- /dev/null
+++ b/uitest/test_main.py
@@ -0,0 +1,101 @@
+# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+import sys
+import getopt
+import os
+import unittest
+import calc_tests
+import importlib
+import importlib.machinery
+
+from UITestCase import UITestCase
+
+from connection import PersistentConnection, OfficeConnection
+
+def parseArgs(argv):
+ (optlist,args) = getopt.getopt(argv[1:], "hr",
+ ["help", "soffice=", "userdir=", "dir="])
+ return (dict(optlist), args)
+
+def usage():
+ message = """usage: {program} [option]... [task_file]..."
+ -h | --help: print usage information
+ {connection_params}
+ the 'task_file' parameters should be
+ full absolute pathnames, not URLs."""
+ print(message.format(program = os.path.basename(sys.argv[0]), \
+ connection_params = OfficeConnection.getHelpText()))
+
+
+def find_test_files(dir_path):
+ valid_files = []
+ for f in os.listdir(dir_path):
+ file_path = os.path.join(dir_path, f)
+
+ # don't go through the sub-directories
+ if not os.path.isfile(file_path):
+ continue
+
+ # ignore any non .py files
+ if not os.path.splitext(file_path)[1] == ".py":
+ continue
+
+ # ignore the __init__.py file
+ # it is obviously not a test file
+ if f is "__init__.py":
+ continue
+
+ valid_files.append(file_path)
+
+ return valid_files
+
+def get_classes_of_module(module):
+ md = module.__dict__
+ return [ md[c] for c in md if (
+ isinstance(md[c], type) and md[c].__module__ == module.__name__ ) ]
+
+def get_test_case_classes_of_module(module):
+ classes = get_classes_of_module(module)
+ return [ c for c in classes if issubclass(c, UITestCase) ]
+
+def get_test_suite(opts):
+ test_loader = unittest.TestLoader()
+ test_suite = unittest.TestSuite()
+
+ valid_test_files = find_test_files(opts['--dir'])
+ for test_file in valid_test_files:
+ module_name = os.path.splitext(os.path.split(test_file)[1])[0]
+ loader = importlib.machinery.SourceFileLoader(module_name, test_file)
+ mod = loader.load_module()
+ classes = get_test_case_classes_of_module(mod)
+ for c in classes:
+ test_names = test_loader.getTestCaseNames(c)
+ for test_name in test_names:
+ obj = c(test_name, opts)
+ test_suite.addTest(obj)
+
+ return test_suite
+
+
+if __name__ == '__main__':
+ (opts,args) = parseArgs(sys.argv)
+ if "-h" in opts or "--help" in opts:
+ usage()
+ sys.exit()
+ elif not "--soffice" in opts:
+ usage()
+ sys.exit(1)
+ elif not "--dir" in opts:
+ usage()
+ sys.exit()
+ test_suite = get_test_suite(opts)
+ print(test_suite)
+
+ unittest.TextTestRunner().run(test_suite)
+
+# vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 660e5597813f88b1aca564198fdf5f78298adc13
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue Jun 21 17:16:35 2016 +0200
uitest: we will need the python unittest module
Change-Id: Ic0589be9b3769279b201dfd314534a087c7f4309
diff --git a/external/python3/ExternalPackage_python3.mk b/external/python3/ExternalPackage_python3.mk
index 07a875c..347b13a 100644
--- a/external/python3/ExternalPackage_python3.mk
+++ b/external/python3/ExternalPackage_python3.mk
@@ -323,6 +323,17 @@ $(eval $(call gb_ExternalPackage_add_unpacked_files,python3,$(LIBO_BIN_FOLDER)/p
Lib/turtle.py \
Lib/types.py \
Lib/typing.py \
+ Lib/unittest/case.py \
+ Lib/unittest/__init__.py \
+ Lib/unittest/loader.py \
+ Lib/unittest/__main__.py \
+ Lib/unittest/main.py \
+ Lib/unittest/mock.py \
+ Lib/unittest/result.py \
+ Lib/unittest/runner.py \
+ Lib/unittest/signals.py \
+ Lib/unittest/suite.py \
+ Lib/unittest/util.py \
Lib/uu.py \
Lib/uuid.py \
Lib/warnings.py \
commit 8fbe0a6f6a32ece52f97801f33eab54705d53bc3
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue Jun 21 16:50:52 2016 +0200
uitest: add treelist demo
Change-Id: I41796a2a557143030cbd016399c2c1bf5cde37bd
diff --git a/uitest/demo_ui/demo_ui.txt b/uitest/demo_ui/demo_ui.txt
index fb39558..512da3f 100644
--- a/uitest/demo_ui/demo_ui.txt
+++ b/uitest/demo_ui/demo_ui.txt
@@ -9,6 +9,7 @@ demo_ui.listbox.select_entry_text
demo_ui.tabcontrol.select_pos
demo_ui.tabdialog.select_tab_page_pos
demo_ui.tabdialog.select_tab_page_name
+demo_ui.treelist.expand
demo_ui.spinfield.up
demo_ui.spinfield.down
demo_ui.spinfield.text
diff --git a/uitest/demo_ui/treelist.py b/uitest/demo_ui/treelist.py
new file mode 100644
index 0000000..4523dca
--- /dev/null
+++ b/uitest/demo_ui/treelist.py
@@ -0,0 +1,64 @@
+# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+import time
+
+from uitest_helper import UITest
+
+from helper import mkPropertyValues
+from uihelper.calc import enter_text_to_cell
+
+from uitest_helper import get_state_as_dict
+
+try:
+ import pyuno
+ import uno
+ import unohelper
+except ImportError:
+ print("pyuno not found: try to set PYTHONPATH and URE_BOOTSTRAP variables")
+ print("PYTHONPATH=/installation/opt/program")
+ print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
+ raise
+
+def expand(xContext):
+ xUITest = xContext.ServiceManager.createInstanceWithContext(
+ "org.libreoffice.uitest.UITest", xContext)
+
+ ui_test = UITest(xUITest, xContext)
+
+ ui_test.create_doc_in_start_center("calc")
+
+ xCalcDoc = xUITest.getTopFocusWindow()
+ xGridWindow = xCalcDoc.getChild("grid_window")
+ enter_text_to_cell(xGridWindow, "B2", "=2+3+4")
+ xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "B2"}))
+
+ ui_test.execute_modeless_dialog_through_command(".uno:FunctionDialog")
+
+ xFunctionDlg = xUITest.getTopFocusWindow()
+
+ xTabs = xFunctionDlg.getChild("tabs")
+ xTabs.executeAction("SELECT", mkPropertyValues({"POS":"1"}))
+
+ xTreelist = xTabs.getChild("struct")
+
+ xTreeEntry = xTreelist.getChild('0')
+
+ xTreeEntry.executeAction("COLLAPSE", tuple())
+
+ time.sleep(1)
+
+ xTreeEntry.executeAction("EXPAND", tuple())
+
+ time.sleep(1)
+
+ xCancelBtn = xFunctionDlg.getChild("cancel")
+ xCancelBtn.executeAction("CLICK", tuple())
+
+ ui_test.close_doc()
+
+# vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 71f562f8f77f14b76fde4329f7238fe2e7d6a054
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue Jun 21 16:49:16 2016 +0200
uitest: support tree lists
Change-Id: Iaa1a49d7e38c8d87bb3cfd749af94a0b92feee0d
diff --git a/svtools/inc/uitest/uiobject.hxx b/svtools/inc/uitest/uiobject.hxx
index 2949421..93cfc15 100644
--- a/svtools/inc/uitest/uiobject.hxx
+++ b/svtools/inc/uitest/uiobject.hxx
@@ -10,6 +10,7 @@
#include <vcl/uitest/uiobject.hxx>
class SvTreeListBox;
+class SvTreeListEntry;
class TreeListUIObject : public WindowUIObject
{
@@ -20,9 +21,44 @@ public:
static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override;
+
+ virtual std::set<OUString> get_children() const override;
+
protected:
virtual OUString get_name() const override;
+
+private:
+
+ VclPtr<SvTreeListBox> mxTreeList;
+};
+
+class TreeListEntryUIObject : public UIObject
+{
+public:
+
+ TreeListEntryUIObject(VclPtr<SvTreeListBox> xTreeList, SvTreeListEntry* pEntry);
+
+ virtual StringMap get_state() override;
+
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override;
+
+ virtual std::set<OUString> get_children() const override;
+
+ virtual OUString get_type() const override;
+
+private:
+
+ VclPtr<SvTreeListBox> mxTreeList;
+
+ SvTreeListEntry* mpEntry;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/uitest/uiobject.cxx b/svtools/source/uitest/uiobject.cxx
index 65cd4a7..494406a 100644
--- a/svtools/source/uitest/uiobject.cxx
+++ b/svtools/source/uitest/uiobject.cxx
@@ -12,13 +12,58 @@
#include <svtools/treelistbox.hxx>
TreeListUIObject::TreeListUIObject(VclPtr<SvTreeListBox> xTreeList):
- WindowUIObject(xTreeList)
+ WindowUIObject(xTreeList),
+ mxTreeList(xTreeList)
{
}
StringMap TreeListUIObject::get_state()
{
- return WindowUIObject::get_state();
+ StringMap aMap = WindowUIObject::get_state();
+
+ aMap["SelectionCount"] = OUString::number(mxTreeList->GetSelectionCount());
+ aMap["VisibleCount"] = OUString::number(mxTreeList->GetVisibleCount());
+ aMap["Children"] = OUString::number(mxTreeList->GetChildCount(nullptr));
+ aMap["LevelChildren"] = OUString::number(mxTreeList->GetLevelChildCount(nullptr));
+ return aMap;
+}
+
+void TreeListUIObject::execute(const OUString& rAction,
+ const StringMap& rParameters)
+{
+ if (rAction == "")
+ {
+ }
+ else
+ WindowUIObject::execute(rAction, rParameters);
+}
+
+std::unique_ptr<UIObject> TreeListUIObject::get_child(const OUString& rID)
+{
+ sal_Int32 nID = rID.toInt32();
+ if (nID >= 0)
+ {
+ SvTreeListEntry* pEntry = mxTreeList->GetEntry(nullptr, nID);
+ if (!pEntry)
+ return nullptr;
+
+ return std::unique_ptr<UIObject>(new TreeListEntryUIObject(mxTreeList, pEntry));
+ }
+
+ return nullptr;
+}
+
+std::set<OUString> TreeListUIObject::get_children() const
+{
+ std::set<OUString> aChildren;
+
+ size_t nChildren = mxTreeList->GetLevelChildCount(nullptr);
+ for (size_t i = 0; i < nChildren; ++i)
+ {
+ aChildren.insert(OUString::number(i));
+ }
+
+ return aChildren;
}
OUString TreeListUIObject::get_name() const
@@ -33,4 +78,66 @@ std::unique_ptr<UIObject> TreeListUIObject::create(vcl::Window* pWindow)
return std::unique_ptr<UIObject>(new TreeListUIObject(pTreeList));
}
+TreeListEntryUIObject::TreeListEntryUIObject(VclPtr<SvTreeListBox> xTreeList, SvTreeListEntry* pEntry):
+ mxTreeList(xTreeList),
+ mpEntry(pEntry)
+{
+}
+
+StringMap TreeListEntryUIObject::get_state()
+{
+ StringMap aMap;
+
+ aMap["Text"] = mxTreeList->GetEntryText(mpEntry);
+ aMap["Children"] = OUString::number(mxTreeList->GetLevelChildCount(mpEntry));
+ aMap["VisibleChildCount"] = OUString::number(mxTreeList->GetVisibleChildCount(mpEntry));
+
+ return aMap;
+}
+
+void TreeListEntryUIObject::execute(const OUString& rAction, const StringMap& rParameters)
+{
+ if (rAction == "COLLAPSE")
+ {
+ mxTreeList->Collapse(mpEntry);
+ }
+ else if (rAction == "EXPAND")
+ {
+ mxTreeList->Expand(mpEntry);
+ }
+}
+
+std::unique_ptr<UIObject> TreeListEntryUIObject::get_child(const OUString& rID)
+{
+ sal_Int32 nID = rID.toInt32();
+ if (nID >= 0)
+ {
+ SvTreeListEntry* pEntry = mxTreeList->GetEntry(mpEntry, nID);
+ if (!pEntry)
+ return nullptr;
+
+ return std::unique_ptr<UIObject>(new TreeListEntryUIObject(mxTreeList, pEntry));
+ }
+
+ return nullptr;
+}
+
+std::set<OUString> TreeListEntryUIObject::get_children() const
+{
+ std::set<OUString> aChildren;
+
+ size_t nChildren = mxTreeList->GetLevelChildCount(mpEntry);
+ for (size_t i = 0; i < nChildren; ++i)
+ {
+ aChildren.insert(OUString::number(i));
+ }
+
+ return aChildren;
+}
+
+OUString TreeListEntryUIObject::get_type() const
+{
+ return OUString("TreeListEntry");
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 33d873b61f2b966c11019fc5e435b04aa0a1476d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue Jun 21 16:45:39 2016 +0200
uitest: add tabcontrol demo
Change-Id: Ibcdf5c1a43ed943c22745545257d5d324ed139ec
diff --git a/uitest/demo_ui/demo_ui.txt b/uitest/demo_ui/demo_ui.txt
index 67600ef..fb39558 100644
--- a/uitest/demo_ui/demo_ui.txt
+++ b/uitest/demo_ui/demo_ui.txt
@@ -6,6 +6,7 @@ demo_ui.gridwin.select_range
demo_ui.gridwin.extend_range
demo_ui.listbox.select_entry_pos
demo_ui.listbox.select_entry_text
+demo_ui.tabcontrol.select_pos
demo_ui.tabdialog.select_tab_page_pos
demo_ui.tabdialog.select_tab_page_name
demo_ui.spinfield.up
diff --git a/uitest/demo_ui/tabcontrol.py b/uitest/demo_ui/tabcontrol.py
new file mode 100644
index 0000000..b9d79ad
--- /dev/null
+++ b/uitest/demo_ui/tabcontrol.py
@@ -0,0 +1,54 @@
+# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+import time
+
+from uitest_helper import UITest
+
+from helper import mkPropertyValues
+
+from uihelper.calc import enter_text_to_cell
+
+try:
+ import pyuno
+ import uno
+ import unohelper
+except ImportError:
+ print("pyuno not found: try to set PYTHONPATH and URE_BOOTSTRAP variables")
+ print("PYTHONPATH=/installation/opt/program")
+ print("URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
+ raise
+
+def select_pos(xContext):
+ xUITest = xContext.ServiceManager.createInstanceWithContext(
+ "org.libreoffice.uitest.UITest", xContext)
+
+ ui_test = UITest(xUITest, xContext)
+
+ ui_test.create_doc_in_start_center("calc")
+
+ xCalcDoc = xUITest.getTopFocusWindow()
+ xGridWindow = xCalcDoc.getChild("grid_window")
+ enter_text_to_cell(xGridWindow, "B2", "=2+3+4")
+ xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "B2"}))
+
+ ui_test.execute_modeless_dialog_through_command(".uno:FunctionDialog")
+
+ xFunctionDlg = xUITest.getTopFocusWindow()
+
+ xTabs = xFunctionDlg.getChild("tabs")
+ xTabs.executeAction("SELECT", mkPropertyValues({"POS":"1"}))
+
+ time.sleep(1)
+
+ xCancelBtn = xFunctionDlg.getChild("cancel")
+ xCancelBtn.executeAction("CLICK", tuple())
+
+ ui_test.close_doc()
+
+# vim:set shiftwidth=4 softtabstop=4 expandtab: */
+
commit 2e2d4a326e25b460b0590d1cccb0ae2834743fc0
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue Jun 21 16:44:30 2016 +0200
uitest: add support for TabControl
Change-Id: I4cdffe62cdabaf110eaaeb0d31a45c44833d354a
diff --git a/include/vcl/tabctrl.hxx b/include/vcl/tabctrl.hxx
index 2d60b40..7597662 100644
--- a/include/vcl/tabctrl.hxx
+++ b/include/vcl/tabctrl.hxx
@@ -191,6 +191,8 @@ public:
std::vector<sal_uInt16> GetPageIDs() const;
+ virtual FactoryFunction GetUITestFactory() const override;
+
virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
};
diff --git a/include/vcl/uitest/uiobject.hxx b/include/vcl/uitest/uiobject.hxx
index 0baddeb..011a2d4 100644
--- a/include/vcl/uitest/uiobject.hxx
+++ b/include/vcl/uitest/uiobject.hxx
@@ -19,6 +19,7 @@
#include <vcl/lstbox.hxx>
#include <vcl/combobox.hxx>
#include <vcl/spinfld.hxx>
+#include <vcl/tabctrl.hxx>
#include <vcl/dllapi.h>
@@ -328,4 +329,26 @@ protected:
virtual OUString get_name() const override;
};
+class UITEST_DLLPUBLIC TabControlUIObject : public WindowUIObject
+{
+private:
+ VclPtr<TabControl> mxTabControl;
+
+public:
+
+ TabControlUIObject(VclPtr<TabControl> mxTabControl);
+ virtual ~TabControlUIObject();
+
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ virtual StringMap get_state() override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+protected:
+
+ virtual OUString get_name() const override;
+};
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index 70869bc..903d3bb 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -31,6 +31,7 @@
#include <vcl/layout.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/settings.hxx>
+#include <vcl/uitest/uiobject.hxx>
#include "controldata.hxx"
#include "svdata.hxx"
@@ -2193,4 +2194,9 @@ std::vector<sal_uInt16> TabControl::GetPageIDs() const
return aIDs;
}
+FactoryFunction TabControl::GetUITestFactory() const
+{
+ return TabControlUIObject::create;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx
index 27c7af5..4d33f9c 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -871,4 +871,52 @@ std::unique_ptr<UIObject> SpinFieldUIObject::create(vcl::Window* pWindow)
return std::unique_ptr<UIObject>(new SpinFieldUIObject(pSpinField));
}
+TabControlUIObject::TabControlUIObject(VclPtr<TabControl> xTabControl):
+ WindowUIObject(xTabControl),
+ mxTabControl(xTabControl)
+{
+}
+
+TabControlUIObject::~TabControlUIObject()
+{
+}
+
+void TabControlUIObject::execute(const OUString& rAction,
+ const StringMap& rParameters)
+{
+ if (rAction == "SELECT")
+ {
+ if (rParameters.find("POS") != rParameters.end())
+ {
+ auto itr = rParameters.find("POS");
+ sal_uInt32 nPos = itr->second.toUInt32();
+ std::vector<sal_uInt16> aIds = mxTabControl->GetPageIDs();
+ mxTabControl->SelectTabPage(aIds[nPos]);
+ }
+ }
+ else
+ WindowUIObject::execute(rAction, rParameters);
+}
+
+StringMap TabControlUIObject::get_state()
+{
+ StringMap aMap = WindowUIObject::get_state();
+
+ return aMap;
+}
+
+OUString TabControlUIObject::get_name() const
+{
+ return OUString("TabControlUIObject");
+}
+
+std::unique_ptr<UIObject> TabControlUIObject::create(vcl::Window* pWindow)
+{
+ TabControl* pTabControl = dynamic_cast<TabControl*>(pWindow);
+ assert(pTabControl);
+ return std::unique_ptr<UIObject>(new TabControlUIObject(pTabControl));
+}
+
+
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 47b9dad7976fe0611b60efa8c38c148445c99949
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue Jun 21 16:42:46 2016 +0200
remove unnecessary whitespace
Change-Id: Ia9c9accf3c5509393c3e09692b6a7eae756907f9
diff --git a/formula/source/ui/dlg/structpg.hxx b/formula/source/ui/dlg/structpg.hxx
index e88ec26..db53c6c 100644
--- a/formula/source/ui/dlg/structpg.hxx
+++ b/formula/source/ui/dlg/structpg.hxx
@@ -35,7 +35,7 @@ namespace formula
{
class IFormulaToken;
-class StructListBox : public SvTreeListBox
+class StructListBox : public SvTreeListBox
{
private:
commit cdfdf580f70e74dff393f9a0a6bac5c32264a42c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Mon Jun 20 06:53:43 2016 +0200
remove visual noise
Change-Id: Ia4b0439af933653bcff5aed9127b2503c622ce0e
diff --git a/include/svtools/treelistbox.hxx b/include/svtools/treelistbox.hxx
index 9a6a2ed..88d39df 100644
--- a/include/svtools/treelistbox.hxx
+++ b/include/svtools/treelistbox.hxx
@@ -152,10 +152,6 @@ public:
bool IsEditable() const { return bool(nFlags & SvLBoxTabFlags::EDITABLE); }
};
-// *********************************************************************
-// ****************************** Items ********************************
-// *********************************************************************
-
class SVT_DLLPUBLIC SvLBoxItem
{
public:
@@ -176,10 +172,6 @@ public:
virtual void Clone(SvLBoxItem* pSource) = 0;
};
-// *********************************************************************
-// ****************************** SvTreeListBox ************************
-// *********************************************************************
-
#define WB_FORCE_SELECTION ((WinBits)0x8000)
enum class DragDropMode
@@ -200,7 +192,6 @@ namespace o3tl
template<> struct typed_flags<DragDropMode> : is_typed_flags<DragDropMode, 0x003f> {};
}
-
enum class SvTreeListBoxFlags
{
NONE = 0x0000,
commit e8b6bcc65f2870562da16d65f4ea2bfb70bd7886
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Mon Jun 20 03:06:43 2016 +0200
uitest: add initial version for calc element demo
Change-Id: I09b724cb80d75b17fd3ad5f3736245f9fca1d17a
diff --git a/uitest/calc_tests/create_chart.py b/uitest/calc_tests/create_chart.py
index 1e72df7..6ec7082 100644
--- a/uitest/calc_tests/create_chart.py
+++ b/uitest/calc_tests/create_chart.py
@@ -183,4 +183,37 @@ def activate_chart(xContext):
ui_test.close_doc()
+def select_chart_element(xContext):
+ xUITest = xContext.ServiceManager.createInstanceWithContext(
+ "org.libreoffice.uitest.UITest", xContext)
+
+ ui_test = UITest(xUITest, xContext)
+
+ ui_test.create_doc_in_start_center("calc")
+
+ fill_spreadsheet(xUITest)
+
+ xCalcDoc = xUITest.getTopFocusWindow()
+ xGridWindow = xCalcDoc.getChild("grid_window")
+
+ ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
+
+ xChartDlg = xUITest.getTopFocusWindow()
+
+ xNextBtn = xChartDlg.getChild("finish")
+ xNextBtn.executeAction("CLICK", tuple())
+
+ xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
+
+ time.sleep(2)
+
+ xGridWindow.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
+ xGridWindow.executeAction("ACTIVATE", tuple())
+
+ time.sleep(2)
+ xCalcDoc = xUITest.getTopFocusWindow()
+ print(xCalcDoc.getChildren())
+ time.sleep(1)
+ ui_test.close_doc()
+
# vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list