summaryrefslogtreecommitdiffstats
path: root/tests/auto/macnativeevents
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-08-25 16:00:47 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-08-25 16:00:47 (GMT)
commit913ea0d5cdee3a182a811db2bb9440aee679ae08 (patch)
tree79708faf5c379948eb5aa2f84cb24488a9cb0c4f /tests/auto/macnativeevents
parent5c45c66b1743645b77826ad61508a79eadd48414 (diff)
parentd9dd68c4400c3ca590ea425d6f3d070ea6094099 (diff)
downloadQt-913ea0d5cdee3a182a811db2bb9440aee679ae08.zip
Qt-913ea0d5cdee3a182a811db2bb9440aee679ae08.tar.gz
Qt-913ea0d5cdee3a182a811db2bb9440aee679ae08.tar.bz2
Merge remote branch 'origin/4.7' into qt-master-from-4.7
Conflicts: qmake/generators/win32/msbuild_objectmodel.cpp src/declarative/qml/qdeclarativexmlhttprequest.cpp src/opengl/opengl.pro src/opengl/qgl_p.h src/plugins/bearer/connman/qconnmanservice_linux.cpp tests/auto/qpainter/tst_qpainter.cpp tools/assistant/tools/assistant/helpviewer_qwv.h tools/assistant/tools/assistant/openpageswidget.h
Diffstat (limited to 'tests/auto/macnativeevents')
-rw-r--r--tests/auto/macnativeevents/tst_macnativeevents.cpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/tests/auto/macnativeevents/tst_macnativeevents.cpp b/tests/auto/macnativeevents/tst_macnativeevents.cpp
index 16638ce..742267f 100644
--- a/tests/auto/macnativeevents/tst_macnativeevents.cpp
+++ b/tests/auto/macnativeevents/tst_macnativeevents.cpp
@@ -68,6 +68,11 @@ private slots:
void testDragWindow();
void testMouseEnter();
void testChildDialogInFrontOfModalParent();
+#ifdef QT_MAC_USE_COCOA
+ void testChildWindowInFrontOfParentWindow();
+// void testChildToolWindowInFrontOfChildNormalWindow();
+ void testChildWindowInFrontOfStaysOnTopParentWindow();
+#endif
void testKeyPressOnToplevel();
void testModifierShift();
void testModifierAlt();
@@ -313,6 +318,82 @@ 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());
+}
+
+/* This test can be enabled once setStackingOrder has been fixed in qwidget_mac.mm
+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