aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2018-10-15 14:51:00 +0200
committerLiang Qi <liang.qi@qt.io>2018-10-15 15:15:22 +0200
commit2876332ad911b3c0402006ca9116af66cecdb8eb (patch)
tree70971ccda91a100edc39aac18a82dbff5ca04eaf /tests/auto
parent567a2de8cd493aabe0055d6dbc367b39447e70dd (diff)
parentd56c193eb4ceb640611d66f22e1f26aae91cd7d1 (diff)
Merge remote-tracking branch 'origin/5.11' into 5.12v5.12.0-beta3
Conflicts: src/quicktemplates2/qquickmenubar.cpp src/quicktemplates2/qquickmenubar_p.h src/quicktemplates2/qquickmenubar_p_p.h Change-Id: I5c2115f05826f68f1b1f5ce6762273cd91e6997e
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qquickmenubar/data/delegateFromSeparateComponent.qml79
-rw-r--r--tests/auto/qquickmenubar/tst_qquickmenubar.cpp27
2 files changed, 106 insertions, 0 deletions
diff --git a/tests/auto/qquickmenubar/data/delegateFromSeparateComponent.qml b/tests/auto/qquickmenubar/data/delegateFromSeparateComponent.qml
new file mode 100644
index 00000000..9d58e8c6
--- /dev/null
+++ b/tests/auto/qquickmenubar/data/delegateFromSeparateComponent.qml
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** 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 QtQuick 2.11
+import QtQuick.Controls 2.4
+
+ApplicationWindow {
+ width: 800
+ height: 800
+
+ Component {
+ id: menuBarItemComponent
+
+ MenuBarItem {
+ contentItem: Text {
+ text: parent.text
+ color: "blue"
+ }
+ background: Rectangle {
+ color: "#00ff00"
+ }
+ }
+ }
+
+ menuBar: MenuBar {
+ delegate: menuBarItemComponent
+
+ Menu {
+ title: "Menu"
+ }
+ }
+}
diff --git a/tests/auto/qquickmenubar/tst_qquickmenubar.cpp b/tests/auto/qquickmenubar/tst_qquickmenubar.cpp
index 3d6c2bbf..cfcdee5e 100644
--- a/tests/auto/qquickmenubar/tst_qquickmenubar.cpp
+++ b/tests/auto/qquickmenubar/tst_qquickmenubar.cpp
@@ -63,6 +63,7 @@ private slots:
void keys();
void mnemonics();
void addRemove();
+ void delegateFromSeparateComponent();
};
void tst_qquickmenubar::delegate()
@@ -578,6 +579,32 @@ void tst_qquickmenubar::addRemove()
QVERIFY(menuBarItem1.isNull());
}
+// QTBUG-67559
+// Test that Menus declared as children of a MenuBar have the
+// correct delegate when it is declared outside of the MenuBar as a Component.
+void tst_qquickmenubar::delegateFromSeparateComponent()
+{
+ QQuickApplicationHelper helper(this, QLatin1String("delegateFromSeparateComponent.qml"));
+ QQuickWindow *window = helper.window;
+ window->show();
+ QVERIFY(QTest::qWaitForWindowActive(window));
+
+ const QColor green = QColor::fromRgb(0x00ff00);
+
+ QQuickMenuBar *menuBar = window->property("menuBar").value<QQuickMenuBar*>();
+ QVERIFY(menuBar);
+
+ QQuickMenu *menu = qobject_cast<QQuickMenu*>(menuBar->menuAt(0));
+ QVERIFY(menu);
+
+ QQuickMenuBarItem *menuBarItem = qobject_cast<QQuickMenuBarItem *>(menu->parentItem());
+ QVERIFY(menuBarItem);
+
+ QQuickItem *menuBarItemBg = menuBarItem->property("background").value<QQuickItem*>();
+ QVERIFY(menuBarItemBg);
+ QCOMPARE(menuBarItemBg->property("color").value<QColor>(), green);
+}
+
QTEST_QUICKCONTROLS_MAIN(tst_qquickmenubar)
#include "tst_qquickmenubar.moc"