aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qquickmenu
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qquickmenu')
-rw-r--r--tests/auto/qquickmenu/data/instantiator.qml76
-rw-r--r--tests/auto/qquickmenu/data/instantiatorWithItemsBeforeAndAfter.qml88
-rw-r--r--tests/auto/qquickmenu/data/repeaterWithItemsBeforeAndAfter.qml88
-rw-r--r--tests/auto/qquickmenu/qquickmenu.pro1
-rw-r--r--tests/auto/qquickmenu/tst_qquickmenu.cpp201
5 files changed, 1 insertions, 453 deletions
diff --git a/tests/auto/qquickmenu/data/instantiator.qml b/tests/auto/qquickmenu/data/instantiator.qml
deleted file mode 100644
index 270266c3..00000000
--- a/tests/auto/qquickmenu/data/instantiator.qml
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQml 2.11
-import QtQuick 2.11
-import QtQuick.Controls 2.4
-
-ApplicationWindow {
- width: 200
- height: 200
-
- property alias menu: menu
-
- Menu {
- id: menu
-
- Instantiator {
- model: ["A", "B"]
-
- MenuItem {
- objectName: text
- text: modelData
- }
-
- onObjectAdded: menu.insertItem(index, object)
- onObjectRemoved: menu.removeItem(object)
- }
- }
-}
diff --git a/tests/auto/qquickmenu/data/instantiatorWithItemsBeforeAndAfter.qml b/tests/auto/qquickmenu/data/instantiatorWithItemsBeforeAndAfter.qml
deleted file mode 100644
index 9f3ef430..00000000
--- a/tests/auto/qquickmenu/data/instantiatorWithItemsBeforeAndAfter.qml
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQml 2.11
-import QtQuick 2.11
-import QtQuick.Controls 2.4
-
-ApplicationWindow {
- width: 200
- height: 200
-
- property alias menu: menu
-
- Menu {
- id: menu
-
- MenuItem {
- objectName: text
- text: "Before"
- }
-
- Instantiator {
- model: ["Instantiated #1", "Instantiated #2"]
-
- MenuItem {
- objectName: text
- text: modelData
- }
-
- // We want our items to be added after the "Before" MenuItem,
- // so we have to insert items at the index after it.
- onObjectAdded: menu.insertItem(1 + index, object)
- onObjectRemoved: menu.removeItem(object)
- }
-
- MenuItem {
- objectName: text
- text: "After"
- }
- }
-}
diff --git a/tests/auto/qquickmenu/data/repeaterWithItemsBeforeAndAfter.qml b/tests/auto/qquickmenu/data/repeaterWithItemsBeforeAndAfter.qml
deleted file mode 100644
index 46ed8856..00000000
--- a/tests/auto/qquickmenu/data/repeaterWithItemsBeforeAndAfter.qml
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQml 2.11
-import QtQuick 2.11
-import QtQuick.Controls 2.4
-
-ApplicationWindow {
- width: 200
- height: 200
-
- property alias menu: menu
-
- Menu {
- id: menu
-
- MenuItem {
- objectName: text
- text: "Before"
- }
-
- Repeater {
- model: ["Repeater Item #1", "Repeater Item #2"]
-
- MenuItem {
- objectName: text
- text: modelData
- }
-
- // We want our items to be added after the "Before" MenuItem,
- // so we have to insert items at the index after it.
- onItemAdded: menu.insertItem(1 + index, item)
- onItemRemoved: menu.removeItem(item)
- }
-
- MenuItem {
- objectName: text
- text: "After"
- }
- }
-}
diff --git a/tests/auto/qquickmenu/qquickmenu.pro b/tests/auto/qquickmenu/qquickmenu.pro
index 7e1080b9..ee539842 100644
--- a/tests/auto/qquickmenu/qquickmenu.pro
+++ b/tests/auto/qquickmenu/qquickmenu.pro
@@ -1,6 +1,5 @@
CONFIG += testcase
TARGET = tst_qquickmenu
-HEADERS += ../shared/menuutil.h
SOURCES += tst_qquickmenu.cpp
macos:CONFIG -= app_bundle
diff --git a/tests/auto/qquickmenu/tst_qquickmenu.cpp b/tests/auto/qquickmenu/tst_qquickmenu.cpp
index 2f6d5049..b46b8781 100644
--- a/tests/auto/qquickmenu/tst_qquickmenu.cpp
+++ b/tests/auto/qquickmenu/tst_qquickmenu.cpp
@@ -43,8 +43,6 @@
#include <QtQml/qqmlcontext.h>
#include <QtQuick/qquickview.h>
#include <QtQuick/private/qquickitem_p.h>
-#include <QtQuick/private/qquicklistview_p.h>
-#include "../shared/menuutil.h"
#include "../shared/util.h"
#include "../shared/visualtestutil.h"
@@ -75,7 +73,6 @@ private slots:
void addItem();
void menuSeparator();
void repeater();
- void repeaterWithItemsBeforeAndAfter();
void order();
void popup();
void actions();
@@ -89,9 +86,6 @@ private slots:
void addRemoveSubMenus();
void scrollable_data();
void scrollable();
- void delegateFromSeparateComponent();
- void instantiator();
- void instantiatorWithItemsBeforeAndAfter();
};
void tst_QQuickMenu::defaults()
@@ -151,7 +145,6 @@ void tst_QQuickMenu::mouse()
menu->open();
QVERIFY(menu->isVisible());
QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem()));
- waitForMenuListViewPolish(menu);
QQuickItem *firstItem = menu->itemAt(0);
QSignalSpy clickedSpy(firstItem, SIGNAL(clicked()));
@@ -275,8 +268,6 @@ void tst_QQuickMenu::contextMenuKeyboard()
QCOMPARE(visibleSpy.count(), 1);
QVERIFY(menu->isVisible());
QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem()));
- waitForMenuListViewPolish(menu);
-
QVERIFY(!firstItem->hasActiveFocus());
QVERIFY(!firstItem->property("highlighted").toBool());
QCOMPARE(menu->currentIndex(), -1);
@@ -592,7 +583,7 @@ void tst_QQuickMenu::repeater()
for (int i = 0; i < count; ++i) {
QQuickItem *item = menu->itemAt(i);
- QVERIFY2(item, qPrintable(QString::fromLatin1("Expected item to be at index %1").arg(i)));
+ QVERIFY(item);
QCOMPARE(item->property("idx").toInt(), i);
QQuickItem *repeaterItem = nullptr;
@@ -616,35 +607,6 @@ void tst_QQuickMenu::repeater()
}
}
-void tst_QQuickMenu::repeaterWithItemsBeforeAndAfter()
-{
- QQuickApplicationHelper helper(this, QLatin1String("repeaterWithItemsBeforeAndAfter.qml"));
-
- QQuickApplicationWindow *window = helper.appWindow;
- window->show();
- window->requestActivate();
- QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
- centerOnScreen(window);
- moveMouseAway(window);
-
- QQuickMenu *menu = window->property("menu").value<QQuickMenu*>();
- menu->open();
- QVERIFY(menu->isVisible());
- waitForMenuListViewPolish(menu);
-
- QStringList expectedItemTexts;
- expectedItemTexts << QLatin1String("Before") << QLatin1String("Repeater Item #1")
- << QLatin1String("Repeater Item #2") << QLatin1String("After");
-
- for (int i = 0; i < expectedItemTexts.size(); ++i) {
- const QString expectedText = expectedItemTexts.at(i);
- QQuickMenuItem *menuItem = qobject_cast<QQuickMenuItem*>(menu->itemAt(i));
- QVERIFY(menuItem);
- QCOMPARE(menuItem->text(), expectedText);
- }
-}
-
void tst_QQuickMenu::order()
{
QQuickApplicationHelper helper(this, QLatin1String("order.qml"));
@@ -972,7 +934,6 @@ void tst_QQuickMenu::subMenuMouse()
QVERIFY(!subMenu1->isVisible());
QVERIFY(!subMenu2->isVisible());
QVERIFY(!subSubMenu1->isVisible());
- waitForMenuListViewPolish(mainMenu);
// open the sub-menu with mouse click
QQuickMenuItem *subMenu1Item = qobject_cast<QQuickMenuItem *>(mainMenu->itemAt(1));
@@ -983,7 +944,6 @@ void tst_QQuickMenu::subMenuMouse()
QVERIFY(subMenu1->isVisible());
QVERIFY(!subMenu2->isVisible());
QVERIFY(!subSubMenu1->isVisible());
- waitForMenuListViewPolish(subMenu1);
// open the cascading sub-sub-menu with mouse hover
QQuickMenuItem *subSubMenu1Item = qobject_cast<QQuickMenuItem *>(subMenu1->itemAt(2));
@@ -994,7 +954,6 @@ void tst_QQuickMenu::subMenuMouse()
QVERIFY(subMenu1->isVisible());
QVERIFY(!subMenu2->isVisible());
QVERIFY(!subSubMenu1->isVisible());
- QVERIFY(subSubMenu1Item->isHovered());
if (cascade)
QTRY_VERIFY(subSubMenu1->isVisible());
@@ -1014,7 +973,6 @@ void tst_QQuickMenu::subMenuMouse()
QVERIFY(subMenu1->isVisible());
QVERIFY(!subMenu2->isVisible());
QVERIFY(!subSubMenu1->isVisible());
- QVERIFY(subSubMenu1Item->isHovered());
if (cascade)
QTRY_VERIFY(subSubMenu1->isVisible());
@@ -1241,7 +1199,6 @@ void tst_QQuickMenu::subMenuPosition()
QVERIFY(!subMenu1->isVisible());
QVERIFY(!subMenu2->isVisible());
QVERIFY(!subSubMenu1->isVisible());
- waitForMenuListViewPolish(mainMenu);
// open the sub-menu (never flips)
QQuickMenuItem *subMenu1Item = qobject_cast<QQuickMenuItem *>(mainMenu->itemAt(1));
@@ -1376,165 +1333,9 @@ void tst_QQuickMenu::scrollable()
QVERIFY(menu->isVisible());
QQuickItem *contentItem = menu->contentItem();
- // Can only be scrollable if it exceeds the height of the window.
- QTRY_VERIFY(contentItem->property("contentHeight").toReal() > window->height());
QCOMPARE(contentItem->property("interactive").toBool(), true);
}
-// QTBUG-67559
-// Test that Actions and MenuItems declared as children of a Menu have the
-// correct delegate when it is declared outside of the Menu as a Component.
-void tst_QQuickMenu::delegateFromSeparateComponent()
-{
- QQuickApplicationHelper helper(this, QLatin1String("delegateFromSeparateComponent.qml"));
- QQuickWindow *window = helper.window;
- window->show();
- QVERIFY(QTest::qWaitForWindowActive(window));
-
- const QColor green = QColor::fromRgb(0x00ff00);
-
- QQuickMenu *menu = window->property("menu").value<QQuickMenu*>();
- QVERIFY(menu);
-
- // "Action Item 1"
- QQuickMenuItem *actionItem1 = qobject_cast<QQuickMenuItem*>(menu->itemAt(0));
- QVERIFY(actionItem1);
- QCOMPARE(actionItem1->text(), QLatin1String("Action Item 1"));
-
- QQuickItem *actionItem1Bg = actionItem1->property("background").value<QQuickItem*>();
- QVERIFY(actionItem1Bg);
- QCOMPARE(actionItem1Bg->property("color").value<QColor>(), green);
-
- // "Sub-menu"
- QQuickMenuItem *subMenuItem = qobject_cast<QQuickMenuItem*>(menu->itemAt(1));
- QVERIFY(subMenuItem);
- QCOMPARE(subMenuItem->text(), QLatin1String("Sub-menu"));
-
- QQuickItem *subMenuItemBg = subMenuItem->property("background").value<QQuickItem*>();
- QVERIFY(subMenuItemBg);
- QCOMPARE(subMenuItemBg->property("color").value<QColor>(), green);
-
- QQuickMenu *subMenu = subMenuItem->subMenu();
- QVERIFY(subMenu);
-
- // "Sub-menu Action Item 1"
- QQuickMenuItem *subMenuActionItem1 = qobject_cast<QQuickMenuItem*>(subMenu->itemAt(0));
- QVERIFY(subMenuActionItem1);
- QCOMPARE(subMenuActionItem1->text(), QLatin1String("Sub-menu Action Item 1"));
-
- QQuickItem *subMenuActionItem1Bg = subMenuActionItem1->property("background").value<QQuickItem*>();
- QVERIFY(subMenuActionItem1Bg);
- QCOMPARE(subMenuActionItem1Bg->property("color").value<QColor>(), green);
-
- // "Sub-sub-menu"
- QQuickMenuItem *subSubMenuItem = qobject_cast<QQuickMenuItem*>(subMenu->itemAt(1));
- QVERIFY(subSubMenuItem);
- QCOMPARE(subSubMenuItem->text(), QLatin1String("Sub-sub-menu"));
-
- QQuickItem *subSubMenuItemBg = subSubMenuItem->property("background").value<QQuickItem*>();
- QVERIFY(subSubMenuItemBg);
- QCOMPARE(subSubMenuItemBg->property("color").value<QColor>(), green);
-
- QQuickMenu *subSubMenu = subSubMenuItem->subMenu();
- QVERIFY(subSubMenu);
-
- // "Sub-sub-menu Action Item 1"
- QQuickMenuItem *subSubMenuActionItem1 = qobject_cast<QQuickMenuItem*>(subSubMenu->itemAt(0));
- QVERIFY(subSubMenuActionItem1);
- QCOMPARE(subSubMenuActionItem1->text(), QLatin1String("Sub-sub-menu Action Item 1"));
-
- QQuickItem *subSubMenuActionItem1Bg = subSubMenuActionItem1->property("background").value<QQuickItem*>();
- QVERIFY(subSubMenuActionItem1Bg);
- QCOMPARE(subSubMenuActionItem1Bg->property("color").value<QColor>(), green);
-
- // "Sub-menu Action Item 2"
- QQuickMenuItem *subMenuActionItem2 = qobject_cast<QQuickMenuItem*>(subMenu->itemAt(2));
- QVERIFY(subMenuActionItem2);
- QCOMPARE(subMenuActionItem2->text(), QLatin1String("Sub-menu Action Item 2"));
-
- QQuickItem *subMenuActionItem2Bg = subMenuActionItem2->property("background").value<QQuickItem*>();
- QVERIFY(subMenuActionItem2Bg);
- QCOMPARE(subMenuActionItem2Bg->property("color").value<QColor>(), green);
-
- // "Action Item 2"
- QQuickMenuItem *actionItem2 = qobject_cast<QQuickMenuItem*>(menu->itemAt(2));
- QVERIFY(actionItem2);
- QCOMPARE(actionItem2->text(), QLatin1String("Action Item 2"));
-
- QQuickItem *actionItem2Bg = actionItem2->property("background").value<QQuickItem*>();
- QVERIFY(actionItem2Bg);
- QCOMPARE(actionItem2Bg->property("color").value<QColor>(), green);
-}
-
-void tst_QQuickMenu::instantiator()
-{
- if (QGuiApplication::styleHints()->tabFocusBehavior() != Qt::TabFocusAllControls)
- QSKIP("This platform only allows tab focus for text controls");
-
- QQuickApplicationHelper helper(this, QLatin1String("instantiator.qml"));
-
- QQuickApplicationWindow *window = helper.appWindow;
- window->show();
- window->requestActivate();
- QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
- centerOnScreen(window);
- moveMouseAway(window);
-
- QQuickMenu *menu = window->property("menu").value<QQuickMenu*>();
- menu->open();
- QVERIFY(menu->isVisible());
- waitForMenuListViewPolish(menu);
- menu->setFocus(true);
-
- // Highlight the first item.
- QQuickMenuItem *firstItem = qobject_cast<QQuickMenuItem *>(menu->itemAt(0));
- QVERIFY(firstItem);
- QTest::keyClick(window, Qt::Key_Tab);
- QVERIFY(firstItem->hasActiveFocus());
- QVERIFY(firstItem->hasVisualFocus());
- QVERIFY(firstItem->isHighlighted());
- QTRY_VERIFY(!QQuickItemPrivate::get(firstItem)->culled);
-
- // Highlight the second item.
- QQuickMenuItem *secondItem = qobject_cast<QQuickMenuItem *>(menu->itemAt(1));
- QVERIFY(secondItem);
- QTest::keyClick(window, Qt::Key_Down);
- QVERIFY(secondItem->hasActiveFocus());
- QVERIFY(secondItem->hasVisualFocus());
- QVERIFY(secondItem->isHighlighted());
- QVERIFY(!QQuickItemPrivate::get(secondItem)->culled);
-}
-
-void tst_QQuickMenu::instantiatorWithItemsBeforeAndAfter()
-{
- QQuickApplicationHelper helper(this, QLatin1String("instantiatorWithItemsBeforeAndAfter.qml"));
-
- QQuickApplicationWindow *window = helper.appWindow;
- window->show();
- window->requestActivate();
- QVERIFY(QTest::qWaitForWindowActive(window));
- QVERIFY(QGuiApplication::focusWindow() == window);
- centerOnScreen(window);
- moveMouseAway(window);
-
- QQuickMenu *menu = window->property("menu").value<QQuickMenu*>();
- menu->open();
- QVERIFY(menu->isVisible());
- waitForMenuListViewPolish(menu);
-
- QStringList expectedItemTexts;
- expectedItemTexts << QLatin1String("Before") << QLatin1String("Instantiated #1")
- << QLatin1String("Instantiated #2") << QLatin1String("After");
-
- for (int i = 0; i < expectedItemTexts.size(); ++i) {
- const QString expectedText = expectedItemTexts.at(i);
- QQuickMenuItem *menuItem = qobject_cast<QQuickMenuItem*>(menu->itemAt(i));
- QVERIFY(menuItem);
- QCOMPARE(menuItem->text(), expectedText);
- }
-}
-
QTEST_MAIN(tst_QQuickMenu)
#include "tst_qquickmenu.moc"