diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-05-21 19:32:58 +0200 |
---|---|---|
committer | Xisco Faulí <xiscofauli@libreoffice.org> | 2020-05-22 20:05:06 +0200 |
commit | 4534d8146f383f75df5f6f4ba2cfe547bcf66a4b (patch) | |
tree | 27e9c5998a1400141ffabbe5a7ac4524acc2a0bd /sw | |
parent | 2674248307e11e113f28680c2a13be0c8103be24 (diff) |
uitest: Add wait methods for slow elements
some elements take some time to be updated, specially
with slow machines or ASan+UBSan builds
Use the same time based approach used for launching the dialogs
also reintroduce 634ce6f2d87a30b8abd2e8c67668e3bb5d87406b
Change-Id: Ia1cca74474ef65578bbc60a53a8a511402a082b6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94648
Tested-by: Xisco Faulí <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Faulí <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/uitest/writer_tests/wordCount.py | 15 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests7/tdf132169.py | 6 | ||||
-rw-r--r-- | sw/source/uibase/inc/conttree.hxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/uitest/uiobject.cxx | 1 |
4 files changed, 13 insertions, 14 deletions
diff --git a/sw/qa/uitest/writer_tests/wordCount.py b/sw/qa/uitest/writer_tests/wordCount.py index d7b7ca07bb4e..07a4c69342ba 100644 --- a/sw/qa/uitest/writer_tests/wordCount.py +++ b/sw/qa/uitest/writer_tests/wordCount.py @@ -10,7 +10,6 @@ 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 @@ -276,24 +275,18 @@ class writerWordCount(UITestCase): 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) - + #needs 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.ui_test.wait_until_property_is_updated(xselectwords, "Text", "1") 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) - + #needs 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.ui_test.wait_until_property_is_updated(xselectwords, "Text", "2") self.assertEqual(get_state_as_dict(xselectwords)["Text"], "2") self.assertEqual(get_state_as_dict(xselectchars)["Text"], "7") diff --git a/sw/qa/uitest/writer_tests7/tdf132169.py b/sw/qa/uitest/writer_tests7/tdf132169.py index ce4865000cf0..e96cf7250a91 100644 --- a/sw/qa/uitest/writer_tests7/tdf132169.py +++ b/sw/qa/uitest/writer_tests7/tdf132169.py @@ -8,7 +8,6 @@ from uitest.framework import UITestCase from uitest.path import get_srcdir_url from uitest.uihelper.common import get_state_as_dict from libreoffice.uno.propertyvalue import mkPropertyValues -import time def get_url_for_data_file(file_name): return get_srcdir_url() + "/sw/qa/uitest/writer_tests/data/" + file_name @@ -39,14 +38,15 @@ class tdf132169(UITestCase): self.xUITest.executeCommand(".uno:JumpToNextFrame") #wait until the toolbar is available - time.sleep(1) + self.ui_test.wait_until_child_is_available(xWriterEdit, 'metricfield') xLineMetric = xWriterEdit.getChild('metricfield') + self.assertEqual(get_state_as_dict(xLineMetric)["Text"], "0.0 pt") props = {"VALUE": "5.0"} actionProps = mkPropertyValues(props) xLineMetric.executeAction("VALUE", actionProps) - self.assertEqual(get_state_as_dict(xLineMetric)['Text'], '5.0 pt') + self.assertEqual(get_state_as_dict(xLineMetric)["Text"], "5.0 pt") document = self.ui_test.get_component() drawPage = document.getDrawPages().getByIndex(0) diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx index 28ea07a1c1de..59df0d51c3ea 100644 --- a/sw/source/uibase/inc/conttree.hxx +++ b/sw/source/uibase/inc/conttree.hxx @@ -247,6 +247,11 @@ public: m_xTreeView->grab_focus(); } + OUString get_selected_text() const + { + return m_xTreeView->get_selected_text(); + } + int count_selected_rows() const { return m_xTreeView->count_selected_rows(); diff --git a/sw/source/uibase/uitest/uiobject.cxx b/sw/source/uibase/uitest/uiobject.cxx index 6a55e42cf5ac..7f922dc9ce16 100644 --- a/sw/source/uibase/uitest/uiobject.cxx +++ b/sw/source/uibase/uitest/uiobject.cxx @@ -139,6 +139,7 @@ StringMap SwNavigationPIUIObject::get_state() StringMap aMap = WindowUIObject::get_state(); aMap["selectioncount"] = OUString::number(mxSwNavigationPI->m_xContentTree->count_selected_rows()); + aMap["selectedtext"] = mxSwNavigationPI->m_xContentTree->get_selected_text(); return aMap; } |