aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quickcontrols/qquickmenu/data
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quickcontrols/qquickmenu/data')
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/actionShortcuts.qml50
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/actions.qml20
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/addItem.qml24
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/applicationWindowScrollable.qml26
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/applicationwindow.qml46
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/customMenuCullItems.qml55
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/customMenuUseRepeaterAsTheContentItem.qml65
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/delegateFromSeparateComponent.qml60
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/disableWhenTriggered.qml74
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/disabledMenuItemKeyNavigation.qml27
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/giveMenuItemFocusOnButtonPress.qml50
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/menuItemWidths.qml56
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/menuSeparator.qml37
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/mnemonics.qml40
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/order.qml34
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/popup.qml77
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/pressAndHold.qml26
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/removeTakeItem.qml40
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/repeater.qml22
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/scrollableWithPadding.qml32
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/subMenuDisabled.qml32
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/subMenus.qml90
-rw-r--r--tests/auto/quickcontrols/qquickmenu/data/windowScrollable.qml27
23 files changed, 1010 insertions, 0 deletions
diff --git a/tests/auto/quickcontrols/qquickmenu/data/actionShortcuts.qml b/tests/auto/quickcontrols/qquickmenu/data/actionShortcuts.qml
new file mode 100644
index 0000000000..3d839b98d4
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/actionShortcuts.qml
@@ -0,0 +1,50 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ width: 400
+ height: 400
+
+ property alias menu: menu
+ property alias subMenu: subMenu
+ property alias buttonMenu: buttonMenu
+
+ Menu {
+ id: menu
+ objectName: "menu"
+
+ Action {
+ objectName: text
+ text: "action1"
+ shortcut: "A"
+ }
+
+ Menu {
+ id: subMenu
+ objectName: "subMenu"
+
+ Action {
+ objectName: text
+ text: "subAction1"
+ shortcut: "B"
+ }
+ }
+ }
+
+ Button {
+ text: "Menu button"
+
+ Menu {
+ id: buttonMenu
+
+ Action {
+ objectName: text
+ text: "buttonMenuAction1"
+ shortcut: "C"
+ }
+ }
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickmenu/data/actions.qml b/tests/auto/quickcontrols/qquickmenu/data/actions.qml
new file mode 100644
index 0000000000..0c4449d888
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/actions.qml
@@ -0,0 +1,20 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ width: 400
+ height: 400
+
+ property alias menu: menu
+
+ Menu {
+ id: menu
+ Action { text: "action1" }
+ MenuItem { text: "menuitem2" }
+ Action { text: "action3" }
+ MenuItem { text: "menuitem4" }
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickmenu/data/addItem.qml b/tests/auto/quickcontrols/qquickmenu/data/addItem.qml
new file mode 100644
index 0000000000..5678210e25
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/addItem.qml
@@ -0,0 +1,24 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ width: 200
+ height: 200
+
+ property alias menu: menu
+
+ MenuItem {
+ id: newMenuItem
+ text: qsTr("New")
+ }
+
+ Menu {
+ id: menu
+ y: parent.height
+
+ Component.onCompleted: addItem(newMenuItem)
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickmenu/data/applicationWindowScrollable.qml b/tests/auto/quickcontrols/qquickmenu/data/applicationWindowScrollable.qml
new file mode 100644
index 0000000000..eb8140eea5
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/applicationWindowScrollable.qml
@@ -0,0 +1,26 @@
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ title: "Test Application Window"
+ width: 300
+ height: 300
+
+ property alias menu: menu
+
+ Menu {
+ id: menu
+
+ Repeater {
+ model: 20
+
+ delegate: MenuItem {
+ objectName: text
+ text: (index + 1)
+ }
+ }
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickmenu/data/applicationwindow.qml b/tests/auto/quickcontrols/qquickmenu/data/applicationwindow.qml
new file mode 100644
index 0000000000..1b42ee6965
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/applicationwindow.qml
@@ -0,0 +1,46 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ title: "Test Application Window"
+ width: 400
+ height: 400
+
+ property alias emptyMenu: emptyMenu
+ property alias menu: menu
+ property alias menuButton: menuButton
+ property Overlay overlay: menu.Overlay.overlay
+
+ Menu {
+ id: emptyMenu
+ }
+
+ Menu {
+ id: menu
+ cascade: true
+
+ MenuItem {
+ objectName: "firstMenuItem"
+ text: "A"
+ }
+ MenuItem {
+ objectName: "secondMenuItem"
+ text: "B"
+ }
+ MenuItem {
+ objectName: "thirdMenuItem"
+ text: "C"
+ }
+ }
+
+ Button {
+ id: menuButton
+ x: 250
+ visible: false
+ text: "Open Menu"
+ onClicked: menu.open()
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickmenu/data/customMenuCullItems.qml b/tests/auto/quickcontrols/qquickmenu/data/customMenuCullItems.qml
new file mode 100644
index 0000000000..0f56ecdd87
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/customMenuCullItems.qml
@@ -0,0 +1,55 @@
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+
+ApplicationWindow {
+ width: 200
+ height: 200
+ property alias menu: menu
+
+ Menu {
+ id: menu
+
+ contentItem: FocusScope {
+ implicitHeight: view.implicitHeight
+ Button {
+ anchors {
+ top: parent.top
+ topMargin: 5
+ horizontalCenter: parent.horizontalCenter
+ }
+ z: 1
+ text: "Button Up"
+ visible: view.interactive
+ }
+ ListView {
+ id: view
+ width: parent.width
+ implicitHeight: Math.min(contentHeight, 300)
+ model: menu.contentModel
+
+ clip: true
+ currentIndex: menu.currentIndex
+ ScrollIndicator.vertical: ScrollIndicator {}
+ }
+ Button {
+ anchors {
+ bottom: parent.bottom
+ bottomMargin: 5
+ horizontalCenter: parent.horizontalCenter
+ }
+ z: 1
+ text: "Button Down"
+ visible: view.interactive
+ }
+ }
+
+ Repeater {
+ model: 20
+ MenuItem {
+ objectName: "Item: " + modelData
+ text: objectName
+ }
+ }
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickmenu/data/customMenuUseRepeaterAsTheContentItem.qml b/tests/auto/quickcontrols/qquickmenu/data/customMenuUseRepeaterAsTheContentItem.qml
new file mode 100644
index 0000000000..bfa8f66be5
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/customMenuUseRepeaterAsTheContentItem.qml
@@ -0,0 +1,65 @@
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+
+ApplicationWindow {
+ width: 200
+ height: 200
+ property alias menu: menu
+
+ Menu {
+ id: menu
+ visible: true
+
+ contentItem: FocusScope {
+ implicitHeight: flickable.height
+
+ Button {
+ anchors {
+ top: parent.top
+ topMargin: 5
+ horizontalCenter: parent.horizontalCenter
+ }
+ z: 1
+ text: "Button Up"
+ }
+
+ Flickable {
+ id: flickable
+ width: parent.width
+ height: Math.min(contentHeight, 300)
+ contentHeight: repeaterLayout.implicitHeight
+ clip: true
+
+ ScrollIndicator.vertical: ScrollIndicator {}
+
+ ColumnLayout {
+ id: repeaterLayout
+ width: parent.width
+
+ Repeater {
+ model: menu.contentModel
+ }
+ }
+ }
+
+ Button {
+ anchors {
+ bottom: parent.bottom
+ bottomMargin: 5
+ horizontalCenter: parent.horizontalCenter
+ }
+ z: 1
+ text: "Button Down"
+ }
+ }
+
+ Repeater {
+ model: 20
+ MenuItem {
+ objectName: "Item: " + modelData
+ text: objectName
+ }
+ }
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickmenu/data/delegateFromSeparateComponent.qml b/tests/auto/quickcontrols/qquickmenu/data/delegateFromSeparateComponent.qml
new file mode 100644
index 0000000000..44a7d8d54a
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/delegateFromSeparateComponent.qml
@@ -0,0 +1,60 @@
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ width: 800
+ height: 800
+
+ property alias menu: menu
+
+ Component {
+ id: menuItemComponent
+
+ MenuItem {
+ contentItem: Text {
+ text: parent.text
+ color: "blue"
+ }
+ background: Rectangle {
+ color: "#00ff00"
+ }
+ }
+ }
+
+ Menu {
+ id: menu
+ title: "Root Menu"
+
+ Action {
+ text: "Action Item 1"
+ }
+ Menu {
+ title: "Sub-menu"
+ delegate: menuItemComponent
+
+ Action {
+ text: "Sub-menu Action Item 1"
+ }
+ Menu {
+ title: "Sub-sub-menu"
+ delegate: menuItemComponent
+
+ Action {
+ text: "Sub-sub-menu Action Item 1"
+ }
+ }
+ Action {
+ text: "Sub-menu Action Item 2"
+ }
+ }
+ Action {
+ text: "Action Item 2"
+ }
+
+ delegate: menuItemComponent
+ visible: true
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickmenu/data/disableWhenTriggered.qml b/tests/auto/quickcontrols/qquickmenu/data/disableWhenTriggered.qml
new file mode 100644
index 0000000000..e59026677a
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/disableWhenTriggered.qml
@@ -0,0 +1,74 @@
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ width: 400
+ height: 400
+
+ Action {
+ id: actionOutsideMenu
+ text: "Action declared outside menu"
+ onTriggered: enabled = false
+ }
+
+ menuBar: MenuBar {
+ Menu {
+ title: "Menu"
+ objectName: title
+
+ Action {
+ text: "Action"
+ objectName: text
+ onTriggered: enabled = false
+ }
+ MenuItem {
+ objectName: "MenuItem with Action"
+ action: Action {
+ text: "Action declared inside MenuItem"
+ objectName: text
+ onTriggered: enabled = false
+ }
+ }
+ MenuItem {
+ objectName: "MenuItem with Action declared outside menu"
+ action: actionOutsideMenu
+ }
+ MenuItem {
+ text: "MenuItem with no Action"
+ objectName: text
+ onTriggered: enabled = false
+ }
+
+ Menu {
+ title: "Submenu"
+ objectName: title
+
+ Action {
+ text: "Sub-Action"
+ objectName: text
+ onTriggered: enabled = false
+ }
+ MenuItem {
+ objectName: "Sub-MenuItem with Action declared inside"
+ action: Action {
+ text: "Action declared inside Sub-MenuItem"
+ objectName: text
+ onTriggered: enabled = false
+ }
+ }
+ MenuItem {
+ objectName: "Sub-MenuItem with Action declared outside menu"
+ action: actionOutsideMenu
+ }
+ MenuItem {
+ text: "Sub-MenuItem with no Action"
+ objectName: text
+ onTriggered: enabled = false
+ }
+ }
+ }
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickmenu/data/disabledMenuItemKeyNavigation.qml b/tests/auto/quickcontrols/qquickmenu/data/disabledMenuItemKeyNavigation.qml
new file mode 100644
index 0000000000..c9c893bb9c
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/disabledMenuItemKeyNavigation.qml
@@ -0,0 +1,27 @@
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ width: 200
+ height: 200
+
+ property alias menu: menu
+
+ Menu {
+ id: menu
+
+ MenuItem {
+ text: qsTr("Enabled 1")
+ }
+ MenuItem {
+ text: qsTr("Disabled 1")
+ enabled: false
+ }
+ MenuItem {
+ text: qsTr("Enabled 2")
+ }
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickmenu/data/giveMenuItemFocusOnButtonPress.qml b/tests/auto/quickcontrols/qquickmenu/data/giveMenuItemFocusOnButtonPress.qml
new file mode 100644
index 0000000000..1db3e351bc
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/giveMenuItemFocusOnButtonPress.qml
@@ -0,0 +1,50 @@
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ width: 640
+ height: 480
+
+ property alias menuButton: menuButton
+ property alias menu: menu
+
+ signal menuButtonClicked
+
+ Button {
+ id: menuButton
+ text: "Open menu"
+
+ // Buttons do not emit clicked() for enter/return, hence the Keys usage.
+ // The signal is just for the test to ensure that the return was actually handled.
+ Keys.onReturnPressed: {
+ menuButtonClicked()
+ menu.open()
+ }
+ }
+
+ Menu {
+ id: menu
+ parent: menuButton
+
+ onOpened: command1.forceActiveFocus()
+
+ MenuItem {
+ id: command1
+ objectName: text
+ text: "Command 1"
+ }
+
+ MenuItem {
+ objectName: text
+ text: "Command 2"
+ }
+
+ MenuItem {
+ objectName: text
+ text: "Command 3"
+ }
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickmenu/data/menuItemWidths.qml b/tests/auto/quickcontrols/qquickmenu/data/menuItemWidths.qml
new file mode 100644
index 0000000000..ff99abd399
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/menuItemWidths.qml
@@ -0,0 +1,56 @@
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ width: 600
+ height: 600
+
+ property alias menu: menu
+
+ Menu {
+ id: menu
+ MenuItem {
+ objectName: "MenuItem"
+ text: "MenuItem"
+ }
+ MenuSeparator {
+ objectName: "MenuSeparator"
+ }
+ Menu {
+ title: "Sub-menu"
+ objectName: "Sub-menu"
+
+ MenuItem {
+ objectName: "SubMenuItem"
+ text: "SubMenuItem"
+ }
+ }
+ Rectangle {
+ objectName: "CustomSeparator"
+ height: 2
+ color: "salmon"
+ }
+ Rectangle {
+ // Use a binding to test retranslate(), which re-evaluates all bindings.
+ implicitWidth: someValue
+ objectName: "CustomRectangleSeparator"
+ height: 2
+ color: "salmon"
+
+ property int someValue: 120
+ }
+ Control {
+ objectName: "CustomControlSeparator"
+ implicitWidth: someOtherValue
+ height: 2
+ background: Rectangle {
+ color: "navajowhite"
+ }
+
+ property int someOtherValue: 180
+ }
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickmenu/data/menuSeparator.qml b/tests/auto/quickcontrols/qquickmenu/data/menuSeparator.qml
new file mode 100644
index 0000000000..b13cd534fd
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/menuSeparator.qml
@@ -0,0 +1,37 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ width: 200
+ height: 200
+
+ property alias menu: menu
+
+ MenuItem {
+ id: newMenuItem
+ text: qsTr("New")
+ }
+
+ MenuSeparator {
+ id: menuSeparator
+ }
+
+ MenuItem {
+ id: saveMenuItem
+ text: qsTr("Save")
+ }
+
+ Menu {
+ id: menu
+ cascade: true
+
+ Component.onCompleted: {
+ addItem(newMenuItem)
+ addItem(menuSeparator)
+ addItem(saveMenuItem)
+ }
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickmenu/data/mnemonics.qml b/tests/auto/quickcontrols/qquickmenu/data/mnemonics.qml
new file mode 100644
index 0000000000..8929b00275
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/mnemonics.qml
@@ -0,0 +1,40 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ width: 400
+ height: 400
+
+ property alias menu: menu
+ property alias action: action
+ property alias menuItem: menuItem
+ property alias subMenu: subMenu
+ property alias subMenuItem: subMenuItem
+
+ Menu {
+ id: menu
+
+ Action {
+ id: action
+ text: "&Action"
+ }
+
+ MenuItem {
+ id: menuItem
+ text: "Menu &Item"
+ }
+
+ Menu {
+ id: subMenu
+ title: "Sub &Menu"
+
+ MenuItem {
+ id: subMenuItem
+ text: "&Sub Menu Item"
+ }
+ }
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickmenu/data/order.qml b/tests/auto/quickcontrols/qquickmenu/data/order.qml
new file mode 100644
index 0000000000..185c9e45c3
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/order.qml
@@ -0,0 +1,34 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ width: 200
+ height: 200
+
+ property alias menu: menu
+
+ Component {
+ id: menuItem
+ MenuItem { }
+ }
+
+ Menu {
+ id: menu
+ property alias repeater: repeater
+ MenuItem { text: "static_1" }
+ Repeater {
+ id: repeater
+ model: 2
+ MenuItem { text: "repeated_" + (index + 2) }
+ }
+ MenuItem { text: "static_4" }
+ Component.onCompleted: {
+ addItem(menuItem.createObject(menu.contentItem, {text: "dynamic_5"}))
+ addItem(menuItem.createObject(menu.contentItem, {text: "dynamic_6"}))
+ insertItem(0, menuItem.createObject(menu.contentItem, {text: "dynamic_0"}))
+ }
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickmenu/data/popup.qml b/tests/auto/quickcontrols/qquickmenu/data/popup.qml
new file mode 100644
index 0000000000..8201c9e03f
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/popup.qml
@@ -0,0 +1,77 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ width: 500
+ height: 600
+
+ property alias menu: menu
+ property alias menuItem1: menuItem1
+ property alias menuItem2: menuItem2
+ property alias menuItem3: menuItem3
+ property alias button: button
+
+ function popupAtCursor() {
+ menu.popup()
+ }
+
+ function popupAtPos(pos) {
+ menu.popup(pos)
+ }
+
+ function popupAtCoord(x, y) {
+ menu.popup(x, y)
+ }
+
+ function popupItemAtCursor(item) {
+ menu.popup(item)
+ }
+
+ function popupItemAtPos(pos, item) {
+ menu.popup(pos, item)
+ }
+
+ function popupItemAtCoord(x, y, item) {
+ menu.popup(x, y, item)
+ }
+
+ function popupAtParentCursor(parent) {
+ menu.popup(parent)
+ }
+
+ function popupAtParentPos(parent, pos) {
+ menu.popup(parent, pos)
+ }
+
+ function popupAtParentCoord(parent, x, y) {
+ menu.popup(parent, x, y)
+ }
+
+ function popupItemAtParentCursor(parent, item) {
+ menu.popup(parent, item)
+ }
+
+ function popupItemAtParentPos(parent, pos, item) {
+ menu.popup(parent, pos, item)
+ }
+
+ function popupItemAtParentCoord(parent, x, y, item) {
+ menu.popup(parent, x, y, item)
+ }
+
+ Menu {
+ id: menu
+ MenuItem { id: menuItem1; text: "Foo" }
+ MenuItem { id: menuItem2; text: "Bar" }
+ MenuItem { id: menuItem3; text: "Baz" }
+ }
+
+ Button {
+ id: button
+ text: "Button"
+ anchors.centerIn: parent
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickmenu/data/pressAndHold.qml b/tests/auto/quickcontrols/qquickmenu/data/pressAndHold.qml
new file mode 100644
index 0000000000..ac0f394604
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/pressAndHold.qml
@@ -0,0 +1,26 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ width: 400
+ height: 400
+
+ property alias menu: menu
+
+ MouseArea {
+ anchors.fill: parent
+ onPressAndHold: menu.open()
+ }
+
+ Menu {
+ id: menu
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ MenuItem { text: "One" }
+ MenuItem { text: "Two" }
+ MenuItem { text: "Three" }
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickmenu/data/removeTakeItem.qml b/tests/auto/quickcontrols/qquickmenu/data/removeTakeItem.qml
new file mode 100644
index 0000000000..aa321cb3a9
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/removeTakeItem.qml
@@ -0,0 +1,40 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ width: 200
+ height: 200
+
+ property alias menu: menu
+ property alias menuItem1: menuItem1
+ property alias menuItem2: menuItem2
+ property alias menuItem3: menuItem3
+
+ function takeSecondItem() {
+ return menu.takeItem(1)
+ }
+
+ function removeFirstItem() {
+ menu.removeItem(menuItem1)
+ }
+
+ function removeNullItem() {
+ menu.removeItem(null)
+ }
+
+ Menu {
+ id: menu
+ MenuItem {
+ id: menuItem1
+ }
+ MenuItem {
+ id: menuItem2
+ }
+ MenuItem {
+ id: menuItem3
+ }
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickmenu/data/repeater.qml b/tests/auto/quickcontrols/qquickmenu/data/repeater.qml
new file mode 100644
index 0000000000..3c056a1d38
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/repeater.qml
@@ -0,0 +1,22 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ width: 200
+ height: 200
+
+ property alias menu: menu
+ property alias repeater: repeater
+
+ Menu {
+ id: menu
+ Repeater {
+ id: repeater
+ model: 5
+ MenuItem { property int idx: index }
+ }
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickmenu/data/scrollableWithPadding.qml b/tests/auto/quickcontrols/qquickmenu/data/scrollableWithPadding.qml
new file mode 100644
index 0000000000..842cb33bfd
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/scrollableWithPadding.qml
@@ -0,0 +1,32 @@
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Window
+
+Window {
+ title: "Test Window"
+ width: 300
+ height: dummyItem.height * 10
+
+ property alias menu: menu
+ MenuItem {
+ id: dummyItem
+ objectName: "Dummy"
+ text: objectName
+ }
+
+ Menu {
+ id: menu
+ topPadding: 10
+ Repeater {
+ model: 10
+
+ delegate: MenuItem {
+ objectName: text
+ text: (index + 1)
+ }
+ }
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickmenu/data/subMenuDisabled.qml b/tests/auto/quickcontrols/qquickmenu/data/subMenuDisabled.qml
new file mode 100644
index 0000000000..4d5db0bd67
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/subMenuDisabled.qml
@@ -0,0 +1,32 @@
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ width: 600
+ height: 400
+
+ property alias mainMenu: mainMenu
+ property alias subMenu: subMenu
+
+ Menu {
+ id: mainMenu
+ title: "Menu"
+
+ Menu {
+ id: subMenu
+ title: "Sub Menu"
+ MenuItem {
+ id: subMenuItem1
+ text: "Sub Menu Item 1"
+ enabled: false
+ }
+ MenuItem {
+ id: subMenuItem2
+ text: "Sub Menu Item 2"
+ }
+ }
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickmenu/data/subMenus.qml b/tests/auto/quickcontrols/qquickmenu/data/subMenus.qml
new file mode 100644
index 0000000000..280fd404e8
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/subMenus.qml
@@ -0,0 +1,90 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ width: 600
+ height: 400
+
+ property alias mainMenu: mainMenu
+ property alias subMenu1: subMenu1
+ property alias subMenu2: subMenu2
+ property alias subSubMenu1: subSubMenu1
+
+ Menu {
+ id: mainMenu
+ MenuItem {
+ id: mainMenuItem1
+ objectName: "mainMenuItem1"
+ text: "Main 1"
+ }
+
+ Menu {
+ overlap: 0
+ id: subMenu1
+ objectName: "subMenu1"
+ title: "Sub Menu 1"
+
+ MenuItem {
+ id: subMenuItem1
+ objectName: "subMenuItem1"
+ text: "Sub 1"
+ }
+
+ MenuItem {
+ id: subMenuItem2
+ objectName: "subMenuItem2"
+ text: "Sub 2"
+ }
+
+ Menu {
+ overlap: 0
+ id: subSubMenu1
+ objectName: "subSubMenu1"
+ title: "Sub Sub Menu 1"
+
+ MenuItem {
+ id: subSubMenuItem1
+ objectName: "subSubMenuItem1"
+ text: "Sub Sub 1"
+ }
+ MenuItem {
+ id: subSubMenuItem2
+ objectName: "subSubMenuItem2"
+ text: "Sub Sub 2"
+ }
+ }
+ }
+
+ MenuItem {
+ id: mainMenuItem2
+ objectName: "mainMenuItem2"
+ text: "Main 2"
+ }
+
+ Menu {
+ id: subMenu2
+ objectName: "subMenu2"
+ title: "Sub Menu 2"
+
+ MenuItem {
+ id: subMenuItem3
+ objectName: "subMenuItem3"
+ text: "Sub 3"
+ }
+ MenuItem {
+ id: subMenuItem4
+ objectName: "subMenuItem4"
+ text: "Sub 4"
+ }
+ }
+
+ MenuItem {
+ id: mainMenuItem3
+ objectName: "mainMenuItem3"
+ text: "Main 3"
+ }
+ }
+}
diff --git a/tests/auto/quickcontrols/qquickmenu/data/windowScrollable.qml b/tests/auto/quickcontrols/qquickmenu/data/windowScrollable.qml
new file mode 100644
index 0000000000..97a06da63d
--- /dev/null
+++ b/tests/auto/quickcontrols/qquickmenu/data/windowScrollable.qml
@@ -0,0 +1,27 @@
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Window
+
+Window {
+ title: "Test Window"
+ width: 300
+ height: 300
+
+ property alias menu: menu
+
+ Menu {
+ id: menu
+
+ Repeater {
+ model: 20
+
+ delegate: MenuItem {
+ objectName: text
+ text: (index + 1)
+ }
+ }
+ }
+}