summaryrefslogtreecommitdiff
path: root/tests/auto/controls/data/tst_menubar.qml
diff options
context:
space:
mode:
authorFilippo Cucchetto <filippocucchetto@gmail.com>2015-08-01 16:54:05 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-08-25 03:37:45 +0000
commit388da47ea0b8dea55e52f623531c0f07b543b460 (patch)
treeba344a26655f1606c1c4bc9eca2f01174dd9709d /tests/auto/controls/data/tst_menubar.qml
parent66b68ed94032e03b7a0ed9d15f72b1fc5e2cb729 (diff)
downloadqtquickcontrols-388da47ea0b8dea55e52f623531c0f07b543b460.tar.gz
Added menubar click test
Added a simple test that click on a menubar root menu Change-Id: I699063a01a76a1b116eccbcc0326782908107a71 Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'tests/auto/controls/data/tst_menubar.qml')
-rw-r--r--tests/auto/controls/data/tst_menubar.qml54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_menubar.qml b/tests/auto/controls/data/tst_menubar.qml
index bf6371e0..c71cdc33 100644
--- a/tests/auto/controls/data/tst_menubar.qml
+++ b/tests/auto/controls/data/tst_menubar.qml
@@ -39,6 +39,7 @@
****************************************************************************/
import QtQuick 2.2
+import QtQuick.Controls 1.3
import QtTest 1.0
TestCase {
@@ -48,8 +49,61 @@ TestCase {
width:400
height:400
+ Component {
+ id: windowComponent
+ ApplicationWindow {
+ width: 300; height: 300
+ visible: true
+ menuBar: MenuBar {
+ Menu {
+ title: "&File"; objectName: "fileMenu"
+ Menu {
+ title: "&Recent Files"; objectName: "actionSubMenu"
+ MenuItem { text: "RecentFile1"; objectName: "recentFile1MenuItem" }
+ MenuItem { text: "RecentFile2"; objectName: "recentFile2MenuItem" }
+ }
+ MenuItem { text: "&Save"; objectName: "saveMenuItem" }
+ MenuItem { text: "&Load"; objectName: "loadMenuItem" }
+ MenuItem { text: "&Exit"; objectName: "exitMenuItem" }
+ }
+ Menu {
+ title: "&Edit"; objectName: "editMenu"
+ Menu {
+ title: "&Advanced"; objectName: "advancedSubMenu"
+ MenuItem { text: "advancedOption1"; objectName: "advancedOption1MenuItem" }
+ }
+ MenuItem { text: "&Preferences"; objectName: "preferencesMenuItem" }
+ }
+ }
+ }
+ }
+
function test_createMenuBar() {
var menuBar = Qt.createQmlObject('import QtQuick.Controls 1.2; MenuBar {}', testCase, '');
menuBar.destroy()
}
+
+ function test_clickMenuBar() {
+ if (Qt.platform.os === "osx")
+ skip("MenuBar cannot be reliably tested on OS X")
+
+ var window = windowComponent.createObject()
+ waitForRendering(window.contentItem)
+ var fileMenu = findChild(window, "fileMenu")
+ compare(fileMenu !== null, true)
+ // Click menu should open
+ compare(fileMenu.__popupVisible, false)
+ mouseClick(fileMenu.__visualItem)
+ tryCompare(fileMenu, "__popupVisible", true)
+ // wait until popup is visible
+ tryCompare(fileMenu.__contentItem, "status", Loader.Ready)
+ waitForRendering(fileMenu.__contentItem.item)
+ // Clicking on menu should close, we workaround the current
+ // implementation event routing of the TestCase suite.
+ // We send the event to an item that is child of the menupopupwindow
+ // to a a negative coordinate
+ mouseClick(fileMenu.__contentItem, 20, -13)
+ tryCompare(fileMenu, "__popupVisible", false)
+ window.destroy()
+ }
}