diff options
author | Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> | 2015-03-30 19:15:34 +0200 |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> | 2015-04-16 12:13:17 +0000 |
commit | 13aad0cf03170cde6dd147f9d2ce460bac98d712 (patch) | |
tree | 3b5cc24d9c6e4095ce2c0d0f88fce4e04619f4dc /tests | |
parent | 5da5925ca6c676a8b36ebd863267b04906ef57d2 (diff) | |
download | qtquickcontrols-13aad0cf03170cde6dd147f9d2ce460bac98d712.tar.gz |
Menu: Add aboutToShow, aboutToHide signals
These do the same as for QMenu, and are emitted
right before the pop-up is shown or hidden. On
Mac, these signals are emitted by the QPA plugin
and relayed by QQuickMenu.
Task-number: QTBUG-40576
Change-Id: I59113d8d9cc8c5b3140f4f552772d33dd0b6e138
Reviewed-by: Caroline Chao <caroline.chao@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/controls/data/tst_menu.qml | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_menu.qml b/tests/auto/controls/data/tst_menu.qml index ca266466..83411bcf 100644 --- a/tests/auto/controls/data/tst_menu.qml +++ b/tests/auto/controls/data/tst_menu.qml @@ -65,6 +65,18 @@ TestCase { signalName: "triggered" } + SignalSpy { + id: aboutToShowSpy + target: testcase.menu + signalName: "aboutToShow" + } + + SignalSpy { + id: aboutToHideSpy + target: testcase.menu + signalName: "aboutToHide" + } + Component { id: creationComponent Menu { @@ -82,6 +94,8 @@ TestCase { function cleanup() { menuSpy.clear() menuItemSpy.clear() + aboutToShowSpy.clear() + aboutToHideSpy.clear() if (menu !== 0) menu.destroy() } @@ -218,4 +232,20 @@ TestCase { compare(item.text, "Item " + i) } } + + function test_popupSignals() { + if (Qt.platform.os === "osx") { + // On Mac the popup() function blocks. The signals are still + // emitted by the QPA plugin and the relayed by QQuickMenu. + return; + } + menu.__popup(Qt.rect(50, 50, 20, 20)) + wait(100) // Give it a chance to actually pop-up + compare(aboutToShowSpy.count, 1) + compare(aboutToHideSpy.count, 0) + aboutToShowSpy.clear() + menu.__dismissMenu() + compare(aboutToShowSpy.count, 0) + compare(aboutToHideSpy.count, 1) + } } |