include/vcl/idletask.hxx                         |    4 ++--
 offapi/com/sun/star/awt/XToolkitExperimental.idl |    3 +++
 sc/qa/unit/subsequent_filters_test3.cxx          |    2 +-
 sw/qa/extras/uiwriter/uiwriter7.cxx              |    2 +-
 sw/qa/uitest/navigator/movechapterupdown.py      |    7 +++++++
 sw/qa/uitest/navigator/tdf134960.py              |    7 +++++++
 sw/qa/uitest/navigator/tdf137274.py              |    7 +++++++
 sw/qa/uitest/navigator/tdf144672.py              |    7 +++++++
 sw/qa/uitest/navigator/tdf151051.py              |    7 +++++++
 sw/qa/uitest/navigator/tdf154212.py              |    7 +++++++
 sw/qa/uitest/writer_tests7/tdf135938.py          |    7 +++++++
 test/Library_test.mk                             |    1 -
 toolkit/source/awt/vclxtoolkit.cxx               |    8 ++++++++
 vcl/Library_vcl.mk                               |    1 +
 vcl/source/helper/idletask.cxx                   |    3 ++-
 15 files changed, 67 insertions(+), 6 deletions(-)

New commits:
commit 0446f73d27a0c43de1a2d5e07c9510a287be6af2
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Oct 26 11:40:24 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Oct 26 16:10:29 2023 +0200

    tdf#153519 use new IdleTask::waitUntilIdleDispatched
    
    to wait until the Idle inside sw/ has done populating the navigator
    tree.
    
    Which required
    (*) moving the code down from test/ to vcl/ to avoid circular dependency
    issues.
    (*) adding a call SolarMutexGuard before Application::Yield inside
    IdleTask::waitUntilIdleDispatched
    (*) exposing the function to python by adding a method to the
    XToolkitExperimental UNO API
    
    Change-Id: Iee418f7a0beb1f5b53addb7fe25823d61720eb3a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158495
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/include/test/idletask.hxx b/include/vcl/idletask.hxx
similarity index 93%
rename from include/test/idletask.hxx
rename to include/vcl/idletask.hxx
index 168f9052974a..fd5b17c61bec 100644
--- a/include/test/idletask.hxx
+++ b/include/vcl/idletask.hxx
@@ -10,11 +10,11 @@
 #pragma once
 
 #include <sal/config.h>
-#include <test/testdllapi.hxx>
+#include <vcl/dllapi.h>
 #include <vcl/idle.hxx>
 
 //IdleTask class to add a low priority Idle task
-class OOO_DLLPUBLIC_TEST IdleTask
+class VCL_DLLPUBLIC IdleTask
 {
 public:
     bool GetFlag() const;
diff --git a/offapi/com/sun/star/awt/XToolkitExperimental.idl 
b/offapi/com/sun/star/awt/XToolkitExperimental.idl
index 1cfcd7521f3c..d48252d95077 100644
--- a/offapi/com/sun/star/awt/XToolkitExperimental.idl
+++ b/offapi/com/sun/star/awt/XToolkitExperimental.idl
@@ -51,6 +51,9 @@ interface XToolkitExperimental : XToolkit3
      */
     sequence<string> getRecordingAndClear();
 
+    /** Wait until all idles dispatched.
+     */
+    void waitUntilAllIdlesDispatched();
 };
 
 }; }; }; };
diff --git a/sc/qa/unit/subsequent_filters_test3.cxx 
b/sc/qa/unit/subsequent_filters_test3.cxx
index 0c2ec7864de2..cdde83913715 100644
--- a/sc/qa/unit/subsequent_filters_test3.cxx
+++ b/sc/qa/unit/subsequent_filters_test3.cxx
@@ -50,7 +50,7 @@
 #include <unotools/syslocaleoptions.hxx>
 #include "helper/qahelper.hxx"
 #include <officecfg/Office/Common.hxx>
-#include <test/idletask.hxx>
+#include <vcl/idletask.hxx>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
diff --git a/sw/qa/extras/uiwriter/uiwriter7.cxx 
b/sw/qa/extras/uiwriter/uiwriter7.cxx
index 871ce984ba75..7ccf7477bd6e 100644
--- a/sw/qa/extras/uiwriter/uiwriter7.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter7.cxx
@@ -71,7 +71,7 @@
 #include <unotxdoc.hxx>
 #include <rootfrm.hxx>
 #include <officecfg/Office/Writer.hxx>
-#include <test/idletask.hxx>
+#include <vcl/idletask.hxx>
 
 namespace
 {
diff --git a/sw/qa/uitest/navigator/movechapterupdown.py 
b/sw/qa/uitest/navigator/movechapterupdown.py
index 6bcda9b3d4bb..0b4c7ef5f540 100644
--- a/sw/qa/uitest/navigator/movechapterupdown.py
+++ b/sw/qa/uitest/navigator/movechapterupdown.py
@@ -25,6 +25,13 @@ class movechapterupdown(UITestCase):
             # wait until the navigator panel is available
             xNavigatorPanel = 
self.ui_test.wait_until_child_is_available('NavigatorPanel')
 
+            # See the `m_aUpdateTimer.SetTimeout(200)` (to "avoid flickering 
of buttons")
+            # in the SwChildWinWrapper ctor in 
sw/source/uibase/fldui/fldwrap.cxx, where that
+            # m_aUpdateTimer is started by SwChildWinWrapper::ReInitDlg 
triggered from the
+            # xInsert click above.
+            xToolkit = 
self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
+            xToolkit.waitUntilAllIdlesDispatched()
+
             # Given the document chapter structure:
                 # 1. One H1
                 #   1.1. one_A (H2)
diff --git a/sw/qa/uitest/navigator/tdf134960.py 
b/sw/qa/uitest/navigator/tdf134960.py
index 8388b63e40f9..d60cc677bcd8 100644
--- a/sw/qa/uitest/navigator/tdf134960.py
+++ b/sw/qa/uitest/navigator/tdf134960.py
@@ -27,6 +27,13 @@ class tdf134960_hyperlinks(UITestCase):
         # wait until the navigator panel is available
         xNavigatorPanel = 
self.ui_test.wait_until_child_is_available('NavigatorPanel')
 
+        # See the `m_aUpdateTimer.SetTimeout(200)` (to "avoid flickering of 
buttons")
+        # in the SwChildWinWrapper ctor in sw/source/uibase/fldui/fldwrap.cxx, 
where that
+        # m_aUpdateTimer is started by SwChildWinWrapper::ReInitDlg triggered 
from the
+        # xInsert click above.
+        xToolkit = 
self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
+        xToolkit.waitUntilAllIdlesDispatched()
+
         xContentTree = xNavigatorPanel.getChild("contenttree")
         xHyperlinks = self.get_item(xContentTree, 'Hyperlinks')
         self.assertEqual('Hyperlinks', get_state_as_dict(xHyperlinks)['Text'])
diff --git a/sw/qa/uitest/navigator/tdf137274.py 
b/sw/qa/uitest/navigator/tdf137274.py
index 5273ddcb2f91..711e8133431a 100644
--- a/sw/qa/uitest/navigator/tdf137274.py
+++ b/sw/qa/uitest/navigator/tdf137274.py
@@ -42,6 +42,13 @@ class tdf137274(UITestCase):
             # wait until the navigator panel is available
             xNavigatorPanel = 
self.ui_test.wait_until_child_is_available('NavigatorPanel')
 
+            # See the `m_aUpdateTimer.SetTimeout(200)` (to "avoid flickering 
of buttons")
+            # in the SwChildWinWrapper ctor in 
sw/source/uibase/fldui/fldwrap.cxx, where that
+            # m_aUpdateTimer is started by SwChildWinWrapper::ReInitDlg 
triggered from the
+            # xInsert click above.
+            xToolkit = 
self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
+            xToolkit.waitUntilAllIdlesDispatched()
+
             xContentTree = xNavigatorPanel.getChild("contenttree")
             xComments = self.get_item(xContentTree, 'Comments')
             self.assertEqual('Comments', get_state_as_dict(xComments)['Text'])
diff --git a/sw/qa/uitest/navigator/tdf144672.py 
b/sw/qa/uitest/navigator/tdf144672.py
index 4bded66dcb08..edbafb616bd7 100644
--- a/sw/qa/uitest/navigator/tdf144672.py
+++ b/sw/qa/uitest/navigator/tdf144672.py
@@ -32,6 +32,13 @@ class tdf144672(UITestCase):
             # wait until the navigator panel is available
             xNavigatorPanel = 
self.ui_test.wait_until_child_is_available('NavigatorPanel')
 
+            # See the `m_aUpdateTimer.SetTimeout(200)` (to "avoid flickering 
of buttons")
+            # in the SwChildWinWrapper ctor in 
sw/source/uibase/fldui/fldwrap.cxx, where that
+            # m_aUpdateTimer is started by SwChildWinWrapper::ReInitDlg 
triggered from the
+            # xInsert click above.
+            xToolkit = 
self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
+            xToolkit.waitUntilAllIdlesDispatched()
+
             xContentTree = xNavigatorPanel.getChild("contenttree")
 
             xReferences = self.get_item(xContentTree, 'References')
diff --git a/sw/qa/uitest/navigator/tdf151051.py 
b/sw/qa/uitest/navigator/tdf151051.py
index 1778cc94fe68..03889c7f49fb 100644
--- a/sw/qa/uitest/navigator/tdf151051.py
+++ b/sw/qa/uitest/navigator/tdf151051.py
@@ -25,6 +25,13 @@ class tdf151051(UITestCase):
             # wait until the navigator panel is available
             xNavigatorPanel = 
self.ui_test.wait_until_child_is_available('NavigatorPanel')
 
+            # See the `m_aUpdateTimer.SetTimeout(200)` (to "avoid flickering 
of buttons")
+            # in the SwChildWinWrapper ctor in 
sw/source/uibase/fldui/fldwrap.cxx, where that
+            # m_aUpdateTimer is started by SwChildWinWrapper::ReInitDlg 
triggered from the
+            # xInsert click above.
+            xToolkit = 
self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
+            xToolkit.waitUntilAllIdlesDispatched()
+
             xContentTree = xNavigatorPanel.getChild("contenttree")
 
             xHeadings = xContentTree.getChild('0')
diff --git a/sw/qa/uitest/navigator/tdf154212.py 
b/sw/qa/uitest/navigator/tdf154212.py
index 2637780e2f4e..00a39a73b980 100644
--- a/sw/qa/uitest/navigator/tdf154212.py
+++ b/sw/qa/uitest/navigator/tdf154212.py
@@ -25,6 +25,13 @@ class tdf154212(UITestCase):
             # wait until the navigator panel is available
             xNavigatorPanel = 
self.ui_test.wait_until_child_is_available('NavigatorPanel')
 
+            # See the `m_aUpdateTimer.SetTimeout(200)` (to "avoid flickering 
of buttons")
+            # in the SwChildWinWrapper ctor in 
sw/source/uibase/fldui/fldwrap.cxx, where that
+            # m_aUpdateTimer is started by SwChildWinWrapper::ReInitDlg 
triggered from the
+            # xInsert click above.
+            xToolkit = 
self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
+            xToolkit.waitUntilAllIdlesDispatched()
+
             xNavigatorPanelContentTree = 
xNavigatorPanel.getChild("contenttree")
 
             xNavigatorPanelContentTreeHeadings = 
xNavigatorPanelContentTree.getChild('0')
diff --git a/sw/qa/uitest/writer_tests7/tdf135938.py 
b/sw/qa/uitest/writer_tests7/tdf135938.py
index 07298ab8d8e1..969b8c5b85ac 100755
--- a/sw/qa/uitest/writer_tests7/tdf135938.py
+++ b/sw/qa/uitest/writer_tests7/tdf135938.py
@@ -28,6 +28,13 @@ class tdf135938(UITestCase):
                 xInsert = xDialog.getChild("ok")
                 xInsert.executeAction("CLICK", tuple())
 
+                # See the `m_aUpdateTimer.SetTimeout(200)` (to "avoid 
flickering of buttons")
+                # in the SwChildWinWrapper ctor in 
sw/source/uibase/fldui/fldwrap.cxx, where that
+                # m_aUpdateTimer is started by SwChildWinWrapper::ReInitDlg 
triggered from the
+                # xInsert click above.
+                xToolkit = 
self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
+                xToolkit.waitUntilAllIdlesDispatched()
+
                 xSelect = xDialog.getChild("select-ref")
                 self.assertEqual("1", get_state_as_dict(xSelect)["Children"])
                 self.assertEqual("ABC", 
get_state_as_dict(xSelect.getChild(0))["Text"])
diff --git a/test/Library_test.mk b/test/Library_test.mk
index 951ddf6edab2..268a68744eaf 100644
--- a/test/Library_test.mk
+++ b/test/Library_test.mk
@@ -50,7 +50,6 @@ $(eval $(call gb_Library_add_exception_objects,test,\
     test/source/callgrind \
     test/source/xmltesttools \
     test/source/htmltesttools \
-    test/source/idletask \
     test/source/screenshot_test \
     test/source/unoapi_property_testers \
     test/source/lokcallback \
diff --git a/toolkit/source/awt/vclxtoolkit.cxx 
b/toolkit/source/awt/vclxtoolkit.cxx
index 7ae9cda1b6ff..7f6bd757b914 100644
--- a/toolkit/source/awt/vclxtoolkit.cxx
+++ b/toolkit/source/awt/vclxtoolkit.cxx
@@ -62,6 +62,7 @@
 #include <rtl/process.h>
 #include <sal/log.hxx>
 #include <tools/link.hxx>
+#include <vcl/idletask.hxx>
 #include <vcl/wintypes.hxx>
 
 #ifdef MACOSX
@@ -485,6 +486,8 @@ public:
 
     css::uno::Sequence< OUString > SAL_CALL getRecordingAndClear() override;
 
+    virtual void SAL_CALL waitUntilAllIdlesDispatched() override;
+
     // css::awt::XToolkit
     css::uno::Reference< css::awt::XWindowPeer >  SAL_CALL getDesktopWindow(  
) override;
     css::awt::Rectangle                                        SAL_CALL 
getWorkArea(  ) override;
@@ -2544,6 +2547,11 @@ css::uno::Sequence< OUString > 
VCLXToolkit::getRecordingAndClear()
     return comphelper::ProfileZone::getRecordingAndClear();
 }
 
+void VCLXToolkit::waitUntilAllIdlesDispatched()
+{
+    IdleTask::waitUntilIdleDispatched();
+}
+
 // css:awt:XToolkitRobot
 
 void SAL_CALL VCLXToolkit::keyPress( const css::awt::KeyEvent & aKeyEvent )
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index ffb35ceb6082..e15b54c4e918 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -385,6 +385,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/helper/displayconnectiondispatch \
     vcl/source/helper/driverblocklist \
     vcl/source/helper/evntpost \
+    vcl/source/helper/idletask \
     vcl/source/helper/lazydelete \
     vcl/source/helper/strhelper \
     vcl/source/helper/svtaccessiblefactory \
diff --git a/test/source/idletask.cxx b/vcl/source/helper/idletask.cxx
similarity index 95%
rename from test/source/idletask.cxx
rename to vcl/source/helper/idletask.cxx
index 904d98eb1e24..7df0514912db 100644
--- a/test/source/idletask.cxx
+++ b/vcl/source/helper/idletask.cxx
@@ -7,7 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include <test/idletask.hxx>
+#include <vcl/idletask.hxx>
 #include <vcl/svapp.hxx>
 
 //constructor of IdleTask Class
@@ -43,6 +43,7 @@ void IdleTask::waitUntilIdleDispatched()
     while (!idleTask.GetFlag())
     {
         //dispatching all the events via VCL main-loop
+        SolarMutexGuard aGuard;
         Application::Yield();
     }
 }

Reply via email to