diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-05-10 22:19:00 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-05-10 22:19:00 (GMT) |
commit | 35bc65ecf89ccc14f2e949f2d2881e899f7c4165 (patch) | |
tree | c206594911961655608803ceda0816e45b4a32c2 /tests | |
parent | da8d6c23ceaeb1f266c9c499e98c9fedb1d1e20d (diff) | |
parent | 5280485f2b614c7b0417e37f91b959b689835b42 (diff) | |
download | Qt-35bc65ecf89ccc14f2e949f2d2881e899f7c4165.zip Qt-35bc65ecf89ccc14f2e949f2d2881e899f7c4165.tar.gz Qt-35bc65ecf89ccc14f2e949f2d2881e899f7c4165.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'tests')
15 files changed, 217 insertions, 153 deletions
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index b8e33cf..a9b069c 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -1,7 +1,6 @@ TEMPLATE = subdirs SUBDIRS += \ examples \ - graphicswidgets \ # Cover parserstress \ # Cover qmetaobjectbuilder \ # Cover qdeclarativeanimations \ # Cover @@ -64,6 +63,7 @@ SUBDIRS += \ qdeclarativestyledtext \ # Cover qdeclarativesqldatabase \ # Cover qdeclarativevisualdatamodel \ # Cover + qdeclarativeviewer \ # Cover qmlvisual # Cover contains(QT_CONFIG, webkit) { diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp index 4f10a98..3759cb5 100644 --- a/tests/auto/declarative/examples/tst_examples.cpp +++ b/tests/auto/declarative/examples/tst_examples.cpp @@ -80,16 +80,6 @@ tst_examples::tst_examples() // Add directories you want excluded here - excludedDirs << "examples/declarative/extending"; - excludedDirs << "examples/declarative/tutorials/extending"; - excludedDirs << "examples/declarative/plugins"; - excludedDirs << "examples/declarative/proxywidgets"; - excludedDirs << "examples/declarative/gestures"; - - excludedDirs << "examples/declarative/imageprovider"; - excludedDirs << "examples/declarative/layouts/graphicsLayouts"; - excludedDirs << "demos/declarative/minehunt"; - excludedDirs << "doc/src/snippets/declarative/graphicswidgets"; #ifdef QT_NO_WEBKIT @@ -160,11 +150,14 @@ QStringList tst_examples::findQmlFiles(const QDir &d) QStringList rv; - QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"), - QDir::Files); - foreach (const QString &file, files) { - if (file.at(0).isLower()) { - rv << d.absoluteFilePath(file); + QStringList cppfiles = d.entryList(QStringList() << QLatin1String("*.cpp"), QDir::Files); + if (cppfiles.isEmpty()) { + QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"), + QDir::Files); + foreach (const QString &file, files) { + if (file.at(0).isLower()) { + rv << d.absoluteFilePath(file); + } } } diff --git a/tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml b/tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml deleted file mode 100644 index d6cf4de..0000000 --- a/tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml +++ /dev/null @@ -1,52 +0,0 @@ -import Qt 4.7 -import Qt.widgets 4.7 - -QGraphicsWidget { - geometry: "20,0,600x400" - layout: QGraphicsLinearLayout { - orientation: Qt.Horizontal - QGraphicsWidget { - layout: QGraphicsLinearLayout { - spacing: 10; orientation: Qt.Vertical - LayoutItem { - QGraphicsLinearLayout.stretchFactor: 1 - QGraphicsLinearLayout.spacing: 1 - objectName: "left" - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "100x100" - Rectangle { objectName: "yellowRect"; color: "yellow"; anchors.fill: parent } - } - LayoutItem { - QGraphicsLinearLayout.stretchFactor: 10 - QGraphicsLinearLayout.spacing: 10 - objectName: "left" - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "100x100" - Rectangle { objectName: "yellowRect"; color: "blue"; anchors.fill: parent } - } - } - } - QGraphicsWidget { - layout: QGraphicsLinearLayout { - spacing: 10; orientation: Qt.Horizontal; contentsMargin: 10 - LayoutItem { - objectName: "left" - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "100x100" - Rectangle { objectName: "yellowRect"; color: "red"; anchors.fill: parent } - } - LayoutItem { - objectName: "left" - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "100x100" - Rectangle { objectName: "yellowRect"; color: "green"; anchors.fill: parent } - } - } - } - } -} - diff --git a/tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp b/tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp deleted file mode 100644 index f1a71d5..0000000 --- a/tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include <qtest.h> -#include <QFile> -#include <QtDeclarative/qdeclarativeengine.h> -#include <QtDeclarative/qdeclarativecomponent.h> -#include <QtGui/qgraphicswidget.h> - -class tst_graphicswidgets : public QObject - -{ - Q_OBJECT -public: - tst_graphicswidgets(); - -private slots: - void widgets(); -}; - -tst_graphicswidgets::tst_graphicswidgets() -{ -} - -void tst_graphicswidgets::widgets() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/graphicswidgets.qml")); - QGraphicsWidget *obj = qobject_cast<QGraphicsWidget*>(c.create()); - - QVERIFY(obj != 0); - delete obj; -} - -QTEST_MAIN(tst_graphicswidgets) - -#include "tst_graphicswidgets.moc" diff --git a/tests/auto/declarative/qdeclarativeanchors/data/anchorsqgraphicswidget.qml b/tests/auto/declarative/qdeclarativeanchors/data/anchorsqgraphicswidget.qml index 91973a3..d430c2c 100644 --- a/tests/auto/declarative/qdeclarativeanchors/data/anchorsqgraphicswidget.qml +++ b/tests/auto/declarative/qdeclarativeanchors/data/anchorsqgraphicswidget.qml @@ -1,5 +1,4 @@ import Qt 4.7 -import Qt.widgets 4.7 Rectangle { color: "white" diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml b/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml index 3047e9b..7b132e1 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml @@ -11,7 +11,7 @@ MyQmlObject{ function createTwo() { var component = Qt.createComponent('dynamicCreation.helper.qml'); - obj.objectProperty = component.createObject(); + obj.objectProperty = component.createObject(obj); } function createThree() @@ -22,6 +22,6 @@ MyQmlObject{ function dontCrash() { var component = Qt.createComponent('file-doesnt-exist.qml'); - obj.objectProperty = component.createObject(); + obj.objectProperty = component.createObject(obj); } } diff --git a/tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml b/tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml index 9bb0b37..3b851c1 100644 --- a/tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml +++ b/tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml @@ -1,5 +1,4 @@ import Qt 4.7 -import Qt.widgets 4.6 QGraphicsWidget { size: "250x250" diff --git a/tests/auto/declarative/qdeclarativemousearea/data/rejectEvent.qml b/tests/auto/declarative/qdeclarativemousearea/data/rejectEvent.qml new file mode 100644 index 0000000..c01e938 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemousearea/data/rejectEvent.qml @@ -0,0 +1,28 @@ +import Qt 4.7 + +Rectangle { + id: root + color: "#ffffff" + width: 320; height: 240 + property bool mr1_pressed: false + property bool mr1_released: false + property bool mr1_canceled: false + property bool mr2_pressed: false + property bool mr2_released: false + property bool mr2_canceled: false + + MouseArea { + id: mouseRegion1 + anchors.fill: parent + onPressed: { root.mr1_pressed = true } + onReleased: { root.mr1_released = true } + onCanceled: { root.mr1_canceled = true } + } + MouseArea { + id: mouseRegion2 + width: 120; height: 120 + onPressed: { root.mr2_pressed = true; mouse.accepted = false } + onReleased: { root.mr2_released = true } + onCanceled: { root.mr2_canceled = true } + } +} diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp index eb4aa12..ff3bf45 100644 --- a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp +++ b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp @@ -56,6 +56,8 @@ private slots: void updateMouseAreaPosOnClick(); void updateMouseAreaPosOnResize(); void noOnClickedWithPressAndHold(); + void onMousePressRejected(); + private: QDeclarativeView *createView(); }; @@ -320,7 +322,7 @@ void tst_QDeclarativeMouseArea::noOnClickedWithPressAndHold() QTest::qWait(1000); - QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMousePress); + QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); releaseEvent.setScenePos(QPointF(100, 100)); releaseEvent.setButton(Qt::LeftButton); releaseEvent.setButtons(Qt::LeftButton); @@ -330,6 +332,48 @@ void tst_QDeclarativeMouseArea::noOnClickedWithPressAndHold() QVERIFY(canvas->rootObject()->property("held").toBool()); } +void tst_QDeclarativeMouseArea::onMousePressRejected() +{ + QDeclarativeView *canvas = createView(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/rejectEvent.qml")); + canvas->show(); + canvas->setFocus(); + QVERIFY(canvas->rootObject() != 0); + + QVERIFY(!canvas->rootObject()->property("mr1_pressed").toBool()); + QVERIFY(!canvas->rootObject()->property("mr1_released").toBool()); + QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool()); + QVERIFY(!canvas->rootObject()->property("mr2_pressed").toBool()); + QVERIFY(!canvas->rootObject()->property("mr2_released").toBool()); + QVERIFY(!canvas->rootObject()->property("mr2_canceled").toBool()); + + QGraphicsScene *scene = canvas->scene(); + QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); + pressEvent.setScenePos(QPointF(100, 100)); + pressEvent.setButton(Qt::LeftButton); + pressEvent.setButtons(Qt::LeftButton); + QApplication::sendEvent(scene, &pressEvent); + + QVERIFY(canvas->rootObject()->property("mr1_pressed").toBool()); + QVERIFY(!canvas->rootObject()->property("mr1_released").toBool()); + QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool()); + QVERIFY(canvas->rootObject()->property("mr2_pressed").toBool()); + QVERIFY(!canvas->rootObject()->property("mr2_released").toBool()); + QVERIFY(canvas->rootObject()->property("mr2_canceled").toBool()); + + QTest::qWait(200); + + QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); + releaseEvent.setScenePos(QPointF(100, 100)); + releaseEvent.setButton(Qt::LeftButton); + releaseEvent.setButtons(Qt::LeftButton); + QApplication::sendEvent(scene, &releaseEvent); + + QVERIFY(canvas->rootObject()->property("mr1_released").toBool()); + QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool()); + QVERIFY(!canvas->rootObject()->property("mr2_released").toBool()); +} + QTEST_MAIN(tst_QDeclarativeMouseArea) #include "tst_qdeclarativemousearea.moc" diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 0065ccf..c00390d 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -576,6 +576,14 @@ void tst_qdeclarativetextinput::navigation() simulateKey(canvas, Qt::Key_Left); QVERIFY(input->hasFocus() == true); + // Up and Down should NOT do Home/End, even on Mac OS X (QTBUG-10438). + input->setCursorPosition(2); + QCOMPARE(input->cursorPosition(),2); + simulateKey(canvas, Qt::Key_Up); + QCOMPARE(input->cursorPosition(),2); + simulateKey(canvas, Qt::Key_Down); + QCOMPARE(input->cursorPosition(),2); + delete canvas; } diff --git a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp index 1ed51c1..dd2f46e 100644 --- a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp +++ b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp @@ -147,7 +147,7 @@ void tst_QDeclarativeView::resizemodedeclarativeitem() declarativeItem->setHeight(80); QCOMPARE(canvas->width(), 80); QCOMPARE(canvas->height(), 100); - QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(QSize(declarativeItem->width(), declarativeItem->height()), canvas->sizeHint()); QCOMPARE(sceneResizedSpy2.count(), 2); // size update from view @@ -230,7 +230,7 @@ void tst_QDeclarativeView::resizemodegraphicswidget() canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView); graphicsWidget->resize(QSizeF(60,80)); QCOMPARE(canvas->size(), QSize(80,100)); - QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(QSize(graphicsWidget->size().width(), graphicsWidget->size().height()), canvas->sizeHint()); QCOMPARE(sceneResizedSpy2.count(), 2); // size update from view diff --git a/tests/auto/declarative/qdeclarativeviewer/data/orientation.qml b/tests/auto/declarative/qdeclarativeviewer/data/orientation.qml new file mode 100644 index 0000000..687fac6 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeviewer/data/orientation.qml @@ -0,0 +1,10 @@ +import Qt 4.7 +Rectangle { + color: "black" + width: (runtime.orientation == Orientation.Landscape) ? 300 : 200 + height: (runtime.orientation == Orientation.Landscape) ? 200 : 300 + Text { + text: runtime.orientation == Orientation.Landscape ? "Landscape" : "Portrait" + color: "white" + } +}
\ No newline at end of file diff --git a/tests/auto/declarative/graphicswidgets/graphicswidgets.pro b/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro index b77b430..dc10f5b 100644 --- a/tests/auto/declarative/graphicswidgets/graphicswidgets.pro +++ b/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro @@ -2,9 +2,10 @@ load(qttest_p4) contains(QT_CONFIG,declarative): QT += declarative gui macx:CONFIG -= app_bundle -SOURCES += tst_graphicswidgets.cpp +include(../../../../tools/qml/qml.pri) + +SOURCES += tst_qdeclarativeviewer.cpp -# Define SRCDIR equal to test's source directory DEFINES += SRCDIR=\\\"$$PWD\\\" CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp new file mode 100644 index 0000000..9429dc9 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qtest.h> +#include <QtDeclarative/qdeclarativeengine.h> +#include <QtDeclarative/qdeclarativeview.h> +#include <QtDeclarative/qdeclarativeitem.h> +#include "qmlruntime.h" + +class tst_QDeclarativeViewer : public QObject + +{ + Q_OBJECT +public: + tst_QDeclarativeViewer(); + +private slots: + void orientation(); + +private: + QDeclarativeEngine engine; +}; + +tst_QDeclarativeViewer::tst_QDeclarativeViewer() +{ +} + +void tst_QDeclarativeViewer::orientation() +{ + QWidget window; + QDeclarativeViewer *viewer = new QDeclarativeViewer(&window); + QVERIFY(viewer); + viewer->open(SRCDIR "/data/orientation.qml"); + QVERIFY(viewer->view()); + QVERIFY(viewer->menuBar()); + QDeclarativeItem* rootItem = qobject_cast<QDeclarativeItem*>(viewer->view()->rootObject()); + QVERIFY(rootItem); + window.show(); + + QCOMPARE(rootItem->width(), 200.0); + QCOMPARE(rootItem->height(), 300.0); + QCOMPARE(viewer->view()->size(), QSize(200, 300)); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); + QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); + QCOMPARE(viewer->size(), viewer->sizeHint()); + + viewer->toggleOrientation(); + qApp->processEvents(); + + QCOMPARE(rootItem->width(), 300.0); + QCOMPARE(rootItem->height(), 200.0); + QCOMPARE(viewer->view()->size(), QSize(300, 200)); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(300, 200)); + QCOMPARE(viewer->size(), QSize(300, 200+viewer->menuBar()->height())); + QCOMPARE(viewer->size(), viewer->sizeHint()); + + viewer->toggleOrientation(); + qApp->processEvents(); + + QCOMPARE(rootItem->width(), 200.0); + QCOMPARE(rootItem->height(), 300.0); + QCOMPARE(viewer->view()->size(), QSize(200, 300)); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); + QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); + QCOMPARE(viewer->size(), viewer->sizeHint()); +} + +QTEST_MAIN(tst_QDeclarativeViewer) + +#include "tst_qdeclarativeviewer.moc" diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/mousearea-flickable.qml b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/mousearea-flickable.qml index a0b787f..e223f5e 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/mousearea-flickable.qml +++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/mousearea-flickable.qml @@ -25,7 +25,7 @@ Rectangle { MouseArea { anchors.fill: parent onPressed: blue.color = "lightsteelblue" - onReleased: blue.color = "steelblue" + onCanceled: blue.color = "steelblue" } } Rectangle { @@ -36,7 +36,7 @@ Rectangle { MouseArea { anchors.fill: parent onEntered: { red.color = "darkred"; tooltip.opacity = 1 } - onExited: { red.color = "red"; tooltip.opacity = 0 } + onCanceled: { red.color = "red"; tooltip.opacity = 0 } } Rectangle { id: tooltip |