diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-03-10 03:00:41 +0100 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-03-10 03:00:41 +0100 |
commit | 41dd1405d5c5bfac05f9c42a4c4017de5075f5cc (patch) | |
tree | 4274b78b41dd1676d717e06d81f77e9b52b18974 /tests/auto | |
parent | 2f4726883b17fe2c935ac2e5d1bfa9b2bca8b5e3 (diff) | |
parent | 031a1e89e1baa952225c0f036b605f591f554e9b (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: Id5cd236e14238612647f7a897886be0202863132
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/platform/data/tst_menu.qml | 19 | ||||
-rw-r--r-- | tests/auto/qquickdrawer/data/slider.qml | 74 | ||||
-rw-r--r-- | tests/auto/qquickdrawer/tst_qquickdrawer.cpp | 55 |
3 files changed, 148 insertions, 0 deletions
diff --git a/tests/auto/platform/data/tst_menu.qml b/tests/auto/platform/data/tst_menu.qml index 2b7a10ad..06b9a30f 100644 --- a/tests/auto/platform/data/tst_menu.qml +++ b/tests/auto/platform/data/tst_menu.qml @@ -242,4 +242,23 @@ TestCase { compare(Menu.DefaultMenu, 0) compare(Menu.EditMenu, 1) } + + function test_subMenus() { + var parentMenu = createTemporaryObject(menu, testCase) + verify(parentMenu) + + var subMenu = menu.createObject(parentMenu) + verify(subMenu) + + var subMenuItem = subMenu.menuItem + verify(subMenuItem) + + parentMenu.addMenu(subMenu) + compare(parentMenu.items.length, 1) + verify(parentMenu.items[0], subMenuItem) + + subMenu.title = "Title" + compare(subMenu.title, "Title") + compare(subMenuItem.text, "Title") + } } diff --git a/tests/auto/qquickdrawer/data/slider.qml b/tests/auto/qquickdrawer/data/slider.qml new file mode 100644 index 00000000..595e7091 --- /dev/null +++ b/tests/auto/qquickdrawer/data/slider.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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.9 +import QtQuick.Controls 2.0 + +ApplicationWindow { + width: 400 + height: 400 + + property alias drawer: drawer + property alias slider: slider + + Drawer { + id: drawer + width: 300 + height: 400 + position: 1.0 + visible: true + + Slider { + id: slider + value: 1 + width: parent.width + } + } +} diff --git a/tests/auto/qquickdrawer/tst_qquickdrawer.cpp b/tests/auto/qquickdrawer/tst_qquickdrawer.cpp index 60c5b189..bba1cf45 100644 --- a/tests/auto/qquickdrawer/tst_qquickdrawer.cpp +++ b/tests/auto/qquickdrawer/tst_qquickdrawer.cpp @@ -106,6 +106,9 @@ private slots: void nonModal_data(); void nonModal(); + void slider_data(); + void slider(); + private: struct TouchDeviceDeleter { @@ -1257,6 +1260,58 @@ void tst_QQuickDrawer::nonModal() QVERIFY(closedSpy.wait()); } +void tst_QQuickDrawer::slider_data() +{ + QTest::addColumn<bool>("mouse"); + QTest::newRow("mouse") << true; + QTest::newRow("touch") << false; +} + +void tst_QQuickDrawer::slider() +{ + QFETCH(bool, mouse); + + QQuickApplicationHelper helper(this, QStringLiteral("slider.qml")); + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickDrawer *drawer = window->property("drawer").value<QQuickDrawer *>(); + QVERIFY(drawer); + + QQuickSlider *slider = window->property("slider").value<QQuickSlider *>(); + QVERIFY(slider); + + QCOMPARE(slider->value(), 1.0); + QCOMPARE(drawer->position(), 1.0); + + const qreal y = slider->height() / 2; + const QPoint from(slider->width() - 1, y); + const QPoint to(1, y); + + if (mouse) + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, from); + else + QTest::touchEvent(window, touchDevice.data()).press(0, from); + + int distance = qAbs(from.x() - to.x()); + for (int dx = 2; dx < distance; dx += 2) { + if (mouse) + QTest::mouseMove(window, from - QPoint(dx, 0)); + else + QTest::touchEvent(window, touchDevice.data()).move(0, from - QPoint(dx, 0)); + QTest::qWait(1); // avoid infinite velocity + } + + QCOMPARE(slider->value(), 0.0); + QCOMPARE(drawer->position(), 1.0); + + if (mouse) + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, to); + else + QTest::touchEvent(window, touchDevice.data()).release(0, to); +} + QTEST_QUICKCONTROLS_MAIN(tst_QQuickDrawer) #include "tst_qquickdrawer.moc" |