65 void testMouseDragOutside(); |
65 void testMouseDragOutside(); |
66 void testMouseDragToNonClientArea(); |
66 void testMouseDragToNonClientArea(); |
67 void testDragWindow(); |
67 void testDragWindow(); |
68 void testMouseEnter(); |
68 void testMouseEnter(); |
69 void testChildDialogInFrontOfModalParent(); |
69 void testChildDialogInFrontOfModalParent(); |
|
70 #ifdef QT_MAC_USE_COCOA |
|
71 void testChildWindowInFrontOfParentWindow(); |
|
72 // void testChildToolWindowInFrontOfChildNormalWindow(); |
|
73 void testChildWindowInFrontOfStaysOnTopParentWindow(); |
|
74 #endif |
70 void testKeyPressOnToplevel(); |
75 void testKeyPressOnToplevel(); |
71 }; |
76 }; |
72 |
77 |
73 void tst_MacNativeEvents::testMouseMoveLocation() |
78 void tst_MacNativeEvents::testMouseMoveLocation() |
74 { |
79 { |
306 native.play(); |
311 native.play(); |
307 QTest::qWait(100); |
312 QTest::qWait(100); |
308 QVERIFY(!child.isVisible()); |
313 QVERIFY(!child.isVisible()); |
309 } |
314 } |
310 |
315 |
|
316 #ifdef QT_MAC_USE_COCOA |
|
317 void tst_MacNativeEvents::testChildWindowInFrontOfParentWindow() |
|
318 { |
|
319 // Test that a child window always stacks in front of its parent window. |
|
320 // Do this by first click on the parent, then on the child window button. |
|
321 QWidget parent; |
|
322 QPushButton child("a button", &parent); |
|
323 child.setWindowFlags(Qt::Window); |
|
324 connect(&child, SIGNAL(clicked()), &child, SLOT(close())); |
|
325 parent.show(); |
|
326 child.show(); |
|
327 |
|
328 QPoint parent_p = parent.geometry().bottomLeft() + QPoint(20, -20); |
|
329 QPoint child_p = child.geometry().center(); |
|
330 |
|
331 NativeEventList native; |
|
332 native.append(new QNativeMouseButtonEvent(parent_p, Qt::LeftButton, 1, Qt::NoModifier)); |
|
333 native.append(new QNativeMouseButtonEvent(parent_p, Qt::LeftButton, 0, Qt::NoModifier)); |
|
334 native.append(new QNativeMouseButtonEvent(child_p, Qt::LeftButton, 1, Qt::NoModifier)); |
|
335 native.append(new QNativeMouseButtonEvent(child_p, Qt::LeftButton, 0, Qt::NoModifier)); |
|
336 |
|
337 native.play(); |
|
338 QTest::qWait(100); |
|
339 QVERIFY(!child.isVisible()); |
|
340 } |
|
341 |
|
342 /* This test can be enabled once setStackingOrder has been fixed in qwidget_mac.mm |
|
343 void tst_MacNativeEvents::testChildToolWindowInFrontOfChildNormalWindow() |
|
344 { |
|
345 // Test that a child tool window always stacks in front of normal sibling windows. |
|
346 // Do this by first click on the sibling, then on the tool window button. |
|
347 QWidget parent; |
|
348 QWidget normalChild(&parent, Qt::Window); |
|
349 QPushButton toolChild("a button", &parent); |
|
350 toolChild.setWindowFlags(Qt::Tool); |
|
351 connect(&toolChild, SIGNAL(clicked()), &toolChild, SLOT(close())); |
|
352 parent.show(); |
|
353 normalChild.show(); |
|
354 toolChild.show(); |
|
355 |
|
356 QPoint normalChild_p = normalChild.geometry().bottomLeft() + QPoint(20, -20); |
|
357 QPoint toolChild_p = toolChild.geometry().center(); |
|
358 |
|
359 NativeEventList native; |
|
360 native.append(new QNativeMouseButtonEvent(normalChild_p, Qt::LeftButton, 1, Qt::NoModifier)); |
|
361 native.append(new QNativeMouseButtonEvent(normalChild_p, Qt::LeftButton, 0, Qt::NoModifier)); |
|
362 native.append(new QNativeMouseButtonEvent(toolChild_p, Qt::LeftButton, 1, Qt::NoModifier)); |
|
363 native.append(new QNativeMouseButtonEvent(toolChild_p, Qt::LeftButton, 0, Qt::NoModifier)); |
|
364 |
|
365 native.play(); |
|
366 QTest::qWait(100); |
|
367 QVERIFY(!toolChild.isVisible()); |
|
368 } |
|
369 */ |
|
370 void tst_MacNativeEvents::testChildWindowInFrontOfStaysOnTopParentWindow() |
|
371 { |
|
372 // Test that a child window stacks on top of a stays-on-top parent. |
|
373 QWidget parent(0, Qt::WindowStaysOnTopHint); |
|
374 QPushButton button("close", &parent); |
|
375 button.setWindowFlags(Qt::Window); |
|
376 connect(&button, SIGNAL(clicked()), &button, SLOT(close())); |
|
377 parent.show(); |
|
378 button.show(); |
|
379 QPoint inside = button.geometry().center(); |
|
380 |
|
381 // Post a click on the button to close the child dialog: |
|
382 NativeEventList native; |
|
383 native.append(new QNativeMouseButtonEvent(inside, Qt::LeftButton, 1, Qt::NoModifier)); |
|
384 native.append(new QNativeMouseButtonEvent(inside, Qt::LeftButton, 0, Qt::NoModifier)); |
|
385 |
|
386 native.play(); |
|
387 QTest::qWait(100); |
|
388 QVERIFY(!button.isVisible()); |
|
389 } |
|
390 #endif |
|
391 |
311 void tst_MacNativeEvents::testKeyPressOnToplevel() |
392 void tst_MacNativeEvents::testKeyPressOnToplevel() |
312 { |
393 { |
313 // Check that we receive keyevents for |
394 // Check that we receive keyevents for |
314 // toplevel widgets. For leagacy reasons, and according to Qt on |
395 // toplevel widgets. For leagacy reasons, and according to Qt on |
315 // other platforms (carbon port + linux), we should get these events |
396 // other platforms (carbon port + linux), we should get these events |