diff options
author | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2010-08-17 12:37:32 (GMT) |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2010-08-17 13:14:41 (GMT) |
commit | 608ed55d87a714be9b0b9681345bd012b40db4e5 (patch) | |
tree | 626a237e692e803ef2bdf43f1d856ca4296bfc60 /tests/auto/macnativeevents | |
parent | 40a2971d2ebe2b7409c13ab049ed26b249033d8e (diff) | |
download | Qt-608ed55d87a714be9b0b9681345bd012b40db4e5.zip Qt-608ed55d87a714be9b0b9681345bd012b40db4e5.tar.gz Qt-608ed55d87a714be9b0b9681345bd012b40db4e5.tar.bz2 |
Cocoa: add autotest to be more safe regarding child window stacking
Autotests only. Use native events on mac to check that child windows
stays on top of parent windows.
Reviewed-by: prasanth
Diffstat (limited to 'tests/auto/macnativeevents')
-rw-r--r-- | tests/auto/macnativeevents/tst_macnativeevents.cpp | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/tests/auto/macnativeevents/tst_macnativeevents.cpp b/tests/auto/macnativeevents/tst_macnativeevents.cpp index ffd0596..ac7d661 100644 --- a/tests/auto/macnativeevents/tst_macnativeevents.cpp +++ b/tests/auto/macnativeevents/tst_macnativeevents.cpp @@ -67,6 +67,11 @@ private slots: void testDragWindow(); void testMouseEnter(); void testChildDialogInFrontOfModalParent(); +#ifdef QT_MAC_USE_COCOA + void testChildWindowInFrontOfParentWindow(); + void testChildToolWindowInFrontOfChildNormalWindow(); + void testChildWindowInFrontOfStaysOnTopParentWindow(); +#endif void testKeyPressOnToplevel(); }; @@ -308,6 +313,81 @@ void tst_MacNativeEvents::testChildDialogInFrontOfModalParent() QVERIFY(!child.isVisible()); } +#ifdef QT_MAC_USE_COCOA +void tst_MacNativeEvents::testChildWindowInFrontOfParentWindow() +{ + // Test that a child window always stacks in front of its parent window. + // Do this by first click on the parent, then on the child window button. + QWidget parent; + QPushButton child("a button", &parent); + child.setWindowFlags(Qt::Window); + connect(&child, SIGNAL(clicked()), &child, SLOT(close())); + parent.show(); + child.show(); + + QPoint parent_p = parent.geometry().bottomLeft() + QPoint(20, -20); + QPoint child_p = child.geometry().center(); + + NativeEventList native; + native.append(new QNativeMouseButtonEvent(parent_p, Qt::LeftButton, 1, Qt::NoModifier)); + native.append(new QNativeMouseButtonEvent(parent_p, Qt::LeftButton, 0, Qt::NoModifier)); + native.append(new QNativeMouseButtonEvent(child_p, Qt::LeftButton, 1, Qt::NoModifier)); + native.append(new QNativeMouseButtonEvent(child_p, Qt::LeftButton, 0, Qt::NoModifier)); + + native.play(); + QTest::qWait(100); + QVERIFY(!child.isVisible()); +} + +void tst_MacNativeEvents::testChildToolWindowInFrontOfChildNormalWindow() +{ + // Test that a child tool window always stacks in front of normal sibling windows. + // Do this by first click on the sibling, then on the tool window button. + QWidget parent; + QWidget normalChild(&parent, Qt::Window); + QPushButton toolChild("a button", &parent); + toolChild.setWindowFlags(Qt::Tool); + connect(&toolChild, SIGNAL(clicked()), &toolChild, SLOT(close())); + parent.show(); + normalChild.show(); + toolChild.show(); + + QPoint normalChild_p = normalChild.geometry().bottomLeft() + QPoint(20, -20); + QPoint toolChild_p = toolChild.geometry().center(); + + NativeEventList native; + native.append(new QNativeMouseButtonEvent(normalChild_p, Qt::LeftButton, 1, Qt::NoModifier)); + native.append(new QNativeMouseButtonEvent(normalChild_p, Qt::LeftButton, 0, Qt::NoModifier)); + native.append(new QNativeMouseButtonEvent(toolChild_p, Qt::LeftButton, 1, Qt::NoModifier)); + native.append(new QNativeMouseButtonEvent(toolChild_p, Qt::LeftButton, 0, Qt::NoModifier)); + + native.play(); + QTest::qWait(100); + QVERIFY(!toolChild.isVisible()); +} + +void tst_MacNativeEvents::testChildWindowInFrontOfStaysOnTopParentWindow() +{ + // Test that a child window stacks on top of a stays-on-top parent. + QWidget parent(0, Qt::WindowStaysOnTopHint); + QPushButton button("close", &parent); + button.setWindowFlags(Qt::Window); + connect(&button, SIGNAL(clicked()), &button, SLOT(close())); + parent.show(); + button.show(); + QPoint inside = button.geometry().center(); + + // Post a click on the button to close the child dialog: + NativeEventList native; + native.append(new QNativeMouseButtonEvent(inside, Qt::LeftButton, 1, Qt::NoModifier)); + native.append(new QNativeMouseButtonEvent(inside, Qt::LeftButton, 0, Qt::NoModifier)); + + native.play(); + QTest::qWait(100); + QVERIFY(!button.isVisible()); +} +#endif + void tst_MacNativeEvents::testKeyPressOnToplevel() { // Check that we receive keyevents for |