[Ktutorial-commits] SF.net SVN: ktutorial:[351] trunk/ktutorial/ktutorial-library/tests/view/ Windo
Status: Alpha
Brought to you by:
danxuliu
From: <dan...@us...> - 2012-06-29 16:05:51
|
Revision: 351 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=351&view=rev Author: danxuliu Date: 2012-06-29 16:05:44 +0000 (Fri, 29 Jun 2012) Log Message: ----------- Add skipped failing test as reference of an unsolved bug: when setting the base window in the WindowOnTopEnforcer only the base window can be visible. If there is a modal widget or modal dialog visible (for example, if a tutorial is tested in the editor when the target application is showing a modal dialog), the window to keep on top is not reparented properly, and it appears on top only of its base window, but not on top of the modal widgets or modal dialogs. I have not found a fix for it yet. Modified Paths: -------------- trunk/ktutorial/ktutorial-library/tests/view/WindowOnTopEnforcerTest.cpp Modified: trunk/ktutorial/ktutorial-library/tests/view/WindowOnTopEnforcerTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/tests/view/WindowOnTopEnforcerTest.cpp 2012-06-29 15:57:55 UTC (rev 350) +++ trunk/ktutorial/ktutorial-library/tests/view/WindowOnTopEnforcerTest.cpp 2012-06-29 16:05:44 UTC (rev 351) @@ -59,6 +59,8 @@ void testShowNestedModalWidgetsInMixedOrder(); + void testSetBaseWindowAfterSeveralModalWidgetsWereShown(); + private: void queueAssertParent(QWidget* widget, QWidget* parent, int timeToWait); @@ -826,6 +828,101 @@ QVERIFY(!windowToKeepOnTop); } +//There is a limitation in the current behavior of WindowOnTopEnforcer which can +//show up as a bug when testing a tutorial from the editor. The limitation is +//that, to work properly, the base window must be set in the WindowOnTopEnforcer +//when there is only one window. If there are modal widgets or modal dialogs the +//reparenting does not work as it should, and the widget to keep on top of the +//others is only kept on top of the main window, but below the modal widgets or +//modal dialogs. This can happen, for example, if a tutorial is tested in the +//edtior when the target application is showing a modal dialog. +//The reason is that the reparenting system works using a stack that stores +//the order in which modal widgets or modal dialogs were opened, so it can +//reparent them back to the proper one when they are hidden. That stack is built +//once the base window was set by spying the show and hidden events of its child +//windows. However, I have not found any way to initialize it with the proper +//order of windows if they are already visible when the base window is set. +//The modal stack is stored by Qt in the variable QWidgetList* qt_modal_stack +//(declared in qapplication.cpp). Alas, this variable seems to be not exported, +//so it can not be used to initialize the WindowOnTopEnforcer stack. +//I have tried another approach spying WindowBlocked and WindowUnblocked events +//and not using a stack at all, but I was not able to come with anything that +//worked in all the cases. +//So... I just keep this test here as a reference of something that should be +//fixed, but that unfortunately I do not know how to do it :( +void WindowOnTopEnforcerTest:: + testSetBaseWindowAfterSeveralModalWidgetsWereShown() { + QSKIP("Pending bug: WindowOnTopEnforcer does not work properly if there \ +are modal widgets already shown when the base window is set. However, I have \ +not found a fix for it yet :(", SkipAll); + + QWidget* window = new QWidget(); + window->setWindowTitle("Window"); + window->show(); + + QPointer<QWidget> windowToKeepOnTop = new QWidget(window); + windowToKeepOnTop->setWindowTitle("Window to keep on top"); + windowToKeepOnTop->setWindowFlags(Qt::Dialog); + windowToKeepOnTop->show(); + + QWidget* siblingModalWidget = new QWidget(window); + siblingModalWidget->setWindowTitle("Sibling modal widget"); + siblingModalWidget->setWindowFlags(Qt::Window); + siblingModalWidget->setWindowModality(Qt::ApplicationModal); + siblingModalWidget->show(); + + QWidget* modalWidget = new QWidget(window); + modalWidget->setWindowTitle("Modal widget"); + modalWidget->setWindowFlags(Qt::Window); + modalWidget->setWindowModality(Qt::ApplicationModal); + modalWidget->show(); + + QWidget* nestedModalWidget = new QWidget(window); + nestedModalWidget->setWindowTitle("Nested modal widget"); + nestedModalWidget->setWindowFlags(Qt::Window); + nestedModalWidget->setWindowModality(Qt::ApplicationModal); + nestedModalWidget->show(); + + QWidget* nestedSiblingModalWidget = new QWidget(siblingModalWidget); + nestedSiblingModalWidget->setWindowTitle("Nested sibling modal widget"); + nestedSiblingModalWidget->setWindowFlags(Qt::Window); + nestedSiblingModalWidget->setWindowModality(Qt::ApplicationModal); + nestedSiblingModalWidget->show(); + + WindowOnTopEnforcer* enforcer = new WindowOnTopEnforcer(windowToKeepOnTop); + enforcer->setBaseWindow(window); + + assertWindow(windowToKeepOnTop, nestedSiblingModalWidget); + + nestedSiblingModalWidget->hide(); + + assertWindow(windowToKeepOnTop, nestedModalWidget); + + nestedSiblingModalWidget->show(); + + assertWindow(windowToKeepOnTop, nestedSiblingModalWidget); + + delete nestedSiblingModalWidget; + + assertWindow(windowToKeepOnTop, nestedModalWidget); + + delete nestedModalWidget; + + assertWindow(windowToKeepOnTop, modalWidget); + + delete modalWidget; + + assertWindow(windowToKeepOnTop, siblingModalWidget); + + delete siblingModalWidget; + + assertWindow(windowToKeepOnTop, window); + + delete window; + + QVERIFY(!windowToKeepOnTop); +} + /////////////////////////////////// Helpers //////////////////////////////////// //The dialogs are modal, so they won't return to the test code until they are This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |