summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2016-02-29 07:56:51 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2016-02-29 07:57:09 +0100
commit6e96c1d6ea3c101f418c3ec95d49999f836ef60c (patch)
tree1858d3bee0e1dde25986b53909a5d055bab839c7 /tests
parent1c5f765658432a08ed52523c3a4547ab2b4a58f1 (diff)
parent0f16932a88f9504e9e3de7cd5e88f6030119528c (diff)
downloadqtquickcontrols-6e96c1d6ea3c101f418c3ec95d49999f836ef60c.tar.gz
Merge remote-tracking branch 'origin/5.6' into 5.7v5.7.0-alpha1
Change-Id: I1bf9c0967db59e25ed7fd848269246d611364f4b
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/controls/data/tst_menubar.qml100
1 files changed, 97 insertions, 3 deletions
diff --git a/tests/auto/controls/data/tst_menubar.qml b/tests/auto/controls/data/tst_menubar.qml
index 4d2ae7fc..e011746e 100644
--- a/tests/auto/controls/data/tst_menubar.qml
+++ b/tests/auto/controls/data/tst_menubar.qml
@@ -59,6 +59,8 @@ TestCase {
width:400
height:400
+ readonly property int waitTime: 200
+
Component {
id: windowComponent
ApplicationWindow {
@@ -148,12 +150,104 @@ TestCase {
verify(fileMenu)
tryCompare(fileMenu, "__popupVisible", false)
mousePress(fileMenu.__visualItem)
- wait(200);
+ wait(waitTime);
tryCompare(fileMenu, "__popupVisible", true)
mouseMove(fileMenu.__contentItem, 0, -10)
- wait(200)
+ wait(waitTime)
mouseRelease(fileMenu.__contentItem, 0, -10)
tryCompare(fileMenu, "__popupVisible", true)
- wait(200)
+ wait(waitTime)
+
+ window.destroy();
+ }
+
+ function test_keyNavigation() {
+ 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")
+ verify(fileMenu)
+ var editMenu = findChild(window, "editMenu")
+ verify(editMenu)
+
+ // Click menu should open
+ tryCompare(fileMenu, "__popupVisible", false)
+ mouseClick(fileMenu.__visualItem)
+ wait(waitTime)
+ tryCompare(fileMenu, "__popupVisible", true)
+ tryCompare(fileMenu, "__currentIndex", -1)
+ tryCompare(fileMenu.__contentItem, "status", Loader.Ready)
+
+ // Move right
+ tryCompare(editMenu, "__popupVisible", false)
+ keyPress(Qt.Key_Right, Qt.NoModifier, waitTime)
+ keyRelease(Qt.Key_Right, Qt.NoModifier, waitTime)
+ tryCompare(editMenu, "__popupVisible", true)
+ tryCompare(editMenu.__contentItem, "status", Loader.Ready)
+
+ // Move left
+ tryCompare(fileMenu, "__popupVisible", false)
+ keyPress(Qt.Key_Left, Qt.NoModifier, waitTime)
+ keyRelease(Qt.Key_Left, Qt.NoModifier, waitTime)
+ tryCompare(fileMenu, "__popupVisible", true)
+ tryCompare(fileMenu, "__currentIndex", 0)
+ tryCompare(fileMenu.__contentItem, "status", Loader.Ready)
+
+ // Move down
+ var saveMenuItem = findChild(window, "saveMenuItem")
+ verify(saveMenuItem)
+ tryCompare(saveMenuItem.__visualItem.styleData, "selected", false)
+ keyPress(Qt.Key_Down, Qt.NoModifier, waitTime)
+ keyRelease(Qt.Key_Down, Qt.NoModifier, waitTime)
+ tryCompare(fileMenu, "__currentIndex", 1)
+ tryCompare(saveMenuItem.__visualItem.styleData, "selected", true)
+
+ // Move up
+ var recentFilesSubMenu = findChild(window, "recentFilesSubMenu")
+ verify(recentFilesSubMenu)
+ tryCompare(recentFilesSubMenu.__visualItem.styleData, "selected", false)
+ keyPress(Qt.Key_Up, Qt.NoModifier, waitTime)
+ keyRelease(Qt.Key_Up, Qt.NoModifier, waitTime)
+ tryCompare(fileMenu, "__currentIndex", 0)
+ tryCompare(recentFilesSubMenu.__visualItem.styleData, "selected", true)
+
+ // Move right inside sub menu
+ tryCompare(recentFilesSubMenu, "__popupVisible", false)
+ tryCompare(recentFilesSubMenu, "__currentIndex", -1)
+ keyPress(Qt.Key_Right, Qt.NoModifier, waitTime)
+ keyRelease(Qt.Key_Right, Qt.NoModifier, waitTime)
+ tryCompare(recentFilesSubMenu, "__popupVisible", true)
+ tryCompare(recentFilesSubMenu, "__currentIndex", 0)
+ tryCompare(recentFilesSubMenu.__contentItem, "status", Loader.Ready)
+
+ // Move down inside sub menu
+ var recentFile2MenuItem = findChild(window, "recentFile2MenuItem")
+ verify(recentFile2MenuItem)
+ tryCompare(recentFile2MenuItem.__visualItem.styleData, "selected", false)
+ tryCompare(recentFilesSubMenu, "__currentIndex", 0)
+ keyPress(Qt.Key_Down, Qt.NoModifier, waitTime)
+ keyRelease(Qt.Key_Down, Qt.NoModifier, waitTime)
+ tryCompare(recentFilesSubMenu, "__currentIndex", 1)
+ tryCompare(recentFile2MenuItem.__visualItem.styleData, "selected", true)
+
+ // Move up inside sub menu
+ var recentFile1MenuItem = findChild(window, "recentFile1MenuItem")
+ verify(recentFile1MenuItem)
+ tryCompare(recentFile1MenuItem.__visualItem.styleData, "selected", false)
+ tryCompare(recentFilesSubMenu, "__currentIndex", 1)
+ keyPress(Qt.Key_Up, Qt.NoModifier, waitTime)
+ keyRelease(Qt.Key_Up, Qt.NoModifier, waitTime)
+ tryCompare(recentFilesSubMenu, "__currentIndex", 0)
+ tryCompare(recentFile1MenuItem.__visualItem.styleData, "selected", true)
+
+ // Move left out of sub menu
+ keyPress(Qt.Key_Left, Qt.NoModifier, waitTime)
+ keyRelease(Qt.Key_Left, Qt.NoModifier, waitTime)
+ tryCompare(recentFilesSubMenu, "__popupVisible", false)
+ tryCompare(recentFilesSubMenu, "__currentIndex", -1)
+
+ window.destroy()
}
}