diff options
Diffstat (limited to 'tests')
66 files changed, 2303 insertions, 755 deletions
diff --git a/tests/auto/accessibility/accessibility.pro b/tests/auto/accessibility/accessibility.pro index ca751265..ead68318 100644 --- a/tests/auto/accessibility/accessibility.pro +++ b/tests/auto/accessibility/accessibility.pro @@ -4,7 +4,7 @@ SOURCES += tst_accessibility.cpp osx:CONFIG -= app_bundle -QT += core-private gui-private qml-private quick-private labstemplates-private testlib +QT += core-private gui-private qml-private quick-private quicktemplates-private testlib include (../shared/util.pri) diff --git a/tests/auto/accessibility/tst_accessibility.cpp b/tests/auto/accessibility/tst_accessibility.cpp index 8c05e2f2..8bd4d09a 100644 --- a/tests/auto/accessibility/tst_accessibility.cpp +++ b/tests/auto/accessibility/tst_accessibility.cpp @@ -41,7 +41,7 @@ #include <QtQml/qqmlcontext.h> #include <QtQuick/qquickview.h> #include <QtQuick/private/qquickitem_p.h> -#include <QtLabsTemplates/private/qquickpopup_p.h> +#include <QtQuickTemplates/private/qquickpopup_p.h> #include "../shared/util.h" #include "../shared/visualtestutil.h" diff --git a/tests/auto/activeFocusOnTab/activeFocusOnTab.pro b/tests/auto/activeFocusOnTab/activeFocusOnTab.pro deleted file mode 100644 index cac27bcc..00000000 --- a/tests/auto/activeFocusOnTab/activeFocusOnTab.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += testcase -TARGET = tst_activeFocusOnTab -osx:CONFIG -= app_bundle - -SOURCES += tst_activeFocusOnTab.cpp - -include (../shared/util.pri) - -TESTDATA = data/* - -QT += core-private gui-private qml-private quick-private testlib diff --git a/tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp b/tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp deleted file mode 100644 index c618a2d5..00000000 --- a/tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp +++ /dev/null @@ -1,494 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <qtest.h> -#include <QtTest/QSignalSpy> -#include <QtQml/qqmlengine.h> -#include <QtQml/qqmlcomponent.h> -#include <QtQml/qqmlcontext.h> -#include <QtQuick/qquickview.h> -#include <QtQuick/private/qquickitem_p.h> -#include <QtGui/private/qguiapplication_p.h> -#include <QtGui/qstylehints.h> -#include "../shared/util.h" -#include "../shared/visualtestutil.h" - -using namespace QQuickVisualTestUtil; - -class tst_activeFocusOnTab : public QQmlDataTest -{ - Q_OBJECT -public: - tst_activeFocusOnTab(); - -private slots: - void initTestCase(); - void cleanup(); - - void allControls(); - void textControls(); -private: - QQmlEngine engine; - bool qt_tab_all_controls() { - return QGuiApplication::styleHints()->tabFocusBehavior() == Qt::TabFocusAllControls; - } -}; - -tst_activeFocusOnTab::tst_activeFocusOnTab() -{ -} - -void tst_activeFocusOnTab::initTestCase() -{ - QQmlDataTest::initTestCase(); -} - -void tst_activeFocusOnTab::cleanup() -{ -} - -void tst_activeFocusOnTab::allControls() -{ - if (!qt_tab_all_controls()) - QSKIP("This platform iterates only text controls. Cannot test iterating all controls."); - - QQuickView *window = new QQuickView(0); - window->setBaseSize(QSize(800,600)); - - window->setSource(testFileUrl("activeFocusOnTab.qml")); - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - QVERIFY(QGuiApplication::focusWindow() == window); - - // original: button1 - QQuickItem *item = findItem<QQuickItem>(window->rootObject(), "button1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Tab: button1->button2 - QKeyEvent key(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "button2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Tab: button2->checkbox - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "checkbox"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Tab: checkbox->checkbox1 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "checkbox1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Tab: checkbox1->checkbox2 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "checkbox2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Tab: checkbox2->radiobutton - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "radiobutton"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Tab: radiobutton->radiobutton1 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "radiobutton1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Tab: radiobutton1->radiobutton2 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "radiobutton2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Tab: radiobutton2->rangeslider.first.handle - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "rangeslider"); - QVERIFY(item); - item = item->property("first").value<QObject*>()->property("handle").value<QQuickItem*>(); - QVERIFY(item->hasActiveFocus()); - - // Tab: rangeslider.first.handle->rangeslider.second.handle - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "rangeslider"); - QVERIFY(item); - item = item->property("second").value<QObject*>()->property("handle").value<QQuickItem*>(); - QVERIFY(item->hasActiveFocus()); - - // Tab: rangeslider.second.handle->slider - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "slider"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Tab: slider->spinbox - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "spinbox"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Tab: spinbox->switch - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "switch"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Tab: switch->tabbutton1 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "tabbutton1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Tab: tabbutton1->tabbutton2 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "tabbutton2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Tab: tabbutton2->textfield - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "textfield"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Tab: textfield->toolbutton - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "toolbutton"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Tab: toolbutton->textarea - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "textarea"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: textarea->toolbutton - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "toolbutton"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: toolbutton->textfield - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "textfield"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: textfield->tabbutton2 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "tabbutton2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: tabbutton2->tabbutton2 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "tabbutton1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: tabbutton1->switch - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "switch"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: switch->spinbox - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "spinbox"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: spinbox->slider - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "slider"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: slider->rangeslider.second.handle - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "rangeslider"); - QVERIFY(item); - item = item->property("second").value<QObject*>()->property("handle").value<QQuickItem*>(); - QVERIFY(item->hasActiveFocus()); - - // BackTab: rangeslider.second.handle->rangeslider.first.handle - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "rangeslider"); - QVERIFY(item); - item = item->property("first").value<QObject*>()->property("handle").value<QQuickItem*>(); - QVERIFY(item->hasActiveFocus()); - - // BackTab: rangeslider.first.handle->radiobutton2 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "radiobutton2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: radiobutton2->radiobutton1 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "radiobutton1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: radiobutton1->radiobutton - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "radiobutton"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: radiobutton->checkbox2 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "checkbox2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: checkbox2->checkbox1 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "checkbox1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: checkbox1->checkbox - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "checkbox"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: checkbox->button2 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "button2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: button2->button1 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "button1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: button1->textarea - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "textarea"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: textarea->toolbutton - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "toolbutton"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - delete window; -} - -void tst_activeFocusOnTab::textControls() -{ - if (qt_tab_all_controls()) - QSKIP("This platform iterates all controls. Cannot test iterating text controls only."); - - QQuickView *window = new QQuickView(0); - window->setBaseSize(QSize(800,600)); - - window->setSource(testFileUrl("activeFocusOnTab.qml")); - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - QVERIFY(QGuiApplication::focusWindow() == window); - - // original: textfield - QQuickItem *item = findItem<QQuickItem>(window->rootObject(), "textfield"); - QVERIFY(item); - item->forceActiveFocus(); - QVERIFY(item->hasActiveFocus()); - - // Tab: textfield->textarea - QKeyEvent key(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "textarea"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: textarea->textfield - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "textfield"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: textfield->spinbox - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "spinbox"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: spinbox->textarea - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem<QQuickItem>(window->rootObject(), "textarea"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - delete window; -} - -QTEST_MAIN(tst_activeFocusOnTab) - -#include "tst_activeFocusOnTab.moc" diff --git a/tests/auto/applicationwindow/applicationwindow.pro b/tests/auto/applicationwindow/applicationwindow.pro index eabe81bf..4d1b44bd 100644 --- a/tests/auto/applicationwindow/applicationwindow.pro +++ b/tests/auto/applicationwindow/applicationwindow.pro @@ -4,7 +4,7 @@ SOURCES += tst_applicationwindow.cpp osx:CONFIG -= app_bundle -QT += core-private gui-private qml-private quick-private labstemplates-private labscontrols-private testlib +QT += core-private gui-private qml-private quick-private quicktemplates-private quickcontrols-private testlib include (../shared/util.pri) diff --git a/tests/auto/applicationwindow/tst_applicationwindow.cpp b/tests/auto/applicationwindow/tst_applicationwindow.cpp index d2937a6d..67525ef7 100644 --- a/tests/auto/applicationwindow/tst_applicationwindow.cpp +++ b/tests/auto/applicationwindow/tst_applicationwindow.cpp @@ -42,13 +42,13 @@ #include <QtQuick/qquickview.h> #include <QtQuick/private/qquickitem_p.h> #include <QtGui/private/qguiapplication_p.h> -#include <QtLabsTemplates/private/qquickapplicationwindow_p.h> -#include <QtLabsTemplates/private/qquickoverlay_p.h> -#include <QtLabsTemplates/private/qquickcontrol_p.h> -#include <QtLabsTemplates/private/qquicklabel_p.h> -#include <QtLabsTemplates/private/qquicktextarea_p.h> -#include <QtLabsTemplates/private/qquicktextfield_p.h> -#include <QtLabsControls/private/qquickproxytheme_p.h> +#include <QtQuickTemplates/private/qquickapplicationwindow_p.h> +#include <QtQuickTemplates/private/qquickoverlay_p.h> +#include <QtQuickTemplates/private/qquickcontrol_p.h> +#include <QtQuickTemplates/private/qquicklabel_p.h> +#include <QtQuickTemplates/private/qquicktextarea_p.h> +#include <QtQuickTemplates/private/qquicktextfield_p.h> +#include <QtQuickControls/private/qquickproxytheme_p.h> #include "../shared/util.h" #include "../shared/visualtestutil.h" @@ -420,7 +420,7 @@ void tst_applicationwindow::attachedProperties() QCOMPARE(childItem->property("attached_footer").value<QQuickItem *>(), childAppWindow->footer()); QCOMPARE(childItem->property("attached_overlay").value<QQuickItem *>(), childAppWindow->overlay()); - childControl->setParentItem(Q_NULLPTR); + childControl->setParentItem(nullptr); QVERIFY(!childControl->window()); QVERIFY(!childControl->property("attached_window").value<QQuickApplicationWindow *>()); QVERIFY(!childControl->property("attached_contentItem").value<QQuickItem *>()); @@ -429,7 +429,7 @@ void tst_applicationwindow::attachedProperties() QVERIFY(!childControl->property("attached_footer").value<QQuickItem *>()); QVERIFY(!childControl->property("attached_overlay").value<QQuickItem *>()); - childItem->setParentItem(Q_NULLPTR); + childItem->setParentItem(nullptr); QVERIFY(!childItem->window()); QVERIFY(!childItem->property("attached_window").value<QQuickApplicationWindow *>()); QVERIFY(!childItem->property("attached_contentItem").value<QQuickItem *>()); @@ -505,9 +505,8 @@ class TestTheme : public QQuickProxyTheme public: TestTheme(QPlatformTheme *theme) : QQuickProxyTheme(theme), m_font("Courier") { QGuiApplicationPrivate::platform_theme = this; } - ~TestTheme() { QGuiApplicationPrivate::platform_theme = theme(); } - const QFont *font(Font type = SystemFont) const Q_DECL_OVERRIDE + const QFont *font(Font type = SystemFont) const override { Q_UNUSED(type); return &m_font; diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index ec9d4111..311f97dc 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -1,7 +1,6 @@ TEMPLATE = subdirs SUBDIRS += \ accessibility \ - activeFocusOnTab \ applicationwindow \ calendar \ controls \ @@ -13,3 +12,7 @@ SUBDIRS += \ snippets \ styles \ universal + +# QTBUG-50295 +!linux: SUBDIRS += \ + focus diff --git a/tests/auto/controls/data/tst_button.qml b/tests/auto/controls/data/tst_button.qml index 45fad8cb..4127fbf2 100644 --- a/tests/auto/controls/data/tst_button.qml +++ b/tests/auto/controls/data/tst_button.qml @@ -228,7 +228,7 @@ TestCase { function test_baseline() { var control = button.createObject(testCase) verify(control) - compare(control.baselineOffset, control.label.y + control.label.baselineOffset) + compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset) control.destroy() } } diff --git a/tests/auto/controls/data/tst_checkbox.qml b/tests/auto/controls/data/tst_checkbox.qml index 4efc7223..7e0c88e4 100644 --- a/tests/auto/controls/data/tst_checkbox.qml +++ b/tests/auto/controls/data/tst_checkbox.qml @@ -421,7 +421,7 @@ TestCase { function test_baseline() { var control = checkBox.createObject(testCase) verify(control) - compare(control.baselineOffset, control.label.y + control.label.baselineOffset) + compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset) control.destroy() } } diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index 759a1ebc..b2782b44 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -39,6 +39,7 @@ ****************************************************************************/ import QtQuick 2.2 +import QtQuick.Window 2.2 import QtTest 1.0 import Qt.labs.controls 1.0 @@ -46,16 +47,10 @@ TestCase { id: testCase width: 200 height: 200 + visible: true + when: windowShown name: "ComboBox" - ApplicationWindow { - id: window - visible: true - width: 400 - height: 400 - font.pixelSize: 25 - } - SignalSpy { id: activatedSpy signalName: "activated" @@ -75,11 +70,6 @@ TestCase { } } - function initTestCase() { - window.requestActivate() - tryCompare(window, "active", true) - } - function init() { verify(!activatedSpy.target) compare(activatedSpy.count, 0) @@ -97,7 +87,7 @@ TestCase { } function test_defaults() { - var control = comboBox.createObject(window.contentItem) + var control = comboBox.createObject(testCase) verify(control) compare(control.count, 0) @@ -113,7 +103,7 @@ TestCase { } function test_array() { - var control = comboBox.createObject(window.contentItem) + var control = comboBox.createObject(testCase) verify(control) var items = [ "Banana", "Apple", "Coconut" ] @@ -139,7 +129,7 @@ TestCase { } function test_objects() { - var control = comboBox.createObject(window.contentItem) + var control = comboBox.createObject(testCase) verify(control) var items = [ @@ -169,7 +159,7 @@ TestCase { } function test_number() { - var control = comboBox.createObject(window.contentItem) + var control = comboBox.createObject(testCase) verify(control) control.model = 10 @@ -202,7 +192,7 @@ TestCase { } function test_listModel() { - var control = comboBox.createObject(window.contentItem) + var control = comboBox.createObject(testCase) verify(control) control.model = listmodel @@ -246,7 +236,7 @@ TestCase { } function test_textRole(data) { - var control = comboBox.createObject(window.contentItem) + var control = comboBox.createObject(testCase) verify(control) control.model = data.model @@ -274,7 +264,7 @@ TestCase { } function test_textAt() { - var control = comboBox.createObject(window.contentItem) + var control = comboBox.createObject(testCase) verify(control) control.model = ["Apple", "Orange", "Banana"] @@ -316,7 +306,7 @@ TestCase { } function test_find(data) { - var control = comboBox.createObject(window.contentItem) + var control = comboBox.createObject(testCase) verify(control) control.model = ["Banana", "banana", "Coconut", "Apple", "Cocomuffin"] @@ -326,8 +316,9 @@ TestCase { control.destroy() } + function test_arrowKeys() { - var control = comboBox.createObject(window.contentItem, {model: 3}) + var control = comboBox.createObject(testCase, {model: 3}) verify(control) activatedSpy.target = control @@ -462,17 +453,18 @@ TestCase { { tag: "space-return", key1: Qt.Key_Space, key2: Qt.Key_Return, showPopup: true, showPress: true, hidePopup: true, hidePress: true }, { tag: "space-escape", key1: Qt.Key_Space, key2: Qt.Key_Escape, showPopup: true, showPress: true, hidePopup: true, hidePress: false }, { tag: "space-0", key1: Qt.Key_Space, key2: Qt.Key_0, showPopup: true, showPress: true, hidePopup: false, hidePress: false }, - { tag: "enter-enter", key1: Qt.Key_Enter, key2: Qt.Key_Enter, showPopup: false, showPress: false, hidePopup: true, hidePress: false }, { tag: "return-return", key1: Qt.Key_Return, key2: Qt.Key_Return, showPopup: false, showPress: false, hidePopup: true, hidePress: false }, - { tag: "escape-escape", key1: Qt.Key_Escape, key2: Qt.Key_Escape, showPopup: false, showPress: false, hidePopup: true, hidePress: false }, + { tag: "escape-escape", key1: Qt.Key_Escape, key2: Qt.Key_Escape, showPopup: false, showPress: false, hidePopup: true, hidePress: false } ] } function test_keys(data) { - var control = comboBox.createObject(window.contentItem, {model: 3}) + var control = comboBox.createObject(testCase, {model: 3}) verify(control) + waitForRendering(control) + control.forceActiveFocus() verify(control.activeFocus) @@ -499,7 +491,7 @@ TestCase { } function test_popup() { - var control = comboBox.createObject(window.contentItem, {model: 3}) + var control = comboBox.createObject(testCase, {model: 3}) verify(control) // show below @@ -517,7 +509,7 @@ TestCase { tryCompare(control.popup, "visible", false) // show above - control.y = window.height - control.height + control.y = control.Window.height - control.height mousePress(control) compare(control.pressed, true) compare(control.popup.visible, false) @@ -530,7 +522,7 @@ TestCase { } function test_mouse() { - var control = comboBox.createObject(window.contentItem, {model: 3}) + var control = comboBox.createObject(testCase, {model: 3}) verify(control) activatedSpy.target = control @@ -573,17 +565,18 @@ TestCase { } function test_focus() { - var control = comboBox.createObject(window.contentItem, {model: 3}) + var control = comboBox.createObject(testCase, {model: 3}) verify(control) + waitForRendering(control) + // click - gain focus - show popup mouseClick(control) verify(control.activeFocus) compare(control.popup.visible, true) // lose focus - hide popup - window.contentItem.forceActiveFocus() - verify(window.contentItem.activeFocus) + control.focus = false verify(!control.activeFocus) tryCompare(control.popup, "visible", false) @@ -672,52 +665,72 @@ TestCase { } function test_font() { // QTBUG_50984, QTBUG-51696 - var control = component.createObject(window.contentItem) + var control = component.createObject(testCase) verify(control) verify(control.button) verify(control.combobox) waitForRendering(control) - control.forceActiveFocus() - verify(control.activeFocus) - compare(control.font.pixelSize, 30) compare(control.button.font.pixelSize, 20) compare(control.combobox.font.pixelSize, 30) - verify(control.combobox.popup) - var popup = control.combobox.popup - popup.open() +// verify(control.combobox.popup) +// var popup = control.combobox.popup +// popup.open() - verify(popup.contentItem) +// verify(popup.contentItem) - var listview = popup.contentItem - verify(listview.contentItem) - waitForRendering(listview) +// var listview = popup.contentItem +// verify(listview.contentItem) +// waitForRendering(listview) - var idx1 = getChild(listview.contentItem, "delegate", -1) - compare(listview.contentItem.children[idx1].font.pixelSize, 25) - var idx2 = getChild(listview.contentItem, "delegate", idx1) - compare(listview.contentItem.children[idx2].font.pixelSize, 25) +// var idx1 = getChild(listview.contentItem, "delegate", -1) +// compare(listview.contentItem.children[idx1].font.pixelSize, 25) +// var idx2 = getChild(listview.contentItem, "delegate", idx1) +// compare(listview.contentItem.children[idx2].font.pixelSize, 25) - compare(listview.contentItem.children[idx1].font.pixelSize, 25) - compare(listview.contentItem.children[idx2].font.pixelSize, 25) +// compare(listview.contentItem.children[idx1].font.pixelSize, 25) +// compare(listview.contentItem.children[idx2].font.pixelSize, 25) control.font.pixelSize = control.font.pixelSize + 10 compare(control.combobox.font.pixelSize, 40) - waitForRendering(listview) - compare(listview.contentItem.children[idx1].font.pixelSize, 25) - compare(listview.contentItem.children[idx2].font.pixelSize, 25) +// waitForRendering(listview) +// compare(listview.contentItem.children[idx1].font.pixelSize, 25) +// compare(listview.contentItem.children[idx2].font.pixelSize, 25) control.combobox.font.pixelSize = control.combobox.font.pixelSize + 5 compare(control.combobox.font.pixelSize, 45) - waitForRendering(listview) +// waitForRendering(listview) + +// idx1 = getChild(listview.contentItem, "delegate", -1) +// compare(listview.contentItem.children[idx1].font.pixelSize, 25) +// idx2 = getChild(listview.contentItem, "delegate", idx1) +// compare(listview.contentItem.children[idx2].font.pixelSize, 25) + + control.destroy() + } + + function test_wheel() { + var control = comboBox.createObject(testCase, {model: 2, wheelEnabled: true}) + verify(control) - idx1 = getChild(listview.contentItem, "delegate", -1) - compare(listview.contentItem.children[idx1].font.pixelSize, 25) - idx2 = getChild(listview.contentItem, "delegate", idx1) - compare(listview.contentItem.children[idx2].font.pixelSize, 25) + var delta = 120 + + mouseWheel(control, control.width / 2, control.height / 2, -delta, -delta) + compare(control.currentIndex, 1) + + // reached bounds -> no change + mouseWheel(control, control.width / 2, control.height / 2, -delta, -delta) + compare(control.currentIndex, 1) + + mouseWheel(control, control.width / 2, control.height / 2, delta, delta) + compare(control.currentIndex, 0) + + // reached bounds -> no change + mouseWheel(control, control.width / 2, control.height / 2, delta, delta) + compare(control.currentIndex, 0) control.destroy() } @@ -733,7 +746,7 @@ TestCase { // QTBUG-51645 function test_activation(data) { - var control = comboBox.createObject(window.contentItem, {currentIndex: 1, model: ["Apple", "Orange", "Banana"]}) + var control = comboBox.createObject(testCase, {currentIndex: 1, model: ["Apple", "Orange", "Banana"]}) verify(control) waitForRendering(control) diff --git a/tests/auto/controls/data/tst_control.qml b/tests/auto/controls/data/tst_control.qml index dd9abefe..5e795feb 100644 --- a/tests/auto/controls/data/tst_control.qml +++ b/tests/auto/controls/data/tst_control.qml @@ -57,6 +57,11 @@ TestCase { } Component { + id: button + T.Button { } + } + + Component { id: signalSpy SignalSpy { } } @@ -334,20 +339,10 @@ TestCase { compare(control2.font.family, "Arial") compare(control2.item2_2.font.family, control2.font.family) - compare(control2.item2_2.font.pointSize, control2.font.pointSize) - compare(control2.item2_2.font.weight, control2.font.weight) compare(control2.item2_3.font.family, control2.font.family) - compare(control2.item2_3.font.pointSize, control2.font.pointSize) - compare(control2.item2_3.font.weight, control2.font.weight) compare(control2.item2_4.font.family, control2.font.family) - compare(control2.item2_4.font.pointSize, control2.font.pointSize) - compare(control2.item2_4.font.weight, control2.font.weight) compare(control2.item2_5.font.family, control2.font.family) - compare(control2.item2_5.font.pointSize, control2.font.pointSize) - compare(control2.item2_5.font.weight, control2.font.weight) compare(control2.item2_6.font.family, control2.font.family) - compare(control2.item2_6.font.pointSize, control2.font.pointSize) - compare(control2.item2_6.font.weight, control2.font.weight) control2.font.pointSize = 48 compare(control2.item2_2.font.pointSize, 48) @@ -491,20 +486,10 @@ TestCase { compare(control3.font.family, "Arial") compare(control3.item3_3.font.family, control3.font.family) - compare(control3.item3_3.font.pointSize, control3.font.pointSize) - compare(control3.item3_3.font.weight, control3.font.weight) compare(control3.item3_4.font.family, control3.font.family) - compare(control3.item3_4.font.pointSize, control3.font.pointSize) - compare(control3.item3_4.font.weight, control3.font.weight) compare(control3.item3_5.font.family, control3.font.family) - compare(control3.item3_5.font.pointSize, control3.font.pointSize) - compare(control3.item3_5.font.weight, control3.font.weight) compare(control3.item3_7.font.family, control3.font.family) - compare(control3.item3_7.font.pointSize, control3.font.pointSize) - compare(control3.item3_7.font.weight, control3.font.weight) compare(control3.item3_8.font.family, control3.font.family) - compare(control3.item3_8.font.pointSize, control3.font.pointSize) - compare(control3.item3_8.font.weight, control3.font.weight) control3.font.pointSize = 48 compare(control3.item3_3.font.pointSize, 48) @@ -872,28 +857,23 @@ TestCase { compare(control.mirroredspy_5.count, 1) } - function test_focusReason_data() { - return [ - { tag: "Control", qml: "import Qt.labs.controls 1.0; Control { }" }, - { tag: "TextField", qml: "import Qt.labs.controls 1.0; TextField { }" }, - { tag: "TextArea", qml: "import Qt.labs.controls 1.0; TextArea { }" }, - { tag: "SpinBox", qml: "import Qt.labs.controls 1.0; SpinBox { }" }, - { tag: "ComboBox", qml: "import Qt.labs.controls 1.0; ComboBox { }" } - ] - } - - function test_focusReason(data) { - var control = Qt.createQmlObject(data.qml, testCase) + function test_hover() { + var control = component.createObject(testCase, {width: 100, height: 100}) verify(control) - compare(control.focusReason, Qt.OtherFocusReason) - control.forceActiveFocus(Qt.MouseFocusReason) - compare(control.activeFocus, true) - compare(control.focusReason, Qt.MouseFocusReason) + compare(control.hovered, false) + compare(control.hoverEnabled, false) + + mouseMove(control, control.width / 2, control.height / 2) + compare(control.hovered, false) + + control.hoverEnabled = true + + mouseMove(control, control.width / 2, control.height / 2) + compare(control.hovered, true) - testCase.forceActiveFocus(Qt.TabFocusReason) - compare(control.activeFocus, false) - compare(control.focusReason, Qt.TabFocusReason) + mouseMove(control, -10, -10) + compare(control.hovered, false) control.destroy() } diff --git a/tests/auto/controls/data/tst_drawer.qml b/tests/auto/controls/data/tst_drawer.qml index 28db11c8..fff8ec49 100644 --- a/tests/auto/controls/data/tst_drawer.qml +++ b/tests/auto/controls/data/tst_drawer.qml @@ -63,4 +63,39 @@ TestCase { verify(control.animation) control.destroy() } + + Component { + id: rectDrawer + + Drawer { + Rectangle { + width: 200 + height: 400 + color: "steelblue" + } + } + } + + function test_swipeVelocity() { + skip("QTBUG-52003"); + + var control = rectDrawer.createObject(testCase) + verify(control.contentItem) + compare(control.edge, Qt.LeftEdge) + compare(control.position, 0.0) + + var dragDistance = Math.max(20, Qt.styleHints.startDragDistance + 5) + var distance = dragDistance * 1.1 + if (distance >= control.width * 0.7) + skip("This test requires a startDragDistance that is less than the opening threshold of the drawer") + + mousePress(control, 0, 0, Qt.LeftButton) + mouseMove(control, distance, 0, Qt.LeftButton) + verify(control.position > 0) + tryCompare(control, "position", distance / control.contentItem.width) + mouseRelease(control, distance, 0, Qt.LeftButton) + tryCompare(control, "position", 1.0) + + control.destroy() + } } diff --git a/tests/auto/controls/data/tst_itemdelegate.qml b/tests/auto/controls/data/tst_itemdelegate.qml index e2f78ac5..f2fd3794 100644 --- a/tests/auto/controls/data/tst_itemdelegate.qml +++ b/tests/auto/controls/data/tst_itemdelegate.qml @@ -58,7 +58,7 @@ TestCase { function test_baseline() { var control = itemDelegate.createObject(testCase) verify(control) - compare(control.baselineOffset, control.label.y + control.label.baselineOffset) + compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset) control.destroy() } } diff --git a/tests/auto/controls/data/tst_menuitem.qml b/tests/auto/controls/data/tst_menuitem.qml index 8581a43f..8c9bc71b 100644 --- a/tests/auto/controls/data/tst_menuitem.qml +++ b/tests/auto/controls/data/tst_menuitem.qml @@ -58,7 +58,7 @@ TestCase { function test_baseline() { var control = menuItem.createObject(testCase) verify(control) - compare(control.baselineOffset, control.label.y + control.label.baselineOffset) + compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset) control.destroy() } } diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml index 02635c9a..d9bef42f 100644 --- a/tests/auto/controls/data/tst_popup.qml +++ b/tests/auto/controls/data/tst_popup.qml @@ -409,38 +409,52 @@ TestCase { Component { id: component ApplicationWindow { + id: _window width: 400 height: 400 visible: true font.pixelSize: 40 property alias pane: _pane + property alias popup: _popup + property SignalSpy fontspy: SignalSpy { target: _window; signalName: "fontChanged" } Pane { id: _pane - property alias button: _button; - property alias popup: _popup; - property alias listview: _listview + property alias button: _button font.pixelSize: 30 + property SignalSpy fontspy: SignalSpy { target: _pane; signalName: "fontChanged" } Column { Button { id: _button text: "Button" font.pixelSize: 20 - + property SignalSpy fontspy: SignalSpy { target: _button; signalName: "fontChanged" } Popup { id: _popup + property alias button: _button2 + property alias listview: _listview y: _button.height implicitHeight: Math.min(396, _listview.contentHeight) - contentItem: ListView { - id: _listview - height: _button.height * 20 - model: 2 - delegate: Button { - objectName: "delegate" - width: _button.width - height: _button.height - text: "N: " + index - checkable: true - autoExclusive: true + property SignalSpy fontspy: SignalSpy { target: _popup; signalName: "fontChanged" } + contentItem: Column { + Button { + id: _button2 + text: "Button" + property SignalSpy fontspy: SignalSpy { target: _button2; signalName: "fontChanged" } + } + ListView { + id: _listview + height: _button.height * 20 + model: 2 + delegate: Button { + id: _button3 + objectName: "delegate" + width: _button.width + height: _button.height + text: "N: " + index + checkable: true + autoExclusive: true + property SignalSpy fontspy: SignalSpy { target: _button3; signalName: "fontChanged" } + } } } } @@ -454,43 +468,80 @@ TestCase { var window = component.createObject(testCase) verify(window) - window.requestActivate() - tryCompare(window, "active", true) - - var control = window.pane - waitForRendering(control) - - control.forceActiveFocus() - verify(control.activeFocus) - compare(window.font.pixelSize, 40) - compare(control.font.pixelSize, 30) - compare(control.button.font.pixelSize, 20) + compare(window.pane.font.pixelSize, 30) + compare(window.pane.button.font.pixelSize, 20) + compare(window.popup.font.pixelSize, 40) + compare(window.popup.button.font.pixelSize, 40) - var popup = control.popup - popup.open() + var idx1 = getChild(window.popup.listview.contentItem, "delegate", -1) + compare(window.popup.listview.contentItem.children[idx1].font.pixelSize, 40) + var idx2 = getChild(window.popup.listview.contentItem, "delegate", idx1) + compare(window.popup.listview.contentItem.children[idx2].font.pixelSize, 40) - verify(popup.contentItem) - - var listview = popup.contentItem - verify(listview.contentItem) - waitForRendering(listview) - - var idx1 = getChild(listview.contentItem, "delegate", -1) - compare(listview.contentItem.children[idx1].font.pixelSize, 40) - var idx2 = getChild(listview.contentItem, "delegate", idx1) - compare(listview.contentItem.children[idx2].font.pixelSize, 40) - - control.button.font.pixelSize = 30 - compare(control.button.font.pixelSize, 30) - waitForRendering(listview) - compare(listview.contentItem.children[idx1].font.pixelSize, 40) - compare(listview.contentItem.children[idx2].font.pixelSize, 40) + window.pane.button.font.pixelSize = 30 + compare(window.font.pixelSize, 40) + compare(window.fontspy.count, 0) + compare(window.pane.font.pixelSize, 30) + compare(window.pane.fontspy.count, 0) + compare(window.pane.button.font.pixelSize, 30) + compare(window.pane.button.fontspy.count, 1) + compare(window.popup.font.pixelSize, 40) + compare(window.popup.fontspy.count, 0) + compare(window.popup.button.font.pixelSize, 40) + compare(window.popup.button.fontspy.count, 0) + compare(window.popup.listview.contentItem.children[idx1].font.pixelSize, 40) + compare(window.popup.listview.contentItem.children[idx1].fontspy.count, 0) + compare(window.popup.listview.contentItem.children[idx2].font.pixelSize, 40) + compare(window.popup.listview.contentItem.children[idx2].fontspy.count, 0) window.font.pixelSize = 50 - waitForRendering(listview) - compare(listview.contentItem.children[idx1].font.pixelSize, 50) - compare(listview.contentItem.children[idx2].font.pixelSize, 50) + compare(window.font.pixelSize, 50) + compare(window.fontspy.count, 1) + compare(window.pane.font.pixelSize, 30) + compare(window.pane.fontspy.count, 0) + compare(window.pane.button.font.pixelSize, 30) + compare(window.pane.button.fontspy.count, 1) + compare(window.popup.font.pixelSize, 50) + compare(window.popup.fontspy.count, 1) + compare(window.popup.button.font.pixelSize, 50) + compare(window.popup.button.fontspy.count, 1) + compare(window.popup.listview.contentItem.children[idx1].font.pixelSize, 50) + compare(window.popup.listview.contentItem.children[idx1].fontspy.count, 1) + compare(window.popup.listview.contentItem.children[idx2].font.pixelSize, 50) + compare(window.popup.listview.contentItem.children[idx2].fontspy.count, 1) + + window.popup.button.font.pixelSize = 10 + compare(window.font.pixelSize, 50) + compare(window.fontspy.count, 1) + compare(window.pane.font.pixelSize, 30) + compare(window.pane.fontspy.count, 0) + compare(window.pane.button.font.pixelSize, 30) + compare(window.pane.button.fontspy.count, 1) + compare(window.popup.font.pixelSize, 50) + compare(window.popup.fontspy.count, 1) + compare(window.popup.button.font.pixelSize, 10) + compare(window.popup.button.fontspy.count, 2) + compare(window.popup.listview.contentItem.children[idx1].font.pixelSize, 50) + compare(window.popup.listview.contentItem.children[idx1].fontspy.count, 1) + compare(window.popup.listview.contentItem.children[idx2].font.pixelSize, 50) + compare(window.popup.listview.contentItem.children[idx2].fontspy.count, 1) + + window.popup.font.pixelSize = 60 + compare(window.font.pixelSize, 50) + compare(window.fontspy.count, 1) + compare(window.pane.font.pixelSize, 30) + compare(window.pane.fontspy.count, 0) + compare(window.pane.button.font.pixelSize, 30) + compare(window.pane.button.fontspy.count, 1) + compare(window.popup.font.pixelSize, 60) + compare(window.popup.fontspy.count, 2) + compare(window.popup.button.font.pixelSize, 10) + compare(window.popup.button.fontspy.count, 2) + compare(window.popup.listview.contentItem.children[idx1].font.pixelSize, 60) + compare(window.popup.listview.contentItem.children[idx1].fontspy.count, 2) + compare(window.popup.listview.contentItem.children[idx2].font.pixelSize, 60) + compare(window.popup.listview.contentItem.children[idx2].fontspy.count, 2) window.destroy() } @@ -511,16 +562,20 @@ TestCase { property alias button1: _button1 property alias button2: _button2 y: _button.height + locale: Qt.locale("fi_FI") implicitHeight: Math.min(396, _column.contentHeight) contentItem: Column { id: _column Button { id: _button1 text: "Button 1" + objectName: "1" } Button { id: _button2 text: "Button 2" + locale: Qt.locale("nb_NO") + objectName: "2" } } } @@ -533,26 +588,14 @@ TestCase { // test looking up natural locale from ancestors var control = localeComponent.createObject(applicationWindow.contentItem) verify(control) - verify(control.button) - verify(control.popup) - verify(control.popup.button1) - verify(control.popup.button2) - applicationWindow.visible = true - waitForRendering(control) - - control.popup.open() - verify(control.popup.visible) - - control.ApplicationWindow.window.locale = Qt.locale("fi_FI") - compare(control.ApplicationWindow.window.locale.name, "fi_FI") compare(control.locale.name, "en_US") compare(control.button.locale.name, "nb_NO") + compare(control.popup.locale.name, "fi_FI") compare(control.popup.button1.locale.name, "fi_FI") - compare(control.popup.button2.locale.name, "fi_FI") + compare(control.popup.button2.locale.name, "nb_NO") control.ApplicationWindow.window.locale = undefined - applicationWindow.visible = false control.destroy() } @@ -588,6 +631,10 @@ TestCase { property alias button2: _button2 y: _button.height implicitHeight: Math.min(396, _column.contentHeight) + property SignalSpy localespy: SignalSpy { + target: _popup + signalName: "localeChanged" + } contentItem: Column { id: _column Button { @@ -625,21 +672,12 @@ TestCase { // test default locale and locale inheritance var control = localeChangeComponent.createObject(applicationWindow.contentItem) verify(control) - verify(control.button) - verify(control.popup) - verify(control.popup.button1) - verify(control.popup.button2) - - applicationWindow.visible = true - waitForRendering(control) - - control.popup.open() - verify(control.popup.visible) var defaultLocale = Qt.locale() compare(control.ApplicationWindow.window.locale.name, defaultLocale.name) compare(control.locale.name, defaultLocale.name) compare(control.button.locale.name, defaultLocale.name) + compare(control.popup.locale.name, defaultLocale.name) compare(control.popup.button1.locale.name, defaultLocale.name) compare(control.popup.button2.locale.name, defaultLocale.name) @@ -647,10 +685,12 @@ TestCase { compare(control.ApplicationWindow.window.locale.name, "nb_NO") compare(control.locale.name, "nb_NO") compare(control.button.locale.name, "nb_NO") + compare(control.popup.locale.name, "nb_NO") compare(control.popup.button1.locale.name, "nb_NO") compare(control.popup.button2.locale.name, "nb_NO") compare(control.localespy.count, 1) compare(control.button.localespy.count, 1) + compare(control.popup.localespy.count, 1) compare(control.popup.button1.localespy.count, 1) compare(control.popup.button2.localespy.count, 1) @@ -658,10 +698,12 @@ TestCase { compare(control.ApplicationWindow.window.locale.name, defaultLocale.name) compare(control.locale.name, defaultLocale.name) compare(control.button.locale.name, defaultLocale.name) + compare(control.popup.locale.name, defaultLocale.name) compare(control.popup.button1.locale.name, defaultLocale.name) compare(control.popup.button2.locale.name, defaultLocale.name) compare(control.localespy.count, 2) compare(control.button.localespy.count, 2) + compare(control.popup.localespy.count, 2) compare(control.popup.button1.localespy.count, 2) compare(control.popup.button2.localespy.count, 2) @@ -669,12 +711,14 @@ TestCase { compare(control.ApplicationWindow.window.locale.name, defaultLocale.name) compare(control.locale.name, "ar_EG") compare(control.button.locale.name, "ar_EG") + compare(control.popup.locale.name, defaultLocale.name) compare(control.popup.button1.locale.name, defaultLocale.name) compare(control.popup.button2.locale.name, defaultLocale.name) compare(control.localespy.count, 3) compare(control.mirrorspy.count, 1) compare(control.button.localespy.count, 3) compare(control.button.mirrorspy.count, 1) + compare(control.popup.localespy.count, 2) compare(control.popup.button1.localespy.count, 2) compare(control.popup.button2.localespy.count, 2) @@ -682,12 +726,14 @@ TestCase { compare(control.ApplicationWindow.window.locale.name, "ar_EG") compare(control.locale.name, "ar_EG") compare(control.button.locale.name, "ar_EG") + compare(control.popup.locale.name, "ar_EG") compare(control.popup.button1.locale.name, "ar_EG") compare(control.popup.button2.locale.name, "ar_EG") compare(control.localespy.count, 3) compare(control.mirrorspy.count, 1) compare(control.button.localespy.count, 3) compare(control.button.mirrorspy.count, 1) + compare(control.popup.localespy.count, 3) compare(control.popup.button1.localespy.count, 3) compare(control.popup.button1.mirrorspy.count, 1) compare(control.popup.button2.localespy.count, 3) @@ -697,12 +743,14 @@ TestCase { compare(control.ApplicationWindow.window.locale.name, "ar_EG") compare(control.locale.name, "ar_EG") compare(control.button.locale.name, "nb_NO") + compare(control.popup.locale.name, "ar_EG") compare(control.popup.button1.locale.name, "ar_EG") compare(control.popup.button2.locale.name, "ar_EG") compare(control.localespy.count, 3) compare(control.mirrorspy.count, 1) compare(control.button.localespy.count, 4) compare(control.button.mirrorspy.count, 2) + compare(control.popup.localespy.count, 3) compare(control.popup.button1.localespy.count, 3) compare(control.popup.button2.localespy.count, 3) @@ -710,12 +758,14 @@ TestCase { compare(control.ApplicationWindow.window.locale.name, "ar_EG") compare(control.locale.name, "ar_EG") compare(control.button.locale.name, "nb_NO") + compare(control.popup.locale.name, "ar_EG") compare(control.popup.button1.locale.name, "ar_EG") compare(control.popup.button2.locale.name, "ar_EG") compare(control.localespy.count, 3) compare(control.mirrorspy.count, 1) compare(control.button.localespy.count, 4) compare(control.button.mirrorspy.count, 2) + compare(control.popup.localespy.count, 3) compare(control.popup.button1.localespy.count, 3) compare(control.popup.button2.localespy.count, 3) @@ -723,33 +773,70 @@ TestCase { compare(control.ApplicationWindow.window.locale.name, "ar_EG") compare(control.locale.name, "ar_EG") compare(control.button.locale.name, "nb_NO") + compare(control.popup.locale.name, "ar_EG") compare(control.popup.button1.locale.name, "nb_NO") compare(control.popup.button2.locale.name, "ar_EG") compare(control.localespy.count, 3) compare(control.mirrorspy.count, 1) compare(control.button.localespy.count, 4) compare(control.button.mirrorspy.count, 2) + compare(control.popup.localespy.count, 3) compare(control.popup.button1.localespy.count, 4) compare(control.popup.button1.mirrorspy.count, 2) compare(control.popup.button2.localespy.count, 3) compare(control.popup.button2.mirrorspy.count, 1) + control.popup.locale = Qt.locale("fi_FI") + compare(control.ApplicationWindow.window.locale.name, "ar_EG") + compare(control.locale.name, "ar_EG") + compare(control.button.locale.name, "nb_NO") + compare(control.popup.locale.name, "fi_FI") + compare(control.popup.button1.locale.name, "nb_NO") + compare(control.popup.button2.locale.name, "fi_FI") + compare(control.localespy.count, 3) + compare(control.mirrorspy.count, 1) + compare(control.button.localespy.count, 4) + compare(control.button.mirrorspy.count, 2) + compare(control.popup.localespy.count, 4) + compare(control.popup.button1.localespy.count, 4) + compare(control.popup.button1.mirrorspy.count, 2) + compare(control.popup.button2.localespy.count, 4) + compare(control.popup.button2.mirrorspy.count, 2) + control.ApplicationWindow.window.locale = undefined compare(control.ApplicationWindow.window.locale.name, defaultLocale.name) compare(control.locale.name, defaultLocale.name) compare(control.button.locale.name, "nb_NO") + compare(control.popup.locale.name, "fi_FI") compare(control.popup.button1.locale.name, "nb_NO") - compare(control.popup.button2.locale.name, defaultLocale.name) + compare(control.popup.button2.locale.name, "fi_FI") compare(control.localespy.count, 4) compare(control.mirrorspy.count, 2) compare(control.button.localespy.count, 4) compare(control.button.mirrorspy.count, 2) + compare(control.popup.localespy.count, 4) compare(control.popup.button1.localespy.count, 4) compare(control.popup.button1.mirrorspy.count, 2) compare(control.popup.button2.localespy.count, 4) compare(control.popup.button2.mirrorspy.count, 2) - applicationWindow.visible = false + control.popup.locale = undefined + compare(control.ApplicationWindow.window.locale.name, defaultLocale.name) + compare(control.locale.name, defaultLocale.name) + compare(control.button.locale.name, "nb_NO") + compare(control.popup.locale.name, defaultLocale.name) + compare(control.popup.button1.locale.name, "nb_NO") + compare(control.popup.button2.locale.name, defaultLocale.name) + compare(control.localespy.count, 4) + compare(control.mirrorspy.count, 2) + compare(control.button.localespy.count, 4) + compare(control.button.mirrorspy.count, 2) + compare(control.popup.localespy.count, 5) + compare(control.popup.button1.localespy.count, 4) + compare(control.popup.button1.mirrorspy.count, 2) + compare(control.popup.button2.localespy.count, 5) + compare(control.popup.button2.mirrorspy.count, 2) + control.destroy() } @@ -769,6 +856,16 @@ TestCase { control.destroy() } + // QTBUG-51989 + function test_visible() { + var control = popupTemplate.createObject(testCase, {visible: true}) + verify(control) + + tryCompare(control, "visible", true) + + control.destroy() + } + Component { id: overlayTest ApplicationWindow { @@ -808,4 +905,16 @@ TestCase { window.destroy() } + + function test_attached_applicationwindow() { + var control = popupTemplate.createObject(applicationWindow.contentItem) + verify(control) + + compare(control.ApplicationWindow.window, applicationWindow) + + control.parent = null + compare(control.ApplicationWindow.window, null) + + control.destroy() + } } diff --git a/tests/auto/controls/data/tst_radiobutton.qml b/tests/auto/controls/data/tst_radiobutton.qml index d4cdf0ad..1b105f08 100644 --- a/tests/auto/controls/data/tst_radiobutton.qml +++ b/tests/auto/controls/data/tst_radiobutton.qml @@ -312,7 +312,7 @@ TestCase { function test_baseline() { var control = radioButton.createObject(testCase) verify(control) - compare(control.baselineOffset, control.label.y + control.label.baselineOffset) + compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset) control.destroy() } } diff --git a/tests/auto/controls/data/tst_scrollbar.qml b/tests/auto/controls/data/tst_scrollbar.qml index 55f31e12..9fa6496e 100644 --- a/tests/auto/controls/data/tst_scrollbar.qml +++ b/tests/auto/controls/data/tst_scrollbar.qml @@ -210,4 +210,42 @@ TestCase { control.destroy() } + + function test_stepSize_data() { + return [ + { tag: "0.0", stepSize: 0.0 }, + { tag: "0.1", stepSize: 0.1 }, + { tag: "0.5", stepSize: 0.5 } + ] + } + + function test_stepSize(data) { + var control = scrollBar.createObject(testCase, {stepSize: data.stepSize}) + verify(control) + + compare(control.stepSize, data.stepSize) + compare(control.position, 0.0) + + var count = 10 + if (data.stepSize !== 0.0) + count = 1.0 / data.stepSize + + // increase until 1.0 + for (var i = 1; i <= count; ++i) { + control.increase() + compare(control.position, i / count) + } + control.increase() + compare(control.position, 1.0) + + // decrease until 0.0 + for (var d = count - 1; d >= 0; --d) { + control.decrease() + compare(control.position, d / count) + } + control.decrease() + compare(control.position, 0.0) + + control.destroy() + } } diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml index 53e2fb8f..7b38f440 100644 --- a/tests/auto/controls/data/tst_slider.qml +++ b/tests/auto/controls/data/tst_slider.qml @@ -471,4 +471,51 @@ TestCase { control.destroy() } + + function test_wheel_data() { + return [ + { tag: "horizontal", orientation: Qt.Horizontal, dx: 120, dy: 0 }, + { tag: "vertical", orientation: Qt.Vertical, dx: 0, dy: 120 } + ] + } + + function test_wheel(data) { + var control = slider.createObject(testCase, {wheelEnabled: true, orientation: data.orientation}) + verify(control) + + compare(control.value, 0.0) + + mouseWheel(control, control.width / 2, control.height / 2, data.dx, data.dy) + compare(control.value, 0.1) + compare(control.position, 0.1) + + control.stepSize = 0.2 + + mouseWheel(control, control.width / 2, control.height / 2, data.dx, data.dy) + compare(control.value, 0.3) + compare(control.position, 0.3) + + control.stepSize = 10.0 + + mouseWheel(control, control.width / 2, control.height / 2, -data.dx, -data.dy) + compare(control.value, 0.0) + compare(control.position, 0.0) + + control.to = 10.0 + control.stepSize = 5.0 + + mouseWheel(control, control.width / 2, control.height / 2, data.dx, data.dy) + compare(control.value, 5.0) + compare(control.position, 0.5) + + mouseWheel(control, control.width / 2, control.height / 2, 0.5 * data.dx, 0.5 * data.dy) + compare(control.value, 7.5) + compare(control.position, 0.75) + + mouseWheel(control, control.width / 2, control.height / 2, -data.dx, -data.dy) + compare(control.value, 2.5) + compare(control.position, 0.25) + + control.destroy() + } } diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml index cdea8b66..e76725b6 100644 --- a/tests/auto/controls/data/tst_spinbox.qml +++ b/tests/auto/controls/data/tst_spinbox.qml @@ -87,6 +87,7 @@ TestCase { compare(control.to, 99) compare(control.value, 0) compare(control.stepSize, 1) + compare(control.editable, false) compare(control.up.pressed, false) compare(control.down.pressed, false) @@ -326,4 +327,62 @@ TestCase { control.destroy() } + + function test_editable() { + var control = spinBox.createObject(testCase) + verify(control) + + control.contentItem.forceActiveFocus() + compare(control.contentItem.activeFocus, true) + + compare(control.editable, false) + control.contentItem.selectAll() + keyClick(Qt.Key_5) + keyClick(Qt.Key_Return) + compare(control.value, 0) + + control.editable = true + compare(control.editable, true) + control.contentItem.selectAll() + keyClick(Qt.Key_5) + keyClick(Qt.Key_Return) + compare(control.value, 5) + + control.destroy() + } + + function test_wheel(data) { + var control = spinBox.createObject(testCase, {wheelEnabled: true}) + verify(control) + + var delta = 120 + + compare(control.value, 0) + + mouseWheel(control, control.width / 2, control.height / 2, delta, delta) + compare(control.value, 1) + + control.stepSize = 2 + + mouseWheel(control, control.width / 2, control.height / 2, delta, delta) + compare(control.value, 3) + + control.stepSize = 10 + + mouseWheel(control, control.width / 2, control.height / 2, -delta, -delta) + compare(control.value, 0) + + control.stepSize = 5 + + mouseWheel(control, control.width / 2, control.height / 2, delta, delta) + compare(control.value, 5) + + mouseWheel(control, control.width / 2, control.height / 2, 0.5 * delta, 0.5 * delta) + compare(control.value, 8) + + mouseWheel(control, control.width / 2, control.height / 2, -delta, -delta) + compare(control.value, 3) + + control.destroy() + } } diff --git a/tests/auto/controls/data/tst_swipedelegate.qml b/tests/auto/controls/data/tst_swipedelegate.qml new file mode 100644 index 00000000..de5d7862 --- /dev/null +++ b/tests/auto/controls/data/tst_swipedelegate.qml @@ -0,0 +1,889 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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.6 +import QtTest 1.0 +import Qt.labs.controls 1.0 + +TestCase { + id: testCase + width: 200 + height: 200 + visible: true + when: windowShown + name: "SwipeDelegate" + + readonly property int dragDistance: Math.max(20, Qt.styleHints.startDragDistance + 5) + + Component { + id: greenLeftComponent + + Rectangle { + objectName: "leftItem" + anchors.fill: parent + color: "green" + } + } + + Component { + id: redRightComponent + + Rectangle { + objectName: "rightItem" + anchors.fill: parent + color: "red" + } + } + + Component { + id: swipeDelegateComponent + + SwipeDelegate { + id: swipeDelegate + text: "SwipeDelegate" + width: 150 + exposure.left: greenLeftComponent + exposure.right: redRightComponent + } + } + + function test_defaults() { + var control = swipeDelegateComponent.createObject(testCase); + verify(control); + + compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset); + compare(control.exposure.position, 0); + verify(!control.pressed); + verify(!control.exposure.active); + + control.destroy(); + } + + Component { + id: itemComponent + + Item {} + } + + // Assumes that the delegate is smaller than the width of the control. + function swipe(control, from, to) { + // Sanity check. + compare(control.exposure.position, from); + + var distance = (to - from) * control.width; + + mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton); + mouseMove(control, control.width / 2 + distance, control.height / 2, Qt.LeftButton); + mouseRelease(control, control.width / 2 + distance, control.height / 2, Qt.LeftButton); + compare(control.exposure.position, to); + + if (control.exposure.position === -1.0) { + if (control.exposure.right) + verify(control.exposure.rightItem); + else if (control.exposure.behind) + verify(control.exposure.behindItem); + } else if (control.exposure.position === 1.0) { + if (control.exposure.left) + verify(control.exposure.leftItem); + else if (control.exposure.behind) + verify(control.exposure.behindItem); + } + } + + function test_settingDelegates() { + var control = swipeDelegateComponent.createObject(testCase); + verify(control); + + ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + + ":78:9: QML SwipeDelegate: cannot set both behind and left/right properties") + control.exposure.behind = itemComponent; + + // Shouldn't be any warnings when unsetting delegates. + control.exposure.left = null; + compare(control.exposure.leftItem, null); + + // right is still set. + ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + + ":78:9: QML SwipeDelegate: cannot set both behind and left/right properties") + control.exposure.behind = itemComponent; + + control.exposure.right = null; + compare(control.exposure.rightItem, null); + + control.exposure.behind = itemComponent; + + ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + + ":78:9: QML SwipeDelegate: cannot set both behind and left/right properties") + control.exposure.left = itemComponent; + + ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + + ":78:9: QML SwipeDelegate: cannot set both behind and left/right properties") + control.exposure.right = itemComponent; + + control.exposure.behind = null; + control.exposure.left = greenLeftComponent; + control.exposure.right = redRightComponent; + + // Test that the user is warned when attempting to set or unset left or + // right item while they're exposed. + // First, try the left item. + swipe(control, 0.0, 1.0); + + var oldLeft = control.exposure.left; + var oldLeftItem = control.exposure.leftItem; + ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + + ":78:9: QML SwipeDelegate: left/right/behind properties may only be set when exposure.position is 0") + control.exposure.left = null; + compare(control.exposure.left, oldLeft); + compare(control.exposure.leftItem, oldLeftItem); + + // Try the same thing with the right item. + swipe(control, 1.0, -1.0); + + var oldRight = control.exposure.right; + var oldRightItem = control.exposure.rightItem; + ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + + ":78:9: QML SwipeDelegate: left/right/behind properties may only be set when exposure.position is 0") + control.exposure.right = null; + compare(control.exposure.right, oldRight); + compare(control.exposure.rightItem, oldRightItem); + + // Return to the default position. + swipe(control, -1.0, 0.0); + + tryCompare(control.background, "x", 0, 1000); + + // Try the same thing with the behind item. + control.exposure.left = null; + verify(!control.exposure.left); + verify(!control.exposure.leftItem); + control.exposure.right = null; + verify(!control.exposure.right); + verify(!control.exposure.rightItem); + control.exposure.behind = greenLeftComponent; + verify(control.exposure.behind); + verify(!control.exposure.behindItem); + + swipe(control, 0.0, 1.0); + + var oldBehind = control.exposure.behind; + var oldBehindItem = control.exposure.behindItem; + ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + + ":78:9: QML SwipeDelegate: left/right/behind properties may only be set when exposure.position is 0") + control.exposure.behind = null; + compare(control.exposure.behind, oldBehind); + compare(control.exposure.behindItem, oldBehindItem); + + control.destroy(); + } + + ControlSpy { + id: mouseEventControlSpy + signals: ["pressed", "released", "canceled", "clicked", "doubleClicked", "pressedChanged"] + } + + function test_swipe() { + var control = swipeDelegateComponent.createObject(testCase); + verify(control); + + var overDragDistance = dragDistance * 1.1; + + mouseEventControlSpy.target = control; + mouseEventControlSpy.expectedSequence = [["pressedChanged", { "pressed": true }], "pressed"]; + mousePress(control, control.width / 2, control.height / 2); + verify(control.pressed); + compare(control.exposure.position, 0.0); + verify(!control.exposure.active); + verify(mouseEventControlSpy.success); + verify(!control.exposure.leftItem); + verify(!control.exposure.rightItem); + + // Drag to the right so that leftItem is created and visible. + mouseMove(control, control.width / 2 + overDragDistance, control.height / 2); + verify(control.pressed); + compare(control.exposure.position, overDragDistance / control.width); + verify(!control.exposure.active); + verify(control.exposure.leftItem); + verify(control.exposure.leftItem.visible); + compare(control.exposure.leftItem.parent, control); + compare(control.exposure.leftItem.objectName, "leftItem"); + verify(!control.exposure.rightItem); + + // Go back to 0. + mouseMove(control, control.width / 2, control.height / 2); + verify(control.pressed); + compare(control.exposure.position, 0.0); + verify(!control.exposure.active); + verify(control.exposure.leftItem); + verify(control.exposure.leftItem.visible); + compare(control.exposure.leftItem.parent, control); + compare(control.exposure.leftItem.objectName, "leftItem"); + verify(!control.exposure.rightItem); + + // Try the other direction. The right item should be created and visible, + // and the left item should be hidden. + mouseMove(control, control.width / 2 - overDragDistance, control.height / 2); + verify(control.pressed); + compare(control.exposure.position, -overDragDistance / control.width); + verify(!control.exposure.active); + verify(control.exposure.leftItem); + verify(!control.exposure.leftItem.visible); + verify(control.exposure.rightItem); + verify(control.exposure.rightItem.visible); + compare(control.exposure.rightItem.parent, control); + compare(control.exposure.rightItem.objectName, "rightItem"); + + // Now release outside the right edge of the control. + mouseMove(control, control.width * 1.1, control.height / 2); + verify(control.pressed); + compare(control.exposure.position, 0.6); + verify(!control.exposure.active); + verify(control.exposure.leftItem); + verify(control.exposure.leftItem.visible); + verify(control.exposure.rightItem); + verify(!control.exposure.rightItem.visible); + + mouseEventControlSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "released", "clicked"]; + mouseRelease(control, control.width / 2, control.height / 2); + verify(!control.pressed); + compare(control.exposure.position, 1.0); + verify(control.exposure.active); + verify(mouseEventControlSpy.success); + verify(control.exposure.leftItem); + verify(control.exposure.leftItem.visible); + verify(control.exposure.rightItem); + verify(!control.exposure.rightItem.visible); + tryCompare(control.contentItem, "x", control.width + control.leftPadding); + + // Swiping from the right and releasing early should return position to 1.0. + mouseEventControlSpy.expectedSequence = [["pressedChanged", { "pressed": true }], "pressed"]; + mousePress(control, control.width / 2, control.height / 2); + verify(control.pressed); + compare(control.exposure.position, 1.0); + // exposed should still be true, because we haven't moved yet, and hence + // haven't started grabbing behind's mouse events. + verify(control.exposure.active); + verify(mouseEventControlSpy.success); + + mouseMove(control, control.width / 2 - overDragDistance, control.height / 2); + verify(control.pressed); + verify(!control.exposure.active); + compare(control.exposure.position, 1.0 - overDragDistance / control.width); + + mouseEventControlSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "released", "clicked"]; + mouseRelease(control, control.width * 0.4, control.height / 2); + verify(!control.pressed); + compare(control.exposure.position, 1.0); + verify(control.exposure.active); + verify(mouseEventControlSpy.success); + tryCompare(control.contentItem, "x", control.width + control.leftPadding); + + // Swiping from the right and releasing should return contents to default position. + mouseEventControlSpy.expectedSequence = [["pressedChanged", { "pressed": true }], "pressed"]; + mousePress(control, control.width / 2, control.height / 2); + verify(control.pressed); + compare(control.exposure.position, 1.0); + verify(control.exposure.active); + verify(mouseEventControlSpy.success); + + mouseMove(control, control.width * -0.1, control.height / 2); + verify(control.pressed); + verify(!control.exposure.active); + compare(control.exposure.position, 0.4); + + mouseEventControlSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "released", "clicked"]; + mouseRelease(control, control.width * -0.1, control.height / 2); + verify(!control.pressed); + compare(control.exposure.position, 0.0); + verify(!control.exposure.active); + verify(mouseEventControlSpy.success); + tryCompare(control.contentItem, "x", control.leftPadding); + + control.destroy(); + } + + function test_swipeVelocity_data() { + return [ + { tag: "positive velocity", direction: 1 }, + { tag: "negative velocity", direction: -1 } + ]; + } + + function test_swipeVelocity(data) { + skip("QTBUG-52003"); + + var control = swipeDelegateComponent.createObject(testCase); + verify(control); + + var distance = dragDistance * 1.1; + if (distance >= control.width / 2) + skip("This test requires a startDragDistance that is less than half the width of the control"); + + distance *= data.direction; + + mouseEventControlSpy.target = control; + mouseEventControlSpy.expectedSequence = [["pressedChanged", { "pressed": true }], "pressed"]; + mousePress(control, control.width / 2, control.height / 2); + verify(control.pressed); + compare(control.exposure.position, 0.0); + verify(!control.exposure.active); + verify(mouseEventControlSpy.success); + verify(!control.exposure.leftItem); + verify(!control.exposure.rightItem); + + // Swipe quickly to the side over a distance that is longer than the drag threshold, + // quicker than the expose velocity threshold, but shorter than the halfway mark. + mouseMove(control, control.width / 2 + distance, control.height / 2); + verify(control.pressed); + compare(control.exposure.position, distance / control.width); + verify(control.exposure.position < 0.5); + verify(!control.exposure.active); + + var expectedVisibleItem; + var expectedVisibleObjectName; + var expectedHiddenItem; + var expectedContentItemX; + if (distance > 0) { + expectedVisibleObjectName = "leftItem"; + expectedVisibleItem = control.exposure.leftItem; + expectedHiddenItem = control.exposure.rightItem; + expectedContentItemX = control.width + control.leftPadding; + } else { + expectedVisibleObjectName = "rightItem"; + expectedVisibleItem = control.exposure.rightItem; + expectedHiddenItem = control.exposure.leftItem; + expectedContentItemX = -control.width + control.leftPadding; + } + verify(expectedVisibleItem); + verify(expectedVisibleItem.visible); + compare(expectedVisibleItem.parent, control); + compare(expectedVisibleItem.objectName, expectedVisibleObjectName); + verify(!expectedHiddenItem); + + mouseEventControlSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "released", "clicked"]; + // Add a delay to ensure that the release event doesn't happen too quickly, + // and hence that the second timestamp isn't zero (can happen with e.g. release builds). + mouseRelease(control, control.width / 2 + distance, control.height / 2, Qt.LeftButton, Qt.NoModifier, 30); + verify(!control.pressed); + compare(control.exposure.position, data.direction); + verify(control.exposure.active); + verify(mouseEventControlSpy.success); + verify(expectedVisibleItem); + verify(expectedVisibleItem.visible); + verify(!expectedHiddenItem); + tryCompare(control.contentItem, "x", expectedContentItemX); + + control.destroy(); + } + + Component { + id: swipeDelegateWithButtonComponent + SwipeDelegate { + text: "SwipeDelegate" + width: 150 + exposure.right: Button { + width: parent.width + height: parent.height + text: "Boo!" + } + } + } + + function test_eventsToLeftAndRight() { + var control = swipeDelegateWithButtonComponent.createObject(testCase); + verify(control); + + // The button should be pressed instead of the SwipeDelegate. + mouseDrag(control, control.width / 2, control.height / 2, -control.width, 0); + verify(!control.pressed); + compare(control.exposure.position, -1.0); + verify(control.exposure.rightItem); + verify(control.exposure.rightItem.visible); + compare(control.exposure.rightItem.parent, control); + + mousePress(control, control.width / 2, control.height / 2); + verify(!control.pressed); + var button = control.exposure.rightItem; + verify(button.pressed); + + mouseRelease(control, control.width / 2, control.height / 2); + verify(!button.pressed); + + // Returning back to a position of 0 and pressing on the control should + // result in the control being pressed. + mouseDrag(control, control.width / 2, control.height / 2, control.width * 0.6, 0); + compare(control.exposure.position, 0); + mousePress(control, control.width / 2, control.height / 2); + verify(control.pressed); + verify(!button.pressed); + mouseRelease(control, control.width / 2, control.height / 2); + verify(!control.pressed); + + control.destroy(); + } + + function test_mouseButtons() { + var control = swipeDelegateComponent.createObject(testCase); + verify(control); + + // click + mouseEventControlSpy.target = control; + mouseEventControlSpy.expectedSequence = [["pressedChanged", { "pressed": true }], "pressed"]; + mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton); + compare(control.pressed, true); + + verify(mouseEventControlSpy.success); + + mouseEventControlSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "released", "clicked"]; + mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftButton); + compare(control.pressed, false); + verify(mouseEventControlSpy.success); + + // right button + mouseEventControlSpy.expectedSequence = []; + mousePress(control, control.width / 2, control.height / 2, Qt.RightButton); + compare(control.pressed, false); + + mouseRelease(control, control.width / 2, control.height / 2, Qt.RightButton); + compare(control.pressed, false); + verify(mouseEventControlSpy.success); + + // double click + mouseEventControlSpy.expectedSequence = [ + ["pressedChanged", { "pressed": true }], + "pressed", + ["pressedChanged", { "pressed": false }], + "released", + "clicked", + ["pressedChanged", { "pressed": true }], + "pressed", + "doubleClicked", + ["pressedChanged", { "pressed": false }], + "released", + "clicked" + ]; + mouseDoubleClickSequence(control, control.width / 2, control.height / 2, Qt.LeftButton); + verify(mouseEventControlSpy.success); + + control.destroy(); + } + + Component { + id: removableDelegatesComponent + + ListView { + id: listView + width: 100 + height: 120 + + model: ListModel { + ListElement { name: "Apple" } + ListElement { name: "Orange" } + ListElement { name: "Pear" } + } + + delegate: SwipeDelegate { + id: rootDelegate + text: modelData + width: listView.width + + onClicked: if (exposure.active) ListView.view.model.remove(index) + + property alias removeAnimation: onRemoveAnimation + + ListView.onRemove: SequentialAnimation { + id: onRemoveAnimation + + PropertyAction { + target: rootDelegate + property: "ListView.delayRemove" + value: true + } + NumberAnimation { + target: rootDelegate + property: "height" + to: 0 + easing.type: Easing.InOutQuad + } + PropertyAction { + target: rootDelegate; + property: "ListView.delayRemove"; + value: false + } + } + + exposure.left: Rectangle { + color: rootDelegate.exposure.active && rootDelegate.pressed ? "#333" : "#444" + anchors.fill: parent + + Label { + objectName: "label" + text: "Remove" + color: "white" + anchors.centerIn: parent + } + } + } + } + } + + function test_removableDelegates() { + var listView = removableDelegatesComponent.createObject(testCase); + verify(listView); + compare(listView.count, 3); + + // Expose the remove button. + var firstItem = listView.itemAt(0, 0); + mousePress(listView, firstItem.width / 2, firstItem.height / 2); + verify(firstItem.pressed); + compare(firstItem.exposure.position, 0.0); + verify(!firstItem.exposure.active); + + mouseMove(listView, firstItem.width * 1.1, firstItem.height / 2); + verify(firstItem.pressed); + compare(firstItem.exposure.position, 0.6); + verify(!firstItem.exposure.active); + + mouseRelease(listView, firstItem.width / 2, firstItem.height / 2); + verify(!firstItem.pressed); + compare(firstItem.exposure.position, 1.0); + verify(firstItem.exposure.active); + compare(listView.count, 3); + + // Wait for it to settle down. + tryCompare(firstItem.contentItem, "x", firstItem.leftPadding + firstItem.width); + + // Click the button to remove the item. + var contentItemX = firstItem.contentItem.x; + mouseClick(listView, firstItem.width / 2, firstItem.height / 2); + tryCompare(firstItem.removeAnimation, "running", true); + // There was a bug where the resizeContent() would be called because the height + // of the control was changing due to the animation. contentItem would then + // change x position and hence be visible when it shouldn't be. + verify(firstItem.removeAnimation.running); + while (1) { + wait(10) + if (firstItem && firstItem.removeAnimation && firstItem.removeAnimation.running) + compare(firstItem.contentItem.x, contentItemX); + else + break; + } + compare(listView.count, 2); + + listView.destroy(); + } + + Component { + id: leadingTrailingXComponent + SwipeDelegate { + id: delegate + width: 150 + text: "SwipeDelegate" + + exposure.left: Rectangle { + x: delegate.background.x - width + width: delegate.width + height: delegate.height + color: "green" + } + + exposure.right: Rectangle { + x: delegate.background.x + delegate.background.width + width: delegate.width + height: delegate.height + color: "red" + } + } + } + + Component { + id: leadingTrailingAnchorsComponent + SwipeDelegate { + id: delegate + width: 150 + text: "SwipeDelegate" + + exposure.left: Rectangle { + anchors.right: delegate.background.left + width: delegate.width + height: delegate.height + color: "green" + } + + exposure.right: Rectangle { + anchors.left: delegate.background.right + width: delegate.width + height: delegate.height + color: "red" + } + } + } + + function test_leadingTrailing_data() { + return [ + { tag: "x", component: leadingTrailingXComponent }, + { tag: "anchors", component: leadingTrailingAnchorsComponent }, + ]; + } + + function test_leadingTrailing(data) { + var control = data.component.createObject(testCase); + verify(control); + + mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton); + mouseMove(control, control.width, control.height / 2, Qt.LeftButton); + verify(control.exposure.leftItem); + compare(control.exposure.leftItem.x, -control.width / 2); + mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftButton); + + control.destroy(); + } + + function test_minMaxPosition() { + var control = leadingTrailingXComponent.createObject(testCase); + verify(control); + + // Should be limited within the range -1.0 to 1.0. + mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton); + mouseMove(control, control.width * 1.5, control.height / 2, Qt.LeftButton); + compare(control.exposure.position, 1.0); + mouseMove(control, control.width * 1.6, control.height / 2, Qt.LeftButton); + compare(control.exposure.position, 1.0); + mouseMove(control, control.width * -1.6, control.height / 2, Qt.LeftButton); + compare(control.exposure.position, -1.0); + mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftButton); + + control.destroy(); + } + + Component { + id: emptySwipeDelegateComponent + + SwipeDelegate { + text: "SwipeDelegate" + width: 150 + } + } + + Component { + id: smallLeftComponent + + Rectangle { + width: 80 + height: 40 + color: "green" + } + } + + // exposure.position should be scaled to the width of the relevant delegate, + // and it shouldn't be possible to drag past the delegate (so that content behind the control is visible). + function test_delegateWidth() { + var control = emptySwipeDelegateComponent.createObject(testCase); + verify(control); + + control.exposure.left = smallLeftComponent; + + // Ensure that the position is scaled to the width of the currently visible delegate. + var overDragDistance = dragDistance * 1.1; + mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton); + mouseMove(control, control.width / 2 + overDragDistance, control.height / 2, Qt.LeftButton); + verify(control.exposure.leftItem); + compare(control.exposure.position, overDragDistance / control.exposure.leftItem.width); + + mouseMove(control, control.width / 2 + control.exposure.leftItem.width, control.height / 2, Qt.LeftButton); + compare(control.exposure.position, 1.0); + + // Ensure that it's not possible to drag past the (left) delegate. + mouseMove(control, control.width / 2 + control.exposure.leftItem.width + 1, control.height / 2, Qt.LeftButton); + compare(control.exposure.position, 1.0); + + // Now release over the right side; the position should be 1.0 and the background + // should be "anchored" to the right side of the left delegate item. + mouseMove(control, control.width / 2 + control.exposure.leftItem.width, control.height / 2, Qt.LeftButton); + mouseRelease(control, control.width / 2 + control.exposure.leftItem.width, control.height / 2, Qt.LeftButton); + compare(control.exposure.position, 1.0); + tryCompare(control.background, "x", control.exposure.leftItem.width, 1000); + + control.destroy(); + } + + SignalSpy { + id: leftVisibleSpy + signalName: "visibleChanged" + } + + SignalSpy { + id: rightVisibleSpy + signalName: "visibleChanged" + } + + function test_positionAfterExposureMadeActive() { + var control = swipeDelegateComponent.createObject(testCase); + verify(control); + + // Ensure that both delegates are constructed. + mousePress(control, 0, control.height / 2, Qt.LeftButton); + mouseMove(control, control.width * 1.1, control.height / 2, Qt.LeftButton); + verify(control.exposure.leftItem); + mouseMove(control, control.width * -0.1, control.height / 2, Qt.LeftButton); + verify(control.exposure.rightItem); + + // Expose the left delegate. + mouseMove(control, control.exposure.leftItem.width, control.height / 2, Qt.LeftButton); + mouseRelease(control, control.exposure.leftItem.width, control.height / 2); + verify(control.exposure.active); + compare(control.exposure.position, 1.0); + + leftVisibleSpy.target = control.exposure.leftItem; + rightVisibleSpy.target = control.exposure.rightItem; + + // Swipe from right to left without exposing the right item, + // and make sure that the right item never becomes visible + // (and hence that the left item never loses visibility). + mousePress(control, control.exposure.leftItem.width, control.height / 2, Qt.LeftButton); + compare(leftVisibleSpy.count, 0); + compare(rightVisibleSpy.count, 0); + var newX = control.exposure.leftItem.width - dragDistance * 1.1; + mouseMove(control, newX, control.height / 2, Qt.LeftButton, Qt.LeftButton); + compare(leftVisibleSpy.count, 0); + compare(rightVisibleSpy.count, 0); + compare(control.exposure.position, newX / control.exposure.leftItem.width); + + mouseMove(control, 0, control.height / 2, Qt.LeftButton); + compare(control.exposure.position, 0); + + // Test swiping over a distance that is greater than the width of the left item. + mouseMove(control, -1, control.height / 2, Qt.LeftButton); + verify(control.exposure.rightItem); + compare(control.exposure.position, -1 / control.exposure.rightItem.width); + + // Now go back to 1.0. + mouseMove(control, control.exposure.leftItem.width, control.height / 2, Qt.LeftButton); + compare(control.exposure.position, 1.0); + tryCompare(control.background, "x", control.exposure.leftItem.width, 1000); + mouseRelease(control, control.exposure.leftItem.width, control.height / 2, Qt.LeftButton); + + control.destroy(); + } + + // TODO: this somehow results in the behind item having a negative width +// Component { +// id: behindSwipeDelegateComponent +// SwipeDelegate { +// anchors.centerIn: parent +// exposure.behind: Rectangle { +// onXChanged: print("x changed", x) +// anchors.left: { +// print("anchors.left expression", exposure.position) +// exposure.position < 0 ? parent.background.right : undefined +// } +// anchors.right: { +// print("anchors.right expression", exposure.position) +// exposure.position > 0 ? parent.background.left : undefined +// } +// width: parent.width +// height: parent.height +// color: "green" +// } +// exposure.left: null +// exposure.right: null +// Rectangle { +// anchors.fill: parent +// color: "transparent" +// border.color: "darkorange" +// } +// } +// } + + Component { + id: behindSwipeDelegateComponent + SwipeDelegate { + text: "SwipeDelegate" + width: 150 + anchors.centerIn: parent + exposure.behind: Rectangle { + x: exposure.position < 0 ? parent.background.x + parent.background.width + : (exposure.position > 0 ? parent.background.x - width : 0) + width: parent.width + height: parent.height + color: "green" + } + exposure.left: null + exposure.right: null + } + } + + function test_leadingTrailingBehindItem() { + var control = behindSwipeDelegateComponent.createObject(testCase); + verify(control); + + swipe(control, 0.0, 1.0); + verify(control.exposure.behindItem.visible); + compare(control.exposure.behindItem.x, control.background.x - control.background.width); + + swipe(control, 1.0, -1.0); + verify(control.exposure.behindItem.visible); + compare(control.exposure.behindItem.x, control.background.x + control.background.width); + + swipe(control, -1.0, 1.0); + verify(control.exposure.behindItem.visible); + compare(control.exposure.behindItem.x, control.background.x - control.background.width); + + // Should be possible to "wrap" with a behind delegate specified. + mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton); + mouseMove(control, control.width / 2 + control.exposure.behindItem.width * 0.8, control.height / 2, Qt.LeftButton); + compare(control.exposure.position, -0.2); + mouseRelease(control, control.width / 2 + control.exposure.behindItem.width * 0.8, control.height / 2, Qt.LeftButton); + compare(control.exposure.position, 0.0); + + // Try wrapping the other way. + swipe(control, 0.0, -1.0); + verify(control.exposure.behindItem.visible); + compare(control.exposure.behindItem.x, control.background.x + control.background.width); + + mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton); + mouseMove(control, control.width / 2 - control.exposure.behindItem.width * 0.8, control.height / 2, Qt.LeftButton); + compare(control.exposure.position, 0.2); + mouseRelease(control, control.width / 2 - control.exposure.behindItem.width * 0.8, control.height / 2, Qt.LeftButton); + compare(control.exposure.position, 0.0); + + control.destroy(); + } +} diff --git a/tests/auto/controls/data/tst_switch.qml b/tests/auto/controls/data/tst_switch.qml index 13924ed0..7443f330 100644 --- a/tests/auto/controls/data/tst_switch.qml +++ b/tests/auto/controls/data/tst_switch.qml @@ -260,7 +260,7 @@ TestCase { function test_baseline() { var control = swtch.createObject(testCase) verify(control) - compare(control.baselineOffset, control.label.y + control.label.baselineOffset) + compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset) control.destroy() } } diff --git a/tests/auto/controls/data/tst_tabbutton.qml b/tests/auto/controls/data/tst_tabbutton.qml index 3a817cfd..f755c081 100644 --- a/tests/auto/controls/data/tst_tabbutton.qml +++ b/tests/auto/controls/data/tst_tabbutton.qml @@ -85,7 +85,7 @@ TestCase { function test_baseline() { var control = tabButton.createObject(testCase) verify(control) - compare(control.baselineOffset, control.label.y + control.label.baselineOffset) + compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset) control.destroy() } } diff --git a/tests/auto/controls/data/tst_toolbutton.qml b/tests/auto/controls/data/tst_toolbutton.qml index 63a87ec2..6c03f18c 100644 --- a/tests/auto/controls/data/tst_toolbutton.qml +++ b/tests/auto/controls/data/tst_toolbutton.qml @@ -173,7 +173,7 @@ TestCase { function test_baseline() { var control = toolButton.createObject(testCase) verify(control) - compare(control.baselineOffset, control.label.y + control.label.baselineOffset) + compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset) control.destroy() } } diff --git a/tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml b/tests/auto/focus/data/activeFocusOnTab.qml index 08ecdda2..46f9f522 100644 --- a/tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml +++ b/tests/auto/focus/data/activeFocusOnTab.qml @@ -129,6 +129,8 @@ Item { RangeSlider { id: rangeslider objectName: "rangeslider" + first.handle.objectName: "rangeslider.first" + second.handle.objectName: "rangeslider.second" } // ScrollBar ScrollIndicator { @@ -143,6 +145,7 @@ Item { SpinBox { id: spinbox objectName: "spinbox" + editable: true value: 50 } // StackView diff --git a/tests/auto/focus/data/keyNavigation.qml b/tests/auto/focus/data/keyNavigation.qml new file mode 100644 index 00000000..3419fe3f --- /dev/null +++ b/tests/auto/focus/data/keyNavigation.qml @@ -0,0 +1,251 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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.5 +import Qt.labs.controls 1.0 + +Item { + id: main + objectName: "main" + width: 400 + height: 800 + focus: true + Component.onCompleted: button1.focus = true + Column { + anchors.fill: parent + id: column + objectName: "column" + BusyIndicator { + id: busyindicator + objectName: "busyindicator" + } + Button { + id: button1 + objectName: "button1" + text: "button1" + KeyNavigation.up: textarea + KeyNavigation.down: button2 + KeyNavigation.left: toolbutton + KeyNavigation.right: button2 + } + Button { + id: button2 + objectName: "button2" + text: "button2" + KeyNavigation.up: button1 + KeyNavigation.down: checkbox + KeyNavigation.left: button1 + KeyNavigation.right: checkbox + } + CheckBox { + id: checkbox + objectName: "checkbox" + text: "checkbox" + KeyNavigation.up: button2 + KeyNavigation.down: checkbox1 + KeyNavigation.left: button2 + KeyNavigation.right: checkbox1 + } + GroupBox { + id: groupbox1 + objectName: "groupbox1" + title: "grouppox1" + Column { + anchors.fill: parent + CheckBox { + id: checkbox1 + objectName: "checkbox1" + text: "checkbox1" + KeyNavigation.up: checkbox + KeyNavigation.down: checkbox2 + KeyNavigation.left: checkbox + KeyNavigation.right: checkbox2 + } + CheckBox { + id: checkbox2 + objectName: "checkbox2" + text: "checkbox2" + KeyNavigation.up: checkbox1 + KeyNavigation.down: radiobutton + KeyNavigation.left: checkbox1 + KeyNavigation.right: radiobutton + } + } + } + Label { + id: label + objectName: "label" + text: "label" + } + PageIndicator { + id: pageindicator + objectName: "pageindicator" + } + ProgressBar { + id: progressbar + objectName: "progressbar" + indeterminate: true + } + RadioButton { + id: radiobutton + objectName: "radiobutton" + text: "radiobutton" + KeyNavigation.up: checkbox2 + KeyNavigation.down: radiobutton1 + KeyNavigation.left: checkbox2 + KeyNavigation.right: radiobutton1 + } + GroupBox { + id: groupbox2 + objectName: "groupbox2" + title: "groupbox2" + Column { + anchors.fill: parent + RadioButton { + id: radiobutton1 + objectName: "radiobutton1" + text: "radiobutton1" + KeyNavigation.up: radiobutton + KeyNavigation.down: radiobutton2 + KeyNavigation.left: radiobutton + KeyNavigation.right: radiobutton2 + } + RadioButton { + id: radiobutton2 + objectName: "radiobutton2" + text: "radiobutton2" + KeyNavigation.up: radiobutton1 + KeyNavigation.down: rangeslider + KeyNavigation.left: radiobutton1 + KeyNavigation.right: spinbox + } + } + } + RangeSlider { + id: rangeslider + objectName: "rangeslider" + first.handle.objectName: "rangeslider.first" + second.handle.objectName: "rangeslider.second" + KeyNavigation.up: radiobutton2 + KeyNavigation.down: slider + } + // ScrollBar + ScrollIndicator { + id: scrollindicator + objectName: "scrollindicator" + } + Slider { + id: slider + objectName: "slider" + value: 0.5 + KeyNavigation.up: rangeslider + KeyNavigation.down: swtich + } + SpinBox { + id: spinbox + objectName: "spinbox" + editable: true + value: 50 + KeyNavigation.left: radiobutton2 + KeyNavigation.right: swtich + } + // StackView + Switch { + id: swtich // switch + objectName: "switch" + text: "switch" + KeyNavigation.up: slider + KeyNavigation.down: tabbutton1 + KeyNavigation.left: spinbox + KeyNavigation.right: tabbutton1 + } + TabBar { + width: parent.width + id: tabbar + objectName: "tabbar" + TabButton { + id: tabbutton1 + objectName: "tabbutton1" + text: "tabbutton1" + KeyNavigation.up: swtich + KeyNavigation.down: tabbutton2 + KeyNavigation.left: swtich + KeyNavigation.right: tabbutton2 + } + TabButton { + id: tabbutton2 + objectName: "tabbutton2" + text: "tabbutton2" + KeyNavigation.up: tabbutton1 + KeyNavigation.down: textfield + KeyNavigation.left: tabbutton1 + KeyNavigation.right: toolbutton + } + } + TextField { + id: textfield + objectName: "textfield" + text: "abc" + KeyNavigation.up: tabbutton2 + KeyNavigation.down: toolbutton + } + ToolBar { + width: parent.width + id: toolbar + objectName: "toolbar" + ToolButton { + id: toolbutton + objectName: "toolbutton" + text: "toolbutton" + KeyNavigation.up: textfield + KeyNavigation.down: textarea + KeyNavigation.left: tabbutton2 + KeyNavigation.right: button1 + } + } + TextArea { + id: textarea + objectName: "textarea" + text: "abc" + KeyNavigation.up: toolbutton + KeyNavigation.down: button1 + } + } +} diff --git a/tests/auto/focus/focus.pro b/tests/auto/focus/focus.pro new file mode 100644 index 00000000..cfd155b8 --- /dev/null +++ b/tests/auto/focus/focus.pro @@ -0,0 +1,11 @@ +CONFIG += testcase +TARGET = tst_focus +osx:CONFIG -= app_bundle + +SOURCES += tst_focus.cpp + +include (../shared/util.pri) + +TESTDATA = data/* + +QT += core-private gui-private qml-private quick-private quicktemplates-private testlib diff --git a/tests/auto/focus/tst_focus.cpp b/tests/auto/focus/tst_focus.cpp new file mode 100644 index 00000000..18012a42 --- /dev/null +++ b/tests/auto/focus/tst_focus.cpp @@ -0,0 +1,215 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qtest.h> +#include <QtTest/QSignalSpy> +#include <QtQml/qqmlengine.h> +#include <QtQml/qqmlcomponent.h> +#include <QtQml/qqmlcontext.h> +#include <QtQuick/qquickview.h> +#include <QtQuick/private/qquickitem_p.h> +#include <QtQuickTemplates/private/qquickcontrol_p.h> +#include <QtGui/private/qguiapplication_p.h> +#include <QtGui/qstylehints.h> +#include "../shared/util.h" +#include "../shared/visualtestutil.h" + +using namespace QQuickVisualTestUtil; + +class tst_focus : public QQmlDataTest +{ + Q_OBJECT + +private slots: + void initTestCase(); + + void navigation_data(); + void navigation(); + + void policy(); + + void reason_data(); + void reason(); +}; + +void tst_focus::initTestCase() +{ + QQmlDataTest::initTestCase(); +} + +void tst_focus::navigation_data() +{ + QTest::addColumn<Qt::Key>("key"); + QTest::addColumn<QString>("testFile"); + QTest::addColumn<Qt::TabFocusBehavior>("behavior"); + QTest::addColumn<QStringList>("order"); + + QTest::newRow("tab-all-controls") << Qt::Key_Tab << QString("activeFocusOnTab.qml") << Qt::TabFocusAllControls << (QStringList() << "button2" << "checkbox" << "checkbox1" << "checkbox2" << "radiobutton" << "radiobutton1" << "radiobutton2" << "rangeslider.first" << "rangeslider.second" << "slider" << "spinbox" << "switch" << "tabbutton1" << "tabbutton2" << "textfield" << "toolbutton" << "textarea" << "button1"); + QTest::newRow("backtab-all-controls") << Qt::Key_Backtab << QString("activeFocusOnTab.qml") << Qt::TabFocusAllControls << (QStringList() << "textarea" << "toolbutton" << "textfield" << "tabbutton2" << "tabbutton1" << "switch" << "spinbox" << "slider" << "rangeslider.second" << "rangeslider.first" << "radiobutton2" << "radiobutton1" << "radiobutton" << "checkbox2" << "checkbox1" << "checkbox" << "button2" << "button1"); + + QTest::newRow("tab-text-controls") << Qt::Key_Tab << QString("activeFocusOnTab.qml") << Qt::TabFocusTextControls << (QStringList() << "spinbox" << "textfield" << "textarea"); + QTest::newRow("backtab-text-controls") << Qt::Key_Backtab << QString("activeFocusOnTab.qml") << Qt::TabFocusTextControls << (QStringList() << "textarea" << "textfield" << "spinbox"); + + QTest::newRow("key-up") << Qt::Key_Up << QString("keyNavigation.qml") << Qt::TabFocusAllControls << (QStringList() << "textarea" << "toolbutton" << "textfield" << "tabbutton2" << "tabbutton1" << "switch" << "slider" << "rangeslider.first" << "radiobutton2" << "radiobutton1" << "radiobutton" << "checkbox2" << "checkbox1" << "checkbox" << "button2" << "button1"); + QTest::newRow("key-down") << Qt::Key_Down << QString("keyNavigation.qml") << Qt::TabFocusAllControls << (QStringList() << "button2" << "checkbox" << "checkbox1" << "checkbox2" << "radiobutton" << "radiobutton1" << "radiobutton2" << "rangeslider.first" << "slider" << "switch" << "tabbutton1" << "tabbutton2" << "textfield" << "toolbutton" << "textarea" << "button1"); + QTest::newRow("key-left") << Qt::Key_Left << QString("keyNavigation.qml") << Qt::TabFocusAllControls << (QStringList() << "toolbutton" << "tabbutton2" << "tabbutton1" << "switch" << "spinbox" << "radiobutton2" << "radiobutton1" << "radiobutton" << "checkbox2" << "checkbox1" << "checkbox" << "button2" << "button1"); + QTest::newRow("key-right") << Qt::Key_Right << QString("keyNavigation.qml") << Qt::TabFocusAllControls << (QStringList() << "button2" << "checkbox" << "checkbox1" << "checkbox2" << "radiobutton" << "radiobutton1" << "radiobutton2" << "spinbox" << "switch" << "tabbutton1" << "tabbutton2" << "toolbutton" << "button1"); +} + +void tst_focus::navigation() +{ + QFETCH(Qt::Key, key); + QFETCH(QString, testFile); + QFETCH(Qt::TabFocusBehavior, behavior); + QFETCH(QStringList, order); + + QGuiApplication::styleHints()->setTabFocusBehavior(behavior); + + QQuickView view; + view.contentItem()->setObjectName("contentItem"); + + view.setSource(testFileUrl(testFile)); + view.show(); + view.requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(&view)); + QVERIFY(QGuiApplication::focusWindow() == &view); + + foreach (const QString &name, order) { + QKeyEvent event(QEvent::KeyPress, key, Qt::NoModifier); + QGuiApplication::sendEvent(&view, &event); + QVERIFY(event.isAccepted()); + + QQuickItem *item = findItem<QQuickItem>(view.rootObject(), name); + QVERIFY2(item, qPrintable(name)); + QVERIFY2(item->hasActiveFocus(), qPrintable(QString("expected: '%1', actual: '%2'").arg(name).arg(view.activeFocusItem() ? view.activeFocusItem()->objectName() : "null"))); + } + + QGuiApplication::styleHints()->setTabFocusBehavior(Qt::TabFocusBehavior(-1)); +} + +void tst_focus::policy() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import Qt.labs.controls 1.0; ApplicationWindow { width: 100; height: 100; Button { anchors.fill: parent } }", QUrl()); + + QScopedPointer<QQuickApplicationWindow> window(qobject_cast<QQuickApplicationWindow *>(component.create())); + QVERIFY(window); + + QQuickControl *control = qobject_cast<QQuickControl *>(window->contentItem()->childItems().first()); + QVERIFY(control); + + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + + // Qt::TabFocus vs. QQuickItem::activeFocusOnTab + control->setActiveFocusOnTab(true); + QCOMPARE(control->focusPolicy(), Qt::TabFocus); + control->setActiveFocusOnTab(false); + QCOMPARE(control->focusPolicy(), Qt::NoFocus); + + control->setFocusPolicy(Qt::TabFocus); + QCOMPARE(control->focusPolicy(), Qt::TabFocus); + QCOMPARE(control->activeFocusOnTab(), true); + + // Qt::ClickFocus + QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier, QPoint(control->width() / 2, control->height() / 2)); + QVERIFY(!control->hasActiveFocus()); + + control->setFocusPolicy(Qt::ClickFocus); + QCOMPARE(control->focusPolicy(), Qt::ClickFocus); + QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier, QPoint(control->width() / 2, control->height() / 2)); + QVERIFY(control->hasActiveFocus()); + + // reset + control->setFocus(false); + QVERIFY(!control->hasActiveFocus()); + + // Qt::WheelFocus + QWheelEvent wheelEvent(QPoint(control->width() / 2, control->height() / 2), 10, Qt::NoButton, Qt::NoModifier); + QGuiApplication::sendEvent(control, &wheelEvent); + QVERIFY(!control->hasActiveFocus()); + + control->setFocusPolicy(Qt::WheelFocus); + QCOMPARE(control->focusPolicy(), Qt::WheelFocus); + + QGuiApplication::sendEvent(control, &wheelEvent); + QVERIFY(control->hasActiveFocus()); +} + +void tst_focus::reason_data() +{ + QTest::addColumn<QString>("name"); + + QTest::newRow("Control") << "Control"; + QTest::newRow("TextField") << "TextField"; + QTest::newRow("TextArea") << "TextArea"; + QTest::newRow("SpinBox") << "SpinBox"; + QTest::newRow("ComboBox") << "ComboBox"; +} + +void tst_focus::reason() +{ + QFETCH(QString, name); + + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData(QString("import Qt.labs.controls 1.0; ApplicationWindow { width: 100; height: 100; %1 { anchors.fill: parent } }").arg(name).toUtf8(), QUrl()); + + QScopedPointer<QQuickApplicationWindow> window(qobject_cast<QQuickApplicationWindow *>(component.create())); + QVERIFY(window.data()); + + QQuickItem *control = window->contentItem()->childItems().first(); + QVERIFY(control); + + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + + QCOMPARE(control->property("focusReason").toInt(), int(Qt::OtherFocusReason)); + control->forceActiveFocus(Qt::MouseFocusReason); + QVERIFY(control->hasActiveFocus()); + QCOMPARE(control->property("focusReason").toInt(), int(Qt::MouseFocusReason)); + + window->contentItem()->forceActiveFocus(Qt::TabFocusReason); + QVERIFY(!control->hasActiveFocus()); + QCOMPARE(control->property("focusReason").toInt(), int(Qt::TabFocusReason)); +} + +QTEST_MAIN(tst_focus) + +#include "tst_focus.moc" diff --git a/tests/auto/material/data/tst_material.qml b/tests/auto/material/data/tst_material.qml index c686fef8..b116125d 100644 --- a/tests/auto/material/data/tst_material.qml +++ b/tests/auto/material/data/tst_material.qml @@ -425,7 +425,19 @@ TestCase { {tag: "ComboBox:pixelSize", type: "ComboBox", attribute: "pixelSize", value: 16, window: 20, pane: 10}, {tag: "ComboBox:weight", type: "ComboBox", attribute: "weight", value: Font.Normal, window: Font.Black, pane: Font.Bold}, - {tag: "ComboBox:capitalization", type: "ComboBox", attribute: "capitalization", value: Font.MixedCase, window: Font.Capitalize, pane: Font.AllLowercase} + {tag: "ComboBox:capitalization", type: "ComboBox", attribute: "capitalization", value: Font.MixedCase, window: Font.Capitalize, pane: Font.AllLowercase}, + + {tag: "TextField:pixelSize", type: "TextField", attribute: "pixelSize", value: 16, window: 20, pane: 10}, + {tag: "TextField:weight", type: "TextField", attribute: "weight", value: Font.Normal, window: Font.Black, pane: Font.Bold}, + {tag: "TextField:capitalization", type: "TextField", attribute: "capitalization", value: Font.MixedCase, window: Font.Capitalize, pane: Font.AllLowercase}, + + {tag: "TextArea:pixelSize", type: "TextArea", attribute: "pixelSize", value: 16, window: 20, pane: 10}, + {tag: "TextArea:weight", type: "TextArea", attribute: "weight", value: Font.Normal, window: Font.Black, pane: Font.Bold}, + {tag: "TextArea:capitalization", type: "TextArea", attribute: "capitalization", value: Font.MixedCase, window: Font.Capitalize, pane: Font.AllLowercase}, + + {tag: "SpinBox:pixelSize", type: "SpinBox", attribute: "pixelSize", value: 16, window: 20, pane: 10}, + {tag: "SpinBox:weight", type: "SpinBox", attribute: "weight", value: Font.Normal, window: Font.Black, pane: Font.Bold}, + {tag: "SpinBox:capitalization", type: "SpinBox", attribute: "capitalization", value: Font.MixedCase, window: Font.Capitalize, pane: Font.AllLowercase} ] } diff --git a/tests/auto/material/material.qrc b/tests/auto/material/material.qrc index 1df3aef9..f1398b2f 100644 --- a/tests/auto/material/material.qrc +++ b/tests/auto/material/material.qrc @@ -1,5 +1,5 @@ <!DOCTYPE RCC><RCC version="1.0"> <qresource> - <file>qtlabscontrols.conf</file> + <file>qtquickcontrols.conf</file> </qresource> </RCC> diff --git a/tests/auto/material/qtlabscontrols.conf b/tests/auto/material/qtquickcontrols.conf index b6c7c87e..b6c7c87e 100644 --- a/tests/auto/material/qtlabscontrols.conf +++ b/tests/auto/material/qtquickcontrols.conf diff --git a/tests/auto/menu/menu.pro b/tests/auto/menu/menu.pro index 2dd2ac7f..71bb0fb0 100644 --- a/tests/auto/menu/menu.pro +++ b/tests/auto/menu/menu.pro @@ -4,7 +4,7 @@ SOURCES += tst_menu.cpp osx:CONFIG -= app_bundle -QT += core-private gui-private qml-private quick-private testlib labstemplates-private +QT += core-private gui-private qml-private quick-private testlib quicktemplates-private include (../shared/util.pri) diff --git a/tests/auto/menu/tst_menu.cpp b/tests/auto/menu/tst_menu.cpp index 825867cf..20b56143 100644 --- a/tests/auto/menu/tst_menu.cpp +++ b/tests/auto/menu/tst_menu.cpp @@ -45,11 +45,11 @@ #include "../shared/util.h" #include "../shared/visualtestutil.h" -#include <QtLabsTemplates/private/qquickapplicationwindow_p.h> -#include <QtLabsTemplates/private/qquickoverlay_p.h> -#include <QtLabsTemplates/private/qquickbutton_p.h> -#include <QtLabsTemplates/private/qquickmenu_p.h> -#include <QtLabsTemplates/private/qquickmenuitem_p.h> +#include <QtQuickTemplates/private/qquickapplicationwindow_p.h> +#include <QtQuickTemplates/private/qquickoverlay_p.h> +#include <QtQuickTemplates/private/qquickbutton_p.h> +#include <QtQuickTemplates/private/qquickmenu_p.h> +#include <QtQuickTemplates/private/qquickmenuitem_p.h> using namespace QQuickVisualTestUtil; diff --git a/tests/auto/popup/popup.pro b/tests/auto/popup/popup.pro index 87aca3b3..45f55cab 100644 --- a/tests/auto/popup/popup.pro +++ b/tests/auto/popup/popup.pro @@ -4,7 +4,7 @@ SOURCES += tst_popup.cpp osx:CONFIG -= app_bundle -QT += core-private gui-private qml-private quick-private testlib labstemplates-private +QT += core-private gui-private qml-private quick-private testlib quicktemplates-private include (../shared/util.pri) diff --git a/tests/auto/popup/tst_popup.cpp b/tests/auto/popup/tst_popup.cpp index 61bf999c..ae886623 100644 --- a/tests/auto/popup/tst_popup.cpp +++ b/tests/auto/popup/tst_popup.cpp @@ -39,10 +39,10 @@ #include "../shared/util.h" #include "../shared/visualtestutil.h" -#include <QtLabsTemplates/private/qquickapplicationwindow_p.h> -#include <QtLabsTemplates/private/qquickoverlay_p.h> -#include <QtLabsTemplates/private/qquickpopup_p.h> -#include <QtLabsTemplates/private/qquickbutton_p.h> +#include <QtQuickTemplates/private/qquickapplicationwindow_p.h> +#include <QtQuickTemplates/private/qquickoverlay_p.h> +#include <QtQuickTemplates/private/qquickpopup_p.h> +#include <QtQuickTemplates/private/qquickbutton_p.h> using namespace QQuickVisualTestUtil; @@ -63,6 +63,7 @@ void tst_popup::visible() QQuickApplicationWindow *window = helper.window; window->show(); + window->requestActivate(); QVERIFY(QTest::qWaitForWindowActive(window)); QQuickPopup *popup = helper.window->property("popup").value<QQuickPopup*>(); @@ -92,6 +93,7 @@ void tst_popup::overlay() QQuickApplicationWindow *window = helper.window; window->show(); + window->requestActivate(); QVERIFY(QTest::qWaitForWindowActive(window)); QQuickItem *overlay = window->overlay(); @@ -127,11 +129,6 @@ void tst_popup::overlay() QCOMPARE(overlayPressedSignal.count(), 2); QCOMPARE(overlayReleasedSignal.count(), 1); - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(button->x() + popup->x() + popup->width() / 2, - button->y() + popup->y() + popup->height() / 2)); - QCOMPARE(overlayPressedSignal.count(), 2); - QCOMPARE(overlayReleasedSignal.count(), 1); - QVERIFY(!popup->isVisible()); } @@ -160,6 +157,7 @@ void tst_popup::closePolicy() QQuickApplicationWindow *window = helper.window; window->show(); + window->requestActivate(); QVERIFY(QTest::qWaitForWindowActive(window)); QQuickPopup *popup = helper.window->property("popup").value<QQuickPopup*>(); diff --git a/tests/auto/pressandhold/data/dependencies.qml b/tests/auto/pressandhold/data/dependencies.qml new file mode 100644 index 00000000..13690bbc --- /dev/null +++ b/tests/auto/pressandhold/data/dependencies.qml @@ -0,0 +1,4 @@ +import QtQuick 2.6 +import Qt.labs.controls 1.0 + +Control { } diff --git a/tests/auto/pressandhold/tst_pressandhold.cpp b/tests/auto/pressandhold/tst_pressandhold.cpp index 8c4cf673..8ec77f46 100644 --- a/tests/auto/pressandhold/tst_pressandhold.cpp +++ b/tests/auto/pressandhold/tst_pressandhold.cpp @@ -37,13 +37,14 @@ #include <QtTest> #include <QtQuick> -// TODO: add QStyleHints::setMousePressAndHoldInterval() to speedup the test - class tst_PressAndHold : public QObject { Q_OBJECT private slots: + void initTestCase(); + void cleanupTestCase(); + void pressAndHold_data(); void pressAndHold(); @@ -51,12 +52,23 @@ private slots: void keepSelection(); }; +void tst_PressAndHold::initTestCase() +{ + QGuiApplication::styleHints()->setMousePressAndHoldInterval(100); +} + +void tst_PressAndHold::cleanupTestCase() +{ + QGuiApplication::styleHints()->setMousePressAndHoldInterval(-1); +} + void tst_PressAndHold::pressAndHold_data() { QTest::addColumn<QByteArray>("data"); QTest::addColumn<QByteArray>("signal"); QTest::newRow("Button") << QByteArray("import Qt.labs.controls 1.0; Button { text: 'Button' }") << QByteArray(SIGNAL(pressAndHold())); + QTest::newRow("SwipeDelegate") << QByteArray("import Qt.labs.controls 1.0; SwipeDelegate { text: 'SwipeDelegate' }") << QByteArray(SIGNAL(pressAndHold())); QTest::newRow("TextField") << QByteArray("import Qt.labs.controls 1.0; TextField { text: 'TextField' }") << QByteArray(SIGNAL(pressAndHold(QQuickMouseEvent*))); QTest::newRow("TextArea") << QByteArray("import Qt.labs.controls 1.0; TextArea { text: 'TextArea' }") << QByteArray(SIGNAL(pressAndHold(QQuickMouseEvent*))); } diff --git a/tests/auto/sanity/data/dependencies.qml b/tests/auto/sanity/data/dependencies.qml new file mode 100644 index 00000000..13690bbc --- /dev/null +++ b/tests/auto/sanity/data/dependencies.qml @@ -0,0 +1,4 @@ +import QtQuick 2.6 +import Qt.labs.controls 1.0 + +Control { } diff --git a/tests/auto/sanity/tst_sanity.cpp b/tests/auto/sanity/tst_sanity.cpp index bc114d62..7f438721 100644 --- a/tests/auto/sanity/tst_sanity.cpp +++ b/tests/auto/sanity/tst_sanity.cpp @@ -267,14 +267,18 @@ static void addTestRows(QQmlEngine *engine, const QString &targetPath, const QSt // the engine's import path. This way we can use QQmlComponent to load each QML file // for benchmarking. - QFileInfoList entries = QDir(QQC2_IMPORT_PATH + targetPath).entryInfoList(QStringList("*.qml"), QDir::Files); + QFileInfoList entries = QDir(QQC2_IMPORT_PATH "/" + targetPath).entryInfoList(QStringList("*.qml"), QDir::Files); foreach (const QFileInfo &entry, entries) { QString name = entry.baseName(); if (!skiplist.contains(name)) { foreach (const QString &importPath, engine->importPathList()) { - QString filePath = QDir(importPath + "/Qt/labs/" + targetPath).absoluteFilePath(entry.fileName()); + QString name = entry.dir().dirName() + "/" + entry.fileName(); + QString filePath = importPath + "/Qt/labs/" + targetPath + "/" + entry.fileName(); if (QFile::exists(filePath)) { - QTest::newRow(qPrintable(entry.dir().dirName() + "/" + entry.fileName())) << QUrl::fromLocalFile(filePath); + QTest::newRow(qPrintable(name)) << QUrl::fromLocalFile(filePath); + break; + } else if (QFile::exists(QQmlFile::urlToLocalFileOrQrc(filePath))) { + QTest::newRow(qPrintable(name)) << QUrl(filePath); break; } } @@ -305,10 +309,10 @@ void tst_Sanity::attachedObjects() void tst_Sanity::attachedObjects_data() { QTest::addColumn<QUrl>("url"); - addTestRows(&engine, "/calendar"); - addTestRows(&engine, "/controls"); - addTestRows(&engine, "/controls/material", QStringList() << "Ripple" << "SliderHandle"); - addTestRows(&engine, "/controls/universal"); + addTestRows(&engine, "calendar"); + addTestRows(&engine, "controls"); + addTestRows(&engine, "controls/material", QStringList() << "Ripple" << "SliderHandle"); + addTestRows(&engine, "controls/universal"); } QTEST_MAIN(tst_Sanity) diff --git a/tests/auto/shared/util.pri b/tests/auto/shared/util.pri index 5e6b06b6..61d4d509 100644 --- a/tests/auto/shared/util.pri +++ b/tests/auto/shared/util.pri @@ -1,4 +1,4 @@ -QT += core-private gui-private qml-private quick-private labstemplates-private +QT += core-private gui-private qml-private quick-private quicktemplates-private HEADERS += $$PWD/visualtestutil.h \ $$PWD/util.h diff --git a/tests/auto/shared/visualtestutil.h b/tests/auto/shared/visualtestutil.h index b3fecf8e..94c45778 100644 --- a/tests/auto/shared/visualtestutil.h +++ b/tests/auto/shared/visualtestutil.h @@ -42,7 +42,7 @@ #include <QtQuick/private/qquickitem_p.h> -#include <QtLabsTemplates/private/qquickapplicationwindow_p.h> +#include <QtQuickTemplates/private/qquickapplicationwindow_p.h> #include "util.h" diff --git a/tests/auto/snippets/data/dependencies.qml b/tests/auto/snippets/data/dependencies.qml new file mode 100644 index 00000000..15fa1a9a --- /dev/null +++ b/tests/auto/snippets/data/dependencies.qml @@ -0,0 +1,6 @@ +import QtQuick 2.6 +import QtQuick.Layouts 1.3 +import Qt.labs.controls 1.0 +import Qt.labs.calendar 1.0 + +Control { } diff --git a/tests/auto/snippets/tst_snippets.cpp b/tests/auto/snippets/tst_snippets.cpp index 2c6fe6f8..a2e07be7 100644 --- a/tests/auto/snippets/tst_snippets.cpp +++ b/tests/auto/snippets/tst_snippets.cpp @@ -64,7 +64,7 @@ void tst_Snippets::initTestCase() qInfo() << datadir; - QDirIterator it(datadir, QStringList() << "qtlabs*.qml", QDir::Files | QDir::Readable, QDirIterator::Subdirectories); + QDirIterator it(datadir, QStringList() << "qtquick*.qml" << "qtlabs*.qml", QDir::Files | QDir::Readable, QDirIterator::Subdirectories); while (it.hasNext()) { QFileInfo fi(it.next()); filePaths.insert(fi.baseName(), qMakePair(fi.filePath(), outdir.filePath(fi.baseName() + ".png"))); diff --git a/tests/auto/styles/data/dependencies.qml b/tests/auto/styles/data/dependencies.qml new file mode 100644 index 00000000..310fbf40 --- /dev/null +++ b/tests/auto/styles/data/dependencies.qml @@ -0,0 +1,7 @@ +import QtTest 1.0 +import QtQuick 2.6 +import Qt.labs.controls 1.0 +import Qt.labs.controls.material 1.0 +import Qt.labs.controls.universal 1.0 + +Control { } diff --git a/tests/auto/styles/tst_styles.cpp b/tests/auto/styles/tst_styles.cpp index b45366b6..fad28d85 100644 --- a/tests/auto/styles/tst_styles.cpp +++ b/tests/auto/styles/tst_styles.cpp @@ -62,6 +62,8 @@ int main(int argc, char *argv[]) process.start(argv[0], app.arguments().mid(1)); process.waitForFinished(); + if (process.exitStatus() != QProcess::NormalExit) + return -1; failures += process.exitCode(); } diff --git a/tests/auto/universal/qtlabscontrols.conf b/tests/auto/universal/qtquickcontrols.conf index 8c6dd807..8c6dd807 100644 --- a/tests/auto/universal/qtlabscontrols.conf +++ b/tests/auto/universal/qtquickcontrols.conf diff --git a/tests/auto/universal/universal.qrc b/tests/auto/universal/universal.qrc index 1df3aef9..f1398b2f 100644 --- a/tests/auto/universal/universal.qrc +++ b/tests/auto/universal/universal.qrc @@ -1,5 +1,5 @@ <!DOCTYPE RCC><RCC version="1.0"> <qresource> - <file>qtlabscontrols.conf</file> + <file>qtquickcontrols.conf</file> </qresource> </RCC> diff --git a/tests/benchmarks/creationtime/data/dependencies.qml b/tests/benchmarks/creationtime/data/dependencies.qml new file mode 100644 index 00000000..65fb0414 --- /dev/null +++ b/tests/benchmarks/creationtime/data/dependencies.qml @@ -0,0 +1,7 @@ +import QtQuick 2.6 +import Qt.labs.controls 1.0 +import Qt.labs.controls.material 1.0 +import Qt.labs.controls.universal 1.0 +import Qt.labs.calendar 1.0 + +Control { } diff --git a/tests/benchmarks/creationtime/tst_creationtime.cpp b/tests/benchmarks/creationtime/tst_creationtime.cpp index 2a61b0ea..927dd17d 100644 --- a/tests/benchmarks/creationtime/tst_creationtime.cpp +++ b/tests/benchmarks/creationtime/tst_creationtime.cpp @@ -78,15 +78,19 @@ static void addTestRows(QQmlEngine *engine, const QString &targetPath, const QSt // the engine's import path. This way we can use QQmlComponent to load each QML file // for benchmarking. - QFileInfoList entries = QDir(QQC2_IMPORT_PATH + targetPath).entryInfoList(QStringList("*.qml"), QDir::Files); + QFileInfoList entries = QDir(QQC2_IMPORT_PATH "/" + targetPath).entryInfoList(QStringList("*.qml"), QDir::Files); foreach (const QFileInfo &entry, entries) { QString name = entry.baseName(); if (!skiplist.contains(name)) { foreach (const QString &importPath, engine->importPathList()) { - QString filePath = QDir(importPath + "/Qt/labs/" + targetPath).absoluteFilePath(entry.fileName()); + QString name = entry.dir().dirName() + "/" + entry.fileName(); + QString filePath = importPath + "/Qt/labs/" + targetPath + "/" + entry.fileName(); if (QFile::exists(filePath)) { QTest::newRow(qPrintable(name)) << QUrl::fromLocalFile(filePath); break; + } else if (QFile::exists(QQmlFile::urlToLocalFileOrQrc(filePath))) { + QTest::newRow(qPrintable(name)) << QUrl(filePath); + break; } } } @@ -117,7 +121,7 @@ void tst_CreationTime::controls() void tst_CreationTime::controls_data() { QTest::addColumn<QUrl>("url"); - addTestRows(&engine, "/controls"); + addTestRows(&engine, "controls"); } void tst_CreationTime::material() @@ -129,7 +133,7 @@ void tst_CreationTime::material() void tst_CreationTime::material_data() { QTest::addColumn<QUrl>("url"); - addTestRows(&engine, "/controls/material", QStringList() << "Ripple" << "SliderHandle"); + addTestRows(&engine, "controls/material", QStringList() << "Ripple" << "SliderHandle"); } void tst_CreationTime::universal() @@ -141,7 +145,7 @@ void tst_CreationTime::universal() void tst_CreationTime::universal_data() { QTest::addColumn<QUrl>("url"); - addTestRows(&engine, "/controls/universal"); + addTestRows(&engine, "controls/universal"); } void tst_CreationTime::calendar() @@ -153,7 +157,7 @@ void tst_CreationTime::calendar() void tst_CreationTime::calendar_data() { QTest::addColumn<QUrl>("url"); - addTestRows(&engine, "/calendar"); + addTestRows(&engine, "calendar"); } QTEST_MAIN(tst_CreationTime) diff --git a/tests/benchmarks/objectcount/data/dependencies.qml b/tests/benchmarks/objectcount/data/dependencies.qml new file mode 100644 index 00000000..65fb0414 --- /dev/null +++ b/tests/benchmarks/objectcount/data/dependencies.qml @@ -0,0 +1,7 @@ +import QtQuick 2.6 +import Qt.labs.controls 1.0 +import Qt.labs.controls.material 1.0 +import Qt.labs.controls.universal 1.0 +import Qt.labs.calendar 1.0 + +Control { } diff --git a/tests/benchmarks/objectcount/tst_objectcount.cpp b/tests/benchmarks/objectcount/tst_objectcount.cpp index b479b0e2..51a968d0 100644 --- a/tests/benchmarks/objectcount/tst_objectcount.cpp +++ b/tests/benchmarks/objectcount/tst_objectcount.cpp @@ -84,7 +84,7 @@ void tst_ObjectCount::init() // warmup QQmlComponent component(&engine); - component.setData("import QtQuick 2.0; import QtQuick.Controls 1.3 as C1; import Qt.labs.controls 1.0 as C2; Row { C1.Button {} C2.Button {} }", QUrl()); + component.setData("import QtQuick 2.0; import Qt.labs.controls 1.0; Item { Button {} }", QUrl()); delete component.create(); } @@ -118,15 +118,19 @@ static void addTestRows(QQmlEngine *engine, const QString &targetPath, const QSt // the engine's import path. This way we can use QQmlComponent to load each QML file // for benchmarking. - QFileInfoList entries = QDir(QQC2_IMPORT_PATH + targetPath).entryInfoList(QStringList("*.qml"), QDir::Files); + QFileInfoList entries = QDir(QQC2_IMPORT_PATH "/" + targetPath).entryInfoList(QStringList("*.qml"), QDir::Files); foreach (const QFileInfo &entry, entries) { QString name = entry.baseName(); if (!skiplist.contains(name)) { foreach (const QString &importPath, engine->importPathList()) { - QString filePath = QDir(importPath + "/Qt/labs/" + targetPath).absoluteFilePath(entry.fileName()); + QString name = entry.dir().dirName() + "/" + entry.fileName(); + QString filePath = importPath + "/Qt/labs/" + targetPath + "/" + entry.fileName(); if (QFile::exists(filePath)) { QTest::newRow(qPrintable(name)) << QUrl::fromLocalFile(filePath); break; + } else if (QFile::exists(QQmlFile::urlToLocalFileOrQrc(filePath))) { + QTest::newRow(qPrintable(name)) << QUrl(filePath); + break; } } } @@ -161,7 +165,7 @@ void tst_ObjectCount::calendar() void tst_ObjectCount::calendar_data() { QTest::addColumn<QUrl>("url"); - addTestRows(&engine, "/calendar"); + addTestRows(&engine, "calendar"); } void tst_ObjectCount::controls() @@ -173,7 +177,7 @@ void tst_ObjectCount::controls() void tst_ObjectCount::controls_data() { QTest::addColumn<QUrl>("url"); - addTestRows(&engine, "/controls"); + addTestRows(&engine, "controls"); } void tst_ObjectCount::material() @@ -185,7 +189,7 @@ void tst_ObjectCount::material() void tst_ObjectCount::material_data() { QTest::addColumn<QUrl>("url"); - addTestRows(&engine, "/controls/material", QStringList() << "Ripple" << "SliderHandle"); + addTestRows(&engine, "controls/material", QStringList() << "Ripple" << "SliderHandle"); } void tst_ObjectCount::universal() @@ -197,7 +201,7 @@ void tst_ObjectCount::universal() void tst_ObjectCount::universal_data() { QTest::addColumn<QUrl>("url"); - addTestRows(&engine, "/controls/universal"); + addTestRows(&engine, "controls/universal"); } QTEST_MAIN(tst_ObjectCount) diff --git a/tests/manual/gifs/data/qtlabscontrols-busyindicator.qml b/tests/manual/gifs/data/qtquickcontrols-busyindicator.qml index e68af7dd..e68af7dd 100644 --- a/tests/manual/gifs/data/qtlabscontrols-busyindicator.qml +++ b/tests/manual/gifs/data/qtquickcontrols-busyindicator.qml diff --git a/tests/manual/gifs/data/qtlabscontrols-button.qml b/tests/manual/gifs/data/qtquickcontrols-button.qml index 3d9a4f45..3d9a4f45 100644 --- a/tests/manual/gifs/data/qtlabscontrols-button.qml +++ b/tests/manual/gifs/data/qtquickcontrols-button.qml diff --git a/tests/manual/gifs/data/qtlabscontrols-menu.qml b/tests/manual/gifs/data/qtquickcontrols-menu.qml index 81ea3137..81ea3137 100644 --- a/tests/manual/gifs/data/qtlabscontrols-menu.qml +++ b/tests/manual/gifs/data/qtquickcontrols-menu.qml diff --git a/tests/manual/gifs/data/qtlabscontrols-rangeslider.qml b/tests/manual/gifs/data/qtquickcontrols-rangeslider.qml index 55056cf8..55056cf8 100644 --- a/tests/manual/gifs/data/qtlabscontrols-rangeslider.qml +++ b/tests/manual/gifs/data/qtquickcontrols-rangeslider.qml diff --git a/tests/manual/gifs/data/qtlabscontrols-slider.qml b/tests/manual/gifs/data/qtquickcontrols-slider.qml index af582d7c..af582d7c 100644 --- a/tests/manual/gifs/data/qtlabscontrols-slider.qml +++ b/tests/manual/gifs/data/qtquickcontrols-slider.qml diff --git a/tests/manual/gifs/data/qtquickcontrols-swipedelegate-behind.qml b/tests/manual/gifs/data/qtquickcontrols-swipedelegate-behind.qml new file mode 100644 index 00000000..31246a79 --- /dev/null +++ b/tests/manual/gifs/data/qtquickcontrols-swipedelegate-behind.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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.6 +import QtQuick.Window 2.0 +import Qt.labs.controls 1.0 + +Window { + width: swipeDelegate.implicitWidth + height: swipeDelegate.implicitHeight + visible: true + + property alias swipeDelegate: swipeDelegate + + SwipeDelegate { + id: swipeDelegate + text: "SwipeDelegate" + anchors.centerIn: parent + + exposure.left: null + exposure.right: null + exposure.behind: Rectangle { + width: swipeDelegate.width + height: swipeDelegate.height + color: swipeDelegate.pressed ? "#333" : "#444" + + Label { + text: "Behind Action" + color: "#fff" + anchors.centerIn: parent + } + } + } +} diff --git a/tests/manual/gifs/data/qtquickcontrols-swipedelegate-leading-trailing.qml b/tests/manual/gifs/data/qtquickcontrols-swipedelegate-leading-trailing.qml new file mode 100644 index 00000000..d346a377 --- /dev/null +++ b/tests/manual/gifs/data/qtquickcontrols-swipedelegate-leading-trailing.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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.6 +import QtQuick.Window 2.0 +import Qt.labs.controls 1.0 + +Window { + width: swipeDelegate.implicitWidth + height: swipeDelegate.implicitHeight + visible: true + + property alias swipeDelegate: swipeDelegate + + SwipeDelegate { + id: swipeDelegate + text: "SwipeDelegate" + anchors.centerIn: parent + + exposure.left: Rectangle { + width: swipeDelegate.width + height: swipeDelegate.height + color: swipeDelegate.pressed ? "#333" : "#444" + anchors.right: parent.left + + Label { + text: "Left Action" + color: "#fff" + anchors.centerIn: parent + } + } + + exposure.right: Rectangle { + width: swipeDelegate.width + height: swipeDelegate.height + color: swipeDelegate.pressed ? "#333" : "#444" + anchors.left: parent.right + + Label { + text: "Right Action" + color: "#fff" + anchors.centerIn: parent + } + } + } +} diff --git a/tests/manual/gifs/data/qtquickcontrols-swipedelegate.qml b/tests/manual/gifs/data/qtquickcontrols-swipedelegate.qml new file mode 100644 index 00000000..78d36e3b --- /dev/null +++ b/tests/manual/gifs/data/qtquickcontrols-swipedelegate.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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.6 +import QtQuick.Window 2.0 +import Qt.labs.controls 1.0 + +Window { + width: swipeDelegate.implicitWidth + height: swipeDelegate.implicitHeight + visible: true + + property alias swipeDelegate: swipeDelegate + + SwipeDelegate { + id: swipeDelegate + text: "SwipeDelegate" + anchors.centerIn: parent + + exposure.left: Rectangle { + width: swipeDelegate.width + height: swipeDelegate.height + color: swipeDelegate.pressed ? "#333" : "#444" + + Label { + text: "Left Action" + color: "#fff" + anchors.centerIn: parent + } + } + + exposure.right: Rectangle { + anchors.fill: parent + width: swipeDelegate.width + height: swipeDelegate.height + color: swipeDelegate.pressed ? "#333" : "#444" + + Label { + text: "Right Action" + color: "#fff" + anchors.centerIn: parent + } + } + } +} diff --git a/tests/manual/gifs/data/qtlabscontrols-switch.qml b/tests/manual/gifs/data/qtquickcontrols-switch.qml index f6067c1b..f6067c1b 100644 --- a/tests/manual/gifs/data/qtlabscontrols-switch.qml +++ b/tests/manual/gifs/data/qtquickcontrols-switch.qml diff --git a/tests/manual/gifs/data/qtlabscontrols-tabbar.qml b/tests/manual/gifs/data/qtquickcontrols-tabbar.qml index 8ca14721..8ca14721 100644 --- a/tests/manual/gifs/data/qtlabscontrols-tabbar.qml +++ b/tests/manual/gifs/data/qtquickcontrols-tabbar.qml diff --git a/tests/manual/gifs/data/qtlabscontrols-tumbler-wrap.qml b/tests/manual/gifs/data/qtquickcontrols-tumbler-wrap.qml index 4b84c6d1..4b84c6d1 100644 --- a/tests/manual/gifs/data/qtlabscontrols-tumbler-wrap.qml +++ b/tests/manual/gifs/data/qtquickcontrols-tumbler-wrap.qml diff --git a/tests/manual/gifs/eventcapturer.cpp b/tests/manual/gifs/eventcapturer.cpp index 5b5905cd..83e1c76b 100644 --- a/tests/manual/gifs/eventcapturer.cpp +++ b/tests/manual/gifs/eventcapturer.cpp @@ -69,7 +69,7 @@ EventCapturer::EventCapturer(QObject *parent) : QObject(parent), - mEventSource(Q_NULLPTR), + mEventSource(nullptr), mStopCaptureKey(Qt::Key_Escape), mMoveEventTrimFlags(TrimNone), mDuration(0), diff --git a/tests/manual/gifs/eventcapturer.h b/tests/manual/gifs/eventcapturer.h index b1f2b4ff..7982d6e9 100644 --- a/tests/manual/gifs/eventcapturer.h +++ b/tests/manual/gifs/eventcapturer.h @@ -74,7 +74,7 @@ public: QVector<CapturedEvent> capturedEvents() const; protected: - bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE; + bool eventFilter(QObject *object, QEvent *event) override; private slots: void stopCapturing(); diff --git a/tests/manual/gifs/gifrecorder.cpp b/tests/manual/gifs/gifrecorder.cpp index 3ba33552..134ece2e 100644 --- a/tests/manual/gifs/gifrecorder.cpp +++ b/tests/manual/gifs/gifrecorder.cpp @@ -64,8 +64,8 @@ namespace { } GifRecorder::GifRecorder() : - QObject(Q_NULLPTR), - mWindow(Q_NULLPTR), + QObject(nullptr), + mWindow(nullptr), mHighQuality(false), mRecordingDuration(0), mRecordCursor(false), @@ -83,7 +83,7 @@ GifRecorder::GifRecorder() : void GifRecorder::setRecordingDuration(int duration) { QVERIFY2(duration >= 1, qPrintable(QString::fromLatin1("Recording duration %1 must be larger than 1 second").arg(duration))); - QVERIFY2(duration < 10, qPrintable(QString::fromLatin1("Recording duration %1 must be less than 10 seconds").arg(duration))); + QVERIFY2(duration < 20, qPrintable(QString::fromLatin1("Recording duration %1 must be less than 20 seconds").arg(duration))); mRecordingDuration = duration; } diff --git a/tests/manual/gifs/tst_gifs.cpp b/tests/manual/gifs/tst_gifs.cpp index 7f2a985c..ed5d2956 100644 --- a/tests/manual/gifs/tst_gifs.cpp +++ b/tests/manual/gifs/tst_gifs.cpp @@ -57,6 +57,9 @@ private slots: void button(); void tabBar(); void menu(); + void swipeDelegate_data(); + void swipeDelegate(); + void swipeDelegateBehind(); private: void moveSmoothly(QQuickWindow *window, const QPoint &from, const QPoint &to, int movements, @@ -97,7 +100,7 @@ void tst_Gifs::tumblerWrap() gifRecorder.setDataDirPath(dataDirPath); gifRecorder.setOutputDir(outputDir); gifRecorder.setRecordingDuration(4); - gifRecorder.setQmlFileName("qtlabscontrols-tumbler-wrap.qml"); + gifRecorder.setQmlFileName("qtquickcontrols-tumbler-wrap.qml"); gifRecorder.start(); @@ -167,7 +170,7 @@ void tst_Gifs::slider() gifRecorder.setOutputDir(outputDir); gifRecorder.setRecordingDuration(5); gifRecorder.setHighQuality(true); - gifRecorder.setQmlFileName("qtlabscontrols-slider.qml"); + gifRecorder.setQmlFileName("qtquickcontrols-slider.qml"); gifRecorder.start(); @@ -204,7 +207,7 @@ void tst_Gifs::rangeSlider() gifRecorder.setOutputDir(outputDir); gifRecorder.setRecordingDuration(7); gifRecorder.setHighQuality(true); - gifRecorder.setQmlFileName("qtlabscontrols-rangeslider.qml"); + gifRecorder.setQmlFileName("qtquickcontrols-rangeslider.qml"); gifRecorder.start(); @@ -253,7 +256,7 @@ void tst_Gifs::busyIndicator() gifRecorder.setOutputDir(outputDir); gifRecorder.setRecordingDuration(3); gifRecorder.setHighQuality(true); - gifRecorder.setQmlFileName("qtlabscontrols-busyindicator.qml"); + gifRecorder.setQmlFileName("qtquickcontrols-busyindicator.qml"); gifRecorder.start(); @@ -280,7 +283,7 @@ void tst_Gifs::switchGif() gifRecorder.setDataDirPath(dataDirPath); gifRecorder.setOutputDir(outputDir); gifRecorder.setRecordingDuration(3); - gifRecorder.setQmlFileName("qtlabscontrols-switch.qml"); + gifRecorder.setQmlFileName("qtquickcontrols-switch.qml"); gifRecorder.setHighQuality(true); gifRecorder.start(); @@ -298,7 +301,7 @@ void tst_Gifs::button() gifRecorder.setDataDirPath(dataDirPath); gifRecorder.setOutputDir(outputDir); gifRecorder.setRecordingDuration(3); - gifRecorder.setQmlFileName("qtlabscontrols-button.qml"); + gifRecorder.setQmlFileName("qtquickcontrols-button.qml"); gifRecorder.setHighQuality(true); gifRecorder.start(); @@ -312,7 +315,7 @@ void tst_Gifs::button() void tst_Gifs::tabBar() { - const QString qmlFileName = QStringLiteral("qtlabscontrols-tabbar.qml"); + const QString qmlFileName = QStringLiteral("qtquickcontrols-tabbar.qml"); GifRecorder gifRecorder; gifRecorder.setDataDirPath(dataDirPath); @@ -341,7 +344,7 @@ void tst_Gifs::tabBar() void tst_Gifs::menu() { - const QString qmlFileName = QStringLiteral("qtlabscontrols-menu.qml"); + const QString qmlFileName = QStringLiteral("qtquickcontrols-menu.qml"); GifRecorder gifRecorder; gifRecorder.setDataDirPath(dataDirPath); @@ -372,6 +375,97 @@ void tst_Gifs::menu() gifRecorder.waitForFinish(); } +void tst_Gifs::swipeDelegate_data() +{ + QTest::addColumn<QString>("qmlFileName"); + QTest::newRow("qtquickcontrols-swipedelegate.qml") << QString::fromLatin1("qtquickcontrols-swipedelegate.qml"); + QTest::newRow("qtquickcontrols-swipedelegate-leading-trailing.qml") << QString::fromLatin1("qtquickcontrols-swipedelegate-leading-trailing.qml"); +} + +void tst_Gifs::swipeDelegate() +{ + QFETCH(QString, qmlFileName); + + GifRecorder gifRecorder; + gifRecorder.setDataDirPath(dataDirPath); + gifRecorder.setOutputDir(outputDir); + gifRecorder.setRecordingDuration(10); + gifRecorder.setQmlFileName(qmlFileName); + gifRecorder.setHighQuality(true); + + gifRecorder.start(); + + QQuickWindow *window = gifRecorder.window(); + QQuickItem *swipeDelegate = window->property("swipeDelegate").value<QQuickItem*>(); + QVERIFY(swipeDelegate); + + // Show left item. + const QPoint leftTarget = QPoint(swipeDelegate->width() * 0.2, 0); + const QPoint rightTarget = QPoint(swipeDelegate->width() * 0.8, 0); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, leftTarget, 100); + const int movements = rightTarget.x() - leftTarget.x(); + moveSmoothly(window, leftTarget, rightTarget, movements, QEasingCurve::OutQuint, 5); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, rightTarget, 20); + + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, rightTarget, 1000); + moveSmoothly(window, rightTarget, leftTarget, movements, QEasingCurve::OutQuint, 5); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, leftTarget, 20); + + QTest::qWait(1000); + + // Show right item. + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, rightTarget, 1000); + moveSmoothly(window, rightTarget, leftTarget, movements, QEasingCurve::OutQuint, 5); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, leftTarget, 20); + + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, leftTarget, 1000); + moveSmoothly(window, leftTarget, rightTarget, movements, QEasingCurve::OutQuint, 5); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, rightTarget, 20); + + gifRecorder.waitForFinish(); +} + +void tst_Gifs::swipeDelegateBehind() +{ + GifRecorder gifRecorder; + gifRecorder.setDataDirPath(dataDirPath); + gifRecorder.setOutputDir(outputDir); + gifRecorder.setRecordingDuration(14); + gifRecorder.setQmlFileName(QStringLiteral("qtquickcontrols-swipedelegate-behind.qml")); + gifRecorder.setHighQuality(true); + + gifRecorder.start(); + + QQuickWindow *window = gifRecorder.window(); + QQuickItem *swipeDelegate = window->property("swipeDelegate").value<QQuickItem*>(); + QVERIFY(swipeDelegate); + + // Show wrapping around left item. + const QPoint leftTarget = QPoint(swipeDelegate->width() * 0.2, 0); + const QPoint rightTarget = QPoint(swipeDelegate->width() * 0.8, 0); + const int movements = rightTarget.x() - leftTarget.x(); + for (int i = 0; i < 4; ++i) { + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, leftTarget, 100); + moveSmoothly(window, leftTarget, rightTarget, movements, QEasingCurve::OutQuint, 5); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, rightTarget, 20); + + QTest::qWait(500); + } + + QTest::qWait(1000); + + // Show wrapping around right item. + for (int i = 0; i < 4; ++i) { + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, rightTarget, 100); + moveSmoothly(window, rightTarget, leftTarget, movements, QEasingCurve::OutQuint, 5); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, leftTarget, 20); + + QTest::qWait(500); + } + + gifRecorder.waitForFinish(); +} + QTEST_MAIN(tst_Gifs) #include "tst_gifs.moc" diff --git a/tests/manual/viewinqwidget/main.cpp b/tests/manual/viewinqwidget/main.cpp index ff949544..3611e071 100644 --- a/tests/manual/viewinqwidget/main.cpp +++ b/tests/manual/viewinqwidget/main.cpp @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) const QUrl gallerySource(QLatin1String("qrc:/gallery.qml")); QQmlApplicationEngine engine(gallerySource); - QObject *root = engine.rootObjects().value(0, Q_NULLPTR); + QObject *root = engine.rootObjects().value(0, nullptr); if (!root || !root->isWindowType()) { qWarning() << "Load error" << gallerySource; return 1; |