diff options
Diffstat (limited to 'tests')
12 files changed, 409 insertions, 10 deletions
diff --git a/tests/auto/headersclean/headersclean.pro b/tests/auto/headersclean/headersclean.pro index 6d2f74a6bc..4457fe1c38 100644 --- a/tests/auto/headersclean/headersclean.pro +++ b/tests/auto/headersclean/headersclean.pro @@ -1,4 +1,2 @@ QT = qml quick qmltest qmldevtools load(qt_headersclean) -# shadowing problems in scenegraph, allow it for now -*-g++*: QMAKE_CXXFLAGS -= -Wshadow diff --git a/tests/auto/quick/qquickdynamicpropertyanimation/data/MyItem.qml b/tests/auto/quick/qquickdynamicpropertyanimation/data/MyItem.qml new file mode 100644 index 0000000000..2fc8b90ac8 --- /dev/null +++ b/tests/auto/quick/qquickdynamicpropertyanimation/data/MyItem.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Item +{ + property int testInt: 0 + property double testDouble: 0.0 + property real testReal: 0.0 + property point testPoint: Qt.point(0, 0) + property size testSize: Qt.size(0, 0) + property rect testRect: Qt.rect(0, 0, 0, 0) + property color testColor: Qt.rgba(0.0, 0.0, 0.0, 0.0) + property var testVar: 0 +} diff --git a/tests/auto/quick/qquickdynamicpropertyanimation/qquickdynamicpropertyanimation.pro b/tests/auto/quick/qquickdynamicpropertyanimation/qquickdynamicpropertyanimation.pro new file mode 100644 index 0000000000..a67daa91ba --- /dev/null +++ b/tests/auto/quick/qquickdynamicpropertyanimation/qquickdynamicpropertyanimation.pro @@ -0,0 +1,14 @@ +CONFIG += testcase +TARGET = tst_qquickdynamicpropertyanimation +SOURCES += tst_qquickdynamicpropertyanimation.cpp + +include (../../shared/util.pri) + +macx:CONFIG -= app_bundle + +TESTDATA = data/* + +CONFIG += parallel_test + +QT += core gui qml quick testlib +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquickdynamicpropertyanimation/tst_qquickdynamicpropertyanimation.cpp b/tests/auto/quick/qquickdynamicpropertyanimation/tst_qquickdynamicpropertyanimation.cpp new file mode 100644 index 0000000000..78f2d17e9b --- /dev/null +++ b/tests/auto/quick/qquickdynamicpropertyanimation/tst_qquickdynamicpropertyanimation.cpp @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 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 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <QtTest/QtTest> +#include <QtQml/QQmlEngine> +#include <QtQml/QQmlProperty> +#include <QtQuick/QQuickView> +#include <QtQuick/QQuickItem> +#include <QtCore/QPropertyAnimation> +#include <QtCore/QPoint> +#include <QtCore/QSize> +#include <QtCore/QRect> +#include <QtGui/QColor> + +#include "../../shared/util.h" + +class tst_qquickdynamicpropertyanimation : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qquickdynamicpropertyanimation() {} + +private: + template<class T> + void dynamicPropertyAnimation(const QByteArray & propertyName, T toValue) + { + QQuickView view(testFileUrl("MyItem.qml")); + QQuickItem * item = qobject_cast<QQuickItem *>(view.rootObject()); + QVERIFY(item); + QQmlProperty testProp(item, propertyName); + QPropertyAnimation animation(item, propertyName, this); + animation.setEndValue(toValue); + QVERIFY(animation.targetObject() == item); + QVERIFY(animation.propertyName() == propertyName); + QVERIFY(animation.endValue().value<T>() == toValue); + animation.start(); + QVERIFY(animation.state() == QAbstractAnimation::Running); + QTest::qWait(animation.duration()); + QTRY_COMPARE(testProp.read().value<T>(), toValue); + } + +private slots: + void initTestCase() + { + QQmlEngine engine; // ensure types are registered + QQmlDataTest::initTestCase(); + } + + void dynamicIntPropertyAnimation(); + void dynamicDoublePropertyAnimation(); + void dynamicRealPropertyAnimation(); + void dynamicPointPropertyAnimation(); + void dynamicSizePropertyAnimation(); + void dynamicRectPropertyAnimation(); + void dynamicColorPropertyAnimation(); + void dynamicVarPropertyAnimation(); +}; + +void tst_qquickdynamicpropertyanimation::dynamicIntPropertyAnimation() +{ + dynamicPropertyAnimation("testInt", 1); +} + +void tst_qquickdynamicpropertyanimation::dynamicDoublePropertyAnimation() +{ + dynamicPropertyAnimation("testDouble", 1.0); +} + +void tst_qquickdynamicpropertyanimation::dynamicRealPropertyAnimation() +{ + dynamicPropertyAnimation("testReal", qreal(1.0)); +} + +void tst_qquickdynamicpropertyanimation::dynamicPointPropertyAnimation() +{ + dynamicPropertyAnimation("testPoint", QPoint(1, 1)); +} + +void tst_qquickdynamicpropertyanimation::dynamicSizePropertyAnimation() +{ + dynamicPropertyAnimation("testSize", QSize(1,1)); +} + +void tst_qquickdynamicpropertyanimation::dynamicRectPropertyAnimation() +{ + dynamicPropertyAnimation("testRect", QRect(1, 1, 1, 1)); +} + +void tst_qquickdynamicpropertyanimation::dynamicColorPropertyAnimation() +{ + dynamicPropertyAnimation("testColor", QColor::fromRgbF(1.0, 1.0, 1.0, 1.0)); +} + +void tst_qquickdynamicpropertyanimation::dynamicVarPropertyAnimation() +{ + dynamicPropertyAnimation("testVar", QVariant::fromValue(1)); +} + +QTEST_MAIN(tst_qquickdynamicpropertyanimation) + +#include "tst_qquickdynamicpropertyanimation.moc" diff --git a/tests/auto/quick/qquickflickable/data/nestedStopAtBounds.qml b/tests/auto/quick/qquickflickable/data/nestedStopAtBounds.qml new file mode 100644 index 0000000000..59318e5b95 --- /dev/null +++ b/tests/auto/quick/qquickflickable/data/nestedStopAtBounds.qml @@ -0,0 +1,37 @@ +import QtQuick 2.0 + +Flickable { + id: outer + objectName: "outerFlickable" + width: 400 + height: 400 + contentX: 50 + contentY: 50 + contentWidth: 500 + contentHeight: 500 + flickableDirection: inner.flickableDirection + + Rectangle { + x: 100 + y: 100 + width: 300 + height: 300 + + color: "yellow" + Flickable { + id: inner + objectName: "innerFlickable" + anchors.fill: parent + contentX: 100 + contentY: 100 + contentWidth: 400 + contentHeight: 400 + boundsBehavior: Flickable.StopAtBounds + Rectangle { + anchors.fill: parent + anchors.margins: 100 + color: "blue" + } + } + } +} diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 9645aaaab3..875ade45b8 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -91,6 +91,8 @@ private slots: void cancelOnMouseGrab(); void clickAndDragWhenTransformed(); void flickTwiceUsingTouches(); + void nestedStopAtBounds(); + void nestedStopAtBounds_data(); private: void flickWithTouch(QWindow *window, QTouchDevice *touchDevice); @@ -1308,6 +1310,75 @@ void tst_qquickflickable::flickWithTouch(QWindow *window, QTouchDevice *touchDev QTest::qWait(1); } +void tst_qquickflickable::nestedStopAtBounds_data() +{ + QTest::addColumn<bool>("transpose"); + QTest::addColumn<bool>("invert"); + + QTest::newRow("left") << false << false; + QTest::newRow("right") << false << true; + QTest::newRow("top") << true << false; + QTest::newRow("bottom") << true << true; +} + +void tst_qquickflickable::nestedStopAtBounds() +{ + QFETCH(bool, transpose); + QFETCH(bool, invert); + + QQuickView view; + view.setSource(testFileUrl("nestedStopAtBounds.qml")); + view.show(); + view.requestActivate(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + QVERIFY(view.rootObject()); + + QQuickFlickable *outer = qobject_cast<QQuickFlickable*>(view.rootObject()); + QVERIFY(outer); + + QQuickFlickable *inner = outer->findChild<QQuickFlickable*>("innerFlickable"); + QVERIFY(inner); + inner->setFlickableDirection(transpose ? QQuickFlickable::VerticalFlick : QQuickFlickable::HorizontalFlick); + inner->setContentX(invert ? 0 : 100); + inner->setContentY(invert ? 0 : 100); + + const int threshold = qApp->styleHints()->startDragDistance(); + + QPoint position(200, 200); + int &axis = transpose ? position.ry() : position.rx(); + + // drag toward the aligned boundary. Outer flickable dragged. + QTest::mousePress(&view, Qt::LeftButton, 0, position); + QTest::qWait(10); + axis += invert ? threshold * 2 : -threshold * 2; + QTest::mouseMove(&view, position); + axis += invert ? threshold : -threshold; + QTest::mouseMove(&view, position); + QCOMPARE(outer->isDragging(), true); + QCOMPARE(inner->isDragging(), false); + QTest::mouseRelease(&view, Qt::LeftButton, 0, position); + + QVERIFY(!outer->isDragging()); + QTRY_VERIFY(!outer->isMoving()); + + axis = 200; + outer->setContentX(50); + outer->setContentY(50); + + // drag away from the aligned boundary. Inner flickable dragged. + QTest::mousePress(&view, Qt::LeftButton, 0, position); + QTest::qWait(10); + axis += invert ? -threshold * 2 : threshold * 2; + QTest::mouseMove(&view, position); + axis += invert ? -threshold : threshold; + QTest::mouseMove(&view, position); + QCOMPARE(outer->isDragging(), false); + QCOMPARE(inner->isDragging(), true); + QTest::mouseRelease(&view, Qt::LeftButton, 0, position); + + QTRY_VERIFY(!outer->isMoving()); +} + QTEST_MAIN(tst_qquickflickable) #include "tst_qquickflickable.moc" diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp index 5c0bbb1e21..0c9788ab8e 100644 --- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp @@ -4308,22 +4308,22 @@ void tst_QQuickGridView::snapOneRow_data() QTest::addColumn<qreal>("startExtent"); QTest::newRow("vertical, left to right") << QQuickGridView::FlowLeftToRight << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) - << QPoint(20, 200) << QPoint(20, 20) << 100.0 << 240.0 << 0.0; + << QPoint(20, 160) << QPoint(20, 20) << 100.0 << 240.0 << 0.0; QTest::newRow("horizontal, left to right") << QQuickGridView::FlowTopToBottom << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) - << QPoint(200, 20) << QPoint(20, 20) << 100.0 << 240.0 << 0.0; + << QPoint(160, 20) << QPoint(20, 20) << 100.0 << 240.0 << 0.0; QTest::newRow("horizontal, right to left") << QQuickGridView::FlowTopToBottom << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange) - << QPoint(20, 20) << QPoint(200, 20) << -340.0 << -240.0 - 240.0 << -240.0; + << QPoint(20, 20) << QPoint(160, 20) << -340.0 << -240.0 - 240.0 << -240.0; QTest::newRow("vertical, left to right, enforce range") << QQuickGridView::FlowLeftToRight << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(20, 200) << QPoint(20, 20) << 100.0 << 340.0 << -20.0; + << QPoint(20, 160) << QPoint(20, 20) << 100.0 << 340.0 << -20.0; QTest::newRow("horizontal, left to right, enforce range") << QQuickGridView::FlowTopToBottom << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(200, 20) << QPoint(20, 20) << 100.0 << 340.0 << -20.0; + << QPoint(160, 20) << QPoint(20, 20) << 100.0 << 340.0 << -20.0; QTest::newRow("horizontal, right to left, enforce range") << QQuickGridView::FlowTopToBottom << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(20, 20) << QPoint(200, 20) << -340.0 << -240.0 - 240.0 - 100.0 << -220.0; + << QPoint(20, 20) << QPoint(160, 20) << -340.0 << -240.0 - 240.0 - 100.0 << -220.0; } void tst_QQuickGridView::snapOneRow() diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 9bcf9d6333..65892ddd9b 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -206,6 +206,7 @@ private slots: void destroyItemOnCreation(); void parentBinding(); + void defaultHighlightMoveDuration(); private: template <class T> void items(const QUrl &source, bool forceLayout); @@ -6801,6 +6802,18 @@ void tst_QQuickListView::parentBinding() delete window; } +void tst_QQuickListView::defaultHighlightMoveDuration() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; ListView {}", QUrl::fromLocalFile("")); + + QObject *obj = component.create(); + QVERIFY(obj); + + QCOMPARE(obj->property("highlightMoveDuration").toInt(), -1); +} + QTEST_MAIN(tst_QQuickListView) #include "tst_qquicklistview.moc" diff --git a/tests/auto/quick/qquickmousearea/data/nestedStopAtBounds.qml b/tests/auto/quick/qquickmousearea/data/nestedStopAtBounds.qml new file mode 100644 index 0000000000..1fd39bb321 --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/nestedStopAtBounds.qml @@ -0,0 +1,44 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + + MouseArea { + id: outer + objectName: "outer" + x: 50 + y: 50 + width: 300 + height: 300 + + drag.target: outer + drag.filterChildren: true + + Rectangle { + anchors.fill: parent + color: "yellow" + } + + MouseArea { + id: inner + objectName: "inner" + + x: 0 + y: 0 + width: 200 + height: 200 + + drag.target: inner + drag.minimumX: 0 + drag.maximumX: 100 + drag.minimumY: 0 + drag.maximumY: 100 + + Rectangle { + anchors.fill: parent + color: "blue" + } + } + } +} diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index 37ce0fd394..327abbebd5 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -89,6 +89,8 @@ private slots: void cursorShape(); #endif void moveAndReleaseWithoutPress(); + void nestedStopAtBounds(); + void nestedStopAtBounds_data(); private: void acceptedButton_data(); @@ -803,8 +805,8 @@ void tst_QQuickMouseArea::preventStealing() // Flickable content should have moved. - QCOMPARE(flickable->contentX(), 11.); - QCOMPARE(flickable->contentY(), 11.); + QCOMPARE(flickable->contentX(), 22.); + QCOMPARE(flickable->contentY(), 22.); QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50, 50)); @@ -1426,6 +1428,72 @@ void tst_QQuickMouseArea::moveAndReleaseWithoutPress() delete window; } +void tst_QQuickMouseArea::nestedStopAtBounds_data() +{ + QTest::addColumn<bool>("transpose"); + QTest::addColumn<bool>("invert"); + + QTest::newRow("left") << false << false; + QTest::newRow("right") << false << true; + QTest::newRow("top") << true << false; + QTest::newRow("bottom") << true << true; +} + +void tst_QQuickMouseArea::nestedStopAtBounds() +{ + QFETCH(bool, transpose); + QFETCH(bool, invert); + + QQuickView view; + view.setSource(testFileUrl("nestedStopAtBounds.qml")); + view.show(); + view.requestActivate(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + QVERIFY(view.rootObject()); + + QQuickMouseArea *outer = view.rootObject()->findChild<QQuickMouseArea*>("outer"); + QVERIFY(outer); + + QQuickMouseArea *inner = outer->findChild<QQuickMouseArea*>("inner"); + QVERIFY(inner); + inner->drag()->setAxis(transpose ? QQuickDrag::YAxis : QQuickDrag::XAxis); + inner->setX(invert ? 100 : 0); + inner->setY(invert ? 100 : 0); + + const int threshold = qApp->styleHints()->startDragDistance(); + + QPoint position(200, 200); + int &axis = transpose ? position.ry() : position.rx(); + + // drag toward the aligned boundary. Outer mouse area dragged. + QTest::mousePress(&view, Qt::LeftButton, 0, position); + QTest::qWait(10); + axis += invert ? threshold * 2 : -threshold * 2; + QTest::mouseMove(&view, position); + axis += invert ? threshold : -threshold; + QTest::mouseMove(&view, position); + QCOMPARE(outer->drag()->active(), true); + QCOMPARE(inner->drag()->active(), false); + QTest::mouseRelease(&view, Qt::LeftButton, 0, position); + + QVERIFY(!outer->drag()->active()); + + axis = 200; + outer->setX(50); + outer->setY(50); + + // drag away from the aligned boundary. Inner mouse area dragged. + QTest::mousePress(&view, Qt::LeftButton, 0, position); + QTest::qWait(10); + axis += invert ? -threshold * 2 : threshold * 2; + QTest::mouseMove(&view, position); + axis += invert ? -threshold : threshold; + QTest::mouseMove(&view, position); + QCOMPARE(outer->drag()->active(), false); + QCOMPARE(inner->drag()->active(), true); + QTest::mouseRelease(&view, Qt::LeftButton, 0, position); +} + QTEST_MAIN(tst_QQuickMouseArea) #include "tst_qquickmousearea.moc" diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index 0139e156c3..c29c6c05d6 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -1872,6 +1872,8 @@ void tst_qquicktextedit::mouseSelection() QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, p2); QTRY_COMPARE(textEditObject->selectedText(), selectedText); + QTest::qWait(QGuiApplication::styleHints()->mouseDoubleClickInterval() + 10); + // Clicking and shift to clicking between the same points should select the same text. textEditObject->setCursorPosition(0); if (clicks > 1) diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro index b969927b8f..81d4fd3348 100644 --- a/tests/auto/quick/quick.pro +++ b/tests/auto/quick/quick.pro @@ -35,6 +35,7 @@ QUICKTESTS = \ qquickanchors \ qquickanimatedimage \ qquickanimatedsprite \ + qquickdynamicpropertyanimation \ qquickborderimage \ qquickwindow \ qquickdrag \ |