diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-06-22 06:07:00 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-06-22 18:19:34 +0200 |
commit | f928a9983423be545583269cb8274e9bfc7cf95d (patch) | |
tree | 7afdf9a10f08b55520f5d587a2bef80055667c1e /uitest | |
parent | fb821500ed026cfddae99c3695660556c75002d3 (diff) |
uitest: convert writer demo to new python unittest framework
Change-Id: Ifff8fe9cb0f005c8a4e892d756ae6b0b95db3544
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/UITest_calc_demo.mk | 2 | ||||
-rw-r--r-- | uitest/UITest_demo_ui.mk | 2 | ||||
-rw-r--r-- | uitest/UITest_impress_demo.mk | 2 | ||||
-rw-r--r-- | uitest/UITest_writer_demo.mk | 2 | ||||
-rw-r--r-- | uitest/writer_tests/start.py | 96 | ||||
-rw-r--r-- | uitest/writer_tests/writer_demo.txt | 4 |
6 files changed, 46 insertions, 62 deletions
diff --git a/uitest/UITest_calc_demo.mk b/uitest/UITest_calc_demo.mk index 96acb49f296c..9869300a0675 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 03da9bba7864..11432f9175a1 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 dfabbf92d3e0..e13d95494b51 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 c0c7f3d50614..a95fbd17128e 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 a5a23ca0044b..51e0d3ad0895 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 0045e2a5b2c6..000000000000 --- 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 |