summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2020-04-20 18:05:28 +0200
committerXisco Faulí <xiscofauli@libreoffice.org>2020-04-21 11:57:31 +0200
commit57839969381d93e96e98fdaee65e8593c8f07893 (patch)
tree656d8cb4a0e82f41db65378cd16af9739d45069f /sw
parent850b8de31c5be5127eac16a4f5cc18c26a582e53 (diff)
uitest: re-enable test using sleep
and instead of sleep(3) use timeout = time.time() + 3 while condition != True and time.time() < timeout: sleep(0.1) execution time of this particular test goes from 7.785 seconds to 3.343 for me Change-Id: I7c99385ccd858dfbb77cfc6e53a0b3f1a8b57c73 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92588 Tested-by: Jenkins Reviewed-by: Xisco Faulí <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/uitest/writer_tests/wordCount.py98
1 files changed, 55 insertions, 43 deletions
diff --git a/sw/qa/uitest/writer_tests/wordCount.py b/sw/qa/uitest/writer_tests/wordCount.py
index 96ff3ea47349..d7b7ca07bb4e 100644
--- a/sw/qa/uitest/writer_tests/wordCount.py
+++ b/sw/qa/uitest/writer_tests/wordCount.py
@@ -10,6 +10,7 @@ from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.debug import sleep
from uitest.uihelper.common import get_state_as_dict, type_text
from uitest.path import get_srcdir_url
+import time
def get_url_for_data_file(file_name):
return get_srcdir_url() + "/sw/qa/uitest/writer_tests/data/" + file_name
@@ -247,47 +248,58 @@ class writerWordCount(UITestCase):
self.ui_test.close_dialog_through_button(xCloseBtn)
self.ui_test.close_doc()
- #need sleep() in test. Disable for now
-# def test_tdf51816(self):
-# writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf51816.odt"))
-# xWriterDoc = self.xUITest.getTopFocusWindow()
-# xWriterEdit = xWriterDoc.getChild("writer_edit")
-# document = self.ui_test.get_component()
-# #1. Open attached document
-# #2. Tools> Word count
-# self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog")
-# xDialog = self.xUITest.getTopFocusWindow()
-# xselectwords = xDialog.getChild("selectwords")
-# xdocwords = xDialog.getChild("docwords")
-# xselectchars = xDialog.getChild("selectchars")
-# xdocchars = xDialog.getChild("docchars")
-# xselectcharsnospaces = xDialog.getChild("selectcharsnospaces")
-# xdoccharsnospaces = xDialog.getChild("doccharsnospaces")
-# xselectcjkchars = xDialog.getChild("selectcjkchars")
-# xdoccjkchars = xDialog.getChild("doccjkchars")
-
-# #3. Click after "At nunc" then <Ctrl><Shift><Left>
-# self.xUITest.executeCommand(".uno:GoRight")
-# self.xUITest.executeCommand(".uno:GoRight")
-# self.xUITest.executeCommand(".uno:GoRight")
-# self.xUITest.executeCommand(".uno:GoRight")
-# self.xUITest.executeCommand(".uno:GoRight")
-# self.xUITest.executeCommand(".uno:GoRight")
-# self.xUITest.executeCommand(".uno:GoRight")
-# self.xUITest.executeCommand(".uno:WordLeftSel")
-# sleep(3) #need to wait, because Word count dialog is already open and it takes time to refresh the counter
-# #Expected result : Words 1 & Characters 4 #Actual result : Words 0 & Characters 0
-# self.assertEqual(get_state_as_dict(xselectwords)["Text"], "1")
-# self.assertEqual(get_state_as_dict(xselectchars)["Text"], "4")
-# #4. Click after "At nunc" then <Shift><Home>
-# self.xUITest.executeCommand(".uno:StartOfParaSel")
-# sleep(3) #need to wait, because Word count dialog is already open and it takes time to refresh the counter
-# #Expected result : Words 2 & Characters 7 & excluding space 6 #Actual result : Words 0 & Characters 0
-# self.assertEqual(get_state_as_dict(xselectwords)["Text"], "2")
-# self.assertEqual(get_state_as_dict(xselectchars)["Text"], "7")
-# self.assertEqual(get_state_as_dict(xselectcharsnospaces)["Text"], "6")
-
-# xCloseBtn = xDialog.getChild("close")
-# self.ui_test.close_dialog_through_button(xCloseBtn)
-# self.ui_test.close_doc()
+ def test_tdf51816(self):
+ writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf51816.odt"))
+ xWriterDoc = self.xUITest.getTopFocusWindow()
+ xWriterEdit = xWriterDoc.getChild("writer_edit")
+ document = self.ui_test.get_component()
+ #1. Open attached document
+ #2. Tools> Word count
+ self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog")
+ xDialog = self.xUITest.getTopFocusWindow()
+ xselectwords = xDialog.getChild("selectwords")
+ xdocwords = xDialog.getChild("docwords")
+ xselectchars = xDialog.getChild("selectchars")
+ xdocchars = xDialog.getChild("docchars")
+ xselectcharsnospaces = xDialog.getChild("selectcharsnospaces")
+ xdoccharsnospaces = xDialog.getChild("doccharsnospaces")
+ xselectcjkchars = xDialog.getChild("selectcjkchars")
+ xdoccjkchars = xDialog.getChild("doccjkchars")
+
+ #3. Click after "At nunc" then <Ctrl><Shift><Left>
+ self.xUITest.executeCommand(".uno:GoRight")
+ self.xUITest.executeCommand(".uno:GoRight")
+ self.xUITest.executeCommand(".uno:GoRight")
+ self.xUITest.executeCommand(".uno:GoRight")
+ self.xUITest.executeCommand(".uno:GoRight")
+ self.xUITest.executeCommand(".uno:GoRight")
+ self.xUITest.executeCommand(".uno:GoRight")
+ self.xUITest.executeCommand(".uno:WordLeftSel")
+
+ #need to wait, because Word count dialog is already open and it takes time to refresh the counter
+ timeout = time.time() + 3
+ while get_state_as_dict(xselectwords)["Text"] != "1" and time.time() < timeout:
+ sleep(0.1)
+
+ #Expected result : Words 1 & Characters 4 #Actual result : Words 0 & Characters 0
+ self.assertEqual(get_state_as_dict(xselectwords)["Text"], "1")
+ self.assertEqual(get_state_as_dict(xselectchars)["Text"], "4")
+
+ #4. Click after "At nunc" then <Shift><Home>
+ self.xUITest.executeCommand(".uno:StartOfParaSel")
+
+ #need to wait, because Word count dialog is already open and it takes time to refresh the counter
+ timeout = time.time() + 3
+ while get_state_as_dict(xselectwords)["Text"] != "2" and time.time() < timeout:
+ sleep(0.1)
+
+ #Expected result : Words 2 & Characters 7 & excluding space 6 #Actual result : Words 0 & Characters 0
+ self.assertEqual(get_state_as_dict(xselectwords)["Text"], "2")
+ self.assertEqual(get_state_as_dict(xselectchars)["Text"], "7")
+
+ self.assertEqual(get_state_as_dict(xselectcharsnospaces)["Text"], "6")
+
+ xCloseBtn = xDialog.getChild("close")
+ self.ui_test.close_dialog_through_button(xCloseBtn)
+ self.ui_test.close_doc()
# vim: set shiftwidth=4 softtabstop=4 expandtab: