diff options
Diffstat (limited to 'tests/auto')
340 files changed, 7303 insertions, 11193 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 12ebc75..c0004f7 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -16,7 +16,6 @@ unix:!embedded:contains(QT_CONFIG, dbus): SUBDIRS += dbus.pro contains(QT_CONFIG, script): SUBDIRS += script.pro contains(QT_CONFIG, webkit): SUBDIRS += webkit.pro contains(QT_CONFIG, multimedia): SUBDIRS += multimedia.pro -contains(QT_CONFIG, mediaservices): SUBDIRS += mediaservices.pro contains(QT_CONFIG, phonon): SUBDIRS += phonon.pro contains(QT_CONFIG, svg): SUBDIRS += svg.pro contains(QT_CONFIG, declarative): SUBDIRS += declarative.pro diff --git a/tests/auto/bic/tst_bic.cpp b/tests/auto/bic/tst_bic.cpp index 010965c..400fcc1 100644 --- a/tests/auto/bic/tst_bic.cpp +++ b/tests/auto/bic/tst_bic.cpp @@ -191,7 +191,7 @@ void tst_Bic::sizesAndVTables_data() #elif defined Q_OS_MAC && defined(__i386__) # define FILESUFFIX "macx-gcc-ia32" #elif defined Q_OS_MAC && defined(__amd64__) -# define FILESUFFIX "macx-gcc-amd64"; +# define FILESUFFIX "macx-gcc-amd64" #elif defined Q_OS_WIN && defined Q_CC_GNU # define FILESUFFIX "win32-gcc-ia32" #else diff --git a/tests/auto/compilerwarnings/tst_compilerwarnings.cpp b/tests/auto/compilerwarnings/tst_compilerwarnings.cpp index f910a18..82c327a 100644 --- a/tests/auto/compilerwarnings/tst_compilerwarnings.cpp +++ b/tests/auto/compilerwarnings/tst_compilerwarnings.cpp @@ -62,6 +62,9 @@ class tst_CompilerWarnings: public QObject private slots: void warnings_data(); void warnings(); + +private: + bool shouldIgnoreWarning(QString const&); }; #if 0 @@ -242,16 +245,37 @@ void tst_CompilerWarnings::warnings() if (!errs.isEmpty()) { errList = errs.split("\n"); qDebug() << "Arguments:" << args; - foreach (QString err, errList) { - qDebug() << err; + QStringList validErrors; + foreach (QString const& err, errList) { + bool ignore = shouldIgnoreWarning(err); + qDebug() << err << (ignore ? " [ignored]" : ""); + if (!ignore) { + validErrors << err; + } } + errList = validErrors; } QCOMPARE(errList.count(), 0); // verbose info how many lines of errors in output - QVERIFY(errs.isEmpty()); tmpQSourceFile.remove(); } +bool tst_CompilerWarnings::shouldIgnoreWarning(QString const& warning) +{ + if (warning.isEmpty()) { + return true; + } + + // icecc outputs warnings if some icecc node breaks + if (warning.startsWith("ICECC[")) { + return true; + } + + // Add more bogus warnings here + + return false; +} + QTEST_APPLESS_MAIN(tst_CompilerWarnings) #include "tst_compilerwarnings.moc" diff --git a/tests/auto/dbus.pro b/tests/auto/dbus.pro index 1c808df..e5f87e3 100644 --- a/tests/auto/dbus.pro +++ b/tests/auto/dbus.pro @@ -13,7 +13,6 @@ SUBDIRS=\ qdbuspendingreply \ qdbusperformance \ qdbusreply \ - qdbusserver \ qdbusservicewatcher \ qdbusthreading \ qdbusxmlparser \ diff --git a/tests/auto/declarative/.gitignore b/tests/auto/declarative/.gitignore deleted file mode 100644 index 57608cf..0000000 --- a/tests/auto/declarative/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -tst_* -!tst_*.* -tst_*.log -tst_*.debug -tst_*~ diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 9b3b3d0..4bb3518 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -1,77 +1,80 @@ TEMPLATE = subdirs +!symbian: { SUBDIRS += \ examples \ - graphicswidgets \ # Cover - parserstress \ # Cover - qmetaobjectbuilder \ # Cover - qdeclarativeanimations \ # Cover - qdeclarativebehaviors \ # Cover - qdeclarativebinding \ # Cover - qdeclarativecomponent \ # Cover - qdeclarativeconnection \ # Cover - qdeclarativecontext \ # Cover - qdeclarativedebug \ # Cover - qdeclarativedebugclient \ # Cover - qdeclarativedebugservice \ # Cover - qdeclarativedom \ # Cover - qdeclarativeecmascript \ # Cover - qdeclarativeengine \ # Cover - qdeclarativeerror \ # Cover - qdeclarativefontloader \ # Cover - qdeclarativeanchors \ # Cover - qdeclarativeanimatedimage \ # Cover - qdeclarativeimage \ # Cover - qdeclarativeborderimage \ # Cover - qdeclarativeflickable \ # Cover - qdeclarativeflipable \ # Cover - qdeclarativefocusscope \ # Cover - qdeclarativegridview \ # Cover - qdeclarativeitem \ # Cover - qdeclarativelistview \ # Cover - qdeclarativeloader \ # Cover - qdeclarativelayouts \ # Cover - qdeclarativemousearea \ # Cover - qdeclarativeparticles \ # Cover - qdeclarativepathview \ # Cover - qdeclarativepositioners \ # Cover - qdeclarativetext \ # Cover - qdeclarativetextedit \ # Cover - qdeclarativetextinput \ # Cover - qdeclarativeinfo \ # Cover - qdeclarativeinstruction \ # Cover - qdeclarativelanguage \ # Cover - qdeclarativelistreference \ # Cover - qdeclarativelistmodel \ # Cover - qdeclarativeproperty \ # Cover - qdeclarativemetatype \ # Cover - qdeclarativemoduleplugin \ # Cover - qdeclarativepixmapcache \ # Cover - qdeclarativepropertymap \ # Cover - qdeclarativeqt \ # Cover - qdeclarativesmoothedanimation \ # Cover - qdeclarativesmoothedfollow\ # Cover - qdeclarativespringfollow \ # Cover - qdeclarativestates \ # Cover - qdeclarativesystempalette \ # Cover - qdeclarativetimer \ # Cover - qdeclarativexmllistmodel \ # Cover - qpacketprotocol \ # Cover - qdeclarativerepeater \ # Cover - qdeclarativeworkerscript \ # Cover - qdeclarativevaluetypes \ # Cover - qdeclarativeview \ # Cover - qdeclarativexmlhttprequest \ # Cover - qdeclarativeimageprovider \ # Cover - qdeclarativestyledtext \ # Cover - qdeclarativesqldatabase \ # Cover - qdeclarativevisualdatamodel \ # Cover - qmlvisual # Cover + qdeclarativemetatype \ + qmetaobjectbuilder +} + +SUBDIRS += \ + parserstress \ + qdeclarativeanchors \ + qdeclarativeanimatedimage \ + qdeclarativeanimations \ + qdeclarativebehaviors \ + qdeclarativebinding \ + qdeclarativeborderimage \ + qdeclarativecomponent \ + qdeclarativeconnection \ + qdeclarativecontext \ + qdeclarativedebug \ + qdeclarativedebugclient \ + qdeclarativedebugservice \ + qdeclarativedom \ + qdeclarativeecmascript \ + qdeclarativeengine \ + qdeclarativeerror \ + qdeclarativefontloader \ + qdeclarativeflickable \ + qdeclarativeflipable \ + qdeclarativefocusscope \ + qdeclarativegridview \ + qdeclarativeimage \ + qdeclarativeimageprovider \ + qdeclarativeinfo \ + qdeclarativeinstruction \ + qdeclarativeitem \ + qdeclarativelanguage \ + qdeclarativelayoutitem \ + qdeclarativelistmodel \ + qdeclarativelistreference \ + qdeclarativelistview \ + qdeclarativeloader \ + qdeclarativemoduleplugin \ + qdeclarativemousearea \ + qdeclarativeparticles \ + qdeclarativepathview \ + qdeclarativepixmapcache \ + qdeclarativepositioners \ + qdeclarativeproperty \ + qdeclarativepropertymap \ + qdeclarativeqt \ + qdeclarativerepeater \ + qdeclarativesmoothedanimation \ + qdeclarativesmoothedfollow\ + qdeclarativespringfollow \ + qdeclarativesqldatabase \ + qdeclarativestates \ + qdeclarativestyledtext \ + qdeclarativesystempalette \ + qdeclarativetext \ + qdeclarativetextedit \ + qdeclarativetextinput \ + qdeclarativetimer \ + qdeclarativevaluetypes \ + qdeclarativeview \ + qdeclarativeviewer \ + qdeclarativevisualdatamodel \ + qdeclarativeworkerscript \ + qdeclarativexmlhttprequest \ + qdeclarativexmllistmodel \ + qmlvisual \ + qpacketprotocol contains(QT_CONFIG, webkit) { SUBDIRS += \ - qdeclarativewebview # Cover + qdeclarativewebview } # Tests which should run in Pulse PULSE_TESTS = $$SUBDIRS - diff --git a/tests/auto/declarative/examples/examples.pro b/tests/auto/declarative/examples/examples.pro index 4c32524..92a16f1 100644 --- a/tests/auto/declarative/examples/examples.pro +++ b/tests/auto/declarative/examples/examples.pro @@ -6,7 +6,14 @@ SOURCES += tst_examples.cpp include(../../../../tools/qml/qml.pri) -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp index 16b0cbe..605345e 100644 --- a/tests/auto/declarative/examples/tst_examples.cpp +++ b/tests/auto/declarative/examples/tst_examples.cpp @@ -80,22 +80,14 @@ 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 << "demos/declarative/minehunt"; #ifdef QT_NO_WEBKIT - excludedDirs << "examples/declarative/webview"; + excludedDirs << "examples/declarative/modelviews/webview"; excludedDirs << "demos/declarative/webbrowser"; #endif #ifdef QT_NO_XMLPATTERNS - excludedDirs << "examples/declarative/xmldata"; + excludedDirs << "examples/declarative/xml/xmldata"; excludedDirs << "demos/declarative/twitter"; excludedDirs << "demos/declarative/flickr"; excludedDirs << "demos/declarative/photoviewer"; @@ -157,11 +149,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/graphicswidgets.pro b/tests/auto/declarative/graphicswidgets/graphicswidgets.pro deleted file mode 100644 index b77b430..0000000 --- a/tests/auto/declarative/graphicswidgets/graphicswidgets.pro +++ /dev/null @@ -1,10 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui -macx:CONFIG -= app_bundle - -SOURCES += tst_graphicswidgets.cpp - -# Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test 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/parserstress/parserstress.pro b/tests/auto/declarative/parserstress/parserstress.pro index 8830511..a95a855 100644 --- a/tests/auto/declarative/parserstress/parserstress.pro +++ b/tests/auto/declarative/parserstress/parserstress.pro @@ -4,7 +4,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_parserstress.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = ..\..\qscriptjstestsuite\tests + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/parserstress/tst_parserstress.cpp b/tests/auto/declarative/parserstress/tst_parserstress.cpp index 294f2f7..c86908b 100644 --- a/tests/auto/declarative/parserstress/tst_parserstress.cpp +++ b/tests/auto/declarative/parserstress/tst_parserstress.cpp @@ -86,12 +86,15 @@ QStringList tst_parserstress::findJSFiles(const QDir &d) void tst_parserstress::ecmascript_data() { +#ifdef Q_OS_SYMBIAN + QDir dir("tests"); +#else QDir dir(SRCDIR); dir.cdUp(); dir.cdUp(); dir.cd("qscriptjstestsuite"); dir.cd("tests"); - +#endif QStringList files = findJSFiles(dir); QTest::addColumn<QString>("file"); @@ -129,6 +132,7 @@ void tst_parserstress::ecmascript() QByteArray qmlData = qml.toUtf8(); QDeclarativeComponent component(&engine); + component.setData(qmlData, QUrl::fromLocalFile(SRCDIR + QString("/dummy.qml"))); QFileInfo info(file); 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/qdeclarativeanchors/qdeclarativeanchors.pro b/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro index a2403f2..452ad55 100644 --- a/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro +++ b/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro @@ -3,7 +3,14 @@ contains(QT_CONFIG,declarative): QT += declarative SOURCES += tst_qdeclarativeanchors.cpp macx:CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp index dff62c7..e169fa2 100644 --- a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp +++ b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp @@ -48,6 +48,7 @@ #include <private/qdeclarativerectangle_p.h> #include <private/qdeclarativetext_p.h> #include <QtDeclarative/private/qdeclarativeanchors_p_p.h> +#include <QtDeclarative/private/qdeclarativeitem_p.h> Q_DECLARE_METATYPE(QDeclarativeAnchors::Anchor) Q_DECLARE_METATYPE(QDeclarativeAnchorLine::AnchorLine) @@ -376,15 +377,16 @@ void tst_qdeclarativeanchors::reset() anchor.anchorLine = anchorLine; QDeclarativeItem *item = new QDeclarativeItem; + QDeclarativeItemPrivate *itemPrivate = QDeclarativeItemPrivate::get(item); - const QMetaObject *meta = item->anchors()->metaObject(); + const QMetaObject *meta = itemPrivate->anchors()->metaObject(); QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData())); - QVERIFY(p.write(item->anchors(), qVariantFromValue(anchor))); - QCOMPARE(item->anchors()->usedAnchors().testFlag(usedAnchor), true); + QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor))); + QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), true); - QVERIFY(p.reset(item->anchors())); - QCOMPARE(item->anchors()->usedAnchors().testFlag(usedAnchor), false); + QVERIFY(p.reset(itemPrivate->anchors())); + QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), false); delete item; delete baseItem; @@ -410,18 +412,19 @@ void tst_qdeclarativeanchors::resetConvenience() { QDeclarativeItem *baseItem = new QDeclarativeItem; QDeclarativeItem *item = new QDeclarativeItem; + QDeclarativeItemPrivate *itemPrivate = QDeclarativeItemPrivate::get(item); //fill - item->anchors()->setFill(baseItem); - QVERIFY(item->anchors()->fill() == baseItem); - item->anchors()->resetFill(); - QVERIFY(item->anchors()->fill() == 0); + itemPrivate->anchors()->setFill(baseItem); + QVERIFY(itemPrivate->anchors()->fill() == baseItem); + itemPrivate->anchors()->resetFill(); + QVERIFY(itemPrivate->anchors()->fill() == 0); //centerIn - item->anchors()->setCenterIn(baseItem); - QVERIFY(item->anchors()->centerIn() == baseItem); - item->anchors()->resetCenterIn(); - QVERIFY(item->anchors()->centerIn() == 0); + itemPrivate->anchors()->setCenterIn(baseItem); + QVERIFY(itemPrivate->anchors()->centerIn() == baseItem); + itemPrivate->anchors()->resetCenterIn(); + QVERIFY(itemPrivate->anchors()->centerIn() == 0); delete item; delete baseItem; @@ -433,12 +436,13 @@ void tst_qdeclarativeanchors::nullItem() QDeclarativeAnchorLine anchor; QDeclarativeItem *item = new QDeclarativeItem; + QDeclarativeItemPrivate *itemPrivate = QDeclarativeItemPrivate::get(item); - const QMetaObject *meta = item->anchors()->metaObject(); + const QMetaObject *meta = itemPrivate->anchors()->metaObject(); QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData())); QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML Item: Cannot anchor to a null item."); - QVERIFY(p.write(item->anchors(), qVariantFromValue(anchor))); + QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor))); delete item; } @@ -486,15 +490,16 @@ void tst_qdeclarativeanchors::fill() qApp->processEvents(); QDeclarativeRectangle* rect = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("filler")); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QCOMPARE(rect->x(), 0.0 + 10.0); QCOMPARE(rect->y(), 0.0 + 30.0); QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0); QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0); //Alter Offsets (tests QTBUG-6631) - rect->anchors()->setLeftMargin(20.0); - rect->anchors()->setRightMargin(0.0); - rect->anchors()->setBottomMargin(0.0); - rect->anchors()->setTopMargin(10.0); + rectPrivate->anchors()->setLeftMargin(20.0); + rectPrivate->anchors()->setRightMargin(0.0); + rectPrivate->anchors()->setBottomMargin(0.0); + rectPrivate->anchors()->setTopMargin(10.0); QCOMPARE(rect->x(), 0.0 + 20.0); QCOMPARE(rect->y(), 0.0 + 10.0); QCOMPARE(rect->width(), 200.0 - 20.0); @@ -509,11 +514,12 @@ void tst_qdeclarativeanchors::centerIn() qApp->processEvents(); QDeclarativeRectangle* rect = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("centered")); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QCOMPARE(rect->x(), 75.0 + 10); QCOMPARE(rect->y(), 75.0 + 30); //Alter Offsets (tests QTBUG-6631) - rect->anchors()->setHorizontalCenterOffset(-20.0); - rect->anchors()->setVerticalCenterOffset(-10.0); + rectPrivate->anchors()->setHorizontalCenterOffset(-20.0); + rectPrivate->anchors()->setVerticalCenterOffset(-10.0); QCOMPARE(rect->x(), 75.0 - 20.0); QCOMPARE(rect->y(), 75.0 - 10.0); @@ -526,13 +532,14 @@ void tst_qdeclarativeanchors::margins() qApp->processEvents(); QDeclarativeRectangle* rect = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("filler")); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QCOMPARE(rect->x(), 5.0); QCOMPARE(rect->y(), 6.0); QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0); QCOMPARE(rect->height(), 200.0 - 6.0 - 10.0); - rect->anchors()->setTopMargin(0.0); - rect->anchors()->setMargins(20.0); + rectPrivate->anchors()->setTopMargin(0.0); + rectPrivate->anchors()->setMargins(20.0); QCOMPARE(rect->x(), 5.0); QCOMPARE(rect->y(), 20.0); diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro b/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro index 74f9be0..7213abd 100644 --- a/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro +++ b/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro @@ -4,7 +4,14 @@ HEADERS += ../shared/testhttpserver.h SOURCES += tst_qdeclarativeanimatedimage.cpp ../shared/testhttpserver.cpp macx:CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro b/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro index ce38eeb..f7ed371 100644 --- a/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro +++ b/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro @@ -3,7 +3,14 @@ contains(QT_CONFIG,declarative): QT += declarative SOURCES += tst_qdeclarativeanimations.cpp macx:CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp index e217e34..ed7e506 100644 --- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp +++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp @@ -44,6 +44,7 @@ #include <QtDeclarative/qdeclarativeview.h> #include <private/qdeclarativerectangle_p.h> #include <private/qdeclarativeanimation_p.h> +#include <private/qdeclarativeitem_p.h> #include <QVariantAnimation> #include <QEasingCurve> @@ -324,7 +325,7 @@ void tst_qdeclarativeanimations::badTypes() QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); QVERIFY(rect); - rect->setState("state1"); + QDeclarativeItemPrivate::get(rect)->setState("state1"); QTest::qWait(1000 + 50); QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("MyRect"); QVERIFY(myRect); @@ -366,7 +367,7 @@ void tst_qdeclarativeanimations::mixedTypes() QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); QVERIFY(rect); - rect->setState("state1"); + QDeclarativeItemPrivate::get(rect)->setState("state1"); QTest::qWait(500); QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("MyRect"); QVERIFY(myRect); @@ -382,7 +383,7 @@ void tst_qdeclarativeanimations::mixedTypes() QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); QVERIFY(rect); - rect->setState("state1"); + QDeclarativeItemPrivate::get(rect)->setState("state1"); QTest::qWait(500); QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("MyRect"); QVERIFY(myRect); @@ -468,7 +469,7 @@ void tst_qdeclarativeanimations::propertiesTransition() QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); QVERIFY(rect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect"); QVERIFY(myRect); QTest::qWait(waitDuration); @@ -483,7 +484,7 @@ void tst_qdeclarativeanimations::propertiesTransition() QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect"); QVERIFY(myRect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); QCOMPARE(myRect->x(),qreal(200)); QCOMPARE(myRect->y(),qreal(100)); QTest::qWait(waitDuration); @@ -498,7 +499,7 @@ void tst_qdeclarativeanimations::propertiesTransition() QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect"); QVERIFY(myRect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); QCOMPARE(myRect->x(),qreal(200)); QCOMPARE(myRect->y(),qreal(100)); } @@ -511,7 +512,7 @@ void tst_qdeclarativeanimations::propertiesTransition() QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect"); QVERIFY(myRect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); QCOMPARE(myRect->x(),qreal(100)); QTest::qWait(waitDuration); QTIMED_COMPARE(myRect->x(),qreal(200)); @@ -525,7 +526,7 @@ void tst_qdeclarativeanimations::propertiesTransition() QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect"); QVERIFY(myRect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); QCOMPARE(myRect->x(),qreal(100)); QTest::qWait(waitDuration); QTIMED_COMPARE(myRect->x(),qreal(200)); @@ -539,7 +540,7 @@ void tst_qdeclarativeanimations::propertiesTransition() QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect"); QVERIFY(myRect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); QCOMPARE(myRect->x(),qreal(100)); QTest::qWait(waitDuration); QTIMED_COMPARE(myRect->x(),qreal(100)); @@ -709,7 +710,7 @@ void tst_qdeclarativeanimations::rotation() QDeclarativeRectangle *rr3 = rect->findChild<QDeclarativeRectangle*>("rr3"); QDeclarativeRectangle *rr4 = rect->findChild<QDeclarativeRectangle*>("rr4"); - rect->setState("state1"); + QDeclarativeItemPrivate::get(rect)->setState("state1"); QTest::qWait(800); qreal r1 = rr->rotation(); qreal r2 = rr2->rotation(); diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/startup2.qml b/tests/auto/declarative/qdeclarativebehaviors/data/startup2.qml new file mode 100644 index 0000000..1911cc4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativebehaviors/data/startup2.qml @@ -0,0 +1,16 @@ +import Qt 4.7 + +Rectangle { + width: 800; + height: 480; + + Text { id:theText; text: "hello world" } + + Rectangle { + objectName: "innerRect" + color: "red" + x: theText.width + Behavior on x { NumberAnimation {} } + width: 100; height: 100 + } +} diff --git a/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro b/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro index c2781b8..7137af1 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro +++ b/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro @@ -3,7 +3,14 @@ contains(QT_CONFIG,declarative): QT += declarative SOURCES += tst_qdeclarativebehaviors.cpp macx:CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index ee9e282..1dc4b53 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -43,8 +43,10 @@ #include <QtDeclarative/qdeclarativecomponent.h> #include <QtDeclarative/qdeclarativeview.h> #include <private/qdeclarativerectangle_p.h> +#include <private/qdeclarativetext_p.h> #include <private/qdeclarativebehavior_p.h> #include <private/qdeclarativeanimation_p.h> +#include <private/qdeclarativeitem_p.h> #include "../../../shared/util.h" class tst_qdeclarativebehaviors : public QObject @@ -80,7 +82,7 @@ void tst_qdeclarativebehaviors::simpleBehavior() QTRY_VERIFY(rect); QTRY_VERIFY(qobject_cast<QDeclarativeBehavior*>(rect->findChild<QDeclarativeBehavior*>("MyBehavior"))->animation()); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() > 0); QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() < 200); //i.e. the behavior has been triggered @@ -128,7 +130,7 @@ void tst_qdeclarativebehaviors::loop() QTRY_VERIFY(rect); //don't crash - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); delete rect; } @@ -140,7 +142,7 @@ void tst_qdeclarativebehaviors::colorBehavior() QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); QTRY_VERIFY(rect); - rect->setState("red"); + QDeclarativeItemPrivate::get(rect)->setState("red"); QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->color() != QColor("red")); QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->color() != QColor("green")); //i.e. the behavior has been triggered @@ -155,7 +157,7 @@ void tst_qdeclarativebehaviors::parentBehavior() QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); QTRY_VERIFY(rect); - rect->setState("reparented"); + QDeclarativeItemPrivate::get(rect)->setState("reparented"); QTRY_VERIFY(rect->findChild<QDeclarativeRectangle*>("MyRect")->parentItem() != rect->findChild<QDeclarativeItem*>("NewParent")); QTRY_VERIFY(rect->findChild<QDeclarativeRectangle*>("MyRect")->parentItem() == rect->findChild<QDeclarativeItem*>("NewParent")); @@ -169,7 +171,7 @@ void tst_qdeclarativebehaviors::replaceBinding() QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); QTRY_VERIFY(rect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect")); QTRY_VERIFY(innerRect); QTRY_VERIFY(innerRect->x() > 0); @@ -181,7 +183,7 @@ void tst_qdeclarativebehaviors::replaceBinding() rect->setProperty("movedx", 210); QTRY_COMPARE(innerRect->x(), (qreal)210); - rect->setState(""); + QDeclarativeItemPrivate::get(rect)->setState(""); QTRY_VERIFY(innerRect->x() > 10); QTRY_VERIFY(innerRect->x() < 210); //i.e. the behavior has been triggered QTRY_COMPARE(innerRect->x(), (qreal)10); @@ -201,7 +203,7 @@ void tst_qdeclarativebehaviors::group() QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); QTRY_VERIFY(rect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); //QTest::qWait(200); QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() > 0); QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() < 200); @@ -216,7 +218,7 @@ void tst_qdeclarativebehaviors::group() QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); QTRY_VERIFY(rect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() > 0); QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() < 200); //i.e. the behavior has been triggered @@ -230,11 +232,11 @@ void tst_qdeclarativebehaviors::emptyBehavior() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/empty.qml")); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); - QTRY_VERIFY(rect); + QVERIFY(rect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x(); - QTRY_COMPARE(x, qreal(200)); //should change immediately + QCOMPARE(x, qreal(200)); //should change immediately delete rect; } @@ -244,9 +246,9 @@ void tst_qdeclarativebehaviors::explicitSelection() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/explicit.qml")); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); - QTRY_VERIFY(rect); + QVERIFY(rect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() > 0); QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() < 200); //i.e. the behavior has been triggered @@ -259,11 +261,11 @@ void tst_qdeclarativebehaviors::nonSelectingBehavior() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting2.qml")); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); - QTRY_VERIFY(rect); + QVERIFY(rect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x(); - QTRY_COMPARE(x, qreal(200)); //should change immediately + QCOMPARE(x, qreal(200)); //should change immediately delete rect; } @@ -275,10 +277,9 @@ void tst_qdeclarativebehaviors::reassignedAnimation() QString warning = QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml").toString() + ":9:9: QML Behavior: Cannot change the animation assigned to a Behavior."; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); - QTRY_VERIFY(rect); - QTRY_COMPARE(qobject_cast<QDeclarativeNumberAnimation*>( - qobject_cast<QDeclarativeBehavior*>( - rect->findChild<QDeclarativeBehavior*>("MyBehavior"))->animation())->duration(), 200); + QVERIFY(rect); + QCOMPARE(qobject_cast<QDeclarativeNumberAnimation*>( + rect->findChild<QDeclarativeBehavior*>("MyBehavior")->animation())->duration(), 200); delete rect; } @@ -288,12 +289,12 @@ void tst_qdeclarativebehaviors::disabled() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/disabled.qml")); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); - QTRY_VERIFY(rect); - QTRY_COMPARE(rect->findChild<QDeclarativeBehavior*>("MyBehavior")->enabled(), false); + QVERIFY(rect); + QCOMPARE(rect->findChild<QDeclarativeBehavior*>("MyBehavior")->enabled(), false); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x(); - QTRY_COMPARE(x, qreal(200)); //should change immediately + QCOMPARE(x, qreal(200)); //should change immediately delete rect; } @@ -307,28 +308,47 @@ void tst_qdeclarativebehaviors::dontStart() QString warning = c.url().toString() + ":13:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes."; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); - QTRY_VERIFY(rect); + QVERIFY(rect); QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim"); - QTRY_VERIFY(myAnim && myAnim->qtAnimation()); - QTRY_VERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); + QVERIFY(myAnim && myAnim->qtAnimation()); + QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); delete rect; } void tst_qdeclarativebehaviors::startup() { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/startup.qml")); - QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); - QTRY_VERIFY(rect); + { + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/startup.qml")); + QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); + QVERIFY(rect); - QDeclarativeRectangle *innerRect = rect->findChild<QDeclarativeRectangle*>("innerRect"); - QTRY_VERIFY(innerRect); + QDeclarativeRectangle *innerRect = rect->findChild<QDeclarativeRectangle*>("innerRect"); + QVERIFY(innerRect); - QTRY_COMPARE(innerRect->x(), qreal(100)); //should be set immediately + QCOMPARE(innerRect->x(), qreal(100)); //should be set immediately - delete rect; + delete rect; + } + + { + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/startup2.qml")); + QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); + QVERIFY(rect); + + QDeclarativeRectangle *innerRect = rect->findChild<QDeclarativeRectangle*>("innerRect"); + QVERIFY(innerRect); + + QDeclarativeText *text = rect->findChild<QDeclarativeText*>(); + QVERIFY(text); + + QCOMPARE(innerRect->x(), text->width()); //should be set immediately + + delete rect; + } } QTEST_MAIN(tst_qdeclarativebehaviors) diff --git a/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro b/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro index 04dd6f5..04535db 100644 --- a/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro +++ b/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro @@ -5,7 +5,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativebinding.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro b/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro index e754923..3aa2197 100644 --- a/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro +++ b/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro @@ -6,7 +6,14 @@ HEADERS += ../shared/testhttpserver.h SOURCES += tst_qdeclarativeborderimage.cpp ../shared/testhttpserver.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro b/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro index e58c798..98c38ad 100644 --- a/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro +++ b/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro @@ -5,7 +5,11 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativecomponent.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml new file mode 100644 index 0000000..764d5ab --- /dev/null +++ b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml @@ -0,0 +1,8 @@ +import Qt 4.7 + +Item { + id: screen + + Connections { target: screen; onNotFooBar1: {} ignoreUnknownSignals: true } + Connections { objectName: "connections"; onNotFooBar2: {} ignoreUnknownSignals: true } +} diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml new file mode 100644 index 0000000..09e7812 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml @@ -0,0 +1,7 @@ +import Qt 4.7 + +Item { + id: screen + + Connections { objectName: "connections"; target: null; onNotFooBar: {} } +} diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-parent.qml b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-parent.qml new file mode 100644 index 0000000..478503d --- /dev/null +++ b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-parent.qml @@ -0,0 +1,7 @@ +import Qt 4.7 + +Item { + id: screen + + Connections { objectName: "connections"; onFooBar: {} } +} diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals.qml b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals.qml new file mode 100644 index 0000000..d4e8d7e --- /dev/null +++ b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals.qml @@ -0,0 +1,7 @@ +import Qt 4.7 + +Item { + id: screen + + Connections { objectName: "connections"; target: screen; onFooBar: {} } +} diff --git a/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro b/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro index 959354d..bbf8630 100644 --- a/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro +++ b/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro @@ -5,7 +5,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeconnection.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp index 0efae3b..00e97ca 100644 --- a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp +++ b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp @@ -59,6 +59,8 @@ private slots: void connection(); void trimming(); void targetChanged(); + void unknownSignals_data(); + void unknownSignals(); private: QDeclarativeEngine engine; @@ -156,6 +158,41 @@ void tst_qdeclarativeconnection::targetChanged() delete item; } +void tst_qdeclarativeconnection::unknownSignals_data() +{ + QTest::addColumn<QString>("file"); + QTest::addColumn<QString>("error"); + + QTest::newRow("basic") << "connection-unknownsignals.qml" << ":6:5: QML Connections: Cannot assign to non-existent property \"onFooBar\""; + QTest::newRow("parent") << "connection-unknownsignals-parent.qml" << ":6:5: QML Connections: Cannot assign to non-existent property \"onFooBar\""; + QTest::newRow("ignored") << "connection-unknownsignals-ignored.qml" << ""; // should be NO error + QTest::newRow("notarget") << "connection-unknownsignals-notarget.qml" << ""; // should be NO error +} + +void tst_qdeclarativeconnection::unknownSignals() +{ + QFETCH(QString, file); + QFETCH(QString, error); + + QUrl url = QUrl::fromLocalFile(SRCDIR "/data/" + file); + if (!error.isEmpty()) { + QTest::ignoreMessage(QtWarningMsg, (url.toString() + error).toLatin1()); + } else { + // QTest has no way to insist no message (i.e. fail) + } + + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, url); + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(c.create()); + QVERIFY(item != 0); + + // check that connection is created (they are all runtime errors) + QDeclarativeConnections *connections = item->findChild<QDeclarativeConnections*>("connections"); + QVERIFY(connections); + + delete item; +} + QTEST_MAIN(tst_qdeclarativeconnection) #include "tst_qdeclarativeconnection.moc" diff --git a/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro b/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro index 5db9a9e..0e1a5b1 100644 --- a/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro +++ b/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro @@ -3,7 +3,11 @@ contains(QT_CONFIG,declarative): QT += declarative SOURCES += tst_qdeclarativecontext.cpp macx:CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp index 851460f..7f0e6c0 100644 --- a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp +++ b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp @@ -398,7 +398,7 @@ void tst_qdeclarativecontext::destruction() QObject obj; QDeclarativeEngine::setContextForObject(&obj, ctxt); - QDeclarativeExpression expr(ctxt, "a", 0); + QDeclarativeExpression expr(ctxt, 0, "a"); QCOMPARE(ctxt, QDeclarativeEngine::contextForObject(&obj)); QCOMPARE(ctxt, expr.context()); diff --git a/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro b/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro index 466c563..9f1e50c 100644 --- a/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro +++ b/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro @@ -4,7 +4,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativedom.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp index a951827..6c19566 100644 --- a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp +++ b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp @@ -419,10 +419,8 @@ void tst_qdeclarativedom::loadSyntaxErrors() void tst_qdeclarativedom::loadRemoteErrors() { QByteArray qml = "import Qt 4.7\n" + "import \"http://localhost/exampleQmlScript.js\" as Script\n" "Item {\n" - " Script {\n" - " source: \"http://localhost/exampleQmlScript.js\"" - " }\n" "}"; QDeclarativeDomDocument document; QVERIFY(false == document.load(&engine, qml)); diff --git a/tests/auto/qmediaplaylist/tmp.unsupported_format b/tests/auto/declarative/qdeclarativeecmascript/data/blank.js index e69de29..e69de29 100644 --- a/tests/auto/qmediaplaylist/tmp.unsupported_format +++ b/tests/auto/declarative/qdeclarativeecmascript/data/blank.js diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml index 72b59ae..2337e44 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml @@ -19,7 +19,7 @@ QtObject { myObject.deleteOnSet = 1; - test3 = myObject.value == undefined; - test4 = obj.value == undefined; + test3 = myObject == null + test4 = obj == null } } 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/qdeclarativeecmascript/data/eval.qml b/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml new file mode 100644 index 0000000..bc2df98 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml @@ -0,0 +1,23 @@ +import Qt 4.7 + +QtObject { + property bool test1: false; + property bool test2: false; + property bool test3: false; + property bool test4: false; + property bool test5: false; + + + property int a: 7 + property int b: 8 + + Component.onCompleted: { + var b = 9; + + test1 = (eval("a") == 7); + test2 = (eval("b") == 9); + test3 = (eval("c") == undefined); + test4 = (eval("console") == console); + test5 = (eval("Qt") == Qt); + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/exception.js b/tests/auto/declarative/qdeclarativeecmascript/data/exception.js new file mode 100644 index 0000000..160bbfa --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/exception.js @@ -0,0 +1 @@ +throw("Whoops!"); diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/function.qml b/tests/auto/declarative/qdeclarativeecmascript/data/function.qml new file mode 100644 index 0000000..b435f58 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/function.qml @@ -0,0 +1,19 @@ +import Qt 4.7 + +QtObject { + property bool test1: false; + property bool test2: false; + property bool test3: false; + + Component.onCompleted: { + var a = 10; + + var func1 = new Function("a", "return a + 7"); + var func2 = new Function("a", "return Qt.atob(a)"); + var func3 = new Function("return a"); + + test1 = (func1(4) == 11); + test2 = (func2("Hello World!") == Qt.atob("Hello World!")); + test3 = (func3() == undefined); + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.1.qml new file mode 100644 index 0000000..09540f1 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.1.qml @@ -0,0 +1,5 @@ +import Qt.test 1.0 + +MyQmlObject { + property variant a: function myFunction() { return 2; } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.2.qml new file mode 100644 index 0000000..948b39c --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.2.qml @@ -0,0 +1,13 @@ +import Qt.test 1.0 + +MyQmlObject { + property variant a + property bool runTest: false + onRunTestChanged: { + function myFunction() { + console.log("hello world"); + } + a = myFunction; + } + +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include.js b/tests/auto/declarative/qdeclarativeecmascript/data/include.js new file mode 100644 index 0000000..232fd80 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include.js @@ -0,0 +1,8 @@ +var test1 = true +var test2 = false +var test3 = false + +function go() { + Qt.include("js/include2.js"); +} + diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include.qml new file mode 100644 index 0000000..18543b2 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include.qml @@ -0,0 +1,23 @@ +import Qt 4.7 +import "include.js" as IncludeTest + +QtObject { + property int test0: 0 + property bool test1: false + property bool test2: false + property bool test2_1: false + property bool test3: false + property bool test3_1: false + + property int testValue: 99 + + Component.onCompleted: { + IncludeTest.go(); + test0 = IncludeTest.value + test1 = IncludeTest.test1 + test2 = IncludeTest.test2 + test2_1 = IncludeTest.test2_1 + test3 = IncludeTest.test3 + test3_1 = IncludeTest.test3_1 + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.js b/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.js new file mode 100644 index 0000000..ea19eba --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.js @@ -0,0 +1,11 @@ +function go() { + var a = Qt.include("missing.js", function(o) { test2 = o.status == o.NETWORK_ERROR }); + test1 = a.status == a.NETWORK_ERROR + + var b = Qt.include("blank.js", function(o) { test4 = o.status == o.OK }); + test3 = b.status == b.OK + + var c = Qt.include("exception.js", function(o) { test6 = o.status == o.EXCEPTION }); + test5 = c.status == c.EXCEPTION +} + diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.qml new file mode 100644 index 0000000..a39e821 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.qml @@ -0,0 +1,15 @@ +import Qt 4.7 +import "include_callback.js" as IncludeTest + +QtObject { + property bool test1: false + property bool test2: false + property bool test3: false + property bool test4: false + property bool test5: false + property bool test6: false + + Component.onCompleted: { + IncludeTest.go(); + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma.qml new file mode 100644 index 0000000..67b8cfd --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma.qml @@ -0,0 +1,11 @@ +import Qt 4.7 +import "include_pragma_outer.js" as Script + +Item { + property int test1 + + Component.onCompleted: { + test1 = Script.callFunction() + } +} + diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_inner.js b/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_inner.js new file mode 100644 index 0000000..a0380a2 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_inner.js @@ -0,0 +1,5 @@ +.pragma library + +function getValue() { + return 100; +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_outer.js b/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_outer.js new file mode 100644 index 0000000..d87bafc --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_outer.js @@ -0,0 +1,6 @@ +Qt.include("include_pragma_inner.js") + +function callFunction() { + return getValue(); +} + diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.js b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.js new file mode 100644 index 0000000..e6a4676 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.js @@ -0,0 +1,26 @@ +var myvar = 10; + +function go() +{ + var a = Qt.include("http://127.0.0.1:8111/remote_file.js", + function(o) { + test2 = o.status == o.OK + test3 = a.status == a.OK + test4 = myvar == 13 + + done = true; + }); + test1 = a.status == a.LOADING + + + var b = Qt.include("http://127.0.0.1:8111/exception.js", + function(o) { + test7 = o.status == o.EXCEPTION + test8 = b.status == a.EXCEPTION + test9 = b.exception.toString() == "Whoops!"; + test10 = o.exception.toString() == "Whoops!"; + + done2 = true; + }); + test6 = b.status == b.LOADING +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.qml new file mode 100644 index 0000000..06bd174 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.qml @@ -0,0 +1,21 @@ +import Qt 4.7 +import "include_remote.js" as IncludeTest + +QtObject { + property bool done: false + property bool done2: false + + property bool test1: false + property bool test2: false + property bool test3: false + property bool test4: false + property bool test5: false + + property bool test6: false + property bool test7: false + property bool test8: false + property bool test9: false + property bool test10: false + + Component.onCompleted: IncludeTest.go(); +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.js b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.js new file mode 100644 index 0000000..cc90860 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.js @@ -0,0 +1,13 @@ +function go() +{ + var a = Qt.include("http://127.0.0.1:8111/missing.js", + function(o) { + test2 = o.status == o.NETWORK_ERROR + test3 = a.status == a.NETWORK_ERROR + + done = true; + }); + + test1 = a.status == a.LOADING +} + diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.qml new file mode 100644 index 0000000..8e486b2 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.qml @@ -0,0 +1,12 @@ +import Qt 4.7 +import "include_remote_missing.js" as IncludeTest + +QtObject { + property bool done: false + + property bool test1: false + property bool test2: false + property bool test3: false + + Component.onCompleted: IncludeTest.go(); +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.js b/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.js new file mode 100644 index 0000000..a49c07b --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.js @@ -0,0 +1,12 @@ +.pragma library + +var test1 = true +var test2 = false +var test3 = false + +var testValue = 99; + +function go() { + Qt.include("js/include2.js"); +} + diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.qml new file mode 100644 index 0000000..e957018 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.qml @@ -0,0 +1,22 @@ +import Qt 4.7 +import "include_shared.js" as IncludeTest + +QtObject { + property int test0: 0 + property bool test1: false + property bool test2: false + property bool test2_1: false + property bool test3: false + property bool test3_1: false + + Component.onCompleted: { + IncludeTest.go(); + test0 = IncludeTest.value + test1 = IncludeTest.test1 + test2 = IncludeTest.test2 + test2_1 = IncludeTest.test2_1 + test3 = IncludeTest.test3 + test3_1 = IncludeTest.test3_1 + } +} + diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/js/include2.js b/tests/auto/declarative/qdeclarativeecmascript/data/js/include2.js new file mode 100644 index 0000000..2a0c039 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/js/include2.js @@ -0,0 +1,4 @@ +test2 = true +var test2_1 = true + +Qt.include("include3.js"); diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/js/include3.js b/tests/auto/declarative/qdeclarativeecmascript/data/js/include3.js new file mode 100644 index 0000000..84b2770 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/js/include3.js @@ -0,0 +1,3 @@ +test3 = true +var test3_1 = true +var value = testValue diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_10696.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_10696.qml new file mode 100644 index 0000000..cb5c4c9 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_10696.qml @@ -0,0 +1,26 @@ +import Qt 4.7 + +QtObject { + property string test: "aaaa" + + "bbbb" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc"; +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtcreatorbug_1289.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qtcreatorbug_1289.qml new file mode 100644 index 0000000..b6d31d5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/qtcreatorbug_1289.qml @@ -0,0 +1,13 @@ +import Qt 4.7 + +QtObject { + id: root + property QtObject object: QtObject { + id: nested + property QtObject nestedObject + } + + Component.onCompleted: { + nested.nestedObject = root; + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/remote_file.js b/tests/auto/declarative/qdeclarativeecmascript/data/remote_file.js new file mode 100644 index 0000000..1b123ae --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/remote_file.js @@ -0,0 +1,2 @@ +myvar = 13; +test5 = true; diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.2.qml new file mode 100644 index 0000000..a36b4c0 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.2.qml @@ -0,0 +1,14 @@ +import Qt 4.7 + +QtObject { + id: root + + property variant a: 10 + property int x: 10 + property int test: a.x + + Component.onCompleted: { + a = 11; + a = root; + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro b/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro index eabed26..c907be5 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro +++ b/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro @@ -1,13 +1,18 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative script +contains(QT_CONFIG,declarative): QT += declarative script network macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeecmascript.cpp \ - testtypes.cpp -HEADERS += testtypes.h + testtypes.cpp \ + ../shared/testhttpserver.cpp +HEADERS += testtypes.h \ + ../shared/testhttpserver.h +INCLUDEPATH += ../shared # QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage # LIBS += -lgcov +DEFINES += SRCDIR=\\\"$$PWD\\\" + CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h index 1381d57..7bb8a8e 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h @@ -190,7 +190,7 @@ class MyExpression : public QDeclarativeExpression Q_OBJECT public: MyExpression(QDeclarativeContext *ctxt, const QString &expr) - : QDeclarativeExpression(ctxt, expr, 0), changed(false) + : QDeclarativeExpression(ctxt, 0, expr), changed(false) { QObject::connect(this, SIGNAL(valueChanged()), this, SLOT(expressionValueChanged())); setNotifyOnValueChanged(true); diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 491a736..4900fa2 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -51,6 +51,7 @@ #include <private/qdeclarativeengine_p.h> #include <private/qdeclarativeglobalscriptclass_p.h> #include "testtypes.h" +#include "testhttpserver.h" /* This test covers evaluation of ECMAScript expressions and bindings from within @@ -142,8 +143,15 @@ private slots: void libraryScriptAssert(); void variantsAssignedUndefined(); void qtbug_9792(); + void qtcreatorbug_1289(); void noSpuriousWarningsAtShutdown(); void canAssignNullToQObject(); + void functionAssignment(); + void eval(); + void function(); + void qtbug_10696(); + + void include(); void callQtInvokables(); private: @@ -1100,7 +1108,7 @@ void tst_qdeclarativeecmascript::exceptionClearsOnReeval() QDeclarativeComponent component(&engine, TEST_FILE("exceptionClearsOnReeval.qml")); QString url = component.url().toString(); - QString warning = url + ":4: TypeError: Result of expression 'objectProperty.objectProperty' [undefined] is not an object."; + QString warning = url + ":4: TypeError: Result of expression 'objectProperty' [null] is not an object."; QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create()); @@ -1149,6 +1157,7 @@ static void transientErrorsMsgHandler(QtMsgType, const char *) // Check that transient binding errors are not displayed void tst_qdeclarativeecmascript::transientErrors() { + { QDeclarativeComponent component(&engine, TEST_FILE("transientErrors.qml")); transientErrorsMsgCount = 0; @@ -1160,6 +1169,22 @@ void tst_qdeclarativeecmascript::transientErrors() qInstallMsgHandler(old); QCOMPARE(transientErrorsMsgCount, 0); + } + + // One binding erroring multiple times, but then resolving + { + QDeclarativeComponent component(&engine, TEST_FILE("transientErrors.2.qml")); + + transientErrorsMsgCount = 0; + QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler); + + QObject *object = component.create(); + QVERIFY(object != 0); + + qInstallMsgHandler(old); + + QCOMPARE(transientErrorsMsgCount, 0); + } } // Check that errors during shutdown are minimized @@ -2058,10 +2083,9 @@ void tst_qdeclarativeecmascript::compiled() QCOMPARE(object->property("test15").toBool(), false); QCOMPARE(object->property("test16").toBool(), true); - QCOMPARE(object->property("test17").toInt(), 4); + QCOMPARE(object->property("test17").toInt(), 5); QCOMPARE(object->property("test18").toReal(), qreal(176)); - QEXPECT_FAIL("", "QTBUG-9538", Continue); - QCOMPARE(object->property("test19").toInt(), 6); + QCOMPARE(object->property("test19").toInt(), 7); QCOMPARE(object->property("test20").toReal(), qreal(6.7)); QCOMPARE(object->property("test21").toString(), QLatin1String("6.7")); QCOMPARE(object->property("test22").toString(), QLatin1String("!")); @@ -2078,20 +2102,21 @@ void tst_qdeclarativeecmascript::numberAssignment() QObject *object = component.create(); QVERIFY(object != 0); - QVERIFY(object->property("test1") == QVariant((qreal)6.7)); - QVERIFY(object->property("test2") == QVariant((qreal)6.7)); - QVERIFY(object->property("test3") == QVariant((qreal)6)); - QVERIFY(object->property("test4") == QVariant((qreal)6)); + QCOMPARE(object->property("test1"), QVariant((qreal)6.7)); + QCOMPARE(object->property("test2"), QVariant((qreal)6.7)); + QCOMPARE(object->property("test2"), QVariant((qreal)6.7)); + QCOMPARE(object->property("test3"), QVariant((qreal)6)); + QCOMPARE(object->property("test4"), QVariant((qreal)6)); - QVERIFY(object->property("test5") == QVariant((int)7)); - QVERIFY(object->property("test6") == QVariant((int)7)); - QVERIFY(object->property("test7") == QVariant((int)6)); - QVERIFY(object->property("test8") == QVariant((int)6)); + QCOMPARE(object->property("test5"), QVariant((int)7)); + QCOMPARE(object->property("test6"), QVariant((int)7)); + QCOMPARE(object->property("test7"), QVariant((int)6)); + QCOMPARE(object->property("test8"), QVariant((int)6)); - QVERIFY(object->property("test9") == QVariant((unsigned int)7)); - QVERIFY(object->property("test10") == QVariant((unsigned int)7)); - QVERIFY(object->property("test11") == QVariant((unsigned int)6)); - QVERIFY(object->property("test12") == QVariant((unsigned int)6)); + QCOMPARE(object->property("test9"), QVariant((unsigned int)7)); + QCOMPARE(object->property("test10"), QVariant((unsigned int)7)); + QCOMPARE(object->property("test11"), QVariant((unsigned int)6)); + QCOMPARE(object->property("test12"), QVariant((unsigned int)6)); delete object; } @@ -2188,6 +2213,27 @@ void tst_qdeclarativeecmascript::qtbug_9792() delete object; } +// Verifies that QDeclarativeGuard<>s used in the vmemetaobject are cleaned correctly +void tst_qdeclarativeecmascript::qtcreatorbug_1289() +{ + QDeclarativeComponent component(&engine, TEST_FILE("qtcreatorbug_1289.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + QObject *nested = qvariant_cast<QObject *>(o->property("object")); + QVERIFY(nested != 0); + + QVERIFY(qvariant_cast<QObject *>(nested->property("nestedObject")) == o); + + delete nested; + nested = qvariant_cast<QObject *>(o->property("object")); + QVERIFY(nested == 0); + + // If the bug is present, the next line will crash + delete o; +} + // Test that we shut down without stupid warnings void tst_qdeclarativeecmascript::noSpuriousWarningsAtShutdown() { @@ -2252,6 +2298,199 @@ void tst_qdeclarativeecmascript::canAssignNullToQObject() } } +void tst_qdeclarativeecmascript::functionAssignment() +{ + { + QDeclarativeComponent component(&engine, TEST_FILE("functionAssignment.1.qml")); + + QString url = component.url().toString(); + QString warning = url + ":4: Unable to assign a function to a property."; + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); + + MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create()); + QVERIFY(o != 0); + + QVERIFY(!o->property("a").isValid()); + + delete o; + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("functionAssignment.2.qml")); + + MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create()); + QVERIFY(o != 0); + + QVERIFY(!o->property("a").isValid()); + + QString url = component.url().toString(); + QString warning = url + ":10: Error: Cannot assign a function to a property."; + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); + + o->setProperty("runTest", true); + + QVERIFY(!o->property("a").isValid()); + + delete o; + } +} + +void tst_qdeclarativeecmascript::eval() +{ + QDeclarativeComponent component(&engine, TEST_FILE("eval.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + QCOMPARE(o->property("test4").toBool(), true); + QCOMPARE(o->property("test5").toBool(), true); + + delete o; +} + +void tst_qdeclarativeecmascript::function() +{ + QDeclarativeComponent component(&engine, TEST_FILE("function.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + + delete o; +} + +#define TRY_WAIT(expr) \ + do { \ + for (int ii = 0; ii < 6; ++ii) { \ + if ((expr)) break; \ + QTest::qWait(50); \ + } \ + QVERIFY((expr)); \ + } while (false) + +// Test the "Qt.include" method +void tst_qdeclarativeecmascript::include() +{ + // Non-library relative include + { + QDeclarativeComponent component(&engine, TEST_FILE("include.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test0").toInt(), 99); + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test2_1").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + QCOMPARE(o->property("test3_1").toBool(), true); + + delete o; + } + + // Library relative include + { + QDeclarativeComponent component(&engine, TEST_FILE("include_shared.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test0").toInt(), 99); + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test2_1").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + QCOMPARE(o->property("test3_1").toBool(), true); + + delete o; + } + + // Callback + { + QDeclarativeComponent component(&engine, TEST_FILE("include_callback.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + QCOMPARE(o->property("test4").toBool(), true); + QCOMPARE(o->property("test5").toBool(), true); + QCOMPARE(o->property("test6").toBool(), true); + + delete o; + } + + // Including file with ".pragma library" + { + QDeclarativeComponent component(&engine, TEST_FILE("include_pragma.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test1").toInt(), 100); + + delete o; + } + + // Remote - success + { + TestHTTPServer server(8111); + QVERIFY(server.isValid()); + server.serveDirectory(SRCDIR "/data"); + + QDeclarativeComponent component(&engine, TEST_FILE("include_remote.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + TRY_WAIT(o->property("done").toBool() == true); + TRY_WAIT(o->property("done2").toBool() == true); + + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + QCOMPARE(o->property("test4").toBool(), true); + QCOMPARE(o->property("test5").toBool(), true); + + QCOMPARE(o->property("test6").toBool(), true); + QCOMPARE(o->property("test7").toBool(), true); + QCOMPARE(o->property("test8").toBool(), true); + QCOMPARE(o->property("test9").toBool(), true); + QCOMPARE(o->property("test10").toBool(), true); + + delete o; + } + + // Remote - error + { + TestHTTPServer server(8111); + QVERIFY(server.isValid()); + server.serveDirectory(SRCDIR "/data"); + + QDeclarativeComponent component(&engine, TEST_FILE("include_remote_missing.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + TRY_WAIT(o->property("done").toBool() == true); + + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + + delete o; + } +} + +void tst_qdeclarativeecmascript::qtbug_10696() +{ + QDeclarativeComponent component(&engine, TEST_FILE("qtbug_10696.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + delete o; +} + QTEST_MAIN(tst_qdeclarativeecmascript) #include "tst_qdeclarativeecmascript.moc" diff --git a/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro b/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro index e0ea2e5..23afd07 100644 --- a/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro +++ b/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro @@ -5,7 +5,11 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeengine.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro b/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro index 501f32c..fae11f9 100644 --- a/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro +++ b/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro @@ -3,7 +3,11 @@ contains(QT_CONFIG,declarative): QT += declarative SOURCES += tst_qdeclarativeerror.cpp macx:CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro b/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro index 07637c9..7a70109 100644 --- a/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro +++ b/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro @@ -5,7 +5,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeflickable.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp index 9ce9c49..2c6890e 100644 --- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp +++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp @@ -61,6 +61,7 @@ private slots: void maximumFlickVelocity(); void flickDeceleration(); void pressDelay(); + void flickableDirection(); private: QDeclarativeEngine engine; @@ -224,6 +225,33 @@ void tst_qdeclarativeflickable::pressDelay() QCOMPARE(spy.count(),1); } +void tst_qdeclarativeflickable::flickableDirection() +{ + QDeclarativeComponent component(&engine); + component.setData("import Qt 4.7; Flickable { flickableDirection: Flickable.VerticalFlick; }", QUrl::fromLocalFile("")); + QDeclarativeFlickable *flickable = qobject_cast<QDeclarativeFlickable*>(component.create()); + QSignalSpy spy(flickable, SIGNAL(flickableDirectionChanged())); + + QVERIFY(flickable); + QCOMPARE(flickable->flickableDirection(), QDeclarativeFlickable::VerticalFlick); + + flickable->setFlickableDirection(QDeclarativeFlickable::HorizontalAndVerticalFlick); + QCOMPARE(flickable->flickableDirection(), QDeclarativeFlickable::HorizontalAndVerticalFlick); + QCOMPARE(spy.count(),1); + + flickable->setFlickableDirection(QDeclarativeFlickable::AutoFlickDirection); + QCOMPARE(flickable->flickableDirection(), QDeclarativeFlickable::AutoFlickDirection); + QCOMPARE(spy.count(),2); + + flickable->setFlickableDirection(QDeclarativeFlickable::HorizontalFlick); + QCOMPARE(flickable->flickableDirection(), QDeclarativeFlickable::HorizontalFlick); + QCOMPARE(spy.count(),3); + + flickable->setFlickableDirection(QDeclarativeFlickable::HorizontalFlick); + QCOMPARE(flickable->flickableDirection(), QDeclarativeFlickable::HorizontalFlick); + QCOMPARE(spy.count(),3); +} + QTEST_MAIN(tst_qdeclarativeflickable) #include "tst_qdeclarativeflickable.moc" diff --git a/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro b/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro index 9830b55..9b4fbc9 100644 --- a/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro +++ b/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro @@ -5,7 +5,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeflipable.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro b/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro index 687c80c..c021fcf 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro +++ b/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro @@ -3,5 +3,12 @@ contains(QT_CONFIG,declarative): QT += declarative SOURCES += tst_qdeclarativefocusscope.cpp macx:CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/data/basic.qml b/tests/auto/declarative/qdeclarativefolderlistmodel/data/basic.qml new file mode 100644 index 0000000..2c4977d --- /dev/null +++ b/tests/auto/declarative/qdeclarativefolderlistmodel/data/basic.qml @@ -0,0 +1,5 @@ +import Qt.labs.folderlistmodel 1.0 + +FolderListModel { + nameFilters: [ "*.qml" ] +} diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/data/dummy.qml b/tests/auto/declarative/qdeclarativefolderlistmodel/data/dummy.qml new file mode 100644 index 0000000..609638b --- /dev/null +++ b/tests/auto/declarative/qdeclarativefolderlistmodel/data/dummy.qml @@ -0,0 +1 @@ +// This file is not used, it is just content for QDirModel diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro b/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro new file mode 100644 index 0000000..487d0e1 --- /dev/null +++ b/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro @@ -0,0 +1,17 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativefolderlistmodel.cpp + +# Define SRCDIR equal to test's source directory +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp b/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp new file mode 100644 index 0000000..8a8bfe7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** 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 <QtTest/QSignalSpy> +#include "../../../shared/util.h" +#include <QtDeclarative/qdeclarativeengine.h> +#include <QtDeclarative/qdeclarativecomponent.h> +#include <QtCore/qdir.h> +#include <QtCore/qfile.h> +#include <QtCore/qabstractitemmodel.h> +#include <QDebug> + +// From qdeclarastivefolderlistmodel.h +const int FileNameRole = Qt::UserRole+1; +const int FilePathRole = Qt::UserRole+2; +enum SortField { Unsorted, Name, Time, Size, Type }; + +class tst_qdeclarativefolderlistmodel : public QObject +{ + Q_OBJECT +public: + tst_qdeclarativefolderlistmodel() {} + +private slots: + void basicProperties(); + +private: + void checkNoErrors(const QDeclarativeComponent& component); + QDeclarativeEngine engine; +}; + +void tst_qdeclarativefolderlistmodel::checkNoErrors(const QDeclarativeComponent& component) +{ + // Wait until the component is ready + QTRY_VERIFY(component.isReady() || component.isError()); + + if (component.isError()) { + QList<QDeclarativeError> errors = component.errors(); + for (int ii = 0; ii < errors.count(); ++ii) { + const QDeclarativeError &error = errors.at(ii); + QByteArray errorStr = QByteArray::number(error.line()) + ":" + + QByteArray::number(error.column()) + ":" + + error.description().toUtf8(); + qWarning() << errorStr; + } + } + QVERIFY(!component.isError()); +} + +void tst_qdeclarativefolderlistmodel::basicProperties() +{ + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/basic.qml")); + checkNoErrors(component); + + QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create()); + QVERIFY(flm != 0); + + + flm->setProperty("folder",QUrl::fromLocalFile(SRCDIR "/data")); + QTRY_COMPARE(flm->property("count").toInt(),2); // wait for refresh + QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile(SRCDIR "/data")); + QCOMPARE(flm->property("parentFolder").toUrl(), QUrl::fromLocalFile(SRCDIR)); + QCOMPARE(flm->property("sortField").toInt(), int(Name)); + QCOMPARE(flm->property("nameFilters").toStringList(), QStringList() << "*.qml"); + QCOMPARE(flm->property("sortReversed").toBool(), false); + QCOMPARE(flm->property("showDirs").toBool(), true); + QCOMPARE(flm->property("showDotAndDotDot").toBool(), false); + QCOMPARE(flm->property("showOnlyReadable").toBool(), false); + QCOMPARE(flm->data(flm->index(0),FileNameRole).toString(), QLatin1String("basic.qml")); + QCOMPARE(flm->data(flm->index(1),FileNameRole).toString(), QLatin1String("dummy.qml")); +} + +QTEST_MAIN(tst_qdeclarativefolderlistmodel) + +#include "tst_qdeclarativefolderlistmodel.moc" diff --git a/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro b/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro index 9a8a3ff..dbe0dcb 100644 --- a/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro +++ b/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro @@ -6,7 +6,14 @@ HEADERS += ../shared/testhttpserver.h SOURCES += tst_qdeclarativefontloader.cpp ../shared/testhttpserver.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativegridview/data/manual-highlight.qml b/tests/auto/declarative/qdeclarativegridview/data/manual-highlight.qml new file mode 100644 index 0000000..510fcc5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativegridview/data/manual-highlight.qml @@ -0,0 +1,48 @@ +import Qt 4.7 + +Item { + + ListModel { + id: model + ListElement { + name: "Bill Smith" + number: "555 3264" + } + ListElement { + name: "John Brown" + number: "555 8426" + } + ListElement { + name: "Sam Wise" + number: "555 0473" + } + ListElement { + name: "Bob Brown" + number: "555 5845" + } + } + + Component { + id: highlight + Rectangle { + objectName: "highlight" + width: 80; height: 80 + color: "lightsteelblue"; radius: 5 + y: grid.currentItem.y + x: grid.currentItem.x + } + } + + GridView { + id: grid + objectName: "grid" + anchors.fill: parent + model: model + delegate: Text { objectName: "wrapper"; text: name; width: 80; height: 80 } + + highlight: highlight + highlightFollowsCurrentItem: false + focus: true + } + +} diff --git a/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro b/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro index b069260..033e20e 100644 --- a/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro +++ b/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro @@ -5,7 +5,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativegridview.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index 89be151..2db3ee6 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -75,6 +75,7 @@ private slots: void resetModel(); void enforceRange(); void QTBUG_8456(); + void manualHighlight(); private: QDeclarativeView *createView(); @@ -1107,6 +1108,35 @@ void tst_QDeclarativeGridView::QTBUG_8456() QTRY_COMPARE(gridview->currentIndex(), 0); } +void tst_QDeclarativeGridView::manualHighlight() +{ + QDeclarativeView *canvas = createView(); + + QString filename(SRCDIR "/data/manual-highlight.qml"); + canvas->setSource(QUrl::fromLocalFile(filename)); + + qApp->processEvents(); + + QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + + QDeclarativeItem *viewport = gridview->viewport(); + QTRY_VERIFY(viewport != 0); + + QTRY_COMPARE(gridview->currentIndex(), 0); + QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 0)); + QTRY_COMPARE(gridview->highlightItem()->y(), gridview->currentItem()->y()); + QTRY_COMPARE(gridview->highlightItem()->x(), gridview->currentItem()->x()); + + gridview->setCurrentIndex(2); + + QTRY_COMPARE(gridview->currentIndex(), 2); + QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 2)); + QTRY_COMPARE(gridview->highlightItem()->y(), gridview->currentItem()->y()); + QTRY_COMPARE(gridview->highlightItem()->x(), gridview->currentItem()->x()); +} + + QDeclarativeView *tst_QDeclarativeGridView::createView() { QDeclarativeView *canvas = new QDeclarativeView(0); diff --git a/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro b/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro index ff365ee..a8b8eca 100644 --- a/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro +++ b/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro @@ -6,7 +6,14 @@ HEADERS += ../shared/testhttpserver.h SOURCES += tst_qdeclarativeimage.cpp ../shared/testhttpserver.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index e0143a6..720702a 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -400,7 +400,7 @@ T *tst_qdeclarativeimage::findItem(QGraphicsObject *parent, const QString &objec //qDebug() << "try" << item; if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { if (index != -1) { - QDeclarativeExpression e(qmlContext(item), "index", item); + QDeclarativeExpression e(qmlContext(item), item, "index"); if (e.evaluate().toInt() == index) return static_cast<T*>(item); } else { diff --git a/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro b/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro index 22be991..1b828a5 100644 --- a/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro +++ b/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro @@ -9,7 +9,14 @@ SOURCES += tst_qdeclarativeimageprovider.cpp # LIBS += -lgcov # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro b/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro index bb54d6c..c6719c0 100644 --- a/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro +++ b/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro @@ -4,7 +4,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeinfo.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro b/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro index 0daa9e5..350f6c6 100644 --- a/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro +++ b/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro @@ -3,7 +3,11 @@ contains(QT_CONFIG,declarative): QT += declarative script SOURCES += tst_qdeclarativeinstruction.cpp macx:CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp index 9ae26f2..1e88255 100644 --- a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp +++ b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp @@ -534,7 +534,6 @@ void tst_qdeclarativeinstruction::dump() << "-------------------------------------------------------------------------------" << "0\t\t0\tINIT\t\t\t0\t3\t-1\t-1" << "1\t\t1\tCREATE\t\t\t0\t\t\t\"Test\"" - << "1\t\t1\tCREATE_SIMPLE\t\t-1" << "2\t\t2\tSETID\t\t\t0\t\t\t\"testId\"" << "3\t\t3\tSET_DEFAULT" << "4\t\t4\tCREATE_COMPONENT\t3" diff --git a/tests/auto/declarative/qdeclarativeitem/data/childrenRect.qml b/tests/auto/declarative/qdeclarativeitem/data/childrenRect.qml new file mode 100644 index 0000000..f351b53 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeitem/data/childrenRect.qml @@ -0,0 +1,27 @@ +import Qt 4.7 + +Rectangle { + width: 400 + height: 400 + + property int childCount: 0; + + Item { + objectName: "testItem" + width: childrenRect.width + height: childrenRect.height + + Repeater { + id: repeater + model: childCount + delegate: Rectangle { + x: index*10 + y: index*20 + width: 10 + height: 20 + + color: "red" + } + } + } +} diff --git a/tests/auto/declarative/qdeclarativeitem/data/keyspriority.qml b/tests/auto/declarative/qdeclarativeitem/data/keyspriority.qml new file mode 100644 index 0000000..171536b --- /dev/null +++ b/tests/auto/declarative/qdeclarativeitem/data/keyspriority.qml @@ -0,0 +1,9 @@ +import Qt 4.7 +import Test 1.0 + +KeyTestItem { + focus: true + Keys.onPressed: keysTestObject.keyPress(event.key, event.text, event.modifiers) + Keys.onReleased: { keysTestObject.keyRelease(event.key, event.text, event.modifiers); event.accepted = true; } + Keys.priority: keysTestObject.processLast ? Keys.AfterItem : Keys.BeforeItem +} diff --git a/tests/auto/declarative/qdeclarativeitem/data/mouseFocus.qml b/tests/auto/declarative/qdeclarativeitem/data/mouseFocus.qml new file mode 100644 index 0000000..a562b8b --- /dev/null +++ b/tests/auto/declarative/qdeclarativeitem/data/mouseFocus.qml @@ -0,0 +1,20 @@ +import Qt 4.7 + +QGraphicsWidget { + size: "200x100" + focusPolicy: QGraphicsWidget.ClickFocus + Item { + objectName: "declarativeItem" + id: item + width: 200 + height: 100 + MouseArea { + anchors.fill: parent + onPressed: { + if (!item.focus) { + item.focus = true; + } + } + } + } +} diff --git a/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro b/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro index e834a4e..f494ef1 100644 --- a/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro +++ b/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro @@ -4,7 +4,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeitem.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index d2c328e..ecc813e 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -45,6 +45,7 @@ #include <QtDeclarative/qdeclarativecontext.h> #include <QtDeclarative/qdeclarativeview.h> #include <QtDeclarative/qdeclarativeitem.h> +#include "../../../shared/util.h" class tst_QDeclarativeItem : public QObject @@ -54,7 +55,9 @@ public: tst_QDeclarativeItem(); private slots: + void initTestCase(); void keys(); + void keysProcessingOrder(); void keyNavigation(); void smooth(); void clip(); @@ -63,9 +66,11 @@ private slots: void propertyChanges(); void transforms(); void transforms_data(); + void childrenRect(); void childrenProperty(); void resourcesProperty(); + void mouseFocus(); private: template<typename T> @@ -76,8 +81,11 @@ private: class KeysTestObject : public QObject { Q_OBJECT + + Q_PROPERTY(bool processLast READ processLast NOTIFY processLastChanged) + public: - KeysTestObject() : mKey(0), mModifiers(0), mForwardedKey(0) {} + KeysTestObject() : mKey(0), mModifiers(0), mForwardedKey(0), mLast(false) {} void reset() { mKey = 0; @@ -86,6 +94,14 @@ public: mForwardedKey = 0; } + bool processLast() const { return mLast; } + void setProcessLast(bool b) { + if (b != mLast) { + mLast = b; + emit processLastChanged(); + } + } + public slots: void keyPress(int key, QString text, int modifiers) { mKey = key; @@ -101,20 +117,73 @@ public slots: mForwardedKey = key; } +signals: + void processLastChanged(); + public: int mKey; QString mText; int mModifiers; int mForwardedKey; + bool mLast; private: }; +class KeyTestItem : public QDeclarativeItem +{ + Q_OBJECT +public: + KeyTestItem(QDeclarativeItem *parent=0) : QDeclarativeItem(parent), mKey(0) {} + +protected: + void keyPressEvent(QKeyEvent *e) { + keyPressPreHandler(e); + if (e->isAccepted()) + return; + + mKey = e->key(); + + if (e->key() == Qt::Key_A) + e->accept(); + else + e->ignore(); + + if (!e->isAccepted()) + QDeclarativeItem::keyPressEvent(e); + } + + void keyReleaseEvent(QKeyEvent *e) { + keyReleasePreHandler(e); + + if (e->isAccepted()) + return; + + if (e->key() == Qt::Key_B) + e->accept(); + else + e->ignore(); + + if (!e->isAccepted()) + QDeclarativeItem::keyReleaseEvent(e); + } + +public: + int mKey; +}; + +QML_DECLARE_TYPE(KeyTestItem); + tst_QDeclarativeItem::tst_QDeclarativeItem() { } +void tst_QDeclarativeItem::initTestCase() +{ + qmlRegisterType<KeyTestItem>("Test",1,0,"KeyTestItem"); +} + void tst_QDeclarativeItem::keys() { QDeclarativeView *canvas = new QDeclarativeView(0); @@ -211,6 +280,69 @@ void tst_QDeclarativeItem::keys() QCOMPARE(testObject->mKey, 0); QVERIFY(!key.isAccepted()); + canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true)); + + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1); + QApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_Return)); + QVERIFY(key.isAccepted()); + + delete canvas; + delete testObject; +} + +void tst_QDeclarativeItem::keysProcessingOrder() +{ + QDeclarativeView *canvas = new QDeclarativeView(0); + canvas->setFixedSize(240,320); + + KeysTestObject *testObject = new KeysTestObject; + canvas->rootContext()->setContextProperty("keysTestObject", testObject); + + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keyspriority.qml")); + canvas->show(); + qApp->processEvents(); + + KeyTestItem *testItem = qobject_cast<KeyTestItem*>(canvas->rootObject()); + QVERIFY(testItem); + + QEvent wa(QEvent::WindowActivate); + QApplication::sendEvent(canvas, &wa); + QFocusEvent fe(QEvent::FocusIn); + QApplication::sendEvent(canvas, &fe); + + QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); + QApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_A)); + QCOMPARE(testObject->mText, QLatin1String("A")); + QVERIFY(testObject->mModifiers == Qt::NoModifier); + QVERIFY(key.isAccepted()); + + testObject->reset(); + + testObject->setProcessLast(true); + + key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); + QApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, 0); + QVERIFY(key.isAccepted()); + + testObject->reset(); + + key = QKeyEvent(QEvent::KeyPress, Qt::Key_B, Qt::NoModifier, "B", false, 1); + QApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_B)); + QCOMPARE(testObject->mText, QLatin1String("B")); + QVERIFY(testObject->mModifiers == Qt::NoModifier); + QVERIFY(!key.isAccepted()); + + testObject->reset(); + + key = QKeyEvent(QEvent::KeyRelease, Qt::Key_B, Qt::NoModifier, "B", false, 1); + QApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, 0); + QVERIFY(key.isAccepted()); + delete canvas; delete testObject; } @@ -465,6 +597,41 @@ void tst_QDeclarativeItem::resourcesProperty() delete o; } +void tst_QDeclarativeItem::mouseFocus() +{ + QDeclarativeView *canvas = new QDeclarativeView(0); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/mouseFocus.qml")); + canvas->show(); + QVERIFY(canvas->rootObject()); + QApplication::setActiveWindow(canvas); + QTest::qWaitForWindowShown(canvas); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas)); + + QDeclarativeItem *item = findItem<QDeclarativeItem>(canvas->rootObject(), "declarativeItem"); + QVERIFY(item); + QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool))); + + QTest::mouseClick(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(item->scenePos())); + QApplication::processEvents(); + QCOMPARE(focusSpy.count(), 1); + QVERIFY(item->hasFocus()); + + // make sure focusable graphics widget underneath does not steal focus + QTest::mouseClick(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(item->scenePos())); + QApplication::processEvents(); + QCOMPARE(focusSpy.count(), 1); + QVERIFY(item->hasFocus()); + + item->setFocus(false); + QVERIFY(!item->hasFocus()); + QCOMPARE(focusSpy.count(), 2); + item->setFocus(true); + QCOMPARE(focusSpy.count(), 3); + + delete canvas; +} + void tst_QDeclarativeItem::propertyChanges() { QDeclarativeView *canvas = new QDeclarativeView(0); @@ -537,6 +704,33 @@ void tst_QDeclarativeItem::propertyChanges() delete canvas; } +void tst_QDeclarativeItem::childrenRect() +{ + QDeclarativeView *canvas = new QDeclarativeView(0); + canvas->setFixedSize(240,320); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/childrenRect.qml")); + canvas->show(); + + QGraphicsObject *o = canvas->rootObject(); + QDeclarativeItem *item = o->findChild<QDeclarativeItem*>("testItem"); + QCOMPARE(item->width(), qreal(0)); + QCOMPARE(item->height(), qreal(0)); + + o->setProperty("childCount", 1); + QCOMPARE(item->width(), qreal(10)); + QCOMPARE(item->height(), qreal(20)); + + o->setProperty("childCount", 5); + QCOMPARE(item->width(), qreal(50)); + QCOMPARE(item->height(), qreal(100)); + + o->setProperty("childCount", 0); + QCOMPARE(item->width(), qreal(0)); + QCOMPARE(item->height(), qreal(0)); + + delete o; +} + template<typename T> T *tst_QDeclarativeItem::findItem(QGraphicsObject *parent, const QString &objectName) { diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml index 5af3d6e..bac704e 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml @@ -10,5 +10,7 @@ QtObject { property variant test7: "10x10" property variant test8: "100,100,100" property variant test9: String("#FF008800") + property variant test10: true + property variant test11: false } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.errors.txt new file mode 100644 index 0000000..eb1430a --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.errors.txt @@ -0,0 +1 @@ +4:5:Cannot assign a value to a signal (expecting a script to be run) diff --git a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.qml index c84fea3..6fa1259 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.qml @@ -1,7 +1,6 @@ import Test 1.0 MyQmlObject { - onBasicSignal { - } + onBasicSignal: "hello world" } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.2.qml new file mode 100644 index 0000000..df3de20 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.2.qml @@ -0,0 +1,11 @@ +import Qt 4.7 +import Qt 4.7 as Qt47 + +Qt.QtObject { + property Qt47.QtObject objectProperty + property list<Qt47.QtObject> objectPropertyList + + objectProperty: QtObject {} + objectPropertyList: QtObject {} +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.2.errors.txt deleted file mode 100644 index 8b20434..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.2.errors.txt +++ /dev/null @@ -1 +0,0 @@ -4:5:Incorrectly specified signal assignment diff --git a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt index 353bbf5..8b20434 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt @@ -1 +1 @@ -4:5:Empty signal assignment +4:5:Incorrectly specified signal assignment diff --git a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml index 4c5a122..c84fea3 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml @@ -1,6 +1,7 @@ import Test 1.0 MyQmlObject { - onBasicSignal: " " + onBasicSignal { + } } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString2.qml b/tests/auto/declarative/qdeclarativelanguage/data/scriptString2.qml new file mode 100644 index 0000000..c42da2b --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/scriptString2.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + scriptProperty: "hello\n\"world\"" +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString3.qml b/tests/auto/declarative/qdeclarativelanguage/data/scriptString3.qml new file mode 100644 index 0000000..0cd82ff --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/scriptString3.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + scriptProperty: 12.345 +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString4.qml b/tests/auto/declarative/qdeclarativelanguage/data/scriptString4.qml new file mode 100644 index 0000000..3e2f9a4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/scriptString4.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + scriptProperty: true +} diff --git a/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro b/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro index 5771469..2b7eb1c 100644 --- a/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro +++ b/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro @@ -11,6 +11,13 @@ INCLUDEPATH += ../shared/ HEADERS += ../shared/testhttpserver.h SOURCES += ../shared/testhttpserver.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\"\"\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h index 89f99c8..acbe219 100644 --- a/tests/auto/declarative/qdeclarativelanguage/testtypes.h +++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.h @@ -99,7 +99,7 @@ private: int m_value2; }; -class MyQmlObject : public QObject, public MyInterface, public QDeclarativeParserStatus +class MyQmlObject : public QObject, public MyInterface { Q_OBJECT Q_PROPERTY(int value READ value WRITE setValue FINAL) @@ -113,7 +113,7 @@ class MyQmlObject : public QObject, public MyInterface, public QDeclarativeParse Q_PROPERTY(MyQmlObject *qmlobjectProperty READ qmlobject WRITE setQmlobject) Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal) - Q_INTERFACES(MyInterface QDeclarativeParserStatus) + Q_INTERFACES(MyInterface) public: MyQmlObject() : m_value(-1), m_interface(0), m_qmlobject(0) { qRegisterMetaType<MyCustomVariantType>("MyCustomVariantType"); } diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index ff03005..011870c 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -351,8 +351,8 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("invalidAttachedProperty.12") << "invalidAttachedProperty.12.qml" << "invalidAttachedProperty.12.errors.txt" << false; QTest::newRow("invalidAttachedProperty.13") << "invalidAttachedProperty.13.qml" << "invalidAttachedProperty.13.errors.txt" << false; + QTest::newRow("assignValueToSignal") << "assignValueToSignal.qml" << "assignValueToSignal.errors.txt" << false; QTest::newRow("emptySignal") << "emptySignal.qml" << "emptySignal.errors.txt" << false; - QTest::newRow("emptySignal.2") << "emptySignal.2.qml" << "emptySignal.2.errors.txt" << false; QTest::newRow("nestedErrors") << "nestedErrors.qml" << "nestedErrors.errors.txt" << false; QTest::newRow("defaultGrouped") << "defaultGrouped.qml" << "defaultGrouped.errors.txt" << false; @@ -536,6 +536,8 @@ void tst_qdeclarativelanguage::assignLiteralToVariant() QCOMPARE(object->property("test7").userType(), (int)QVariant::SizeF); QCOMPARE(object->property("test8").userType(), (int)QVariant::Vector3D); QCOMPARE(object->property("test9").userType(), (int)QVariant::String); + QCOMPARE(object->property("test10").userType(), (int)QVariant::Bool); + QCOMPARE(object->property("test11").userType(), (int)QVariant::Bool); QVERIFY(object->property("test1") == QVariant(1)); QVERIFY(object->property("test2") == QVariant((double)1.7)); @@ -546,6 +548,8 @@ void tst_qdeclarativelanguage::assignLiteralToVariant() QVERIFY(object->property("test7") == QVariant(QSizeF(10, 10))); QVERIFY(object->property("test8") == QVariant(QVector3D(100, 100, 100))); QVERIFY(object->property("test9") == QVariant(QString(QLatin1String("#FF008800")))); + QVERIFY(object->property("test10") == QVariant(bool(true))); + QVERIFY(object->property("test11") == QVariant(bool(false))); delete object; } @@ -679,6 +683,7 @@ void tst_qdeclarativelanguage::listProperties() // ### Not complete void tst_qdeclarativelanguage::dynamicObjectProperties() { + { QDeclarativeComponent component(&engine, TEST_FILE("dynamicObjectProperties.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); @@ -686,6 +691,16 @@ void tst_qdeclarativelanguage::dynamicObjectProperties() QVERIFY(object->property("objectProperty") == qVariantFromValue((QObject*)0)); QVERIFY(object->property("objectProperty2") != qVariantFromValue((QObject*)0)); + } + { + QDeclarativeComponent component(&engine, TEST_FILE("dynamicObjectProperties.2.qml")); + QEXPECT_FAIL("", "QTBUG-10822", Abort); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QVERIFY(object->property("objectProperty") != qVariantFromValue((QObject*)0)); + } } // Tests the declaration of dynamic signals and slots @@ -1101,19 +1116,48 @@ void tst_qdeclarativelanguage::onDestruction() // Check that assignments to QDeclarativeScriptString properties work void tst_qdeclarativelanguage::scriptString() { - QDeclarativeComponent component(&engine, TEST_FILE("scriptString.qml")); - VERIFY_ERRORS(0); + { + QDeclarativeComponent component(&engine, TEST_FILE("scriptString.qml")); + VERIFY_ERRORS(0); - MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create()); - QVERIFY(object != 0); - QCOMPARE(object->scriptProperty().script(), QString("foo + bar")); - QCOMPARE(object->scriptProperty().scopeObject(), qobject_cast<QObject*>(object)); - QCOMPARE(object->scriptProperty().context(), qmlContext(object)); - - QVERIFY(object->grouped() != 0); - QCOMPARE(object->grouped()->script().script(), QString("console.log(1921)")); - QCOMPARE(object->grouped()->script().scopeObject(), qobject_cast<QObject*>(object)); - QCOMPARE(object->grouped()->script().context(), qmlContext(object)); + MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->scriptProperty().script(), QString("foo + bar")); + QCOMPARE(object->scriptProperty().scopeObject(), qobject_cast<QObject*>(object)); + QCOMPARE(object->scriptProperty().context(), qmlContext(object)); + + QVERIFY(object->grouped() != 0); + QCOMPARE(object->grouped()->script().script(), QString("console.log(1921)")); + QCOMPARE(object->grouped()->script().scopeObject(), qobject_cast<QObject*>(object)); + QCOMPARE(object->grouped()->script().context(), qmlContext(object)); + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("scriptString2.qml")); + VERIFY_ERRORS(0); + + MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->scriptProperty().script(), QString("\"hello\\n\\\"world\\\"\"")); + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("scriptString3.qml")); + VERIFY_ERRORS(0); + + MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->scriptProperty().script(), QString("12.345")); + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("scriptString4.qml")); + VERIFY_ERRORS(0); + + MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->scriptProperty().script(), QString("true")); + } } // Check that default property assignments are correctly spliced into explicit diff --git a/tests/auto/declarative/qdeclarativelayoutitem/data/layoutItem.qml b/tests/auto/declarative/qdeclarativelayoutitem/data/layoutItem.qml new file mode 100644 index 0000000..ee881a2 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelayoutitem/data/layoutItem.qml @@ -0,0 +1,9 @@ +import Qt 4.7 + +LayoutItem {//Sized by the layout + id: resizable + objectName: "resizable" + minimumSize: "100x100" + maximumSize: "300x300" + preferredSize: "200x200" +} diff --git a/tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro b/tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro new file mode 100644 index 0000000..79954fe --- /dev/null +++ b/tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro @@ -0,0 +1,15 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativelayoutitem.cpp + +# Define SRCDIR equal to test's source directory +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +}
\ No newline at end of file diff --git a/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp b/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp new file mode 100644 index 0000000..c0c5abc --- /dev/null +++ b/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** 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 <QtTest/QtTest> +#include <qdeclarativecomponent.h> +#include <qdeclarativeengine.h> +#include <qdeclarativeitem.h> +#include <private/qdeclarativelayoutitem_p.h> +#include <qgraphicsview.h> +#include <qgraphicsscene.h> +#include <qgraphicswidget.h> +#include <qgraphicslinearlayout.h> +#include "../../../shared/util.h" + +class tst_qdeclarativelayoutitem : public QObject +{ + Q_OBJECT +public: + tst_qdeclarativelayoutitem(); + +private slots: + void test_resizing(); +}; + +tst_qdeclarativelayoutitem::tst_qdeclarativelayoutitem() +{ +} + +void tst_qdeclarativelayoutitem::test_resizing() +{ + //Create Layout (must be done in C++) + QGraphicsView view; + QGraphicsScene scene; + QGraphicsWidget *widget = new QGraphicsWidget(); + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(); + widget->setLayout(layout); + scene.addItem(widget); + view.setScene(&scene); + //Add the QML snippet into the layout + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/layoutItem.qml")); + QDeclarativeLayoutItem* obj = static_cast<QDeclarativeLayoutItem*>(c.create()); + layout->addItem(obj); + layout->setContentsMargins(0,0,0,0); + widget->setContentsMargins(0,0,0,0); + view.show(); + + QVERIFY(obj!= 0); + + widget->setGeometry(QRectF(0,0, 400,400)); + QCOMPARE(obj->width(), 300.0); + QCOMPARE(obj->height(), 300.0); + + widget->setGeometry(QRectF(0,0, 300,300)); + QCOMPARE(obj->width(), 300.0); + QCOMPARE(obj->height(), 300.0); + + widget->setGeometry(QRectF(0,0, 200,200)); + QCOMPARE(obj->width(), 200.0); + QCOMPARE(obj->height(), 200.0); + + widget->setGeometry(QRectF(0,0, 100,100)); + QCOMPARE(obj->width(), 100.0); + QCOMPARE(obj->height(), 100.0); + + widget->setGeometry(QRectF(0,0, 40,40)); + QCOMPARE(obj->width(), 100.0); + QCOMPARE(obj->height(), 100.0); + + widget->setGeometry(QRectF(0,0, 412,112)); + QCOMPARE(obj->width(), 300.0); + QCOMPARE(obj->height(), 112.0); +} + + +QTEST_MAIN(tst_qdeclarativelayoutitem) + +#include "tst_qdeclarativelayoutitem.moc" diff --git a/tests/auto/declarative/qdeclarativelayouts/data/layouts.qml b/tests/auto/declarative/qdeclarativelayouts/data/layouts.qml deleted file mode 100644 index 0538738..0000000 --- a/tests/auto/declarative/qdeclarativelayouts/data/layouts.qml +++ /dev/null @@ -1,31 +0,0 @@ -import Qt 4.7 -import Qt.widgets 4.7 - -Item { - id: resizable - width:300 - height:300 - QGraphicsWidget { - x : resizable.x - y : resizable.y - width : resizable.width - height : resizable.height - layout: QGraphicsLinearLayout { - spacing: 0 - LayoutItem { - objectName: "left" - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "100x100" - Rectangle { objectName: "yellowRect"; color: "yellow"; anchors.fill: parent } - } - LayoutItem { - objectName: "right" - minimumSize: "100x100" - maximumSize: "400x400" - preferredSize: "200x200" - Rectangle { objectName: "greenRect"; color: "green"; anchors.fill: parent } - } - } - } -} diff --git a/tests/auto/declarative/qdeclarativelayouts/qdeclarativelayouts.pro b/tests/auto/declarative/qdeclarativelayouts/qdeclarativelayouts.pro deleted file mode 100644 index a2065f4..0000000 --- a/tests/auto/declarative/qdeclarativelayouts/qdeclarativelayouts.pro +++ /dev/null @@ -1,10 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative -SOURCES += tst_qdeclarativelayouts.cpp -macx:CONFIG -= app_bundle - -# Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - diff --git a/tests/auto/declarative/qdeclarativelayouts/tst_qdeclarativelayouts.cpp b/tests/auto/declarative/qdeclarativelayouts/tst_qdeclarativelayouts.cpp deleted file mode 100644 index 412c3b7..0000000 --- a/tests/auto/declarative/qdeclarativelayouts/tst_qdeclarativelayouts.cpp +++ /dev/null @@ -1,147 +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 <QtTest/QtTest> -#include <private/qlistmodelinterface_p.h> -#include <qdeclarativeview.h> -#include <private/qdeclarativelayoutitem_p.h> -#include <qdeclarativeexpression.h> -#include <QStyle> - -class tst_QDeclarativeLayouts : public QObject -{ - Q_OBJECT -public: - tst_QDeclarativeLayouts(); - -private slots: - void test_qml();//GraphicsLayout set up in Qml - void test_cpp();//GraphicsLayout set up in C++ - -private: - QDeclarativeView *createView(const QString &filename); -}; - -tst_QDeclarativeLayouts::tst_QDeclarativeLayouts() -{ -} - -void tst_QDeclarativeLayouts::test_qml() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/layouts.qml"); - - qApp->processEvents(); - QDeclarativeLayoutItem *left = static_cast<QDeclarativeLayoutItem*>(canvas->rootObject()->findChild<QDeclarativeItem*>("left")); - QVERIFY(left != 0); - - QDeclarativeLayoutItem *right = static_cast<QDeclarativeLayoutItem*>(canvas->rootObject()->findChild<QDeclarativeItem*>("right")); - QVERIFY(right != 0); - - qreal l = QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin); - qreal r = QApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin); - qreal t = QApplication::style()->pixelMetric(QStyle::PM_LayoutTopMargin); - qreal b = QApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin); - QVERIFY2(l == r && r == t && t == b, "Test assumes equal margins."); - qreal gvMargin = l; - - QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(canvas->rootObject()); - QVERIFY(rootItem != 0); - - //Preferred Size - rootItem->setWidth(300 + 2*gvMargin); - rootItem->setHeight(300 + 2*gvMargin); - - QCOMPARE(left->x(), gvMargin); - QCOMPARE(left->y(), gvMargin); - QCOMPARE(left->width(), 100.0); - QCOMPARE(left->height(), 300.0); - - QCOMPARE(right->x(), 100.0 + gvMargin); - QCOMPARE(right->y(), 0.0 + gvMargin); - QCOMPARE(right->width(), 200.0); - QCOMPARE(right->height(), 300.0); - - //Minimum Size - rootItem->setWidth(10+2*gvMargin); - rootItem->setHeight(10+2*gvMargin); - - QCOMPARE(left->x(), gvMargin); - QCOMPARE(left->width(), 100.0); - QCOMPARE(left->height(), 100.0); - - QCOMPARE(right->x(), 100.0 + gvMargin); - QCOMPARE(right->width(), 100.0); - QCOMPARE(right->height(), 100.0); - - //Between preferred and Maximum Size - /*Note that if set to maximum size (or above) GraphicsLinearLayout behavior - is to shrink them down to preferred size. So the exact maximum size can't - be used*/ - rootItem->setWidth(670 + 2*gvMargin); - rootItem->setHeight(300 + 2*gvMargin); - - QCOMPARE(left->x(), gvMargin); - QCOMPARE(left->width(), 270.0); - QCOMPARE(left->height(), 300.0); - - QCOMPARE(right->x(), 270.0 + gvMargin); - QCOMPARE(right->width(), 400.0); - QCOMPARE(right->height(), 300.0); - - delete canvas; -} - -void tst_QDeclarativeLayouts::test_cpp() -{ - //TODO: This test! -} - -QDeclarativeView *tst_QDeclarativeLayouts::createView(const QString &filename) -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setSource(QUrl::fromLocalFile(filename)); - - return canvas; -} - - -QTEST_MAIN(tst_QDeclarativeLayouts) - -#include "tst_qdeclarativelayouts.moc" diff --git a/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro b/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro index 9f1e146..53bb9ec 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro +++ b/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro @@ -6,7 +6,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativelistmodel.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index ec97461..be4ffe8 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -184,8 +184,8 @@ void tst_qdeclarativelistmodel::dynamic_data() QTest::newRow("count") << "count" << 0 << ""; - QTest::newRow("get1") << "{get(0)}" << 0 << "<Unknown File>: QML ListModel: get: index 0 out of range"; - QTest::newRow("get2") << "{get(-1)}" << 0 << "<Unknown File>: QML ListModel: get: index -1 out of range"; + QTest::newRow("get1") << "{get(0)}" << 0 << ""; + QTest::newRow("get2") << "{get(-1)}" << 0 << ""; QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << ""; QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << ""; @@ -196,13 +196,13 @@ void tst_qdeclarativelistmodel::dynamic_data() QTest::newRow("clear1") << "{append({'foo':456});clear();count}" << 0 << ""; QTest::newRow("clear2") << "{append({'foo':123});append({'foo':456});clear();count}" << 0 << ""; - QTest::newRow("clear3") << "{append({'foo':123});clear();get(0).foo}" << 0 << "<Unknown File>: QML ListModel: get: index 0 out of range"; + QTest::newRow("clear3") << "{append({'foo':123});clear()}" << 0 << ""; QTest::newRow("remove1") << "{append({'foo':123});remove(0);count}" << 0 << ""; QTest::newRow("remove2a") << "{append({'foo':123});append({'foo':456});remove(0);count}" << 1 << ""; QTest::newRow("remove2b") << "{append({'foo':123});append({'foo':456});remove(0);get(0).foo}" << 456 << ""; QTest::newRow("remove2c") << "{append({'foo':123});append({'foo':456});remove(1);get(0).foo}" << 123 << ""; - QTest::newRow("remove3") << "{append({'foo':123});remove(0);get(0).foo}" << 0 << "<Unknown File>: QML ListModel: get: index 0 out of range"; + QTest::newRow("remove3") << "{append({'foo':123});remove(0)}" << 0 << ""; QTest::newRow("remove3a") << "{append({'foo':123});remove(-1);count}" << 1 << "<Unknown File>: QML ListModel: remove: index -1 out of range"; QTest::newRow("remove4a") << "{remove(0)}" << 0 << "<Unknown File>: QML ListModel: remove: index 0 out of range"; QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0);count}" << 0 << "<Unknown File>: QML ListModel: remove: index 0 out of range"; @@ -275,14 +275,16 @@ void tst_qdeclarativelistmodel::dynamic() QDeclarativeListModel model; QDeclarativeEngine::setContextForObject(&model,engine.rootContext()); engine.rootContext()->setContextObject(&model); - QDeclarativeExpression e(engine.rootContext(), script, &model); + QDeclarativeExpression e(engine.rootContext(), &model, script); if (!warning.isEmpty()) QTest::ignoreMessage(QtWarningMsg, warning.toLatin1()); int actual = e.evaluate().toInt(); if (e.hasError()) qDebug() << e.error(); // errors not expected - QVERIFY(!e.hasError()); + + if (QTest::currentDataTag() != QLatin1String("clear3") && QTest::currentDataTag() != QLatin1String("remove3")) + QVERIFY(!e.hasError()); QCOMPARE(actual,result); } @@ -326,17 +328,11 @@ void tst_qdeclarativelistmodel::dynamic_worker() if (QByteArray(QTest::currentDataTag()).startsWith("nested")) QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML ListModel: Cannot add nested list values when modifying or after modification from a worker script"); - if (QByteArray(QTest::currentDataTag()).startsWith("nested-append")) { - int callsToGet = script.count(QLatin1String(";get(")); - for (int i=0; i<callsToGet; i++) - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML ListModel: get: index 0 out of range"); - } - QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", Q_ARG(QVariant, operations.mid(0, operations.length()-1)))); waitForWorker(item); - QDeclarativeExpression e(eng.rootContext(), operations.last().toString(), &model); + QDeclarativeExpression e(eng.rootContext(), &model, operations.last().toString()); if (QByteArray(QTest::currentDataTag()).startsWith("nested")) QVERIFY(e.evaluate().toInt() != result); else diff --git a/tests/auto/declarative/qdeclarativelistview/data/manual-highlight.qml b/tests/auto/declarative/qdeclarativelistview/data/manual-highlight.qml new file mode 100644 index 0000000..4913ebe --- /dev/null +++ b/tests/auto/declarative/qdeclarativelistview/data/manual-highlight.qml @@ -0,0 +1,47 @@ +import Qt 4.7 + +Item { + + ListModel { + id: model + ListElement { + name: "Bill Smith" + number: "555 3264" + } + ListElement { + name: "John Brown" + number: "555 8426" + } + ListElement { + name: "Sam Wise" + number: "555 0473" + } + ListElement { + name: "Bob Brown" + number: "555 5845" + } + } + + Component { + id: highlight + Rectangle { + objectName: "highlight" + width: 180; height: 20 + color: "lightsteelblue"; radius: 5 + y: list.currentItem.y + } + } + + ListView { + id: list + objectName: "list" + anchors.fill: parent + model: model + delegate: Text { objectName: "wrapper"; text: name } + + highlight: highlight + highlightFollowsCurrentItem: false + focus: true + } + +} diff --git a/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro b/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro index 5d962c0..b406fde 100644 --- a/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro +++ b/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro @@ -5,6 +5,13 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativelistview.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 22eb734..203760e 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -90,6 +90,7 @@ private slots: void componentChanges(); void modelChanges(); void QTBUG_9791(); + void manualHighlight(); private: template <class T> void items(); @@ -1432,8 +1433,6 @@ void tst_QDeclarativeListView::QTBUG_9791() { QDeclarativeView *canvas = createView(); - QDeclarativeContext *ctxt = canvas->rootContext(); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/strictlyenforcerange.qml")); qApp->processEvents(); @@ -1465,6 +1464,34 @@ void tst_QDeclarativeListView::QTBUG_9791() delete canvas; } +void tst_QDeclarativeListView::manualHighlight() +{ + QDeclarativeView *canvas = new QDeclarativeView(0); + canvas->setFixedSize(240,320); + + QDeclarativeContext *ctxt = canvas->rootContext(); + + QString filename(SRCDIR "/data/manual-highlight.qml"); + canvas->setSource(QUrl::fromLocalFile(filename)); + + qApp->processEvents(); + + QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QDeclarativeItem *viewport = listview->viewport(); + QTRY_VERIFY(viewport != 0); + + QTRY_COMPARE(listview->currentIndex(), 0); + QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 0)); + QTRY_COMPARE(listview->highlightItem()->y(), listview->currentItem()->y()); + + listview->setCurrentIndex(2); + + QTRY_COMPARE(listview->currentIndex(), 2); + QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 2)); + QTRY_COMPARE(listview->highlightItem()->y(), listview->currentItem()->y()); +} void tst_QDeclarativeListView::qListModelInterface_items() { @@ -1552,7 +1579,7 @@ T *tst_QDeclarativeListView::findItem(QGraphicsObject *parent, const QString &ob //qDebug() << "try" << item; if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { if (index != -1) { - QDeclarativeExpression e(qmlContext(item), "index", item); + QDeclarativeExpression e(qmlContext(item), item, "index"); if (e.evaluate().toInt() == index) return static_cast<T*>(item); } else { diff --git a/tests/auto/declarative/qdeclarativeloader/data/AnchoredLoader.qml b/tests/auto/declarative/qdeclarativeloader/data/AnchoredLoader.qml new file mode 100644 index 0000000..5d02dae --- /dev/null +++ b/tests/auto/declarative/qdeclarativeloader/data/AnchoredLoader.qml @@ -0,0 +1,14 @@ +import Qt 4.7 + +Rectangle { + width: 300 + height: 200 + color: "blue" + Loader { + objectName: "loader" + anchors.fill: parent + sourceComponent: Component { + Rectangle { color: "red"; objectName: "sourceElement" } + } + } +} 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/qdeclarativeloader/data/NoResize.qml b/tests/auto/declarative/qdeclarativeloader/data/NoResize.qml index 6aa3d2f..72cd3b9 100644 --- a/tests/auto/declarative/qdeclarativeloader/data/NoResize.qml +++ b/tests/auto/declarative/qdeclarativeloader/data/NoResize.qml @@ -1,7 +1,8 @@ import Qt 4.7 -Loader { - resizeMode: "NoResize" +Item { width: 200; height: 80 - source: "Rect120x60.qml" + Loader { + source: "Rect120x60.qml" + } } diff --git a/tests/auto/declarative/qdeclarativeloader/data/NoResizeGraphicsWidget.qml b/tests/auto/declarative/qdeclarativeloader/data/NoResizeGraphicsWidget.qml index 9322141..0cff506 100644 --- a/tests/auto/declarative/qdeclarativeloader/data/NoResizeGraphicsWidget.qml +++ b/tests/auto/declarative/qdeclarativeloader/data/NoResizeGraphicsWidget.qml @@ -1,8 +1,9 @@ import Qt 4.7 -Loader { - resizeMode: Loader.NoResize - source: "GraphicsWidget250x250.qml" +Item { width: 200 - height: 80 + height: 80 + Loader { + source: "GraphicsWidget250x250.qml" + } } diff --git a/tests/auto/declarative/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml b/tests/auto/declarative/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml index 0cfb4df..81610ad 100644 --- a/tests/auto/declarative/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml +++ b/tests/auto/declarative/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml @@ -1,7 +1,6 @@ import Qt 4.7 Loader { - resizeMode: Loader.SizeItemToLoader width: 200 height: 80 source: "GraphicsWidget250x250.qml" diff --git a/tests/auto/declarative/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml b/tests/auto/declarative/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml index b588c9d..a801a42 100644 --- a/tests/auto/declarative/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml +++ b/tests/auto/declarative/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml @@ -1,6 +1,5 @@ import Qt 4.7 Loader { - resizeMode: Loader.SizeLoaderToItem source: "GraphicsWidget250x250.qml" } diff --git a/tests/auto/declarative/qdeclarativeloader/data/SizeToItem.qml b/tests/auto/declarative/qdeclarativeloader/data/SizeToItem.qml index 93be6f1..77aa8d9 100644 --- a/tests/auto/declarative/qdeclarativeloader/data/SizeToItem.qml +++ b/tests/auto/declarative/qdeclarativeloader/data/SizeToItem.qml @@ -1,6 +1,5 @@ import Qt 4.7 Loader { - resizeMode: "SizeLoaderToItem" source: "Rect120x60.qml" } diff --git a/tests/auto/declarative/qdeclarativeloader/data/SizeToLoader.qml b/tests/auto/declarative/qdeclarativeloader/data/SizeToLoader.qml index 04b46fb..0098927 100644 --- a/tests/auto/declarative/qdeclarativeloader/data/SizeToLoader.qml +++ b/tests/auto/declarative/qdeclarativeloader/data/SizeToLoader.qml @@ -1,7 +1,6 @@ import Qt 4.7 Loader { - resizeMode: "SizeItemToLoader" width: 200; height: 80 source: "Rect120x60.qml" } diff --git a/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro b/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro index 96fea5b..9334928 100644 --- a/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro +++ b/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro @@ -7,7 +7,14 @@ HEADERS += ../shared/testhttpserver.h SOURCES += tst_qdeclarativeloader.cpp \ ../shared/testhttpserver.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp index 7cdadb4..11cc61b 100644 --- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp +++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp @@ -78,6 +78,7 @@ private slots: void clear(); void urlToComponent(); void componentToUrl(); + void anchoredLoader(); void sizeLoaderToItem(); void sizeItemToLoader(); void noResize(); @@ -104,13 +105,14 @@ tst_QDeclarativeLoader::tst_QDeclarativeLoader() void tst_QDeclarativeLoader::url() { QDeclarativeComponent component(&engine); - component.setData(QByteArray("import Qt 4.7\nLoader { source: \"Rect120x60.qml\" }"), TEST_FILE("")); + component.setData(QByteArray("import Qt 4.7\nLoader { property int did_load: 0; onLoaded: did_load=123; source: \"Rect120x60.qml\" }"), TEST_FILE("")); QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create()); QVERIFY(loader != 0); QVERIFY(loader->item()); QVERIFY(loader->source() == QUrl::fromLocalFile(SRCDIR "/data/Rect120x60.qml")); QCOMPARE(loader->progress(), 1.0); QCOMPARE(loader->status(), QDeclarativeLoader::Ready); + QCOMPARE(loader->property("did_load").toInt(), 123); QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); delete loader; @@ -265,12 +267,32 @@ void tst_QDeclarativeLoader::componentToUrl() delete item; } +void tst_QDeclarativeLoader::anchoredLoader() +{ + QDeclarativeComponent component(&engine, TEST_FILE("/AnchoredLoader.qml")); + QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(rootItem != 0); + QDeclarativeItem *loader = rootItem->findChild<QDeclarativeItem*>("loader"); + QDeclarativeItem *sourceElement = rootItem->findChild<QDeclarativeItem*>("sourceElement"); + + QVERIFY(loader != 0); + QVERIFY(sourceElement != 0); + + QCOMPARE(rootItem->width(), 300.0); + QCOMPARE(rootItem->height(), 200.0); + + QCOMPARE(loader->width(), 300.0); + QCOMPARE(loader->height(), 200.0); + + QCOMPARE(sourceElement->width(), 300.0); + QCOMPARE(sourceElement->height(), 200.0); +} + void tst_QDeclarativeLoader::sizeLoaderToItem() { QDeclarativeComponent component(&engine, TEST_FILE("/SizeToItem.qml")); QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create()); QVERIFY(loader != 0); - QVERIFY(loader->resizeMode() == QDeclarativeLoader::SizeLoaderToItem); QCOMPARE(loader->width(), 120.0); QCOMPARE(loader->height(), 60.0); @@ -282,20 +304,28 @@ void tst_QDeclarativeLoader::sizeLoaderToItem() QCOMPARE(loader->width(), 150.0); QCOMPARE(loader->height(), 45.0); + // Check explicit width + loader->setWidth(200.0); + QCOMPARE(loader->width(), 200.0); + QCOMPARE(rect->width(), 200.0); + rect->setWidth(100.0); // when rect changes ... + QCOMPARE(rect->width(), 100.0); // ... it changes + QCOMPARE(loader->width(), 200.0); // ... but loader stays the same + + // Check explicit height + loader->setHeight(200.0); + QCOMPARE(loader->height(), 200.0); + QCOMPARE(rect->height(), 200.0); + rect->setHeight(100.0); // when rect changes ... + QCOMPARE(rect->height(), 100.0); // ... it changes + QCOMPARE(loader->height(), 200.0); // ... but loader stays the same + // Switch mode - loader->setResizeMode(QDeclarativeLoader::SizeItemToLoader); loader->setWidth(180); loader->setHeight(30); QCOMPARE(rect->width(), 180.0); QCOMPARE(rect->height(), 30.0); - // notify - QSignalSpy spy(loader, SIGNAL(resizeModeChanged())); - loader->setResizeMode(QDeclarativeLoader::NoResize); - QCOMPARE(spy.count(),1); - loader->setResizeMode(QDeclarativeLoader::NoResize); - QCOMPARE(spy.count(),1); - delete loader; } @@ -304,7 +334,6 @@ void tst_QDeclarativeLoader::sizeItemToLoader() QDeclarativeComponent component(&engine, TEST_FILE("/SizeToLoader.qml")); QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create()); QVERIFY(loader != 0); - QVERIFY(loader->resizeMode() == QDeclarativeLoader::SizeItemToLoader); QCOMPARE(loader->width(), 200.0); QCOMPARE(loader->height(), 80.0); @@ -320,7 +349,8 @@ void tst_QDeclarativeLoader::sizeItemToLoader() QCOMPARE(rect->height(), 30.0); // Switch mode - loader->setResizeMode(QDeclarativeLoader::SizeLoaderToItem); + loader->resetWidth(); // reset explicit size + loader->resetHeight(); rect->setWidth(160); rect->setHeight(45); QCOMPARE(loader->width(), 160.0); @@ -332,17 +362,12 @@ void tst_QDeclarativeLoader::sizeItemToLoader() void tst_QDeclarativeLoader::noResize() { QDeclarativeComponent component(&engine, TEST_FILE("/NoResize.qml")); - QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create()); - QVERIFY(loader != 0); - QCOMPARE(loader->width(), 200.0); - QCOMPARE(loader->height(), 80.0); + QDeclarativeItem* item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item != 0); + QCOMPARE(item->width(), 200.0); + QCOMPARE(item->height(), 80.0); - QDeclarativeItem *rect = qobject_cast<QDeclarativeItem*>(loader->item()); - QVERIFY(rect); - QCOMPARE(rect->width(), 120.0); - QCOMPARE(rect->height(), 60.0); - - delete loader; + delete item; } void tst_QDeclarativeLoader::sizeLoaderToGraphicsWidget() @@ -353,7 +378,6 @@ void tst_QDeclarativeLoader::sizeLoaderToGraphicsWidget() scene.addItem(loader); QVERIFY(loader != 0); - QVERIFY(loader->resizeMode() == QDeclarativeLoader::SizeLoaderToItem); QCOMPARE(loader->width(), 250.0); QCOMPARE(loader->height(), 250.0); @@ -365,7 +389,6 @@ void tst_QDeclarativeLoader::sizeLoaderToGraphicsWidget() QCOMPARE(loader->height(), 45.0); // Switch mode - loader->setResizeMode(QDeclarativeLoader::SizeItemToLoader); loader->setWidth(180); loader->setHeight(30); QCOMPARE(widget->size().width(), 180.0); @@ -382,7 +405,6 @@ void tst_QDeclarativeLoader::sizeGraphicsWidgetToLoader() scene.addItem(loader); QVERIFY(loader != 0); - QVERIFY(loader->resizeMode() == QDeclarativeLoader::SizeItemToLoader); QCOMPARE(loader->width(), 200.0); QCOMPARE(loader->height(), 80.0); @@ -398,7 +420,8 @@ void tst_QDeclarativeLoader::sizeGraphicsWidgetToLoader() QCOMPARE(widget->size().height(), 30.0); // Switch mode - loader->setResizeMode(QDeclarativeLoader::SizeLoaderToItem); + loader->resetWidth(); // reset explicit size + loader->resetHeight(); widget->resize(QSizeF(160,45)); QCOMPARE(loader->width(), 160.0); QCOMPARE(loader->height(), 45.0); @@ -409,20 +432,15 @@ void tst_QDeclarativeLoader::sizeGraphicsWidgetToLoader() void tst_QDeclarativeLoader::noResizeGraphicsWidget() { QDeclarativeComponent component(&engine, TEST_FILE("/NoResizeGraphicsWidget.qml")); - QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create()); + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); QGraphicsScene scene; - scene.addItem(loader); + scene.addItem(item); - QVERIFY(loader != 0); - QCOMPARE(loader->width(), 200.0); - QCOMPARE(loader->height(), 80.0); - - QGraphicsWidget *widget = qobject_cast<QGraphicsWidget*>(loader->item()); - QVERIFY(widget); - QCOMPARE(widget->size().width(), 250.0); - QCOMPARE(widget->size().height(), 250.0); + QVERIFY(item != 0); + QCOMPARE(item->width(), 200.0); + QCOMPARE(item->height(), 80.0); - delete loader; + delete item; } void tst_QDeclarativeLoader::networkRequestUrl() @@ -432,7 +450,7 @@ void tst_QDeclarativeLoader::networkRequestUrl() server.serveDirectory(SRCDIR "/data"); QDeclarativeComponent component(&engine); - component.setData(QByteArray("import Qt 4.7\nLoader { source: \"http://127.0.0.1:14450/Rect120x60.qml\" }"), QUrl::fromLocalFile(SRCDIR "/dummy.qml")); + component.setData(QByteArray("import Qt 4.7\nLoader { property int did_load : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: did_load=123 }"), QUrl::fromLocalFile(SRCDIR "/dummy.qml")); if (component.isError()) qDebug() << component.errors(); QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create()); @@ -442,6 +460,7 @@ void tst_QDeclarativeLoader::networkRequestUrl() QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); + QCOMPARE(loader->property("did_load").toInt(), 123); QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); delete loader; @@ -488,7 +507,7 @@ void tst_QDeclarativeLoader::failNetworkRequest() QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Network error for URL http://127.0.0.1:14450/IDontExist.qml"); QDeclarativeComponent component(&engine); - component.setData(QByteArray("import Qt 4.7\nLoader { source: \"http://127.0.0.1:14450/IDontExist.qml\" }"), QUrl::fromLocalFile("http://127.0.0.1:14450/dummy.qml")); + component.setData(QByteArray("import Qt 4.7\nLoader { property int did_load: 123; source: \"http://127.0.0.1:14450/IDontExist.qml\"; onLoaded: did_load=456 }"), QUrl::fromLocalFile("http://127.0.0.1:14450/dummy.qml")); QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create()); QVERIFY(loader != 0); @@ -496,6 +515,7 @@ void tst_QDeclarativeLoader::failNetworkRequest() QVERIFY(loader->item() == 0); QCOMPARE(loader->progress(), 0.0); + QCOMPARE(loader->property("did_load").toInt(), 123); QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0); delete loader; diff --git a/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro b/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro index cf3fa65..0d32ab8 100644 --- a/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro +++ b/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro @@ -3,7 +3,11 @@ contains(QT_CONFIG,declarative): QT += declarative SOURCES += tst_qdeclarativemetatype.cpp macx:CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp index 36efe13..76e86c9 100644 --- a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp +++ b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp @@ -88,7 +88,10 @@ QML_DECLARE_TYPE(TestType); class ParserStatusTestType : public QObject, public QDeclarativeParserStatus { Q_OBJECT + void classBegin(){} + void componentComplete(){} Q_CLASSINFO("DefaultProperty", "foo") // Missing default property + Q_INTERFACES(QDeclarativeParserStatus) }; QML_DECLARE_TYPE(ParserStatusTestType); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro index fc77225..173a302 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro +++ b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro @@ -4,3 +4,6 @@ SOURCES = plugin.cpp QT = core declarative DESTDIR = ../imports/com/nokia/AutoTestQmlPluginType +symbian: { + TARGET.EPOCALLOWDLLDATA=1 +} diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro index d895ed0..29a1009 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro +++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro @@ -2,4 +2,11 @@ load(qttest_p4) SOURCES = tst_qdeclarativemoduleplugin.cpp QT += declarative CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} 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/qdeclarativemousearea.pro b/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro index 48fe025..6f9c98c 100644 --- a/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro +++ b/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro @@ -6,7 +6,14 @@ HEADERS += ../shared/testhttpserver.h SOURCES += tst_qdeclarativemousearea.cpp ../shared/testhttpserver.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test 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/qdeclarativeparticles/qdeclarativeparticles.pro b/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro index 8a061c3..31172a9 100644 --- a/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro +++ b/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro @@ -5,7 +5,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeparticles.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathUpdateOnStartChanged.qml b/tests/auto/declarative/qdeclarativepathview/data/pathUpdateOnStartChanged.qml new file mode 100644 index 0000000..ce0f0c9 --- /dev/null +++ b/tests/auto/declarative/qdeclarativepathview/data/pathUpdateOnStartChanged.qml @@ -0,0 +1,38 @@ +import Qt 4.7 + +Rectangle { + width: 800 + height: 480 + color: "black" + resources: [ + ListModel { + id: appModel + ListElement { color: "green" } + }, + Component { + id: appDelegate + Rectangle { + id: wrapper + objectName: "wrapper" + color: "green" + width: 100 + height: 100 + } + } + ] + PathView { + id: pathView + objectName: "pathView" + model: appModel + anchors.fill: parent + + transformOrigin: "Top" + delegate: appDelegate + path: Path { + objectName: "path" + startX: pathView.width / 2 // startX: 400 <- this works as expected + startY: 300 + PathLine { x: 400; y: 120 } + } + } +} diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview_package.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview_package.qml new file mode 100644 index 0000000..082da13 --- /dev/null +++ b/tests/auto/declarative/qdeclarativepathview/data/pathview_package.qml @@ -0,0 +1,88 @@ +import Qt 4.7 + +Item { + width: 800; height: 600 + Component { + id: photoDelegate + Package { + Item { id: pathItem; objectName: "pathItem"; Package.name: 'path'; width: 85; height: 85; scale: pathItem.PathView.scale } + Item { id: linearItem; Package.name: 'linear'; width: 85; height: 85 } + Rectangle { + id: wrapper + width: 85; height: 85; color: lColor + + transform: Rotation { + id: itemRotation; origin.x: wrapper.width/2; origin.y: wrapper.height/2 + axis.y: 1; axis.z: 0 + } + state: 'path' + states: [ + State { + name: 'path' + ParentChange { target: wrapper; parent: pathItem; x: 0; y: 0 } + PropertyChanges { target: wrapper; opacity: pathItem.PathView.onPath ? 1.0 : 0 } + } + ] + } + } + } + ListModel { + id: rssModel + ListElement { lColor: "red" } + ListElement { lColor: "green" } + ListElement { lColor: "yellow" } + ListElement { lColor: "blue" } + ListElement { lColor: "purple" } + ListElement { lColor: "gray" } + ListElement { lColor: "brown" } + ListElement { lColor: "thistle" } + } + VisualDataModel { id: visualModel; model: rssModel; delegate: photoDelegate } + + PathView { + id: photoPathView + objectName: "photoPathView" + width: 800; height: 330; pathItemCount: 4; offset: 1 + dragMargin: 24 + preferredHighlightBegin: 0.50 + preferredHighlightEnd: 0.50 + + path: Path { + startX: -50; startY: 40; + + PathAttribute { name: "scale"; value: 0.5 } + PathAttribute { name: "angle"; value: -45 } + + PathCubic { + x: 400; y: 220 + control1X: 140; control1Y: 40 + control2X: 210; control2Y: 220 + } + + PathAttribute { name: "scale"; value: 1.2 } + PathAttribute { name: "angle"; value: 0 } + + PathCubic { + x: 850; y: 40 + control2X: 660; control2Y: 40 + control1X: 590; control1Y: 220 + } + + PathAttribute { name: "scale"; value: 0.5 } + PathAttribute { name: "angle"; value: 45 } + } + + model: visualModel.parts.path + } + + PathView { + y: 400; width: 800; height: 330; pathItemCount: 8 + + path: Path { + startX: 0; startY: 40; + PathLine { x: 800; y: 40 } + } + + model: visualModel.parts.linear + } +} diff --git a/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro b/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro index 3c327d5..6bef61c 100644 --- a/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro +++ b/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro @@ -5,7 +5,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativepathview.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp index 0e3a74d..f32a6c7 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -77,6 +77,8 @@ private slots: void pathChanges(); void componentChanges(); void modelChanges(); + void pathUpdateOnStartChanged(); + void package(); private: @@ -436,7 +438,8 @@ void tst_QDeclarativePathView::pathMoved() for(int i=0; i<model.count(); i++){ QDeclarativeRectangle *curItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", i); - QCOMPARE(curItem->pos() + offset, path->pointAt(0.25 + i*0.25)); + QPointF itemPos(path->pointAt(0.25 + i*0.25)); + QCOMPARE(curItem->pos() + offset, QPointF(qRound(itemPos.x()), qRound(itemPos.y()))); } pathview->setOffset(0.0); @@ -477,13 +480,36 @@ void tst_QDeclarativePathView::setCurrentIndex() QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 0); pathview->setCurrentIndex(2); - QTest::qWait(1000); firstItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 2); - QCOMPARE(firstItem->pos() + offset, start); + QTRY_COMPARE(firstItem->pos() + offset, start); QCOMPARE(canvas->rootObject()->property("currentA").toInt(), 2); QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 2); + pathview->decrementCurrentIndex(); + QTRY_COMPARE(pathview->currentIndex(), 1); + firstItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 1); + QVERIFY(firstItem); + QTRY_COMPARE(firstItem->pos() + offset, start); + + pathview->decrementCurrentIndex(); + QTRY_COMPARE(pathview->currentIndex(), 0); + firstItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 0); + QVERIFY(firstItem); + QTRY_COMPARE(firstItem->pos() + offset, start); + + pathview->decrementCurrentIndex(); + QTRY_COMPARE(pathview->currentIndex(), 3); + firstItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 3); + QVERIFY(firstItem); + QTRY_COMPARE(firstItem->pos() + offset, start); + + pathview->incrementCurrentIndex(); + QTRY_COMPARE(pathview->currentIndex(), 0); + firstItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 0); + QVERIFY(firstItem); + QTRY_COMPARE(firstItem->pos() + offset, start); + delete canvas; } @@ -672,6 +698,44 @@ void tst_QDeclarativePathView::modelChanges() delete canvas; } +void tst_QDeclarativePathView::pathUpdateOnStartChanged() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathUpdateOnStartChanged.qml")); + + QDeclarativePathView *pathView = canvas->rootObject()->findChild<QDeclarativePathView*>("pathView"); + QVERIFY(pathView); + + QDeclarativePath *path = canvas->rootObject()->findChild<QDeclarativePath*>("path"); + QVERIFY(path); + QCOMPARE(path->startX(), 400.0); + QCOMPARE(path->startY(), 300.0); + + QDeclarativeItem *item = findItem<QDeclarativeItem>(pathView, "wrapper", 0); + QVERIFY(item); + QCOMPARE(item->x(), path->startX() - item->width() / 2.0); + QCOMPARE(item->y(), path->startY() - item->height() / 2.0); + + delete canvas; +} + +void tst_QDeclarativePathView::package() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview_package.qml")); + + QDeclarativePathView *pathView = canvas->rootObject()->findChild<QDeclarativePathView*>("photoPathView"); + QVERIFY(pathView); + + QDeclarativeItem *item = findItem<QDeclarativeItem>(pathView, "pathItem"); + QVERIFY(item); + QVERIFY(item->scale() != 1.0); + + delete canvas; +} + QDeclarativeView *tst_QDeclarativePathView::createView() { QDeclarativeView *canvas = new QDeclarativeView(0); @@ -696,7 +760,7 @@ T *tst_QDeclarativePathView::findItem(QGraphicsObject *parent, const QString &ob //qDebug() << "try" << item; if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { if (index != -1) { - QDeclarativeExpression e(qmlContext(item), "index", item); + QDeclarativeExpression e(qmlContext(item), item, "index"); if (e.evaluate().toInt() == index) return static_cast<T*>(item); } else { diff --git a/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro b/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro index 4b247fc..99a94bc 100644 --- a/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro +++ b/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro @@ -9,7 +9,14 @@ INCLUDEPATH += ../shared/ HEADERS += ../shared/testhttpserver.h SOURCES += ../shared/testhttpserver.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} # QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage # LIBS += -lgcov diff --git a/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro b/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro index dbe2cbee..2c5b473 100644 --- a/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro +++ b/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro @@ -4,7 +4,14 @@ SOURCES += tst_qdeclarativepositioners.cpp macx:CONFIG -= app_bundle # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp index b4ac0e1..e639014 100644 --- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp +++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp @@ -41,6 +41,7 @@ #include <QtTest/QtTest> #include <private/qlistmodelinterface_p.h> #include <qdeclarativeview.h> +#include <qdeclarativeengine.h> #include <private/qdeclarativerectangle_p.h> #include <private/qdeclarativepositioners_p.h> #include <private/qdeclarativetransition_p.h> @@ -69,6 +70,7 @@ private slots: void test_repeater(); void test_flow(); void test_flow_resize(); + void test_conflictinganchors(); private: QDeclarativeView *createView(const QString &filename); }; @@ -100,6 +102,8 @@ void tst_QDeclarativePositioners::test_horizontal() QDeclarativeItem *row = canvas->rootObject()->findChild<QDeclarativeItem*>("row"); QCOMPARE(row->width(), 110.0); QCOMPARE(row->height(), 50.0); + + delete canvas; } void tst_QDeclarativePositioners::test_horizontal_spacing() @@ -125,6 +129,8 @@ void tst_QDeclarativePositioners::test_horizontal_spacing() QDeclarativeItem *row = canvas->rootObject()->findChild<QDeclarativeItem*>("row"); QCOMPARE(row->width(), 130.0); QCOMPARE(row->height(), 50.0); + + delete canvas; } void tst_QDeclarativePositioners::test_horizontal_animated() @@ -175,6 +181,8 @@ void tst_QDeclarativePositioners::test_horizontal_animated() QTRY_COMPARE(two->x(), 50.0); QTRY_COMPARE(three->x(), 100.0); + + delete canvas; } void tst_QDeclarativePositioners::test_vertical() @@ -201,6 +209,8 @@ void tst_QDeclarativePositioners::test_vertical() QVERIFY(column); QCOMPARE(column->height(), 80.0); QCOMPARE(column->width(), 50.0); + + delete canvas; } void tst_QDeclarativePositioners::test_vertical_spacing() @@ -226,6 +236,8 @@ void tst_QDeclarativePositioners::test_vertical_spacing() QDeclarativeItem *column = canvas->rootObject()->findChild<QDeclarativeItem*>("column"); QCOMPARE(column->height(), 100.0); QCOMPARE(column->width(), 50.0); + + delete canvas; } void tst_QDeclarativePositioners::test_vertical_animated() @@ -273,6 +285,7 @@ void tst_QDeclarativePositioners::test_vertical_animated() QTRY_COMPARE(two->y(), 50.0); QTRY_COMPARE(three->y(), 100.0); + delete canvas; } void tst_QDeclarativePositioners::test_grid() @@ -304,6 +317,8 @@ void tst_QDeclarativePositioners::test_grid() QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid"); QCOMPARE(grid->width(), 120.0); QCOMPARE(grid->height(), 100.0); + + delete canvas; } void tst_QDeclarativePositioners::test_grid_topToBottom() @@ -335,6 +350,8 @@ void tst_QDeclarativePositioners::test_grid_topToBottom() QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid"); QCOMPARE(grid->width(), 100.0); QCOMPARE(grid->height(), 120.0); + + delete canvas; } void tst_QDeclarativePositioners::test_grid_spacing() @@ -366,6 +383,8 @@ void tst_QDeclarativePositioners::test_grid_spacing() QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid"); QCOMPARE(grid->width(), 128.0); QCOMPARE(grid->height(), 104.0); + + delete canvas; } void tst_QDeclarativePositioners::test_grid_animated() @@ -446,6 +465,7 @@ void tst_QDeclarativePositioners::test_grid_animated() QTRY_COMPARE(five->x(), 50.0); QTRY_COMPARE(five->y(), 50.0); + delete canvas; } void tst_QDeclarativePositioners::test_grid_zero_columns() @@ -477,6 +497,8 @@ void tst_QDeclarativePositioners::test_grid_zero_columns() QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid"); QCOMPARE(grid->width(), 170.0); QCOMPARE(grid->height(), 60.0); + + delete canvas; } void tst_QDeclarativePositioners::test_propertychanges() @@ -534,6 +556,8 @@ void tst_QDeclarativePositioners::test_propertychanges() grid->setRows(2); QCOMPARE(columnsSpy.count(),2); QCOMPARE(rowsSpy.count(),2); + + delete canvas; } void tst_QDeclarativePositioners::test_repeater() @@ -555,6 +579,8 @@ void tst_QDeclarativePositioners::test_repeater() QCOMPARE(two->y(), 0.0); QCOMPARE(three->x(), 100.0); QCOMPARE(three->y(), 0.0); + + delete canvas; } void tst_QDeclarativePositioners::test_flow() @@ -587,6 +613,8 @@ void tst_QDeclarativePositioners::test_flow() QVERIFY(flow); QCOMPARE(flow->width(), 90.0); QCOMPARE(flow->height(), 120.0); + + delete canvas; } void tst_QDeclarativePositioners::test_flow_resize() @@ -618,6 +646,101 @@ void tst_QDeclarativePositioners::test_flow_resize() QCOMPARE(four->y(), 50.0); QCOMPARE(five->x(), 50.0); QCOMPARE(five->y(), 50.0); + + delete canvas; +} + +QString warningMessage; + +void interceptWarnings(QtMsgType type, const char *msg) +{ + Q_UNUSED( type ); + warningMessage = msg; +} + +void tst_QDeclarativePositioners::test_conflictinganchors() +{ + qInstallMsgHandler(interceptWarnings); + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine); + + component.setData("import Qt 4.7\nColumn { Item {} }", QUrl::fromLocalFile("")); + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QVERIFY(warningMessage.isEmpty()); + + component.setData("import Qt 4.7\nRow { Item {} }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QVERIFY(warningMessage.isEmpty()); + + component.setData("import Qt 4.7\nGrid { Item {} }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QVERIFY(warningMessage.isEmpty()); + + component.setData("import Qt 4.7\nFlow { Item {} }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QVERIFY(warningMessage.isEmpty()); + + component.setData("import Qt 4.7\nColumn { Item { anchors.top: parent.top } }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column")); + warningMessage.clear(); + + component.setData("import Qt 4.7\nColumn { Item { anchors.centerIn: parent } }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column")); + warningMessage.clear(); + + component.setData("import Qt 4.7\nColumn { Item { anchors.left: parent.left } }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QVERIFY(warningMessage.isEmpty()); + warningMessage.clear(); + + component.setData("import Qt 4.7\nRow { Item { anchors.left: parent.left } }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row")); + warningMessage.clear(); + + component.setData("import Qt 4.7\nRow { Item { anchors.fill: parent } }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row")); + warningMessage.clear(); + + component.setData("import Qt 4.7\nRow { Item { anchors.top: parent.top } }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QVERIFY(warningMessage.isEmpty()); + warningMessage.clear(); + + component.setData("import Qt 4.7\nGrid { Item { anchors.horizontalCenter: parent.horizontalCenter } }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid")); + warningMessage.clear(); + + component.setData("import Qt 4.7\nGrid { Item { anchors.centerIn: parent } }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid")); + warningMessage.clear(); + + component.setData("import Qt 4.7\nFlow { Item { anchors.verticalCenter: parent.verticalCenter } }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow")); + + component.setData("import Qt 4.7\nFlow { Item { anchors.fill: parent } }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow")); } QDeclarativeView *tst_QDeclarativePositioners::createView(const QString &filename) diff --git a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro index 6910ccc..f37d952 100644 --- a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro +++ b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro @@ -4,7 +4,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeproperty.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeqt/data/darker.qml b/tests/auto/declarative/qdeclarativeqt/data/darker.qml index f6333fe..738095d 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/darker.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/darker.qml @@ -3,9 +3,10 @@ import Qt 4.7 QtObject { property variant test1: Qt.darker(Qt.rgba(1, 0.8, 0.3)) property variant test2: Qt.darker() - property variant test3: Qt.darker(Qt.rgba(1, 0.8, 0.3), 10) + property variant test3: Qt.darker(Qt.rgba(1, 0.8, 0.3), 2.8) property variant test4: Qt.darker("red"); property variant test5: Qt.darker("perfectred"); // Non-existant color property variant test6: Qt.darker(10); + property variant test7: Qt.darker(Qt.rgba(1, 0.8, 0.3), 2.8, 10) } diff --git a/tests/auto/declarative/qdeclarativeqt/data/fontFamilies.qml b/tests/auto/declarative/qdeclarativeqt/data/fontFamilies.qml new file mode 100644 index 0000000..e66c7be --- /dev/null +++ b/tests/auto/declarative/qdeclarativeqt/data/fontFamilies.qml @@ -0,0 +1,6 @@ +import Qt 4.7 + +QtObject { + property variant test1: Qt.fontFamilies(10) + property variant test2: Qt.fontFamilies(); +} diff --git a/tests/auto/declarative/qdeclarativeqt/data/lighter.qml b/tests/auto/declarative/qdeclarativeqt/data/lighter.qml index 6c0053ba..ddaf78d 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/lighter.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/lighter.qml @@ -3,8 +3,9 @@ import Qt 4.7 QtObject { property variant test1: Qt.lighter(Qt.rgba(1, 0.8, 0.3)) property variant test2: Qt.lighter() - property variant test3: Qt.lighter(Qt.rgba(1, 0.8, 0.3), 10) + property variant test3: Qt.lighter(Qt.rgba(1, 0.8, 0.3), 1.8) property variant test4: Qt.lighter("red"); property variant test5: Qt.lighter("perfectred"); // Non-existant color property variant test6: Qt.lighter(10); + property variant test7: Qt.lighter(Qt.rgba(1, 0.8, 0.3), 1.8, 5) } diff --git a/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro b/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro index 10e10a3..b381a9b 100644 --- a/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro +++ b/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro @@ -3,7 +3,14 @@ contains(QT_CONFIG,declarative): QT += declarative SOURCES += tst_qdeclarativeqt.cpp macx:CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} # QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage # LIBS += -lgcov diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp index 7cbd8db..5095be8 100644 --- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp +++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp @@ -42,6 +42,7 @@ #include <qtest.h> #include <QDebug> #include <QDeclarativeEngine> +#include <QFontDatabase> #include <QFileInfo> #include <QDeclarativeComponent> #include <QDesktopServices> @@ -76,6 +77,7 @@ private slots: void isQtObject(); void btoa(); void atob(); + void fontFamilies(); private: QDeclarativeEngine engine; @@ -232,7 +234,7 @@ void tst_qdeclarativeqt::lighter() QDeclarativeComponent component(&engine, TEST_FILE("lighter.qml")); QString warning1 = component.url().toString() + ":5: Error: Qt.lighter(): Invalid arguments"; - QString warning2 = component.url().toString() + ":6: Error: Qt.lighter(): Invalid arguments"; + QString warning2 = component.url().toString() + ":10: Error: Qt.lighter(): Invalid arguments"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); @@ -241,7 +243,7 @@ void tst_qdeclarativeqt::lighter() QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).lighter()); QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor()); - QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0.8, 0.3).lighter(180)); QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").lighter()); QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor()); QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor()); @@ -254,7 +256,7 @@ void tst_qdeclarativeqt::darker() QDeclarativeComponent component(&engine, TEST_FILE("darker.qml")); QString warning1 = component.url().toString() + ":5: Error: Qt.darker(): Invalid arguments"; - QString warning2 = component.url().toString() + ":6: Error: Qt.darker(): Invalid arguments"; + QString warning2 = component.url().toString() + ":10: Error: Qt.darker(): Invalid arguments"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); @@ -263,7 +265,7 @@ void tst_qdeclarativeqt::darker() QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).darker()); QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor()); - QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0.8, 0.3).darker(280)); QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").darker()); QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor()); QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor()); @@ -483,6 +485,22 @@ void tst_qdeclarativeqt::atob() delete object; } +void tst_qdeclarativeqt::fontFamilies() +{ + QDeclarativeComponent component(&engine, TEST_FILE("fontFamilies.qml")); + + QString warning1 = component.url().toString() + ":4: Error: Qt.fontFamilies(): Invalid arguments"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QFontDatabase database; + QCOMPARE(object->property("test2"), QVariant::fromValue(database.families())); + + delete object; +} + QTEST_MAIN(tst_qdeclarativeqt) #include "tst_qdeclarativeqt.moc" diff --git a/tests/auto/declarative/qdeclarativerepeater/data/objlist.qml b/tests/auto/declarative/qdeclarativerepeater/data/objlist.qml index 17c5d8d..e1bd2e2 100644 --- a/tests/auto/declarative/qdeclarativerepeater/data/objlist.qml +++ b/tests/auto/declarative/qdeclarativerepeater/data/objlist.qml @@ -14,7 +14,7 @@ Rectangle { property int instantiated: 0 Component { Item{ - Component.onCompleted: {if(index!=model.idx) repeater.errors += 1; repeater.instantiated++} + Component.onCompleted: {if(index!=modelData.idx) repeater.errors += 1; repeater.instantiated++} } } } diff --git a/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro b/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro index abd36e0..51667af 100644 --- a/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro +++ b/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro @@ -5,6 +5,13 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativerepeater.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp index 8be7d80..e6b2fdd 100644 --- a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp +++ b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp @@ -185,15 +185,24 @@ void tst_QDeclarativeRepeater::numberModel() delete canvas; } +class MyObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int idx READ idx CONSTANT) +public: + MyObject(int i) : QObject(), m_idx(i) {} + + int idx() const { return m_idx; } + + int m_idx; +}; + void tst_QDeclarativeRepeater::objectList() { QDeclarativeView *canvas = createView(); - QObjectList data; - for(int i=0; i<100; i++){ - data << new QObject(); - data.back()->setProperty("idx", i); - } + for(int i=0; i<100; i++) + data << new MyObject(i); QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testData", QVariant::fromValue(data)); diff --git a/tests/auto/declarative/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro b/tests/auto/declarative/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro index 80b757d..6b98f1e 100644 --- a/tests/auto/declarative/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro +++ b/tests/auto/declarative/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro @@ -5,7 +5,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativesmoothedanimation.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro b/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro index 7f737c2..eb7d793 100644 --- a/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro +++ b/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro @@ -5,7 +5,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativesmoothedfollow.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro b/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro index 6f400a3..6ed8924 100644 --- a/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro +++ b/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro @@ -5,7 +5,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativespringfollow.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro b/tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro index 3ff4529..9cdb884 100644 --- a/tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro +++ b/tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro @@ -6,7 +6,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativesqldatabase.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativestates/data/signalOverrideCrash2.qml b/tests/auto/declarative/qdeclarativestates/data/signalOverrideCrash2.qml new file mode 100644 index 0000000..2215ee4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativestates/data/signalOverrideCrash2.qml @@ -0,0 +1,24 @@ +import Qt 4.7 + +Rectangle { + id: myRect + width: 400 + height: 400 + + states: [ + State { + name: "state1" + PropertyChanges { + target: myRect + onHeightChanged: console.log("Hello World") + color: "green" + } + }, + State { + name: "state2"; extend: "state1" + PropertyChanges { + target: myRect + color: "red" + } + }] +} diff --git a/tests/auto/declarative/qdeclarativestates/data/unnamedWhen.qml b/tests/auto/declarative/qdeclarativestates/data/unnamedWhen.qml new file mode 100644 index 0000000..a70840c --- /dev/null +++ b/tests/auto/declarative/qdeclarativestates/data/unnamedWhen.qml @@ -0,0 +1,14 @@ +import Qt 4.7 + +Rectangle { + id: theRect + property bool triggerState: false + property string stateString: "" + states: State { + when: triggerState + PropertyChanges { + target: theRect + stateString: "inState" + } + } +} diff --git a/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro b/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro index 706d045..6f4ecb3 100644 --- a/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro +++ b/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro @@ -5,6 +5,13 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativestates.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index a016fa7..ea074a4 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -47,6 +47,7 @@ #include <private/qdeclarativetext_p.h> #include <private/qdeclarativepropertychanges_p.h> #include <private/qdeclarativestategroup_p.h> +#include <private/qdeclarativeitem_p.h> class MyRect : public QDeclarativeRectangle @@ -86,6 +87,7 @@ private slots: void basicBinding(); void signalOverride(); void signalOverrideCrash(); + void signalOverrideCrash2(); void parentChange(); void parentChangeErrors(); void anchorChanges(); @@ -109,6 +111,7 @@ private slots: void illegalObjectCreation(); void whenOrdering(); void urlResolution(); + void unnamedWhen(); }; void tst_qdeclarativestates::initTestCase() @@ -128,63 +131,66 @@ void tst_qdeclarativestates::basicChanges() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); } { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges2.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - rect->setState("green"); + rectPrivate->setState("green"); QCOMPARE(rect->color(),QColor("green")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); - rect->setState("green"); + rectPrivate->setState("green"); QCOMPARE(rect->color(),QColor("green")); } { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges3.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); QCOMPARE(rect->border()->width(),1); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); QCOMPARE(rect->border()->width(),1); - rect->setState("bordered"); + rectPrivate->setState("bordered"); QCOMPARE(rect->color(),QColor("red")); QCOMPARE(rect->border()->width(),2); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); QCOMPARE(rect->border()->width(),1); //### we should be checking that this is an implicit rather than explicit 1 (which currently fails) - rect->setState("bordered"); + rectPrivate->setState("bordered"); QCOMPARE(rect->color(),QColor("red")); QCOMPARE(rect->border()->width(),2); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); QCOMPARE(rect->border()->width(),1); @@ -220,32 +226,33 @@ void tst_qdeclarativestates::basicExtension() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicExtension.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); QCOMPARE(rect->border()->width(),1); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); QCOMPARE(rect->border()->width(),1); - rect->setState("bordered"); + rectPrivate->setState("bordered"); QCOMPARE(rect->color(),QColor("blue")); QCOMPARE(rect->border()->width(),2); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); QCOMPARE(rect->border()->width(),1); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); QCOMPARE(rect->border()->width(),1); - rect->setState("bordered"); + rectPrivate->setState("bordered"); QCOMPARE(rect->color(),QColor("blue")); QCOMPARE(rect->border()->width(),2); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); QCOMPARE(rect->border()->width(),1); } @@ -253,26 +260,27 @@ void tst_qdeclarativestates::basicExtension() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/fakeExtension.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - rect->setState("green"); + rectPrivate->setState("green"); QCOMPARE(rect->color(),QColor("green")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - rect->setState("green"); + rectPrivate->setState("green"); QCOMPARE(rect->color(),QColor("green")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); - rect->setState("green"); + rectPrivate->setState("green"); QCOMPARE(rect->color(),QColor("green")); } } @@ -284,77 +292,80 @@ void tst_qdeclarativestates::basicBinding() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); rect->setProperty("sourceColor", QColor("green")); QCOMPARE(rect->color(),QColor("green")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); rect->setProperty("sourceColor", QColor("yellow")); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("yellow")); } { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding2.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); rect->setProperty("sourceColor", QColor("green")); QCOMPARE(rect->color(),QColor("blue")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("green")); rect->setProperty("sourceColor", QColor("yellow")); QCOMPARE(rect->color(),QColor("yellow")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("yellow")); } { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding3.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); rect->setProperty("sourceColor", QColor("green")); QCOMPARE(rect->color(),QColor("green")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); rect->setProperty("sourceColor", QColor("red")); QCOMPARE(rect->color(),QColor("blue")); rect->setProperty("sourceColor2", QColor("yellow")); QCOMPARE(rect->color(),QColor("yellow")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); rect->setProperty("sourceColor2", QColor("green")); QCOMPARE(rect->color(),QColor("red")); @@ -365,27 +376,28 @@ void tst_qdeclarativestates::basicBinding() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding4.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); rect->setProperty("sourceColor", QColor("yellow")); QCOMPARE(rect->color(),QColor("yellow")); - rect->setState("green"); + rectPrivate->setState("green"); QCOMPARE(rect->color(),QColor("green")); rect->setProperty("sourceColor", QColor("purple")); QCOMPARE(rect->color(),QColor("green")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("purple")); - rect->setState("green"); + rectPrivate->setState("green"); QCOMPARE(rect->color(),QColor("green")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); } } @@ -403,7 +415,7 @@ void tst_qdeclarativestates::signalOverride() rect->doSomething(); QCOMPARE(rect->color(),QColor("blue")); - rect->setState("green"); + QDeclarativeItemPrivate::get(rect)->setState("green"); rect->doSomething(); QCOMPARE(rect->color(),QColor("green")); } @@ -418,8 +430,7 @@ void tst_qdeclarativestates::signalOverride() QCOMPARE(rect->color(),QColor("blue")); QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("extendedRect")); - - innerRect->setState("green"); + QDeclarativeItemPrivate::get(innerRect)->setState("green"); rect->doSomething(); QCOMPARE(rect->color(),QColor("blue")); QCOMPARE(innerRect->color(),QColor("green")); @@ -435,10 +446,25 @@ void tst_qdeclarativestates::signalOverrideCrash() MyRect *rect = qobject_cast<MyRect*>(rectComponent.create()); QVERIFY(rect != 0); - rect->setState("overridden"); + QDeclarativeItemPrivate::get(rect)->setState("overridden"); rect->doSomething(); } +void tst_qdeclarativestates::signalOverrideCrash2() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverrideCrash2.qml"); + QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); + QVERIFY(rect != 0); + + QDeclarativeItemPrivate::get(rect)->setState("state1"); + QDeclarativeItemPrivate::get(rect)->setState("state2"); + QDeclarativeItemPrivate::get(rect)->setState("state1"); + + delete rect; +} + void tst_qdeclarativestates::parentChange() { QDeclarativeEngine engine; @@ -463,7 +489,7 @@ void tst_qdeclarativestates::parentChange() QCOMPARE(pChange->parent(), nParent); - rect->setState("reparented"); + QDeclarativeItemPrivate::get(rect)->setState("reparented"); QCOMPARE(innerRect->rotation(), qreal(0)); QCOMPARE(innerRect->scale(), qreal(1)); QCOMPARE(innerRect->x(), qreal(-133)); @@ -474,11 +500,11 @@ void tst_qdeclarativestates::parentChange() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange2.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); QVERIFY(rect != 0); - + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect")); QVERIFY(innerRect != 0); - rect->setState("reparented"); + rectPrivate->setState("reparented"); QCOMPARE(innerRect->rotation(), qreal(15)); QCOMPARE(innerRect->scale(), qreal(.5)); QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-19.9075)); @@ -489,17 +515,17 @@ void tst_qdeclarativestates::parentChange() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange3.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); QVERIFY(rect != 0); - + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect")); QVERIFY(innerRect != 0); - rect->setState("reparented"); + rectPrivate->setState("reparented"); QCOMPARE(innerRect->rotation(), qreal(-37)); QCOMPARE(innerRect->scale(), qreal(.25)); QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-217.305)); QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-164.413)); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(innerRect->rotation(), qreal(0)); QCOMPARE(innerRect->scale(), qreal(1)); QCOMPARE(innerRect->x(), qreal(5)); @@ -521,7 +547,7 @@ void tst_qdeclarativestates::parentChangeErrors() QVERIFY(innerRect != 0); QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/parentChange4.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under non-uniform scale"); - rect->setState("reparented"); + QDeclarativeItemPrivate::get(rect)->setState("reparented"); QCOMPARE(innerRect->rotation(), qreal(0)); QCOMPARE(innerRect->scale(), qreal(1)); QCOMPARE(innerRect->x(), qreal(5)); @@ -537,7 +563,7 @@ void tst_qdeclarativestates::parentChangeErrors() QVERIFY(innerRect != 0); QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/parentChange5.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under complex transform"); - rect->setState("reparented"); + QDeclarativeItemPrivate::get(rect)->setState("reparented"); QCOMPARE(innerRect->rotation(), qreal(0)); QCOMPARE(innerRect->scale(), qreal(1)); QCOMPARE(innerRect->x(), qreal(5)); @@ -552,6 +578,7 @@ void tst_qdeclarativestates::anchorChanges() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges1.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect")); QVERIFY(innerRect != 0); @@ -564,14 +591,14 @@ void tst_qdeclarativestates::anchorChanges() QDeclarativeAnchorChanges *aChanges = qobject_cast<QDeclarativeAnchorChanges*>(state->operationAt(0)); QVERIFY(aChanges != 0); - rect->setState("right"); + rectPrivate->setState("right"); QCOMPARE(innerRect->x(), qreal(150)); QCOMPARE(aChanges->object(), qobject_cast<QDeclarativeItem*>(innerRect)); - QCOMPARE(aChanges->object()->anchors()->left().anchorLine, QDeclarativeAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all) - QCOMPARE(aChanges->object()->anchors()->right().item, rect->right().item); - QCOMPARE(aChanges->object()->anchors()->right().anchorLine, rect->right().anchorLine); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QDeclarativeAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all) + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(innerRect->x(), qreal(5)); delete rect; @@ -584,14 +611,15 @@ void tst_qdeclarativestates::anchorChanges2() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges2.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect")); QVERIFY(innerRect != 0); - rect->setState("right"); + rectPrivate->setState("right"); QCOMPARE(innerRect->x(), qreal(150)); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(innerRect->x(), qreal(5)); delete rect; @@ -604,6 +632,7 @@ void tst_qdeclarativestates::anchorChanges3() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges3.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect")); QVERIFY(innerRect != 0); @@ -622,23 +651,23 @@ void tst_qdeclarativestates::anchorChanges3() QDeclarativeAnchorChanges *aChanges = qobject_cast<QDeclarativeAnchorChanges*>(state->operationAt(0)); QVERIFY(aChanges != 0); - rect->setState("reanchored"); + rectPrivate->setState("reanchored"); QCOMPARE(aChanges->object(), qobject_cast<QDeclarativeItem*>(innerRect)); - QCOMPARE(aChanges->object()->anchors()->left().item, leftGuideline->left().item); - QCOMPARE(aChanges->object()->anchors()->left().anchorLine, leftGuideline->left().anchorLine); - QCOMPARE(aChanges->object()->anchors()->right().item, rect->right().item); - QCOMPARE(aChanges->object()->anchors()->right().anchorLine, rect->right().anchorLine); - QCOMPARE(aChanges->object()->anchors()->top().item, rect->top().item); - QCOMPARE(aChanges->object()->anchors()->top().anchorLine, rect->top().anchorLine); - QCOMPARE(aChanges->object()->anchors()->bottom().item, bottomGuideline->bottom().item); - QCOMPARE(aChanges->object()->anchors()->bottom().anchorLine, bottomGuideline->bottom().anchorLine); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().item, QDeclarativeItemPrivate::get(leftGuideline)->left().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QDeclarativeItemPrivate::get(leftGuideline)->left().anchorLine); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->bottom().item, QDeclarativeItemPrivate::get(bottomGuideline)->bottom().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QDeclarativeItemPrivate::get(bottomGuideline)->bottom().anchorLine); QCOMPARE(innerRect->x(), qreal(10)); QCOMPARE(innerRect->y(), qreal(0)); QCOMPARE(innerRect->width(), qreal(190)); QCOMPARE(innerRect->height(), qreal(150)); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(innerRect->x(), qreal(0)); QCOMPARE(innerRect->y(), qreal(10)); QCOMPARE(innerRect->width(), qreal(150)); @@ -672,12 +701,12 @@ void tst_qdeclarativestates::anchorChanges4() QDeclarativeAnchorChanges *aChanges = qobject_cast<QDeclarativeAnchorChanges*>(state->operationAt(0)); QVERIFY(aChanges != 0); - rect->setState("reanchored"); + QDeclarativeItemPrivate::get(rect)->setState("reanchored"); QCOMPARE(aChanges->object(), qobject_cast<QDeclarativeItem*>(innerRect)); - QCOMPARE(aChanges->object()->anchors()->horizontalCenter().item, bottomGuideline->horizontalCenter().item); - QCOMPARE(aChanges->object()->anchors()->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine); - QCOMPARE(aChanges->object()->anchors()->verticalCenter().item, leftGuideline->verticalCenter().item); - QCOMPARE(aChanges->object()->anchors()->verticalCenter().anchorLine, leftGuideline->verticalCenter().anchorLine); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().item, QDeclarativeItemPrivate::get(bottomGuideline)->horizontalCenter().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().anchorLine, QDeclarativeItemPrivate::get(bottomGuideline)->horizontalCenter().anchorLine); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->verticalCenter().item, QDeclarativeItemPrivate::get(leftGuideline)->verticalCenter().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->verticalCenter().anchorLine, QDeclarativeItemPrivate::get(leftGuideline)->verticalCenter().anchorLine); delete rect; } @@ -707,7 +736,7 @@ void tst_qdeclarativestates::anchorChanges5() QDeclarativeAnchorChanges *aChanges = qobject_cast<QDeclarativeAnchorChanges*>(state->operationAt(0)); QVERIFY(aChanges != 0); - rect->setState("reanchored"); + QDeclarativeItemPrivate::get(rect)->setState("reanchored"); QCOMPARE(aChanges->object(), qobject_cast<QDeclarativeItem*>(innerRect)); //QCOMPARE(aChanges->anchors()->horizontalCenter().item, bottomGuideline->horizontalCenter().item); //QCOMPARE(aChanges->anchors()->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine); @@ -726,7 +755,7 @@ void tst_qdeclarativestates::anchorChangesCrash() QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); QVERIFY(rect != 0); - rect->setState("reanchored"); + QDeclarativeItemPrivate::get(rect)->setState("reanchored"); delete rect; } @@ -739,13 +768,13 @@ void tst_qdeclarativestates::script() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/script.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); QVERIFY(rect != 0); - + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("blue")); // a script isn't reverted } } @@ -757,13 +786,13 @@ void tst_qdeclarativestates::restoreEntryValues() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/restoreEntryValues.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); QVERIFY(rect != 0); - + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("blue")); } @@ -774,7 +803,7 @@ void tst_qdeclarativestates::explicitChanges() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/explicit.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); QVERIFY(rect != 0); - + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QDeclarativeListReference list(rect, "states"); QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0)); QVERIFY(state != 0); @@ -786,18 +815,18 @@ void tst_qdeclarativestates::explicitChanges() QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); rect->setProperty("sourceColor", QColor("green")); QCOMPARE(rect->color(),QColor("blue")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); rect->setProperty("sourceColor", QColor("yellow")); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("yellow")); } @@ -812,7 +841,7 @@ void tst_qdeclarativestates::propertyErrors() QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\""); QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to read-only property \"wantsFocus\""); - rect->setState("blue"); + QDeclarativeItemPrivate::get(rect)->setState("blue"); } void tst_qdeclarativestates::incorrectRestoreBug() @@ -822,22 +851,22 @@ void tst_qdeclarativestates::incorrectRestoreBug() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); QVERIFY(rect != 0); - + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); // make sure if we change the base state value, we then restore to it correctly rect->setColor(QColor("green")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("green")); } @@ -865,12 +894,12 @@ void tst_qdeclarativestates::deletingChange() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/deleting.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); QVERIFY(rect != 0); - - rect->setState("blue"); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); QCOMPARE(rect->radius(),qreal(5)); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); QCOMPARE(rect->radius(),qreal(0)); @@ -883,7 +912,7 @@ void tst_qdeclarativestates::deletingChange() qmlExecuteDeferred(state); QCOMPARE(state->operationCount(), 1); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("red")); QCOMPARE(rect->radius(),qreal(5)); @@ -928,11 +957,11 @@ void tst_qdeclarativestates::tempState() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/legalTempState.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); QVERIFY(rect != 0); - + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QTest::ignoreMessage(QtDebugMsg, "entering placed"); QTest::ignoreMessage(QtDebugMsg, "entering idle"); - rect->setState("placed"); - QCOMPARE(rect->state(), QLatin1String("idle")); + rectPrivate->setState("placed"); + QCOMPARE(rectPrivate->state(), QLatin1String("idle")); } void tst_qdeclarativestates::illegalTempState() @@ -942,10 +971,10 @@ void tst_qdeclarativestates::illegalTempState() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/illegalTempState.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); QVERIFY(rect != 0); - + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML StateGroup: Can't apply a state change as part of a state definition."); - rect->setState("placed"); - QCOMPARE(rect->state(), QLatin1String("placed")); + rectPrivate->setState("placed"); + QCOMPARE(rectPrivate->state(), QLatin1String("placed")); } void tst_qdeclarativestates::nonExistantProperty() @@ -955,10 +984,10 @@ void tst_qdeclarativestates::nonExistantProperty() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/nonExistantProp.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); QVERIFY(rect != 0); - + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/nonExistantProp.qml") + ":9:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\""); - rect->setState("blue"); - QCOMPARE(rect->state(), QLatin1String("blue")); + rectPrivate->setState("blue"); + QCOMPARE(rectPrivate->state(), QLatin1String("blue")); } void tst_qdeclarativestates::reset() @@ -974,7 +1003,7 @@ void tst_qdeclarativestates::reset() QCOMPARE(text->width(), qreal(40.)); QVERIFY(text->width() < text->height()); - rect->setState("state1"); + QDeclarativeItemPrivate::get(rect)->setState("state1"); QVERIFY(text->width() > 41); QVERIFY(text->width() > text->height()); @@ -1000,19 +1029,20 @@ void tst_qdeclarativestates::whenOrdering() QDeclarativeComponent c(&engine, SRCDIR "/data/whenOrdering.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QCOMPARE(rect->state(), QLatin1String("")); + QCOMPARE(rectPrivate->state(), QLatin1String("")); rect->setProperty("condition2", true); - QCOMPARE(rect->state(), QLatin1String("state2")); + QCOMPARE(rectPrivate->state(), QLatin1String("state2")); rect->setProperty("condition1", true); - QCOMPARE(rect->state(), QLatin1String("state1")); + QCOMPARE(rectPrivate->state(), QLatin1String("state1")); rect->setProperty("condition2", false); - QCOMPARE(rect->state(), QLatin1String("state1")); + QCOMPARE(rectPrivate->state(), QLatin1String("state1")); rect->setProperty("condition2", true); - QCOMPARE(rect->state(), QLatin1String("state1")); + QCOMPARE(rectPrivate->state(), QLatin1String("state1")); rect->setProperty("condition1", false); rect->setProperty("condition2", false); - QCOMPARE(rect->state(), QLatin1String("")); + QCOMPARE(rectPrivate->state(), QLatin1String("")); } void tst_qdeclarativestates::urlResolution() @@ -1029,13 +1059,32 @@ void tst_qdeclarativestates::urlResolution() QDeclarativeImage *image3 = rect->findChild<QDeclarativeImage*>("image3"); QVERIFY(myType != 0 && image1 != 0 && image2 != 0 && image3 != 0); - myType->setState("SetImageState"); + QDeclarativeItemPrivate::get(myType)->setState("SetImageState"); QUrl resolved = QUrl::fromLocalFile(SRCDIR "/data/Implementation/images/qt-logo.png"); QCOMPARE(image1->source(), resolved); QCOMPARE(image2->source(), resolved); QCOMPARE(image3->source(), resolved); } +void tst_qdeclarativestates::unnamedWhen() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, SRCDIR "/data/unnamedWhen.qml"); + QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + + QCOMPARE(rectPrivate->state(), QLatin1String("")); + QCOMPARE(rect->property("stateString").toString(), QLatin1String("")); + rect->setProperty("triggerState", true); + QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1")); + QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState")); + rect->setProperty("triggerState", false); + QCOMPARE(rectPrivate->state(), QLatin1String("")); + QCOMPARE(rect->property("stateString").toString(), QLatin1String("")); +} + QTEST_MAIN(tst_qdeclarativestates) #include "tst_qdeclarativestates.moc" diff --git a/tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro b/tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro index b2705fa..786bc1b 100644 --- a/tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro +++ b/tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro @@ -4,5 +4,12 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativesystempalette.cpp +# Define SRCDIR equal to test's source directory +symbian: { + DEFINES += SRCDIR=\".\" +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro b/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro index e70443e..51c7f43 100644 --- a/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro +++ b/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro @@ -9,7 +9,14 @@ INCLUDEPATH += ../shared/ HEADERS += ../shared/testhttpserver.h SOURCES += ../shared/testhttpserver.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativetextedit/data/geometrySignals.qml b/tests/auto/declarative/qdeclarativetextedit/data/geometrySignals.qml new file mode 100644 index 0000000..b39ba5b --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/geometrySignals.qml @@ -0,0 +1,12 @@ +import Qt 4.7 + +Item { + width: 400; height: 500; + property int bindingWidth: text.width + property int bindingHeight: text.height + + TextInput { + id: text + anchors.fill: parent + } +} diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_default.qml b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_default.qml new file mode 100644 index 0000000..f1cf86c --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_default.qml @@ -0,0 +1,7 @@ +import Qt 4.7 + +TextEdit { + focus: true + text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + selectByMouse: false +} diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_false.qml b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_false.qml new file mode 100644 index 0000000..f1cf86c --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_false.qml @@ -0,0 +1,7 @@ +import Qt 4.7 + +TextEdit { + focus: true + text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + selectByMouse: false +} diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_true.qml b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_true.qml new file mode 100644 index 0000000..90383b9 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_true.qml @@ -0,0 +1,7 @@ +import Qt 4.7 + +TextEdit { + focus: true + text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + selectByMouse: true +} diff --git a/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro b/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro index 2228f11..2adb2b8 100644 --- a/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro +++ b/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro @@ -6,4 +6,11 @@ SOURCES += tst_qdeclarativetextedit.cpp ../shared/testhttpserver.cpp HEADERS += ../shared/testhttpserver.h # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 3307b7c..4befc4c 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -76,6 +76,8 @@ private slots: void persistentSelection(); void focusOnPress(); void selection(); + void mouseSelection_data(); + void mouseSelection(); void inputMethodHints(); void cursorDelegate(); @@ -84,7 +86,7 @@ private slots: void navigation(); void readOnly(); void sendRequestSoftwareInputPanelEvent(); - + void geometrySignals(); private: void simulateKey(QDeclarativeView *, int key); QDeclarativeView *createView(const QString &filename); @@ -202,7 +204,7 @@ void tst_qdeclarativetextedit::width() QFont f; QFontMetricsF fm(f); qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width(); - metricWidth = floor(metricWidth); + metricWidth = ceil(metricWidth); QString componentStr = "import Qt 4.7\nTextEdit { text: \"" + standard.at(i) + "\" }"; QDeclarativeComponent texteditComponent(&engine); @@ -219,7 +221,7 @@ void tst_qdeclarativetextedit::width() document.setHtml(richText.at(i)); document.setDocumentMargin(0); - int documentWidth = document.idealWidth(); + int documentWidth = ceil(document.idealWidth()); QString componentStr = "import Qt 4.7\nTextEdit { text: \"" + richText.at(i) + "\" }"; QDeclarativeComponent texteditComponent(&engine); @@ -602,6 +604,49 @@ void tst_qdeclarativetextedit::selection() QVERIFY(textEditObject->selectedText().size() == 10); } +void tst_qdeclarativetextedit::mouseSelection_data() +{ + QTest::addColumn<QString>("qmlfile"); + QTest::addColumn<bool>("expectSelection"); + + // import installed + QTest::newRow("on") << SRCDIR "/data/mouseselection_true.qml" << true; + QTest::newRow("off") << SRCDIR "/data/mouseselection_false.qml" << false; + QTest::newRow("default") << SRCDIR "/data/mouseselection_default.qml" << false; +} + +void tst_qdeclarativetextedit::mouseSelection() +{ + QFETCH(QString, qmlfile); + QFETCH(bool, expectSelection); + + QDeclarativeView *canvas = createView(qmlfile); + + canvas->show(); + QApplication::setActiveWindow(canvas); + QTest::qWaitForWindowShown(canvas); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas)); + + QVERIFY(canvas->rootObject() != 0); + QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit *>(canvas->rootObject()); + QVERIFY(textEditObject != 0); + + // press-and-drag-and-release from x1 to x2 + int x1 = 10; + int x2 = 70; + int y = textEditObject->height()/2; + QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y))); + //QTest::mouseMove(canvas->viewport(), canvas->mapFromScene(QPoint(x2,y))); // doesn't work + QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas->viewport(), &mv); + QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y))); + QString str = textEditObject->selectedText(); + if (expectSelection) + QVERIFY(str.length() > 3); // don't reallly care *what* was selected (and it's too sensitive to platform) + else + QVERIFY(str.isEmpty()); +} + void tst_qdeclarativetextedit::inputMethodHints() { QDeclarativeView *canvas = createView(SRCDIR "/data/inputmethodhints.qml"); @@ -793,8 +838,6 @@ void tst_qdeclarativetextedit::sendRequestSoftwareInputPanelEvent() view.viewport()->setInputContext(&ic); QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel( view.style()->styleHint(QStyle::SH_RequestSoftwareInputPanel)); - if ((behavior != QStyle::RSIP_OnMouseClick)) - QSKIP("This test need to have a style with RSIP_OnMouseClick", SkipSingle); QDeclarativeTextEdit edit; edit.setText("Hello world"); edit.setPos(0, 0); @@ -806,8 +849,26 @@ void tst_qdeclarativetextedit::sendRequestSoftwareInputPanelEvent() QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view)); QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); QApplication::processEvents(); - QCOMPARE(ic.softwareInputPanelEventReceived, true); + if (behavior == QStyle::RSIP_OnMouseClickAndAlreadyFocused) { + QCOMPARE(ic.softwareInputPanelEventReceived, false); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); + QApplication::processEvents(); + QCOMPARE(ic.softwareInputPanelEventReceived, true); + } else if (behavior == QStyle::RSIP_OnMouseClick) { + QCOMPARE(ic.softwareInputPanelEventReceived, true); + } +} + +void tst_qdeclarativetextedit::geometrySignals() +{ + QDeclarativeComponent component(&engine, SRCDIR "/data/geometrySignals.qml"); + QObject *o = component.create(); + QVERIFY(o); + QCOMPARE(o->property("bindingWidth").toInt(), 400); + QCOMPARE(o->property("bindingHeight").toInt(), 500); + delete o; } + QTEST_MAIN(tst_qdeclarativetextedit) #include "tst_qdeclarativetextedit.moc" diff --git a/tests/auto/declarative/qdeclarativetextinput/data/geometrySignals.qml b/tests/auto/declarative/qdeclarativetextinput/data/geometrySignals.qml new file mode 100644 index 0000000..a9b50fe --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextinput/data/geometrySignals.qml @@ -0,0 +1,12 @@ +import Qt 4.7 + +Item { + width: 400; height: 500; + property int bindingWidth: text.width + property int bindingHeight: text.height + + TextEdit { + id: text + anchors.fill: parent + } +} diff --git a/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro b/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro index 957e75c..2953567 100644 --- a/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro +++ b/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro @@ -5,5 +5,12 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativetextinput.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 83ebe6c..ac80edb 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -76,6 +76,7 @@ private slots: void focusOutClearSelection(); void echoMode(); + void geometrySignals(); private: void simulateKey(QDeclarativeView *, int key); QDeclarativeView *createView(const QString &filename); @@ -575,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; } @@ -734,8 +743,6 @@ void tst_qdeclarativetextinput::sendRequestSoftwareInputPanelEvent() view.viewport()->setInputContext(&ic); QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel( view.style()->styleHint(QStyle::SH_RequestSoftwareInputPanel)); - if ((behavior != QStyle::RSIP_OnMouseClick)) - QSKIP("This test need to have a style with RSIP_OnMouseClick", SkipSingle); QDeclarativeTextInput input; input.setText("Hello world"); input.setPos(0, 0); @@ -747,7 +754,14 @@ void tst_qdeclarativetextinput::sendRequestSoftwareInputPanelEvent() QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view)); QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); QApplication::processEvents(); - QCOMPARE(ic.softwareInputPanelEventReceived, true); + if (behavior == QStyle::RSIP_OnMouseClickAndAlreadyFocused) { + QCOMPARE(ic.softwareInputPanelEventReceived, false); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); + QApplication::processEvents(); + QCOMPARE(ic.softwareInputPanelEventReceived, true); + } else if (behavior == QStyle::RSIP_OnMouseClick) { + QCOMPARE(ic.softwareInputPanelEventReceived, true); + } } class MyTextInput : public QDeclarativeTextInput @@ -805,6 +819,16 @@ void tst_qdeclarativetextinput::focusOutClearSelection() QTRY_COMPARE(input.selectedText(), QLatin1String("")); } +void tst_qdeclarativetextinput::geometrySignals() +{ + QDeclarativeComponent component(&engine, SRCDIR "/data/geometrySignals.qml"); + QObject *o = component.create(); + QVERIFY(o); + QCOMPARE(o->property("bindingWidth").toInt(), 400); + QCOMPARE(o->property("bindingHeight").toInt(), 500); + delete o; +} + QTEST_MAIN(tst_qdeclarativetextinput) #include "tst_qdeclarativetextinput.moc" diff --git a/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro b/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro index 42604d8..d95165c 100644 --- a/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro +++ b/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro @@ -4,6 +4,10 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativetimer.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.5.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.5.qml new file mode 100644 index 0000000..a66e9d6 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.5.qml @@ -0,0 +1,10 @@ +import Test 1.0 +import Qt 4.7 as MyQt + +MyTypeObject { + MyQt.Component.onCompleted: { + font.capitalization = MyQt.Font.AllUppercase + } +} + + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_read.qml new file mode 100644 index 0000000..6c4a682 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_read.qml @@ -0,0 +1,22 @@ +import Test 1.0 + +MyTypeObject { + property real v_m11: matrix.m11 + property real v_m12: matrix.m12 + property real v_m13: matrix.m13 + property real v_m14: matrix.m14 + property real v_m21: matrix.m21 + property real v_m22: matrix.m22 + property real v_m23: matrix.m23 + property real v_m24: matrix.m24 + property real v_m31: matrix.m31 + property real v_m32: matrix.m32 + property real v_m33: matrix.m33 + property real v_m34: matrix.m34 + property real v_m41: matrix.m41 + property real v_m42: matrix.m42 + property real v_m43: matrix.m43 + property real v_m44: matrix.m44 + property variant copy: matrix +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_write.qml new file mode 100644 index 0000000..2a9f154 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_write.qml @@ -0,0 +1,21 @@ +import Test 1.0 + +MyTypeObject { + matrix.m11: if (true) 11 + matrix.m12: if (true) 12 + matrix.m13: if (true) 13 + matrix.m14: if (true) 14 + matrix.m21: if (true) 21 + matrix.m22: if (true) 22 + matrix.m23: if (true) 23 + matrix.m24: if (true) 24 + matrix.m31: if (true) 31 + matrix.m32: if (true) 32 + matrix.m33: if (true) 33 + matrix.m34: if (true) 34 + matrix.m41: if (true) 41 + matrix.m42: if (true) 42 + matrix.m43: if (true) 43 + matrix.m44: if (true) 44 +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_read.qml new file mode 100644 index 0000000..d1a21dc --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_read.qml @@ -0,0 +1,10 @@ +import Test 1.0 + +MyTypeObject { + property real v_scalar: quaternion.scalar + property real v_x: quaternion.x + property real v_y: quaternion.y + property real v_z: quaternion.z + property variant copy: quaternion +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_write.qml new file mode 100644 index 0000000..0c3e5af --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_write.qml @@ -0,0 +1,9 @@ +import Test 1.0 + +MyTypeObject { + quaternion.scalar: if (true) 88.5 + quaternion.x: if (true) -0.3 + quaternion.y: if (true) -12.9 + quaternion.z: if (true) 907.4 +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/varAssignment.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/varAssignment.qml new file mode 100644 index 0000000..e4715ab --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/varAssignment.qml @@ -0,0 +1,14 @@ +import Qt 4.7 + +QtObject { + property int x; + property int y; + property int z; + + Component.onCompleted: { + var vec3 = Qt.vector3d(1, 2, 3); + x = vec3.x; + y = vec3.y; + z = vec3.z; + } +} diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_read.qml new file mode 100644 index 0000000..fc315f7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_read.qml @@ -0,0 +1,8 @@ +import Test 1.0 + +MyTypeObject { + property real v_x: vector2.x + property real v_y: vector2.y + property variant copy: vector2 +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_write.qml new file mode 100644 index 0000000..f0e35ff --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_write.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + vector2.x: if (true) -0.3 + vector2.y: if (true) -12.9 +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_read.qml new file mode 100644 index 0000000..f9d5d60 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_read.qml @@ -0,0 +1,10 @@ +import Test 1.0 + +MyTypeObject { + property real v_x: vector4.x + property real v_y: vector4.y + property real v_z: vector4.z + property real v_w: vector4.w + property variant copy: vector4 +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_write.qml new file mode 100644 index 0000000..5486981 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_write.qml @@ -0,0 +1,9 @@ +import Test 1.0 + +MyTypeObject { + vector4.x: if (true) -0.3 + vector4.y: if (true) -12.9 + vector4.z: if (true) 907.4 + vector4.w: if (true) 88.5 +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro b/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro index d9f1c13..02c480c 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro +++ b/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro @@ -7,7 +7,14 @@ HEADERS += testtypes.h SOURCES += tst_qdeclarativevaluetypes.cpp \ testtypes.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h index 8a9b981..7ed3993 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h +++ b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h @@ -48,7 +48,11 @@ #include <QSizeF> #include <QRect> #include <QRectF> +#include <QVector2D> #include <QVector3D> +#include <QVector4D> +#include <QQuaternion> +#include <QMatrix4x4> #include <QFont> #include <qdeclarative.h> #include <QDeclarativePropertyValueSource> @@ -66,7 +70,11 @@ class MyTypeObject : public QObject Q_PROPERTY(QSize sizereadonly READ size NOTIFY changed) Q_PROPERTY(QRect rect READ rect WRITE setRect NOTIFY changed) Q_PROPERTY(QRectF rectf READ rectf WRITE setRectf NOTIFY changed) + Q_PROPERTY(QVector2D vector2 READ vector2 WRITE setVector2 NOTIFY changed) Q_PROPERTY(QVector3D vector READ vector WRITE setVector NOTIFY changed) + Q_PROPERTY(QVector4D vector4 READ vector4 WRITE setVector4 NOTIFY changed) + Q_PROPERTY(QQuaternion quaternion READ quaternion WRITE setQuaternion NOTIFY changed) + Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix NOTIFY changed) Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed) public: @@ -77,7 +85,11 @@ public: m_sizef(0.1, 100923.2), m_rect(2, 3, 109, 102), m_rectf(103.8, 99.2, 88.1, 77.6), - m_vector(23.88, 3.1, 4.3) + m_vector2(32.88, 1.3), + m_vector(23.88, 3.1, 4.3), + m_vector4(54.2, 23.88, 3.1, 4.3), + m_quaternion(4.3, 54.2, 23.88, 3.1), + m_matrix(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) { m_font.setFamily("Arial"); m_font.setBold(true); @@ -87,7 +99,7 @@ public: m_font.setOverline(true); m_font.setStrikeOut(true); m_font.setPointSize(29); - m_font.setCapitalization(QFont::AllUppercase); + m_font.setCapitalization(QFont::AllLowercase); m_font.setLetterSpacing(QFont::AbsoluteSpacing, 10.2); m_font.setWordSpacing(19.7); } @@ -116,10 +128,26 @@ public: QRectF rectf() const { return m_rectf; } void setRectf(const QRectF &v) { m_rectf = v; emit changed(); } + QVector2D m_vector2; + QVector2D vector2() const { return m_vector2; } + void setVector2(const QVector2D &v) { m_vector2 = v; emit changed(); } + QVector3D m_vector; QVector3D vector() const { return m_vector; } void setVector(const QVector3D &v) { m_vector = v; emit changed(); } + QVector4D m_vector4; + QVector4D vector4() const { return m_vector4; } + void setVector4(const QVector4D &v) { m_vector4 = v; emit changed(); } + + QQuaternion m_quaternion; + QQuaternion quaternion() const { return m_quaternion; } + void setQuaternion(const QQuaternion &v) { m_quaternion = v; emit changed(); } + + QMatrix4x4 m_matrix; + QMatrix4x4 matrix() const { return m_matrix; } + void setMatrix(const QMatrix4x4 &v) { m_matrix = v; emit changed(); } + QFont m_font; QFont font() const { return m_font; } void setFont(const QFont &v) { m_font = v; emit changed(); } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index b733b10..53fd68c 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -62,7 +62,11 @@ private slots: void sizereadonly(); void rect(); void rectf(); + void vector2d(); void vector3d(); + void vector4d(); + void quaternion(); + void matrix4x4(); void font(); void bindingAssignment(); @@ -80,6 +84,7 @@ private slots: void enums(); void conflictingBindings(); void returnValues(); + void varAssignment(); private: QDeclarativeEngine engine; @@ -293,6 +298,31 @@ void tst_qdeclarativevaluetypes::rectf() } } +void tst_qdeclarativevaluetypes::vector2d() +{ + { + QDeclarativeComponent component(&engine, TEST_FILE("vector2d_read.qml")); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + + QCOMPARE((float)object->property("v_x").toDouble(), (float)32.88); + QCOMPARE((float)object->property("v_y").toDouble(), (float)1.3); + QCOMPARE(object->property("copy"), QVariant(QVector2D(32.88, 1.3))); + + delete object; + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("vector2d_write.qml")); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->vector2(), QVector2D(-0.3, -12.9)); + + delete object; + } +} + void tst_qdeclarativevaluetypes::vector3d() { { @@ -319,6 +349,106 @@ void tst_qdeclarativevaluetypes::vector3d() } } +void tst_qdeclarativevaluetypes::vector4d() +{ + { + QDeclarativeComponent component(&engine, TEST_FILE("vector4d_read.qml")); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + + QCOMPARE((float)object->property("v_x").toDouble(), (float)54.2); + QCOMPARE((float)object->property("v_y").toDouble(), (float)23.88); + QCOMPARE((float)object->property("v_z").toDouble(), (float)3.1); + QCOMPARE((float)object->property("v_w").toDouble(), (float)4.3); + QCOMPARE(object->property("copy"), QVariant(QVector4D(54.2, 23.88, 3.1, 4.3))); + + delete object; + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("vector4d_write.qml")); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->vector4(), QVector4D(-0.3, -12.9, 907.4, 88.5)); + + delete object; + } +} + +void tst_qdeclarativevaluetypes::quaternion() +{ + { + QDeclarativeComponent component(&engine, TEST_FILE("quaternion_read.qml")); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + + QCOMPARE((float)object->property("v_scalar").toDouble(), (float)4.3); + QCOMPARE((float)object->property("v_x").toDouble(), (float)54.2); + QCOMPARE((float)object->property("v_y").toDouble(), (float)23.88); + QCOMPARE((float)object->property("v_z").toDouble(), (float)3.1); + QCOMPARE(object->property("copy"), QVariant(QQuaternion(4.3, 54.2, 23.88, 3.1))); + + delete object; + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("quaternion_write.qml")); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->quaternion(), QQuaternion(88.5, -0.3, -12.9, 907.4)); + + delete object; + } +} + +void tst_qdeclarativevaluetypes::matrix4x4() +{ + { + QDeclarativeComponent component(&engine, TEST_FILE("matrix4x4_read.qml")); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + + QCOMPARE((float)object->property("v_m11").toDouble(), (float)1); + QCOMPARE((float)object->property("v_m12").toDouble(), (float)2); + QCOMPARE((float)object->property("v_m13").toDouble(), (float)3); + QCOMPARE((float)object->property("v_m14").toDouble(), (float)4); + QCOMPARE((float)object->property("v_m21").toDouble(), (float)5); + QCOMPARE((float)object->property("v_m22").toDouble(), (float)6); + QCOMPARE((float)object->property("v_m23").toDouble(), (float)7); + QCOMPARE((float)object->property("v_m24").toDouble(), (float)8); + QCOMPARE((float)object->property("v_m31").toDouble(), (float)9); + QCOMPARE((float)object->property("v_m32").toDouble(), (float)10); + QCOMPARE((float)object->property("v_m33").toDouble(), (float)11); + QCOMPARE((float)object->property("v_m34").toDouble(), (float)12); + QCOMPARE((float)object->property("v_m41").toDouble(), (float)13); + QCOMPARE((float)object->property("v_m42").toDouble(), (float)14); + QCOMPARE((float)object->property("v_m43").toDouble(), (float)15); + QCOMPARE((float)object->property("v_m44").toDouble(), (float)16); + QCOMPARE(object->property("copy"), + QVariant(QMatrix4x4(1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16))); + + delete object; + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("matrix4x4_write.qml")); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->matrix(), QMatrix4x4(11, 12, 13, 14, + 21, 22, 23, 24, + 31, 32, 33, 34, + 41, 42, 43, 44)); + + delete object; + } +} + void tst_qdeclarativevaluetypes::font() { { @@ -665,7 +795,12 @@ void tst_qdeclarativevaluetypes::cppClasses() CPP_TEST(QDeclarativeSizeFValueType, QSizeF(-100.7, 18.2)); CPP_TEST(QDeclarativeRectValueType, QRect(13, 39, 10928, 88)); CPP_TEST(QDeclarativeRectFValueType, QRectF(88.2, -90.1, 103.2, 118)); + CPP_TEST(QDeclarativeVector2DValueType, QVector2D(19.7, 1002)); CPP_TEST(QDeclarativeVector3DValueType, QVector3D(18.2, 19.7, 1002)); + CPP_TEST(QDeclarativeVector4DValueType, QVector4D(18.2, 19.7, 1002, 54)); + CPP_TEST(QDeclarativeQuaternionValueType, QQuaternion(18.2, 19.7, 1002, 54)); + CPP_TEST(QDeclarativeMatrix4x4ValueType, + QMatrix4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)); CPP_TEST(QDeclarativeFontValueType, QFont("Helvetica")); } @@ -703,6 +838,14 @@ void tst_qdeclarativevaluetypes::enums() QVERIFY(object->font().capitalization() == QFont::AllUppercase); delete object; } + + { + QDeclarativeComponent component(&engine, TEST_FILE("enums.5.qml")); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + QVERIFY(object->font().capitalization() == QFont::AllUppercase); + delete object; + } } // Tests switching between "conflicting" bindings (eg. a binding on the core @@ -777,6 +920,19 @@ void tst_qdeclarativevaluetypes::returnValues() delete object; } +void tst_qdeclarativevaluetypes::varAssignment() +{ + QDeclarativeComponent component(&engine, TEST_FILE("varAssignment.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("x").toInt(), 1); + QCOMPARE(object->property("y").toInt(), 2); + QCOMPARE(object->property("z").toInt(), 3); + + delete object; +} + QTEST_MAIN(tst_qdeclarativevaluetypes) #include "tst_qdeclarativevaluetypes.moc" diff --git a/tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro b/tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro index d6be728..ad54713 100644 --- a/tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro +++ b/tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro @@ -4,4 +4,11 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeview.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} diff --git a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp index 1ed51c1..b183105 100644 --- a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp +++ b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp @@ -45,6 +45,7 @@ #include <QtDeclarative/qdeclarativeview.h> #include <QtDeclarative/qdeclarativeitem.h> #include <QtGui/qgraphicswidget.h> +#include "../../../shared/util.h" class tst_QDeclarativeView : public QObject @@ -106,9 +107,9 @@ void tst_QDeclarativeView::resizemodedeclarativeitem() // size update from root object declarativeItem->setWidth(250); declarativeItem->setHeight(350); - qApp->processEvents(); QCOMPARE(declarativeItem->width(), 250.0); QCOMPARE(declarativeItem->height(), 350.0); + QTRY_COMPARE(canvas->size(), QSize(250, 350)); QCOMPARE(canvas->size(), QSize(250, 350)); QCOMPARE(canvas->size(), canvas->sizeHint()); QCOMPARE(sceneResizedSpy.count(), 4); @@ -134,9 +135,9 @@ void tst_QDeclarativeView::resizemodedeclarativeitem() // size update from root object declarativeItem->setWidth(80); declarativeItem->setHeight(100); - qApp->processEvents(); QCOMPARE(declarativeItem->width(), 80.0); QCOMPARE(declarativeItem->height(), 100.0); + QTRY_COMPARE(canvas->size(), QSize(80, 100)); QCOMPARE(canvas->size(), QSize(80, 100)); QCOMPARE(canvas->size(), canvas->sizeHint()); QCOMPARE(sceneResizedSpy2.count(), 2); @@ -147,7 +148,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 +231,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/qdeclarativeviewer/qdeclarativeviewer.pro b/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro new file mode 100644 index 0000000..9bb6161 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro @@ -0,0 +1,18 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui +macx:CONFIG -= app_bundle + +include(../../../../tools/qml/qml.pri) + +SOURCES += tst_qdeclarativeviewer.cpp + +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + 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/qdeclarativevisualdatamodel/data/objectlist.qml b/tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml new file mode 100644 index 0000000..f5198c9 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml @@ -0,0 +1,16 @@ +import Qt 4.7 + +ListView { + width: 100 + height: 100 + anchors.fill: parent + model: myModel + delegate: Component { + Rectangle { + height: 25 + width: 100 + color: model.modelData.color + Text { objectName: "name"; text: name } + } + } +} diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro b/tests/auto/declarative/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro index d76b582..c87171b 100644 --- a/tests/auto/declarative/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro +++ b/tests/auto/declarative/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro @@ -4,8 +4,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativevisualdatamodel.cpp -# Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp index 7de15a3..8f3fb16 100644 --- a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp +++ b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp @@ -44,6 +44,10 @@ #include <QtDeclarative/qdeclarativeengine.h> #include <QtDeclarative/qdeclarativecomponent.h> #include <QtDeclarative/qdeclarativecontext.h> +#include <QtDeclarative/qdeclarativeexpression.h> +#include <QtDeclarative/qdeclarativeview.h> +#include <private/qdeclarativelistview_p.h> +#include <private/qdeclarativetext_p.h> #include <private/qdeclarativevisualitemmodel_p.h> #include <private/qdeclarativevaluetype_p.h> #include <math.h> @@ -74,9 +78,50 @@ public: private slots: void rootIndex(); + void objectListModel(); private: QDeclarativeEngine engine; + template<typename T> + T *findItem(QGraphicsObject *parent, const QString &objectName, int index); +}; + +class DataObject : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged) + +public: + DataObject(QObject *parent=0) : QObject(parent) {} + DataObject(const QString &name, const QString &color, QObject *parent=0) + : QObject(parent), m_name(name), m_color(color) { } + + + QString name() const { return m_name; } + void setName(const QString &name) { + if (name != m_name) { + m_name = name; + emit nameChanged(); + } + } + + QString color() const { return m_color; } + void setColor(const QString &color) { + if (color != m_color) { + m_color = color; + emit colorChanged(); + } + } + +signals: + void nameChanged(); + void colorChanged(); + +private: + QString m_name; + QString m_color; }; tst_qdeclarativevisualdatamodel::tst_qdeclarativevisualdatamodel() @@ -105,6 +150,60 @@ void tst_qdeclarativevisualdatamodel::rootIndex() delete obj; } +void tst_qdeclarativevisualdatamodel::objectListModel() +{ + QDeclarativeView view; + + QList<QObject*> dataList; + dataList.append(new DataObject("Item 1", "red")); + dataList.append(new DataObject("Item 2", "green")); + dataList.append(new DataObject("Item 3", "blue")); + dataList.append(new DataObject("Item 4", "yellow")); + + QDeclarativeContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); + + view.setSource(QUrl::fromLocalFile(SRCDIR "/data/objectlist.qml")); + + QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(view.rootObject()); + QVERIFY(listview != 0); + + QDeclarativeItem *viewport = listview->viewport(); + QVERIFY(viewport != 0); + + QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "name", 0); + QCOMPARE(name->text(), QString("Item 1")); + + dataList[0]->setProperty("name", QLatin1String("Changed")); + QCOMPARE(name->text(), QString("Changed")); +} + +template<typename T> +T *tst_qdeclarativevisualdatamodel::findItem(QGraphicsObject *parent, const QString &objectName, int index) +{ + const QMetaObject &mo = T::staticMetaObject; + //qDebug() << parent->childItems().count() << "children"; + for (int i = 0; i < parent->childItems().count(); ++i) { + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i)); + if(!item) + continue; + //qDebug() << "try" << item; + if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { + if (index != -1) { + QDeclarativeExpression e(qmlContext(item), item, "index"); + if (e.evaluate().toInt() == index) + return static_cast<T*>(item); + } else { + return static_cast<T*>(item); + } + } + item = findItem<T>(item, objectName, index); + if (item) + return static_cast<T*>(item); + } + + return 0; +} QTEST_MAIN(tst_qdeclarativevisualdatamodel) diff --git a/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro b/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro index 956272f..8caa393 100644 --- a/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro +++ b/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro @@ -6,6 +6,13 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativewebview.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro b/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro index 2e3da4d..36b3449 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro +++ b/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro @@ -5,7 +5,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeworkerscript.cpp # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro b/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro index 160300e..b54f670 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro @@ -8,9 +8,15 @@ HEADERS += ../shared/testhttpserver.h SOURCES += tst_qdeclarativexmlhttprequest.cpp \ ../shared/testhttpserver.cpp - # Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro b/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro index 8c5052a..1bf1c58 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro +++ b/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro @@ -8,7 +8,14 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativexmllistmodel.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp index 831e318..4173a44 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp +++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp @@ -238,7 +238,7 @@ void tst_qdeclarativexmllistmodel::roleErrors() QCOMPARE(data.value(Qt::UserRole+1), QVariant()); QCOMPARE(data.value(Qt::UserRole+2), QVariant()); - QEXPECT_FAIL("", "QT-2456", Continue); + QEXPECT_FAIL("", "QTBUG-10797", Continue); QCOMPARE(data.value(Qt::UserRole+3), QVariant()); delete model; diff --git a/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.0.png b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.0.png Binary files differnew file mode 100644 index 0000000..135911c --- /dev/null +++ b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.0.png diff --git a/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.1.png b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.1.png Binary files differnew file mode 100644 index 0000000..0d71292 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.1.png diff --git a/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.2.png b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.2.png Binary files differnew file mode 100644 index 0000000..920d992 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.2.png diff --git a/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.3.png b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.3.png Binary files differnew file mode 100644 index 0000000..1c4d89e --- /dev/null +++ b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.3.png diff --git a/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.qml b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.qml new file mode 100644 index 0000000..9e1b923 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.qml @@ -0,0 +1,1023 @@ +import Qt.VisualTest 4.7 + +VisualTest { + Frame { + msec: 0 + } + Frame { + msec: 16 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 32 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 48 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 64 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 80 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 96 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 112 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 128 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 144 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 160 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 176 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 192 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 208 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 224 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 240 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 256 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 272 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 288 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 304 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 320 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 336 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 352 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 368 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 384 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 400 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 416 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 432 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 448 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 464 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 480 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 496 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 512 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 528 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 544 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 560 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 576 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 592 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 608 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 624 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 640 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 656 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 672 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 688 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 704 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Mouse { + type: 2 + button: 1 + buttons: 1 + x: 350; y: 182 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 720 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 736 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 752 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 768 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 784 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 800 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Mouse { + type: 3 + button: 1 + buttons: 0 + x: 350; y: 182 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 816 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 832 + hash: "9b524b546d250d239ea99dd3319f3d6a" + } + Frame { + msec: 848 + hash: "593300f166c2fd3c325cb35114ca595b" + } + Frame { + msec: 864 + hash: "4451e76e111c99faa77b5fff9a2642fa" + } + Frame { + msec: 880 + hash: "0b4a5675afba935e17eba19e29b709ee" + } + Frame { + msec: 896 + hash: "8682866f0234eebf25aca27a7737c777" + } + Frame { + msec: 912 + hash: "5b3b70dd366bb4c1b5e7d56ce50e59a6" + } + Frame { + msec: 928 + hash: "897394982c93ebcbea68c25cec6d47d3" + } + Frame { + msec: 944 + hash: "23c3c0383a517d33767adeebc53bfa3a" + } + Frame { + msec: 960 + image: "parentAnimation2.0.png" + } + Frame { + msec: 976 + hash: "95b4fe1e5eeffe1673e199308e8ce76c" + } + Frame { + msec: 992 + hash: "dbb9a5aa9f569b97711aa2c1f5ebda47" + } + Frame { + msec: 1008 + hash: "0a5a73409b019e650ea860e1a8e27328" + } + Frame { + msec: 1024 + hash: "496bd0d053522bcf71d506b497ede0d5" + } + Frame { + msec: 1040 + hash: "97a32b4a6c99ffe842c35e903bd23d79" + } + Frame { + msec: 1056 + hash: "496dfbbb0c0c28e108adf4c25341ef11" + } + Frame { + msec: 1072 + hash: "aa2e5eb88b1498f0d36897be2a36b0ff" + } + Frame { + msec: 1088 + hash: "0c6f7b54264ab36cfd5145fb7b30432f" + } + Frame { + msec: 1104 + hash: "797fc3ea1db51f12d900b4e0e4998065" + } + Frame { + msec: 1120 + hash: "2b076b8bc1ec1e2f21a4d7a77c94cfeb" + } + Frame { + msec: 1136 + hash: "8d5888ca1cfba19cea569bd38bada417" + } + Frame { + msec: 1152 + hash: "15ae94de5aa106eaa18d0faefa5d61f5" + } + Frame { + msec: 1168 + hash: "96e90d74d5a7788d5a6da6cfdb92b185" + } + Frame { + msec: 1184 + hash: "5698a5e9e628209fc28644198eac65da" + } + Frame { + msec: 1200 + hash: "074ac8f08de8f22c241e23ad8b89b0f0" + } + Frame { + msec: 1216 + hash: "a49fdf41e9ee1e5d764262d4585af2ff" + } + Frame { + msec: 1232 + hash: "accc9b6573a676a40fcf0129085f6fce" + } + Frame { + msec: 1248 + hash: "1cc956d55f0c382c2f74dcc05a05494f" + } + Frame { + msec: 1264 + hash: "38ff3121566b2c719f47d027fcef8b8e" + } + Frame { + msec: 1280 + hash: "4de97b3361a16ca1710f2e75d5c9de6f" + } + Frame { + msec: 1296 + hash: "dbd1455105630bb8f262140e79ceda1b" + } + Frame { + msec: 1312 + hash: "bcdac4ab71a29b78bfa756b56b8d8414" + } + Frame { + msec: 1328 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1344 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1360 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1376 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1392 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1408 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1424 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1440 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1456 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1472 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1488 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1504 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1520 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1536 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1552 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1568 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1584 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1600 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1616 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1632 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1648 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1664 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1680 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1696 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1712 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Mouse { + type: 2 + button: 1 + buttons: 1 + x: 415; y: 121 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 1728 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1744 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1760 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1776 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1792 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1808 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1824 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Mouse { + type: 3 + button: 1 + buttons: 0 + x: 415; y: 121 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 1840 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1856 + hash: "b59fbcfb7db77cf30ea4ff039a9163ae" + } + Frame { + msec: 1872 + hash: "432a76f0663bfd35f6bbeb3fbeb91799" + } + Frame { + msec: 1888 + hash: "098e18005d3a2ff9095587954c92339c" + } + Frame { + msec: 1904 + hash: "069100bf4ec523a9e9d5bf557ffc51d1" + } + Frame { + msec: 1920 + image: "parentAnimation2.1.png" + } + Frame { + msec: 1936 + hash: "60ed700e49bf2c51aba9b44400b56294" + } + Frame { + msec: 1952 + hash: "79aa15dc74668d963f36f28524f4d091" + } + Frame { + msec: 1968 + hash: "6838cb2d728259adc8d91a4a69e35adf" + } + Frame { + msec: 1984 + hash: "3f73c720ce5f1e65fb8537a9beb66d26" + } + Frame { + msec: 2000 + hash: "95d990ccd3e45e780d875aae1f4654f8" + } + Frame { + msec: 2016 + hash: "5389a121571f61e73903305860e60016" + } + Frame { + msec: 2032 + hash: "66f0018b6f35c1c18b28f4959eef96a8" + } + Frame { + msec: 2048 + hash: "c0fa0560a9a5a0f773394c4fd98c9fa3" + } + Frame { + msec: 2064 + hash: "e2d665ae0ac3007520003bb4a24ca708" + } + Frame { + msec: 2080 + hash: "ab6e6976e4214c725f71a4f0ba6d3f68" + } + Frame { + msec: 2096 + hash: "642f48f731f896d0d4b66956485b615b" + } + Frame { + msec: 2112 + hash: "cdc36222978e4361dd3ddc2cba78328d" + } + Frame { + msec: 2128 + hash: "22fe869d83d9d290c4d1702e7553c7aa" + } + Frame { + msec: 2144 + hash: "3cf2b6a4fd5c73c24717a1ce901cfb19" + } + Frame { + msec: 2160 + hash: "ea7ecad2a9b7e6ca9a9d1c9c46e0f6dc" + } + Frame { + msec: 2176 + hash: "3a7e7e2145b40732ef4e18218a959536" + } + Frame { + msec: 2192 + hash: "1386046373ab246ae533aba206ffe502" + } + Frame { + msec: 2208 + hash: "2183072e2117c2bc660767bc67e6c355" + } + Frame { + msec: 2224 + hash: "659c6fedf573d19727f9852a9034e4fe" + } + Frame { + msec: 2240 + hash: "5be4e8fa87593aeb4d59768a61441c37" + } + Frame { + msec: 2256 + hash: "2030b883508d07735b20726d218fd751" + } + Frame { + msec: 2272 + hash: "fd70334fa8a1ff80369cce6aa69255c4" + } + Frame { + msec: 2288 + hash: "be666aafc8a3d2de9ffaff54d9ac15d1" + } + Frame { + msec: 2304 + hash: "3370f2246f679068e40cdb48c92decad" + } + Frame { + msec: 2320 + hash: "f0b4565fd441c071112bdc8225861f76" + } + Frame { + msec: 2336 + hash: "61babd82afc20a3023c2fe483a2e73cb" + } + Frame { + msec: 2352 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2368 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2384 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2400 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2416 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2432 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2448 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2464 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2480 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2496 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2512 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2528 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2544 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2560 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2576 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2592 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2608 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2624 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2640 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2656 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2672 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2688 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2704 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2720 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2736 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2752 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2768 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Mouse { + type: 2 + button: 1 + buttons: 1 + x: 207; y: 255 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 2784 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2800 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2816 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2832 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2848 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2864 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2880 + image: "parentAnimation2.2.png" + } + Frame { + msec: 2896 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Mouse { + type: 3 + button: 1 + buttons: 0 + x: 207; y: 255 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 2912 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2928 + hash: "608af88c841d6058c3304cc134de0187" + } + Frame { + msec: 2944 + hash: "96a727d6ff02c7baf85865fda9d871bd" + } + Frame { + msec: 2960 + hash: "22cacf109e40b457041d6c2862c4f97f" + } + Frame { + msec: 2976 + hash: "ea2a53381eef8ac75fce23c518f1e261" + } + Frame { + msec: 2992 + hash: "a719237e74e9c40b46cc1f27cca5e286" + } + Frame { + msec: 3008 + hash: "804ef3519ba9852afb0bd4ef793e0006" + } + Frame { + msec: 3024 + hash: "4abc5026f0de1165717bd14630c9d9f6" + } + Frame { + msec: 3040 + hash: "1e4dd04698691932725076073a0bd2e7" + } + Frame { + msec: 3056 + hash: "12aae9dcfd9597ce600588b19bdf5a7d" + } + Frame { + msec: 3072 + hash: "9176b69f7df68d860b7d7aecc2496f09" + } + Frame { + msec: 3088 + hash: "9cba95a510685ab6367ba87246f6c922" + } + Frame { + msec: 3104 + hash: "33ef448b9485fafb7a2af319f9f6e816" + } + Frame { + msec: 3120 + hash: "791760db748e46aceb9f469c33b7bf2f" + } + Frame { + msec: 3136 + hash: "201a00feef1bb445f2fd0ba8ef9467a1" + } + Frame { + msec: 3152 + hash: "6e8962c3cb522f5a45b093f1780d2dae" + } + Frame { + msec: 3168 + hash: "d75cb08203a4f2c05b4dfdca2196e3db" + } + Frame { + msec: 3184 + hash: "0417d681c9b64e2cc252ab6fcf20148b" + } + Frame { + msec: 3200 + hash: "85993e5a91a86cedb8c88819b035b6bb" + } + Frame { + msec: 3216 + hash: "d7a0db647e641df9625b8eb5078a8ec3" + } + Frame { + msec: 3232 + hash: "fa29824ed3fd3d4e0d8036079be6bcf8" + } + Frame { + msec: 3248 + hash: "4fc84a3ae74bb6ab7b0b846c8747eb54" + } + Frame { + msec: 3264 + hash: "a172921ffe15077382db8e8915fb340b" + } + Frame { + msec: 3280 + hash: "480ee71d2407d729814a2e19d4320c59" + } + Frame { + msec: 3296 + hash: "b8cf02a1ad96d5c3354f2b658085ed28" + } + Frame { + msec: 3312 + hash: "80fc0f57f58250f63a77b1988a9e1d2e" + } + Frame { + msec: 3328 + hash: "bc283b5d7c5b88ef447be5992a77b6a9" + } + Frame { + msec: 3344 + hash: "89c86df88dc1a3188d52c1f75b80ccf1" + } + Frame { + msec: 3360 + hash: "84148139d89b45949561321bd6f6c835" + } + Frame { + msec: 3376 + hash: "9118d6933b3f77e0b5b8da2d630152e8" + } + Frame { + msec: 3392 + hash: "2b5f746225053778fb07a606ff113e64" + } + Frame { + msec: 3408 + hash: "0a1ed1bea6ed674826d0a2c3146a1c31" + } + Frame { + msec: 3424 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3440 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3456 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3472 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3488 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3504 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3520 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3536 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3552 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3568 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3584 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3600 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3616 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3632 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3648 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Key { + type: 6 + key: 16777249 + modifiers: 67108864 + text: "" + autorep: false + count: 1 + } + Frame { + msec: 3664 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3680 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3696 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3712 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3728 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3744 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3760 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3776 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3792 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3808 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3824 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3840 + image: "parentAnimation2.3.png" + } +} diff --git a/tests/auto/declarative/qmlvisual/animation/parentAnimation2/parentAnimation2.qml b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/parentAnimation2.qml new file mode 100644 index 0000000..dfab108 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/parentAnimation2.qml @@ -0,0 +1,64 @@ +import Qt 4.7 + +/* +Blue rect fills (with 10px margin) screen, then red, then green, then screen again. +*/ + +Rectangle { + id: whiteRect + width: 640; height: 480; + + Rectangle { + id: redRect + x: 400; y: 50 + width: 100; height: 100 + color: "red" + } + + Rectangle { + id: greenRect + x: 100; y: 150 + width: 200; height: 300 + color: "green" + } + + Rectangle { + id: blueRect + x: 5; y: 5 + width: parent.width-10 + height: parent.height-10 + color: "lightblue" + + //Text { text: "Click me!"; anchors.centerIn: parent } + + MouseArea { + anchors.fill: parent + onClicked: { + switch(blueRect.state) { + case "": blueRect.state = "inRed"; break; + case "inRed": blueRect.state = "inGreen"; break; + case "inGreen": blueRect.state = ""; break; + } + } + } + + states: [ + State { + name: "inRed" + ParentChange { target: blueRect; parent: redRect; x: 5; y: 5; width: parent.width-10; height: parent.height-10 } + PropertyChanges { target: redRect; z: 1 } + }, + State { + name: "inGreen" + ParentChange { target: blueRect; parent: greenRect; x: 5; y: 5; width: parent.width-10; height: parent.height-10 } + PropertyChanges { target: greenRect; z: 1 } + } + ] + + transitions: Transition { + ParentAnimation { target: blueRect; //via: whiteRect; + NumberAnimation { properties: "x, y, width, height"; duration: 500 } + } + } + } +} diff --git a/tests/auto/declarative/qmlvisual/animation/pauseAnimation/pauseAnimation-visual.qml b/tests/auto/declarative/qmlvisual/animation/pauseAnimation/pauseAnimation-visual.qml index d82c6df..cc9a639 100644 --- a/tests/auto/declarative/qmlvisual/animation/pauseAnimation/pauseAnimation-visual.qml +++ b/tests/auto/declarative/qmlvisual/animation/pauseAnimation/pauseAnimation-visual.qml @@ -16,7 +16,7 @@ Rectangle { id: img source: "pics/qtlogo.png" x: 60-width/2 - y: 100 + y: 200-img.height SequentialAnimation on y { loops: Animation.Infinite NumberAnimation { @@ -24,7 +24,7 @@ Rectangle { easing.type: "InOutQuad" } NumberAnimation { - to: 100 + to: 200-img.height easing.type: "OutBounce" duration: 2000 } diff --git a/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.0.png b/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.0.png Binary files differnew file mode 100644 index 0000000..d8be67b --- /dev/null +++ b/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.0.png diff --git a/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.1.png b/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.1.png Binary files differnew file mode 100644 index 0000000..249e0dd --- /dev/null +++ b/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.1.png diff --git a/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.2.png b/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.2.png Binary files differnew file mode 100644 index 0000000..044f823 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.2.png diff --git a/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.3.png b/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.3.png Binary files differnew file mode 100644 index 0000000..d8be67b --- /dev/null +++ b/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.3.png diff --git a/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.qml b/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.qml new file mode 100644 index 0000000..dc8e2e2 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/animation/qtbug10586/data/qtbug10586.qml @@ -0,0 +1,1151 @@ +import Qt.VisualTest 4.7 + +VisualTest { + Frame { + msec: 0 + } + Frame { + msec: 16 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 32 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 48 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 64 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 80 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 96 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 112 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 128 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 144 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 160 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 176 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 192 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 208 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 224 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 240 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 256 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 272 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 288 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 304 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 320 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 336 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 352 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 368 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 384 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 400 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 416 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 432 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 448 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 464 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 480 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 496 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 512 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 528 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 544 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 560 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 576 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 592 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 608 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 624 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 640 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 656 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 672 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 688 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 704 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 720 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 736 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 752 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 768 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 784 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 800 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 816 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 832 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 848 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 864 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 880 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 896 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 912 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 928 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 944 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 960 + image: "qtbug10586.0.png" + } + Frame { + msec: 976 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 992 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1008 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1024 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1040 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1056 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1072 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1088 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1104 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1120 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1136 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1152 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1168 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1184 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1200 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1216 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1232 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1248 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1264 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1280 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1296 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1312 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Mouse { + type: 2 + button: 1 + buttons: 1 + x: 174; y: 204 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 1328 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1344 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1360 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1376 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1392 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Mouse { + type: 5 + button: 0 + buttons: 1 + x: 170; y: 204 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 1408 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Mouse { + type: 5 + button: 0 + buttons: 1 + x: 156; y: 204 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 1424 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 1440 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Mouse { + type: 5 + button: 0 + buttons: 1 + x: 130; y: 204 + modifiers: 0 + sendToViewport: true + } + Mouse { + type: 3 + button: 1 + buttons: 0 + x: 130; y: 204 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 1456 + hash: "8b7dd0f0a3881f10d76b47cbec4754c3" + } + Frame { + msec: 1472 + hash: "b6fc4990acb245e015c35261a3c6fd75" + } + Frame { + msec: 1488 + hash: "849fa4174134804dadc000323141b341" + } + Frame { + msec: 1504 + hash: "35f2d6405ed7d992bb62eb6e24478492" + } + Frame { + msec: 1520 + hash: "673ebb4499522c3f27b775dff1dbbe44" + } + Frame { + msec: 1536 + hash: "96945f5489ffd0dc8ab995c96eb5da43" + } + Frame { + msec: 1552 + hash: "2e4543754429ac3db831a2432098c063" + } + Frame { + msec: 1568 + hash: "02253fe8a9fd5009a07265c2c6ffc8e4" + } + Frame { + msec: 1584 + hash: "200a89949df1e9ef58d005a139857d2c" + } + Frame { + msec: 1600 + hash: "ceb28be34c7ea8eff5fa00fdea087439" + } + Frame { + msec: 1616 + hash: "a9ece475c51f126094c5eff4e20f4a19" + } + Frame { + msec: 1632 + hash: "aa0776f84aef87d6971affdfa2d8dd82" + } + Frame { + msec: 1648 + hash: "4c74661e1c73fefc9c5154b257239352" + } + Frame { + msec: 1664 + hash: "c10d23df3a75966aad5016bd8ba8e9d8" + } + Frame { + msec: 1680 + hash: "41692977d654a55d3b1d037aea9f2c03" + } + Frame { + msec: 1696 + hash: "2f1835a1de94f962eb5dc781c85b4c32" + } + Frame { + msec: 1712 + hash: "7cb78e2e5f6d35d456c95f2bd8652eb5" + } + Frame { + msec: 1728 + hash: "4388aee9b1c8b4fde43634ad08f03557" + } + Frame { + msec: 1744 + hash: "1cdc71100fd11cb6e60c9ab7e65e95bf" + } + Frame { + msec: 1760 + hash: "feddbf269adfc8bb1b1a3656b5b5736d" + } + Frame { + msec: 1776 + hash: "76b39ce0ee9b9b4af8aa0141577b8460" + } + Frame { + msec: 1792 + hash: "bac963d3df2841ab7a3770a371f3a94d" + } + Frame { + msec: 1808 + hash: "403007bb6c0782fece1cedbd40994550" + } + Frame { + msec: 1824 + hash: "72076c743fdd33fab2ac789c7c22973a" + } + Frame { + msec: 1840 + hash: "662be553c32b0145b3f4fee9bb0d659d" + } + Frame { + msec: 1856 + hash: "e6b9049949a0ee4ff8a0fcaf5464f479" + } + Frame { + msec: 1872 + hash: "eb1939458851780b7bb51ee50f0a3bd7" + } + Frame { + msec: 1888 + hash: "41c8d2686ddb882981a7d3a5c8c69005" + } + Frame { + msec: 1904 + hash: "7d3b1fc34082a160cbea4409af85fc9c" + } + Frame { + msec: 1920 + image: "qtbug10586.1.png" + } + Frame { + msec: 1936 + hash: "17be4a9c3d4d19e93bf1fc3a13a374a2" + } + Frame { + msec: 1952 + hash: "d449593024a59487eb92195ee6b77a64" + } + Frame { + msec: 1968 + hash: "c6ccbc2acec8e32f043f2cfb7b7848a9" + } + Frame { + msec: 1984 + hash: "cef9f8e8cdd5e2d33b86a9a6fb64ecb4" + } + Frame { + msec: 2000 + hash: "2a8956de5ce417431bdb156144985370" + } + Frame { + msec: 2016 + hash: "73721425a9c658bd9d40eac3fcbe8e25" + } + Frame { + msec: 2032 + hash: "9a9cf8eee0bf2f09944a4fb3b1c139d5" + } + Frame { + msec: 2048 + hash: "3673cdee04343ce679ec2cebadc9f512" + } + Frame { + msec: 2064 + hash: "eedd62019867e3189f9cf6e2b4149c6d" + } + Frame { + msec: 2080 + hash: "7a66bc37f5cf917e8b121003af0530b0" + } + Frame { + msec: 2096 + hash: "401667ed0f38858553de27164e9cadb5" + } + Frame { + msec: 2112 + hash: "b391699437c4092de3ad1684a35bfd30" + } + Frame { + msec: 2128 + hash: "109c91215f075292910095a25eaded49" + } + Frame { + msec: 2144 + hash: "c44d3f6ce1fa1ab324dd9ef394f37f87" + } + Frame { + msec: 2160 + hash: "299d43cb3dcf7b95af8803df3eb17a46" + } + Frame { + msec: 2176 + hash: "7ddd97266383d954a008fbe7b95a3169" + } + Frame { + msec: 2192 + hash: "941f2837ff5145a26df9a0d9f6d20bd9" + } + Frame { + msec: 2208 + hash: "d99d76cba43f3ae953605d7732d6ce21" + } + Frame { + msec: 2224 + hash: "929f49416f7ca80d7f5f2be3b13b849e" + } + Frame { + msec: 2240 + hash: "929f49416f7ca80d7f5f2be3b13b849e" + } + Frame { + msec: 2256 + hash: "fff9bbf16d1c3f7510ddfc44af616a5e" + } + Frame { + msec: 2272 + hash: "70b6cdb95ad6723d18c623e1dc79a8db" + } + Frame { + msec: 2288 + hash: "70b6cdb95ad6723d18c623e1dc79a8db" + } + Frame { + msec: 2304 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2320 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2336 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2352 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2368 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2384 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2400 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2416 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2432 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2448 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2464 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2480 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2496 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2512 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2528 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2544 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2560 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2576 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2592 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2608 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2624 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2640 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2656 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2672 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2688 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2704 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2720 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2736 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Mouse { + type: 2 + button: 1 + buttons: 1 + x: 29; y: 239 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 2752 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2768 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2784 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2800 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Frame { + msec: 2816 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Mouse { + type: 5 + button: 0 + buttons: 1 + x: 35; y: 241 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 2832 + hash: "cdb3c12b1b0b6ab269ba7fcf75320f69" + } + Mouse { + type: 5 + button: 0 + buttons: 1 + x: 63; y: 243 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 2848 + hash: "2732b282b8ac482033694cd04c6f5b7e" + } + Mouse { + type: 5 + button: 0 + buttons: 1 + x: 106; y: 244 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 2864 + hash: "7d253797885f8b304d8fb3ba727a3c5d" + } + Mouse { + type: 5 + button: 0 + buttons: 1 + x: 158; y: 243 + modifiers: 0 + sendToViewport: true + } + Mouse { + type: 3 + button: 1 + buttons: 0 + x: 158; y: 243 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 2880 + image: "qtbug10586.2.png" + } + Frame { + msec: 2896 + hash: "d85a416e4ddf59dfd0723b0be0e2b418" + } + Frame { + msec: 2912 + hash: "f1934f6ca6a3c5ac5df3451596b8d8ba" + } + Frame { + msec: 2928 + hash: "28fc74a76f9eaeeccbd3063dc55a1000" + } + Frame { + msec: 2944 + hash: "eb8ad8dae734b624664fcf584cda6ba0" + } + Frame { + msec: 2960 + hash: "a6d0f4aba3e5ae1e003520f45b75d6dd" + } + Frame { + msec: 2976 + hash: "4e5a4d04dfa5f06292774e6bf4f86508" + } + Frame { + msec: 2992 + hash: "fc9e16fd8c7379d774a09fe50d4259dc" + } + Frame { + msec: 3008 + hash: "721ea322d9a5e9d48117336476f568cb" + } + Frame { + msec: 3024 + hash: "5930448341bce1c50de7acaba1f64ca1" + } + Frame { + msec: 3040 + hash: "7194bacd56906f83948844224ce6a3e7" + } + Frame { + msec: 3056 + hash: "fcf11cf70b8ac210d4bb2bc716942053" + } + Frame { + msec: 3072 + hash: "767d707db4dbb02b6f97153b3822a1d1" + } + Frame { + msec: 3088 + hash: "f8eb75b97f5233aa82b887aab34a38e3" + } + Frame { + msec: 3104 + hash: "1d3beb06b39fa1d5cabd31ec4297f59f" + } + Frame { + msec: 3120 + hash: "cadc775e0764afa7b50c5bab782035dd" + } + Frame { + msec: 3136 + hash: "385f5a6e80da0d3ddf24539a64f26eb9" + } + Frame { + msec: 3152 + hash: "34204871a684ea251c9d07fb125436da" + } + Frame { + msec: 3168 + hash: "bc3e496535e66ff0d1e800092b7c78ca" + } + Frame { + msec: 3184 + hash: "d6c4ff5bf223361be42c78d6d81248c3" + } + Frame { + msec: 3200 + hash: "cb09d41612df66a8d099153026adcbf3" + } + Frame { + msec: 3216 + hash: "f82180b8c0389ddc3623107a049c3366" + } + Frame { + msec: 3232 + hash: "1b0f65e4599c65b8a603abd8da718d48" + } + Frame { + msec: 3248 + hash: "897391a8206178356858139b3d1a4ce8" + } + Frame { + msec: 3264 + hash: "b66d268dc7a42a7b1172b1ff566f4eb8" + } + Frame { + msec: 3280 + hash: "0fe5d38a253dbd1ebcc67cca7ea86dc7" + } + Frame { + msec: 3296 + hash: "b788f8a7e1e42f768fd1fe1198ca0344" + } + Frame { + msec: 3312 + hash: "4f7f8b7f5bb78bb9327b6fa8142ce3a2" + } + Frame { + msec: 3328 + hash: "30f041278c08174671568a0dfb7cbdf7" + } + Frame { + msec: 3344 + hash: "6ecd90fc89ab9b6c4813fa6a6e9dffdb" + } + Frame { + msec: 3360 + hash: "6ecd90fc89ab9b6c4813fa6a6e9dffdb" + } + Frame { + msec: 3376 + hash: "6d79d9d0ba8da0b5654b39768b25591f" + } + Frame { + msec: 3392 + hash: "6d79d9d0ba8da0b5654b39768b25591f" + } + Frame { + msec: 3408 + hash: "6d79d9d0ba8da0b5654b39768b25591f" + } + Frame { + msec: 3424 + hash: "6d79d9d0ba8da0b5654b39768b25591f" + } + Frame { + msec: 3440 + hash: "6d79d9d0ba8da0b5654b39768b25591f" + } + Frame { + msec: 3456 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3472 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3488 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3504 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3520 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3536 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3552 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3568 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3584 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3600 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3616 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3632 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3648 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3664 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3680 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3696 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3712 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3728 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3744 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3760 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3776 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3792 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3808 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3824 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3840 + image: "qtbug10586.3.png" + } + Frame { + msec: 3856 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3872 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3888 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3904 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3920 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3936 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3952 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3968 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 3984 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4000 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4016 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4032 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4048 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4064 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Key { + type: 6 + key: 16777249 + modifiers: 67108864 + text: "" + autorep: false + count: 1 + } + Frame { + msec: 4080 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4096 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4112 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4128 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4144 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4160 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4176 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } + Frame { + msec: 4192 + hash: "cba9afe3f351e6cd6dc72d7f263401b0" + } +} diff --git a/tests/auto/declarative/qmlvisual/animation/qtbug10586/qtbug10586.qml b/tests/auto/declarative/qmlvisual/animation/qtbug10586/qtbug10586.qml new file mode 100644 index 0000000..f1a3ef7 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/animation/qtbug10586/qtbug10586.qml @@ -0,0 +1,27 @@ +import Qt 4.7 + +Rectangle { + width: 200 + height: 400 + Flickable { + id: flick + anchors.fill: parent + contentWidth: 1000; contentHeight: parent.height + Rectangle { + border.color: "black" + border.width: 10 + width: 1000; height: 1000 + rotation: 90 + gradient: Gradient { + GradientStop { position: 0; color: "black" } + GradientStop { position: 1; color: "white" } + } + } + } + Rectangle { + color: "red" + width: 100; height: 100 + y: flick.contentX < 10 ? 300 : 0 + Behavior on y { NumberAnimation {} } + } +} 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 diff --git a/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data-X11/autosize.0.png b/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data-X11/autosize.0.png Binary files differdeleted file mode 100644 index 1f28b9a..0000000 --- a/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data-X11/autosize.0.png +++ /dev/null diff --git a/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data-X11/autosize.qml b/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data-X11/autosize.qml deleted file mode 100644 index f4c4e29..0000000 --- a/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data-X11/autosize.qml +++ /dev/null @@ -1,83 +0,0 @@ -import Qt.VisualTest 4.7 - -VisualTest { - Frame { - msec: 0 - } - Frame { - msec: 16 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 32 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 48 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 64 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 80 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 96 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 112 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 128 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 144 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 160 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 176 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 192 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 208 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 224 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 240 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 256 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 272 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 288 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } - Frame { - msec: 304 - hash: "0c70d855adc847fe33d7959ccb98bb8b" - } -} diff --git a/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data/autosize.0.png b/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data/autosize.0.png Binary files differdeleted file mode 100644 index 1f28b9a..0000000 --- a/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data/autosize.0.png +++ /dev/null diff --git a/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data/autosize.qml b/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data/autosize.qml deleted file mode 100644 index 273c2b0..0000000 --- a/tests/auto/declarative/qmlvisual/qfxwebview/autosize/data/autosize.qml +++ /dev/null @@ -1,83 +0,0 @@ -import Qt.VisualTest 4.7 - -VisualTest { - Frame { - msec: 0 - } - Frame { - msec: 16 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 32 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 48 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 64 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 80 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 96 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 112 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 128 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 144 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 160 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 176 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 192 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 208 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 224 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 240 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 256 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 272 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 288 - hash: "66539e1b1983d95386b0d30d6e969904" - } - Frame { - msec: 304 - hash: "66539e1b1983d95386b0d30d6e969904" - } -} diff --git a/tests/auto/declarative/qmlvisual/qmlvisual.pro b/tests/auto/declarative/qmlvisual/qmlvisual.pro index a3abbe3..dca9b04 100644 --- a/tests/auto/declarative/qmlvisual/qmlvisual.pro +++ b/tests/auto/declarative/qmlvisual/qmlvisual.pro @@ -4,7 +4,34 @@ macx:CONFIG -= app_bundle SOURCES += tst_qmlvisual.cpp -DEFINES += QT_TEST_SOURCE_DIR=\"\\\"$$PWD\\\"\" +symbian: { + importFiles.path = + importFiles.sources = animation \ + fillmode \ + focusscope \ + ListView \ + qdeclarativeborderimage \ + qdeclarativeflickable \ + qdeclarativeflipable \ + qdeclarativegridview \ + qdeclarativemousearea \ + qdeclarativeparticles \ + qdeclarativepathview \ + qdeclarativepositioners \ + qdeclarativesmoothedanimation \ + qdeclarativespringfollow \ + qdeclarativetext \ + qdeclarativetextedit \ + qdeclarativetextinput \ + rect \ + repeater \ + selftest_noimages \ + webview + DEPLOYMENT = importFiles + + DEFINES += QT_TEST_SOURCE_DIR=\".\" +} else { + DEFINES += QT_TEST_SOURCE_DIR=\"\\\"$$PWD\\\"\" +} CONFIG += parallel_test - diff --git a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp index 5f25882..f105692 100644 --- a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp +++ b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp @@ -82,7 +82,7 @@ QString tst_qmlvisual::viewer() #if defined(Q_WS_MAC) qmlruntime = QDir(binaries).absoluteFilePath("qml.app/Contents/MacOS/qml"); -#elif defined(Q_WS_WIN) +#elif defined(Q_WS_WIN) || defined(Q_WS_S60) qmlruntime = QDir(binaries).absoluteFilePath("qml.exe"); #else qmlruntime = QDir(binaries).absoluteFilePath("qml"); @@ -101,11 +101,11 @@ void tst_qmlvisual::visual_data() files << findQmlFiles(QDir(QT_TEST_SOURCE_DIR)); else { //these are newly added tests we want to try out in CI (then move to the stable list) - files << QT_TEST_SOURCE_DIR "/qdeclarativeborderimage/borders.qml"; + files << QT_TEST_SOURCE_DIR "/animation/qtbug10586/qtbug10586.qml"; files << QT_TEST_SOURCE_DIR "/qdeclarativeborderimage/animated.qml"; - files << QT_TEST_SOURCE_DIR "/qdeclarativeborderimage/animated-smooth.qml"; files << QT_TEST_SOURCE_DIR "/qdeclarativeflipable/test-flipable.qml"; files << QT_TEST_SOURCE_DIR "/qdeclarativepositioners/usingRepeater.qml"; + files << QT_TEST_SOURCE_DIR "/animation/parentAnimation2/parentAnimation2.qml"; //these are tests we think are stable and useful enough to be run by the CI system files << QT_TEST_SOURCE_DIR "/animation/bindinganimation/bindinganimation.qml"; @@ -123,6 +123,8 @@ void tst_qmlvisual::visual_data() //these reliably fail in CI, for unknown reasons //files << QT_TEST_SOURCE_DIR "/animation/easing/easing.qml"; //files << QT_TEST_SOURCE_DIR "/animation/pauseAnimation/pauseAnimation-visual.qml"; + //files << QT_TEST_SOURCE_DIR "/qdeclarativeborderimage/borders.qml"; + //files << QT_TEST_SOURCE_DIR "/qdeclarativeborderimage/animated-smooth.qml"; //these reliably fail on Linux because of color interpolation (different float rounding) #if !defined(Q_WS_X11) && !defined(Q_WS_QWS) diff --git a/tests/auto/declarative/qmlvisual/qfxwebview/autosize/autosize.qml b/tests/auto/declarative/qmlvisual/webview/autosize/autosize.qml index c4a502e..c4a502e 100644 --- a/tests/auto/declarative/qmlvisual/qfxwebview/autosize/autosize.qml +++ b/tests/auto/declarative/qmlvisual/webview/autosize/autosize.qml diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.0.png b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.0.png Binary files differnew file mode 100644 index 0000000..ed87174 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.0.png diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.1.png b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.1.png Binary files differnew file mode 100644 index 0000000..ed87174 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.1.png diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.2.png b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.2.png Binary files differnew file mode 100644 index 0000000..ed87174 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.2.png diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.3.png b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.3.png Binary files differnew file mode 100644 index 0000000..ed87174 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.3.png diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.4.png b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.4.png Binary files differnew file mode 100644 index 0000000..ed87174 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.4.png diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.qml b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.qml new file mode 100644 index 0000000..6122138 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/webview/autosize/data-X11/autosize.qml @@ -0,0 +1,115 @@ +import Qt.VisualTest 4.7 + +VisualTest { + Frame { + msec: 0 + } + Frame { + msec: 16 + hash: "b2d863e57dee2a297d038e18acc70f92" + } + Frame { + msec: 32 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 48 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 64 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 80 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 96 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 112 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 128 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 144 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 160 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 176 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 192 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 208 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 224 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 240 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 256 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 272 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 288 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 304 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 320 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 336 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 352 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 368 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 384 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 400 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 416 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 432 + hash: "903a4c7e619abba5342c8c827f26a722" + } +} diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.0.png b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.0.png Binary files differnew file mode 100644 index 0000000..ed87174 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.0.png diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.1.png b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.1.png Binary files differnew file mode 100644 index 0000000..ed87174 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.1.png diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.2.png b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.2.png Binary files differnew file mode 100644 index 0000000..ed87174 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.2.png diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.3.png b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.3.png Binary files differnew file mode 100644 index 0000000..ed87174 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.3.png diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.4.png b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.4.png Binary files differnew file mode 100644 index 0000000..ed87174 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.4.png diff --git a/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.qml b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.qml new file mode 100644 index 0000000..6122138 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/webview/autosize/data/autosize.qml @@ -0,0 +1,115 @@ +import Qt.VisualTest 4.7 + +VisualTest { + Frame { + msec: 0 + } + Frame { + msec: 16 + hash: "b2d863e57dee2a297d038e18acc70f92" + } + Frame { + msec: 32 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 48 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 64 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 80 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 96 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 112 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 128 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 144 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 160 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 176 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 192 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 208 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 224 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 240 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 256 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 272 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 288 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 304 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 320 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 336 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 352 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 368 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 384 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 400 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 416 + hash: "903a4c7e619abba5342c8c827f26a722" + } + Frame { + msec: 432 + hash: "903a4c7e619abba5342c8c827f26a722" + } +} diff --git a/tests/auto/declarative/qmlvisual/webview/embedding/data/nesting.0.png b/tests/auto/declarative/qmlvisual/webview/embedding/data/nesting.0.png Binary files differdeleted file mode 100644 index 57de710..0000000 --- a/tests/auto/declarative/qmlvisual/webview/embedding/data/nesting.0.png +++ /dev/null diff --git a/tests/auto/declarative/qmlvisual/webview/embedding/data/nesting.qml b/tests/auto/declarative/qmlvisual/webview/embedding/data/nesting.qml deleted file mode 100644 index 9664566..0000000 --- a/tests/auto/declarative/qmlvisual/webview/embedding/data/nesting.qml +++ /dev/null @@ -1,363 +0,0 @@ -import Qt.VisualTest 4.7 - -VisualTest { - Frame { - msec: 0 - } - Frame { - msec: 16 - hash: "5dc8dca7a73022fbf2116b654b709244" - } - Frame { - msec: 32 - hash: "5dc8dca7a73022fbf2116b654b709244" - } - Frame { - msec: 48 - hash: "34079c4076ab6aadd8b64fcba7d95e15" - } - Frame { - msec: 64 - hash: "5ab5fc62b49e78d0609dcb4be6c9a157" - } - Frame { - msec: 80 - hash: "063cc7438bbffae717648d98006021a8" - } - Frame { - msec: 96 - hash: "c5cd16663e48639cbeade82c3bfa0403" - } - Frame { - msec: 112 - hash: "ea7f8df84ddbad0f683fe97ddb0a0130" - } - Frame { - msec: 128 - hash: "3c353e09bdb3a1e6ff388ad6020f55ea" - } - Frame { - msec: 144 - hash: "5b6de430365d0c9824337011916b0c0b" - } - Frame { - msec: 160 - hash: "48d353ac9e7ee1ce41361d0a2b47e008" - } - Frame { - msec: 176 - hash: "c96e4d02d343ddd78e8d3dd6aa8e0198" - } - Frame { - msec: 192 - hash: "543c63d77ec635b77672ba4c5160a3d4" - } - Frame { - msec: 208 - hash: "2d56ad9c2352e555fef613d625e71151" - } - Frame { - msec: 224 - hash: "18e433c3e3ee64510f875f674791d51c" - } - Frame { - msec: 240 - hash: "56889122c1ddacdd8ebd88310c7410bc" - } - Frame { - msec: 256 - hash: "d51c85458e0109bd5bf9528b741d98d0" - } - Frame { - msec: 272 - hash: "ac54137afc29a3022c6f01df7cdf2fd6" - } - Frame { - msec: 288 - hash: "c7a42b389bae3b729ba9e6cba7f54530" - } - Frame { - msec: 304 - hash: "7583b55841e80891652c3472c658f989" - } - Frame { - msec: 320 - hash: "95a7f8d47c3788261427727f82c9ff59" - } - Frame { - msec: 336 - hash: "a87bad3e2f010680e16cd1e3f5e03e99" - } - Frame { - msec: 352 - hash: "e16bc51653f21819e0eec412b99a069f" - } - Frame { - msec: 368 - hash: "f1e869580ac148ae207141c5f0adc185" - } - Frame { - msec: 384 - hash: "7e496e44363a16d7c62e4258af9ce087" - } - Frame { - msec: 400 - hash: "19e97915c84d3554c66d5a9ad3aa6a3e" - } - Frame { - msec: 416 - hash: "181181b48a1085d1850f18ca9b163549" - } - Frame { - msec: 432 - hash: "4637cb04595a543867bd43b0c1c829ea" - } - Frame { - msec: 448 - hash: "bd0a074fed5507f8556de6110bf56aa4" - } - Frame { - msec: 464 - hash: "9547618923edac6f7f9a3ff324c4f2d8" - } - Frame { - msec: 480 - hash: "a2f90c88eacb7c66878d45e33c2a787d" - } - Frame { - msec: 496 - hash: "d5ffd3e35d0426887c106069310f84d8" - } - Frame { - msec: 512 - hash: "6bc50a5b76e2a2ef0e6bee762abeb330" - } - Frame { - msec: 528 - hash: "d4439933c842ed8432434d272fea2845" - } - Frame { - msec: 544 - hash: "61699e6ec476ac3f090e4f485430421d" - } - Frame { - msec: 560 - hash: "02d7fa9bcd697d2cab364d0a3ca4a0e2" - } - Frame { - msec: 576 - hash: "914178cbf1f6a6822cc40f81823475e4" - } - Frame { - msec: 592 - hash: "280f867ea27891ee764332998567d40d" - } - Frame { - msec: 608 - hash: "ea0d00fe54a172a89c24eac781f7ae6d" - } - Frame { - msec: 624 - hash: "4e910fb507964a710e26f318c62227bf" - } - Frame { - msec: 640 - hash: "b0c3392eb739f270dd21f552ad999c23" - } - Frame { - msec: 656 - hash: "f3698c83b0972bd66a53ad95d4fc301e" - } - Frame { - msec: 672 - hash: "0d303a0d6a9b626943ac93cc6f3fb230" - } - Frame { - msec: 688 - hash: "ba56d49e6f51aa6f1bd2a7500e3538fd" - } - Frame { - msec: 704 - hash: "273ce89d5194168e5bfd1dcefad49be2" - } - Frame { - msec: 720 - hash: "c2beef4fb7996dbccdaff4f54bdc33f1" - } - Frame { - msec: 736 - hash: "1e1aa7d84f27158a8e61bd8698ddbf2a" - } - Frame { - msec: 752 - hash: "24e82479802e710c673133ca0413be66" - } - Frame { - msec: 768 - hash: "b77e935a690bcb396e15b942d772cf1b" - } - Frame { - msec: 784 - hash: "7b729c74df1d15d6b0e8e1fc19c2d710" - } - Frame { - msec: 800 - hash: "fd6cbdca3e481baaf35022dfea76e74c" - } - Frame { - msec: 816 - hash: "c975f6eb592793aa81895ffcb74ca577" - } - Frame { - msec: 832 - hash: "677c4039a650df53b4e885f37b049ab3" - } - Frame { - msec: 848 - hash: "89563aae36552cb1749ec06567e46d9d" - } - Frame { - msec: 864 - hash: "01f57402874de6608cc02937aaf91794" - } - Frame { - msec: 880 - hash: "50c9c4e5eaaadee1ff230975390d34e3" - } - Frame { - msec: 896 - hash: "20b7d277d398afad59afdf9e6b41a57e" - } - Frame { - msec: 912 - hash: "8f9ea938a2375afeba419199de66dd52" - } - Frame { - msec: 928 - hash: "b96745888ba954bcf304c0840a030f93" - } - Frame { - msec: 944 - hash: "f5715e931274011123160f7ad10d6c52" - } - Frame { - msec: 960 - image: "nesting.0.png" - } - Frame { - msec: 976 - hash: "459fe967816c795a177a3926093fae75" - } - Frame { - msec: 992 - hash: "c599a26083068b6db628c8d8416bab60" - } - Frame { - msec: 1008 - hash: "e0aee7d1152c971b1beee9d36542acb7" - } - Frame { - msec: 1024 - hash: "2af0facdf6412f7b06979aae25e4db26" - } - Frame { - msec: 1040 - hash: "f147a92cb1826f95d4fdb7d011ba79b1" - } - Frame { - msec: 1056 - hash: "12a1cb894b0fb8e44152cccacf855c1a" - } - Frame { - msec: 1072 - hash: "c7500cf58b74fef2c3e9820d1de8f843" - } - Frame { - msec: 1088 - hash: "3a031b2206835f8b2dc9837016df6ae6" - } - Frame { - msec: 1104 - hash: "7a4796b419bbc04237764dea0b1d47d5" - } - Frame { - msec: 1120 - hash: "151d350f0064e2faf0bfb9c58bc3e4f2" - } - Frame { - msec: 1136 - hash: "d72c20a97e678908acc1d6c1f8114d9e" - } - Frame { - msec: 1152 - hash: "22da1e645640a3c31b064ff757113197" - } - Frame { - msec: 1168 - hash: "401f0bf370e2ecea5a84276fb72eb1da" - } - Frame { - msec: 1184 - hash: "c6e00d7b0ac14a5c3860b6a29901c915" - } - Frame { - msec: 1200 - hash: "f1f7dc55d7719fcb6e97157c0ca85fc0" - } - Frame { - msec: 1216 - hash: "6a112e1d79c7128c235d093e4f1f9325" - } - Frame { - msec: 1232 - hash: "14a2caf8cdca8d5147261a315059b69d" - } - Frame { - msec: 1248 - hash: "5645243aa3cfd12b0b32442f063bedb2" - } - Frame { - msec: 1264 - hash: "c7f72534a88e33c72a54cb8580534551" - } - Frame { - msec: 1280 - hash: "6cd5e2e8e0128586a682b3c649ae0631" - } - Frame { - msec: 1296 - hash: "67cefb4526b52d40a31811bc0dfaeb6a" - } - Frame { - msec: 1312 - hash: "fbe2a43a27bf490719c8b9e2b094e34f" - } - Frame { - msec: 1328 - hash: "e028aad6f51a47d8189efcf9c5d277ee" - } - Frame { - msec: 1344 - hash: "2b4cc50c37c07289fa6f9309991d36da" - } - Frame { - msec: 1360 - hash: "b67b2244cd0616d07e100d7b3b00bbe2" - } - Frame { - msec: 1376 - hash: "4e4690cffc98c49e91bdb600f1e94c79" - } - Frame { - msec: 1392 - hash: "e5215c727836a5547a170d42363bc5c8" - } - Frame { - msec: 1408 - hash: "26868e91d1794bb3f42d51f508fef613" - } - Frame { - msec: 1424 - hash: "1e5f431b125a66096ac9a4d5a211a2c4" - } -} diff --git a/tests/auto/declarative/qmlvisual/webview/embedding/egg.qml b/tests/auto/declarative/qmlvisual/webview/embedding/egg.qml deleted file mode 100644 index c569c9a..0000000 --- a/tests/auto/declarative/qmlvisual/webview/embedding/egg.qml +++ /dev/null @@ -1,26 +0,0 @@ -import Qt 4.7 - -Item { - property variant period : 250 - property variant color : "black" - id: root - - Item { - x: root.width/2 - y: root.height/2 - Rectangle { - radius: width/2 - color: root.color - x: -width/2 - y: -height/2 - width: root.width*1.5 - height: root.height*1.5 - } - rotation: NumberAnimation { - from: 0 - to: 360 - repeat: true - duration: root.period - } - } -} diff --git a/tests/auto/declarative/qmlvisual/webview/embedding/nesting.html b/tests/auto/declarative/qmlvisual/webview/embedding/nesting.html deleted file mode 100644 index 6e81689..0000000 --- a/tests/auto/declarative/qmlvisual/webview/embedding/nesting.html +++ /dev/null @@ -1,9 +0,0 @@ -<html> -<head><title>Nesting</title> -<link rel="icon" sizes="48x48" href="basic.png"> -</head> -<body bgcolor="green"> -<h1>Nesting</h1> -This is a test... -<OBJECT data=egg.qml TYPE=application/x-qt-plugin width=50 height=70 period=2000 color=white></OBJECT> -... with a spinning QML egg nested in it. diff --git a/tests/auto/declarative/qmlvisual/webview/embedding/nesting.qml b/tests/auto/declarative/qmlvisual/webview/embedding/nesting.qml deleted file mode 100644 index 9e008de..0000000 --- a/tests/auto/declarative/qmlvisual/webview/embedding/nesting.qml +++ /dev/null @@ -1,9 +0,0 @@ -import Qt 4.7 -import org.webkit 1.0 - -WebView { - width: 300 - height: 200 - url: "nesting.html" - settings.pluginsEnabled: true -} diff --git a/tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp b/tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp index b8e317e..7d34698 100644 --- a/tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp +++ b/tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp @@ -225,7 +225,7 @@ void tst_QPacketProtocol::read() void tst_QPacketProtocol::device() { QPacketProtocol p(m_client); - QCOMPARE(p.device(), m_client); + QVERIFY(p.device() == m_client); } void tst_QPacketProtocol::tst_QPacket_clear() diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index f8ecca3..4a9f1d1 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -50,6 +50,7 @@ #include <qgesturerecognizer.h> #include <qgraphicsitem.h> #include <qgraphicsview.h> +#include <qmainwindow.h> #include <qdebug.h> @@ -335,6 +336,7 @@ private slots: void finishedWithoutStarted(); void unknownGesture(); void graphicsItemGesture(); + void graphicsView(); void graphicsItemTreeGesture(); void explicitGraphicsObjectTarget(); void gestureOverChildGraphicsItem(); @@ -355,6 +357,7 @@ private slots: void deleteGestureTargetItem(); void viewportCoordinates(); void partialGesturePropagation(); + void testQGestureRecognizerCleanup(); }; tst_Gestures::tst_Gestures() @@ -857,7 +860,6 @@ void tst_Gestures::graphicsItemGesture() QTest::qWaitForWindowShown(&view); view.ensureVisible(scene.sceneRect()); - view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); item->grabGesture(CustomGesture::GestureType); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; @@ -906,6 +908,71 @@ void tst_Gestures::graphicsItemGesture() QCOMPARE(item->gestureOverrideEventsReceived, 0); } +void tst_Gestures::graphicsView() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + view.setWindowFlags(Qt::X11BypassWindowManagerHint); + + GestureItem *item = new GestureItem("item"); + scene.addItem(item); + item->setPos(100, 100); + + view.show(); + QTest::qWaitForWindowShown(&view); + view.ensureVisible(scene.sceneRect()); + + item->grabGesture(CustomGesture::GestureType); + + static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; + static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; + + CustomEvent event; + // make sure the event is properly delivered if only the hotspot is set. + event.hotSpot = mapToGlobal(QPointF(10, 10), item, &view); + event.hasHotSpot = true; + sendCustomGesture(&event, item, &scene); + + QCOMPARE(item->customEventsReceived, TotalCustomEventsCount); + QCOMPARE(item->gestureEventsReceived, TotalGestureEventsCount); + QCOMPARE(item->gestureOverrideEventsReceived, 0); + + // change the viewport and try again + QWidget *newViewport = new QWidget; + view.setViewport(newViewport); + + item->reset(); + sendCustomGesture(&event, item, &scene); + + QCOMPARE(item->customEventsReceived, TotalCustomEventsCount); + QCOMPARE(item->gestureEventsReceived, TotalGestureEventsCount); + QCOMPARE(item->gestureOverrideEventsReceived, 0); + + // change the scene and try again + QGraphicsScene newScene; + item = new GestureItem("newItem"); + newScene.addItem(item); + item->setPos(100, 100); + view.setScene(&newScene); + + item->reset(); + // first without a gesture + sendCustomGesture(&event, item, &newScene); + + QCOMPARE(item->customEventsReceived, TotalCustomEventsCount); + QCOMPARE(item->gestureEventsReceived, 0); + QCOMPARE(item->gestureOverrideEventsReceived, 0); + + // then grab the gesture and try again + item->reset(); + item->grabGesture(CustomGesture::GestureType); + sendCustomGesture(&event, item, &newScene); + + QCOMPARE(item->customEventsReceived, TotalCustomEventsCount); + QCOMPARE(item->gestureEventsReceived, TotalGestureEventsCount); + QCOMPARE(item->gestureOverrideEventsReceived, 0); +} + void tst_Gestures::graphicsItemTreeGesture() { QGraphicsScene scene; @@ -931,7 +998,6 @@ void tst_Gestures::graphicsItemTreeGesture() QTest::qWaitForWindowShown(&view); view.ensureVisible(scene.sceneRect()); - view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); item1->grabGesture(CustomGesture::GestureType); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; @@ -989,7 +1055,6 @@ void tst_Gestures::explicitGraphicsObjectTarget() QTest::qWaitForWindowShown(&view); view.ensureVisible(scene.sceneRect()); - view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); item1->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); item2->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); item2_child1->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); @@ -1049,7 +1114,6 @@ void tst_Gestures::gestureOverChildGraphicsItem() QTest::qWaitForWindowShown(&view); view.ensureVisible(scene.sceneRect()); - view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); item1->grabGesture(CustomGesture::GestureType); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; @@ -1517,8 +1581,6 @@ void tst_Gestures::autoCancelGestures2() parent->setPos(0, 0); child->setPos(10, 10); scene.addItem(parent); - view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); - view.viewport()->grabGesture(secondGesture, Qt::DontStartGestureOnChildren); parent->grabGesture(CustomGesture::GestureType); child->grabGesture(secondGesture); @@ -1571,7 +1633,6 @@ void tst_Gestures::graphicsViewParentPropagation() QTest::qWaitForWindowShown(&view); view.ensureVisible(scene.sceneRect()); - view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); item0->grabGesture(CustomGesture::GestureType, Qt::ReceivePartialGestures | Qt::IgnoredGesturesPropagateToParent); item1->grabGesture(CustomGesture::GestureType, Qt::ReceivePartialGestures | Qt::IgnoredGesturesPropagateToParent); item1_c1->grabGesture(CustomGesture::GestureType, Qt::IgnoredGesturesPropagateToParent); @@ -1642,8 +1703,6 @@ void tst_Gestures::panelPropagation() QTest::qWaitForWindowShown(&view); view.ensureVisible(scene.sceneRect()); - view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); - static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; @@ -1755,8 +1814,6 @@ void tst_Gestures::panelStacksBehindParent() QTest::qWaitForWindowShown(&view); view.ensureVisible(scene.sceneRect()); - view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); - static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; CustomEvent event; @@ -1841,8 +1898,6 @@ void tst_Gestures::deleteGestureTargetItem() QTest::qWaitForWindowShown(&view); view.ensureVisible(scene.sceneRect()); - view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); - if (propagateUpdateGesture) item2->ignoredUpdatedGestures << CustomGesture::GestureType; connect(items.value(emitter, 0), signalName, items.value(receiver, 0), slotName); @@ -1888,8 +1943,6 @@ void tst_Gestures::viewportCoordinates() QTest::qWaitForWindowShown(&view); view.ensureVisible(scene.sceneRect()); - view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); - CustomEvent event; event.hotSpot = mapToGlobal(item1->boundingRect().center(), item1, &view); event.hasHotSpot = true; @@ -1927,8 +1980,6 @@ void tst_Gestures::partialGesturePropagation() QTest::qWaitForWindowShown(&view); view.ensureVisible(scene.sceneRect()); - view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); - item1->ignoredUpdatedGestures << CustomGesture::GestureType; CustomEvent event; @@ -1949,5 +2000,74 @@ void tst_Gestures::partialGesturePropagation() QCOMPARE(item4->gestureEventsReceived, 0); } +class WinNativePan : public QPanGesture { +public: + WinNativePan() {} +}; + +class Pan : public QPanGesture { +public: + Pan() {} +}; + +class CustomPan : public QPanGesture { +public: + CustomPan() {} +}; + +// Recognizer for active gesture triggers on mouse press +class PanRecognizer : public QGestureRecognizer { +public: + enum PanType { Platform, Default, Custom }; + + PanRecognizer(int id) : m_id(id) {} + QGesture *create(QObject *) { + switch(m_id) { + case Platform: return new WinNativePan(); + case Default: return new Pan(); + default: return new CustomPan(); + } + } + + Result recognize(QGesture *, QObject *, QEvent *) { return QGestureRecognizer::Ignore; } + + const int m_id; +}; + +void tst_Gestures::testQGestureRecognizerCleanup() +{ + // Clean first the current recognizers in QGManager + QGestureRecognizer::unregisterRecognizer(Qt::PanGesture); + + // v-- Qt singleton QGManager initialization + + // Mimic QGestureManager: register both default and "platform" recognizers + // (this is done in windows when QT_NO_NATIVE_GESTURES is not defined) + PanRecognizer *def = new PanRecognizer(PanRecognizer::Default); + QGestureRecognizer::registerRecognizer(def); + PanRecognizer *plt = new PanRecognizer(PanRecognizer::Platform); + QGestureRecognizer::registerRecognizer(plt); + qDebug () << "register: default =" << def << "; platform =" << plt; + + // ^-- Qt singleton QGManager initialization + + // Here, application code would start + + // Create QGV (has a QAScrollArea, which uses Qt::PanGesture) + QMainWindow *w = new QMainWindow; + QGraphicsView *v = new QGraphicsView(); + w->setCentralWidget(v); + + // Unregister Qt recognizers + QGestureRecognizer::unregisterRecognizer(Qt::PanGesture); + + // Register a custom Pan recognizer + //QGestureRecognizer::registerRecognizer(new PanRecognizer(PanRecognizer::Custom)); + + w->show(); + QTest::qWaitForWindowShown(w); + delete w; +} + QTEST_MAIN(tst_Gestures) #include "tst_gestures.moc" diff --git a/tests/auto/languagechange/tst_languagechange.cpp b/tests/auto/languagechange/tst_languagechange.cpp index d04707e..bcc3be4 100644 --- a/tests/auto/languagechange/tst_languagechange.cpp +++ b/tests/auto/languagechange/tst_languagechange.cpp @@ -238,8 +238,8 @@ void tst_languageChange::retranslatability() QString fooName = tmpParentDir + "/foo"; QDir dir; QCOMPARE(dir.mkpath(tmpDir), true); -#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86) - // Just create a new file instead of copying exe, because exe is not there in emulator +#if defined(Q_OS_SYMBIAN) + // Just create a new file instead of copying exe, because there is no read access to /sys/bin { QFile fooFile(fooName); QVERIFY(fooFile.open(QIODevice::WriteOnly | QIODevice::Text)); diff --git a/tests/auto/mediaservices.pro b/tests/auto/mediaservices.pro deleted file mode 100644 index 1b50cd7..0000000 --- a/tests/auto/mediaservices.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE=subdirs -SUBDIRS=\ - qsoundeffect \ - qdeclarativeaudio \ - qdeclarativevideo \ - qgraphicsvideoitem \ - qmediacontent \ - qmediaobject \ - qmediaplayer \ - qmediaplaylist \ - qmediaplaylistnavigator \ - qmediapluginloader \ - qmediaresource \ - qmediaservice \ - qmediaserviceprovider \ - qmediatimerange \ - qvideowidget - - diff --git a/tests/auto/qabstractnetworkcache/qabstractnetworkcache.pro b/tests/auto/qabstractnetworkcache/qabstractnetworkcache.pro index a57c56f..2e2577d 100644 --- a/tests/auto/qabstractnetworkcache/qabstractnetworkcache.pro +++ b/tests/auto/qabstractnetworkcache/qabstractnetworkcache.pro @@ -9,3 +9,4 @@ wince*|symbian: { DEPLOYMENT += testFiles } +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qabstractsocket/qabstractsocket.pro b/tests/auto/qabstractsocket/qabstractsocket.pro index 59999af..814a7d2 100644 --- a/tests/auto/qabstractsocket/qabstractsocket.pro +++ b/tests/auto/qabstractsocket/qabstractsocket.pro @@ -7,4 +7,5 @@ QT = core network SOURCES += tst_qabstractsocket.cpp +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qbuffer/tst_qbuffer.cpp b/tests/auto/qbuffer/tst_qbuffer.cpp index fcef6a3..dd5ca91 100644 --- a/tests/auto/qbuffer/tst_qbuffer.cpp +++ b/tests/auto/qbuffer/tst_qbuffer.cpp @@ -76,6 +76,7 @@ private slots: void atEnd(); void readLineBoundaries(); void writeAfterQByteArrayResize(); + void read_null(); protected slots: void readyReadSlot(); @@ -529,5 +530,30 @@ void tst_QBuffer::writeAfterQByteArrayResize() QCOMPARE(buffer.buffer().size(), 1000); } +void tst_QBuffer::read_null() +{ + QByteArray buffer; + buffer.resize(32000); + for (int i = 0; i < buffer.size(); ++i) + buffer[i] = char(i & 0xff); + + QBuffer in(&buffer); + in.open(QIODevice::ReadOnly); + + QByteArray chunk; + + chunk.resize(16380); + in.read(chunk.data(), 16380); + + QCOMPARE(chunk, buffer.mid(0, chunk.size())); + + in.read(chunk.data(), 0); + + chunk.resize(8); + in.read(chunk.data(), chunk.size()); + + QCOMPARE(chunk, buffer.mid(16380, chunk.size())); +} + QTEST_MAIN(tst_QBuffer) #include "tst_qbuffer.moc" diff --git a/tests/auto/qcolumnview/tst_qcolumnview.cpp b/tests/auto/qcolumnview/tst_qcolumnview.cpp index 90f499d..1da8c5d 100644 --- a/tests/auto/qcolumnview/tst_qcolumnview.cpp +++ b/tests/auto/qcolumnview/tst_qcolumnview.cpp @@ -596,11 +596,11 @@ void tst_QColumnView::clicked() QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, localPoint); QCOMPARE(clickedSpy.count(), 1); qApp->processEvents(); - + if (sizeof(qreal) != sizeof(double)) { QSKIP("Skipped due to rounding errors", SkipAll); } - + for (int i = 0; i < view.createdColumns.count(); ++i) { QAbstractItemView *column = view.createdColumns.at(i); if (column && column->selectionModel() && (column->rootIndex() == home)) @@ -961,9 +961,9 @@ void tst_QColumnView::parentCurrentIndex() QVERIFY(third.isValid()); view.setCurrentIndex(third); QTest::qWait(ANIMATION_DELAY); - QCOMPARE(view.createdColumns[0]->currentIndex(), first); - QCOMPARE(view.createdColumns[1]->currentIndex(), second); - QCOMPARE(view.createdColumns[2]->currentIndex(), third); + QTRY_COMPARE(view.createdColumns[0]->currentIndex(), first); + QTRY_COMPARE(view.createdColumns[1]->currentIndex(), second); + QTRY_COMPARE(view.createdColumns[2]->currentIndex(), third); first = model.index(0, 0, QModelIndex()); second = model.index(secondRow, 0, first); diff --git a/tests/auto/qdatetime/tst_qdatetime.cpp b/tests/auto/qdatetime/tst_qdatetime.cpp index 6aca996..47c54a5 100644 --- a/tests/auto/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/qdatetime/tst_qdatetime.cpp @@ -106,6 +106,8 @@ private slots: void daysTo(); void secsTo_data(); void secsTo(); + void msecsTo_data(); + void msecsTo(); void operator_eqeq(); void currentDateTime(); void currentDateTimeUtc(); @@ -910,6 +912,30 @@ void tst_QDateTime::secsTo() QVERIFY((dt >= result) == (0 >= nsecs)); } +void tst_QDateTime::msecsTo_data() +{ + addMSecs_data(); +} + +void tst_QDateTime::msecsTo() +{ + QFETCH(QDateTime, dt); + QFETCH(int, nsecs); + QFETCH(QDateTime, result); + +#ifdef Q_OS_IRIX + QEXPECT_FAIL("cet4", "IRIX databases say 1970 had DST", Abort); +#endif + QCOMPARE(dt.msecsTo(result), qint64(nsecs) * 1000); + QCOMPARE(result.msecsTo(dt), -qint64(nsecs) * 1000); + QVERIFY((dt == result) == (0 == (qint64(nsecs) * 1000))); + QVERIFY((dt != result) == (0 != (qint64(nsecs) * 1000))); + QVERIFY((dt < result) == (0 < (qint64(nsecs) * 1000))); + QVERIFY((dt <= result) == (0 <= (qint64(nsecs) * 1000))); + QVERIFY((dt > result) == (0 > (qint64(nsecs) * 1000))); + QVERIFY((dt >= result) == (0 >= (qint64(nsecs) * 1000))); +} + void tst_QDateTime::currentDateTime() { #if defined(Q_OS_WINCE) diff --git a/tests/auto/qdbusserver/.gitignore b/tests/auto/qdbusserver/.gitignore deleted file mode 100644 index 33a9be2..0000000 --- a/tests/auto/qdbusserver/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qdbusserver diff --git a/tests/auto/qdbusserver/qdbusserver.pro b/tests/auto/qdbusserver/qdbusserver.pro deleted file mode 100644 index 05a4eb8..0000000 --- a/tests/auto/qdbusserver/qdbusserver.pro +++ /dev/null @@ -1,11 +0,0 @@ -load(qttest_p4) -QT = core - -contains(QT_CONFIG,dbus): { - SOURCES += tst_qdbusserver.cpp - QT += dbus -} else { - SOURCES += ../qdbusmarshall/dummy.cpp -} - - diff --git a/tests/auto/qdbusserver/server.cpp b/tests/auto/qdbusserver/server.cpp deleted file mode 100644 index d4422f0..0000000 --- a/tests/auto/qdbusserver/server.cpp +++ /dev/null @@ -1,49 +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 <QtCore/QtCore> -#include <QtDBus/QtDBus> - -int main(int argc, char *argv[]) -{ - QCoreApplication app(argc, argv); - QDBusServer server("unix:path=/tmp/qdbus-test"); - return app.exec(); -} diff --git a/tests/auto/qdbusserver/tst_qdbusserver.cpp b/tests/auto/qdbusserver/tst_qdbusserver.cpp deleted file mode 100644 index f0da02a..0000000 --- a/tests/auto/qdbusserver/tst_qdbusserver.cpp +++ /dev/null @@ -1,78 +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 <qcoreapplication.h> -#include <qdebug.h> - -#include <QtTest/QtTest> -#include <QtDBus/QtDBus> - -static const QString bus = "unix:path=/tmp/qdbus-test"; -static const QString service = "com.trolltech.Qt.Autotests.QDBusServer"; -static const QString path = "/com/trolltech/test"; - -class tst_QDBusServer : public QObject -{ - Q_OBJECT - - void connectToServer(); - void callMethod(); -private slots: -}; - -void tst_QDBusServer::connectToServer() -{ - QDBusConnection connection = QDBusConnection::connectToBus(bus, "test-connection"); - QTest::qWait(100); - QVERIFY(connection.isConnected()); -} - -void tst_QDBusServer::callMethod() -{ - QDBusConnection connection = QDBusConnection::connectToBus(bus, "test-connection"); - QTest::qWait(100); - QVERIFY(connection.isConnected()); - //QDBusMessage msg = QDBusMessage::createMethodCall(bus, path, /*service*/"", "method"); - //QDBusMessage reply = connection.call(msg, QDBus::Block); -} - -QTEST_MAIN(tst_QDBusServer) - -#include "tst_qdbusserver.moc" diff --git a/tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro b/tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro deleted file mode 100644 index ecfe299..0000000 --- a/tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro +++ /dev/null @@ -1,14 +0,0 @@ -load(qttest_p4) - -HEADERS += \ - $$PWD/../../../src/imports/multimedia/qdeclarativeaudio_p.h \ - $$PWD/../../../src/imports/multimedia/qdeclarativemediabase_p.h \ - $$PWD/../../../src/imports/multimedia/qmetadatacontrolmetaobject_p.h - -SOURCES += \ - tst_qdeclarativeaudio.cpp \ - $$PWD/../../../src/imports/multimedia/qdeclarativeaudio.cpp \ - $$PWD/../../../src/imports/multimedia/qdeclarativemediabase.cpp \ - $$PWD/../../../src/imports/multimedia/qmetadatacontrolmetaobject.cpp - -QT += mediaservices declarative diff --git a/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp b/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp deleted file mode 100644 index e393599..0000000 --- a/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp +++ /dev/null @@ -1,1252 +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 <QtTest/QtTest> - -#include "../../../src/imports/multimedia/qdeclarativeaudio_p.h" - -#include <QtGui/qapplication.h> -#include <QtMediaServices/qmediaplayercontrol.h> -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/qmetadatacontrol.h> - - -class tst_QDeclarativeAudio : public QObject -{ - Q_OBJECT -public slots: - void initTestCase(); - -private slots: - void nullPlayerControl(); - void nullMetaDataControl(); - void nullService(); - - void source(); - void autoLoad(); - void playing(); - void paused(); - void duration(); - void position(); - void volume(); - void muted(); - void bufferProgress(); - void seekable(); - void playbackRate(); - void status(); - void metaData_data(); - void metaData(); - void error(); -}; - -Q_DECLARE_METATYPE(QtMediaServices::MetaData); -Q_DECLARE_METATYPE(QDeclarativeAudio::Error); - -class QtTestMediaPlayerControl : public QMediaPlayerControl -{ - Q_OBJECT -public: - QtTestMediaPlayerControl(QObject *parent = 0) - : QMediaPlayerControl(parent) - , m_state(QMediaPlayer::StoppedState) - , m_mediaStatus(QMediaPlayer::NoMedia) - , m_duration(0) - , m_position(0) - , m_playbackRate(1.0) - , m_volume(50) - , m_bufferStatus(0) - , m_muted(false) - , m_audioAvailable(false) - , m_videoAvailable(false) - , m_seekable(false) - { - } - - QMediaPlayer::State state() const { return m_state; } - void updateState(QMediaPlayer::State state) { emit stateChanged(m_state = state); } - - QMediaPlayer::MediaStatus mediaStatus() const { return m_mediaStatus; } - void updateMediaStatus(QMediaPlayer::MediaStatus status) { - emit mediaStatusChanged(m_mediaStatus = status); } - void updateMediaStatus(QMediaPlayer::MediaStatus status, QMediaPlayer::State state) - { - m_mediaStatus = status; - m_state = state; - - emit mediaStatusChanged(m_mediaStatus); - emit stateChanged(m_state); - } - - qint64 duration() const { return m_duration; } - void setDuration(qint64 duration) { emit durationChanged(m_duration = duration); } - - qint64 position() const { return m_position; } - void setPosition(qint64 position) { emit positionChanged(m_position = position); } - - int volume() const { return m_volume; } - void setVolume(int volume) { emit volumeChanged(m_volume = volume); } - - bool isMuted() const { return m_muted; } - void setMuted(bool muted) { emit mutedChanged(m_muted = muted); } - - int bufferStatus() const { return m_bufferStatus; } - void setBufferStatus(int status) { emit bufferStatusChanged(m_bufferStatus = status); } - - bool isAudioAvailable() const { return m_audioAvailable; } - void setAudioAvailable(bool available) { - emit audioAvailableChanged(m_audioAvailable = available); } - bool isVideoAvailable() const { return m_videoAvailable; } - void setVideoAvailable(bool available) { - emit videoAvailableChanged(m_videoAvailable = available); } - - bool isSeekable() const { return m_seekable; } - void setSeekable(bool seekable) { emit seekableChanged(m_seekable = seekable); } - - QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); } - - qreal playbackRate() const { return m_playbackRate; } - void setPlaybackRate(qreal rate) { emit playbackRateChanged(m_playbackRate = rate); } - - QMediaContent media() const { return m_media; } - const QIODevice *mediaStream() const { return 0; } - void setMedia(const QMediaContent &media, QIODevice *) - { - m_media = media; - - m_mediaStatus = m_media.isNull() - ? QMediaPlayer::NoMedia - : QMediaPlayer::LoadingMedia; - - emit mediaChanged(m_media); - emit mediaStatusChanged(m_mediaStatus); - } - - void play() { emit stateChanged(m_state = QMediaPlayer::PlayingState); } - void pause() { emit stateChanged(m_state = QMediaPlayer::PausedState); } - void stop() { emit stateChanged(m_state = QMediaPlayer::StoppedState); } - - void emitError(QMediaPlayer::Error err, const QString &errorString) { - emit error(err, errorString); } - -private: - QMediaPlayer::State m_state; - QMediaPlayer::MediaStatus m_mediaStatus; - qint64 m_duration; - qint64 m_position; - qreal m_playbackRate; - int m_volume; - int m_bufferStatus; - bool m_muted; - bool m_audioAvailable; - bool m_videoAvailable; - bool m_seekable; - QMediaContent m_media; -}; - -class QtTestMetaDataControl : public QMetaDataControl -{ - Q_OBJECT -public: - QtTestMetaDataControl(QObject *parent = 0) - : QMetaDataControl(parent) - { - } - - bool isWritable() const { return true; } - bool isMetaDataAvailable() const { return true; } - - QVariant metaData(QtMediaServices::MetaData key) const { return m_metaData.value(key); } - void setMetaData(QtMediaServices::MetaData key, const QVariant &value) { - m_metaData.insert(key, value); emit metaDataChanged(); } - void setMetaData(const QMap<QtMediaServices::MetaData, QVariant> &metaData) { - m_metaData = metaData; emit metaDataChanged(); } - - QList<QtMediaServices::MetaData> availableMetaData() const { return m_metaData.keys(); } - - QVariant extendedMetaData(const QString &) const { return QVariant(); } - void setExtendedMetaData(const QString &, const QVariant &) {} - QStringList availableExtendedMetaData() const { return QStringList(); } - -private: - QMap<QtMediaServices::MetaData, QVariant> m_metaData; -}; - -class QtTestMediaService : public QMediaService -{ - Q_OBJECT -public: - QtTestMediaService( - QtTestMediaPlayerControl *playerControl, - QtTestMetaDataControl *metaDataControl, - QObject *parent) - : QMediaService(parent) - , playerControl(playerControl) - , metaDataControl(metaDataControl) - { - } - - QMediaControl *control(const char *name) const - { - if (qstrcmp(name, QMediaPlayerControl_iid) == 0) - return playerControl; - else if (qstrcmp(name, QMetaDataControl_iid) == 0) - return metaDataControl; - else - return 0; - } - - QtTestMediaPlayerControl *playerControl; - QtTestMetaDataControl *metaDataControl; -}; - -class QtTestMediaServiceProvider : public QMediaServiceProvider -{ - Q_OBJECT -public: - QtTestMediaServiceProvider() - : service(new QtTestMediaService( - new QtTestMediaPlayerControl(this), new QtTestMetaDataControl(this), this)) - { - setDefaultServiceProvider(this); - } - - QtTestMediaServiceProvider(QtTestMediaService *service) - : service(service) - { - setDefaultServiceProvider(this); - } - - QtTestMediaServiceProvider( - QtTestMediaPlayerControl *playerControl, QtTestMetaDataControl *metaDataControl) - : service(new QtTestMediaService(playerControl, metaDataControl, this)) - { - setDefaultServiceProvider(this); - } - - ~QtTestMediaServiceProvider() - { - setDefaultServiceProvider(0); - } - - QMediaService *requestService( - const QByteArray &type, - const QMediaServiceProviderHint & = QMediaServiceProviderHint()) - { - requestedService = type; - - return service; - } - - void releaseService(QMediaService *) {} - - inline QtTestMediaPlayerControl *playerControl() { return service->playerControl; } - inline QtTestMetaDataControl *metaDataControl() { return service->metaDataControl; } - - QtTestMediaService *service; - QByteArray requestedService; -}; - - -void tst_QDeclarativeAudio::initTestCase() -{ - qRegisterMetaType<QDeclarativeAudio::Error>(); -} - -void tst_QDeclarativeAudio::nullPlayerControl() -{ - QtTestMetaDataControl metaDataControl; - QtTestMediaServiceProvider provider(0, &metaDataControl); - - QDeclarativeAudio audio; - - QCOMPARE(audio.source(), QUrl()); - audio.setSource(QUrl("http://example.com")); - QCOMPARE(audio.source(), QUrl("http://example.com")); - - QCOMPARE(audio.isPlaying(), false); - audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), true); - audio.setPlaying(false); - audio.play(); - QCOMPARE(audio.isPlaying(), false); - - QCOMPARE(audio.isPaused(), false); - audio.pause(); - QCOMPARE(audio.isPaused(), false); - audio.setPaused(true); - QCOMPARE(audio.isPaused(), true); - - QCOMPARE(audio.duration(), 0); - - QCOMPARE(audio.position(), 0); - audio.setPosition(10000); - QCOMPARE(audio.position(), 10000); - - QCOMPARE(audio.volume(), qreal(1.0)); - audio.setVolume(0.5); - QCOMPARE(audio.volume(), qreal(0.5)); - - QCOMPARE(audio.isMuted(), false); - audio.setMuted(true); - QCOMPARE(audio.isMuted(), true); - - QCOMPARE(audio.bufferProgress(), qreal(0)); - - QCOMPARE(audio.isSeekable(), false); - - QCOMPARE(audio.playbackRate(), qreal(1.0)); - - QCOMPARE(audio.status(), QDeclarativeAudio::NoMedia); - - QCOMPARE(audio.error(), QDeclarativeAudio::ServiceMissing); -} - -void tst_QDeclarativeAudio::nullMetaDataControl() -{ - QtTestMediaPlayerControl playerControl; - QtTestMediaServiceProvider provider(&playerControl, 0); - - QDeclarativeAudio audio; - - QCOMPARE(audio.metaObject()->indexOfProperty("title"), -1); - QCOMPARE(audio.metaObject()->indexOfProperty("genre"), -1); - QCOMPARE(audio.metaObject()->indexOfProperty("description"), -1); -} - -void tst_QDeclarativeAudio::nullService() -{ - QtTestMediaServiceProvider provider(0); - - QDeclarativeAudio audio; - - QCOMPARE(audio.source(), QUrl()); - audio.setSource(QUrl("http://example.com")); - QCOMPARE(audio.source(), QUrl("http://example.com")); - - QCOMPARE(audio.isPlaying(), false); - audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), true); - audio.setPlaying(false); - audio.play(); - QCOMPARE(audio.isPlaying(), false); - - QCOMPARE(audio.isPaused(), false); - audio.pause(); - QCOMPARE(audio.isPaused(), false); - audio.setPaused(true); - QCOMPARE(audio.isPaused(), true); - - QCOMPARE(audio.duration(), 0); - - QCOMPARE(audio.position(), 0); - audio.setPosition(10000); - QCOMPARE(audio.position(), 10000); - - QCOMPARE(audio.volume(), qreal(1.0)); - audio.setVolume(0.5); - QCOMPARE(audio.volume(), qreal(0.5)); - - QCOMPARE(audio.isMuted(), false); - audio.setMuted(true); - QCOMPARE(audio.isMuted(), true); - - QCOMPARE(audio.bufferProgress(), qreal(0)); - - QCOMPARE(audio.isSeekable(), false); - - QCOMPARE(audio.playbackRate(), qreal(1.0)); - - QCOMPARE(audio.status(), QDeclarativeAudio::NoMedia); - - QCOMPARE(audio.error(), QDeclarativeAudio::ServiceMissing); - - QCOMPARE(audio.metaObject()->indexOfProperty("title"), -1); - QCOMPARE(audio.metaObject()->indexOfProperty("genre"), -1); - QCOMPARE(audio.metaObject()->indexOfProperty("description"), -1); -} - -void tst_QDeclarativeAudio::source() -{ - const QUrl url1("http://example.com"); - const QUrl url2("file:///local/path"); - const QUrl url3; - - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(sourceChanged())); - - audio.setSource(url1); - QCOMPARE(audio.source(), url1); - QCOMPARE(provider.playerControl()->media().canonicalUrl(), url1); - QCOMPARE(spy.count(), 1); - - audio.setSource(url2); - QCOMPARE(audio.source(), url2); - QCOMPARE(provider.playerControl()->media().canonicalUrl(), url2); - QCOMPARE(spy.count(), 2); - - audio.setSource(url3); - QCOMPARE(audio.source(), url3); - QCOMPARE(provider.playerControl()->media().canonicalUrl(), url3); - QCOMPARE(spy.count(), 3); -} - -void tst_QDeclarativeAudio::autoLoad() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(autoLoadChanged())); - - QCOMPARE(audio.isAutoLoad(), true); - - audio.setAutoLoad(false); - QCOMPARE(audio.isAutoLoad(), false); - QCOMPARE(spy.count(), 1); - - audio.setSource(QUrl("http://example.com")); - QCOMPARE(audio.source(), QUrl("http://example.com")); - audio.play(); - QCOMPARE(audio.isPlaying(), true); - audio.stop(); - - audio.setAutoLoad(true); - audio.setSource(QUrl("http://example.com")); - audio.setPaused(true); - QCOMPARE(spy.count(), 2); - QCOMPARE(audio.isPaused(), true); -} - -void tst_QDeclarativeAudio::playing() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - QSignalSpy playingChangedSpy(&audio, SIGNAL(playingChanged())); - QSignalSpy startedSpy(&audio, SIGNAL(started())); - QSignalSpy stoppedSpy(&audio, SIGNAL(stopped())); - - int playingChanged = 0; - int started = 0; - int stopped = 0; - - audio.componentComplete(); - - QCOMPARE(audio.isPlaying(), false); - - // setPlaying(true) when stopped. - audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when playing. - audio.setPlaying(false); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // play() when stopped. - audio.play(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(stoppedSpy.count(), stopped); - - // stop() when playing. - audio.stop(); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // stop() when stopped. - audio.stop(); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when stopped. - audio.setPlaying(false); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); - - audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(true) when playing. - audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); - - // play() when playing. - audio.play(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); -} - -void tst_QDeclarativeAudio::paused() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - QSignalSpy playingChangedSpy(&audio, SIGNAL(playingChanged())); - QSignalSpy pausedChangedSpy(&audio, SIGNAL(pausedChanged())); - QSignalSpy startedSpy(&audio, SIGNAL(started())); - QSignalSpy pausedSpy(&audio, SIGNAL(paused())); - QSignalSpy resumedSpy(&audio, SIGNAL(resumed())); - QSignalSpy stoppedSpy(&audio, SIGNAL(stopped())); - - int playingChanged = 0; - int pausedChanged = 0; - int started = 0; - int paused = 0; - int resumed = 0; - int stopped = 0; - - audio.componentComplete(); - - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), false); - - // setPlaying(true) when stopped. - audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when playing. - audio.setPaused(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when paused. - audio.setPaused(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // pause() when paused. - audio.pause(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(false) when paused. - audio.setPaused(false); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), ++resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(false) when playing. - audio.setPaused(false); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // pause() when playing. - audio.pause(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when paused. - audio.setPlaying(false); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // setPaused(true) when stopped and paused. - audio.setPaused(true); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(false) when stopped and paused. - audio.setPaused(false); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when stopped. - audio.setPaused(true); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(true) when stopped and paused. - audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // play() when paused. - audio.play(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), ++resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when playing. - audio.setPaused(true); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // stop() when paused. - audio.stop(); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // setPaused(true) when stopped. - audio.setPaused(true); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // stop() when stopped and paused. - audio.stop(); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // pause() when stopped. - audio.pause(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when paused. - audio.setPlaying(false); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // pause() when stopped and paused. - audio.pause(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when paused. - audio.setPlaying(false); - QCOMPARE(audio.isPlaying(), false); - QCOMPARE(audio.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // play() when stopped and paused. - audio.play(); - QCOMPARE(audio.isPlaying(), true); - QCOMPARE(audio.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); -} - -void tst_QDeclarativeAudio::duration() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(durationChanged())); - - QCOMPARE(audio.duration(), 0); - - provider.playerControl()->setDuration(4040); - QCOMPARE(audio.duration(), 4040); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setDuration(-129); - QCOMPARE(audio.duration(), -129); - QCOMPARE(spy.count(), 2); - - provider.playerControl()->setDuration(0); - QCOMPARE(audio.duration(), 0); - QCOMPARE(spy.count(), 3); - - // Unnecessary duration changed signals aren't filtered. - provider.playerControl()->setDuration(0); - QCOMPARE(audio.duration(), 0); - QCOMPARE(spy.count(), 4); -} - -void tst_QDeclarativeAudio::position() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(positionChanged())); - - QCOMPARE(audio.position(), 0); - - // QDeclarativeAudio won't bound set positions to the duration. A media service may though. - QCOMPARE(audio.duration(), 0); - - audio.setPosition(450); - QCOMPARE(audio.position(), 450); - QCOMPARE(provider.playerControl()->position(), qint64(450)); - QCOMPARE(spy.count(), 1); - - audio.setPosition(-5403); - QCOMPARE(audio.position(), -5403); - QCOMPARE(provider.playerControl()->position(), qint64(-5403)); - QCOMPARE(spy.count(), 2); - - audio.setPosition(-5403); - QCOMPARE(audio.position(), -5403); - QCOMPARE(provider.playerControl()->position(), qint64(-5403)); - QCOMPARE(spy.count(), 2); - - // Check the signal change signal is emitted if the change originates from the media service. - provider.playerControl()->setPosition(0); - QCOMPARE(audio.position(), 0); - QCOMPARE(spy.count(), 3); - - connect(&audio, SIGNAL(positionChanged()), &QTestEventLoop::instance(), SLOT(exitLoop())); - - provider.playerControl()->updateState(QMediaPlayer::PlayingState); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(spy.count() > 3 && spy.count() < 6); // 4 or 5 - - provider.playerControl()->updateState(QMediaPlayer::PausedState); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(spy.count() < 6); -} - -void tst_QDeclarativeAudio::volume() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(volumeChanged())); - - QCOMPARE(audio.volume(), qreal(1.0)); - - audio.setVolume(0.7); - QCOMPARE(audio.volume(), qreal(0.7)); - QCOMPARE(provider.playerControl()->volume(), 70); - QCOMPARE(spy.count(), 1); - - audio.setVolume(0.7); - QCOMPARE(audio.volume(), qreal(0.7)); - QCOMPARE(provider.playerControl()->volume(), 70); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setVolume(30); - QCOMPARE(audio.volume(), qreal(0.3)); - QCOMPARE(spy.count(), 2); -} - -void tst_QDeclarativeAudio::muted() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(mutedChanged())); - - QCOMPARE(audio.isMuted(), false); - - audio.setMuted(true); - QCOMPARE(audio.isMuted(), true); - QCOMPARE(provider.playerControl()->isMuted(), true); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setMuted(false); - QCOMPARE(audio.isMuted(), false); - QCOMPARE(spy.count(), 2); - - audio.setMuted(false); - QCOMPARE(audio.isMuted(), false); - QCOMPARE(provider.playerControl()->isMuted(), false); - QCOMPARE(spy.count(), 3); -} - -void tst_QDeclarativeAudio::bufferProgress() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(bufferProgressChanged())); - - QCOMPARE(audio.bufferProgress(), qreal(0.0)); - - provider.playerControl()->setBufferStatus(20); - QCOMPARE(audio.bufferProgress(), qreal(0.2)); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setBufferStatus(20); - QCOMPARE(audio.bufferProgress(), qreal(0.2)); - QCOMPARE(spy.count(), 2); - - provider.playerControl()->setBufferStatus(40); - QCOMPARE(audio.bufferProgress(), qreal(0.4)); - QCOMPARE(spy.count(), 3); - - connect(&audio, SIGNAL(positionChanged()), &QTestEventLoop::instance(), SLOT(exitLoop())); - - provider.playerControl()->updateMediaStatus( - QMediaPlayer::BufferingMedia, QMediaPlayer::PlayingState); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(spy.count() > 3 && spy.count() < 6); // 4 or 5 - - provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(spy.count() < 6); -} - -void tst_QDeclarativeAudio::seekable() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(seekableChanged())); - - QCOMPARE(audio.isSeekable(), false); - - provider.playerControl()->setSeekable(true); - QCOMPARE(audio.isSeekable(), true); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setSeekable(true); - QCOMPARE(audio.isSeekable(), true); - QCOMPARE(spy.count(), 2); - - provider.playerControl()->setSeekable(false); - QCOMPARE(audio.isSeekable(), false); - QCOMPARE(spy.count(), 3); -} - -void tst_QDeclarativeAudio::playbackRate() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(playbackRateChanged())); - - QCOMPARE(audio.playbackRate(), qreal(1.0)); - - audio.setPlaybackRate(0.5); - QCOMPARE(audio.playbackRate(), qreal(0.5)); - QCOMPARE(provider.playerControl()->playbackRate(), qreal(0.5)); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setPlaybackRate(2.0); - QCOMPARE(provider.playerControl()->playbackRate(), qreal(2.0)); - QCOMPARE(spy.count(), 2); - - audio.setPlaybackRate(2.0); - QCOMPARE(audio.playbackRate(), qreal(2.0)); - QCOMPARE(provider.playerControl()->playbackRate(), qreal(2.0)); - QCOMPARE(spy.count(), 3); -} - -void tst_QDeclarativeAudio::status() -{ - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - audio.componentComplete(); - - QSignalSpy statusChangedSpy(&audio, SIGNAL(statusChanged())); - QSignalSpy loadedSpy(&audio, SIGNAL(loaded())); - QSignalSpy bufferingSpy(&audio, SIGNAL(buffering())); - QSignalSpy stalledSpy(&audio, SIGNAL(stalled())); - QSignalSpy bufferedSpy(&audio, SIGNAL(buffered())); - QSignalSpy endOfMediaSpy(&audio, SIGNAL(endOfMedia())); - - QCOMPARE(audio.status(), QDeclarativeAudio::NoMedia); - - // Set media, start loading. - provider.playerControl()->updateMediaStatus(QMediaPlayer::LoadingMedia); - QCOMPARE(audio.status(), QDeclarativeAudio::Loading); - QCOMPARE(statusChangedSpy.count(), 1); - QCOMPARE(loadedSpy.count(), 0); - QCOMPARE(bufferingSpy.count(), 0); - QCOMPARE(stalledSpy.count(), 0); - QCOMPARE(bufferedSpy.count(), 0); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Finish loading. - provider.playerControl()->updateMediaStatus(QMediaPlayer::LoadedMedia); - QCOMPARE(audio.status(), QDeclarativeAudio::Loaded); - QCOMPARE(statusChangedSpy.count(), 2); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 0); - QCOMPARE(stalledSpy.count(), 0); - QCOMPARE(bufferedSpy.count(), 0); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Play, start buffering. - provider.playerControl()->updateMediaStatus( - QMediaPlayer::StalledMedia, QMediaPlayer::PlayingState); - QCOMPARE(audio.status(), QDeclarativeAudio::Stalled); - QCOMPARE(statusChangedSpy.count(), 3); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 0); - QCOMPARE(stalledSpy.count(), 1); - QCOMPARE(bufferedSpy.count(), 0); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Enough data buffered to proceed. - provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia); - QCOMPARE(audio.status(), QDeclarativeAudio::Buffering); - QCOMPARE(statusChangedSpy.count(), 4); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 1); - QCOMPARE(stalledSpy.count(), 1); - QCOMPARE(bufferedSpy.count(), 0); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Errant second buffering status changed. - provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia); - QCOMPARE(audio.status(), QDeclarativeAudio::Buffering); - QCOMPARE(statusChangedSpy.count(), 4); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 1); - QCOMPARE(stalledSpy.count(), 1); - QCOMPARE(bufferedSpy.count(), 0); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Buffer full. - provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia); - QCOMPARE(audio.status(), QDeclarativeAudio::Buffered); - QCOMPARE(statusChangedSpy.count(), 5); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 1); - QCOMPARE(stalledSpy.count(), 1); - QCOMPARE(bufferedSpy.count(), 1); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Buffer getting low. - provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia); - QCOMPARE(audio.status(), QDeclarativeAudio::Buffering); - QCOMPARE(statusChangedSpy.count(), 6); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 2); - QCOMPARE(stalledSpy.count(), 1); - QCOMPARE(bufferedSpy.count(), 1); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Buffer full. - provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia); - QCOMPARE(audio.status(), QDeclarativeAudio::Buffered); - QCOMPARE(statusChangedSpy.count(), 7); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 2); - QCOMPARE(stalledSpy.count(), 1); - QCOMPARE(bufferedSpy.count(), 2); - QCOMPARE(endOfMediaSpy.count(), 0); - - // Finished. - provider.playerControl()->updateMediaStatus( - QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState); - QCOMPARE(audio.status(), QDeclarativeAudio::EndOfMedia); - QCOMPARE(statusChangedSpy.count(), 8); - QCOMPARE(loadedSpy.count(), 1); - QCOMPARE(bufferingSpy.count(), 2); - QCOMPARE(stalledSpy.count(), 1); - QCOMPARE(bufferedSpy.count(), 2); - QCOMPARE(endOfMediaSpy.count(), 1); -} - -void tst_QDeclarativeAudio::metaData_data() -{ - QTest::addColumn<QByteArray>("propertyName"); - QTest::addColumn<QtMediaServices::MetaData>("propertyKey"); - QTest::addColumn<QVariant>("value1"); - QTest::addColumn<QVariant>("value2"); - - QTest::newRow("title") - << QByteArray("title") - << QtMediaServices::Title - << QVariant(QString::fromLatin1("This is a title")) - << QVariant(QString::fromLatin1("This is another title")); - - QTest::newRow("genre") - << QByteArray("genre") - << QtMediaServices::Genre - << QVariant(QString::fromLatin1("rock")) - << QVariant(QString::fromLatin1("pop")); - - QTest::newRow("trackNumber") - << QByteArray("trackNumber") - << QtMediaServices::TrackNumber - << QVariant(8) - << QVariant(12); -} - -void tst_QDeclarativeAudio::metaData() -{ - QFETCH(QByteArray, propertyName); - QFETCH(QtMediaServices::MetaData, propertyKey); - QFETCH(QVariant, value1); - QFETCH(QVariant, value2); - - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - audio.componentComplete(); - - QSignalSpy spy(&audio, SIGNAL(__metaDataChanged())); - - const int index = audio.metaObject()->indexOfProperty(propertyName.constData()); - QVERIFY(index != -1); - - QMetaProperty property = audio.metaObject()->property(index); - QCOMPARE(property.read(&audio), QVariant()); - - property.write(&audio, value1); - QCOMPARE(property.read(&audio), value1); - QCOMPARE(provider.metaDataControl()->metaData(propertyKey), value1); - QCOMPARE(spy.count(), 1); - - provider.metaDataControl()->setMetaData(propertyKey, value2); - QCOMPARE(property.read(&audio), value2); - QCOMPARE(spy.count(), 2); -} - -void tst_QDeclarativeAudio::error() -{ - const QString errorString = QLatin1String("Failed to open device."); - - QtTestMediaServiceProvider provider; - QDeclarativeAudio audio; - - audio.componentComplete(); - - QSignalSpy errorSpy(&audio, SIGNAL(error(QDeclarativeAudio::Error,QString))); - QSignalSpy errorChangedSpy(&audio, SIGNAL(errorChanged())); - - QCOMPARE(audio.error(), QDeclarativeAudio::NoError); - QCOMPARE(audio.errorString(), QString()); - - provider.playerControl()->emitError(QMediaPlayer::ResourceError, errorString); - - QCOMPARE(audio.error(), QDeclarativeAudio::ResourceError); - QCOMPARE(audio.errorString(), errorString); - QCOMPARE(errorSpy.count(), 1); - QCOMPARE(errorChangedSpy.count(), 1); - - // Changing the source resets the error properties. - audio.setSource(QUrl("http://example.com")); - QCOMPARE(audio.error(), QDeclarativeAudio::NoError); - QCOMPARE(audio.errorString(), QString()); - QCOMPARE(errorSpy.count(), 1); - QCOMPARE(errorChangedSpy.count(), 2); - - // But isn't noisy. - audio.setSource(QUrl("file:///file/path")); - QCOMPARE(audio.error(), QDeclarativeAudio::NoError); - QCOMPARE(audio.errorString(), QString()); - QCOMPARE(errorSpy.count(), 1); - QCOMPARE(errorChangedSpy.count(), 2); -} - - -QTEST_MAIN(tst_QDeclarativeAudio) - -#include "tst_qdeclarativeaudio.moc" diff --git a/tests/auto/qdeclarativevideo/qdeclarativevideo.pro b/tests/auto/qdeclarativevideo/qdeclarativevideo.pro deleted file mode 100644 index 64a20da..0000000 --- a/tests/auto/qdeclarativevideo/qdeclarativevideo.pro +++ /dev/null @@ -1,14 +0,0 @@ -load(qttest_p4) - -HEADERS += \ - $$PWD/../../../src/imports/multimedia/qdeclarativevideo_p.h \ - $$PWD/../../../src/imports/multimedia/qdeclarativemediabase_p.h \ - $$PWD/../../../src/imports/multimedia/qmetadatacontrolmetaobject_p.h - -SOURCES += \ - tst_qdeclarativevideo.cpp \ - $$PWD/../../../src/imports/multimedia/qdeclarativevideo.cpp \ - $$PWD/../../../src/imports/multimedia/qdeclarativemediabase.cpp \ - $$PWD/../../../src/imports/multimedia/qmetadatacontrolmetaobject.cpp - -QT += multimedia mediaservices declarative diff --git a/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp b/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp deleted file mode 100644 index 99b447a..0000000 --- a/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp +++ /dev/null @@ -1,921 +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 <QtTest/QtTest> - -#include "../../../src/imports/multimedia/qdeclarativevideo_p.h" - -#include <QtGui/qapplication.h> -#include <QtMultimedia/qabstractvideosurface.h> -#include <QtMediaServices/qgraphicsvideoitem.h> -#include <QtMediaServices/qmediaplayercontrol.h> -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/qvideooutputcontrol.h> -#include <QtMediaServices/qvideorenderercontrol.h> -#include <QtMultimedia/qvideosurfaceformat.h> - - -class tst_QDeclarativeVideo : public QObject -{ - Q_OBJECT -public slots: - void initTestCase(); - -private slots: - void nullPlayerControl(); - void nullService(); - - void playing(); - void paused(); - void error(); - - void hasAudio(); - void hasVideo(); - void fillMode(); - void geometry(); -}; - -Q_DECLARE_METATYPE(QtMediaServices::MetaData); -Q_DECLARE_METATYPE(QDeclarativeVideo::Error); - -class QtTestMediaPlayerControl : public QMediaPlayerControl -{ - Q_OBJECT -public: - QtTestMediaPlayerControl(QObject *parent = 0) - : QMediaPlayerControl(parent) - , m_state(QMediaPlayer::StoppedState) - , m_mediaStatus(QMediaPlayer::NoMedia) - , m_duration(0) - , m_position(0) - , m_playbackRate(1.0) - , m_volume(50) - , m_bufferStatus(0) - , m_muted(false) - , m_audioAvailable(false) - , m_videoAvailable(false) - , m_seekable(false) - { - } - - QMediaPlayer::State state() const { return m_state; } - void updateState(QMediaPlayer::State state) { emit stateChanged(m_state = state); } - - QMediaPlayer::MediaStatus mediaStatus() const { return m_mediaStatus; } - void updateMediaStatus(QMediaPlayer::MediaStatus status) { - emit mediaStatusChanged(m_mediaStatus = status); } - void updateMediaStatus(QMediaPlayer::MediaStatus status, QMediaPlayer::State state) - { - m_mediaStatus = status; - m_state = state; - - emit mediaStatusChanged(m_mediaStatus); - emit stateChanged(m_state); - } - - qint64 duration() const { return m_duration; } - void setDuration(qint64 duration) { emit durationChanged(m_duration = duration); } - - qint64 position() const { return m_position; } - void setPosition(qint64 position) { emit positionChanged(m_position = position); } - - int volume() const { return m_volume; } - void setVolume(int volume) { emit volumeChanged(m_volume = volume); } - - bool isMuted() const { return m_muted; } - void setMuted(bool muted) { emit mutedChanged(m_muted = muted); } - - int bufferStatus() const { return m_bufferStatus; } - void setBufferStatus(int status) { emit bufferStatusChanged(m_bufferStatus = status); } - - bool isAudioAvailable() const { return m_audioAvailable; } - void setAudioAvailable(bool available) { - emit audioAvailableChanged(m_audioAvailable = available); } - bool isVideoAvailable() const { return m_videoAvailable; } - void setVideoAvailable(bool available) { - emit videoAvailableChanged(m_videoAvailable = available); } - - bool isSeekable() const { return m_seekable; } - void setSeekable(bool seekable) { emit seekableChanged(m_seekable = seekable); } - - QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); } - - qreal playbackRate() const { return m_playbackRate; } - void setPlaybackRate(qreal rate) { emit playbackRateChanged(m_playbackRate = rate); } - - QMediaContent media() const { return m_media; } - const QIODevice *mediaStream() const { return 0; } - void setMedia(const QMediaContent &media, QIODevice *) - { - m_media = media; - - m_mediaStatus = m_media.isNull() - ? QMediaPlayer::NoMedia - : QMediaPlayer::LoadingMedia; - - emit mediaChanged(m_media); - emit mediaStatusChanged(m_mediaStatus); - } - - void play() { emit stateChanged(m_state = QMediaPlayer::PlayingState); } - void pause() { emit stateChanged(m_state = QMediaPlayer::PausedState); } - void stop() { emit stateChanged(m_state = QMediaPlayer::StoppedState); } - - void emitError(QMediaPlayer::Error err, const QString &errorString) { - emit error(err, errorString); } - -private: - QMediaPlayer::State m_state; - QMediaPlayer::MediaStatus m_mediaStatus; - qint64 m_duration; - qint64 m_position; - qreal m_playbackRate; - int m_volume; - int m_bufferStatus; - bool m_muted; - bool m_audioAvailable; - bool m_videoAvailable; - bool m_seekable; - QMediaContent m_media; -}; - -class QtTestOutputControl : public QVideoOutputControl -{ -public: - QtTestOutputControl(QObject *parent) : QVideoOutputControl(parent), m_output(NoOutput) {} - - QList<Output> availableOutputs() const { return m_outputs; } - void setAvailableOutputs(const QList<Output> outputs) { m_outputs = outputs; } - - Output output() const { return m_output; } - virtual void setOutput(Output output) { m_output = output; } - -private: - Output m_output; - QList<Output> m_outputs; -}; - -class QtTestRendererControl : public QVideoRendererControl -{ -public: - QtTestRendererControl(QObject *parent ) : QVideoRendererControl(parent), m_surface(0) {} - - QAbstractVideoSurface *surface() const { return m_surface; } - void setSurface(QAbstractVideoSurface *surface) { m_surface = surface; } - -private: - QAbstractVideoSurface *m_surface; -}; - -class QtTestMediaService : public QMediaService -{ - Q_OBJECT -public: - QtTestMediaService( - QtTestMediaPlayerControl *playerControl, - QtTestOutputControl *outputControl, - QtTestRendererControl *rendererControl, - QObject *parent) - : QMediaService(parent) - , playerControl(playerControl) - , outputControl(outputControl) - , rendererControl(rendererControl) - { - } - - QMediaControl *control(const char *name) const - { - if (qstrcmp(name, QMediaPlayerControl_iid) == 0) - return playerControl; - else if (qstrcmp(name, QVideoOutputControl_iid) == 0) - return outputControl; - else if (qstrcmp(name, QVideoRendererControl_iid) == 0) - return rendererControl; - else - return 0; - } - - QtTestMediaPlayerControl *playerControl; - QtTestOutputControl *outputControl; - QtTestRendererControl *rendererControl; -}; - -class QtTestMediaServiceProvider : public QMediaServiceProvider -{ - Q_OBJECT -public: - QtTestMediaServiceProvider() - : service(new QtTestMediaService( - new QtTestMediaPlayerControl(this), - new QtTestOutputControl(this), - new QtTestRendererControl(this), - this)) - { - setDefaultServiceProvider(this); - } - - QtTestMediaServiceProvider(QtTestMediaService *service) - : service(service) - { - setDefaultServiceProvider(this); - } - - QtTestMediaServiceProvider( - QtTestMediaPlayerControl *playerControl, - QtTestOutputControl *outputControl, - QtTestRendererControl *rendererControl) - : service(new QtTestMediaService(playerControl, outputControl, rendererControl, this)) - { - setDefaultServiceProvider(this); - } - - ~QtTestMediaServiceProvider() - { - setDefaultServiceProvider(0); - } - - QMediaService *requestService( - const QByteArray &type, - const QMediaServiceProviderHint & = QMediaServiceProviderHint()) - { - requestedService = type; - - return service; - } - - void releaseService(QMediaService *) {} - - inline QtTestMediaPlayerControl *playerControl() { return service->playerControl; } - inline QtTestRendererControl *rendererControl() { return service->rendererControl; } - - QtTestMediaService *service; - QByteArray requestedService; -}; - - -void tst_QDeclarativeVideo::initTestCase() -{ - qRegisterMetaType<QDeclarativeVideo::Error>(); -} - -void tst_QDeclarativeVideo::nullPlayerControl() -{ - QtTestMediaServiceProvider provider(0, 0, 0); - - QDeclarativeVideo video; - - QCOMPARE(video.source(), QUrl()); - video.setSource(QUrl("http://example.com")); - QCOMPARE(video.source(), QUrl("http://example.com")); - - QCOMPARE(video.isPlaying(), false); - video.setPlaying(true); - QCOMPARE(video.isPlaying(), true); - video.setPlaying(false); - video.play(); - QCOMPARE(video.isPlaying(), false); - - QCOMPARE(video.isPaused(), false); - video.pause(); - QCOMPARE(video.isPaused(), false); - video.setPaused(true); - QCOMPARE(video.isPaused(), true); - - QCOMPARE(video.duration(), 0); - - QCOMPARE(video.position(), 0); - video.setPosition(10000); - QCOMPARE(video.position(), 10000); - - QCOMPARE(video.volume(), qreal(1.0)); - video.setVolume(0.5); - QCOMPARE(video.volume(), qreal(0.5)); - - QCOMPARE(video.isMuted(), false); - video.setMuted(true); - QCOMPARE(video.isMuted(), true); - - QCOMPARE(video.bufferProgress(), qreal(0)); - - QCOMPARE(video.isSeekable(), false); - - QCOMPARE(video.playbackRate(), qreal(1.0)); - - QCOMPARE(video.hasAudio(), false); - QCOMPARE(video.hasVideo(), false); - - QCOMPARE(video.status(), QDeclarativeVideo::NoMedia); - - QCOMPARE(video.error(), QDeclarativeVideo::ServiceMissing); -} - -void tst_QDeclarativeVideo::nullService() -{ - QtTestMediaServiceProvider provider(0); - - QDeclarativeVideo video; - - QCOMPARE(video.source(), QUrl()); - video.setSource(QUrl("http://example.com")); - QCOMPARE(video.source(), QUrl("http://example.com")); - - QCOMPARE(video.isPlaying(), false); - video.setPlaying(true); - QCOMPARE(video.isPlaying(), true); - video.setPlaying(false); - video.play(); - QCOMPARE(video.isPlaying(), false); - - QCOMPARE(video.isPaused(), false); - video.pause(); - QCOMPARE(video.isPaused(), false); - video.setPaused(true); - QCOMPARE(video.isPaused(), true); - - QCOMPARE(video.duration(), 0); - - QCOMPARE(video.position(), 0); - video.setPosition(10000); - QCOMPARE(video.position(), 10000); - - QCOMPARE(video.volume(), qreal(1.0)); - video.setVolume(0.5); - QCOMPARE(video.volume(), qreal(0.5)); - - QCOMPARE(video.isMuted(), false); - video.setMuted(true); - QCOMPARE(video.isMuted(), true); - - QCOMPARE(video.bufferProgress(), qreal(0)); - - QCOMPARE(video.isSeekable(), false); - - QCOMPARE(video.playbackRate(), qreal(1.0)); - - QCOMPARE(video.hasAudio(), false); - QCOMPARE(video.hasVideo(), false); - - QCOMPARE(video.status(), QDeclarativeVideo::NoMedia); - - QCOMPARE(video.error(), QDeclarativeVideo::ServiceMissing); - - QCOMPARE(video.metaObject()->indexOfProperty("title"), -1); - QCOMPARE(video.metaObject()->indexOfProperty("genre"), -1); - QCOMPARE(video.metaObject()->indexOfProperty("description"), -1); -} - -void tst_QDeclarativeVideo::playing() -{ - QtTestMediaServiceProvider provider; - QDeclarativeVideo video; - video.componentComplete(); - - QSignalSpy playingChangedSpy(&video, SIGNAL(playingChanged())); - QSignalSpy startedSpy(&video, SIGNAL(started())); - QSignalSpy stoppedSpy(&video, SIGNAL(stopped())); - - int playingChanged = 0; - int started = 0; - int stopped = 0; - - QCOMPARE(video.isPlaying(), false); - - // setPlaying(true) when stopped. - video.setPlaying(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when playing. - video.setPlaying(false); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // play() when stopped. - video.play(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(stoppedSpy.count(), stopped); - - // stop() when playing. - video.stop(); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // stop() when stopped. - video.stop(); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when stopped. - video.setPlaying(false); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); - - video.setPlaying(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(true) when playing. - video.setPlaying(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); - - // play() when playing. - video.play(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(stoppedSpy.count(), stopped); -} - -void tst_QDeclarativeVideo::paused() -{ - QtTestMediaServiceProvider provider; - QDeclarativeVideo video; - video.componentComplete(); - - QSignalSpy playingChangedSpy(&video, SIGNAL(playingChanged())); - QSignalSpy pausedChangedSpy(&video, SIGNAL(pausedChanged())); - QSignalSpy startedSpy(&video, SIGNAL(started())); - QSignalSpy pausedSpy(&video, SIGNAL(paused())); - QSignalSpy resumedSpy(&video, SIGNAL(resumed())); - QSignalSpy stoppedSpy(&video, SIGNAL(stopped())); - - int playingChanged = 0; - int pausedChanged = 0; - int started = 0; - int paused = 0; - int resumed = 0; - int stopped = 0; - - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), false); - - // setPlaying(true) when stopped. - video.setPlaying(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when playing. - video.setPaused(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when paused. - video.setPaused(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // pause() when paused. - video.pause(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(false) when paused. - video.setPaused(false); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), ++resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(false) when playing. - video.setPaused(false); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // pause() when playing. - video.pause(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when paused. - video.setPlaying(false); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // setPaused(true) when stopped and paused. - video.setPaused(true); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(false) when stopped and paused. - video.setPaused(false); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when stopped. - video.setPaused(true); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(true) when stopped and paused. - video.setPlaying(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // play() when paused. - video.play(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), ++resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPaused(true) when playing. - video.setPaused(true); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // stop() when paused. - video.stop(); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // setPaused(true) when stopped. - video.setPaused(true); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // stop() when stopped and paused. - video.stop(); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // pause() when stopped. - video.pause(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when paused. - video.setPlaying(false); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // pause() when stopped and paused. - video.pause(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), ++paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); - - // setPlaying(false) when paused. - video.setPlaying(false); - QCOMPARE(video.isPlaying(), false); - QCOMPARE(video.isPaused(), true); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), pausedChanged); - QCOMPARE(startedSpy.count(), started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), ++stopped); - - // play() when stopped and paused. - video.play(); - QCOMPARE(video.isPlaying(), true); - QCOMPARE(video.isPaused(), false); - QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState); - QCOMPARE(playingChangedSpy.count(), ++playingChanged); - QCOMPARE(pausedChangedSpy.count(), ++pausedChanged); - QCOMPARE(startedSpy.count(), ++started); - QCOMPARE(pausedSpy.count(), paused); - QCOMPARE(resumedSpy.count(), resumed); - QCOMPARE(stoppedSpy.count(), stopped); -} - -void tst_QDeclarativeVideo::error() -{ - const QString errorString = QLatin1String("Failed to open device."); - - QtTestMediaServiceProvider provider; - QDeclarativeVideo video; - video.componentComplete(); - - QSignalSpy errorSpy(&video, SIGNAL(error(QDeclarativeVideo::Error,QString))); - QSignalSpy errorChangedSpy(&video, SIGNAL(errorChanged())); - - QCOMPARE(video.error(), QDeclarativeVideo::NoError); - QCOMPARE(video.errorString(), QString()); - - provider.playerControl()->emitError(QMediaPlayer::ResourceError, errorString); - - QCOMPARE(video.error(), QDeclarativeVideo::ResourceError); - QCOMPARE(video.errorString(), errorString); - QCOMPARE(errorSpy.count(), 1); - QCOMPARE(errorChangedSpy.count(), 1); - - // Changing the source resets the error properties. - video.setSource(QUrl("http://example.com")); - QCOMPARE(video.error(), QDeclarativeVideo::NoError); - QCOMPARE(video.errorString(), QString()); - QCOMPARE(errorSpy.count(), 1); - QCOMPARE(errorChangedSpy.count(), 2); - - // But isn't noisy. - video.setSource(QUrl("file:///file/path")); - QCOMPARE(video.error(), QDeclarativeVideo::NoError); - QCOMPARE(video.errorString(), QString()); - QCOMPARE(errorSpy.count(), 1); - QCOMPARE(errorChangedSpy.count(), 2); -} - - -void tst_QDeclarativeVideo::hasAudio() -{ - QtTestMediaServiceProvider provider; - QDeclarativeVideo video; - video.componentComplete(); - - QSignalSpy spy(&video, SIGNAL(hasAudioChanged())); - - QCOMPARE(video.hasAudio(), false); - - provider.playerControl()->setAudioAvailable(true); - QCOMPARE(video.hasAudio(), true); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setAudioAvailable(true); - QCOMPARE(video.hasAudio(), true); - QCOMPARE(spy.count(), 2); - - provider.playerControl()->setAudioAvailable(false); - QCOMPARE(video.hasAudio(), false); - QCOMPARE(spy.count(), 3); -} - -void tst_QDeclarativeVideo::hasVideo() -{ - QtTestMediaServiceProvider provider; - QDeclarativeVideo video; - - video.componentComplete(); - - QSignalSpy spy(&video, SIGNAL(hasVideoChanged())); - - QCOMPARE(video.hasVideo(), false); - - provider.playerControl()->setVideoAvailable(true); - QCOMPARE(video.hasVideo(), true); - QCOMPARE(spy.count(), 1); - - provider.playerControl()->setVideoAvailable(true); - QCOMPARE(video.hasVideo(), true); - QCOMPARE(spy.count(), 2); - - provider.playerControl()->setVideoAvailable(false); - QCOMPARE(video.hasVideo(), false); - QCOMPARE(spy.count(), 3); -} - -void tst_QDeclarativeVideo::fillMode() -{ - QtTestMediaServiceProvider provider; - QDeclarativeVideo video; - video.componentComplete(); - - QList<QGraphicsItem *> children = video.childItems(); - QCOMPARE(children.count(), 1); - QGraphicsVideoItem *videoItem = qgraphicsitem_cast<QGraphicsVideoItem *>(children.first()); - QVERIFY(videoItem != 0); - - QCOMPARE(video.fillMode(), QDeclarativeVideo::PreserveAspectFit); - - video.setFillMode(QDeclarativeVideo::PreserveAspectCrop); - QCOMPARE(video.fillMode(), QDeclarativeVideo::PreserveAspectCrop); - QCOMPARE(videoItem->aspectRatioMode(), Qt::KeepAspectRatioByExpanding); - - video.setFillMode(QDeclarativeVideo::Stretch); - QCOMPARE(video.fillMode(), QDeclarativeVideo::Stretch); - QCOMPARE(videoItem->aspectRatioMode(), Qt::IgnoreAspectRatio); - - video.setFillMode(QDeclarativeVideo::PreserveAspectFit); - QCOMPARE(video.fillMode(), QDeclarativeVideo::PreserveAspectFit); - QCOMPARE(videoItem->aspectRatioMode(), Qt::KeepAspectRatio); -} - -void tst_QDeclarativeVideo::geometry() -{ - QtTestMediaServiceProvider provider; - QDeclarativeVideo video; - video.componentComplete(); - - QAbstractVideoSurface *surface = provider.rendererControl()->surface(); - QVERIFY(surface != 0); - - QList<QGraphicsItem *> children = video.childItems(); - QCOMPARE(children.count(), 1); - QGraphicsVideoItem *videoItem = qgraphicsitem_cast<QGraphicsVideoItem *>(children.first()); - QVERIFY(videoItem != 0); - - QVideoSurfaceFormat format(QSize(640, 480), QVideoFrame::Format_RGB32); - - QVERIFY(surface->start(format)); - - QCOMPARE(video.implicitWidth(), qreal(640)); - QCOMPARE(video.implicitHeight(), qreal(480)); - - video.setWidth(560); - video.setHeight(328); - - QCOMPARE(videoItem->size().width(), qreal(560)); - QCOMPARE(videoItem->size().height(), qreal(328)); -} - -QTEST_MAIN(tst_QDeclarativeVideo) - -#include "tst_qdeclarativevideo.moc" diff --git a/tests/auto/qdirmodel/tst_qdirmodel.cpp b/tests/auto/qdirmodel/tst_qdirmodel.cpp index 1bc5b7f..41bbd87 100644 --- a/tests/auto/qdirmodel/tst_qdirmodel.cpp +++ b/tests/auto/qdirmodel/tst_qdirmodel.cpp @@ -613,6 +613,11 @@ void tst_QDirModel::task196768_sorting() //this task showed that the persistent model indexes got corrupted when sorting QString path = SRCDIR; +#ifdef Q_OS_SYMBIAN + if(!RProcess().HasCapability(ECapabilityAllFiles)) + QEXPECT_FAIL("", "QTBUG-9746", Continue); +#endif + QDirModel model; /* QDirModel has a bug if we show the content of the subdirectory inside a hidden directory diff --git a/tests/auto/qdockwidget/tst_qdockwidget.cpp b/tests/auto/qdockwidget/tst_qdockwidget.cpp index a734985..2059101 100644 --- a/tests/auto/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/qdockwidget/tst_qdockwidget.cpp @@ -96,6 +96,7 @@ private slots: void task248604_infiniteResize(); void task258459_visibilityChanged(); void taskQTBUG_1665_closableChanged(); + void taskQTBUG_9758_undockedGeometry(); }; // Testing get/set functions @@ -653,7 +654,7 @@ void tst_QDockWidget::dockLocationChanged() QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), Qt::TopDockWidgetArea); spy.clear(); - + dw.setFloating(true); QTest::qWait(100); dw.setFloating(false); @@ -878,6 +879,27 @@ void tst_QDockWidget::taskQTBUG_1665_closableChanged() QVERIFY(!(dock.windowFlags() & Qt::WindowCloseButtonHint)); } +void tst_QDockWidget::taskQTBUG_9758_undockedGeometry() +{ + QMainWindow window; + QDockWidget dock1(&window); + QDockWidget dock2(&window); + window.addDockWidget(Qt::RightDockWidgetArea, &dock1); + window.addDockWidget(Qt::RightDockWidgetArea, &dock2); + window.tabifyDockWidget(&dock1, &dock2); + dock1.hide(); + dock2.hide(); + window.show(); + QTest::qWaitForWindowShown(&window); + dock1.setFloating(true); + dock1.show(); + QTest::qWaitForWindowShown(&dock1); + + QVERIFY(dock1.x() >= 0); + QVERIFY(dock1.y() >= 0); +} + + QTEST_MAIN(tst_QDockWidget) #include "tst_qdockwidget.moc" diff --git a/tests/auto/qfile/largefile/tst_largefile.cpp b/tests/auto/qfile/largefile/tst_largefile.cpp index 041e5f2..60c5f89 100644 --- a/tests/auto/qfile/largefile/tst_largefile.cpp +++ b/tests/auto/qfile/largefile/tst_largefile.cpp @@ -523,6 +523,10 @@ void tst_LargeFile::mapFile() void tst_LargeFile::mapOffsetOverflow() { +#if defined(Q_OS_MAC) + QSKIP("mmap'ping beyond EOF may succeed; generate bus error on access", SkipAll); +#endif + // Out-of-range mappings should fail, and not silently clip the offset for (int i = 50; i < 63; ++i) { uchar *address = 0; diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp index 38a1ee7..ca7c445 100644 --- a/tests/auto/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp @@ -529,10 +529,6 @@ void tst_QFiledialog::completer() #endif ++expected; } -#if !defined(Q_OS_WIN) - if (inputStartsWithRootPath) - expected++; -#endif } QTest::qWait(1000); diff --git a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp index 6bfa8be..eee495f 100644 --- a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp @@ -76,6 +76,13 @@ # define SRCDIR "C:/Private/" TOSTRING(SYMBIAN_SRCDIR_UID) "/" #endif +#if defined QT_BUILD_INTERNAL +QT_BEGIN_NAMESPACE +Q_GUI_EXPORT bool qt_test_isFetchedRoot(); +Q_GUI_EXPORT void qt_test_resetFetchedRoot(); +QT_END_NAMESPACE +#endif + class QNonNativeFileDialog : public QFileDialog { Q_OBJECT @@ -139,7 +146,7 @@ private: }; tst_QFileDialog2::tst_QFileDialog2() -{ +{ #if defined(Q_OS_WINCE) qApp->setAutoMaximizeThreshold(-1); #endif @@ -177,19 +184,18 @@ void tst_QFileDialog2::listRoot() QFileInfoGatherer fileInfoGatherer; fileInfoGatherer.start(); QTest::qWait(1500); - - QFileInfoGatherer::fetchedRoot = false; + qt_test_resetFetchedRoot(); QString dir(QDir::currentPath()); QNonNativeFileDialog fd(0, QString(), dir); fd.show(); - QCOMPARE(QFileInfoGatherer::fetchedRoot,false); + QCOMPARE(qt_test_isFetchedRoot(),false); fd.setDirectory(""); #ifdef Q_OS_WINCE QTest::qWait(1500); #else QTest::qWait(500); #endif - QCOMPARE(QFileInfoGatherer::fetchedRoot,true); + QCOMPARE(qt_test_isFetchedRoot(),true); #endif } diff --git a/tests/auto/qftp/qftp.pro b/tests/auto/qftp/qftp.pro index c060296..33d479a 100644 --- a/tests/auto/qftp/qftp.pro +++ b/tests/auto/qftp/qftp.pro @@ -14,6 +14,7 @@ wince*: { addFiles.path = . DEPLOYMENT += addFiles TARGET.EPOCHEAPSIZE="0x100 0x1000000" + TARGET.CAPABILITY = NetworkServices } else { DEFINES += SRCDIR=\\\"$$PWD/\\\" } diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 81097be..5a5a821 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -45,6 +45,7 @@ #include <private/qtextcontrol_p.h> #include <private/qgraphicsitem_p.h> #include <private/qgraphicsview_p.h> +#include <private/qgraphicsscene_p.h> #include <QStyleOptionGraphicsItem> #include <QAbstractTextDocumentLayout> #include <QBitmap> @@ -447,6 +448,7 @@ private slots: void QT_2649_focusScope(); void sortItemsWhileAdding(); void doNotMarkFullUpdateIfNotInScene(); + void itemDiesDuringDraggingOperation(); private: QList<QGraphicsItem *> paintedItems; @@ -10484,5 +10486,27 @@ void tst_QGraphicsItem::doNotMarkFullUpdateIfNotInScene() QTRY_COMPARE(item3->painted, 3); } +void tst_QGraphicsItem::itemDiesDuringDraggingOperation() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + QGraphicsRectItem *item = new QGraphicsRectItem(QRectF(0, 0, 100, 100)); + item->setFlag(QGraphicsItem::ItemIsMovable); + item->setAcceptDrops(true); + scene.addItem(item); + view.show(); + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(QApplication::activeWindow(), (QWidget *)&view); + QGraphicsSceneDragDropEvent dragEnter(QEvent::GraphicsSceneDragEnter); + dragEnter.setScenePos(item->boundingRect().center()); + QApplication::sendEvent(&scene, &dragEnter); + QGraphicsSceneDragDropEvent event(QEvent::GraphicsSceneDragMove); + event.setScenePos(item->boundingRect().center()); + QApplication::sendEvent(&scene, &event); + QVERIFY(QGraphicsScenePrivate::get(&scene)->dragDropItem == item); + delete item; + QVERIFY(QGraphicsScenePrivate::get(&scene)->dragDropItem == 0); +} QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index d5f63d3..6cea834 100644 --- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -3436,6 +3436,21 @@ void tst_QGraphicsProxyWidget::inputMethod() qApp->sendEvent(proxy, &event); QCOMPARE(lineEdit->inputMethodEvents, i); } + + scene.clear(); + QGraphicsView view(&scene); + QWidget *w = new QWidget; + w->setLayout(new QVBoxLayout(w)); + QLineEdit *lineEdit = new QLineEdit; + lineEdit->setEchoMode(QLineEdit::Password); + w->layout()->addWidget(lineEdit); + lineEdit->setAttribute(Qt::WA_InputMethodEnabled, true); + QGraphicsProxyWidget *proxy = scene.addWidget(w); + view.show(); + QTest::qWaitForWindowShown(&view); + QTRY_VERIFY(!(proxy->flags() & QGraphicsItem::ItemAcceptsInputMethod)); + lineEdit->setFocus(); + QVERIFY((proxy->flags() & QGraphicsItem::ItemAcceptsInputMethod)); } void tst_QGraphicsProxyWidget::clickFocus() diff --git a/tests/auto/qgraphicsvideoitem/qgraphicsvideoitem.pro b/tests/auto/qgraphicsvideoitem/qgraphicsvideoitem.pro deleted file mode 100644 index b57e8e3..0000000 --- a/tests/auto/qgraphicsvideoitem/qgraphicsvideoitem.pro +++ /dev/null @@ -1,5 +0,0 @@ -load(qttest_p4) -SOURCES += tst_qgraphicsvideoitem.cpp - -QT += multimedia mediaservices -requires(contains(QT_CONFIG, mediaservices)) diff --git a/tests/auto/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp b/tests/auto/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp deleted file mode 100644 index 1815779..0000000 --- a/tests/auto/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp +++ /dev/null @@ -1,670 +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 <QtTest/QtTest> - -#include <QtMediaServices/qgraphicsvideoitem.h> - -#include <QtGui/qapplication.h> -#include <QtGui/qgraphicsscene.h> -#include <QtGui/qgraphicsview.h> -#include <QtMultimedia/qabstractvideosurface.h> -#include <QtMediaServices/qmediaobject.h> -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/qvideooutputcontrol.h> -#include <QtMediaServices/qvideorenderercontrol.h> -#include <QtMultimedia/qvideosurfaceformat.h> - -#include <QtMediaServices/private/qpaintervideosurface_p.h> - -class tst_QGraphicsVideoItem : public QObject -{ - Q_OBJECT -public slots: - void initTestCase(); - -private slots: - void nullObject(); - void nullService(); - void nullOutputControl(); - void noOutputs(); - void serviceDestroyed(); - void mediaObjectDestroyed(); - void setMediaObject(); - - void show(); - - void aspectRatioMode(); - void offset(); - void size(); - void nativeSize_data(); - void nativeSize(); - - void boundingRect_data(); - void boundingRect(); - - void paint(); -}; - -Q_DECLARE_METATYPE(const uchar *) -Q_DECLARE_METATYPE(Qt::AspectRatioMode) - -class QtTestOutputControl : public QVideoOutputControl -{ -public: - QtTestOutputControl() : m_output(NoOutput) {} - - QList<Output> availableOutputs() const { return m_outputs; } - void setAvailableOutputs(const QList<Output> outputs) { m_outputs = outputs; } - - Output output() const { return m_output; } - virtual void setOutput(Output output) { m_output = output; } - -private: - Output m_output; - QList<Output> m_outputs; -}; - -class QtTestRendererControl : public QVideoRendererControl -{ -public: - QtTestRendererControl() - : m_surface(0) - { - } - - QAbstractVideoSurface *surface() const { return m_surface; } - void setSurface(QAbstractVideoSurface *surface) { m_surface = surface; } - -private: - QAbstractVideoSurface *m_surface; -}; - -class QtTestVideoService : public QMediaService -{ - Q_OBJECT -public: - QtTestVideoService( - QtTestOutputControl *output, - QtTestRendererControl *renderer) - : QMediaService(0) - , outputControl(output) - , rendererControl(renderer) - { - } - - ~QtTestVideoService() - { - delete outputControl; - delete rendererControl; - } - - QMediaControl *control(const char *name) const - { - if (qstrcmp(name, QVideoOutputControl_iid) == 0) - return outputControl; - else if (qstrcmp(name, QVideoRendererControl_iid) == 0) - return rendererControl; - else - return 0; - } - - QtTestOutputControl *outputControl; - QtTestRendererControl *rendererControl; -}; - -class QtTestVideoObject : public QMediaObject -{ - Q_OBJECT -public: - QtTestVideoObject(QtTestRendererControl *renderer): - QMediaObject(0, new QtTestVideoService(new QtTestOutputControl, renderer)) - { - testService = qobject_cast<QtTestVideoService*>(service()); - QList<QVideoOutputControl::Output> outputs; - - if (renderer) - outputs.append(QVideoOutputControl::RendererOutput); - - testService->outputControl->setAvailableOutputs(outputs); - } - - QtTestVideoObject(QtTestVideoService *service): - QMediaObject(0, service), - testService(service) - { - } - - ~QtTestVideoObject() - { - delete testService; - } - - QtTestVideoService *testService; -}; - -class QtTestGraphicsVideoItem : public QGraphicsVideoItem -{ -public: - QtTestGraphicsVideoItem(QGraphicsItem *parent = 0) - : QGraphicsVideoItem(parent) - , m_paintCount(0) - { - } - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) - { - ++m_paintCount; - - QTestEventLoop::instance().exitLoop(); - - QGraphicsVideoItem::paint(painter, option, widget); - } - - bool waitForPaint(int secs) - { - const int paintCount = m_paintCount; - - QTestEventLoop::instance().enterLoop(secs); - - return m_paintCount != paintCount; - } - - int paintCount() const - { - return m_paintCount; - } - -private: - int m_paintCount; -}; - -void tst_QGraphicsVideoItem::initTestCase() -{ - qRegisterMetaType<Qt::AspectRatioMode>(); -} - -void tst_QGraphicsVideoItem::nullObject() -{ - QGraphicsVideoItem item(0); - - QVERIFY(item.boundingRect().isEmpty()); -} - -void tst_QGraphicsVideoItem::nullService() -{ - QtTestVideoService *service = 0; - - QtTestVideoObject object(service); - - QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem; - item->setMediaObject(&object); - - QVERIFY(item->boundingRect().isEmpty()); - - item->hide(); - item->show(); - - QGraphicsScene graphicsScene; - graphicsScene.addItem(item); - QGraphicsView graphicsView(&graphicsScene); - graphicsView.show(); -} - -void tst_QGraphicsVideoItem::nullOutputControl() -{ - QtTestVideoObject object(new QtTestVideoService(0, 0)); - - QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem; - item->setMediaObject(&object); - - QVERIFY(item->boundingRect().isEmpty()); - - item->hide(); - item->show(); - - QGraphicsScene graphicsScene; - graphicsScene.addItem(item); - QGraphicsView graphicsView(&graphicsScene); - graphicsView.show(); -} - -void tst_QGraphicsVideoItem::noOutputs() -{ - QtTestRendererControl *control = 0; - QtTestVideoObject object(control); - - QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem; - item->setMediaObject(&object); - - QVERIFY(item->boundingRect().isEmpty()); - - item->hide(); - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - item->show(); - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - QGraphicsScene graphicsScene; - graphicsScene.addItem(item); - QGraphicsView graphicsView(&graphicsScene); - graphicsView.show(); -} - -void tst_QGraphicsVideoItem::serviceDestroyed() -{ - QtTestVideoObject object(new QtTestRendererControl); - - QGraphicsVideoItem item; - item.setMediaObject(&object); - - QtTestVideoService *service = object.testService; - object.testService = 0; - - delete service; - - QCOMPARE(item.mediaObject(), static_cast<QMediaObject *>(&object)); - QVERIFY(item.boundingRect().isEmpty()); -} - -void tst_QGraphicsVideoItem::mediaObjectDestroyed() -{ - QtTestVideoObject *object = new QtTestVideoObject(new QtTestRendererControl); - - QGraphicsVideoItem item; - item.setMediaObject(object); - - delete object; - object = 0; - - QCOMPARE(item.mediaObject(), static_cast<QMediaObject *>(object)); - QVERIFY(item.boundingRect().isEmpty()); -} - -void tst_QGraphicsVideoItem::setMediaObject() -{ - QMediaObject *nullObject = 0; - QtTestVideoObject object(new QtTestRendererControl); - - QGraphicsVideoItem item; - - QCOMPARE(item.mediaObject(), nullObject); - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - item.setMediaObject(&object); - QCOMPARE(item.mediaObject(), static_cast<QMediaObject *>(&object)); - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::RendererOutput); - QVERIFY(object.testService->rendererControl->surface() != 0); - - item.setMediaObject(0); - QCOMPARE(item.mediaObject(), nullObject); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - item.setVisible(false); - - item.setMediaObject(&object); - QCOMPARE(item.mediaObject(), static_cast<QMediaObject *>(&object)); - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - QVERIFY(object.testService->rendererControl->surface() != 0); -} - -void tst_QGraphicsVideoItem::show() -{ - QtTestVideoObject object(new QtTestRendererControl); - QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem; - item->setMediaObject(&object); - - // Graphics items are visible by default - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::RendererOutput); - QVERIFY(object.testService->rendererControl->surface() != 0); - - item->hide(); - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::RendererOutput); - - item->show(); - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::RendererOutput); - QVERIFY(object.testService->rendererControl->surface() != 0); - - QVERIFY(item->boundingRect().isEmpty()); - - QVideoSurfaceFormat format(QSize(320,240),QVideoFrame::Format_RGB32); - QVERIFY(object.testService->rendererControl->surface()->start(format)); - - QVERIFY(!item->boundingRect().isEmpty()); - - QGraphicsScene graphicsScene; - graphicsScene.addItem(item); - QGraphicsView graphicsView(&graphicsScene); - graphicsView.show(); - - QVERIFY(item->paintCount() || item->waitForPaint(1)); -} - -void tst_QGraphicsVideoItem::aspectRatioMode() -{ - QGraphicsVideoItem item; - - QCOMPARE(item.aspectRatioMode(), Qt::KeepAspectRatio); - - item.setAspectRatioMode(Qt::IgnoreAspectRatio); - QCOMPARE(item.aspectRatioMode(), Qt::IgnoreAspectRatio); - - item.setAspectRatioMode(Qt::KeepAspectRatioByExpanding); - QCOMPARE(item.aspectRatioMode(), Qt::KeepAspectRatioByExpanding); - - item.setAspectRatioMode(Qt::KeepAspectRatio); - QCOMPARE(item.aspectRatioMode(), Qt::KeepAspectRatio); -} - -void tst_QGraphicsVideoItem::offset() -{ - QGraphicsVideoItem item; - - QCOMPARE(item.offset(), QPointF(0, 0)); - - item.setOffset(QPointF(-32.4, 43.0)); - QCOMPARE(item.offset(), QPointF(-32.4, 43.0)); - - item.setOffset(QPointF(1, 1)); - QCOMPARE(item.offset(), QPointF(1, 1)); - - item.setOffset(QPointF(12, -30.4)); - QCOMPARE(item.offset(), QPointF(12, -30.4)); - - item.setOffset(QPointF(-90.4, -75)); - QCOMPARE(item.offset(), QPointF(-90.4, -75)); -} - -void tst_QGraphicsVideoItem::size() -{ - QGraphicsVideoItem item; - - QCOMPARE(item.size(), QSizeF(320, 240)); - - item.setSize(QSizeF(542.5, 436.3)); - QCOMPARE(item.size(), QSizeF(542.5, 436.3)); - - item.setSize(QSizeF(-43, 12)); - QCOMPARE(item.size(), QSizeF(0, 0)); - - item.setSize(QSizeF(54, -9)); - QCOMPARE(item.size(), QSizeF(0, 0)); - - item.setSize(QSizeF(-90, -65)); - QCOMPARE(item.size(), QSizeF(0, 0)); - - item.setSize(QSizeF(1000, 1000)); - QCOMPARE(item.size(), QSizeF(1000, 1000)); -} - -void tst_QGraphicsVideoItem::nativeSize_data() -{ - QTest::addColumn<QSize>("frameSize"); - QTest::addColumn<QRect>("viewport"); - QTest::addColumn<QSize>("pixelAspectRatio"); - QTest::addColumn<QSizeF>("nativeSize"); - - QTest::newRow("640x480") - << QSize(640, 480) - << QRect(0, 0, 640, 480) - << QSize(1, 1) - << QSizeF(640, 480); - - QTest::newRow("800x600, (80,60, 640x480) viewport") - << QSize(800, 600) - << QRect(80, 60, 640, 480) - << QSize(1, 1) - << QSizeF(640, 480); - - QTest::newRow("800x600, (80,60, 640x480) viewport, 4:3") - << QSize(800, 600) - << QRect(80, 60, 640, 480) - << QSize(4, 3) - << QSizeF(853, 480); -} - -void tst_QGraphicsVideoItem::nativeSize() -{ - QFETCH(QSize, frameSize); - QFETCH(QRect, viewport); - QFETCH(QSize, pixelAspectRatio); - QFETCH(QSizeF, nativeSize); - - QtTestVideoObject object(new QtTestRendererControl); - QGraphicsVideoItem item; - item.setMediaObject(&object); - - QCOMPARE(item.nativeSize(), QSizeF()); - - QSignalSpy spy(&item, SIGNAL(nativeSizeChanged(QSizeF))); - - QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_ARGB32); - format.setViewport(viewport); - format.setPixelAspectRatio(pixelAspectRatio); - - QVERIFY(object.testService->rendererControl->surface()->start(format)); - - QCOMPARE(item.nativeSize(), nativeSize); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.last().first().toSizeF(), nativeSize); - - object.testService->rendererControl->surface()->stop(); - - QCOMPARE(item.nativeSize(), QSizeF(0, 0)); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.last().first().toSizeF(), QSizeF(0, 0)); -} - -void tst_QGraphicsVideoItem::boundingRect_data() -{ - QTest::addColumn<QSize>("frameSize"); - QTest::addColumn<QPointF>("offset"); - QTest::addColumn<QSizeF>("size"); - QTest::addColumn<Qt::AspectRatioMode>("aspectRatioMode"); - QTest::addColumn<QRectF>("expectedRect"); - - - QTest::newRow("640x480: (0,0 640x480), Keep") - << QSize(640, 480) - << QPointF(0, 0) - << QSizeF(640, 480) - << Qt::KeepAspectRatio - << QRectF(0, 0, 640, 480); - - QTest::newRow("800x600, (0,0, 640x480), Keep") - << QSize(800, 600) - << QPointF(0, 0) - << QSizeF(640, 480) - << Qt::KeepAspectRatio - << QRectF(0, 0, 640, 480); - - QTest::newRow("800x600, (0,0, 640x480), KeepByExpanding") - << QSize(800, 600) - << QPointF(0, 0) - << QSizeF(640, 480) - << Qt::KeepAspectRatioByExpanding - << QRectF(0, 0, 640, 480); - - QTest::newRow("800x600, (0,0, 640x480), Ignore") - << QSize(800, 600) - << QPointF(0, 0) - << QSizeF(640, 480) - << Qt::IgnoreAspectRatio - << QRectF(0, 0, 640, 480); - - QTest::newRow("800x600, (100,100, 640x480), Keep") - << QSize(800, 600) - << QPointF(100, 100) - << QSizeF(640, 480) - << Qt::KeepAspectRatio - << QRectF(100, 100, 640, 480); - - QTest::newRow("800x600, (100,-100, 640x480), KeepByExpanding") - << QSize(800, 600) - << QPointF(100, -100) - << QSizeF(640, 480) - << Qt::KeepAspectRatioByExpanding - << QRectF(100, -100, 640, 480); - - QTest::newRow("800x600, (-100,-100, 640x480), Ignore") - << QSize(800, 600) - << QPointF(-100, -100) - << QSizeF(640, 480) - << Qt::IgnoreAspectRatio - << QRectF(-100, -100, 640, 480); - - QTest::newRow("800x600, (0,0, 1920x1024), Keep") - << QSize(800, 600) - << QPointF(0, 0) - << QSizeF(1920, 1024) - << Qt::KeepAspectRatio - << QRectF(832.0 / 3, 0, 4096.0 / 3, 1024); - - QTest::newRow("800x600, (0,0, 1920x1024), KeepByExpanding") - << QSize(800, 600) - << QPointF(0, 0) - << QSizeF(1920, 1024) - << Qt::KeepAspectRatioByExpanding - << QRectF(0, 0, 1920, 1024); - - QTest::newRow("800x600, (0,0, 1920x1024), Ignore") - << QSize(800, 600) - << QPointF(0, 0) - << QSizeF(1920, 1024) - << Qt::IgnoreAspectRatio - << QRectF(0, 0, 1920, 1024); - - QTest::newRow("800x600, (100,100, 1920x1024), Keep") - << QSize(800, 600) - << QPointF(100, 100) - << QSizeF(1920, 1024) - << Qt::KeepAspectRatio - << QRectF(100 + 832.0 / 3, 100, 4096.0 / 3, 1024); - - QTest::newRow("800x600, (100,-100, 1920x1024), KeepByExpanding") - << QSize(800, 600) - << QPointF(100, -100) - << QSizeF(1920, 1024) - << Qt::KeepAspectRatioByExpanding - << QRectF(100, -100, 1920, 1024); - - QTest::newRow("800x600, (-100,-100, 1920x1024), Ignore") - << QSize(800, 600) - << QPointF(-100, -100) - << QSizeF(1920, 1024) - << Qt::IgnoreAspectRatio - << QRectF(-100, -100, 1920, 1024); -} - -void tst_QGraphicsVideoItem::boundingRect() -{ - QFETCH(QSize, frameSize); - QFETCH(QPointF, offset); - QFETCH(QSizeF, size); - QFETCH(Qt::AspectRatioMode, aspectRatioMode); - QFETCH(QRectF, expectedRect); - - QtTestVideoObject object(new QtTestRendererControl); - QGraphicsVideoItem item; - item.setMediaObject(&object); - - item.setOffset(offset); - item.setSize(size); - item.setAspectRatioMode(aspectRatioMode); - - QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_ARGB32); - - QVERIFY(object.testService->rendererControl->surface()->start(format)); - - QCOMPARE(item.boundingRect(), expectedRect); -} - -static const uchar rgb32ImageData[] = -{ - 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, - 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00 -}; - -void tst_QGraphicsVideoItem::paint() -{ - QtTestVideoObject object(new QtTestRendererControl); - QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem; - item->setMediaObject(&object); - - QGraphicsScene graphicsScene; - graphicsScene.addItem(item); - QGraphicsView graphicsView(&graphicsScene); - graphicsView.show(); - - QPainterVideoSurface *surface = qobject_cast<QPainterVideoSurface *>( - object.testService->rendererControl->surface()); - - QVideoSurfaceFormat format(QSize(2, 2), QVideoFrame::Format_RGB32); - - QVERIFY(surface->start(format)); - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), true); - - QVERIFY(item->waitForPaint(1)); - - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), true); - - QVideoFrame frame(sizeof(rgb32ImageData), QSize(2, 2), 8, QVideoFrame::Format_RGB32); - - frame.map(QAbstractVideoBuffer::WriteOnly); - memcpy(frame.bits(), rgb32ImageData, frame.mappedBytes()); - frame.unmap(); - - QVERIFY(surface->present(frame)); - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), false); - - QVERIFY(item->waitForPaint(1)); - - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), true); -} - - -QTEST_MAIN(tst_QGraphicsVideoItem) - -#include "tst_qgraphicsvideoitem.moc" diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 1df9a37..b8df7f6 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -218,6 +218,7 @@ private slots: void update(); void update2_data(); void update2(); + void update_ancestorClipsChildrenToShape(); void inputMethodSensitivity(); void inputContextReset(); void indirectPainting(); @@ -3758,6 +3759,62 @@ void tst_QGraphicsView::update2() #endif } +void tst_QGraphicsView::update_ancestorClipsChildrenToShape() +{ + QGraphicsScene scene(-150, -150, 300, 300); + + /* + Add three rects: + + +------------------+ + | child | + | +--------------+ | + | | parent | | + | | +-----------+ | + | | |grandParent| | + | | +-----------+ | + | +--------------+ | + +------------------+ + + ... where both the parent and the grand parent clips children to shape. + */ + QApplication::processEvents(); // Get rid of pending update. + + QGraphicsRectItem *grandParent = static_cast<QGraphicsRectItem *>(scene.addRect(0, 0, 50, 50)); + grandParent->setBrush(Qt::black); + grandParent->setFlag(QGraphicsItem::ItemClipsChildrenToShape); + + QGraphicsRectItem *parent = static_cast<QGraphicsRectItem *>(scene.addRect(-50, -50, 100, 100)); + parent->setBrush(QColor(0, 0, 255, 125)); + parent->setParentItem(grandParent); + parent->setFlag(QGraphicsItem::ItemClipsChildrenToShape); + + QGraphicsRectItem *child = static_cast<QGraphicsRectItem *>(scene.addRect(-100, -100, 200, 200)); + child->setBrush(QColor(255, 0, 0, 125)); + child->setParentItem(parent); + + CustomView view(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + QTRY_VERIFY(view.painted); + + view.lastUpdateRegions.clear(); + view.painted = false; + + // Call child->update() and make sure the updated area is within the ancestors' clip. + QRectF expected = child->deviceTransform(view.viewportTransform()).mapRect(child->boundingRect()); + expected &= grandParent->deviceTransform(view.viewportTransform()).mapRect(grandParent->boundingRect()); + + child->update(); + QTRY_VERIFY(view.painted); + +#ifndef QT_MAC_USE_COCOA //cocoa doesn't support drawing regions + QTRY_VERIFY(view.painted); + QCOMPARE(view.lastUpdateRegions.size(), 1); + QCOMPARE(view.lastUpdateRegions.at(0), QRegion(expected.toAlignedRect())); +#endif +} + class FocusItem : public QGraphicsRectItem { public: diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 5a1d20b..ed8ff04 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -169,6 +169,7 @@ private slots: void initialShow(); void initialShow2(); void itemChangeEvents(); + void itemSendGeometryPosChangesDeactivated(); // Task fixes void task236127_bspTreeIndexFails(); @@ -3030,6 +3031,34 @@ void tst_QGraphicsWidget::itemChangeEvents() QTRY_VERIFY(!item->valueDuringEvents.value(QEvent::EnabledChange).toBool()); } +void tst_QGraphicsWidget::itemSendGeometryPosChangesDeactivated() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + QGraphicsWidget *item = new QGraphicsWidget; + scene.addItem(item); + view.show(); + QTest::qWaitForWindowShown(&view); + item->setGeometry(QRectF(0, 0, 50, 50)); + QTRY_COMPARE(item->geometry(), QRectF(0, 0, 50, 50)); + + item->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); + item->setGeometry(QRectF(0, 0, 60, 60)); + QCOMPARE(item->geometry(), QRectF(0, 0, 60, 60)); + QCOMPARE(item->pos(), QPointF(0, 0)); + item->setPos(QPointF(10, 10)); + QCOMPARE(item->pos(), QPointF(10, 10)); + QCOMPARE(item->geometry(), QRectF(10, 10, 60, 60)); + + item->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false); + item->setGeometry(QRectF(0, 0, 60, 60)); + QCOMPARE(item->geometry(), QRectF(0, 0, 60, 60)); + QCOMPARE(item->pos(), QPointF(0, 0)); + item->setPos(QPointF(10, 10)); + QCOMPARE(item->pos(), QPointF(10, 10)); + QCOMPARE(item->geometry(), QRectF(10, 10, 60, 60)); +} + void tst_QGraphicsWidget::QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems() { QGraphicsScene scene; diff --git a/tests/auto/qhostaddress/qhostaddress.pro b/tests/auto/qhostaddress/qhostaddress.pro index b208214..7bcbfb0 100644 --- a/tests/auto/qhostaddress/qhostaddress.pro +++ b/tests/auto/qhostaddress/qhostaddress.pro @@ -12,3 +12,4 @@ wince*: { } } +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qhostinfo/qhostinfo.pro b/tests/auto/qhostinfo/qhostinfo.pro index 9bfe576..97197a9 100644 --- a/tests/auto/qhostinfo/qhostinfo.pro +++ b/tests/auto/qhostinfo/qhostinfo.pro @@ -2,7 +2,7 @@ load(qttest_p4) SOURCES += tst_qhostinfo.cpp -QT = core network core +QT = core network wince*: { LIBS += ws2.lib @@ -10,4 +10,7 @@ wince*: { win32:LIBS += -lws2_32 } - +symbian: TARGET.CAPABILITY = NetworkServices +symbian: { + INCLUDEPATH *= $$MW_LAYER_SYSTEMINCLUDE +} diff --git a/tests/auto/qhttp/qhttp.pro b/tests/auto/qhttp/qhttp.pro index 8678a19..23a73c4 100644 --- a/tests/auto/qhttp/qhttp.pro +++ b/tests/auto/qhttp/qhttp.pro @@ -21,6 +21,7 @@ wince*: { addFiles.sources = rfc3252.txt trolltech addFiles.path = . DEPLOYMENT = addFiles webFiles cgi + TARGET.CAPABILITY = NetworkServices } else:vxworks*: { DEFINES += SRCDIR=\\\"\\\" } else { diff --git a/tests/auto/qhttpnetworkconnection/qhttpnetworkconnection.pro b/tests/auto/qhttpnetworkconnection/qhttpnetworkconnection.pro index 0021bc1..d9e2dce 100644 --- a/tests/auto/qhttpnetworkconnection/qhttpnetworkconnection.pro +++ b/tests/auto/qhttpnetworkconnection/qhttpnetworkconnection.pro @@ -4,3 +4,5 @@ INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/zlib requires(contains(QT_CONFIG,private_tests)) QT = core network + +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index 21f228a..89f608e 100644 --- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -109,6 +109,9 @@ private Q_SLOTS: void getMultipleWithPriorities(); void getEmptyWithPipelining(); + + void getAndThenDeleteObject(); + void getAndThenDeleteObject_data(); }; tst_QHttpNetworkConnection::tst_QHttpNetworkConnection() @@ -1033,6 +1036,47 @@ void tst_QHttpNetworkConnection::getEmptyWithPipelining() qDeleteAll(replies); } +void tst_QHttpNetworkConnection::getAndThenDeleteObject_data() +{ + QTest::addColumn<bool>("replyFirst"); + + QTest::newRow("delete-reply-first") << true; + QTest::newRow("delete-connection-first") << false; +} + +void tst_QHttpNetworkConnection::getAndThenDeleteObject() +{ + // yes, this will leak if the testcase fails. I don't care. It must not fail then :P + QHttpNetworkConnection *connection = new QHttpNetworkConnection(QtNetworkSettings::serverName()); + QHttpNetworkRequest request("http://" + QtNetworkSettings::serverName() + "/qtest/bigfile"); + QHttpNetworkReply *reply = connection->sendRequest(request); + reply->setDownstreamLimited(true); + + QTime stopWatch; + stopWatch.start(); + forever { + QCoreApplication::instance()->processEvents(); + if (reply->bytesAvailable()) + break; + if (stopWatch.elapsed() >= 30000) + break; + } + + QVERIFY(reply->bytesAvailable()); + QCOMPARE(reply->statusCode() ,200); + QVERIFY(!reply->isFinished()); // must not be finished + + QFETCH(bool, replyFirst); + + if (replyFirst) { + delete reply; + delete connection; + } else { + delete connection; + delete reply; + } +} + QTEST_MAIN(tst_QHttpNetworkConnection) diff --git a/tests/auto/qhttpnetworkreply/qhttpnetworkreply.pro b/tests/auto/qhttpnetworkreply/qhttpnetworkreply.pro index 1782b43..36d56c6 100644 --- a/tests/auto/qhttpnetworkreply/qhttpnetworkreply.pro +++ b/tests/auto/qhttpnetworkreply/qhttpnetworkreply.pro @@ -4,3 +4,4 @@ INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/zlib requires(contains(QT_CONFIG,private_tests)) QT = core network +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qhttpsocketengine/qhttpsocketengine.pro b/tests/auto/qhttpsocketengine/qhttpsocketengine.pro index f6ad073..d76ebb6 100644 --- a/tests/auto/qhttpsocketengine/qhttpsocketengine.pro +++ b/tests/auto/qhttpsocketengine/qhttpsocketengine.pro @@ -8,5 +8,6 @@ MOC_DIR=tmp QT = core network +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index 1b4c502..aadee5b 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -114,6 +114,9 @@ private slots: void readFromFileAfterJunk_data(); void readFromFileAfterJunk(); + void devicePosition_data(); + void devicePosition(); + void setBackgroundColor_data(); void setBackgroundColor(); @@ -1117,7 +1120,7 @@ void tst_QImageReader::readFromFileAfterJunk() QByteArray imageData = imageFile.readAll(); QVERIFY(!imageData.isNull()); - int iterations = 10; + int iterations = 3; if (format == "ppm" || format == "pbm" || format == "pgm" || format == "svg" || format == "svgz") iterations = 1; @@ -1147,6 +1150,64 @@ void tst_QImageReader::readFromFileAfterJunk() } } +void tst_QImageReader::devicePosition_data() +{ + QTest::addColumn<QString>("fileName"); + QTest::addColumn<QByteArray>("format"); + + QTest::newRow("pbm") << QString("image.pbm") << QByteArray("pbm"); + QTest::newRow("pgm") << QString("image.pgm") << QByteArray("pgm"); + QTest::newRow("ppm-1") << QString("image.ppm") << QByteArray("ppm"); +#ifdef QTEST_HAVE_JPEG + QTest::newRow("jpeg-1") << QString("beavis.jpg") << QByteArray("jpeg"); + QTest::newRow("jpeg-2") << QString("YCbCr_cmyk.jpg") << QByteArray("jpeg"); + QTest::newRow("jpeg-3") << QString("YCbCr_rgb.jpg") << QByteArray("jpeg"); +#endif +#if defined QTEST_HAVE_GIF + QTest::newRow("gif-1") << QString("earth.gif") << QByteArray("gif"); +#endif + QTest::newRow("xbm") << QString("gnus.xbm") << QByteArray("xbm"); + QTest::newRow("xpm") << QString("marble.xpm") << QByteArray("xpm"); + QTest::newRow("bmp-1") << QString("colorful.bmp") << QByteArray("bmp"); + QTest::newRow("bmp-2") << QString("font.bmp") << QByteArray("bmp"); + QTest::newRow("png") << QString("kollada.png") << QByteArray("png"); +// QTest::newRow("mng-1") << QString("images/ball.mng") << QByteArray("mng"); +// QTest::newRow("mng-2") << QString("images/fire.mng") << QByteArray("mng"); +#if defined QTEST_HAVE_SVG + QTest::newRow("svg") << QString("rect.svg") << QByteArray("svg"); + QTest::newRow("svgz") << QString("rect.svgz") << QByteArray("svgz"); +#endif +} + +void tst_QImageReader::devicePosition() +{ + QFETCH(QString, fileName); + QFETCH(QByteArray, format); + + QImage expected(prefix + fileName); + QVERIFY(!expected.isNull()); + + QFile imageFile(prefix + fileName); + QVERIFY(imageFile.open(QFile::ReadOnly)); + QByteArray imageData = imageFile.readAll(); + QVERIFY(!imageData.isNull()); + int imageDataSize = imageData.size(); + + const char *preStr = "prebeef\n"; + int preLen = qstrlen(preStr); + imageData.prepend(preStr); + if (format != "svg" && format != "svgz") // Doesn't handle trailing data + imageData.append("\npostbeef"); + QBuffer buf(&imageData); + buf.open(QIODevice::ReadOnly); + buf.seek(preLen); + QImageReader reader(&buf, format); + QCOMPARE(expected, reader.read()); + if (format != "ppm" && format != "gif") // Known not to work + QCOMPARE(buf.pos(), qint64(preLen+imageDataSize)); +} + + void tst_QImageReader::description_data() { QTest::addColumn<QString>("fileName"); diff --git a/tests/auto/qiodevice/qiodevice.pro b/tests/auto/qiodevice/qiodevice.pro index e695bf6..716cdce 100644 --- a/tests/auto/qiodevice/qiodevice.pro +++ b/tests/auto/qiodevice/qiodevice.pro @@ -14,6 +14,7 @@ wince*: { addFiles.sources = tst_qiodevice.cpp addFiles.path = . DEPLOYMENT += addFiles + TARGET.CAPABILITY = NetworkServices } else { DEFINES += SRCDIR=\\\"$$PWD/\\\" contains(QT_CONFIG, qt3support):QT += qt3support diff --git a/tests/auto/qlocale/tst_qlocale.cpp b/tests/auto/qlocale/tst_qlocale.cpp index 7a5d8a6..7e9b8ec 100644 --- a/tests/auto/qlocale/tst_qlocale.cpp +++ b/tests/auto/qlocale/tst_qlocale.cpp @@ -192,6 +192,7 @@ void tst_QLocale::ctor() TEST_CTOR(French, France, QLocale::French, QLocale::France) TEST_CTOR(C, France, QLocale::C, QLocale::AnyCountry) + TEST_CTOR(Spanish, LatinAmericaAndTheCaribbean, QLocale::Spanish, QLocale::LatinAmericaAndTheCaribbean) QLocale::setDefault(QLocale(QLocale::English, QLocale::France)); @@ -323,6 +324,12 @@ void tst_QLocale::ctor() TEST_CTOR("no_NO", Norwegian, Norway) TEST_CTOR("nb_NO", Norwegian, Norway) TEST_CTOR("nn_NO", NorwegianNynorsk, Norway) + TEST_CTOR("es_ES", Spanish, Spain) + TEST_CTOR("es_419", Spanish, LatinAmericaAndTheCaribbean) + + // test default countries for languages + TEST_CTOR("mn", Mongolian, Mongolia) + TEST_CTOR("ne", Nepali, Nepal) #undef TEST_CTOR @@ -1321,10 +1328,12 @@ static const LocaleListItem g_locale_list[] = { { 9, 11}, // Armenian/Armenia { 10, 100}, // Assamese/India { 12, 15}, // Azerbaijani/Azerbaijan + { 12, 102}, // Azerbaijani/Iran { 14, 197}, // Basque/Spain { 15, 18}, // Bengali/Bangladesh { 15, 100}, // Bengali/India { 16, 25}, // Bhutani/Bhutan + { 19, 74}, // Breton/France { 20, 33}, // Bulgarian/Bulgaria { 21, 147}, // Burmese/Myanmar { 22, 20}, // Byelorussian/Belarus @@ -1354,6 +1363,7 @@ static const LocaleListItem g_locale_list[] = { { 31, 107}, // English/Jamaica { 31, 133}, // English/Malta { 31, 134}, // English/MarshallIslands + { 31, 137}, // English/Mauritius { 31, 148}, // English/Namibia { 31, 154}, // English/NewZealand { 31, 160}, // English/NorthernMarianaIslands @@ -1371,11 +1381,23 @@ static const LocaleListItem g_locale_list[] = { { 36, 73}, // Finnish/Finland { 37, 74}, // French/France { 37, 21}, // French/Belgium + { 37, 37}, // French/Cameroon { 37, 38}, // French/Canada + { 37, 41}, // French/CentralAfricanRepublic + { 37, 53}, // French/IvoryCoast + { 37, 88}, // French/Guadeloupe + { 37, 91}, // French/Guinea { 37, 125}, // French/Luxembourg + { 37, 128}, // French/Madagascar + { 37, 132}, // French/Mali + { 37, 135}, // French/Martinique { 37, 142}, // French/Monaco + { 37, 156}, // French/Niger + { 37, 176}, // French/Reunion { 37, 187}, // French/Senegal { 37, 206}, // French/Switzerland + { 37, 244}, // French/Saint Barthelemy + { 37, 245}, // French/Saint Martin { 40, 197}, // Galician/Spain { 41, 81}, // Georgian/Georgia { 42, 82}, // German/Germany @@ -1406,6 +1428,9 @@ static const LocaleListItem g_locale_list[] = { { 64, 179}, // Kinyarwanda/Rwanda { 65, 116}, // Kirghiz/Kyrgyzstan { 66, 114}, // Korean/RepublicOfKorea + { 67, 102}, // Kurdish/Iran + { 67, 103}, // Kurdish/Iraq + { 67, 207}, // Kurdish/SyrianArabRepublic { 67, 217}, // Kurdish/Turkey { 69, 117}, // Laothian/Lao { 71, 118}, // Latvian/Latvia @@ -1413,16 +1438,19 @@ static const LocaleListItem g_locale_list[] = { { 72, 50}, // Lingala/PeoplesRepublicOfCongo { 73, 124}, // Lithuanian/Lithuania { 74, 127}, // Macedonian/Macedonia + { 75, 128}, // Malagasy/Madagascar { 76, 130}, // Malay/Malaysia { 76, 32}, // Malay/BruneiDarussalam { 77, 100}, // Malayalam/India { 78, 133}, // Maltese/Malta + { 79, 154}, // Maori/NewZealand { 80, 100}, // Marathi/India { 82, 44}, // Mongolian/China { 82, 143}, // Mongolian/Mongolia { 84, 100}, // Nepali/India { 84, 150}, // Nepali/Nepal { 85, 161}, // Norwegian/Norway + { 86, 74}, // Occitan/France { 87, 100}, // Oriya/India { 88, 1}, // Pashto/Afghanistan { 89, 102}, // Persian/Iran @@ -1430,22 +1458,30 @@ static const LocaleListItem g_locale_list[] = { { 90, 172}, // Polish/Poland { 91, 173}, // Portuguese/Portugal { 91, 30}, // Portuguese/Brazil + { 91, 92}, // Portuguese/GuineaBissau + { 91, 146}, // Portuguese/Mozambique { 92, 100}, // Punjabi/India { 92, 163}, // Punjabi/Pakistan + { 94, 206}, // RhaetoRomance/Switzerland { 95, 141}, // Romanian/Moldova { 95, 177}, // Romanian/Romania { 96, 178}, // Russian/RussianFederation + { 96, 141}, // Russian/Moldova { 96, 222}, // Russian/Ukraine + { 98, 41}, // Sangho/CentralAfricanRepublic { 99, 100}, // Sanskrit/India { 100, 241}, // Serbian/SerbiaAndMontenegro { 100, 27}, // Serbian/BosniaAndHerzegowina { 100, 238}, // Serbian/Yugoslavia + { 100, 242}, // Serbian/Montenegro + { 100, 243}, // Serbian/Serbia { 101, 241}, // SerboCroatian/SerbiaAndMontenegro { 101, 27}, // SerboCroatian/BosniaAndHerzegowina { 101, 238}, // SerboCroatian/Yugoslavia { 102, 120}, // Sesotho/Lesotho { 102, 195}, // Sesotho/SouthAfrica { 103, 195}, // Setswana/SouthAfrica + { 104, 240}, // Shona/Zimbabwe { 106, 198}, // Singhalese/SriLanka { 107, 195}, // Siswati/SouthAfrica { 107, 204}, // Siswati/Swaziland @@ -1464,6 +1500,7 @@ static const LocaleListItem g_locale_list[] = { { 111, 61}, // Spanish/DominicanRepublic { 111, 63}, // Spanish/Ecuador { 111, 65}, // Spanish/ElSalvador + { 111, 66}, // Spanish/EquatorialGuinea { 111, 90}, // Spanish/Guatemala { 111, 96}, // Spanish/Honduras { 111, 139}, // Spanish/Mexico @@ -1481,9 +1518,12 @@ static const LocaleListItem g_locale_list[] = { { 114, 73}, // Swedish/Finland { 116, 209}, // Tajik/Tajikistan { 117, 100}, // Tamil/India + { 117, 198}, // Tamil/SriLanka { 118, 178}, // Tatar/RussianFederation { 119, 100}, // Telugu/India { 120, 211}, // Thai/Thailand + { 121, 44}, // Tibetan/China + { 121, 100}, // Tibetan/India { 122, 67}, // Tigrinya/Eritrea { 122, 69}, // Tigrinya/Ethiopia { 123, 214}, // Tonga/Tonga @@ -1524,9 +1564,63 @@ static const LocaleListItem g_locale_list[] = { { 160, 195}, // Venda/SouthAfrica { 161, 83}, // Ewe/Ghana { 161, 212}, // Ewe/Togo + { 162, 69}, // Walamo/Ethiopia { 163, 225}, // Hawaiian/UnitedStates { 164, 157}, // Tyap/Nigeria - { 165, 129} // Chewa/Malawi + { 165, 129}, // Chewa/Malawi + { 166, 170}, // Filipino/Philippines + { 167, 206}, // Swiss German/Switzerland + { 168, 44}, // Sichuan Yi/China + { 169, 91}, // Kpelle/Guinea + { 169, 121}, // Kpelle/Liberia + { 170, 82}, // Low German/Germany + { 171, 195}, // South Ndebele/SouthAfrica + { 172, 195}, // Northern Sotho/SouthAfrica + { 173, 73}, // Northern Sami/Finland + { 173, 161}, // Northern Sami/Norway + { 174, 208}, // Taroko/Taiwan + { 175, 111}, // Gusii/Kenya + { 176, 111}, // Taita/Kenya + { 177, 187}, // Fulah/Senegal + { 178, 111}, // Kikuyu/Kenya + { 179, 111}, // Samburu/Kenya + { 180, 146}, // Sena/Mozambique + { 181, 240}, // North Ndebele/Zimbabwe + { 182, 210}, // Rombo/Tanzania + { 183, 145}, // Tachelhit/Morocco + { 184, 3}, // Kabyle/Algeria + { 185, 221}, // Nyankole/Uganda + { 186, 210}, // Bena/Tanzania + { 187, 210}, // Vunjo/Tanzania + { 188, 132}, // Bambara/Mali + { 189, 111}, // Embu/Kenya + { 190, 225}, // Cherokee/UnitedStates + { 191, 137}, // Morisyen/Mauritius + { 192, 210}, // Makonde/Tanzania + { 193, 210}, // Langi/Tanzania + { 194, 221}, // Ganda/Uganda + { 195, 239}, // Bemba/Zambia + { 196, 39}, // Kabuverdianu/CapeVerde + { 197, 111}, // Meru/Kenya + { 198, 111}, // Kalenjin/Kenya + { 199, 148}, // Nama/Namibia + { 200, 210}, // Machame/Tanzania + { 201, 82}, // Colognian/Germany + { 202, 111}, // Masai/Kenya + { 202, 210}, // Masai/Tanzania + { 203, 221}, // Soga/Uganda + { 204, 111}, // Luyia/Kenya + { 205, 210}, // Asu/Tanzania + { 206, 111}, // Teso/Kenya + { 206, 221}, // Teso/Uganda + { 207, 67}, // Saho/Eritrea + { 208, 132}, // Koyra Chiini/Mali + { 209, 210}, // Rwa/Tanzania + { 210, 111}, // Luo/Kenya + { 211, 221}, // Chiga/Uganda + { 212, 145}, // Central Morocco Tamazight/Morocco + { 213, 132}, // Koyraboro Senni/Mali + { 214, 210} // Shambala/Tanzania }; static const int g_locale_list_count = sizeof(g_locale_list)/sizeof(g_locale_list[0]); @@ -1896,8 +1990,8 @@ void tst_QLocale::ampm() QCOMPARE(c.pmText(), QLatin1String("PM")); QLocale de("de_DE"); - QCOMPARE(de.amText(), QLatin1String("AM")); - QCOMPARE(de.pmText(), QLatin1String("PM")); + QCOMPARE(de.amText(), QLatin1String("vorm.")); + QCOMPARE(de.pmText(), QLatin1String("nachm.")); QLocale sv("sv_SE"); QCOMPARE(sv.amText(), QLatin1String("fm")); diff --git a/tests/auto/qlocalsocket/qlocalsocket.pro b/tests/auto/qlocalsocket/qlocalsocket.pro index 0849453..287e946 100644 --- a/tests/auto/qlocalsocket/qlocalsocket.pro +++ b/tests/auto/qlocalsocket/qlocalsocket.pro @@ -1,3 +1,4 @@ TEMPLATE = subdirs SUBDIRS = lackey test !wince*:!symbian*: SUBDIRS += example +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qmediacontent/qmediacontent.pro b/tests/auto/qmediacontent/qmediacontent.pro deleted file mode 100644 index e20b4db..0000000 --- a/tests/auto/qmediacontent/qmediacontent.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES += tst_qmediacontent.cpp - -QT = core network mediaservices - diff --git a/tests/auto/qmediacontent/tst_qmediacontent.cpp b/tests/auto/qmediacontent/tst_qmediacontent.cpp deleted file mode 100644 index e33149a..0000000 --- a/tests/auto/qmediacontent/tst_qmediacontent.cpp +++ /dev/null @@ -1,174 +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 <QtTest/QtTest> - -#include <QtMediaServices/qmediacontent.h> - - -class tst_QMediaContent : public QObject -{ - Q_OBJECT - -private slots: - void testNull(); - void testUrlCtor(); - void testRequestCtor(); - void testResourceCtor(); - void testResourceListCtor(); - void testCopy(); - void testAssignment(); - void testEquality(); - void testResources(); -}; - -void tst_QMediaContent::testNull() -{ - QMediaContent media; - - QCOMPARE(media.isNull(), true); - QCOMPARE(media.canonicalUrl(), QUrl()); - QCOMPARE(media.canonicalResource(), QMediaResource()); - QCOMPARE(media.resources(), QMediaResourceList()); -} - -void tst_QMediaContent::testUrlCtor() -{ - QMediaContent media(QUrl("http://example.com/movie.mov")); - - QCOMPARE(media.canonicalUrl(), QUrl("http://example.com/movie.mov")); - QCOMPARE(media.canonicalResource().url(), QUrl("http://example.com/movie.mov")); -} - -void tst_QMediaContent::testRequestCtor() -{ - QNetworkRequest request(QUrl("http://example.com/movie.mov")); - request.setAttribute(QNetworkRequest::User, QVariant(1234)); - - QMediaContent media(request); - - QCOMPARE(media.canonicalRequest(), request); - QCOMPARE(media.canonicalUrl(), QUrl("http://example.com/movie.mov")); - QCOMPARE(media.canonicalResource().request(), request); - QCOMPARE(media.canonicalResource().url(), QUrl("http://example.com/movie.mov")); -} - -void tst_QMediaContent::testResourceCtor() -{ - QMediaContent media(QMediaResource(QUrl("http://example.com/movie.mov"))); - - QCOMPARE(media.canonicalResource(), QMediaResource(QUrl("http://example.com/movie.mov"))); -} - -void tst_QMediaContent::testResourceListCtor() -{ - QMediaResourceList resourceList; - resourceList << QMediaResource(QUrl("http://example.com/movie.mov")); - - QMediaContent media(resourceList); - - QCOMPARE(media.canonicalUrl(), QUrl("http://example.com/movie.mov")); - QCOMPARE(media.canonicalResource().url(), QUrl("http://example.com/movie.mov")); -} - -void tst_QMediaContent::testCopy() -{ - QMediaContent media1(QMediaResource(QUrl("http://example.com/movie.mov"))); - QMediaContent media2(media1); - - QVERIFY(media1 == media2); -} - -void tst_QMediaContent::testAssignment() -{ - QMediaContent media1(QMediaResource(QUrl("http://example.com/movie.mov"))); - QMediaContent media2; - QMediaContent media3; - - media2 = media1; - QVERIFY(media2 == media1); - - media2 = media3; - QVERIFY(media2 == media3); -} - -void tst_QMediaContent::testEquality() -{ - QMediaContent media1; - QMediaContent media2; - QMediaContent media3(QMediaResource(QUrl("http://example.com/movie.mov"))); - QMediaContent media4(QMediaResource(QUrl("http://example.com/movie.mov"))); - QMediaContent media5(QMediaResource(QUrl("file:///some/where/over/the/rainbow.mp3"))); - - // null == null - QCOMPARE(media1 == media2, true); - QCOMPARE(media1 != media2, false); - - // null != something - QCOMPARE(media1 == media3, false); - QCOMPARE(media1 != media3, true); - - // equiv - QCOMPARE(media3 == media4, true); - QCOMPARE(media3 != media4, false); - - // not equiv - QCOMPARE(media4 == media5, false); - QCOMPARE(media4 != media5, true); -} - -void tst_QMediaContent::testResources() -{ - QMediaResourceList resourceList; - - resourceList << QMediaResource(QUrl("http://example.com/movie-main.mov")); - resourceList << QMediaResource(QUrl("http://example.com/movie-big.mov")); - QMediaContent media(resourceList); - - QMediaResourceList res = media.resources(); - QCOMPARE(res.size(), 2); - QCOMPARE(res[0], QMediaResource(QUrl("http://example.com/movie-main.mov"))); - QCOMPARE(res[1], QMediaResource(QUrl("http://example.com/movie-big.mov"))); -} - -QTEST_MAIN(tst_QMediaContent) - -#include "tst_qmediacontent.moc" diff --git a/tests/auto/qmediaobject/qmediaobject.pro b/tests/auto/qmediaobject/qmediaobject.pro deleted file mode 100644 index d6a0f7b..0000000 --- a/tests/auto/qmediaobject/qmediaobject.pro +++ /dev/null @@ -1,4 +0,0 @@ -load(qttest_p4) - -SOURCES += tst_qmediaobject.cpp -QT = core mediaservices diff --git a/tests/auto/qmediaobject/tst_qmediaobject.cpp b/tests/auto/qmediaobject/tst_qmediaobject.cpp deleted file mode 100644 index 5a2fdeb..0000000 --- a/tests/auto/qmediaobject/tst_qmediaobject.cpp +++ /dev/null @@ -1,549 +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 <QtTest/QtTest> - -#include <QtCore/qtimer.h> - -#include <QtMediaServices/qmediaobject.h> -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/qmetadatacontrol.h> - - -class tst_QMediaObject : public QObject -{ - Q_OBJECT - -private slots: - void propertyWatch(); - void notifySignals_data(); - void notifySignals(); - void notifyInterval_data(); - void notifyInterval(); - - void nullMetaDataControl(); - void isMetaDataAvailable(); - void isWritable(); - void metaDataChanged(); - void metaData_data(); - void metaData(); - void setMetaData_data(); - void setMetaData(); - void extendedMetaData_data() { metaData_data(); } - void extendedMetaData(); - void setExtendedMetaData_data() { extendedMetaData_data(); } - void setExtendedMetaData(); - - -private: - void setupNotifyTests(); -}; - -class QtTestMetaDataProvider : public QMetaDataControl -{ - Q_OBJECT -public: - QtTestMetaDataProvider(QObject *parent = 0) - : QMetaDataControl(parent) - , m_available(false) - , m_writable(false) - { - } - - bool isMetaDataAvailable() const { return m_available; } - void setMetaDataAvailable(bool available) { - if (m_available != available) - emit metaDataAvailableChanged(m_available = available); - } - QList<QtMediaServices::MetaData> availableMetaData() const { return m_data.keys(); } - - bool isWritable() const { return m_writable; } - void setWritable(bool writable) { emit writableChanged(m_writable = writable); } - - QVariant metaData(QtMediaServices::MetaData key) const { return m_data.value(key); } - void setMetaData(QtMediaServices::MetaData key, const QVariant &value) { - m_data.insert(key, value); } - - QVariant extendedMetaData(const QString &key) const { return m_extendedData.value(key); } - void setExtendedMetaData(const QString &key, const QVariant &value) { - m_extendedData.insert(key, value); } - - QStringList availableExtendedMetaData() const { return m_extendedData.keys(); } - - using QMetaDataControl::metaDataChanged; - - void populateMetaData() - { - m_available = true; - } - - bool m_available; - bool m_writable; - QMap<QtMediaServices::MetaData, QVariant> m_data; - QMap<QString, QVariant> m_extendedData; -}; - -class QtTestMetaDataService : public QMediaService -{ - Q_OBJECT -public: - QtTestMetaDataService(QObject *parent = 0):QMediaService(parent), hasMetaData(true) - { - } - - QMediaControl *control(const char *iid) const - { - if (hasMetaData && qstrcmp(iid, QMetaDataControl_iid) == 0) - return const_cast<QtTestMetaDataProvider *>(&metaData); - else - return 0; - } - - QtTestMetaDataProvider metaData; - bool hasMetaData; -}; - - -class QtTestMediaObject : public QMediaObject -{ - Q_OBJECT - Q_PROPERTY(int a READ a WRITE setA NOTIFY aChanged) - Q_PROPERTY(int b READ b WRITE setB NOTIFY bChanged) - Q_PROPERTY(int c READ c WRITE setC NOTIFY cChanged) - Q_PROPERTY(int d READ d WRITE setD) -public: - QtTestMediaObject(QMediaService *service = 0): QMediaObject(0, service), m_a(0), m_b(0), m_c(0), m_d(0) {} - - using QMediaObject::addPropertyWatch; - using QMediaObject::removePropertyWatch; - - int a() const { return m_a; } - void setA(int a) { m_a = a; } - - int b() const { return m_b; } - void setB(int b) { m_b = b; } - - int c() const { return m_c; } - void setC(int c) { m_c = c; } - - int d() const { return m_d; } - void setD(int d) { m_d = d; } - -Q_SIGNALS: - void aChanged(int a); - void bChanged(int b); - void cChanged(int c); - -private: - int m_a; - int m_b; - int m_c; - int m_d; -}; - -void tst_QMediaObject::propertyWatch() -{ - QtTestMediaObject object; - object.setNotifyInterval(0); - - QEventLoop loop; - connect(&object, SIGNAL(aChanged(int)), &QTestEventLoop::instance(), SLOT(exitLoop())); - connect(&object, SIGNAL(bChanged(int)), &QTestEventLoop::instance(), SLOT(exitLoop())); - connect(&object, SIGNAL(cChanged(int)), &QTestEventLoop::instance(), SLOT(exitLoop())); - - QSignalSpy aSpy(&object, SIGNAL(aChanged(int))); - QSignalSpy bSpy(&object, SIGNAL(bChanged(int))); - QSignalSpy cSpy(&object, SIGNAL(cChanged(int))); - - QTestEventLoop::instance().enterLoop(1); - - QCOMPARE(aSpy.count(), 0); - QCOMPARE(bSpy.count(), 0); - QCOMPARE(cSpy.count(), 0); - - int aCount = 0; - int bCount = 0; - int cCount = 0; - - object.addPropertyWatch("a"); - - QTestEventLoop::instance().enterLoop(1); - - QVERIFY(aSpy.count() > aCount); - QCOMPARE(bSpy.count(), 0); - QCOMPARE(cSpy.count(), 0); - QCOMPARE(aSpy.last().value(0).toInt(), 0); - - aCount = aSpy.count(); - - object.setA(54); - object.setB(342); - object.setC(233); - - QTestEventLoop::instance().enterLoop(1); - - QVERIFY(aSpy.count() > aCount); - QCOMPARE(bSpy.count(), 0); - QCOMPARE(cSpy.count(), 0); - QCOMPARE(aSpy.last().value(0).toInt(), 54); - - aCount = aSpy.count(); - - object.addPropertyWatch("b"); - object.addPropertyWatch("d"); - object.removePropertyWatch("e"); - object.setA(43); - object.setB(235); - object.setC(90); - - QTestEventLoop::instance().enterLoop(1); - - QVERIFY(aSpy.count() > aCount); - QVERIFY(bSpy.count() > bCount); - QCOMPARE(cSpy.count(), 0); - QCOMPARE(aSpy.last().value(0).toInt(), 43); - QCOMPARE(bSpy.last().value(0).toInt(), 235); - - aCount = aSpy.count(); - bCount = bSpy.count(); - - object.removePropertyWatch("a"); - object.addPropertyWatch("c"); - object.addPropertyWatch("e"); - - QTestEventLoop::instance().enterLoop(1); - - QCOMPARE(aSpy.count(), aCount); - QVERIFY(bSpy.count() > bCount); - QVERIFY(cSpy.count() > cCount); - QCOMPARE(bSpy.last().value(0).toInt(), 235); - QCOMPARE(cSpy.last().value(0).toInt(), 90); - - bCount = bSpy.count(); - cCount = cSpy.count(); - - object.setA(435); - object.setC(9845); - - QTestEventLoop::instance().enterLoop(1); - - QCOMPARE(aSpy.count(), aCount); - QVERIFY(bSpy.count() > bCount); - QVERIFY(cSpy.count() > cCount); - QCOMPARE(bSpy.last().value(0).toInt(), 235); - QCOMPARE(cSpy.last().value(0).toInt(), 9845); - - bCount = bSpy.count(); - cCount = cSpy.count(); - - object.setA(8432); - object.setB(324); - object.setC(443); - object.removePropertyWatch("c"); - object.removePropertyWatch("d"); - - QTestEventLoop::instance().enterLoop(1); - - QCOMPARE(aSpy.count(), aCount); - QVERIFY(bSpy.count() > bCount); - QCOMPARE(cSpy.count(), cCount); - QCOMPARE(bSpy.last().value(0).toInt(), 324); - QCOMPARE(cSpy.last().value(0).toInt(), 9845); - - bCount = bSpy.count(); - - object.removePropertyWatch("b"); - - QTestEventLoop::instance().enterLoop(1); - - QCOMPARE(aSpy.count(), aCount); - QCOMPARE(bSpy.count(), bCount); - QCOMPARE(cSpy.count(), cCount); -} - -void tst_QMediaObject::setupNotifyTests() -{ - QTest::addColumn<int>("interval"); - QTest::addColumn<int>("count"); - - QTest::newRow("single 750ms") - << 750 - << 1; - QTest::newRow("single 600ms") - << 600 - << 1; - QTest::newRow("x3 300ms") - << 300 - << 3; - QTest::newRow("x5 180ms") - << 180 - << 5; -} - -void tst_QMediaObject::notifySignals_data() -{ - setupNotifyTests(); -} - -void tst_QMediaObject::notifySignals() -{ - QFETCH(int, interval); - QFETCH(int, count); - - QtTestMediaObject object; - object.setNotifyInterval(interval); - object.addPropertyWatch("a"); - - QSignalSpy spy(&object, SIGNAL(aChanged(int))); - - QTestEventLoop::instance().enterLoop(1); - - QCOMPARE(spy.count(), count); -} - -void tst_QMediaObject::notifyInterval_data() -{ - setupNotifyTests(); -} - -void tst_QMediaObject::notifyInterval() -{ - QFETCH(int, interval); - - QtTestMediaObject object; - QSignalSpy spy(&object, SIGNAL(notifyIntervalChanged(int))); - - object.setNotifyInterval(interval); - QCOMPARE(object.notifyInterval(), interval); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.last().value(0).toInt(), interval); - - object.setNotifyInterval(interval); - QCOMPARE(object.notifyInterval(), interval); - QCOMPARE(spy.count(), 1); -} - -void tst_QMediaObject::nullMetaDataControl() -{ - const QString titleKey(QLatin1String("Title")); - const QString title(QLatin1String("Host of Seraphim")); - - QtTestMetaDataService service; - service.hasMetaData = false; - - QtTestMediaObject object(&service); - - QSignalSpy spy(&object, SIGNAL(metaDataChanged())); - - QCOMPARE(object.isMetaDataAvailable(), false); - QCOMPARE(object.isMetaDataWritable(), false); - - object.setMetaData(QtMediaServices::Title, title); - object.setExtendedMetaData(titleKey, title); - - QCOMPARE(object.metaData(QtMediaServices::Title).toString(), QString()); - QCOMPARE(object.extendedMetaData(titleKey).toString(), QString()); - QCOMPARE(object.availableMetaData(), QList<QtMediaServices::MetaData>()); - QCOMPARE(object.availableExtendedMetaData(), QStringList()); - QCOMPARE(spy.count(), 0); -} - -void tst_QMediaObject::isMetaDataAvailable() -{ - QtTestMetaDataService service; - service.metaData.setMetaDataAvailable(false); - - QtTestMediaObject object(&service); - QCOMPARE(object.isMetaDataAvailable(), false); - - QSignalSpy spy(&object, SIGNAL(metaDataAvailableChanged(bool))); - service.metaData.setMetaDataAvailable(true); - - QCOMPARE(object.isMetaDataAvailable(), true); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.at(0).at(0).toBool(), true); - - service.metaData.setMetaDataAvailable(false); - - QCOMPARE(object.isMetaDataAvailable(), false); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.at(1).at(0).toBool(), false); -} - -void tst_QMediaObject::isWritable() -{ - QtTestMetaDataService service; - service.metaData.setWritable(false); - - QtTestMediaObject object(&service); - - QSignalSpy spy(&object, SIGNAL(metaDataWritableChanged(bool))); - - QCOMPARE(object.isMetaDataWritable(), false); - - service.metaData.setWritable(true); - - QCOMPARE(object.isMetaDataWritable(), true); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.at(0).at(0).toBool(), true); - - service.metaData.setWritable(false); - - QCOMPARE(object.isMetaDataWritable(), false); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.at(1).at(0).toBool(), false); -} - -void tst_QMediaObject::metaDataChanged() -{ - QtTestMetaDataService service; - QtTestMediaObject object(&service); - - QSignalSpy spy(&object, SIGNAL(metaDataChanged())); - - service.metaData.metaDataChanged(); - QCOMPARE(spy.count(), 1); - - service.metaData.metaDataChanged(); - QCOMPARE(spy.count(), 2); -} - -void tst_QMediaObject::metaData_data() -{ - QTest::addColumn<QString>("artist"); - QTest::addColumn<QString>("title"); - QTest::addColumn<QString>("genre"); - - QTest::newRow("") - << QString::fromLatin1("Dead Can Dance") - << QString::fromLatin1("Host of Seraphim") - << QString::fromLatin1("Awesome"); -} - -void tst_QMediaObject::metaData() -{ - QFETCH(QString, artist); - QFETCH(QString, title); - QFETCH(QString, genre); - - QtTestMetaDataService service; - service.metaData.populateMetaData(); - - QtTestMediaObject object(&service); - QVERIFY(object.availableMetaData().isEmpty()); - - service.metaData.m_data.insert(QtMediaServices::AlbumArtist, artist); - service.metaData.m_data.insert(QtMediaServices::Title, title); - service.metaData.m_data.insert(QtMediaServices::Genre, genre); - - QCOMPARE(object.metaData(QtMediaServices::AlbumArtist).toString(), artist); - QCOMPARE(object.metaData(QtMediaServices::Title).toString(), title); - - QList<QtMediaServices::MetaData> metaDataKeys = object.availableMetaData(); - QCOMPARE(metaDataKeys.size(), 3); - QVERIFY(metaDataKeys.contains(QtMediaServices::AlbumArtist)); - QVERIFY(metaDataKeys.contains(QtMediaServices::Title)); - QVERIFY(metaDataKeys.contains(QtMediaServices::Genre)); -} - -void tst_QMediaObject::setMetaData_data() -{ - QTest::addColumn<QString>("title"); - - QTest::newRow("") - << QString::fromLatin1("In the Kingdom of the Blind the One eyed are Kings"); -} - -void tst_QMediaObject::setMetaData() -{ - QFETCH(QString, title); - - QtTestMetaDataService service; - service.metaData.populateMetaData(); - - QtTestMediaObject object(&service); - - object.setMetaData(QtMediaServices::Title, title); - QCOMPARE(object.metaData(QtMediaServices::Title).toString(), title); - QCOMPARE(service.metaData.m_data.value(QtMediaServices::Title).toString(), title); -} - -void tst_QMediaObject::extendedMetaData() -{ - QFETCH(QString, artist); - QFETCH(QString, title); - QFETCH(QString, genre); - - QtTestMetaDataService service; - QtTestMediaObject object(&service); - QVERIFY(object.availableExtendedMetaData().isEmpty()); - - service.metaData.m_extendedData.insert(QLatin1String("Artist"), artist); - service.metaData.m_extendedData.insert(QLatin1String("Title"), title); - service.metaData.m_extendedData.insert(QLatin1String("Genre"), genre); - - QCOMPARE(object.extendedMetaData(QLatin1String("Artist")).toString(), artist); - QCOMPARE(object.extendedMetaData(QLatin1String("Title")).toString(), title); - - QStringList extendedKeys = object.availableExtendedMetaData(); - QCOMPARE(extendedKeys.size(), 3); - QVERIFY(extendedKeys.contains(QLatin1String("Artist"))); - QVERIFY(extendedKeys.contains(QLatin1String("Title"))); - QVERIFY(extendedKeys.contains(QLatin1String("Genre"))); -} - -void tst_QMediaObject::setExtendedMetaData() -{ - QtTestMetaDataService service; - service.metaData.populateMetaData(); - - QtTestMediaObject object(&service); - - QString title(QLatin1String("In the Kingdom of the Blind the One eyed are Kings")); - - object.setExtendedMetaData(QLatin1String("Title"), title); - QCOMPARE(object.extendedMetaData(QLatin1String("Title")).toString(), title); - QCOMPARE(service.metaData.m_extendedData.value(QLatin1String("Title")).toString(), title); -} - -QTEST_MAIN(tst_QMediaObject) - -#include "tst_qmediaobject.moc" diff --git a/tests/auto/qmediaplayer/qmediaplayer.pro b/tests/auto/qmediaplayer/qmediaplayer.pro deleted file mode 100644 index f355078..0000000 --- a/tests/auto/qmediaplayer/qmediaplayer.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES += tst_qmediaplayer.cpp - -QT = core mediaservices - diff --git a/tests/auto/qmediaplayer/tst_qmediaplayer.cpp b/tests/auto/qmediaplayer/tst_qmediaplayer.cpp deleted file mode 100644 index 9a597e2..0000000 --- a/tests/auto/qmediaplayer/tst_qmediaplayer.cpp +++ /dev/null @@ -1,986 +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 <QtTest/QtTest> -#include <QtCore/qdebug.h> -#include <QtCore/qbuffer.h> - -#include <QtMediaServices/qmediaplayer.h> -#include <QtMediaServices/qmediaplayercontrol.h> -#include <QtMediaServices/qmediaplaylist.h> -#include <QtMediaServices/qmediaservice.h> - - - -class AutoConnection -{ -public: - AutoConnection(QObject *sender, const char *signal, QObject *receiver, const char *method) - : sender(sender), signal(signal), receiver(receiver), method(method) - { - QObject::connect(sender, signal, receiver, method); - } - - ~AutoConnection() - { - QObject::disconnect(sender, signal, receiver, method); - } - -private: - QObject *sender; - const char *signal; - QObject *receiver; - const char *method; -}; - - -class MockPlayerControl : public QMediaPlayerControl -{ - friend class MockPlayerService; - -public: - MockPlayerControl():QMediaPlayerControl(0) {} - - QMediaPlayer::State state() const { return _state; } - QMediaPlayer::MediaStatus mediaStatus() const { return _mediaStatus; } - - qint64 duration() const { return _duration; } - - qint64 position() const { return _position; } - - void setPosition(qint64 position) { if (position != _position) emit positionChanged(_position = position); } - - int volume() const { return _volume; } - void setVolume(int volume) { emit volumeChanged(_volume = volume); } - - bool isMuted() const { return _muted; } - void setMuted(bool muted) { if (muted != _muted) emit mutedChanged(_muted = muted); } - - int bufferStatus() const { return _bufferStatus; } - - bool isAudioAvailable() const { return _audioAvailable; } - bool isVideoAvailable() const { return _videoAvailable; } - - bool isSeekable() const { return _isSeekable; } - QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(_seekRange.first, _seekRange.second); } - void setSeekRange(qint64 minimum, qint64 maximum) { _seekRange = qMakePair(minimum, maximum); } - - qreal playbackRate() const { return _playbackRate; } - void setPlaybackRate(qreal rate) { if (rate != _playbackRate) emit playbackRateChanged(_playbackRate = rate); } - - QMediaContent media() const { return _media; } - void setMedia(const QMediaContent &content, QIODevice *stream) - { - _stream = stream; - _media = content; - if (_state != QMediaPlayer::StoppedState) { - _mediaStatus = _media.isNull() ? QMediaPlayer::NoMedia : QMediaPlayer::LoadingMedia; - emit stateChanged(_state = QMediaPlayer::StoppedState); - emit mediaStatusChanged(_mediaStatus); - } - emit mediaChanged(_media = content); - } - QIODevice *mediaStream() const { return _stream; } - - void play() { if (_isValid && !_media.isNull() && _state != QMediaPlayer::PlayingState) emit stateChanged(_state = QMediaPlayer::PlayingState); } - void pause() { if (_isValid && !_media.isNull() && _state != QMediaPlayer::PausedState) emit stateChanged(_state = QMediaPlayer::PausedState); } - void stop() { if (_state != QMediaPlayer::StoppedState) emit stateChanged(_state = QMediaPlayer::StoppedState); } - - QMediaPlayer::State _state; - QMediaPlayer::MediaStatus _mediaStatus; - QMediaPlayer::Error _error; - qint64 _duration; - qint64 _position; - int _volume; - bool _muted; - int _bufferStatus; - bool _audioAvailable; - bool _videoAvailable; - bool _isSeekable; - QPair<qint64, qint64> _seekRange; - qreal _playbackRate; - QMediaContent _media; - QIODevice *_stream; - bool _isValid; - QString _errorString; -}; - - -class MockPlayerService : public QMediaService -{ - Q_OBJECT - -public: - MockPlayerService():QMediaService(0) - { - mockControl = new MockPlayerControl; - } - - ~MockPlayerService() - { - delete mockControl; - } - - QMediaControl* control(const char *iid) const - { - if (qstrcmp(iid, QMediaPlayerControl_iid) == 0) - return mockControl; - - return 0; - } - - void setState(QMediaPlayer::State state) { emit mockControl->stateChanged(mockControl->_state = state); } - void setState(QMediaPlayer::State state, QMediaPlayer::MediaStatus status) { - mockControl->_state = state; - mockControl->_mediaStatus = status; - emit mockControl->mediaStatusChanged(status); - emit mockControl->stateChanged(state); - } - void setMediaStatus(QMediaPlayer::MediaStatus status) { emit mockControl->mediaStatusChanged(mockControl->_mediaStatus = status); } - void setIsValid(bool isValid) { mockControl->_isValid = isValid; } - void setMedia(QMediaContent media) { mockControl->_media = media; } - void setDuration(qint64 duration) { mockControl->_duration = duration; } - void setPosition(qint64 position) { mockControl->_position = position; } - void setSeekable(bool seekable) { mockControl->_isSeekable = seekable; } - void setVolume(int volume) { mockControl->_volume = volume; } - void setMuted(bool muted) { mockControl->_muted = muted; } - void setVideoAvailable(bool videoAvailable) { mockControl->_videoAvailable = videoAvailable; } - void setBufferStatus(int bufferStatus) { mockControl->_bufferStatus = bufferStatus; } - void setPlaybackRate(qreal playbackRate) { mockControl->_playbackRate = playbackRate; } - void setError(QMediaPlayer::Error error) { mockControl->_error = error; emit mockControl->error(mockControl->_error, mockControl->_errorString); } - void setErrorString(QString errorString) { mockControl->_errorString = errorString; emit mockControl->error(mockControl->_error, mockControl->_errorString); } - - void reset() - { - mockControl->_state = QMediaPlayer::StoppedState; - mockControl->_mediaStatus = QMediaPlayer::UnknownMediaStatus; - mockControl->_error = QMediaPlayer::NoError; - mockControl->_duration = 0; - mockControl->_position = 0; - mockControl->_volume = 0; - mockControl->_muted = false; - mockControl->_bufferStatus = 0; - mockControl->_videoAvailable = false; - mockControl->_isSeekable = false; - mockControl->_playbackRate = 0.0; - mockControl->_media = QMediaContent(); - mockControl->_stream = 0; - mockControl->_isValid = false; - mockControl->_errorString = QString(); - } - - MockPlayerControl *mockControl; -}; - -class MockProvider : public QMediaServiceProvider -{ -public: - MockProvider(MockPlayerService *service):mockService(service) {} - QMediaService *requestService(const QByteArray &, const QMediaServiceProviderHint &) - { - return mockService; - } - - void releaseService(QMediaService *service) { delete service; } - - MockPlayerService *mockService; -}; - -class tst_QMediaPlayer: public QObject -{ - Q_OBJECT - -public slots: - void initTestCase_data(); - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - -private slots: - void testNullService(); - void testValid(); - void testMedia(); - void testDuration(); - void testPosition(); - void testVolume(); - void testMuted(); - void testVideoAvailable(); - void testBufferStatus(); - void testSeekable(); - void testPlaybackRate(); - void testError(); - void testErrorString(); - void testService(); - void testPlay(); - void testPause(); - void testStop(); - void testMediaStatus(); - void testPlaylist(); - -private: - MockProvider *mockProvider; - MockPlayerService *mockService; - QMediaPlayer *player; -}; - -void tst_QMediaPlayer::initTestCase_data() -{ - QTest::addColumn<bool>("valid"); - QTest::addColumn<QMediaPlayer::State>("state"); - QTest::addColumn<QMediaPlayer::MediaStatus>("status"); - QTest::addColumn<QMediaContent>("mediaContent"); - QTest::addColumn<qint64>("duration"); - QTest::addColumn<qint64>("position"); - QTest::addColumn<bool>("seekable"); - QTest::addColumn<int>("volume"); - QTest::addColumn<bool>("muted"); - QTest::addColumn<bool>("videoAvailable"); - QTest::addColumn<int>("bufferStatus"); - QTest::addColumn<qreal>("playbackRate"); - QTest::addColumn<QMediaPlayer::Error>("error"); - QTest::addColumn<QString>("errorString"); - - QTest::newRow("invalid") << false << QMediaPlayer::StoppedState << QMediaPlayer::UnknownMediaStatus << - QMediaContent() << qint64(0) << qint64(0) << false << 0 << false << false << 0 << - qreal(0) << QMediaPlayer::NoError << QString(); - QTest::newRow("valid+null") << true << QMediaPlayer::StoppedState << QMediaPlayer::UnknownMediaStatus << - QMediaContent() << qint64(0) << qint64(0) << false << 0 << false << false << 50 << - qreal(0) << QMediaPlayer::NoError << QString(); - QTest::newRow("valid+content+stopped") << true << QMediaPlayer::StoppedState << QMediaPlayer::UnknownMediaStatus << - QMediaContent(QUrl("file:///some.mp3")) << qint64(0) << qint64(0) << false << 50 << false << false << 0 << - qreal(1) << QMediaPlayer::NoError << QString(); - QTest::newRow("valid+content+playing") << true << QMediaPlayer::PlayingState << QMediaPlayer::LoadedMedia << - QMediaContent(QUrl("file:///some.mp3")) << qint64(10000) << qint64(10) << true << 50 << true << false << 0 << - qreal(1) << QMediaPlayer::NoError << QString(); - QTest::newRow("valid+content+paused") << true << QMediaPlayer::PausedState << QMediaPlayer::LoadedMedia << - QMediaContent(QUrl("file:///some.mp3")) << qint64(10000) << qint64(10) << true << 50 << true << false << 0 << - qreal(1) << QMediaPlayer::NoError << QString(); - QTest::newRow("valud+streaming") << true << QMediaPlayer::PlayingState << QMediaPlayer::LoadedMedia << - QMediaContent(QUrl("http://example.com/stream")) << qint64(10000) << qint64(10000) << false << 50 << false << true << 0 << - qreal(1) << QMediaPlayer::NoError << QString(); - QTest::newRow("valid+error") << true << QMediaPlayer::StoppedState << QMediaPlayer::UnknownMediaStatus << - QMediaContent(QUrl("http://example.com/stream")) << qint64(0) << qint64(0) << false << 50 << false << false << 0 << - qreal(0) << QMediaPlayer::ResourceError << QString("Resource unavailable"); -} - -void tst_QMediaPlayer::initTestCase() -{ - qRegisterMetaType<QMediaContent>(); - - mockService = new MockPlayerService; - mockProvider = new MockProvider(mockService); - player = new QMediaPlayer(0, 0, mockProvider); -} - -void tst_QMediaPlayer::cleanupTestCase() -{ - delete player; -} - -void tst_QMediaPlayer::init() -{ - mockService->reset(); -} - -void tst_QMediaPlayer::cleanup() -{ -} - -void tst_QMediaPlayer::testNullService() -{ - MockProvider provider(0); - QMediaPlayer player(0, 0, &provider); - - const QIODevice *nullDevice = 0; - - QCOMPARE(player.media(), QMediaContent()); - QCOMPARE(player.mediaStream(), nullDevice); - QCOMPARE(player.state(), QMediaPlayer::StoppedState); - QCOMPARE(player.mediaStatus(), QMediaPlayer::UnknownMediaStatus); - QCOMPARE(player.duration(), qint64(-1)); - QCOMPARE(player.position(), qint64(0)); - QCOMPARE(player.volume(), 0); - QCOMPARE(player.isMuted(), false); - QCOMPARE(player.isVideoAvailable(), false); - QCOMPARE(player.bufferStatus(), 0); - QCOMPARE(player.isSeekable(), false); - QCOMPARE(player.playbackRate(), qreal(0)); - QCOMPARE(player.error(), QMediaPlayer::ServiceMissingError); - - { - QFETCH_GLOBAL(QMediaContent, mediaContent); - - QSignalSpy spy(&player, SIGNAL(mediaChanged(QMediaContent))); - QFile file; - - player.setMedia(mediaContent, &file); - QCOMPARE(player.media(), QMediaContent()); - QCOMPARE(player.mediaStream(), nullDevice); - QCOMPARE(spy.count(), 0); - } { - QSignalSpy stateSpy(&player, SIGNAL(stateChanged(QMediaPlayer::State))); - QSignalSpy statusSpy(&player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus))); - - player.play(); - QCOMPARE(player.state(), QMediaPlayer::StoppedState); - QCOMPARE(player.mediaStatus(), QMediaPlayer::UnknownMediaStatus); - QCOMPARE(stateSpy.count(), 0); - QCOMPARE(statusSpy.count(), 0); - - player.pause(); - QCOMPARE(player.state(), QMediaPlayer::StoppedState); - QCOMPARE(player.mediaStatus(), QMediaPlayer::UnknownMediaStatus); - QCOMPARE(stateSpy.count(), 0); - QCOMPARE(statusSpy.count(), 0); - - player.stop(); - QCOMPARE(player.state(), QMediaPlayer::StoppedState); - QCOMPARE(player.mediaStatus(), QMediaPlayer::UnknownMediaStatus); - QCOMPARE(stateSpy.count(), 0); - QCOMPARE(statusSpy.count(), 0); - } { - QFETCH_GLOBAL(int, volume); - QFETCH_GLOBAL(bool, muted); - - QSignalSpy volumeSpy(&player, SIGNAL(volumeChanged(int))); - QSignalSpy mutingSpy(&player, SIGNAL(mutedChanged(bool))); - - player.setVolume(volume); - QCOMPARE(player.volume(), 0); - QCOMPARE(volumeSpy.count(), 0); - - player.setMuted(muted); - QCOMPARE(player.isMuted(), false); - QCOMPARE(mutingSpy.count(), 0); - } { - QFETCH_GLOBAL(qint64, position); - - QSignalSpy spy(&player, SIGNAL(positionChanged(qint64))); - - player.setPosition(position); - QCOMPARE(player.position(), qint64(0)); - QCOMPARE(spy.count(), 0); - } { - QFETCH_GLOBAL(qreal, playbackRate); - - QSignalSpy spy(&player, SIGNAL(playbackRateChanged(qreal))); - - player.setPlaybackRate(playbackRate); - QCOMPARE(player.playbackRate(), qreal(0)); - QCOMPARE(spy.count(), 0); - } { - QMediaPlaylist playlist; - playlist.setMediaObject(&player); - - QSignalSpy mediaSpy(&player, SIGNAL(mediaChanged(QMediaContent))); - QSignalSpy statusSpy(&player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus))); - - playlist.addMedia(QUrl("http://example.com/stream")); - playlist.addMedia(QUrl("file:///some.mp3")); - - playlist.setCurrentIndex(0); - QCOMPARE(playlist.currentIndex(), 0); - QCOMPARE(player.media(), QMediaContent()); - QCOMPARE(mediaSpy.count(), 0); - QCOMPARE(statusSpy.count(), 0); - - playlist.next(); - QCOMPARE(playlist.currentIndex(), 1); - QCOMPARE(player.media(), QMediaContent()); - QCOMPARE(mediaSpy.count(), 0); - QCOMPARE(statusSpy.count(), 0); - } -} - -void tst_QMediaPlayer::testValid() -{ - /* - QFETCH_GLOBAL(bool, valid); - - mockService->setIsValid(valid); - QCOMPARE(player->isValid(), valid); - */ -} - -void tst_QMediaPlayer::testMedia() -{ - QFETCH_GLOBAL(QMediaContent, mediaContent); - - mockService->setMedia(mediaContent); - QCOMPARE(player->media(), mediaContent); - - QBuffer stream; - player->setMedia(mediaContent, &stream); - QCOMPARE(player->media(), mediaContent); - QCOMPARE((QBuffer*)player->mediaStream(), &stream); -} - -void tst_QMediaPlayer::testDuration() -{ - QFETCH_GLOBAL(qint64, duration); - - mockService->setDuration(duration); - QVERIFY(player->duration() == duration); -} - -void tst_QMediaPlayer::testPosition() -{ - QFETCH_GLOBAL(bool, valid); - QFETCH_GLOBAL(bool, seekable); - QFETCH_GLOBAL(qint64, position); - QFETCH_GLOBAL(qint64, duration); - - mockService->setIsValid(valid); - mockService->setSeekable(seekable); - mockService->setPosition(position); - mockService->setDuration(duration); - QVERIFY(player->isSeekable() == seekable); - QVERIFY(player->position() == position); - QVERIFY(player->duration() == duration); - - if (seekable) { - { QSignalSpy spy(player, SIGNAL(positionChanged(qint64))); - player->setPosition(position); - QCOMPARE(player->position(), position); - QCOMPARE(spy.count(), 0); } - - mockService->setPosition(position); - { QSignalSpy spy(player, SIGNAL(positionChanged(qint64))); - player->setPosition(0); - QCOMPARE(player->position(), qint64(0)); - QCOMPARE(spy.count(), position == 0 ? 0 : 1); } - - mockService->setPosition(position); - { QSignalSpy spy(player, SIGNAL(positionChanged(qint64))); - player->setPosition(duration); - QCOMPARE(player->position(), duration); - QCOMPARE(spy.count(), position == duration ? 0 : 1); } - - mockService->setPosition(position); - { QSignalSpy spy(player, SIGNAL(positionChanged(qint64))); - player->setPosition(-1); - QCOMPARE(player->position(), qint64(0)); - QCOMPARE(spy.count(), position == 0 ? 0 : 1); } - - mockService->setPosition(position); - { QSignalSpy spy(player, SIGNAL(positionChanged(qint64))); - player->setPosition(duration + 1); - QCOMPARE(player->position(), duration); - QCOMPARE(spy.count(), position == duration ? 0 : 1); } - } - else { - QSignalSpy spy(player, SIGNAL(positionChanged(qint64))); - player->setPosition(position); - - QCOMPARE(player->position(), position); - QCOMPARE(spy.count(), 0); - } -} - -void tst_QMediaPlayer::testVolume() -{ - QFETCH_GLOBAL(bool, valid); - QFETCH_GLOBAL(int, volume); - - mockService->setVolume(volume); - QVERIFY(player->volume() == volume); - - if (valid) { - { QSignalSpy spy(player, SIGNAL(volumeChanged(int))); - player->setVolume(10); - QCOMPARE(player->volume(), 10); - QCOMPARE(spy.count(), 1); } - - { QSignalSpy spy(player, SIGNAL(volumeChanged(int))); - player->setVolume(-1000); - QCOMPARE(player->volume(), 0); - QCOMPARE(spy.count(), 1); } - - { QSignalSpy spy(player, SIGNAL(volumeChanged(int))); - player->setVolume(100); - QCOMPARE(player->volume(), 100); - QCOMPARE(spy.count(), 1); } - - { QSignalSpy spy(player, SIGNAL(volumeChanged(int))); - player->setVolume(1000); - QCOMPARE(player->volume(), 100); - QCOMPARE(spy.count(), 0); } - } -} - -void tst_QMediaPlayer::testMuted() -{ - QFETCH_GLOBAL(bool, valid); - QFETCH_GLOBAL(bool, muted); - QFETCH_GLOBAL(int, volume); - - if (valid) { - mockService->setMuted(muted); - mockService->setVolume(volume); - QVERIFY(player->isMuted() == muted); - - QSignalSpy spy(player, SIGNAL(mutedChanged(bool))); - player->setMuted(!muted); - QCOMPARE(player->isMuted(), !muted); - QCOMPARE(player->volume(), volume); - QCOMPARE(spy.count(), 1); - } -} - -void tst_QMediaPlayer::testVideoAvailable() -{ - QFETCH_GLOBAL(bool, videoAvailable); - - mockService->setVideoAvailable(videoAvailable); - QVERIFY(player->isVideoAvailable() == videoAvailable); -} - -void tst_QMediaPlayer::testBufferStatus() -{ - QFETCH_GLOBAL(int, bufferStatus); - - mockService->setBufferStatus(bufferStatus); - QVERIFY(player->bufferStatus() == bufferStatus); -} - -void tst_QMediaPlayer::testSeekable() -{ - QFETCH_GLOBAL(bool, seekable); - - mockService->setSeekable(seekable); - QVERIFY(player->isSeekable() == seekable); -} - -void tst_QMediaPlayer::testPlaybackRate() -{ - QFETCH_GLOBAL(bool, valid); - QFETCH_GLOBAL(qreal, playbackRate); - - if (valid) { - mockService->setPlaybackRate(playbackRate); - QVERIFY(player->playbackRate() == playbackRate); - - QSignalSpy spy(player, SIGNAL(playbackRateChanged(qreal))); - player->setPlaybackRate(playbackRate + 0.5f); - QCOMPARE(player->playbackRate(), playbackRate + 0.5f); - QCOMPARE(spy.count(), 1); - } -} - -void tst_QMediaPlayer::testError() -{ - QFETCH_GLOBAL(QMediaPlayer::Error, error); - - mockService->setError(error); - QVERIFY(player->error() == error); -} - -void tst_QMediaPlayer::testErrorString() -{ - QFETCH_GLOBAL(QString, errorString); - - mockService->setErrorString(errorString); - QVERIFY(player->errorString() == errorString); -} - -void tst_QMediaPlayer::testService() -{ - /* - QFETCH_GLOBAL(bool, valid); - - mockService->setIsValid(valid); - - if (valid) - QVERIFY(player->service() != 0); - else - QVERIFY(player->service() == 0); - */ -} - -void tst_QMediaPlayer::testPlay() -{ - QFETCH_GLOBAL(bool, valid); - QFETCH_GLOBAL(QMediaContent, mediaContent); - QFETCH_GLOBAL(QMediaPlayer::State, state); - - mockService->setIsValid(valid); - mockService->setState(state); - mockService->setMedia(mediaContent); - QVERIFY(player->state() == state); - QVERIFY(player->media() == mediaContent); - - QSignalSpy spy(player, SIGNAL(stateChanged(QMediaPlayer::State))); - - player->play(); - - if (!valid || mediaContent.isNull()) { - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(spy.count(), 0); - } - else { - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(spy.count(), state == QMediaPlayer::PlayingState ? 0 : 1); - } -} - -void tst_QMediaPlayer::testPause() -{ - QFETCH_GLOBAL(bool, valid); - QFETCH_GLOBAL(QMediaContent, mediaContent); - QFETCH_GLOBAL(QMediaPlayer::State, state); - - mockService->setIsValid(valid); - mockService->setState(state); - mockService->setMedia(mediaContent); - QVERIFY(player->state() == state); - QVERIFY(player->media() == mediaContent); - - QSignalSpy spy(player, SIGNAL(stateChanged(QMediaPlayer::State))); - - player->pause(); - - if (!valid || mediaContent.isNull()) { - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(spy.count(), 0); - } - else { - QCOMPARE(player->state(), QMediaPlayer::PausedState); - QCOMPARE(spy.count(), state == QMediaPlayer::PausedState ? 0 : 1); - } -} - -void tst_QMediaPlayer::testStop() -{ - QFETCH_GLOBAL(QMediaContent, mediaContent); - QFETCH_GLOBAL(QMediaPlayer::State, state); - - mockService->setState(state); - mockService->setMedia(mediaContent); - QVERIFY(player->state() == state); - QVERIFY(player->media() == mediaContent); - - QSignalSpy spy(player, SIGNAL(stateChanged(QMediaPlayer::State))); - - player->stop(); - - if (mediaContent.isNull() || state == QMediaPlayer::StoppedState) { - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(spy.count(), 0); - } - else { - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(spy.count(), 1); - } -} - -void tst_QMediaPlayer::testMediaStatus() -{ - QFETCH_GLOBAL(int, bufferStatus); - int bufferSignals = 0; - - player->setNotifyInterval(10); - - mockService->setMediaStatus(QMediaPlayer::NoMedia); - mockService->setBufferStatus(bufferStatus); - - AutoConnection connection( - player, SIGNAL(bufferStatusChanged(int)), - &QTestEventLoop::instance(), SLOT(exitLoop())); - - QSignalSpy statusSpy(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus))); - QSignalSpy bufferSpy(player, SIGNAL(bufferStatusChanged(int))); - - QCOMPARE(player->mediaStatus(), QMediaPlayer::NoMedia); - - mockService->setMediaStatus(QMediaPlayer::LoadingMedia); - QCOMPARE(player->mediaStatus(), QMediaPlayer::LoadingMedia); - QCOMPARE(statusSpy.count(), 1); - - QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)), - QMediaPlayer::LoadingMedia); - - mockService->setMediaStatus(QMediaPlayer::LoadedMedia); - QCOMPARE(player->mediaStatus(), QMediaPlayer::LoadedMedia); - QCOMPARE(statusSpy.count(), 2); - - QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)), - QMediaPlayer::LoadedMedia); - - // Verify the bufferStatusChanged() signal isn't being emitted. - QTestEventLoop::instance().enterLoop(1); - QCOMPARE(bufferSpy.count(), 0); - - mockService->setMediaStatus(QMediaPlayer::StalledMedia); - QCOMPARE(player->mediaStatus(), QMediaPlayer::StalledMedia); - QCOMPARE(statusSpy.count(), 3); - - QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)), - QMediaPlayer::StalledMedia); - - // Verify the bufferStatusChanged() signal is being emitted. - QTestEventLoop::instance().enterLoop(1); - QVERIFY(bufferSpy.count() > bufferSignals); - QCOMPARE(bufferSpy.last().value(0).toInt(), bufferStatus); - bufferSignals = bufferSpy.count(); - - mockService->setMediaStatus(QMediaPlayer::BufferingMedia); - QCOMPARE(player->mediaStatus(), QMediaPlayer::BufferingMedia); - QCOMPARE(statusSpy.count(), 4); - - QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)), - QMediaPlayer::BufferingMedia); - - // Verify the bufferStatusChanged() signal is being emitted. - QTestEventLoop::instance().enterLoop(1); - QVERIFY(bufferSpy.count() > bufferSignals); - QCOMPARE(bufferSpy.last().value(0).toInt(), bufferStatus); - bufferSignals = bufferSpy.count(); - - mockService->setMediaStatus(QMediaPlayer::BufferedMedia); - QCOMPARE(player->mediaStatus(), QMediaPlayer::BufferedMedia); - QCOMPARE(statusSpy.count(), 5); - - QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)), - QMediaPlayer::BufferedMedia); - - // Verify the bufferStatusChanged() signal isn't being emitted. - QTestEventLoop::instance().enterLoop(1); - QCOMPARE(bufferSpy.count(), bufferSignals); - - mockService->setMediaStatus(QMediaPlayer::EndOfMedia); - QCOMPARE(player->mediaStatus(), QMediaPlayer::EndOfMedia); - QCOMPARE(statusSpy.count(), 6); - - QCOMPARE(qvariant_cast<QMediaPlayer::MediaStatus>(statusSpy.last().value(0)), - QMediaPlayer::EndOfMedia); -} - -void tst_QMediaPlayer::testPlaylist() -{ - QMediaContent content0(QUrl(QLatin1String("test://audio/song1.mp3"))); - QMediaContent content1(QUrl(QLatin1String("test://audio/song2.mp3"))); - QMediaContent content2(QUrl(QLatin1String("test://video/movie1.mp4"))); - QMediaContent content3(QUrl(QLatin1String("test://video/movie2.mp4"))); - QMediaContent content4(QUrl(QLatin1String("test://image/photo.jpg"))); - - mockService->setIsValid(true); - mockService->setState(QMediaPlayer::StoppedState, QMediaPlayer::NoMedia); - - QMediaPlaylist *playlist = new QMediaPlaylist; - playlist->setMediaObject(player); - - QSignalSpy stateSpy(player, SIGNAL(stateChanged(QMediaPlayer::State))); - QSignalSpy mediaSpy(player, SIGNAL(mediaChanged(QMediaContent))); - - // Test the player does nothing with an empty playlist attached. - player->play(); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(player->media(), QMediaContent()); - QCOMPARE(stateSpy.count(), 0); - QCOMPARE(mediaSpy.count(), 0); - - playlist->addMedia(content0); - playlist->addMedia(content1); - playlist->addMedia(content2); - playlist->addMedia(content3); - - // Test changing the playlist position, changes the current media, but not the playing state. - playlist->setCurrentIndex(1); - QCOMPARE(player->media(), content1); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(stateSpy.count(), 0); - QCOMPARE(mediaSpy.count(), 1); - - // Test playing starts with the current media. - player->play(); - QCOMPARE(player->media(), content1); - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(stateSpy.count(), 1); - QCOMPARE(mediaSpy.count(), 1); - - // Test pausing doesn't change the current media. - player->pause(); - QCOMPARE(player->media(), content1); - QCOMPARE(player->state(), QMediaPlayer::PausedState); - QCOMPARE(stateSpy.count(), 2); - QCOMPARE(mediaSpy.count(), 1); - - // Test stopping doesn't change the current media. - player->stop(); - QCOMPARE(player->media(), content1); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(stateSpy.count(), 3); - QCOMPARE(mediaSpy.count(), 1); - - // Test when the player service reaches the end of the current media, the player moves onto - // the next item without stopping. - player->play(); - QCOMPARE(player->media(), content1); - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(stateSpy.count(), 4); - QCOMPARE(mediaSpy.count(), 1); - - mockService->setState(QMediaPlayer::StoppedState, QMediaPlayer::EndOfMedia); - QCOMPARE(player->media(), content2); - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(stateSpy.count(), 4); - QCOMPARE(mediaSpy.count(), 2); - - // Test skipping the current media doesn't change the state. - playlist->next(); - QCOMPARE(player->media(), content3); - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(stateSpy.count(), 4); - QCOMPARE(mediaSpy.count(), 3); - - // Test changing the current media while paused doesn't change the state. - player->pause(); - mockService->setMediaStatus(QMediaPlayer::BufferedMedia); - QCOMPARE(player->media(), content3); - QCOMPARE(player->state(), QMediaPlayer::PausedState); - QCOMPARE(stateSpy.count(), 5); - QCOMPARE(mediaSpy.count(), 3); - - playlist->previous(); - QCOMPARE(player->media(), content2); - QCOMPARE(player->state(), QMediaPlayer::PausedState); - QCOMPARE(stateSpy.count(), 5); - QCOMPARE(mediaSpy.count(), 4); - - // Test changing the current media while stopped doesn't change the state. - player->stop(); - mockService->setMediaStatus(QMediaPlayer::LoadedMedia); - QCOMPARE(player->media(), content2); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(stateSpy.count(), 6); - QCOMPARE(mediaSpy.count(), 4); - - playlist->next(); - QCOMPARE(player->media(), content3); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(stateSpy.count(), 6); - QCOMPARE(mediaSpy.count(), 5); - - // Test the player is stopped and the current media cleared when it reaches the end of the last - // item in the playlist. - player->play(); - QCOMPARE(player->media(), content3); - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(stateSpy.count(), 7); - QCOMPARE(mediaSpy.count(), 5); - - // Double up the signals to ensure some noise doesn't destabalize things. - mockService->setState(QMediaPlayer::StoppedState, QMediaPlayer::EndOfMedia); - mockService->setState(QMediaPlayer::StoppedState, QMediaPlayer::EndOfMedia); - QCOMPARE(player->media(), QMediaContent()); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(stateSpy.count(), 8); - QCOMPARE(mediaSpy.count(), 6); - - // Test starts playing from the start of the playlist if there is no current media selected. - player->play(); - QCOMPARE(player->media(), content0); - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(stateSpy.count(), 9); - QCOMPARE(mediaSpy.count(), 7); - - // Test deleting the playlist stops the player and clears the media it set. - delete playlist; - QCOMPARE(player->media(), QMediaContent()); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(stateSpy.count(), 10); - QCOMPARE(mediaSpy.count(), 8); - - // Test the player works as normal with the playlist removed. - player->play(); - QCOMPARE(player->media(), QMediaContent()); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - QCOMPARE(stateSpy.count(), 10); - QCOMPARE(mediaSpy.count(), 8); - - player->setMedia(content1); - player->play(); - - QCOMPARE(player->media(), content1); - QCOMPARE(player->state(), QMediaPlayer::PlayingState); - QCOMPARE(stateSpy.count(), 11); - QCOMPARE(mediaSpy.count(), 9); - - // Test the player can bind to playlist again - playlist = new QMediaPlaylist; - playlist->setMediaObject(player); - QCOMPARE(playlist->mediaObject(), qobject_cast<QMediaObject*>(player)); - - QCOMPARE(player->media(), QMediaContent()); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - - playlist->addMedia(content0); - playlist->addMedia(content1); - playlist->addMedia(content2); - playlist->addMedia(content3); - - playlist->setCurrentIndex(1); - QCOMPARE(player->media(), content1); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - - // Test attaching the new playlist, - // player should detach the current one - QMediaPlaylist *playlist2 = new QMediaPlaylist; - playlist2->addMedia(content1); - playlist2->addMedia(content2); - playlist2->addMedia(content3); - playlist2->setCurrentIndex(2); - - player->play(); - playlist2->setMediaObject(player); - QCOMPARE(playlist2->mediaObject(), qobject_cast<QMediaObject*>(player)); - QVERIFY(playlist->mediaObject() == 0); - QCOMPARE(player->media(), playlist2->currentMedia()); - QCOMPARE(player->state(), QMediaPlayer::StoppedState); - - playlist2->setCurrentIndex(1); - QCOMPARE(player->media(), playlist2->currentMedia()); -} - -QTEST_MAIN(tst_QMediaPlayer) - -#include "tst_qmediaplayer.moc" diff --git a/tests/auto/qmediaplaylist/qmediaplaylist.pro b/tests/auto/qmediaplaylist/qmediaplaylist.pro deleted file mode 100644 index 809473b..0000000 --- a/tests/auto/qmediaplaylist/qmediaplaylist.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qmediaplaylist.cpp - -QT = core mediaservices - diff --git a/tests/auto/qmediaplaylist/tst_qmediaplaylist.cpp b/tests/auto/qmediaplaylist/tst_qmediaplaylist.cpp deleted file mode 100644 index 1037f37..0000000 --- a/tests/auto/qmediaplaylist/tst_qmediaplaylist.cpp +++ /dev/null @@ -1,593 +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 <QtTest/QtTest> -#include <QDebug> -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/qmediaplaylist.h> -#include <QtMediaServices/qmediaplaylistcontrol.h> -#include <QtMediaServices/qmediaplaylistnavigator.h> -#include <QtMediaServices/private/qmediapluginloader_p.h> - - -class MockReadOnlyPlaylistProvider : public QMediaPlaylistProvider -{ - Q_OBJECT -public: - MockReadOnlyPlaylistProvider(QObject *parent) - :QMediaPlaylistProvider(parent) - { - m_items.append(QMediaContent(QUrl(QLatin1String("file:///1")))); - m_items.append(QMediaContent(QUrl(QLatin1String("file:///2")))); - m_items.append(QMediaContent(QUrl(QLatin1String("file:///3")))); - } - - int mediaCount() const { return m_items.size(); } - QMediaContent media(int index) const - { - return index >=0 && index < mediaCount() ? m_items.at(index) : QMediaContent(); - } - -private: - QList<QMediaContent> m_items; -}; - -class MockPlaylistControl : public QMediaPlaylistControl -{ - Q_OBJECT -public: - MockPlaylistControl(QObject *parent) : QMediaPlaylistControl(parent) - { - m_navigator = new QMediaPlaylistNavigator(new MockReadOnlyPlaylistProvider(this), this); - } - - ~MockPlaylistControl() - { - } - - QMediaPlaylistProvider* playlistProvider() const { return m_navigator->playlist(); } - bool setPlaylistProvider(QMediaPlaylistProvider *playlist) { m_navigator->setPlaylist(playlist); return true; } - - int currentIndex() const { return m_navigator->currentIndex(); } - void setCurrentIndex(int position) { m_navigator->jump(position); } - int nextIndex(int steps) const { return m_navigator->nextIndex(steps); } - int previousIndex(int steps) const { return m_navigator->previousIndex(steps); } - - void next() { m_navigator->next(); } - void previous() { m_navigator->previous(); } - - QMediaPlaylist::PlaybackMode playbackMode() const { return m_navigator->playbackMode(); } - void setPlaybackMode(QMediaPlaylist::PlaybackMode mode) { m_navigator->setPlaybackMode(mode); } - -private: - QMediaPlaylistNavigator *m_navigator; -}; - -class MockPlaylistService : public QMediaService -{ - Q_OBJECT - -public: - MockPlaylistService():QMediaService(0) - { - mockControl = new MockPlaylistControl(this); - } - - ~MockPlaylistService() - { - } - - QMediaControl* control(const char *iid) const - { - if (qstrcmp(iid, QMediaPlaylistControl_iid) == 0) - return mockControl; - return 0; - } - - MockPlaylistControl *mockControl; -}; - -class MockReadOnlyPlaylistObject : public QMediaObject -{ - Q_OBJECT -public: - MockReadOnlyPlaylistObject(QObject *parent = 0) - :QMediaObject(parent, new MockPlaylistService) - { - } -}; - - -class tst_QMediaPlaylist : public QObject -{ - Q_OBJECT -public slots: - void init(); - void cleanup(); - void initTestCase(); - -private slots: - void construction(); - void append(); - void insert(); - void clear(); - void removeMedia(); - void currentItem(); - void saveAndLoad(); - void playbackMode(); - void playbackMode_data(); - void shuffle(); - void readOnlyPlaylist(); - void setMediaObject(); - -private: - QMediaContent content1; - QMediaContent content2; - QMediaContent content3; -}; - -void tst_QMediaPlaylist::init() -{ -} - -void tst_QMediaPlaylist::initTestCase() -{ - content1 = QMediaContent(QUrl(QLatin1String("file:///1"))); - content2 = QMediaContent(QUrl(QLatin1String("file:///2"))); - content3 = QMediaContent(QUrl(QLatin1String("file:///3"))); -} - -void tst_QMediaPlaylist::cleanup() -{ -} - -void tst_QMediaPlaylist::construction() -{ - QMediaPlaylist playlist; - QCOMPARE(playlist.mediaCount(), 0); - QVERIFY(playlist.isEmpty()); -} - -void tst_QMediaPlaylist::append() -{ - QMediaPlaylist playlist; - QVERIFY(!playlist.isReadOnly()); - - playlist.addMedia(content1); - QCOMPARE(playlist.mediaCount(), 1); - QCOMPARE(playlist.media(0), content1); - - QSignalSpy aboutToBeInsertedSignalSpy(&playlist, SIGNAL(mediaAboutToBeInserted(int,int))); - QSignalSpy insertedSignalSpy(&playlist, SIGNAL(mediaInserted(int,int))); - playlist.addMedia(content2); - QCOMPARE(playlist.mediaCount(), 2); - QCOMPARE(playlist.media(1), content2); - - QCOMPARE(aboutToBeInsertedSignalSpy.count(), 1); - QCOMPARE(aboutToBeInsertedSignalSpy.first()[0].toInt(), 1); - QCOMPARE(aboutToBeInsertedSignalSpy.first()[1].toInt(), 1); - - QCOMPARE(insertedSignalSpy.count(), 1); - QCOMPARE(insertedSignalSpy.first()[0].toInt(), 1); - QCOMPARE(insertedSignalSpy.first()[1].toInt(), 1); - - aboutToBeInsertedSignalSpy.clear(); - insertedSignalSpy.clear(); - - QMediaContent content4(QUrl(QLatin1String("file:///4"))); - QMediaContent content5(QUrl(QLatin1String("file:///5"))); - playlist.addMedia(QList<QMediaContent>() << content3 << content4 << content5); - QCOMPARE(playlist.mediaCount(), 5); - QCOMPARE(playlist.media(2), content3); - QCOMPARE(playlist.media(3), content4); - QCOMPARE(playlist.media(4), content5); - - QCOMPARE(aboutToBeInsertedSignalSpy.count(), 1); - QCOMPARE(aboutToBeInsertedSignalSpy[0][0].toInt(), 2); - QCOMPARE(aboutToBeInsertedSignalSpy[0][1].toInt(), 4); - - QCOMPARE(insertedSignalSpy.count(), 1); - QCOMPARE(insertedSignalSpy[0][0].toInt(), 2); - QCOMPARE(insertedSignalSpy[0][1].toInt(), 4); - - aboutToBeInsertedSignalSpy.clear(); - insertedSignalSpy.clear(); - - playlist.addMedia(QList<QMediaContent>()); - QCOMPARE(aboutToBeInsertedSignalSpy.count(), 0); - QCOMPARE(insertedSignalSpy.count(), 0); -} - -void tst_QMediaPlaylist::insert() -{ - QMediaPlaylist playlist; - QVERIFY(!playlist.isReadOnly()); - - playlist.addMedia(content1); - QCOMPARE(playlist.mediaCount(), 1); - QCOMPARE(playlist.media(0), content1); - - playlist.addMedia(content2); - QCOMPARE(playlist.mediaCount(), 2); - QCOMPARE(playlist.media(1), content2); - - QSignalSpy aboutToBeInsertedSignalSpy(&playlist, SIGNAL(mediaAboutToBeInserted(int,int))); - QSignalSpy insertedSignalSpy(&playlist, SIGNAL(mediaInserted(int,int))); - - playlist.insertMedia(1, content3); - QCOMPARE(playlist.mediaCount(), 3); - QCOMPARE(playlist.media(0), content1); - QCOMPARE(playlist.media(1), content3); - QCOMPARE(playlist.media(2), content2); - - QCOMPARE(aboutToBeInsertedSignalSpy.count(), 1); - QCOMPARE(aboutToBeInsertedSignalSpy.first()[0].toInt(), 1); - QCOMPARE(aboutToBeInsertedSignalSpy.first()[1].toInt(), 1); - - QCOMPARE(insertedSignalSpy.count(), 1); - QCOMPARE(insertedSignalSpy.first()[0].toInt(), 1); - QCOMPARE(insertedSignalSpy.first()[1].toInt(), 1); - - aboutToBeInsertedSignalSpy.clear(); - insertedSignalSpy.clear(); - - QMediaContent content4(QUrl(QLatin1String("file:///4"))); - QMediaContent content5(QUrl(QLatin1String("file:///5"))); - playlist.insertMedia(1, QList<QMediaContent>() << content4 << content5); - - QCOMPARE(playlist.media(0), content1); - QCOMPARE(playlist.media(1), content4); - QCOMPARE(playlist.media(2), content5); - QCOMPARE(playlist.media(3), content3); - QCOMPARE(playlist.media(4), content2); - QCOMPARE(aboutToBeInsertedSignalSpy.count(), 1); - QCOMPARE(aboutToBeInsertedSignalSpy[0][0].toInt(), 1); - QCOMPARE(aboutToBeInsertedSignalSpy[0][1].toInt(), 2); - - QCOMPARE(insertedSignalSpy.count(), 1); - QCOMPARE(insertedSignalSpy[0][0].toInt(), 1); - QCOMPARE(insertedSignalSpy[0][1].toInt(), 2); - - aboutToBeInsertedSignalSpy.clear(); - insertedSignalSpy.clear(); - - playlist.insertMedia(1, QList<QMediaContent>()); - QCOMPARE(aboutToBeInsertedSignalSpy.count(), 0); - QCOMPARE(insertedSignalSpy.count(), 0); -} - - -void tst_QMediaPlaylist::currentItem() -{ - QMediaPlaylist playlist; - playlist.addMedia(content1); - playlist.addMedia(content2); - - QCOMPARE(playlist.currentIndex(), -1); - QCOMPARE(playlist.currentMedia(), QMediaContent()); - - QCOMPARE(playlist.nextIndex(), 0); - QCOMPARE(playlist.nextIndex(2), 1); - QCOMPARE(playlist.previousIndex(), 1); - QCOMPARE(playlist.previousIndex(2), 0); - - playlist.setCurrentIndex(0); - QCOMPARE(playlist.currentIndex(), 0); - QCOMPARE(playlist.currentMedia(), content1); - - QCOMPARE(playlist.nextIndex(), 1); - QCOMPARE(playlist.nextIndex(2), -1); - QCOMPARE(playlist.previousIndex(), -1); - QCOMPARE(playlist.previousIndex(2), -1); - - playlist.setCurrentIndex(1); - QCOMPARE(playlist.currentIndex(), 1); - QCOMPARE(playlist.currentMedia(), content2); - - QCOMPARE(playlist.nextIndex(), -1); - QCOMPARE(playlist.nextIndex(2), -1); - QCOMPARE(playlist.previousIndex(), 0); - QCOMPARE(playlist.previousIndex(2), -1); - - QTest::ignoreMessage(QtWarningMsg, "QMediaPlaylistNavigator: Jump outside playlist range "); - playlist.setCurrentIndex(2); - - QCOMPARE(playlist.currentIndex(), -1); - QCOMPARE(playlist.currentMedia(), QMediaContent()); -} - -void tst_QMediaPlaylist::clear() -{ - QMediaPlaylist playlist; - playlist.addMedia(content1); - playlist.addMedia(content2); - - playlist.clear(); - QVERIFY(playlist.isEmpty()); - QCOMPARE(playlist.mediaCount(), 0); -} - -void tst_QMediaPlaylist::removeMedia() -{ - QMediaPlaylist playlist; - playlist.addMedia(content1); - playlist.addMedia(content2); - playlist.addMedia(content3); - - QSignalSpy aboutToBeRemovedSignalSpy(&playlist, SIGNAL(mediaAboutToBeRemoved(int,int))); - QSignalSpy removedSignalSpy(&playlist, SIGNAL(mediaRemoved(int,int))); - playlist.removeMedia(1); - QCOMPARE(playlist.mediaCount(), 2); - QCOMPARE(playlist.media(1), content3); - - QCOMPARE(aboutToBeRemovedSignalSpy.count(), 1); - QCOMPARE(aboutToBeRemovedSignalSpy.first()[0].toInt(), 1); - QCOMPARE(aboutToBeRemovedSignalSpy.first()[1].toInt(), 1); - - QCOMPARE(removedSignalSpy.count(), 1); - QCOMPARE(removedSignalSpy.first()[0].toInt(), 1); - QCOMPARE(removedSignalSpy.first()[1].toInt(), 1); - - aboutToBeRemovedSignalSpy.clear(); - removedSignalSpy.clear(); - - playlist.removeMedia(0,1); - QVERIFY(playlist.isEmpty()); - - QCOMPARE(aboutToBeRemovedSignalSpy.count(), 1); - QCOMPARE(aboutToBeRemovedSignalSpy.first()[0].toInt(), 0); - QCOMPARE(aboutToBeRemovedSignalSpy.first()[1].toInt(), 1); - - QCOMPARE(removedSignalSpy.count(), 1); - QCOMPARE(removedSignalSpy.first()[0].toInt(), 0); - QCOMPARE(removedSignalSpy.first()[1].toInt(), 1); - - - playlist.addMedia(content1); - playlist.addMedia(content2); - playlist.addMedia(content3); - - playlist.removeMedia(0,1); - QCOMPARE(playlist.mediaCount(), 1); - QCOMPARE(playlist.media(0), content3); -} - -void tst_QMediaPlaylist::saveAndLoad() -{ - QMediaPlaylist playlist; - playlist.addMedia(content1); - playlist.addMedia(content2); - playlist.addMedia(content3); - - QCOMPARE(playlist.error(), QMediaPlaylist::NoError); - QVERIFY(playlist.errorString().isEmpty()); - - QBuffer buffer; - buffer.open(QBuffer::ReadWrite); - - bool res = playlist.save(&buffer, "unsupported_format"); - QVERIFY(!res); - QVERIFY(playlist.error() != QMediaPlaylist::NoError); - QVERIFY(!playlist.errorString().isEmpty()); - - QSignalSpy errorSignal(&playlist, SIGNAL(loadFailed())); - playlist.load(&buffer, "unsupported_format"); - QCOMPARE(errorSignal.size(), 1); - QVERIFY(playlist.error() != QMediaPlaylist::NoError); - QVERIFY(!playlist.errorString().isEmpty()); - - res = playlist.save(QUrl(QLatin1String("tmp.unsupported_format")), "unsupported_format"); - QVERIFY(!res); - QVERIFY(playlist.error() != QMediaPlaylist::NoError); - QVERIFY(!playlist.errorString().isEmpty()); - - errorSignal.clear(); - playlist.load(QUrl(QLatin1String("tmp.unsupported_format")), "unsupported_format"); - QCOMPARE(errorSignal.size(), 1); - QVERIFY(playlist.error() != QMediaPlaylist::NoError); - QVERIFY(!playlist.errorString().isEmpty()); -} - -void tst_QMediaPlaylist::playbackMode_data() -{ - QTest::addColumn<QMediaPlaylist::PlaybackMode>("playbackMode"); - QTest::addColumn<int>("expectedPrevious"); - QTest::addColumn<int>("pos"); - QTest::addColumn<int>("expectedNext"); - - QTest::newRow("Linear, 0") << QMediaPlaylist::Linear << -1 << 0 << 1; - QTest::newRow("Linear, 1") << QMediaPlaylist::Linear << 0 << 1 << 2; - QTest::newRow("Linear, 2") << QMediaPlaylist::Linear << 1 << 2 << -1; - - QTest::newRow("Loop, 0") << QMediaPlaylist::Loop << 2 << 0 << 1; - QTest::newRow("Loop, 1") << QMediaPlaylist::Loop << 0 << 1 << 2; - QTest::newRow("Lopp, 2") << QMediaPlaylist::Loop << 1 << 2 << 0; - - QTest::newRow("ItemOnce, 1") << QMediaPlaylist::CurrentItemOnce << -1 << 1 << -1; - QTest::newRow("ItemInLoop, 1") << QMediaPlaylist::CurrentItemInLoop << 1 << 1 << 1; - -} - -void tst_QMediaPlaylist::playbackMode() -{ - QFETCH(QMediaPlaylist::PlaybackMode, playbackMode); - QFETCH(int, expectedPrevious); - QFETCH(int, pos); - QFETCH(int, expectedNext); - - QMediaPlaylist playlist; - playlist.addMedia(content1); - playlist.addMedia(content2); - playlist.addMedia(content3); - - QCOMPARE(playlist.playbackMode(), QMediaPlaylist::Linear); - QCOMPARE(playlist.currentIndex(), -1); - - playlist.setPlaybackMode(playbackMode); - QCOMPARE(playlist.playbackMode(), playbackMode); - - playlist.setCurrentIndex(pos); - QCOMPARE(playlist.currentIndex(), pos); - QCOMPARE(playlist.nextIndex(), expectedNext); - QCOMPARE(playlist.previousIndex(), expectedPrevious); - - playlist.next(); - QCOMPARE(playlist.currentIndex(), expectedNext); - - playlist.setCurrentIndex(pos); - playlist.previous(); - QCOMPARE(playlist.currentIndex(), expectedPrevious); -} - -void tst_QMediaPlaylist::shuffle() -{ - QMediaPlaylist playlist; - QList<QMediaContent> contentList; - - for (int i=0; i<100; i++) { - QMediaContent content(QUrl(QString::number(i))); - contentList.append(content); - playlist.addMedia(content); - } - - playlist.shuffle(); - - QList<QMediaContent> shuffledContentList; - for (int i=0; i<playlist.mediaCount(); i++) - shuffledContentList.append(playlist.media(i)); - - QVERIFY(contentList != shuffledContentList); - -} - -void tst_QMediaPlaylist::readOnlyPlaylist() -{ - MockReadOnlyPlaylistObject mediaObject; - QMediaPlaylist playlist; - playlist.setMediaObject(&mediaObject); - - QVERIFY(playlist.isReadOnly()); - QVERIFY(!playlist.isEmpty()); - QCOMPARE(playlist.mediaCount(), 3); - - QCOMPARE(playlist.media(0), content1); - QCOMPARE(playlist.media(1), content2); - QCOMPARE(playlist.media(2), content3); - QCOMPARE(playlist.media(3), QMediaContent()); - - //it's a read only playlist, so all the modification should fail - QVERIFY(!playlist.addMedia(content1)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(!playlist.addMedia(QList<QMediaContent>() << content1 << content2)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(!playlist.insertMedia(1, content1)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(!playlist.insertMedia(1, QList<QMediaContent>() << content1 << content2)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(!playlist.removeMedia(1)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(!playlist.removeMedia(0,2)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(!playlist.clear()); - QCOMPARE(playlist.mediaCount(), 3); - - //but it is still allowed to append/insert an empty list - QVERIFY(playlist.addMedia(QList<QMediaContent>())); - QVERIFY(playlist.insertMedia(1, QList<QMediaContent>())); - - playlist.shuffle(); - //it's still the same - QCOMPARE(playlist.media(0), content1); - QCOMPARE(playlist.media(1), content2); - QCOMPARE(playlist.media(2), content3); - QCOMPARE(playlist.media(3), QMediaContent()); - - - //load to read only playlist should fail, - //unless underlaying provider supports it - QBuffer buffer; - buffer.open(QBuffer::ReadWrite); - buffer.write(QByteArray("file:///1\nfile:///2")); - buffer.seek(0); - - QSignalSpy errorSignal(&playlist, SIGNAL(loadFailed())); - playlist.load(&buffer, "m3u"); - QCOMPARE(errorSignal.size(), 1); - QCOMPARE(playlist.error(), QMediaPlaylist::AccessDeniedError); - QVERIFY(!playlist.errorString().isEmpty()); - QCOMPARE(playlist.mediaCount(), 3); - - errorSignal.clear(); - playlist.load(QUrl(QLatin1String("tmp.m3u")), "m3u"); - - QCOMPARE(errorSignal.size(), 1); - QCOMPARE(playlist.error(), QMediaPlaylist::AccessDeniedError); - QVERIFY(!playlist.errorString().isEmpty()); - QCOMPARE(playlist.mediaCount(), 3); -} - -void tst_QMediaPlaylist::setMediaObject() -{ - MockReadOnlyPlaylistObject mediaObject; - - QMediaPlaylist playlist; - QVERIFY(playlist.mediaObject() == 0); - QVERIFY(!playlist.isReadOnly()); - - playlist.setMediaObject(&mediaObject); - QCOMPARE(playlist.mediaObject(), qobject_cast<QMediaObject*>(&mediaObject)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(playlist.isReadOnly()); - - playlist.setMediaObject(0); - QVERIFY(playlist.mediaObject() == 0); - QCOMPARE(playlist.mediaCount(), 0); - QVERIFY(!playlist.isReadOnly()); - - playlist.setMediaObject(&mediaObject); - QCOMPARE(playlist.mediaObject(), qobject_cast<QMediaObject*>(&mediaObject)); - QCOMPARE(playlist.mediaCount(), 3); - QVERIFY(playlist.isReadOnly()); -} - -QTEST_MAIN(tst_QMediaPlaylist) -#include "tst_qmediaplaylist.moc" - diff --git a/tests/auto/qmediaplaylistnavigator/qmediaplaylistnavigator.pro b/tests/auto/qmediaplaylistnavigator/qmediaplaylistnavigator.pro deleted file mode 100644 index 3265762..0000000 --- a/tests/auto/qmediaplaylistnavigator/qmediaplaylistnavigator.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qmediaplaylistnavigator.cpp - -QT = core mediaservices - diff --git a/tests/auto/qmediaplaylistnavigator/tst_qmediaplaylistnavigator.cpp b/tests/auto/qmediaplaylistnavigator/tst_qmediaplaylistnavigator.cpp deleted file mode 100644 index 04f736c..0000000 --- a/tests/auto/qmediaplaylistnavigator/tst_qmediaplaylistnavigator.cpp +++ /dev/null @@ -1,316 +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 <QtTest/QtTest> -#include <QDebug> -#include <QtMediaServices/qlocalmediaplaylistprovider.h> -#include <QtMediaServices/qmediaplaylistnavigator.h> - - -class tst_QMediaPlaylistNavigator : public QObject -{ - Q_OBJECT -public slots: - void init(); - void cleanup(); - -private slots: - void construction(); - void setPlaylist(); - void linearPlayback(); - void loopPlayback(); - void currentItemOnce(); - void currentItemInLoop(); - void randomPlayback(); -}; - -void tst_QMediaPlaylistNavigator::init() -{ -} - -void tst_QMediaPlaylistNavigator::cleanup() -{ -} - -void tst_QMediaPlaylistNavigator::construction() -{ - QLocalMediaPlaylistProvider playlist; - QCOMPARE(playlist.mediaCount(), 0); - - QMediaPlaylistNavigator navigator(&playlist); - QVERIFY(navigator.currentItem().isNull()); - QCOMPARE(navigator.currentIndex(), -1); -} - -void tst_QMediaPlaylistNavigator::setPlaylist() -{ - QMediaPlaylistNavigator navigator(0); - QVERIFY(navigator.playlist() != 0); - QCOMPARE(navigator.playlist()->mediaCount(), 0); - QCOMPARE(navigator.playlist()->media(0), QMediaContent()); - QVERIFY(navigator.playlist()->isReadOnly() ); - - QLocalMediaPlaylistProvider playlist; - QCOMPARE(playlist.mediaCount(), 0); - - navigator.setPlaylist(&playlist); - QCOMPARE(navigator.playlist(), (QMediaPlaylistProvider*)&playlist); - QCOMPARE(navigator.playlist()->mediaCount(), 0); - QVERIFY(!navigator.playlist()->isReadOnly() ); -} - -void tst_QMediaPlaylistNavigator::linearPlayback() -{ - QLocalMediaPlaylistProvider playlist; - QMediaPlaylistNavigator navigator(&playlist); - - navigator.setPlaybackMode(QMediaPlaylist::Linear); - QTest::ignoreMessage(QtWarningMsg, "QMediaPlaylistNavigator: Jump outside playlist range "); - navigator.jump(0);//it's ok to have warning here - QVERIFY(navigator.currentItem().isNull()); - QCOMPARE(navigator.currentIndex(), -1); - - QMediaContent content1(QUrl(QLatin1String("file:///1"))); - playlist.addMedia(content1); - navigator.jump(0); - QVERIFY(!navigator.currentItem().isNull()); - - QCOMPARE(navigator.currentIndex(), 0); - QCOMPARE(navigator.currentItem(), content1); - QCOMPARE(navigator.nextItem(), QMediaContent()); - QCOMPARE(navigator.nextItem(2), QMediaContent()); - QCOMPARE(navigator.previousItem(), QMediaContent()); - QCOMPARE(navigator.previousItem(2), QMediaContent()); - - QMediaContent content2(QUrl(QLatin1String("file:///2"))); - playlist.addMedia(content2); - QCOMPARE(navigator.currentIndex(), 0); - QCOMPARE(navigator.currentItem(), content1); - QCOMPARE(navigator.nextItem(), content2); - QCOMPARE(navigator.nextItem(2), QMediaContent()); - QCOMPARE(navigator.previousItem(), QMediaContent()); - QCOMPARE(navigator.previousItem(2), QMediaContent()); - - navigator.jump(1); - QCOMPARE(navigator.currentIndex(), 1); - QCOMPARE(navigator.currentItem(), content2); - QCOMPARE(navigator.nextItem(), QMediaContent()); - QCOMPARE(navigator.nextItem(2), QMediaContent()); - QCOMPARE(navigator.previousItem(), content1); - QCOMPARE(navigator.previousItem(2), QMediaContent()); - - navigator.jump(0); - navigator.next(); - QCOMPARE(navigator.currentIndex(), 1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), -1); - navigator.next();//jump to the first item - QCOMPARE(navigator.currentIndex(), 0); - - navigator.previous(); - QCOMPARE(navigator.currentIndex(), -1); - navigator.previous();//jump to the last item - QCOMPARE(navigator.currentIndex(), 1); -} - -void tst_QMediaPlaylistNavigator::loopPlayback() -{ - QLocalMediaPlaylistProvider playlist; - QMediaPlaylistNavigator navigator(&playlist); - - navigator.setPlaybackMode(QMediaPlaylist::Loop); - QTest::ignoreMessage(QtWarningMsg, "QMediaPlaylistNavigator: Jump outside playlist range "); - navigator.jump(0); - QVERIFY(navigator.currentItem().isNull()); - QCOMPARE(navigator.currentIndex(), -1); - - QMediaContent content1(QUrl(QLatin1String("file:///1"))); - playlist.addMedia(content1); - navigator.jump(0); - QVERIFY(!navigator.currentItem().isNull()); - - QCOMPARE(navigator.currentIndex(), 0); - QCOMPARE(navigator.currentItem(), content1); - QCOMPARE(navigator.nextItem(), content1); - QCOMPARE(navigator.nextItem(2), content1); - QCOMPARE(navigator.previousItem(), content1); - QCOMPARE(navigator.previousItem(2), content1); - - QMediaContent content2(QUrl(QLatin1String("file:///2"))); - playlist.addMedia(content2); - QCOMPARE(navigator.currentIndex(), 0); - QCOMPARE(navigator.currentItem(), content1); - QCOMPARE(navigator.nextItem(), content2); - QCOMPARE(navigator.nextItem(2), content1); //loop over end of the list - QCOMPARE(navigator.previousItem(), content2); - QCOMPARE(navigator.previousItem(2), content1); - - navigator.jump(1); - QCOMPARE(navigator.currentIndex(), 1); - QCOMPARE(navigator.currentItem(), content2); - QCOMPARE(navigator.nextItem(), content1); - QCOMPARE(navigator.nextItem(2), content2); - QCOMPARE(navigator.previousItem(), content1); - QCOMPARE(navigator.previousItem(2), content2); - - navigator.jump(0); - navigator.next(); - QCOMPARE(navigator.currentIndex(), 1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), 0); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), 1); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), 0); -} - -void tst_QMediaPlaylistNavigator::currentItemOnce() -{ - QLocalMediaPlaylistProvider playlist; - QMediaPlaylistNavigator navigator(&playlist); - - navigator.setPlaybackMode(QMediaPlaylist::CurrentItemOnce); - - QCOMPARE(navigator.playbackMode(), QMediaPlaylist::CurrentItemOnce); - QCOMPARE(navigator.currentIndex(), -1); - - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1")))); - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2")))); - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///3")))); - - QCOMPARE(navigator.currentIndex(), -1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), -1); - - navigator.jump(1); - QCOMPARE(navigator.currentIndex(), 1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), -1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), -1); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), -1); - navigator.jump(1); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), -1); -} - -void tst_QMediaPlaylistNavigator::currentItemInLoop() -{ - QLocalMediaPlaylistProvider playlist; - QMediaPlaylistNavigator navigator(&playlist); - - navigator.setPlaybackMode(QMediaPlaylist::CurrentItemInLoop); - - QCOMPARE(navigator.playbackMode(), QMediaPlaylist::CurrentItemInLoop); - QCOMPARE(navigator.currentIndex(), -1); - - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1")))); - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2")))); - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///3")))); - - QCOMPARE(navigator.currentIndex(), -1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), -1); - navigator.jump(1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), 1); - navigator.next(); - QCOMPARE(navigator.currentIndex(), 1); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), 1); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), 1); -} - -void tst_QMediaPlaylistNavigator::randomPlayback() -{ - QLocalMediaPlaylistProvider playlist; - QMediaPlaylistNavigator navigator(&playlist); - - navigator.setPlaybackMode(QMediaPlaylist::Random); - - QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Random); - QCOMPARE(navigator.currentIndex(), -1); - - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1")))); - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2")))); - playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///3")))); - - playlist.shuffle(); - - QCOMPARE(navigator.currentIndex(), -1); - navigator.next(); - int pos1 = navigator.currentIndex(); - navigator.next(); - int pos2 = navigator.currentIndex(); - navigator.next(); - int pos3 = navigator.currentIndex(); - - QVERIFY(pos1 != -1); - QVERIFY(pos2 != -1); - QVERIFY(pos3 != -1); - - navigator.previous(); - QCOMPARE(navigator.currentIndex(), pos2); - navigator.next(); - QCOMPARE(navigator.currentIndex(), pos3); - navigator.next(); - int pos4 = navigator.currentIndex(); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), pos3); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), pos2); - navigator.previous(); - QCOMPARE(navigator.currentIndex(), pos1); - navigator.previous(); - int pos0 = navigator.currentIndex(); - QVERIFY(pos0 != -1); - navigator.next(); - navigator.next(); - navigator.next(); - navigator.next(); - QCOMPARE(navigator.currentIndex(), pos4); - -} - -QTEST_MAIN(tst_QMediaPlaylistNavigator) -#include "tst_qmediaplaylistnavigator.moc" diff --git a/tests/auto/qmediapluginloader/qmediapluginloader.pro b/tests/auto/qmediapluginloader/qmediapluginloader.pro deleted file mode 100644 index a47cc57..0000000 --- a/tests/auto/qmediapluginloader/qmediapluginloader.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qmediapluginloader.cpp - -QT = core mediaservices - diff --git a/tests/auto/qmediapluginloader/tst_qmediapluginloader.cpp b/tests/auto/qmediapluginloader/tst_qmediapluginloader.cpp deleted file mode 100644 index 001e68a..0000000 --- a/tests/auto/qmediapluginloader/tst_qmediapluginloader.cpp +++ /dev/null @@ -1,121 +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 <QtTest/QtTest> -#include <QDebug> - -#include <QtMediaServices/private/qmediapluginloader_p.h> -#include <QtMediaServices/qmediaserviceproviderplugin.h> - - - -class tst_QMediaPluginLoader : public QObject -{ - Q_OBJECT - -public slots: - void initTestCase(); - void cleanupTestCase(); - -private slots: - void testInstance(); - void testInstances(); - void testInvalidKey(); - -private: - QMediaPluginLoader *loader; -}; - -void tst_QMediaPluginLoader::initTestCase() -{ - loader = new QMediaPluginLoader(QMediaServiceProviderFactoryInterface_iid, - QLatin1String("/mediaservice"), - Qt::CaseInsensitive); -} - -void tst_QMediaPluginLoader::cleanupTestCase() -{ - delete loader; -} - -void tst_QMediaPluginLoader::testInstance() -{ - const QStringList keys = loader->keys(); - - if (keys.isEmpty()) // Test is invalidated, skip. - QSKIP("No plug-ins available", SkipAll); - - foreach (const QString &key, keys) - QVERIFY(loader->instance(key) != 0); -} - -void tst_QMediaPluginLoader::testInstances() -{ - const QStringList keys = loader->keys(); - - if (keys.isEmpty()) // Test is invalidated, skip. - QSKIP("No plug-ins available", SkipAll); - - foreach (const QString &key, keys) - QVERIFY(loader->instances(key).size() > 0); -} - -// Last so as to not interfere with the other tests if there is a failure. -void tst_QMediaPluginLoader::testInvalidKey() -{ - const QString key(QLatin1String("invalid-key")); - - // This test assumes there is no 'invalid-key' in the key list, verify that. - if (loader->keys().contains(key)) - QSKIP("a plug-in includes the invalid key", SkipAll); - - QVERIFY(loader->instance(key) == 0); - - // Test looking up the key hasn't inserted it into the list. See QMap::operator[]. - QVERIFY(!loader->keys().contains(key)); - - QVERIFY(loader->instances(key).isEmpty()); - QVERIFY(!loader->keys().contains(key)); -} - -QTEST_MAIN(tst_QMediaPluginLoader) - -#include "tst_qmediapluginloader.moc" diff --git a/tests/auto/qmediaresource/qmediaresource.pro b/tests/auto/qmediaresource/qmediaresource.pro deleted file mode 100644 index 64669a2..0000000 --- a/tests/auto/qmediaresource/qmediaresource.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qmediaresource.cpp - -QT = core mediaservices network - diff --git a/tests/auto/qmediaresource/tst_qmediaresource.cpp b/tests/auto/qmediaresource/tst_qmediaresource.cpp deleted file mode 100644 index 984cfef..0000000 --- a/tests/auto/qmediaresource/tst_qmediaresource.cpp +++ /dev/null @@ -1,516 +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 <QtTest/QtTest> - -#include <QtMediaServices/qmediaresource.h> - - -class tst_QMediaResource : public QObject -{ - Q_OBJECT -private slots: - void constructNull(); - void construct_data(); - void construct(); - void setResolution(); - void equality(); - void copy(); - void assign(); -}; - -void tst_QMediaResource::constructNull() -{ - QMediaResource resource; - - QCOMPARE(resource.isNull(), true); - QCOMPARE(resource.url(), QUrl()); - QCOMPARE(resource.request(), QNetworkRequest()); - QCOMPARE(resource.mimeType(), QString()); - QCOMPARE(resource.language(), QString()); - QCOMPARE(resource.audioCodec(), QString()); - QCOMPARE(resource.videoCodec(), QString()); - QCOMPARE(resource.dataSize(), qint64(0)); - QCOMPARE(resource.audioBitRate(), 0); - QCOMPARE(resource.sampleRate(), 0); - QCOMPARE(resource.channelCount(), 0); - QCOMPARE(resource.videoBitRate(), 0); - QCOMPARE(resource.resolution(), QSize()); -} - -void tst_QMediaResource::construct_data() -{ - QTest::addColumn<QUrl>("url"); - QTest::addColumn<QNetworkRequest>("request"); - QTest::addColumn<QString>("mimeType"); - QTest::addColumn<QString>("language"); - QTest::addColumn<QString>("audioCodec"); - QTest::addColumn<QString>("videoCodec"); - QTest::addColumn<qint64>("dataSize"); - QTest::addColumn<int>("audioBitRate"); - QTest::addColumn<int>("sampleRate"); - QTest::addColumn<int>("channelCount"); - QTest::addColumn<int>("videoBitRate"); - QTest::addColumn<QSize>("resolution"); - - QTest::newRow("audio content") - << QUrl(QString::fromLatin1("http:://test.com/test.mp3")) - << QNetworkRequest(QUrl(QString::fromLatin1("http:://test.com/test.mp3"))) - << QString::fromLatin1("audio/mpeg") - << QString::fromLatin1("eng") - << QString::fromLatin1("mp3") - << QString() - << qint64(5465433) - << 128000 - << 44100 - << 2 - << 0 - << QSize(); - QTest::newRow("image content") - << QUrl(QString::fromLatin1("http:://test.com/test.jpg")) - << QNetworkRequest(QUrl(QString::fromLatin1("http:://test.com/test.jpg"))) - << QString::fromLatin1("image/jpeg") - << QString() - << QString() - << QString() - << qint64(23600) - << 0 - << 0 - << 0 - << 0 - << QSize(640, 480); - QTest::newRow("video content") - << QUrl(QString::fromLatin1("http:://test.com/test.mp4")) - << QNetworkRequest(QUrl(QString::fromLatin1("http:://test.com/test.mp4"))) - << QString::fromLatin1("video/mp4") - << QString() - << QString::fromLatin1("aac") - << QString::fromLatin1("h264") - << qint64(36245851) - << 96000 - << 44000 - << 5 - << 750000 - << QSize(720, 576); - QTest::newRow("thumbnail") - << QUrl(QString::fromLatin1("file::///thumbs/test.png")) - << QNetworkRequest(QUrl(QString::fromLatin1("file::///thumbs/test.png"))) - << QString::fromLatin1("image/png") - << QString() - << QString() - << QString() - << qint64(2360) - << 0 - << 0 - << 0 - << 0 - << QSize(128, 128); -} - -void tst_QMediaResource::construct() -{ - QFETCH(QUrl, url); - QFETCH(QNetworkRequest, request); - QFETCH(QString, mimeType); - QFETCH(QString, language); - QFETCH(QString, audioCodec); - QFETCH(QString, videoCodec); - QFETCH(qint64, dataSize); - QFETCH(int, audioBitRate); - QFETCH(int, sampleRate); - QFETCH(int, channelCount); - QFETCH(int, videoBitRate); - QFETCH(QSize, resolution); - - { - QMediaResource resource(url); - - QCOMPARE(resource.isNull(), false); - QCOMPARE(resource.url(), url); - QCOMPARE(resource.mimeType(), QString()); - QCOMPARE(resource.language(), QString()); - QCOMPARE(resource.audioCodec(), QString()); - QCOMPARE(resource.videoCodec(), QString()); - QCOMPARE(resource.dataSize(), qint64(0)); - QCOMPARE(resource.audioBitRate(), 0); - QCOMPARE(resource.sampleRate(), 0); - QCOMPARE(resource.channelCount(), 0); - QCOMPARE(resource.videoBitRate(), 0); - QCOMPARE(resource.resolution(), QSize()); - } - { - QMediaResource resource(url, mimeType); - - QCOMPARE(resource.isNull(), false); - QCOMPARE(resource.url(), url); - QCOMPARE(resource.request(), request); - QCOMPARE(resource.mimeType(), mimeType); - QCOMPARE(resource.language(), QString()); - QCOMPARE(resource.audioCodec(), QString()); - QCOMPARE(resource.videoCodec(), QString()); - QCOMPARE(resource.dataSize(), qint64(0)); - QCOMPARE(resource.audioBitRate(), 0); - QCOMPARE(resource.sampleRate(), 0); - QCOMPARE(resource.channelCount(), 0); - QCOMPARE(resource.videoBitRate(), 0); - QCOMPARE(resource.resolution(), QSize()); - - resource.setLanguage(language); - resource.setAudioCodec(audioCodec); - resource.setVideoCodec(videoCodec); - resource.setDataSize(dataSize); - resource.setAudioBitRate(audioBitRate); - resource.setSampleRate(sampleRate); - resource.setChannelCount(channelCount); - resource.setVideoBitRate(videoBitRate); - resource.setResolution(resolution); - - QCOMPARE(resource.language(), language); - QCOMPARE(resource.audioCodec(), audioCodec); - QCOMPARE(resource.videoCodec(), videoCodec); - QCOMPARE(resource.dataSize(), dataSize); - QCOMPARE(resource.audioBitRate(), audioBitRate); - QCOMPARE(resource.sampleRate(), sampleRate); - QCOMPARE(resource.channelCount(), channelCount); - QCOMPARE(resource.videoBitRate(), videoBitRate); - QCOMPARE(resource.resolution(), resolution); - } - { - QMediaResource resource(request, mimeType); - - QCOMPARE(resource.isNull(), false); - QCOMPARE(resource.url(), url); - QCOMPARE(resource.request(), request); - QCOMPARE(resource.mimeType(), mimeType); - QCOMPARE(resource.language(), QString()); - QCOMPARE(resource.audioCodec(), QString()); - QCOMPARE(resource.videoCodec(), QString()); - QCOMPARE(resource.dataSize(), qint64(0)); - QCOMPARE(resource.audioBitRate(), 0); - QCOMPARE(resource.sampleRate(), 0); - QCOMPARE(resource.channelCount(), 0); - QCOMPARE(resource.videoBitRate(), 0); - QCOMPARE(resource.resolution(), QSize()); - - resource.setLanguage(language); - resource.setAudioCodec(audioCodec); - resource.setVideoCodec(videoCodec); - resource.setDataSize(dataSize); - resource.setAudioBitRate(audioBitRate); - resource.setSampleRate(sampleRate); - resource.setChannelCount(channelCount); - resource.setVideoBitRate(videoBitRate); - resource.setResolution(resolution); - - QCOMPARE(resource.language(), language); - QCOMPARE(resource.audioCodec(), audioCodec); - QCOMPARE(resource.videoCodec(), videoCodec); - QCOMPARE(resource.dataSize(), dataSize); - QCOMPARE(resource.audioBitRate(), audioBitRate); - QCOMPARE(resource.sampleRate(), sampleRate); - QCOMPARE(resource.channelCount(), channelCount); - QCOMPARE(resource.videoBitRate(), videoBitRate); - QCOMPARE(resource.resolution(), resolution); - } -} - -void tst_QMediaResource::setResolution() -{ - QMediaResource resource( - QUrl(QString::fromLatin1("file::///thumbs/test.png")), - QString::fromLatin1("image/png")); - - QCOMPARE(resource.resolution(), QSize()); - - resource.setResolution(QSize(120, 80)); - QCOMPARE(resource.resolution(), QSize(120, 80)); - - resource.setResolution(QSize(-1, 23)); - QCOMPARE(resource.resolution(), QSize(-1, 23)); - - resource.setResolution(QSize(-43, 34)); - QCOMPARE(resource.resolution(), QSize(-43, 34)); - - resource.setResolution(QSize(64, -1)); - QCOMPARE(resource.resolution(), QSize(64, -1)); - - resource.setResolution(QSize(64, -83)); - QCOMPARE(resource.resolution(), QSize(64, -83)); - - resource.setResolution(QSize(-12, -83)); - QCOMPARE(resource.resolution(), QSize(-12, -83)); - - resource.setResolution(QSize()); - QCOMPARE(resource.resolution(), QSize(-1, -1)); - - resource.setResolution(120, 80); - QCOMPARE(resource.resolution(), QSize(120, 80)); - - resource.setResolution(-1, 23); - QCOMPARE(resource.resolution(), QSize(-1, 23)); - - resource.setResolution(-43, 34); - QCOMPARE(resource.resolution(), QSize(-43, 34)); - - resource.setResolution(64, -1); - QCOMPARE(resource.resolution(), QSize(64, -1)); - - resource.setResolution(64, -83); - QCOMPARE(resource.resolution(), QSize(64, -83)); - - resource.setResolution(-12, -83); - QCOMPARE(resource.resolution(), QSize(-12, -83)); - - resource.setResolution(-1, -1); - QCOMPARE(resource.resolution(), QSize()); -} - -void tst_QMediaResource::equality() -{ - QMediaResource resource1( - QUrl(QString::fromLatin1("http://test.com/test.mp4")), - QString::fromLatin1("video/mp4")); - QMediaResource resource2( - QUrl(QString::fromLatin1("http://test.com/test.mp4")), - QString::fromLatin1("video/mp4")); - QMediaResource resource3( - QUrl(QString::fromLatin1("file:///thumbs/test.jpg"))); - QMediaResource resource4( - QUrl(QString::fromLatin1("file:///thumbs/test.jpg"))); - QMediaResource resource5( - QUrl(QString::fromLatin1("http://test.com/test.mp3")), - QString::fromLatin1("audio/mpeg")); - - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - QCOMPARE(resource3 == resource4, true); - QCOMPARE(resource3 != resource4, false); - - QCOMPARE(resource1 == resource3, false); - QCOMPARE(resource1 != resource3, true); - - QCOMPARE(resource1 == resource5, false); - QCOMPARE(resource1 != resource5, true); - - resource1.setAudioCodec(QString::fromLatin1("mp3")); - resource2.setAudioCodec(QString::fromLatin1("aac")); - - // Not equal differing audio codecs. - QCOMPARE(resource1 == resource2, false); - QCOMPARE(resource1 != resource2, true); - - resource1.setAudioCodec(QString::fromLatin1("aac")); - - // Equal. - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource1.setVideoCodec(QString()); - - // Equal. - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource1.setVideoCodec(QString::fromLatin1("h264")); - - // Not equal differing video codecs. - QCOMPARE(resource1 == resource2, false); - QCOMPARE(resource1 != resource2, true); - - resource2.setVideoCodec(QString::fromLatin1("h264")); - - // Equal. - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource2.setDataSize(0); - - // Equal. - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource1.setDataSize(546423); - - // Not equal differing video codecs. - QCOMPARE(resource1 == resource2, false); - QCOMPARE(resource1 != resource2, true); - - resource2.setDataSize(546423); - - // Equal. - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource1.setAudioBitRate(96000); - resource1.setSampleRate(48000); - resource2.setSampleRate(44100); - resource1.setChannelCount(0); - resource1.setVideoBitRate(900000); - resource2.setLanguage(QString::fromLatin1("eng")); - - // Not equal, audio bit rate, sample rate, video bit rate, and - // language. - QCOMPARE(resource1 == resource2, false); - QCOMPARE(resource1 != resource2, true); - - resource2.setAudioBitRate(96000); - resource1.setSampleRate(44100); - - // Not equal, differing video bit rate, and language. - QCOMPARE(resource1 == resource2, false); - QCOMPARE(resource1 != resource2, true); - - resource2.setVideoBitRate(900000); - resource1.setLanguage(QString::fromLatin1("eng")); - - // Equal - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource1.setResolution(QSize()); - - // Equal - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource2.setResolution(-1, -1); - - // Equal - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); - - resource1.setResolution(QSize(-640, -480)); - - // Not equal, differing resolution. - QCOMPARE(resource1 == resource2, false); - QCOMPARE(resource1 != resource2, true); - resource1.setResolution(QSize(640, 480)); - resource2.setResolution(QSize(800, 600)); - - // Not equal, differing resolution. - QCOMPARE(resource1 == resource2, false); - QCOMPARE(resource1 != resource2, true); - - resource1.setResolution(800, 600); - - // Equal - QCOMPARE(resource1 == resource2, true); - QCOMPARE(resource1 != resource2, false); -} - -void tst_QMediaResource::copy() -{ - const QUrl url(QString::fromLatin1("http://test.com/test.mp4")); - const QString mimeType(QLatin1String("video/mp4")); - const QString amrCodec(QLatin1String("amr")); - const QString mp3Codec(QLatin1String("mp3")); - const QString aacCodec(QLatin1String("aac")); - const QString h264Codec(QLatin1String("h264")); - - QMediaResource original(url, mimeType); - original.setAudioCodec(amrCodec); - - QMediaResource copy(original); - - QCOMPARE(copy.url(), url); - QCOMPARE(copy.mimeType(), mimeType); - QCOMPARE(copy.audioCodec(), amrCodec); - - QCOMPARE(original == copy, true); - QCOMPARE(original != copy, false); - - original.setAudioCodec(mp3Codec); - - QCOMPARE(copy.audioCodec(), amrCodec); - QCOMPARE(original == copy, false); - QCOMPARE(original != copy, true); - - copy.setAudioCodec(aacCodec); - copy.setVideoCodec(h264Codec); - - QCOMPARE(copy.url(), url); - QCOMPARE(copy.mimeType(), mimeType); - - QCOMPARE(original.audioCodec(), mp3Codec); -} - -void tst_QMediaResource::assign() -{ - const QUrl url(QString::fromLatin1("http://test.com/test.mp4")); - const QString mimeType(QLatin1String("video/mp4")); - const QString amrCodec(QLatin1String("amr")); - const QString mp3Codec(QLatin1String("mp3")); - const QString aacCodec(QLatin1String("aac")); - const QString h264Codec(QLatin1String("h264")); - - QMediaResource copy(QUrl(QString::fromLatin1("file:///thumbs/test.jpg"))); - - QMediaResource original(url, mimeType); - original.setAudioCodec(amrCodec); - - copy = original; - - QCOMPARE(copy.url(), url); - QCOMPARE(copy.mimeType(), mimeType); - QCOMPARE(copy.audioCodec(), amrCodec); - - QCOMPARE(original == copy, true); - QCOMPARE(original != copy, false); - - original.setAudioCodec(mp3Codec); - - QCOMPARE(copy.audioCodec(), amrCodec); - QCOMPARE(original == copy, false); - QCOMPARE(original != copy, true); - - copy.setAudioCodec(aacCodec); - copy.setVideoCodec(h264Codec); - - QCOMPARE(copy.url(), url); - QCOMPARE(copy.mimeType(), mimeType); - - QCOMPARE(original.audioCodec(), mp3Codec); -} - -QTEST_MAIN(tst_QMediaResource) - -#include "tst_qmediaresource.moc" diff --git a/tests/auto/qmediaservice/qmediaservice.pro b/tests/auto/qmediaservice/qmediaservice.pro deleted file mode 100644 index 8acd03a..0000000 --- a/tests/auto/qmediaservice/qmediaservice.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qmediaservice.cpp - -QT = core gui mediaservices - diff --git a/tests/auto/qmediaservice/tst_qmediaservice.cpp b/tests/auto/qmediaservice/tst_qmediaservice.cpp deleted file mode 100644 index a544e77..0000000 --- a/tests/auto/qmediaservice/tst_qmediaservice.cpp +++ /dev/null @@ -1,219 +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 <QtTest/QtTest> - -#include <QtMediaServices/qvideodevicecontrol.h> -#include <QtMediaServices/qmediacontrol.h> -#include <QtMediaServices/qmediaservice.h> - -#include <QtGui/qapplication.h> -#include <QtGui/qstyle.h> - -class QtTestMediaService; - - -class tst_QMediaService : public QObject -{ - Q_OBJECT -private slots: - void initTestCase(); - - void control_iid(); - void control(); -}; - - -class QtTestMediaControlA : public QMediaControl -{ - Q_OBJECT -}; - - -#define QtTestMediaControlA_iid "com.nokia.QtTestMediaControlA" -QT_BEGIN_NAMESPACE -Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlA, QtTestMediaControlA_iid) -QT_END_NAMESPACE - - -class QtTestMediaControlB : public QMediaControl -{ - Q_OBJECT -}; - -#define QtTestMediaControlB_iid "com.nokia.QtTestMediaControlB" -QT_BEGIN_NAMESPACE -Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlB, QtTestMediaControlB_iid) -QT_END_NAMESPACE - - -class QtTestMediaControlC : public QMediaControl -{ - Q_OBJECT -}; - -#define QtTestMediaControlC_iid "com.nokia.QtTestMediaControlC" -QT_BEGIN_NAMESPACE -Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlC, QtTestMediaControlA_iid) // Yes A. -QT_END_NAMESPACE - -class QtTestMediaControlD : public QMediaControl -{ - Q_OBJECT -}; - -#define QtTestMediaControlD_iid "com.nokia.QtTestMediaControlD" -QT_BEGIN_NAMESPACE -Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlD, QtTestMediaControlD_iid) -QT_END_NAMESPACE - -class QtTestMediaControlE : public QMediaControl -{ - Q_OBJECT -}; - -struct QtTestDevice -{ - QtTestDevice() {} - QtTestDevice(const QString &name, const QString &description, const QIcon &icon) - : name(name), description(description), icon(icon) - { - } - - QString name; - QString description; - QIcon icon; -}; - -class QtTestVideoDeviceControl : public QVideoDeviceControl -{ -public: - QtTestVideoDeviceControl(QObject *parent = 0) - : QVideoDeviceControl(parent) - , m_selectedDevice(-1) - , m_defaultDevice(-1) - { - } - - int deviceCount() const { return devices.count(); } - - QString deviceName(int index) const { return devices.value(index).name; } - QString deviceDescription(int index) const { return devices.value(index).description; } - QIcon deviceIcon(int index) const { return devices.value(index).icon; } - - int defaultDevice() const { return m_defaultDevice; } - void setDefaultDevice(int index) { m_defaultDevice = index; } - - int selectedDevice() const { return m_selectedDevice; } - void setSelectedDevice(int index) - { - emit selectedDeviceChanged(m_selectedDevice = index); - emit selectedDeviceChanged(devices.value(index).name); - } - - QList<QtTestDevice> devices; - -private: - int m_selectedDevice; - int m_defaultDevice; -}; - -class QtTestMediaService : public QMediaService -{ - Q_OBJECT -public: - QtTestMediaService() - : QMediaService(0) - , hasDeviceControls(false) - { - } - - QMediaControl* control(const char *name) const - { - if (strcmp(name, QtTestMediaControlA_iid) == 0) - return const_cast<QtTestMediaControlA *>(&controlA); - else if (strcmp(name, QtTestMediaControlB_iid) == 0) - return const_cast<QtTestMediaControlB *>(&controlB); - else if (strcmp(name, QtTestMediaControlC_iid) == 0) - return const_cast<QtTestMediaControlC *>(&controlC); - else if (hasDeviceControls && strcmp(name, QVideoDeviceControl_iid) == 0) - return const_cast<QtTestVideoDeviceControl *>(&videoDeviceControl); - else - return 0; - } - - using QMediaService::control; - - QtTestMediaControlA controlA; - QtTestMediaControlB controlB; - QtTestMediaControlC controlC; - QtTestVideoDeviceControl videoDeviceControl; - bool hasDeviceControls; -}; - -void tst_QMediaService::initTestCase() -{ -} - -void tst_QMediaService::control_iid() -{ - const char *nullString = 0; - - // Default implementation. - QCOMPARE(qmediacontrol_iid<QtTestMediaControlE *>(), nullString); - - // Partial template. - QVERIFY(qstrcmp(qmediacontrol_iid<QtTestMediaControlA *>(), QtTestMediaControlA_iid) == 0); -} - -void tst_QMediaService::control() -{ - QtTestMediaService service; - - QCOMPARE(service.control<QtTestMediaControlA *>(), &service.controlA); - QCOMPARE(service.control<QtTestMediaControlB *>(), &service.controlB); - QVERIFY(!service.control<QtTestMediaControlC *>()); // Faulty implementation returns A. - QVERIFY(!service.control<QtTestMediaControlD *>()); // No control of that type. -} - -QTEST_MAIN(tst_QMediaService) - -#include "tst_qmediaservice.moc" diff --git a/tests/auto/qmediaserviceprovider/qmediaserviceprovider.pro b/tests/auto/qmediaserviceprovider/qmediaserviceprovider.pro deleted file mode 100644 index 69b3864..0000000 --- a/tests/auto/qmediaserviceprovider/qmediaserviceprovider.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qmediaserviceprovider.cpp - -QT = core gui mediaservices - diff --git a/tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp b/tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp deleted file mode 100644 index 64abedb..0000000 --- a/tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp +++ /dev/null @@ -1,481 +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 <QtTest/QtTest> -#include <QDebug> -#include <QStringList> - -#include <QtMediaServices/qmediaserviceprovider.h> -#include <QtMediaServices/qmediaserviceproviderplugin.h> -#include <QtMediaServices/private/qmediapluginloader_p.h> -#include <QtMediaServices/qmediaobject.h> -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/qmediaplayer.h> - -class MockMediaService : public QMediaService -{ - Q_OBJECT -public: - MockMediaService(const QString& name, QObject *parent = 0) : QMediaService(parent) - { setObjectName(name); } - ~MockMediaService() {} - - QMediaControl* control(const char *) const {return 0;} -}; - -class MockServicePlugin1 : public QMediaServiceProviderPlugin, - public QMediaServiceSupportedFormatsInterface, - public QMediaServiceSupportedDevicesInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaServiceSupportedFormatsInterface) - Q_INTERFACES(QMediaServiceSupportedDevicesInterface) -public: - QStringList keys() const - { - return QStringList() << - QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER); - } - - QMediaService* create(QString const& key) - { - if (keys().contains(key)) - return new MockMediaService("MockServicePlugin1"); - else - return 0; - } - - void release(QMediaService *service) - { - delete service; - } - - QtMediaServices::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const - { - if (codecs.contains(QLatin1String("mpeg4"))) - return QtMediaServices::NotSupported; - - if (mimeType == "audio/ogg") { - return QtMediaServices::ProbablySupported; - } - - return QtMediaServices::MaybeSupported; - } - - QStringList supportedMimeTypes() const - { - return QStringList("audio/ogg"); - } - - QList<QByteArray> devices(const QByteArray &service) const - { - Q_UNUSED(service); - QList<QByteArray> res; - return res; - } - - QString deviceDescription(const QByteArray &service, const QByteArray &device) - { - if (devices(service).contains(device)) - return QString(device)+" description"; - else - return QString(); - } -}; - -class MockServicePlugin2 : public QMediaServiceProviderPlugin, - public QMediaServiceSupportedFormatsInterface, - public QMediaServiceFeaturesInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaServiceSupportedFormatsInterface) - Q_INTERFACES(QMediaServiceFeaturesInterface) -public: - QStringList keys() const - { - return QStringList() << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER); - } - - QMediaService* create(QString const& key) - { - if (keys().contains(key)) - return new MockMediaService("MockServicePlugin2"); - else - return 0; - } - - void release(QMediaService *service) - { - delete service; - } - - QtMediaServices::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const - { - Q_UNUSED(codecs); - - if (mimeType == "audio/wav") - return QtMediaServices::PreferredService; - - return QtMediaServices::NotSupported; - } - - QStringList supportedMimeTypes() const - { - return QStringList("audio/wav"); - } - - QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const - { - if (service == QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)) - return QMediaServiceProviderHint::LowLatencyPlayback; - else - return 0; - } -}; - - -class MockServicePlugin3 : public QMediaServiceProviderPlugin, - public QMediaServiceSupportedDevicesInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaServiceSupportedDevicesInterface) -public: - QStringList keys() const - { - return QStringList() << - QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER); - } - - QMediaService* create(QString const& key) - { - if (keys().contains(key)) - return new MockMediaService("MockServicePlugin3"); - else - return 0; - } - - void release(QMediaService *service) - { - delete service; - } - - QList<QByteArray> devices(const QByteArray &service) const - { - Q_UNUSED(service); - QList<QByteArray> res; - return res; - } - - QString deviceDescription(const QByteArray &service, const QByteArray &device) - { - if (devices(service).contains(device)) - return QString(device)+" description"; - else - return QString(); - } -}; - -class MockServicePlugin4 : public QMediaServiceProviderPlugin, - public QMediaServiceSupportedFormatsInterface, - public QMediaServiceFeaturesInterface -{ - Q_OBJECT - Q_INTERFACES(QMediaServiceSupportedFormatsInterface) - Q_INTERFACES(QMediaServiceFeaturesInterface) -public: - QStringList keys() const - { - return QStringList() << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER); - } - - QMediaService* create(QString const& key) - { - if (keys().contains(key)) - return new MockMediaService("MockServicePlugin4"); - else - return 0; - } - - void release(QMediaService *service) - { - delete service; - } - - QtMediaServices::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const - { - if (codecs.contains(QLatin1String("jpeg2000"))) - return QtMediaServices::NotSupported; - - if (supportedMimeTypes().contains(mimeType)) - return QtMediaServices::ProbablySupported; - - return QtMediaServices::MaybeSupported; - } - - QStringList supportedMimeTypes() const - { - return QStringList() << "video/mp4" << "video/quicktime"; - } - - QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const - { - if (service == QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)) - return QMediaServiceProviderHint::StreamPlayback; - else - return 0; - } -}; - - - -class MockMediaServiceProvider : public QMediaServiceProvider -{ - QMediaService* requestService(const QByteArray &type, const QMediaServiceProviderHint &) - { - Q_UNUSED(type); - return 0; - } - - void releaseService(QMediaService *service) - { - Q_UNUSED(service); - } -}; - - -class tst_QMediaServiceProvider : public QObject -{ - Q_OBJECT - -public slots: - void initTestCase(); - -private slots: - void testDefaultProviderAvailable(); - void testObtainService(); - void testHasSupport(); - void testSupportedMimeTypes(); - void testProviderHints(); - -private: - QObjectList plugins; -}; - -void tst_QMediaServiceProvider::initTestCase() -{ - plugins << new MockServicePlugin1; - plugins << new MockServicePlugin2; - plugins << new MockServicePlugin3; - plugins << new MockServicePlugin4; - - QMediaPluginLoader::setStaticPlugins(QLatin1String("/mediaservices"), plugins); -} - -void tst_QMediaServiceProvider::testDefaultProviderAvailable() -{ - // Must always be a default provider available - QVERIFY(QMediaServiceProvider::defaultServiceProvider() != 0); -} - -void tst_QMediaServiceProvider::testObtainService() -{ - QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); - - if (provider == 0) - QSKIP("No default provider", SkipSingle); - - QMediaService *service = 0; - - // Player - service = provider->requestService(Q_MEDIASERVICE_MEDIAPLAYER); - QVERIFY(service != 0); - provider->releaseService(service); -} - -void tst_QMediaServiceProvider::testHasSupport() -{ - MockMediaServiceProvider mockProvider; - QCOMPARE(mockProvider.hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/ogv", QStringList()), - QtMediaServices::MaybeSupported); - - QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); - - if (provider == 0) - QSKIP("No default provider", SkipSingle); - - QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/ogv", QStringList()), - QtMediaServices::MaybeSupported); - - QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "audio/ogg", QStringList()), - QtMediaServices::ProbablySupported); - - //while the service returns PreferredService, provider should return ProbablySupported - QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "audio/wav", QStringList()), - QtMediaServices::ProbablySupported); - - //even while all the plugins with "hasSupport" returned NotSupported, - //MockServicePlugin3 has no "hasSupport" interface, so MaybeSupported - QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/avi", - QStringList() << "mpeg4"), - QtMediaServices::MaybeSupported); - - QCOMPARE(provider->hasSupport(QByteArray("non existing service"), "video/ogv", QStringList()), - QtMediaServices::NotSupported); - - QCOMPARE(QMediaPlayer::hasSupport("video/ogv"), QtMediaServices::MaybeSupported); - QCOMPARE(QMediaPlayer::hasSupport("audio/ogg"), QtMediaServices::ProbablySupported); - QCOMPARE(QMediaPlayer::hasSupport("audio/wav"), QtMediaServices::ProbablySupported); - - //test low latency flag support - QCOMPARE(QMediaPlayer::hasSupport("audio/wav", QStringList(), QMediaPlayer::LowLatency), - QtMediaServices::ProbablySupported); - //plugin1 probably supports audio/ogg, it checked because it doesn't provide features iface - QCOMPARE(QMediaPlayer::hasSupport("audio/ogg", QStringList(), QMediaPlayer::LowLatency), - QtMediaServices::ProbablySupported); - //Plugin4 is not checked here, sine it's known not support low latency - QCOMPARE(QMediaPlayer::hasSupport("video/quicktime", QStringList(), QMediaPlayer::LowLatency), - QtMediaServices::MaybeSupported); - - //test streaming flag support - QCOMPARE(QMediaPlayer::hasSupport("video/quicktime", QStringList(), QMediaPlayer::StreamPlayback), - QtMediaServices::ProbablySupported); - //Plugin2 is not checked here, sine it's known not support streaming - QCOMPARE(QMediaPlayer::hasSupport("audio/wav", QStringList(), QMediaPlayer::StreamPlayback), - QtMediaServices::MaybeSupported); - - //ensure the correct media player plugin is choosen for mime type - QMediaPlayer simplePlayer(0, QMediaPlayer::LowLatency); - QCOMPARE(simplePlayer.service()->objectName(), QLatin1String("MockServicePlugin2")); - - QMediaPlayer mediaPlayer; - QVERIFY(mediaPlayer.service()->objectName() != QLatin1String("MockServicePlugin2")); - - QMediaPlayer streamPlayer(0, QMediaPlayer::StreamPlayback); - QCOMPARE(streamPlayer.service()->objectName(), QLatin1String("MockServicePlugin4")); -} - -void tst_QMediaServiceProvider::testSupportedMimeTypes() -{ - QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); - - if (provider == 0) - QSKIP("No default provider", SkipSingle); - - QVERIFY(provider->supportedMimeTypes(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)).contains("audio/ogg")); - QVERIFY(!provider->supportedMimeTypes(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)).contains("audio/mp3")); -} - -void tst_QMediaServiceProvider::testProviderHints() -{ - { - QMediaServiceProviderHint hint; - QVERIFY(hint.isNull()); - QCOMPARE(hint.type(), QMediaServiceProviderHint::Null); - QVERIFY(hint.device().isEmpty()); - QVERIFY(hint.mimeType().isEmpty()); - QVERIFY(hint.codecs().isEmpty()); - QCOMPARE(hint.features(), 0); - } - - { - QByteArray deviceName(QByteArray("testDevice")); - QMediaServiceProviderHint hint(deviceName); - QVERIFY(!hint.isNull()); - QCOMPARE(hint.type(), QMediaServiceProviderHint::Device); - QCOMPARE(hint.device(), deviceName); - QVERIFY(hint.mimeType().isEmpty()); - QVERIFY(hint.codecs().isEmpty()); - QCOMPARE(hint.features(), 0); - } - - { - QMediaServiceProviderHint hint(QMediaServiceProviderHint::LowLatencyPlayback); - QVERIFY(!hint.isNull()); - QCOMPARE(hint.type(), QMediaServiceProviderHint::SupportedFeatures); - QVERIFY(hint.device().isEmpty()); - QVERIFY(hint.mimeType().isEmpty()); - QVERIFY(hint.codecs().isEmpty()); - QCOMPARE(hint.features(), QMediaServiceProviderHint::LowLatencyPlayback); - } - - { - QString mimeType(QLatin1String("video/ogg")); - QStringList codecs; - codecs << "theora" << "vorbis"; - - QMediaServiceProviderHint hint(mimeType,codecs); - QVERIFY(!hint.isNull()); - QCOMPARE(hint.type(), QMediaServiceProviderHint::ContentType); - QVERIFY(hint.device().isEmpty()); - QCOMPARE(hint.mimeType(), mimeType); - QCOMPARE(hint.codecs(), codecs); - - QMediaServiceProviderHint hint2(hint); - - QVERIFY(!hint2.isNull()); - QCOMPARE(hint2.type(), QMediaServiceProviderHint::ContentType); - QVERIFY(hint2.device().isEmpty()); - QCOMPARE(hint2.mimeType(), mimeType); - QCOMPARE(hint2.codecs(), codecs); - - QMediaServiceProviderHint hint3; - QVERIFY(hint3.isNull()); - hint3 = hint; - QVERIFY(!hint3.isNull()); - QCOMPARE(hint3.type(), QMediaServiceProviderHint::ContentType); - QVERIFY(hint3.device().isEmpty()); - QCOMPARE(hint3.mimeType(), mimeType); - QCOMPARE(hint3.codecs(), codecs); - - QCOMPARE(hint, hint2); - QCOMPARE(hint3, hint2); - - QMediaServiceProviderHint hint4(mimeType,codecs); - QCOMPARE(hint, hint4); - - QMediaServiceProviderHint hint5(mimeType,QStringList()); - QVERIFY(hint != hint5); - } -} - -QTEST_MAIN(tst_QMediaServiceProvider) - -#include "tst_qmediaserviceprovider.moc" diff --git a/tests/auto/qmediatimerange/qmediatimerange.pro b/tests/auto/qmediatimerange/qmediatimerange.pro deleted file mode 100644 index c5e74ce..0000000 --- a/tests/auto/qmediatimerange/qmediatimerange.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qmediatimerange.cpp - -QT = core mediaservices - diff --git a/tests/auto/qmediatimerange/tst_qmediatimerange.cpp b/tests/auto/qmediatimerange/tst_qmediatimerange.cpp deleted file mode 100644 index a21abe2..0000000 --- a/tests/auto/qmediatimerange/tst_qmediatimerange.cpp +++ /dev/null @@ -1,735 +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 <QtTest/QtTest> -#include <QtCore/qdebug.h> - -#include <QtMediaServices/qmediatimerange.h> - -class tst_QMediaTimeRange: public QObject -{ - Q_OBJECT - -public slots: - -private slots: - void testCtor(); - void testGetters(); - void testAssignment(); - void testNormalize(); - void testTranslated(); - void testEarliestLatest(); - void testContains(); - void testAddInterval(); - void testAddTimeRange(); - void testRemoveInterval(); - void testRemoveTimeRange(); - void testClear(); - void testComparisons(); - void testArithmetic(); -}; - -void tst_QMediaTimeRange::testCtor() -{ - // Default Ctor - QMediaTimeRange a; - QVERIFY(a.isEmpty()); - - // (qint, qint) Ctor - QMediaTimeRange b(10, 20); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 20); - - // Interval Ctor - QMediaTimeRange c(QMediaTimeInterval(30, 40)); - - QVERIFY(!c.isEmpty()); - QVERIFY(c.isContinuous()); - QVERIFY(c.earliestTime() == 30); - QVERIFY(c.latestTime() == 40); - - // Abnormal Interval Ctor - QMediaTimeRange d(QMediaTimeInterval(20, 10)); - - QVERIFY(d.isEmpty()); - - // Copy Ctor - QMediaTimeRange e(b); - - QVERIFY(!e.isEmpty()); - QVERIFY(e.isContinuous()); - QVERIFY(e.earliestTime() == 10); - QVERIFY(e.latestTime() == 20); -} - -void tst_QMediaTimeRange::testGetters() -{ - QMediaTimeRange x; - - // isEmpty - QVERIFY(x.isEmpty()); - - x.addInterval(10, 20); - - // isEmpty + isContinuous - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - - x.addInterval(30, 40); - - // isEmpty + isContinuous + intervals + start + end - QVERIFY(!x.isEmpty()); - QVERIFY(!x.isContinuous()); - QVERIFY(x.intervals().count() == 2); - QVERIFY(x.intervals()[0].start() == 10); - QVERIFY(x.intervals()[0].end() == 20); - QVERIFY(x.intervals()[1].start() == 30); - QVERIFY(x.intervals()[1].end() == 40); -} - -void tst_QMediaTimeRange::testAssignment() -{ - QMediaTimeRange x; - - // Range Assignment - x = QMediaTimeRange(10, 20); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 10); - QVERIFY(x.latestTime() == 20); - - // Interval Assignment - x = QMediaTimeInterval(30, 40); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 30); - QVERIFY(x.latestTime() == 40); - - // Shared Data Check - QMediaTimeRange y; - - y = x; - y.addInterval(10, 20); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 30); - QVERIFY(x.latestTime() == 40); -} - -void tst_QMediaTimeRange::testNormalize() -{ - QMediaTimeInterval x(20, 10); - - QVERIFY(!x.isNormal()); - - x = x.normalized(); - - QVERIFY(x.isNormal()); - QVERIFY(x.start() == 10); - QVERIFY(x.end() == 20); -} - -void tst_QMediaTimeRange::testTranslated() -{ - QMediaTimeInterval x(10, 20); - x = x.translated(10); - - QVERIFY(x.start() == 20); - QVERIFY(x.end() == 30); -} - -void tst_QMediaTimeRange::testEarliestLatest() -{ - // Test over a single interval - QMediaTimeRange x(30, 40); - - QVERIFY(x.earliestTime() == 30); - QVERIFY(x.latestTime() == 40); - - // Test over multiple intervals - x.addInterval(50, 60); - - QVERIFY(x.earliestTime() == 30); - QVERIFY(x.latestTime() == 60); -} - -void tst_QMediaTimeRange::testContains() -{ - // Test over a single interval - QMediaTimeRange x(10, 20); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.contains(15)); - QVERIFY(x.contains(10)); - QVERIFY(x.contains(20)); - QVERIFY(!x.contains(25)); - - // Test over multiple intervals - x.addInterval(40, 50); - - QVERIFY(!x.isEmpty()); - QVERIFY(!x.isContinuous()); - QVERIFY(x.contains(15)); - QVERIFY(x.contains(45)); - QVERIFY(!x.contains(30)); - - // Test over a concrete interval - QMediaTimeInterval y(10, 20); - QVERIFY(y.contains(15)); - QVERIFY(y.contains(10)); - QVERIFY(y.contains(20)); - QVERIFY(!y.contains(25)); -} - -void tst_QMediaTimeRange::testAddInterval() -{ - // All intervals Overlap - QMediaTimeRange x; - x.addInterval(10, 40); - x.addInterval(30, 50); - x.addInterval(20, 60); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 10); - QVERIFY(x.latestTime() == 60); - - // 1 adjacent interval, 1 encompassed interval - x = QMediaTimeRange(); - x.addInterval(10, 40); - x.addInterval(20, 30); - x.addInterval(41, 50); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 10); - QVERIFY(x.latestTime() == 50); - - // 1 overlapping interval, 1 disjoint interval - x = QMediaTimeRange(); - x.addInterval(10, 30); - x.addInterval(20, 40); - x.addInterval(50, 60); - - QVERIFY(!x.isEmpty()); - QVERIFY(!x.isContinuous()); - QVERIFY(x.intervals().count() == 2); - QVERIFY(x.intervals()[0].start() == 10); - QVERIFY(x.intervals()[0].end() == 40); - QVERIFY(x.intervals()[1].start() == 50); - QVERIFY(x.intervals()[1].end() == 60); - - // Identical Add - x = QMediaTimeRange(); - x.addInterval(10, 20); - x.addInterval(10, 20); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 10); - QVERIFY(x.latestTime() == 20); - - // Multi-Merge - x = QMediaTimeRange(); - x.addInterval(10, 20); - x.addInterval(30, 40); - x.addInterval(50, 60); - x.addInterval(15, 55); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 10); - QVERIFY(x.latestTime() == 60); - - // Interval Parameter - All intervals Overlap - x = QMediaTimeRange(); - x.addInterval(QMediaTimeInterval(10, 40)); - x.addInterval(QMediaTimeInterval(30, 50)); - x.addInterval(QMediaTimeInterval(20, 60)); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 10); - QVERIFY(x.latestTime() == 60); - - // Interval Parameter - Abnormal Interval - x = QMediaTimeRange(); - x.addInterval(QMediaTimeInterval(20, 10)); - - QVERIFY(x.isEmpty()); -} - -void tst_QMediaTimeRange::testAddTimeRange() -{ - // Add Time Range uses Add Interval internally, - // so in this test the focus is on combinations of number - // of intervals added, rather than the different types of - // merges which can occur. - QMediaTimeRange a, b; - - // Add Single into Single - a = QMediaTimeRange(10, 30); - b = QMediaTimeRange(20, 40); - - b.addTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 40); - - // Add Multiple into Single - a = QMediaTimeRange(); - a.addInterval(10, 30); - a.addInterval(40, 60); - - b = QMediaTimeRange(20, 50); - - b.addTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 60); - - // Add Single into Multiple - a = QMediaTimeRange(20, 50); - - b = QMediaTimeRange(); - b.addInterval(10, 30); - b.addInterval(40, 60); - - b.addTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 60); - - // Add Multiple into Multiple - a = QMediaTimeRange(); - a.addInterval(10, 30); - a.addInterval(40, 70); - a.addInterval(80, 100); - - b = QMediaTimeRange(); - b.addInterval(20, 50); - b.addInterval(60, 90); - - b.addTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 100); - - // Add Nothing to Single - a = QMediaTimeRange(); - b = QMediaTimeRange(10, 20); - - b.addTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 20); - - // Add Single to Nothing - a = QMediaTimeRange(10, 20); - b = QMediaTimeRange(); - - b.addTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 20); - - // Add Nothing to Nothing - a = QMediaTimeRange(); - b = QMediaTimeRange(); - - b.addTimeRange(a); - - QVERIFY(b.isEmpty()); -} - -void tst_QMediaTimeRange::testRemoveInterval() -{ - // Removing an interval, causing a split - QMediaTimeRange x; - x.addInterval(10, 50); - x.removeInterval(20, 40); - - QVERIFY(!x.isEmpty()); - QVERIFY(!x.isContinuous()); - QVERIFY(x.intervals().count() == 2); - QVERIFY(x.intervals()[0].start() == 10); - QVERIFY(x.intervals()[0].end() == 19); - QVERIFY(x.intervals()[1].start() == 41); - QVERIFY(x.intervals()[1].end() == 50); - - // Removing an interval, causing a deletion - x = QMediaTimeRange(); - x.addInterval(20, 30); - x.removeInterval(10, 40); - - QVERIFY(x.isEmpty()); - - // Removing an interval, causing a tail trim - x = QMediaTimeRange(); - x.addInterval(20, 40); - x.removeInterval(30, 50); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 20); - QVERIFY(x.latestTime() == 29); - - // Removing an interval, causing a head trim - x = QMediaTimeRange(); - x.addInterval(20, 40); - x.removeInterval(10, 30); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 31); - QVERIFY(x.latestTime() == 40); - - // Identical Remove - x = QMediaTimeRange(); - x.addInterval(10, 20); - x.removeInterval(10, 20); - - QVERIFY(x.isEmpty()); - - // Multi-Trim - x = QMediaTimeRange(); - x.addInterval(10, 20); - x.addInterval(30, 40); - x.removeInterval(15, 35); - - QVERIFY(!x.isEmpty()); - QVERIFY(!x.isContinuous()); - QVERIFY(x.intervals().count() == 2); - QVERIFY(x.intervals()[0].start() == 10); - QVERIFY(x.intervals()[0].end() == 14); - QVERIFY(x.intervals()[1].start() == 36); - QVERIFY(x.intervals()[1].end() == 40); - - // Multi-Delete - x = QMediaTimeRange(); - x.addInterval(10, 20); - x.addInterval(30, 40); - x.addInterval(50, 60); - x.removeInterval(10, 60); - - QVERIFY(x.isEmpty()); - - // Interval Parameter - Removing an interval, causing a split - x = QMediaTimeRange(); - x.addInterval(10, 50); - x.removeInterval(QMediaTimeInterval(20, 40)); - - QVERIFY(!x.isEmpty()); - QVERIFY(!x.isContinuous()); - QVERIFY(x.intervals().count() == 2); - QVERIFY(x.intervals()[0].start() == 10); - QVERIFY(x.intervals()[0].end() == 19); - QVERIFY(x.intervals()[1].start() == 41); - QVERIFY(x.intervals()[1].end() == 50); - - // Interval Parameter - Abnormal Interval - x = QMediaTimeRange(); - x.addInterval(10, 40); - x.removeInterval(QMediaTimeInterval(30, 20)); - - QVERIFY(!x.isEmpty()); - QVERIFY(x.isContinuous()); - QVERIFY(x.earliestTime() == 10); - QVERIFY(x.latestTime() == 40); -} - -void tst_QMediaTimeRange::testRemoveTimeRange() -{ - // Remove Time Range uses Remove Interval internally, - // so in this test the focus is on combinations of number - // of intervals removed, rather than the different types of - // deletions which can occur. - QMediaTimeRange a, b; - - // Remove Single from Single - a = QMediaTimeRange(10, 30); - b = QMediaTimeRange(20, 40); - - b.removeTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 31); - QVERIFY(b.latestTime() == 40); - - // Remove Multiple from Single - a = QMediaTimeRange(); - a.addInterval(10, 30); - a.addInterval(40, 60); - - b = QMediaTimeRange(20, 50); - - b.removeTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 31); - QVERIFY(b.latestTime() == 39); - - // Remove Single from Multiple - a = QMediaTimeRange(20, 50); - - b = QMediaTimeRange(); - b.addInterval(10, 30); - b.addInterval(40, 60); - - b.removeTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(!b.isContinuous()); - QVERIFY(b.intervals().count() == 2); - QVERIFY(b.intervals()[0].start() == 10); - QVERIFY(b.intervals()[0].end() == 19); - QVERIFY(b.intervals()[1].start() == 51); - QVERIFY(b.intervals()[1].end() == 60); - - // Remove Multiple from Multiple - a = QMediaTimeRange(); - a.addInterval(20, 50); - a.addInterval(50, 90); - - - b = QMediaTimeRange(); - b.addInterval(10, 30); - b.addInterval(40, 70); - b.addInterval(80, 100); - - b.removeTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(!b.isContinuous()); - QVERIFY(b.intervals().count() == 2); - QVERIFY(b.intervals()[0].start() == 10); - QVERIFY(b.intervals()[0].end() == 19); - QVERIFY(b.intervals()[1].start() == 91); - QVERIFY(b.intervals()[1].end() == 100); - - // Remove Nothing from Single - a = QMediaTimeRange(); - b = QMediaTimeRange(10, 20); - - b.removeTimeRange(a); - - QVERIFY(!b.isEmpty()); - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 10); - QVERIFY(b.latestTime() == 20); - - // Remove Single from Nothing - a = QMediaTimeRange(10, 20); - b = QMediaTimeRange(); - - b.removeTimeRange(a); - - QVERIFY(b.isEmpty()); - - // Remove Nothing from Nothing - a = QMediaTimeRange(); - b = QMediaTimeRange(); - - b.removeTimeRange(a); - - QVERIFY(b.isEmpty()); -} - -void tst_QMediaTimeRange::testClear() -{ - QMediaTimeRange x; - - // Clear Nothing - x.clear(); - - QVERIFY(x.isEmpty()); - - // Clear Single - x = QMediaTimeRange(10, 20); - x.clear(); - - QVERIFY(x.isEmpty()); - - // Clear Multiple - x = QMediaTimeRange(); - x.addInterval(10, 20); - x.addInterval(30, 40); - x.clear(); - - QVERIFY(x.isEmpty()); -} - -void tst_QMediaTimeRange::testComparisons() -{ - // Interval equality - QVERIFY(QMediaTimeInterval(10, 20) == QMediaTimeInterval(10, 20)); - QVERIFY(QMediaTimeInterval(10, 20) != QMediaTimeInterval(10, 30)); - QVERIFY(!(QMediaTimeInterval(10, 20) != QMediaTimeInterval(10, 20))); - QVERIFY(!(QMediaTimeInterval(10, 20) == QMediaTimeInterval(10, 30))); - - // Time range equality - Single Interval - QMediaTimeRange a(10, 20), b(20, 30), c(10, 20); - - QVERIFY(a == c); - QVERIFY(!(a == b)); - QVERIFY(a != b); - QVERIFY(!(a != c)); - - // Time Range Equality - Multiple Intervals - QMediaTimeRange x, y, z; - - x.addInterval(10, 20); - x.addInterval(30, 40); - x.addInterval(50, 60); - - y.addInterval(10, 20); - y.addInterval(35, 45); - y.addInterval(50, 60); - - z.addInterval(10, 20); - z.addInterval(30, 40); - z.addInterval(50, 60); - - QVERIFY(x == z); - QVERIFY(!(x == y)); - QVERIFY(x != y); - QVERIFY(!(x != z)); -} - -void tst_QMediaTimeRange::testArithmetic() -{ - QMediaTimeRange a(10, 20), b(20, 30); - - // Test += - a += b; - - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 30); - - // Test -= - a -= b; - - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 19); - - // Test += and -= on intervals - a -= QMediaTimeInterval(10, 20); - a += QMediaTimeInterval(40, 50); - - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 40); - QVERIFY(a.latestTime() == 50); - - // Test Interval + Interval - a = QMediaTimeInterval(10, 20) + QMediaTimeInterval(20, 30); - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 30); - - // Test Range + Interval - a = a + QMediaTimeInterval(30, 40); - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 40); - - // Test Interval + Range - a = QMediaTimeInterval(40, 50) + a; - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 50); - - // Test Range + Range - a = a + QMediaTimeRange(50, 60); - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 60); - - // Test Range - Interval - a = a - QMediaTimeInterval(50, 60); - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 49); - - // Test Range - Range - a = a - QMediaTimeRange(40, 50); - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 39); - - // Test Interval - Range - b = QMediaTimeInterval(0, 20) - a; - QVERIFY(b.isContinuous()); - QVERIFY(b.earliestTime() == 0); - QVERIFY(b.latestTime() == 9); - - // Test Interval - Interval - a = QMediaTimeInterval(10, 20) - QMediaTimeInterval(15, 30); - QVERIFY(a.isContinuous()); - QVERIFY(a.earliestTime() == 10); - QVERIFY(a.latestTime() == 14); -} - -QTEST_MAIN(tst_QMediaTimeRange) - -#include "tst_qmediatimerange.moc" diff --git a/tests/auto/qmessagebox/tst_qmessagebox.cpp b/tests/auto/qmessagebox/tst_qmessagebox.cpp index 2de1c52..d4ca064 100644 --- a/tests/auto/qmessagebox/tst_qmessagebox.cpp +++ b/tests/auto/qmessagebox/tst_qmessagebox.cpp @@ -140,6 +140,8 @@ private: tst_QMessageBox::tst_QMessageBox() : keyToSend(-1) { + int argc = qApp->argc(); + QT_REQUIRE_VERSION(argc, qApp->argv(), "4.6.2") } int tst_QMessageBox::exec(QMessageBox *msgBox, int key) diff --git a/tests/auto/qnativesocketengine/qnativesocketengine.pro b/tests/auto/qnativesocketengine/qnativesocketengine.pro index ad40d53..0275d37 100644 --- a/tests/auto/qnativesocketengine/qnativesocketengine.pro +++ b/tests/auto/qnativesocketengine/qnativesocketengine.pro @@ -9,4 +9,5 @@ MOC_DIR=tmp QT = core network +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qnetworkaccessmanager/qnetworkaccessmanager.pro b/tests/auto/qnetworkaccessmanager/qnetworkaccessmanager.pro index e2889c1..3ccbffb 100644 --- a/tests/auto/qnetworkaccessmanager/qnetworkaccessmanager.pro +++ b/tests/auto/qnetworkaccessmanager/qnetworkaccessmanager.pro @@ -2,4 +2,5 @@ load(qttest_p4) SOURCES += tst_qnetworkaccessmanager.cpp QT = core network +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qnetworkaccessmanager_and_qprogressdialog/qnetworkaccessmanager_and_qprogressdialog.pro b/tests/auto/qnetworkaccessmanager_and_qprogressdialog/qnetworkaccessmanager_and_qprogressdialog.pro index 7ed5b07..378deba 100644 --- a/tests/auto/qnetworkaccessmanager_and_qprogressdialog/qnetworkaccessmanager_and_qprogressdialog.pro +++ b/tests/auto/qnetworkaccessmanager_and_qprogressdialog/qnetworkaccessmanager_and_qprogressdialog.pro @@ -2,4 +2,5 @@ load(qttest_p4) SOURCES += tst_qnetworkaccessmanager_and_qprogressdialog.cpp QT += network +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qnetworkaddressentry/qnetworkaddressentry.pro b/tests/auto/qnetworkaddressentry/qnetworkaddressentry.pro index 8feb95f..885dbf7 100644 --- a/tests/auto/qnetworkaddressentry/qnetworkaddressentry.pro +++ b/tests/auto/qnetworkaddressentry/qnetworkaddressentry.pro @@ -2,3 +2,5 @@ load(qttest_p4) SOURCES += tst_qnetworkaddressentry.cpp QT = core network + +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qnetworkcachemetadata/qnetworkcachemetadata.pro b/tests/auto/qnetworkcachemetadata/qnetworkcachemetadata.pro index b24fe00..77ad347 100644 --- a/tests/auto/qnetworkcachemetadata/qnetworkcachemetadata.pro +++ b/tests/auto/qnetworkcachemetadata/qnetworkcachemetadata.pro @@ -2,4 +2,5 @@ load(qttest_p4) QT += network SOURCES += tst_qnetworkcachemetadata.cpp +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp b/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp index ce3acb7..e66719a 100644 --- a/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp +++ b/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp @@ -45,7 +45,14 @@ #include <QtNetwork/qnetworkconfiguration.h> #include <QtNetwork/qnetworkconfigmanager.h> -#if defined(Q_WS_MAEMO_6) || defined(Q_WS_MAEMO_5) +/* + Although this unit test doesn't use QNetworkAccessManager + this include is used to ensure that bearer continues to compile against + Qt 4.7+ which has a QNetworkConfiguration enabled QNetworkAccessManager +*/ +#include <QNetworkAccessManager> + +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) #include <stdio.h> #include <iapconf.h> #endif @@ -66,7 +73,7 @@ private slots: void isRoamingAvailable(); private: -#if defined(Q_WS_MAEMO_6) || defined(Q_WS_MAEMO_5) +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) Maemo::IAPConf *iapconf; Maemo::IAPConf *iapconf2; Maemo::IAPConf *gprsiap; @@ -78,7 +85,7 @@ private: void tst_QNetworkConfiguration::initTestCase() { -#if defined(Q_WS_MAEMO_6) || defined(Q_WS_MAEMO_5) +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) iapconf = new Maemo::IAPConf("007"); iapconf->setValue("ipv4_type", "AUTO"); iapconf->setValue("wlan_wepkey1", "connt"); @@ -151,7 +158,7 @@ void tst_QNetworkConfiguration::initTestCase() void tst_QNetworkConfiguration::cleanupTestCase() { -#if defined(Q_WS_MAEMO_6) || defined(Q_WS_MAEMO_5) +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) iapconf->clear(); delete iapconf; iapconf2->clear(); diff --git a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp index 7cc527c..c732a5b 100644 --- a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp +++ b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp @@ -45,7 +45,7 @@ #include <QtNetwork/qnetworkconfiguration.h> #include <QtNetwork/qnetworkconfigmanager.h> -#if defined(Q_WS_MAEMO_6) || defined(Q_WS_MAEMO_5) +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) #include <stdio.h> #include <iapconf.h> #endif @@ -67,7 +67,7 @@ private slots: void configurationFromIdentifier(); private: -#if defined(Q_WS_MAEMO_6) || defined(Q_WS_MAEMO_5) +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) Maemo::IAPConf *iapconf; Maemo::IAPConf *iapconf2; Maemo::IAPConf *gprsiap; @@ -79,7 +79,7 @@ private: void tst_QNetworkConfigurationManager::initTestCase() { -#if defined(Q_WS_MAEMO_6) || defined(Q_WS_MAEMO_5) +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) iapconf = new Maemo::IAPConf("007"); iapconf->setValue("ipv4_type", "AUTO"); iapconf->setValue("wlan_wepkey1", "connt"); @@ -153,7 +153,7 @@ void tst_QNetworkConfigurationManager::initTestCase() void tst_QNetworkConfigurationManager::cleanupTestCase() { -#if defined(Q_WS_MAEMO_6) || defined(Q_WS_MAEMO_5) +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) iapconf->clear(); delete iapconf; iapconf2->clear(); diff --git a/tests/auto/qnetworkcookie/qnetworkcookie.pro b/tests/auto/qnetworkcookie/qnetworkcookie.pro index 95d8b6e..2f31138 100644 --- a/tests/auto/qnetworkcookie/qnetworkcookie.pro +++ b/tests/auto/qnetworkcookie/qnetworkcookie.pro @@ -2,3 +2,4 @@ load(qttest_p4) SOURCES += tst_qnetworkcookie.cpp QT = core network +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qnetworkcookiejar/qnetworkcookiejar.pro b/tests/auto/qnetworkcookiejar/qnetworkcookiejar.pro index 3a8e61b..6d75fab 100644 --- a/tests/auto/qnetworkcookiejar/qnetworkcookiejar.pro +++ b/tests/auto/qnetworkcookiejar/qnetworkcookiejar.pro @@ -2,3 +2,4 @@ load(qttest_p4) SOURCES += tst_qnetworkcookiejar.cpp QT = core network +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qnetworkdiskcache/qnetworkdiskcache.pro b/tests/auto/qnetworkdiskcache/qnetworkdiskcache.pro index f47d6d7..3b13087 100644 --- a/tests/auto/qnetworkdiskcache/qnetworkdiskcache.pro +++ b/tests/auto/qnetworkdiskcache/qnetworkdiskcache.pro @@ -2,4 +2,5 @@ load(qttest_p4) QT += network SOURCES += tst_qnetworkdiskcache.cpp +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qnetworkinterface/qnetworkinterface.pro b/tests/auto/qnetworkinterface/qnetworkinterface.pro index 26095e9..1c5feee 100644 --- a/tests/auto/qnetworkinterface/qnetworkinterface.pro +++ b/tests/auto/qnetworkinterface/qnetworkinterface.pro @@ -3,4 +3,5 @@ SOURCES += tst_qnetworkinterface.cpp QT = core network +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qnetworkproxy/qnetworkproxy.pro b/tests/auto/qnetworkproxy/qnetworkproxy.pro index 8ffc80c..fc0a216 100644 --- a/tests/auto/qnetworkproxy/qnetworkproxy.pro +++ b/tests/auto/qnetworkproxy/qnetworkproxy.pro @@ -7,4 +7,5 @@ QT = core network SOURCES += tst_qnetworkproxy.cpp +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qnetworkreply/qnetworkreply.pro b/tests/auto/qnetworkreply/qnetworkreply.pro index fd8454c..86d3155 100644 --- a/tests/auto/qnetworkreply/qnetworkreply.pro +++ b/tests/auto/qnetworkreply/qnetworkreply.pro @@ -4,3 +4,4 @@ SUBDIRS = test requires(contains(QT_CONFIG,private_tests)) !wince*:SUBDIRS += echo +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qnetworkreply/smb-file.txt b/tests/auto/qnetworkreply/smb-file.txt new file mode 100644 index 0000000..73c3ac2 --- /dev/null +++ b/tests/auto/qnetworkreply/smb-file.txt @@ -0,0 +1 @@ +This is 34 bytes. Do not change...
\ No newline at end of file diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index ff79c09..01d7783 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -284,6 +284,11 @@ private Q_SLOTS: void ignoreSslErrorsListWithSlot(); #endif + void getAndThenDeleteObject_data(); + void getAndThenDeleteObject(); + + void symbianOpenCDataUrlCrash(); + // NOTE: This test must be last! void parentingRepliesToTheApp(); }; @@ -522,8 +527,8 @@ public: active->connectToHost("127.0.0.1", server.serverPort()); #ifndef Q_OS_SYMBIAN // need more time as working with embedded - // device and testing from emualtor - // things tend to get slower + // device and testing from emualtor + // things tend to get slower if (!active->waitForConnected(1000)) return false; @@ -929,7 +934,7 @@ void tst_QNetworkReply::invalidProtocol() void tst_QNetworkReply::getFromData_data() { - QTest::addColumn<QString>("request"); + QTest::addColumn<QString>("request"); QTest::addColumn<QByteArray>("expected"); QTest::addColumn<QString>("mimeType"); @@ -1025,7 +1030,7 @@ void tst_QNetworkReply::getFromData() void tst_QNetworkReply::getFromFile() { - // create the file: + // create the file: QTemporaryFile file(QDir::currentPath() + "/temp-XXXXXX"); file.setAutoRemove(true); QVERIFY(file.open()); @@ -1073,11 +1078,14 @@ void tst_QNetworkReply::getFromFileSpecial_data() QTest::newRow("resource") << ":/resource" << "qrc:/resource"; QTest::newRow("search-path") << "srcdir:/rfc3252.txt" << "srcdir:/rfc3252.txt"; QTest::newRow("bigfile-path") << "srcdir:/bigfile" << "srcdir:/bigfile"; +#ifdef Q_OS_WIN + QTest::newRow("smb-path") << "srcdir:/smb-file.txt" << "file://" + QtNetworkSettings::winServerName() + "/testshare/test.pri"; +#endif } void tst_QNetworkReply::getFromFileSpecial() { - QFETCH(QString, fileName); + QFETCH(QString, fileName); QFETCH(QString, url); // open the resource so we can find out its size @@ -1107,7 +1115,7 @@ void tst_QNetworkReply::getFromFtp_data() void tst_QNetworkReply::getFromFtp() { - QFETCH(QString, referenceName); + QFETCH(QString, referenceName); QFETCH(QString, url); QFile reference(referenceName); @@ -1136,7 +1144,7 @@ void tst_QNetworkReply::getFromHttp_data() void tst_QNetworkReply::getFromHttp() { - QFETCH(QString, referenceName); + QFETCH(QString, referenceName); QFETCH(QString, url); QFile reference(referenceName); @@ -3456,8 +3464,8 @@ void tst_QNetworkReply::downloadProgress_data() QTest::newRow("big") << 4096; #else // it can run even with 4096 - // but it takes lot time - //especially on emulator + // but it takes lot time + //especially on emulator QTest::newRow("big") << 1024; #endif } @@ -3646,7 +3654,7 @@ void tst_QNetworkReply::receiveCookiesFromHttp_data() void tst_QNetworkReply::receiveCookiesFromHttp() { - QFETCH(QString, cookieString); + QFETCH(QString, cookieString); QByteArray data = cookieString.toLatin1() + '\n'; QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/set-cookie.cgi"); @@ -4208,6 +4216,66 @@ void tst_QNetworkReply::ignoreSslErrorsListWithSlot() #endif // QT_NO_OPENSSL +void tst_QNetworkReply::getAndThenDeleteObject_data() +{ + QTest::addColumn<bool>("replyFirst"); + + QTest::newRow("delete-reply-first") << true; + QTest::newRow("delete-qnam-first") << false; +} + +void tst_QNetworkReply::getAndThenDeleteObject() +{ + // yes, this will leak if the testcase fails. I don't care. It must not fail then :P + QNetworkAccessManager *manager = new QNetworkAccessManager(); + QNetworkRequest request("http://" + QtNetworkSettings::serverName() + "/qtest/bigfile"); + QNetworkReply *reply = manager->get(request); + reply->setReadBufferSize(1); + reply->setParent((QObject*)0); // must be 0 because else it is the manager + + QTime stopWatch; + stopWatch.start(); + forever { + QCoreApplication::instance()->processEvents(); + if (reply->bytesAvailable()) + break; + if (stopWatch.elapsed() >= 30000) + break; + } + + QVERIFY(reply->bytesAvailable()); + QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); + QVERIFY(!reply->isFinished()); // must not be finished + + QFETCH(bool, replyFirst); + + if (replyFirst) { + delete reply; + delete manager; + } else { + delete manager; + delete reply; + } +} + +// see https://bugs.webkit.org/show_bug.cgi?id=38935 +void tst_QNetworkReply::symbianOpenCDataUrlCrash() +{ + QString requestUrl("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAWCAYAAAA1vze2AAAAB3RJTUUH2AUSEgolrgBvVQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAARnQU1BAACxjwv8YQUAAAHlSURBVHja5VbNShxBEK6ZaXtnHTebQPA1gngNmfaeq+QNPIlIXkC9iQdJxJNvEHLN3VkxhxxE8gTmEhAVddXZ6Z3f9Ndriz89/sHmkBQUVVT1fB9d9c3uOERUKTunIdn3HzstxGpYBDS4wZk7TAJj/wlJ90J+jnuygqs8svSj+/rGHBos3rE18XBvfU3no7NzlJfUaY/5whAwl8Lr/WDUv4ODxTMb+P5xLExe5LmO559WqTX/MQR4WZYEAtSePS4pE0qSnuhnRUcBU5Gm2k9XljU4Z26I3NRxBrd80rj2fh+KNE0FY4xevRgTjREvPFpasAK8Xli6MUbbuKw3afAGgSBXozo5u4hkmncAlkl5wx8iMGbdyQjnCFEiEwGiosj1UQA/x2rVddiVoi+l4IxE0PTDnx+mrQBvvnx9cFz3krhVvuhzFn579/aq/n5rW8fbtTqiWhIQZEo17YBvbkxOXNVndnYpTvod7AtiuN2re0+siwcB9oH8VxxrNwQQAhzyRs30n7wTI2HIN2g2QtQwjjhJIQatOq7E8bIVCLwzpl83Lvtvl+NohWWlE8UZTWEMAGCcR77fHKhPnZF5tYie6dfdxCphACmLPM+j8bYfmTryg64kV9Vh3mV8jP0b/4wO/YUPiT/8i0MLf55lSQAAAABJRU5ErkJggg=="); + QUrl url = QUrl::fromEncoded(requestUrl.toLatin1()); + QNetworkRequest req(url); + QNetworkReplyPtr reply; + + RUN_REQUEST(runSimpleRequest(QNetworkAccessManager::GetOperation, req, reply)); + + QCOMPARE(reply->url(), url); + QCOMPARE(reply->error(), QNetworkReply::NoError); + + QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), qint64(598)); +} + + + // NOTE: This test must be last testcase in tst_qnetworkreply! void tst_QNetworkReply::parentingRepliesToTheApp() { diff --git a/tests/auto/qnetworkrequest/qnetworkrequest.pro b/tests/auto/qnetworkrequest/qnetworkrequest.pro index f576ba2..f96fd3b 100644 --- a/tests/auto/qnetworkrequest/qnetworkrequest.pro +++ b/tests/auto/qnetworkrequest/qnetworkrequest.pro @@ -2,3 +2,4 @@ load(qttest_p4) SOURCES += tst_qnetworkrequest.cpp QT = core network +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qnetworksession/lackey/main.cpp b/tests/auto/qnetworksession/lackey/main.cpp index 8759b52..ec2fad9 100644 --- a/tests/auto/qnetworksession/lackey/main.cpp +++ b/tests/auto/qnetworksession/lackey/main.cpp @@ -47,6 +47,8 @@ #include <QtNetwork/qnetworkconfigmanager.h> #include <QtNetwork/qnetworksession.h> +#include <QEventLoop> +#include <QTimer> #include <QDebug> QT_USE_NAMESPACE @@ -60,15 +62,14 @@ int main(int argc, char** argv) { QCoreApplication app(argc, argv); - // Cannot read/write to processes on WinCE or Symbian. - // Easiest alternative is to use sockets for IPC. - - QLocalSocket oopSocket; - - oopSocket.connectToServer("tst_qnetworksession"); - oopSocket.waitForConnected(-1); - + // Update configurations so that everything is up to date for this process too. + // Event loop is used to wait for awhile. QNetworkConfigurationManager manager; + manager.updateConfigurations(); + QEventLoop iIgnoreEventLoop; + QTimer::singleShot(3000, &iIgnoreEventLoop, SLOT(quit())); + iIgnoreEventLoop.exec(); + QList<QNetworkConfiguration> discovered = manager.allConfigurations(QNetworkConfiguration::Discovered); @@ -82,6 +83,13 @@ int main(int argc, char** argv) return NO_DISCOVERED_CONFIGURATIONS_ERROR; } + // Cannot read/write to processes on WinCE or Symbian. + // Easiest alternative is to use sockets for IPC. + QLocalSocket oopSocket; + + oopSocket.connectToServer("tst_qnetworksession"); + oopSocket.waitForConnected(-1); + qDebug() << "Lackey started"; QNetworkSession *session = 0; diff --git a/tests/auto/qnetworksession/qnetworksession.pro b/tests/auto/qnetworksession/qnetworksession.pro index a85925b..34761e5 100644 --- a/tests/auto/qnetworksession/qnetworksession.pro +++ b/tests/auto/qnetworksession/qnetworksession.pro @@ -1,2 +1,3 @@ TEMPLATE = subdirs SUBDIRS = lackey test +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp index 23cdc6a..e4f2486 100644 --- a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp +++ b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp @@ -48,7 +48,7 @@ #include <QtNetwork/qnetworkconfigmanager.h> #include <QtNetwork/qnetworksession.h> -#if defined(Q_WS_MAEMO_6) || defined(Q_WS_MAEMO_5) +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) #include <stdio.h> #include <iapconf.h> #endif @@ -100,10 +100,11 @@ private slots: private: QNetworkConfigurationManager manager; + QMap<QString, bool> testsToRun; int inProcessSessionManagementCount; -#if defined(Q_WS_MAEMO_6) || defined(Q_WS_MAEMO_5) +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) Maemo::IAPConf *iapconf; Maemo::IAPConf *iapconf2; Maemo::IAPConf *gprsiap; @@ -117,6 +118,7 @@ private: bool openSession(QNetworkSession *session); bool closeSession(QNetworkSession *session, bool lastSessionOnConfiguration = true); void updateConfigurations(); +void printConfigurations(); QNetworkConfiguration suitableConfiguration(QString bearerType, QNetworkConfiguration::Type configType); void tst_QNetworkSession::initTestCase() @@ -125,8 +127,20 @@ void tst_QNetworkSession::initTestCase() qRegisterMetaType<QNetworkSession::SessionError>("QNetworkSession::SessionError"); qRegisterMetaType<QNetworkConfiguration>("QNetworkConfiguration"); qRegisterMetaType<QNetworkConfiguration::Type>("QNetworkConfiguration::Type"); - -#if defined(Q_WS_MAEMO_6) || defined(Q_WS_MAEMO_5) + + // If you wish to skip tests, set value as false. This is often very convinient because tests are so lengthy. + // Better way still would be to make this readable from a file. + testsToRun["robustnessBombing"] = true; + testsToRun["outOfProcessSession"] = true; + testsToRun["invalidSession"] = true; + testsToRun["repeatedOpenClose"] = true; + testsToRun["roamingErrorCodes"] = true; + testsToRun["sessionStop"] = true; + testsToRun["sessionProperties"] = true; + testsToRun["userChoiceSession"] = true; + testsToRun["sessionOpenCloseStop"] = true; + +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) iapconf = new Maemo::IAPConf("007"); iapconf->setValue("ipv4_type", "AUTO"); iapconf->setValue("wlan_wepkey1", "connt"); @@ -212,7 +226,7 @@ void tst_QNetworkSession::cleanupTestCase() "inProcessSessionManagement()"); } -#if defined(Q_WS_MAEMO_6) || defined(Q_WS_MAEMO_5) +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) iapconf->clear(); delete iapconf; iapconf2->clear(); @@ -238,6 +252,10 @@ void tst_QNetworkSession::cleanupTestCase() // Robustness test for calling interfaces in nonsense order / with nonsense parameters void tst_QNetworkSession::robustnessBombing() { + if (!testsToRun["robustnessBombing"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } + QNetworkConfigurationManager mgr; QNetworkSession testSession(mgr.defaultConfiguration()); // Should not reset even session is not opened @@ -245,15 +263,14 @@ void tst_QNetworkSession::robustnessBombing() testSession.accept(); testSession.ignore(); testSession.reject(); - quint64 temp; - temp = testSession.bytesWritten(); - temp = testSession.bytesReceived(); - temp = testSession.activeTime(); } void tst_QNetworkSession::invalidSession() -{ +{ + if (!testsToRun["invalidSession"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } // 1. Verify that session created with invalid configuration remains in invalid state QNetworkSession session(QNetworkConfiguration(), 0); QVERIFY(!session.isOpen()); @@ -270,11 +287,24 @@ void tst_QNetworkSession::invalidSession() QVERIFY(error == QNetworkSession::InvalidConfigurationError); QVERIFY(session.error() == QNetworkSession::InvalidConfigurationError); QVERIFY(session.state() == QNetworkSession::Invalid); - + #ifdef QNETWORKSESSION_MANUAL_TESTS + + QNetworkConfiguration invalidatedConfig = suitableConfiguration("WLAN",QNetworkConfiguration::InternetAccessPoint); + if (invalidatedConfig.isValid()) { + // 3. Verify that invalidating a session after its successfully configured works + QNetworkSession invalidatedSession(invalidatedConfig); + qDebug() << "Delete the WLAN IAP from phone now (waiting 60 seconds): " << invalidatedConfig.name(); + QTest::qWait(60000); + QVERIFY(!invalidatedConfig.isValid()); + QVERIFY(invalidatedSession.state() == QNetworkSession::Invalid); + qDebug() << "Add the WLAN IAP back (waiting 60 seconds): " << invalidatedConfig.name(); + QTest::qWait(60000); + } + QNetworkConfiguration definedConfig = suitableConfiguration("WLAN",QNetworkConfiguration::InternetAccessPoint); if (definedConfig.isValid()) { - // 3. Verify that opening a session with defined configuration emits error and enters notavailable-state + // 4. Verify that opening a session with defined configuration emits error and enters notavailable-state // TODO these timer waits should be changed to waiting appropriate signals, now these wait excessively qDebug() << "Shutdown WLAN IAP (waiting 60 seconds): " << definedConfig.name(); QTest::qWait(60000); @@ -283,43 +313,27 @@ void tst_QNetworkSession::invalidSession() QNetworkSession definedSession(definedConfig); QSignalSpy errorSpy(&definedSession, SIGNAL(error(QNetworkSession::SessionError))); QNetworkSession::SessionError sessionError; + updateConfigurations(); definedSession.open(); +#ifdef Q_OS_SYMBIAN + // On symbian, the connection opening is tried even with defined state. + qDebug("Waiting for 10 seconds to all signals to propagate."); + QTest::qWait(10000); +#endif + updateConfigurations(); QVERIFY(definedConfig.isValid()); // Session remains valid QVERIFY(definedSession.state() == QNetworkSession::NotAvailable); // State is not available because WLAN is not in coverage QVERIFY(!errorSpy.isEmpty()); // Session tells with error about invalidated configuration sessionError = qvariant_cast<QNetworkSession::SessionError> (errorSpy.first().at(0)); - qDebug() << "Error code is: " << sessionError; QVERIFY(sessionError == QNetworkSession::InvalidConfigurationError); - qDebug() << "Turn the WLAN IAP back on (waiting 60 seconds): " << definedConfig.name(); QTest::qWait(60000); - updateConfigurations(); - + updateConfigurations(); QVERIFY(definedConfig.state() == QNetworkConfiguration::Discovered); } - - QNetworkConfiguration invalidatedConfig = suitableConfiguration("WLAN",QNetworkConfiguration::InternetAccessPoint); - if (invalidatedConfig.isValid()) { - // 4. Verify that invalidating a session after its successfully configured works - QNetworkSession invalidatedSession(invalidatedConfig); - QSignalSpy errorSpy(&invalidatedSession, SIGNAL(error(QNetworkSession::SessionError))); - QNetworkSession::SessionError sessionError; - - qDebug() << "Delete the WLAN IAP from phone now (waiting 60 seconds): " << invalidatedConfig.name(); - QTest::qWait(60000); - - invalidatedSession.open(); - QVERIFY(!invalidatedConfig.isValid()); - QVERIFY(invalidatedSession.state() == QNetworkSession::Invalid); - QVERIFY(!errorSpy.isEmpty()); - - sessionError = qvariant_cast<QNetworkSession::SessionError> (errorSpy.first().at(0)); - QVERIFY(sessionError == QNetworkSession::InvalidConfigurationError); - qDebug() << "Add the WLAN IAP back (waiting 60 seconds): " << invalidatedConfig.name(); - QTest::qWait(60000); - } + #endif } @@ -337,12 +351,12 @@ void tst_QNetworkSession::sessionProperties_data() void tst_QNetworkSession::sessionProperties() { + if (!testsToRun["sessionProperties"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } QFETCH(QNetworkConfiguration, configuration); - QNetworkSession session(configuration); - QVERIFY(session.configuration() == configuration); - QStringList validBearerNames = QStringList() << QLatin1String("Unknown") << QLatin1String("Ethernet") << QLatin1String("WLAN") @@ -356,9 +370,6 @@ void tst_QNetworkSession::sessionProperties() if (!configuration.isValid()) { QVERIFY(configuration.bearerName().isEmpty()); } else { - qDebug() << "Type:" << configuration.type() - << "Bearer:" << configuration.bearerName(); - switch (configuration.type()) { case QNetworkConfiguration::ServiceNetwork: @@ -374,9 +385,7 @@ void tst_QNetworkSession::sessionProperties() // QNetworkSession::interface() should return an invalid interface unless // session is in the connected state. - qDebug() << "Session state:" << session.state(); #ifndef QT_NO_NETWORKINTERFACE - qDebug() << "Session iface:" << session.interface().isValid() << session.interface().name(); #if !(defined(Q_OS_SYMBIAN) && defined(__WINS__)) // On Symbian emulator, the support for data bearers is limited QCOMPARE(session.state() == QNetworkSession::Connected, session.interface().isValid()); @@ -420,7 +429,12 @@ void tst_QNetworkSession::repeatedOpenClose_data() { } // Tests repeated-open close. -void tst_QNetworkSession::repeatedOpenClose() { +void tst_QNetworkSession::repeatedOpenClose() +{ + if (!testsToRun["repeatedOpenClose"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } + QFETCH(QString, bearerType); QFETCH(QNetworkConfiguration::Type, configurationType); QFETCH(int, repeatTimes); @@ -436,13 +450,20 @@ void tst_QNetworkSession::repeatedOpenClose() { !closeSession(&permanentSession)) { QSKIP("Unable to open/close session, skipping this round of repeated open-close test.", SkipSingle); } - for (int i = repeatTimes; i > 0; i--) { + for (int i = 0; i < repeatTimes; i++) { + qDebug() << "Opening, loop number " << i; QVERIFY(openSession(&permanentSession)); + qDebug() << "Closing, loop number, then waiting 5 seconds: " << i; QVERIFY(closeSession(&permanentSession)); + QTest::qWait(5000); } } -void tst_QNetworkSession::roamingErrorCodes() { +void tst_QNetworkSession::roamingErrorCodes() +{ + if (!testsToRun["roamingErrorCodes"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } #ifndef Q_OS_SYMBIAN QSKIP("Roaming supported on Symbian.", SkipAll); #else @@ -466,41 +487,11 @@ void tst_QNetworkSession::roamingErrorCodes() { adminIapSession.stop(); // requires NetworkControl capabilities QTRY_VERIFY(!errorSpy.isEmpty()); // wait for error signals QNetworkSession::SessionError error = qvariant_cast<QNetworkSession::SessionError>(errorSpy.first().at(0)); + QTest::qWait(2000); // Wait for a moment to all platform signals to propagate QVERIFY(error == QNetworkSession::SessionAbortedError); QVERIFY(iapSession.state() == QNetworkSession::Disconnected); QVERIFY(adminIapSession.state() == QNetworkSession::Disconnected); #endif // Q_OS_SYMBIAN - -#ifdef QNETWORKSESSION_MANUAL_TESTS - // Check for roaming error. - // Case requires that you have controllable WLAN in Internet SNAP (only). - QNetworkConfiguration snapConfig = suitableConfiguration("bearer_not_relevant_with_snaps", QNetworkConfiguration::ServiceNetwork); - if (!snapConfig.isValid()) { - QSKIP("No SNAP accessible, skipping test.", SkipAll); - } - QNetworkSession snapSession(snapConfig); - QVERIFY(openSession(&snapSession)); - QSignalSpy errorSpySnap(&snapSession, SIGNAL(error(QNetworkSession::SessionError))); - qDebug("Disconnect the WLAN now"); - QTRY_VERIFY(!errorSpySnap.isEmpty()); // wait for error signals - QVERIFY(errorSpySnap.count() == 1); - error = qvariant_cast<QNetworkSession::SessionError>(errorSpySnap.first().at(0)); - qDebug() << "Error received when turning off wlan on SNAP: " << error; - QVERIFY(error == QNetworkSession::RoamingError); - - qDebug("Connect the WLAN now"); - QTest::qWait(60000); // Wait for WLAN to get up - QNetworkConfiguration wlanIapConfig2 = suitableConfiguration("WLAN", QNetworkConfiguration::InternetAccessPoint); - QNetworkSession iapSession2(wlanIapConfig2); - QVERIFY(openSession(&iapSession2)); - QSignalSpy errorSpy2(&iapSession2, SIGNAL(error(QNetworkSession::SessionError))); - qDebug("Disconnect the WLAN now"); - QTRY_VERIFY(!errorSpy2.isEmpty()); // wait for error signals - QVERIFY(errorSpy2.count() == 1); - error = qvariant_cast<QNetworkSession::SessionError>(errorSpy2.first().at(0)); - QVERIFY(error == QNetworkSession::SessionAbortedError); - QVERIFY(iapSession2.state() == QNetworkSession::Disconnected); -#endif } @@ -515,6 +506,9 @@ void tst_QNetworkSession::sessionStop_data() { void tst_QNetworkSession::sessionStop() { + if (!testsToRun["sessionStop"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } #ifndef Q_OS_SYMBIAN QSKIP("Testcase contains mainly Symbian specific checks, because it is only platform to really support interface (IAP-level) Stop.", SkipAll); #endif @@ -522,6 +516,9 @@ void tst_QNetworkSession::sessionStop() QFETCH(QNetworkConfiguration::Type, configurationType); int configWaitdelayInMs = 2000; + + updateConfigurations(); + printConfigurations(); QNetworkConfiguration config = suitableConfiguration(bearerType, configurationType); if (!config.isValid()) { @@ -539,6 +536,9 @@ void tst_QNetworkSession::sessionStop() QSignalSpy closedSessionStateChangedSpy(&closedSession, SIGNAL(stateChanged(QNetworkSession::State))); QSignalSpy closedErrorSpy(&closedSession, SIGNAL(error(QNetworkSession::SessionError))); + QSignalSpy openedSessionClosedSpy(&openedSession, SIGNAL(closed())); + QSignalSpy openedSessionStateChangedSpy(&openedSession, SIGNAL(stateChanged(QNetworkSession::State))); + QSignalSpy innocentSessionClosedSpy(&innocentSession, SIGNAL(closed())); QSignalSpy innocentSessionStateChangedSpy(&innocentSession, SIGNAL(stateChanged(QNetworkSession::State))); QSignalSpy innocentErrorSpy(&innocentSession, SIGNAL(error(QNetworkSession::SessionError))); @@ -554,10 +554,18 @@ void tst_QNetworkSession::sessionStop() closedSessionClosedSpy.clear(); closedSessionStateChangedSpy.clear(); closedErrorSpy.clear(); + openedSessionStateChangedSpy.clear(); + openedSessionClosedSpy.clear(); + openedSession.stop(); - QVERIFY(openedSession.state() == QNetworkSession::Disconnected); + qDebug("Waiting for %d ms to get all configurationChange signals from platform.", configWaitdelayInMs); QTest::qWait(configWaitdelayInMs); // Wait to get all relevant configurationChange() signals + + // First to closing, then to disconnected + QVERIFY(openedSessionStateChangedSpy.count() == 2); + QVERIFY(!openedSessionClosedSpy.isEmpty()); + QVERIFY(openedSession.state() == QNetworkSession::Disconnected); QVERIFY(config.state() != QNetworkConfiguration::Active); // 2. Verify that stopping a session based on non-connected configuration does nothing @@ -583,18 +591,20 @@ void tst_QNetworkSession::sessionStop() // 3. Check that stopping a opened session affects also other opened session based on the same configuration. if (config.type() == QNetworkConfiguration::InternetAccessPoint) { qDebug("----------3. Check that stopping a opened session affects also other opened session based on the same configuration."); + QVERIFY(openSession(&openedSession)); QVERIFY(openSession(&innocentSession)); - + configChangeSpy.clear(); innocentSessionClosedSpy.clear(); innocentSessionStateChangedSpy.clear(); innocentErrorSpy.clear(); - + openedSession.stop(); qDebug("Waiting for %d ms to get all configurationChange signals from platform.", configWaitdelayInMs); QTest::qWait(configWaitdelayInMs); // Wait to get all relevant configurationChange() signals - + QTest::qWait(configWaitdelayInMs); // Wait to get all relevant configurationChange() signals + QVERIFY(!innocentSessionClosedSpy.isEmpty()); QVERIFY(!innocentSessionStateChangedSpy.isEmpty()); QVERIFY(!innocentErrorSpy.isEmpty()); @@ -614,14 +624,19 @@ void tst_QNetworkSession::sessionStop() if (config.type() == QNetworkConfiguration::ServiceNetwork) { qDebug("----------4. Skip for SNAP configuration."); } else if (config.type() == QNetworkConfiguration::InternetAccessPoint) { - qDebug("----------4. Check that stopping a non-opened session stops the other session based on the same configuration"); - QVERIFY(openSession(&innocentSession)); + qDebug("----------4. Check that stopping a non-opened session stops the other session based on the same configuration"); + qDebug("----------4.1 Opening innocent session"); + QVERIFY(openSession(&innocentSession)); qDebug("Waiting for %d ms after open to make sure all platform indications are propagated", configWaitdelayInMs); QTest::qWait(configWaitdelayInMs); + qDebug("----------4.2 Calling closedSession.stop()"); closedSession.stop(); qDebug("Waiting for %d ms to get all configurationChange signals from platform..", configWaitdelayInMs); QTest::qWait(configWaitdelayInMs); // Wait to get all relevant configurationChange() signals + QTest::qWait(configWaitdelayInMs); + QTest::qWait(configWaitdelayInMs); + QVERIFY(!innocentSessionClosedSpy.isEmpty()); QVERIFY(!innocentSessionStateChangedSpy.isEmpty()); QVERIFY(!innocentErrorSpy.isEmpty()); @@ -653,6 +668,9 @@ void tst_QNetworkSession::userChoiceSession_data() void tst_QNetworkSession::userChoiceSession() { + if (!testsToRun["userChoiceSession"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } QFETCH(QNetworkConfiguration, configuration); QVERIFY(configuration.type() == QNetworkConfiguration::UserChoice); @@ -682,7 +700,20 @@ void tst_QNetworkSession::userChoiceSession() session.open(); +#if defined(Q_OS_SYMBIAN) + // Opening & closing multiple connections in a row sometimes + // results hanging of connection opening on Symbian devices + // => If first open fails, wait a moment and try again. + if (!session.waitForOpened()) { + qDebug("**** Session open Timeout - Wait 5 seconds and try once again ****"); + session.close(); + QTest::qWait(5000); // Wait a while before trying to open session again + session.open(); + session.waitForOpened(); + } +#else session.waitForOpened(); +#endif if (session.isOpen()) QVERIFY(!sessionOpenedSpy.isEmpty() || !errorSpy.isEmpty()); @@ -786,6 +817,9 @@ void tst_QNetworkSession::sessionOpenCloseStop_data() void tst_QNetworkSession::sessionOpenCloseStop() { + if (!testsToRun["sessionOpenCloseStop"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } QFETCH(QNetworkConfiguration, configuration); QFETCH(bool, forceSessionStop); @@ -818,7 +852,20 @@ void tst_QNetworkSession::sessionOpenCloseStop() session.open(); +#if defined(Q_OS_SYMBIAN) + // Opening & closing multiple connections in a row sometimes + // results hanging of connection opening on Symbian devices + // => If first open fails, wait a moment and try again. + if (!session.waitForOpened()) { + qDebug("**** Session open Timeout - Wait 5 seconds and try once again ****"); + session.close(); + QTest::qWait(5000); // Wait a while before trying to open session again + session.open(); + session.waitForOpened(); + } +#else session.waitForOpened(); +#endif if (session.isOpen()) QVERIFY(!sessionOpenedSpy.isEmpty() || !errorSpy.isEmpty()); @@ -894,26 +941,30 @@ void tst_QNetworkSession::sessionOpenCloseStop() QVERIFY(session.error() == QNetworkSession::UnknownSessionError); session2.open(); - + QTRY_VERIFY(!sessionOpenedSpy2.isEmpty() || !errorSpy2.isEmpty()); + if (errorSpy2.isEmpty()) { + QVERIFY(session2.isOpen()); + QVERIFY(session2.state() == QNetworkSession::Connected); + } QVERIFY(session.isOpen()); - QVERIFY(session2.isOpen()); QVERIFY(session.state() == QNetworkSession::Connected); - QVERIFY(session2.state() == QNetworkSession::Connected); #ifndef QT_NO_NETWORKINTERFACE #if !(defined(Q_OS_SYMBIAN) && defined(__WINS__)) // On Symbian emulator, the support for data bearers is limited QVERIFY(session.interface().isValid()); #endif - QCOMPARE(session.interface().hardwareAddress(), session2.interface().hardwareAddress()); - QCOMPARE(session.interface().index(), session2.interface().index()); + if (errorSpy2.isEmpty()) { + QCOMPARE(session.interface().hardwareAddress(), session2.interface().hardwareAddress()); + QCOMPARE(session.interface().index(), session2.interface().index()); + } #endif } sessionOpenedSpy2.clear(); - if (forceSessionStop) { + if (forceSessionStop && session2.isOpen()) { // Test forcing the second session to stop the interface. QNetworkSession::State previousState = session.state(); #ifdef Q_CC_NOKIAX86 @@ -922,15 +973,17 @@ void tst_QNetworkSession::sessionOpenCloseStop() #else bool expectStateChange = previousState != QNetworkSession::Disconnected; #endif - session2.stop(); + // QNetworkSession::stop() must result either closed() signal + // or error() signal QTRY_VERIFY(!sessionClosedSpy2.isEmpty() || !errorSpy2.isEmpty()); - QVERIFY(!session2.isOpen()); if (!errorSpy2.isEmpty()) { - QVERIFY(!errorSpy.isEmpty()); + // QNetworkSession::stop() resulted error() signal for session2 + // => also session should emit error() signal + QTRY_VERIFY(!errorSpy.isEmpty()); // check for SessionAbortedError QNetworkSession::SessionError error = @@ -950,9 +1003,12 @@ void tst_QNetworkSession::sessionOpenCloseStop() QVERIFY(errorSpy.isEmpty()); QVERIFY(errorSpy2.isEmpty()); - + + // Wait for Disconnected state + QTRY_NOOP(session2.state() == QNetworkSession::Disconnected); + if (expectStateChange) - QTRY_VERIFY(stateChangedSpy2.count() >= 2 || !errorSpy2.isEmpty()); + QTRY_VERIFY(stateChangedSpy2.count() >= 1 || !errorSpy2.isEmpty()); if (!errorSpy2.isEmpty()) { QVERIFY(session2.state() == previousState); @@ -996,16 +1052,29 @@ void tst_QNetworkSession::sessionOpenCloseStop() state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(3).at(0)); QVERIFY(state == QNetworkSession::Disconnected); + + QTRY_VERIFY(session.state() == QNetworkSession::Roaming || + session.state() == QNetworkSession::Connected || + session.state() == QNetworkSession::Disconnected); + QTRY_VERIFY(stateChangedSpy.count() > 0); - state = qvariant_cast<QNetworkSession::State>(stateChangedSpy.at(0).at(0)); + state = qvariant_cast<QNetworkSession::State>(stateChangedSpy.at(stateChangedSpy.count() - 1).at(0)); + if (state == QNetworkSession::Roaming) { - QTRY_VERIFY(!errorSpy.isEmpty() || stateChangedSpy.count() > 1); - if (stateChangedSpy.count() > 1 && - qvariant_cast<QNetworkSession::State>(stateChangedSpy.at(1).at(0)) == - QNetworkSession::Connected) { - roamedSuccessfully = true; + QTRY_VERIFY(session.state() == QNetworkSession::Connected); + QTRY_VERIFY(session2.state() == QNetworkSession::Connected); + roamedSuccessfully = true; + } else if (state == QNetworkSession::Disconnected) { + QTRY_VERIFY(!errorSpy.isEmpty()); + QTRY_VERIFY(session2.state() == QNetworkSession::Disconnected); + } else if (state == QNetworkSession::Connected) { + QTRY_VERIFY(errorSpy.isEmpty()); + if (stateChangedSpy.count() > 1) { + state = qvariant_cast<QNetworkSession::State>(stateChangedSpy.at(stateChangedSpy.count() - 2).at(0)); + QVERIFY(state == QNetworkSession::Roaming); } - } + roamedSuccessfully = true; + } if (roamedSuccessfully) { QString configId = session.sessionProperty("ActiveConfiguration").toString(); @@ -1013,37 +1082,36 @@ void tst_QNetworkSession::sessionOpenCloseStop() QNetworkSession session3(config); QSignalSpy errorSpy3(&session3, SIGNAL(error(QNetworkSession::SessionError))); QSignalSpy sessionOpenedSpy3(&session3, SIGNAL(opened())); - session3.open(); - session3.waitForOpened(); - + session3.waitForOpened(); if (session.isOpen()) QVERIFY(!sessionOpenedSpy3.isEmpty() || !errorSpy3.isEmpty()); - session.stop(); - QTRY_VERIFY(session.state() == QNetworkSession::Disconnected); - QTRY_VERIFY(session3.state() == QNetworkSession::Disconnected); } #ifndef Q_CC_NOKIAX86 if (!roamedSuccessfully) QVERIFY(!errorSpy.isEmpty()); #endif } else { - QCOMPARE(stateChangedSpy2.count(), 2); - - QNetworkSession::State state = - qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(0).at(0)); - QVERIFY(state == QNetworkSession::Closing); - - state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(1).at(0)); - QVERIFY(state == QNetworkSession::Disconnected); + QTest::qWait(2000); // Wait awhile to get all signals from platform + + if (stateChangedSpy2.count() == 2) { + QNetworkSession::State state = + qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(0).at(0)); + QVERIFY(state == QNetworkSession::Closing); + state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(1).at(0)); + QVERIFY(state == QNetworkSession::Disconnected); + } else { // Assume .count() == 1 + QCOMPARE(stateChangedSpy2.count(), 1); + QNetworkSession::State state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(0).at(0)); + // Symbian version dependant. + QVERIFY(state == QNetworkSession::Disconnected); + } } QTRY_VERIFY(!sessionClosedSpy.isEmpty()); - QTRY_VERIFY(session.state() == QNetworkSession::Disconnected); - QTRY_VERIFY(session2.state() == QNetworkSession::Disconnected); } QVERIFY(errorSpy2.isEmpty()); @@ -1062,7 +1130,7 @@ void tst_QNetworkSession::sessionOpenCloseStop() QVERIFY(!session.isOpen()); #endif QVERIFY(!session2.isOpen()); - } else { + } else if (session2.isOpen()) { // Test closing the second session. { int stateChangedCountBeforeClose = stateChangedSpy2.count(); @@ -1161,11 +1229,15 @@ QDebug operator<<(QDebug debug, const QList<QNetworkConfiguration> &list) // at Discovered -state. void tst_QNetworkSession::outOfProcessSession() { - qDebug() << "START"; - + if (!testsToRun["outOfProcessSession"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } #if defined(Q_OS_SYMBIAN) && defined(__WINS__) QSKIP("Symbian emulator does not support two [QR]PRocesses linking a dll (QtBearer.dll) with global writeable static data.", SkipAll); #endif + updateConfigurations(); + QTest::qWait(2000); + QNetworkConfigurationManager manager; // Create a QNetworkConfigurationManager to detect configuration changes made in Lackey. This // is actually the essence of this testcase - to check that platform mediates/reflects changes @@ -1182,16 +1254,15 @@ void tst_QNetworkSession::outOfProcessSession() QLocalServer::removeServer("tst_qnetworksession"); oopServer.listen("tst_qnetworksession"); - qDebug() << "starting lackey"; QProcess lackey; lackey.start("lackey/lackey"); qDebug() << lackey.error() << lackey.errorString(); QVERIFY(lackey.waitForStarted()); - qDebug() << "waiting for connection"; + QVERIFY(oopServer.waitForNewConnection(-1)); QLocalSocket *oopSocket = oopServer.nextPendingConnection(); - qDebug() << "got connection"; + do { QByteArray output; @@ -1258,7 +1329,6 @@ void tst_QNetworkSession::outOfProcessSession() default: QSKIP("Lackey failed", SkipAll); } - qDebug("STOP"); } // A convinience / helper function for testcases. Return the first matching configuration. @@ -1269,6 +1339,7 @@ QNetworkConfiguration suitableConfiguration(QString bearerType, QNetworkConfigur // Refresh configurations and derive configurations matching given parameters. QNetworkConfigurationManager mgr; QSignalSpy updateSpy(&mgr, SIGNAL(updateCompleted())); + mgr.updateConfigurations(); QTRY_NOOP(updateSpy.count() == 1); if (updateSpy.count() != 1) { @@ -1277,8 +1348,7 @@ QNetworkConfiguration suitableConfiguration(QString bearerType, QNetworkConfigur } QList<QNetworkConfiguration> discoveredConfigs = mgr.allConfigurations(QNetworkConfiguration::Discovered); foreach(QNetworkConfiguration config, discoveredConfigs) { - if ((config.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { - // qDebug() << "Dumping config because is active: " << config.name(); + if ((config.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { discoveredConfigs.removeOne(config); } else if (config.type() != configType) { // qDebug() << "Dumping config because type (IAP/SNAP) mismatches: " << config.name(); @@ -1315,9 +1385,23 @@ void updateConfigurations() QTRY_NOOP(updateSpy.count() == 1); } +// A convinience-function: updates and prints all available confiurations and their states +void printConfigurations() +{ + QNetworkConfigurationManager manager; + QList<QNetworkConfiguration> allConfigs = + manager.allConfigurations(); + qDebug("tst_QNetworkSession::printConfigurations QNetworkConfigurationManager gives following configurations: "); + foreach(QNetworkConfiguration config, allConfigs) { + qDebug() << "Name of the configuration: " << config.name(); + qDebug() << "State of the configuration: " << config.state(); + } +} + // A convinience function for test-cases: opens the given configuration and return // true if it was done gracefully. bool openSession(QNetworkSession *session) { + bool result = true; QNetworkConfigurationManager mgr; QSignalSpy openedSpy(session, SIGNAL(opened())); QSignalSpy stateChangeSpy(session, SIGNAL(stateChanged(QNetworkSession::State))); @@ -1327,43 +1411,57 @@ bool openSession(QNetworkSession *session) { // active by some other session QNetworkConfiguration::StateFlags configInitState = session->configuration().state(); QNetworkSession::State sessionInitState = session->state(); + qDebug() << "tst_QNetworkSession::openSession() name of the configuration to be opened: " << session->configuration().name(); + qDebug() << "tst_QNetworkSession::openSession() state of the configuration to be opened: " << session->configuration().state(); + qDebug() << "tst_QNetworkSession::openSession() state of the session to be opened: " << session->state(); if (session->isOpen() || !session->sessionProperty("ActiveConfiguration").toString().isEmpty()) { qDebug("tst_QNetworkSession::openSession() failure: session was already open / active."); - return false; + result = false; } else { session->open(); session->waitForOpened(120000); // Bringing interfaces up and down may take time at platform } + QTest::qWait(5000); // Wait a moment to ensure all signals are propagated // Check that connection opening went by the book. Add checks here if more strictness needed. if (!session->isOpen()) { qDebug("tst_QNetworkSession::openSession() failure: QNetworkSession::open() failed."); - return false; + result = false; } if (openedSpy.count() != 1) { qDebug("tst_QNetworkSession::openSession() failure: QNetworkSession::opened() - signal not received."); - return false; + result = false; } if (!errorSpy.isEmpty()) { qDebug("tst_QNetworkSession::openSession() failure: QNetworkSession::error() - signal was detected."); - return false; + result = false; } if (sessionInitState != QNetworkSession::Connected && stateChangeSpy.isEmpty()) { qDebug("tst_QNetworkSession::openSession() failure: QNetworkSession::stateChanged() - signals not detected."); - return false; + result = false; } if (configInitState != QNetworkConfiguration::Active && configChangeSpy.isEmpty()) { qDebug("tst_QNetworkSession::openSession() failure: QNetworkConfigurationManager::configurationChanged() - signals not detected."); - return false; + result = false; } if (session->configuration().state() != QNetworkConfiguration::Active) { qDebug("tst_QNetworkSession::openSession() failure: session's configuration is not in 'Active' -state."); - return false; + qDebug() << "tst_QNetworkSession::openSession() state is: " << session->configuration().state(); + result = false; + } + if (result == false) { + qDebug() << "tst_QNetworkSession::openSession() opening session failed."; + } else { + qDebug() << "tst_QNetworkSession::openSession() opening session succeeded."; } - return true; + qDebug() << "tst_QNetworkSession::openSession() name of the configuration is: " << session->configuration().name(); + qDebug() << "tst_QNetworkSession::openSession() configuration state is: " << session->configuration().state(); + qDebug() << "tst_QNetworkSession::openSession() session state is: " << session->state(); + + return result; } // Helper function for closing opened session. Performs checks that @@ -1376,6 +1474,11 @@ bool closeSession(QNetworkSession *session, bool lastSessionOnConfiguration) { qDebug("tst_QNetworkSession::closeSession() failure: NULL session given"); return false; } + + qDebug() << "tst_QNetworkSession::closeSession() name of the configuration to be closed: " << session->configuration().name(); + qDebug() << "tst_QNetworkSession::closeSession() state of the configuration to be closed: " << session->configuration().state(); + qDebug() << "tst_QNetworkSession::closeSession() state of the session to be closed: " << session->state(); + if (session->state() != QNetworkSession::Connected || !session->isOpen()) { qDebug("tst_QNetworkSession::closeSession() failure: session is not opened."); @@ -1387,38 +1490,48 @@ bool closeSession(QNetworkSession *session, bool lastSessionOnConfiguration) { QSignalSpy sessionErrorSpy(session, SIGNAL(error(QNetworkSession::SessionError))); QSignalSpy configChangeSpy(&mgr, SIGNAL(configurationChanged(QNetworkConfiguration))); + bool result = true; session->close(); + QTest::qWait(5000); // Wait a moment so that all signals are propagated if (!sessionErrorSpy.isEmpty()) { qDebug("tst_QNetworkSession::closeSession() failure: QNetworkSession::error() received."); - return false; + result = false; } if (sessionClosedSpy.count() != 1) { qDebug("tst_QNetworkSession::closeSession() failure: QNetworkSession::closed() signal not received."); - return false; + result = false; } if (lastSessionOnConfiguration && sessionStateChangedSpy.isEmpty()) { qDebug("tst_QNetworkSession::closeSession() failure: QNetworkSession::stateChanged() signals not received."); - return false; + result = false; } if (lastSessionOnConfiguration && session->state() != QNetworkSession::Disconnected) { qDebug("tst_QNetworkSession::closeSession() failure: QNetworkSession is not in Disconnected -state"); - return false; + result = false; } QTRY_NOOP(!configChangeSpy.isEmpty()); if (lastSessionOnConfiguration && configChangeSpy.isEmpty()) { qDebug("tst_QNetworkSession::closeSession() failure: QNetworkConfigurationManager::configurationChanged() - signal not detected."); - return false; + result = false; } if (lastSessionOnConfiguration && session->configuration().state() == QNetworkConfiguration::Active) { qDebug("tst_QNetworkSession::closeSession() failure: session's configuration is still in active state."); - return false; + result = false; } - return true; + if (result == false) { + qDebug() << "tst_QNetworkSession::closeSession() closing session failed."; + } else { + qDebug() << "tst_QNetworkSession::closeSession() closing session succeeded."; + } + qDebug() << "tst_QNetworkSession::closeSession() name of the configuration is: " << session->configuration().name(); + qDebug() << "tst_QNetworkSession::closeSession() configuration state is: " << session->configuration().state(); + qDebug() << "tst_QNetworkSession::closeSession() session state is: " << session->state(); + return result; } void tst_QNetworkSession::sessionAutoClose_data() diff --git a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp index f8951f5..70f2ac3 100644 --- a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp +++ b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#define Q_TEST_QPIXMAPCACHE #include <QtTest/QtTest> @@ -152,6 +153,7 @@ void tst_QPixmapCache::setCacheLimit() p1 = new QPixmap(2, 3); key = QPixmapCache::insert(*p1); QVERIFY(QPixmapCache::find(key, p1) != 0); + p1->detach(); // dectach so that the cache thinks no-one is using it. QPixmapCache::setCacheLimit(0); QVERIFY(QPixmapCache::find(key, p1) == 0); QPixmapCache::setCacheLimit(1000); @@ -169,6 +171,8 @@ void tst_QPixmapCache::setCacheLimit() key = QPixmapCache::insert(*p1); QVERIFY(QPixmapCache::find(key, &p2) != 0); //we flush the cache + p1->detach(); + p2.detach(); QPixmapCache::setCacheLimit(0); QPixmapCache::setCacheLimit(1000); QPixmapCache::Key key2 = QPixmapCache::insert(*p1); @@ -180,21 +184,25 @@ void tst_QPixmapCache::setCacheLimit() delete p1; //Here we simulate the flushing when the app is idle - /*QPixmapCache::clear(); + QPixmapCache::clear(); QPixmapCache::setCacheLimit(originalCacheLimit); p1 = new QPixmap(300, 300); key = QPixmapCache::insert(*p1); + p1->detach(); QCOMPARE(getPrivate(key)->key, 1); key2 = QPixmapCache::insert(*p1); + p1->detach(); key2 = QPixmapCache::insert(*p1); + p1->detach(); QPixmapCache::Key key3 = QPixmapCache::insert(*p1); - QTest::qWait(32000); + p1->detach(); + QPixmapCache::flushDetachedPixmaps(); key2 = QPixmapCache::insert(*p1); QCOMPARE(getPrivate(key2)->key, 1); //This old key is not valid anymore after the flush QCOMPARE(getPrivate(key)->isValid, false); QVERIFY(QPixmapCache::find(key, &p2) == 0); - delete p1;*/ + delete p1; } void tst_QPixmapCache::find() @@ -225,12 +233,14 @@ void tst_QPixmapCache::find() QPixmapCache::clear(); QPixmapCache::setCacheLimit(128); - key = QPixmapCache::insert(p1); + QPixmap p4(10,10); + key = QPixmapCache::insert(p4); + p4.detach(); - //The int part of the API + QPixmap p5(10,10); QList<QPixmapCache::Key> keys; for (int i = 0; i < 4000; ++i) - QPixmapCache::insert(p1); + QPixmapCache::insert(p5); //at that time the first key has been erase because no more place in the cache QVERIFY(QPixmapCache::find(key, &p1) == 0); @@ -257,8 +267,10 @@ void tst_QPixmapCache::insert() QPixmapCache::insert("0", p1); // ditto - for (int j = 0; j < numberOfKeys; ++j) - QPixmapCache::insert(QString::number(j), p1); + for (int j = 0; j < numberOfKeys; ++j) { + QPixmap p3(10, 10); + QPixmapCache::insert(QString::number(j), p3); + } int num = 0; for (int k = 0; k < numberOfKeys; ++k) { @@ -286,8 +298,10 @@ void tst_QPixmapCache::insert() //The int part of the API // make sure it doesn't explode QList<QPixmapCache::Key> keys; - for (int i = 0; i < numberOfKeys; ++i) - keys.append(QPixmapCache::insert(p1)); + for (int i = 0; i < numberOfKeys; ++i) { + QPixmap p3(10,10); + keys.append(QPixmapCache::insert(p3)); + } num = 0; for (int k = 0; k < numberOfKeys; ++k) { diff --git a/tests/auto/qprinter/tst_qprinter.cpp b/tests/auto/qprinter/tst_qprinter.cpp index 49bddb2..8b79533 100644 --- a/tests/auto/qprinter/tst_qprinter.cpp +++ b/tests/auto/qprinter/tst_qprinter.cpp @@ -110,6 +110,7 @@ private slots: void testCurrentPage(); void taskQTBUG4497_reusePrinterOnDifferentFiles(); + void testPdfTitle(); private: }; @@ -417,7 +418,7 @@ void tst_QPrinter::testMargins() printer.setFullPage(fullpage); printer.setPageSize((QPrinter::PageSize)pagesize); if (withPainter) - painter = new QPainter(&printer); + painter = new QPainter(&printer); #ifdef QT3_SUPPORT Q3PaintDeviceMetrics metrics(&printer); @@ -1028,5 +1029,30 @@ void tst_QPrinter::testCurrentPage() } +void tst_QPrinter::testPdfTitle() +{ + // Check the document name is represented correctly in produced pdf + { + QPainter painter; + QPrinter printer; + // This string is just the UTF-8 encoding of the string: \()f ø hiragana o + const char title[]={0x5c, 0x28, 0x29, 0x66, 0xc3, 0xb8, 0xe3, 0x81, 0x8a, 0x00}; + printer.setOutputFileName("file.pdf"); + printer.setDocName(QString::fromUtf8(title)); + painter.begin(&printer); + painter.end(); + } + QFile file("file.pdf"); + QVERIFY(file.open(QIODevice::ReadOnly)); + // The we expect the title to appear in the PDF as: + // ASCII('\title (') UTF16(\\\(\)f ø hiragana o) ASCII(')'). + // which has the following binary representation + const char expected[] = { + 0x2f, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x20, 0x28, 0xfe, + 0xff, 0x00, 0x5c, 0x5c, 0x00, 0x5c, 0x28, 0x00, 0x5c, + 0x29, 0x00, 0x66, 0x00, 0xf8, 0x30, 0x4a, 0x29}; + QVERIFY(file.readAll().contains(QByteArray(expected, 26))); +} + QTEST_MAIN(tst_QPrinter) #include "tst_qprinter.moc" diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index 849b8b2..ea527de 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -133,6 +133,7 @@ private slots: void twoAnimations(); void deletedInUpdateCurrentTime(); void totalDuration(); + void zeroLoopCount(); }; tst_QPropertyAnimation::tst_QPropertyAnimation() @@ -1214,6 +1215,29 @@ void tst_QPropertyAnimation::totalDuration() QCOMPARE(anim.totalDuration(), 0); } +void tst_QPropertyAnimation::zeroLoopCount() +{ + DummyPropertyAnimation* anim; + anim = new DummyPropertyAnimation; + anim->setStartValue(0); + anim->setDuration(20); + anim->setLoopCount(0); + + QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); + QSignalSpy finishedSpy(anim, SIGNAL(finished())); + + QCOMPARE(anim->state(), QAnimationGroup::Stopped); + QCOMPARE(anim->currentValue().toInt(), 0); + QCOMPARE(runningSpy.count(), 0); + QCOMPARE(finishedSpy.count(), 0); + + anim->start(); + + QCOMPARE(anim->state(), QAnimationGroup::Stopped); + QCOMPARE(anim->currentValue().toInt(), 0); + QCOMPARE(runningSpy.count(), 0); + QCOMPARE(finishedSpy.count(), 0); +} QTEST_MAIN(tst_QPropertyAnimation) #include "tst_qpropertyanimation.moc" diff --git a/tests/auto/qsocketnotifier/qsocketnotifier.pro b/tests/auto/qsocketnotifier/qsocketnotifier.pro index ec924c1..c43c96a 100644 --- a/tests/auto/qsocketnotifier/qsocketnotifier.pro +++ b/tests/auto/qsocketnotifier/qsocketnotifier.pro @@ -6,5 +6,6 @@ requires(contains(QT_CONFIG,private_tests)) include(../qnativesocketengine/qsocketengine.pri) +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qsocks5socketengine/qsocks5socketengine.pro b/tests/auto/qsocks5socketengine/qsocks5socketengine.pro index 4a32852..cd5e6e7 100644 --- a/tests/auto/qsocks5socketengine/qsocks5socketengine.pro +++ b/tests/auto/qsocks5socketengine/qsocks5socketengine.pro @@ -11,6 +11,7 @@ QT = core network # Symbian toolchain does not support correct include semantics symbian:INCPATH+=..\..\..\include\QtNetwork\private +symbian: TARGET.CAPABILITY = NetworkServices requires(contains(QT_CONFIG,private_tests)) diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 2339b21..992c95e 100644 --- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -138,6 +138,7 @@ private slots: void taskQTBUG_6205_doubleProxySelectionSetSourceModel(); void taskQTBUG_7537_appearsAndSort(); void taskQTBUG_7716_unnecessaryDynamicSorting(); + void taskQTBUG_10287_unnecessaryMapCreation(); void testMultipleProxiesWithSelection(); @@ -3038,5 +3039,65 @@ void tst_QSortFilterProxyModel::testMultipleProxiesWithSelection() } +class Model10287 : public QStandardItemModel +{ + Q_OBJECT + +public: + Model10287(QObject *parent = 0) + : QStandardItemModel(0, 1, parent) + { + parentItem = new QStandardItem("parent"); + parentItem->setData(false, Qt::UserRole); + appendRow(parentItem); + + childItem = new QStandardItem("child"); + childItem->setData(true, Qt::UserRole); + parentItem->appendRow(childItem); + + childItem2 = new QStandardItem("child2"); + childItem2->setData(true, Qt::UserRole); + parentItem->appendRow(childItem2); + } + + void removeChild() + { + childItem2->setData(false, Qt::UserRole); + parentItem->removeRow(0); + } + +private: + QStandardItem *parentItem, *childItem, *childItem2; +}; + +class Proxy10287 : public QSortFilterProxyModel +{ + Q_OBJECT + +public: + Proxy10287(QAbstractItemModel *model, QObject *parent = 0) + : QSortFilterProxyModel(parent) + { + setSourceModel(model); + setDynamicSortFilter(true); + } + +protected: + virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const + { + // Filter based on UserRole in model + QModelIndex i = sourceModel()->index(source_row, 0, source_parent); + return i.data(Qt::UserRole).toBool(); + } +}; + +void tst_QSortFilterProxyModel::taskQTBUG_10287_unnecessaryMapCreation() +{ + Model10287 m; + Proxy10287 p(&m); + m.removeChild(); + // No assert failure, it passes. +} + QTEST_MAIN(tst_QSortFilterProxyModel) #include "tst_qsortfilterproxymodel.moc" diff --git a/tests/auto/qsoundeffect/qsoundeffect.pro b/tests/auto/qsoundeffect/qsoundeffect.pro deleted file mode 100644 index 5344a16..0000000 --- a/tests/auto/qsoundeffect/qsoundeffect.pro +++ /dev/null @@ -1,20 +0,0 @@ -load(qttest_p4) - -SOURCES += tst_qsoundeffect.cpp - -QT = core multimedia mediaservices - -wince* { - deploy.sources += 4.wav - DEPLOYMENT = deploy - DEFINES += SRCDIR=\\\"\\\" - QT += gui -} else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" -} - -unix:!mac { - !contains(QT_CONFIG, pulseaudio) { - DEFINES += QT_MULTIMEDIA_QMEDIAPLAYER - } -} diff --git a/tests/auto/qsoundeffect/test.wav b/tests/auto/qsoundeffect/test.wav Binary files differdeleted file mode 100644 index e4088a9..0000000 --- a/tests/auto/qsoundeffect/test.wav +++ /dev/null diff --git a/tests/auto/qsoundeffect/tst_qsoundeffect.cpp b/tests/auto/qsoundeffect/tst_qsoundeffect.cpp deleted file mode 100644 index e76a4c5..0000000 --- a/tests/auto/qsoundeffect/tst_qsoundeffect.cpp +++ /dev/null @@ -1,144 +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 <QtTest/QtTest> -#include <QtCore/qlocale.h> -#include <qaudiooutput.h> -#include <qaudiodeviceinfo.h> -#include <qaudio.h> -#include <private/qsoundeffect_p.h> - - -class tst_QSoundEffect : public QObject -{ - Q_OBJECT -public: - tst_QSoundEffect(QObject* parent=0) : QObject(parent) {} - -private slots: - void initTestCase(); - void testSource(); - void testLooping(); - void testVolume(); - void testMuting(); - -private: - QSoundEffect* sound; -}; - -void tst_QSoundEffect::initTestCase() -{ -#ifndef QT_MULTIMEDIA_QMEDIAPLAYER - sound = new QSoundEffect; - - QVERIFY(sound->source().isEmpty()); - QVERIFY(sound->loops() == 1); - QVERIFY(sound->volume() == 100); - QVERIFY(sound->isMuted() == false); -#endif -} - -void tst_QSoundEffect::testSource() -{ -#ifndef QT_MULTIMEDIA_QMEDIAPLAYER - QSignalSpy readSignal(sound, SIGNAL(sourceChanged())); - - QUrl url = QUrl::fromLocalFile(QString("%1%2").arg(SRCDIR).arg("test.wav")); - sound->setSource(url); - - QCOMPARE(sound->source(),url); - QCOMPARE(readSignal.count(),1); - - QTestEventLoop::instance().enterLoop(1); - sound->play(); - - QTest::qWait(3000); -#endif -} - -void tst_QSoundEffect::testLooping() -{ -#ifndef QT_MULTIMEDIA_QMEDIAPLAYER - QSignalSpy readSignal(sound, SIGNAL(loopsChanged())); - - sound->setLoops(5); - QCOMPARE(sound->loops(),5); - - sound->play(); - - // test.wav is about 200ms, wait until it has finished playing 5 times - QTest::qWait(3000); -#endif -} - -void tst_QSoundEffect::testVolume() -{ -#ifndef QT_MULTIMEDIA_QMEDIAPLAYER - QSignalSpy readSignal(sound, SIGNAL(volumeChanged())); - - sound->setVolume(50); - QCOMPARE(sound->volume(),50); - - QTest::qWait(20); - QCOMPARE(readSignal.count(),1); -#endif -} - -void tst_QSoundEffect::testMuting() -{ -#ifndef QT_MULTIMEDIA_QMEDIAPLAYER - QSignalSpy readSignal(sound, SIGNAL(mutedChanged())); - - sound->setMuted(true); - QCOMPARE(sound->isMuted(),true); - - QTest::qWait(20); - QCOMPARE(readSignal.count(),1); - - delete sound; -#endif -} - -QTEST_MAIN(tst_QSoundEffect) - -#include "tst_qsoundeffect.moc" diff --git a/tests/auto/qsslcertificate/qsslcertificate.pro b/tests/auto/qsslcertificate/qsslcertificate.pro index b237f2e..d7671ea 100644 --- a/tests/auto/qsslcertificate/qsslcertificate.pro +++ b/tests/auto/qsslcertificate/qsslcertificate.pro @@ -24,4 +24,5 @@ wince*: { DEFINES += SRCDIR=\\\".\\\" } else:!symbian { DEFINES += SRCDIR=\\\"$$PWD/\\\" + TARGET.CAPABILITY = NetworkServices } diff --git a/tests/auto/qsslcipher/qsslcipher.pro b/tests/auto/qsslcipher/qsslcipher.pro index 6eae588..78fd387 100644 --- a/tests/auto/qsslcipher/qsslcipher.pro +++ b/tests/auto/qsslcipher/qsslcipher.pro @@ -14,4 +14,5 @@ win32 { } } +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qsslerror/qsslerror.pro b/tests/auto/qsslerror/qsslerror.pro index ee5872b..5b907fb 100644 --- a/tests/auto/qsslerror/qsslerror.pro +++ b/tests/auto/qsslerror/qsslerror.pro @@ -14,4 +14,5 @@ win32 { } } +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qsslkey/qsslkey.pro b/tests/auto/qsslkey/qsslkey.pro index 32138f8..e3eeef9 100644 --- a/tests/auto/qsslkey/qsslkey.pro +++ b/tests/auto/qsslkey/qsslkey.pro @@ -24,4 +24,5 @@ wince*: { DEFINES += SRCDIR=\\\".\\\" } else:!symbian { DEFINES+= SRCDIR=\\\"$$PWD\\\" + TARGET.CAPABILITY = NetworkServices } diff --git a/tests/auto/qsslsocket/qsslsocket.pro b/tests/auto/qsslsocket/qsslsocket.pro index 541b2d9..3557fc8 100644 --- a/tests/auto/qsslsocket/qsslsocket.pro +++ b/tests/auto/qsslsocket/qsslsocket.pro @@ -24,7 +24,7 @@ wince* { } else:symbian { DEFINES += QSSLSOCKET_CERTUNTRUSTED_WORKAROUND TARGET.EPOCHEAPSIZE="0x100 0x1000000" - TARGET.CAPABILITY="ALL -TCB" + TARGET.CAPABILITY=NetworkServices certFiles.sources = certs ssl.tar.gz certFiles.path = . diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp index e0512a9..e370309 100644 --- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -98,6 +98,7 @@ private slots: void complexWidgetFocus(); void task188195_baseBackground(); void task232085_spinBoxLineEditBg(); + void changeStyleInChangeEvent(); //at the end because it mess with the style. void widgetStyle(); @@ -1256,7 +1257,7 @@ void tst_QStyleSheetStyle::proxyStyle() QStyleOptionViewItemV4 opt; opt.initFrom(w); opt.features |= QStyleOptionViewItemV2::HasCheckIndicator; - QVERIFY(pb5->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, + QVERIFY(pb5->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &opt, pb5).width() == 3); delete w; delete proxy; @@ -1579,6 +1580,34 @@ void tst_QStyleSheetStyle::task232085_spinBoxLineEditBg() .toLocal8Bit().constData()); } +class ChangeEventWidget : public QWidget +{ public: + void changeEvent(QEvent * event) + { + if(event->type() == QEvent::StyleChange) { + static bool recurse = false; + if (!recurse) { + recurse = true; + QStyle *style = new QMotifStyle; + style->setParent(this); + setStyle(style); + recurse = false; + } + } + QWidget::changeEvent(event); + } +}; + +void tst_QStyleSheetStyle::changeStyleInChangeEvent() +{ //must not crash; + ChangeEventWidget wid; + wid.ensurePolished(); + wid.setStyleSheet(" /* */ "); + wid.ensurePolished(); + wid.setStyleSheet(" /* ** */ "); + wid.ensurePolished(); +} + QTEST_MAIN(tst_QStyleSheetStyle) #include "tst_qstylesheetstyle.moc" diff --git a/tests/auto/qtcpserver/qtcpserver.pro b/tests/auto/qtcpserver/qtcpserver.pro index fe5ea37..a3744a2 100644 --- a/tests/auto/qtcpserver/qtcpserver.pro +++ b/tests/auto/qtcpserver/qtcpserver.pro @@ -1,5 +1,6 @@ TEMPLATE = subdirs SUBDIRS = test crashingServer +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qtcpsocket/qtcpsocket.pro b/tests/auto/qtcpsocket/qtcpsocket.pro index 3d4eba3..370a695 100644 --- a/tests/auto/qtcpsocket/qtcpsocket.pro +++ b/tests/auto/qtcpsocket/qtcpsocket.pro @@ -6,3 +6,4 @@ wince*|symbian*|vxworks* : SUBDIRS = test requires(contains(QT_CONFIG,private_tests)) +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp index cd512a1..31cae40 100644 --- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp @@ -144,6 +144,7 @@ private slots: void blockingIMAP(); void nonBlockingIMAP(); void hostNotFound(); + void timeoutConnect_data(); void timeoutConnect(); void delayedClose(); void partialRead(); @@ -544,19 +545,36 @@ void tst_QTcpSocket::hostNotFound() } //---------------------------------------------------------------------------------- +void tst_QTcpSocket::timeoutConnect_data() +{ + QTest::addColumn<QString>("address"); + QTest::newRow("host") << QtNetworkSettings::serverName(); + QTest::newRow("ip") << QtNetworkSettings::serverIP().toString(); +} void tst_QTcpSocket::timeoutConnect() { + QFETCH(QString, address); QTcpSocket *socket = newSocket(); - // Outgoing port 53 is firewalled in the Oslo office. - socket->connectToHost("cisco.com", 53); + QElapsedTimer timer; + timer.start(); + + // Port 1357 is configured to drop packets on the test server + socket->connectToHost(address, 1357); + QVERIFY(timer.elapsed() < 50); QVERIFY(!socket->waitForConnected(200)); QCOMPARE(socket->state(), QTcpSocket::UnconnectedState); QCOMPARE(int(socket->error()), int(QTcpSocket::SocketTimeoutError)); - socket->connectToHost("cisco.com", 53); - QTest::qSleep(50); + timer.start(); + socket->connectToHost(address, 1357); + QVERIFY(timer.elapsed() < 50); + QTimer::singleShot(50, &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(socket->state() == QTcpSocket::ConnectingState + || socket->state() == QTcpSocket::HostLookupState); socket->abort(); QCOMPARE(socket->state(), QTcpSocket::UnconnectedState); QCOMPARE(socket->openMode(), QIODevice::NotOpen); diff --git a/tests/auto/qudpsocket/qudpsocket.pro b/tests/auto/qudpsocket/qudpsocket.pro index 4ef8a40..8fd3545 100644 --- a/tests/auto/qudpsocket/qudpsocket.pro +++ b/tests/auto/qudpsocket/qudpsocket.pro @@ -1,5 +1,6 @@ TEMPLATE = subdirs SUBDIRS = test clientserver +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qurl/qurl.pro b/tests/auto/qurl/qurl.pro index 72c93bc..018bb38 100644 --- a/tests/auto/qurl/qurl.pro +++ b/tests/auto/qurl/qurl.pro @@ -1,3 +1,4 @@ load(qttest_p4) SOURCES += tst_qurl.cpp QT = core +symbian: TARGET.CAPABILITY = NetworkServices diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index fa42adc..820e32d 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -1410,7 +1410,7 @@ void tst_QUrl::setUrl() void tst_QUrl::i18n_data() { QTest::addColumn<QString>("input"); - QTest::addColumn<QByteArray>("punyOutput"); + QTest::addColumn<QByteArray>("punyOutput"); QTest::newRow("øl") << QString::fromLatin1("http://ole:passord@www.øl.no/index.html?ole=æsemann&ilder gud=hei#top") << QByteArray("http://ole:passord@www.xn--l-4ga.no/index.html?ole=%C3%A6semann&ilder%20gud=hei#top"); @@ -2165,25 +2165,25 @@ void tst_QUrl::toPercentEncoding_data() QTest::addColumn<QByteArray>("includeInEncoding"); QTest::newRow("test_01") << QString::fromLatin1("abcdevghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678-._~") - << QByteArray("abcdevghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678-._~") + << QByteArray("abcdevghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678-._~") << QByteArray("") << QByteArray(""); QTest::newRow("test_02") << QString::fromLatin1("{\t\n\r^\"abc}") - << QByteArray("%7B%09%0A%0D%5E%22abc%7D") + << QByteArray("%7B%09%0A%0D%5E%22abc%7D") << QByteArray("") << QByteArray(""); QTest::newRow("test_03") << QString::fromLatin1("://?#[]@!$&'()*+,;=") - << QByteArray("%3A%2F%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D") + << QByteArray("%3A%2F%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D") << QByteArray("") << QByteArray(""); QTest::newRow("test_04") << QString::fromLatin1("://?#[]@!$&'()*+,;=") - << QByteArray("%3A%2F%2F%3F%23%5B%5D%40!$&'()*+,;=") + << QByteArray("%3A%2F%2F%3F%23%5B%5D%40!$&'()*+,;=") << QByteArray("!$&'()*+,;=") << QByteArray(""); QTest::newRow("test_05") << QString::fromLatin1("abcd") << QByteArray("a%62%63d") << QByteArray("") - << QByteArray("bc"); + << QByteArray("bc"); } void tst_QUrl::toPercentEncoding() @@ -2193,7 +2193,7 @@ void tst_QUrl::toPercentEncoding() QFETCH(QByteArray, excludeInEncoding); QFETCH(QByteArray, includeInEncoding); - QByteArray encodedUrl = QUrl::toPercentEncoding(original, excludeInEncoding, includeInEncoding); + QByteArray encodedUrl = QUrl::toPercentEncoding(original, excludeInEncoding, includeInEncoding); QCOMPARE(encodedUrl.constData(), encoded.constData()); QCOMPARE(original, QUrl::fromPercentEncoding(encodedUrl)); } @@ -2461,6 +2461,8 @@ void tst_QUrl::isValid() QUrl url = QUrl::fromEncoded("http://strange<username>@ok-hostname/", QUrl::StrictMode); QVERIFY(!url.isValid()); // < and > are not allowed in userinfo in strict mode + url.setUserName("normal_username"); + QVERIFY(url.isValid()); } { QUrl url = QUrl::fromEncoded("http://strange<username>@ok-hostname/"); @@ -2471,7 +2473,18 @@ void tst_QUrl::isValid() QUrl url = QUrl::fromEncoded("http://strange;hostname/here"); QVERIFY(!url.isValid()); QCOMPARE(url.path(), QString("/here")); + url.setAuthority("foobar@bar"); + QVERIFY(url.isValid()); } + + { + QUrl url = QUrl::fromEncoded("foo://stuff;1/g"); + QVERIFY(!url.isValid()); + QCOMPARE(url.path(), QString("/g")); + url.setHost("stuff-1"); + QVERIFY(url.isValid()); + } + } void tst_QUrl::schemeValidator_data() @@ -3194,6 +3207,32 @@ void tst_QUrl::ace_testsuite_data() QTest::newRow("separator-3002") << QString::fromUtf8("example\343\200\202com") << "example.com" << "." << "example.com"; + + QString egyptianIDN = + QString::fromUtf8("\331\210\330\262\330\247\330\261\330\251\055\330\247\331\204\330" + "\243\330\252\330\265\330\247\331\204\330\247\330\252.\331\205" + "\330\265\330\261"); + QTest::newRow("egyptian-tld-ace") + << "xn----rmckbbajlc6dj7bxne2c.xn--wgbh1c" + << "xn----rmckbbajlc6dj7bxne2c.xn--wgbh1c" + << "." + << egyptianIDN; + QTest::newRow("egyptian-tld-unicode") + << egyptianIDN + << "xn----rmckbbajlc6dj7bxne2c.xn--wgbh1c" + << "." + << egyptianIDN; + QTest::newRow("egyptian-tld-mix1") + << QString::fromUtf8("\331\210\330\262\330\247\330\261\330\251\055\330\247\331\204\330" + "\243\330\252\330\265\330\247\331\204\330\247\330\252.xn--wgbh1c") + << "xn----rmckbbajlc6dj7bxne2c.xn--wgbh1c" + << "." + << egyptianIDN; + QTest::newRow("egyptian-tld-mix2") + << QString::fromUtf8("xn----rmckbbajlc6dj7bxne2c.\331\205\330\265\330\261") + << "xn----rmckbbajlc6dj7bxne2c.xn--wgbh1c" + << "." + << egyptianIDN; } void tst_QUrl::ace_testsuite() diff --git a/tests/auto/qvideowidget/qvideowidget.pro b/tests/auto/qvideowidget/qvideowidget.pro deleted file mode 100644 index 12686f3..0000000 --- a/tests/auto/qvideowidget/qvideowidget.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) - -SOURCES = tst_qvideowidget.cpp - -QT = core gui multimedia mediaservices - diff --git a/tests/auto/qvideowidget/tst_qvideowidget.cpp b/tests/auto/qvideowidget/tst_qvideowidget.cpp deleted file mode 100644 index 8a54789..0000000 --- a/tests/auto/qvideowidget/tst_qvideowidget.cpp +++ /dev/null @@ -1,1602 +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 <QtTest/QtTest> - -#include <QtMediaServices/qvideowidget.h> - -#include <QtMediaServices/qmediaobject.h> -#include <QtMediaServices/qmediaservice.h> -#include <QtMediaServices/private/qpaintervideosurface_p.h> -#include <QtMediaServices/qvideooutputcontrol.h> -#include <QtMediaServices/qvideowindowcontrol.h> -#include <QtMediaServices/qvideowidgetcontrol.h> -#include <QtMediaServices/qvideorenderercontrol.h> -#include <QtMultimedia/qabstractvideosurface.h> -#include <QtMultimedia/qvideosurfaceformat.h> - -#include <QtGui/qapplication.h> - - -class tst_QVideoWidget : public QObject -{ - Q_OBJECT -private slots: - void nullObject(); - void nullService(); - void nullOutputControl(); - void noOutputs(); - void serviceDestroyed(); - void objectDestroyed(); - void setMediaObject(); - - void showWindowControl(); - void aspectRatioWindowControl(); - void sizeHintWindowControl_data() { sizeHint_data(); } - void sizeHintWindowControl(); - void brightnessWindowControl_data() { color_data(); } - void brightnessWindowControl(); - void contrastWindowControl_data() { color_data(); } - void contrastWindowControl(); - void hueWindowControl_data() { color_data(); } - void hueWindowControl(); - void saturationWindowControl_data() { color_data(); } - void saturationWindowControl(); - - void showWidgetControl(); - void aspectRatioWidgetControl(); - void sizeHintWidgetControl_data() { sizeHint_data(); } - void sizeHintWidgetControl(); - void brightnessWidgetControl_data() { color_data(); } - void brightnessWidgetControl(); - void contrastWidgetControl_data() { color_data(); } - void contrastWidgetControl(); - void hueWidgetControl_data() { color_data(); } - void hueWidgetControl(); - void saturationWidgetControl_data() { color_data(); } - void saturationWidgetControl(); - - void showRendererControl(); - void aspectRatioRendererControl(); - void sizeHintRendererControl_data(); - void sizeHintRendererControl(); - void brightnessRendererControl_data() { color_data(); } - void brightnessRendererControl(); - void contrastRendererControl_data() { color_data(); } - void contrastRendererControl(); - void hueRendererControl_data() { color_data(); } - void hueRendererControl(); - void saturationRendererControl_data() { color_data(); } - void saturationRendererControl(); - - void paintRendererControl(); - -#ifndef Q_WS_X11 - void fullScreenWindowControl(); - void fullScreenWidgetControl(); - void fullScreenRendererControl(); -#endif - -private: - void sizeHint_data(); - void color_data(); -}; - -Q_DECLARE_METATYPE(Qt::AspectRatioMode) -Q_DECLARE_METATYPE(const uchar *) - -class QtTestOutputControl : public QVideoOutputControl -{ -public: - QtTestOutputControl() : m_output(NoOutput) {} - - QList<Output> availableOutputs() const { return m_outputs; } - void setAvailableOutputs(const QList<Output> outputs) { m_outputs = outputs; } - - Output output() const { return m_output; } - virtual void setOutput(Output output) { m_output = output; } - -private: - Output m_output; - QList<Output> m_outputs; -}; - -class QtTestWindowControl : public QVideoWindowControl -{ -public: - QtTestWindowControl() - : m_winId(0) - , m_repaintCount(0) - , m_brightness(0) - , m_contrast(0) - , m_saturation(0) - , m_aspectRatioMode(Qt::KeepAspectRatio) - , m_fullScreen(0) - { - } - - WId winId() const { return m_winId; } - void setWinId(WId id) { m_winId = id; } - - QRect displayRect() const { return m_displayRect; } - void setDisplayRect(const QRect &rect) { m_displayRect = rect; } - - bool isFullScreen() const { return m_fullScreen; } - void setFullScreen(bool fullScreen) { emit fullScreenChanged(m_fullScreen = fullScreen); } - - int repaintCount() const { return m_repaintCount; } - void setRepaintCount(int count) { m_repaintCount = count; } - void repaint() { ++m_repaintCount; } - - QSize nativeSize() const { return m_nativeSize; } - void setNativeSize(const QSize &size) { m_nativeSize = size; emit nativeSizeChanged(); } - - Qt::AspectRatioMode aspectRatioMode() const { return m_aspectRatioMode; } - void setAspectRatioMode(Qt::AspectRatioMode mode) { m_aspectRatioMode = mode; } - - int brightness() const { return m_brightness; } - void setBrightness(int brightness) { emit brightnessChanged(m_brightness = brightness); } - - int contrast() const { return m_contrast; } - void setContrast(int contrast) { emit contrastChanged(m_contrast = contrast); } - - int hue() const { return m_hue; } - void setHue(int hue) { emit hueChanged(m_hue = hue); } - - int saturation() const { return m_saturation; } - void setSaturation(int saturation) { emit saturationChanged(m_saturation = saturation); } - -private: - WId m_winId; - int m_repaintCount; - int m_brightness; - int m_contrast; - int m_hue; - int m_saturation; - Qt::AspectRatioMode m_aspectRatioMode; - QRect m_displayRect; - QSize m_nativeSize; - bool m_fullScreen; -}; - -class QtTestWidgetControl : public QVideoWidgetControl -{ -public: - QtTestWidgetControl() - : m_brightness(1.0) - , m_contrast(1.0) - , m_hue(1.0) - , m_saturation(1.0) - , m_aspectRatioMode(Qt::KeepAspectRatio) - , m_fullScreen(false) - { - } - - bool isFullScreen() const { return m_fullScreen; } - void setFullScreen(bool fullScreen) { emit fullScreenChanged(m_fullScreen = fullScreen); } - - Qt::AspectRatioMode aspectRatioMode() const { return m_aspectRatioMode; } - void setAspectRatioMode(Qt::AspectRatioMode mode) { m_aspectRatioMode = mode; } - - int brightness() const { return m_brightness; } - void setBrightness(int brightness) { emit brightnessChanged(m_brightness = brightness); } - - int contrast() const { return m_contrast; } - void setContrast(int contrast) { emit contrastChanged(m_contrast = contrast); } - - int hue() const { return m_hue; } - void setHue(int hue) { emit hueChanged(m_hue = hue); } - - int saturation() const { return m_saturation; } - void setSaturation(int saturation) { emit saturationChanged(m_saturation = saturation); } - - void setSizeHint(const QSize &size) { m_widget.setSizeHint(size); } - - QWidget *videoWidget() { return &m_widget; } - -private: - class Widget : public QWidget - { - public: - QSize sizeHint() const { return m_sizeHint; } - void setSizeHint(const QSize &size) { m_sizeHint = size; updateGeometry(); } - private: - QSize m_sizeHint; - } m_widget; - int m_brightness; - int m_contrast; - int m_hue; - int m_saturation; - Qt::AspectRatioMode m_aspectRatioMode; - QSize m_sizeHint; - bool m_fullScreen; -}; - -class QtTestRendererControl : public QVideoRendererControl -{ -public: - QtTestRendererControl() - : m_surface(0) - { - } - - QAbstractVideoSurface *surface() const { return m_surface; } - void setSurface(QAbstractVideoSurface *surface) { m_surface = surface; } - -private: - QAbstractVideoSurface *m_surface; -}; - -class QtTestVideoService : public QMediaService -{ - Q_OBJECT -public: - QtTestVideoService( - QtTestOutputControl *output, - QtTestWindowControl *window, - QtTestWidgetControl *widget, - QtTestRendererControl *renderer) - : QMediaService(0) - , outputControl(output) - , windowControl(window) - , widgetControl(widget) - , rendererControl(renderer) - { - } - - ~QtTestVideoService() - { - delete outputControl; - delete windowControl; - delete widgetControl; - delete rendererControl; - } - - QMediaControl *control(const char *name) const - { - if (qstrcmp(name, QVideoOutputControl_iid) == 0) - return outputControl; - else if (qstrcmp(name, QVideoWindowControl_iid) == 0) - return windowControl; - else if (qstrcmp(name, QVideoWidgetControl_iid) == 0) - return widgetControl; - else if (qstrcmp(name, QVideoRendererControl_iid) == 0) - return rendererControl; - else - return 0; - } - - QtTestOutputControl *outputControl; - QtTestWindowControl *windowControl; - QtTestWidgetControl *widgetControl; - QtTestRendererControl *rendererControl; -}; - -class QtTestVideoObject : public QMediaObject -{ - Q_OBJECT -public: - QtTestVideoObject( - QtTestWindowControl *window, - QtTestWidgetControl *widget, - QtTestRendererControl *renderer): - QMediaObject(0, new QtTestVideoService(new QtTestOutputControl, window, widget, renderer)) - { - testService = qobject_cast<QtTestVideoService*>(service()); - QList<QVideoOutputControl::Output> outputs; - - if (window) - outputs.append(QVideoOutputControl::WindowOutput); - if (widget) - outputs.append(QVideoOutputControl::WidgetOutput); - if (renderer) - outputs.append(QVideoOutputControl::RendererOutput); - - testService->outputControl->setAvailableOutputs(outputs); - } - - QtTestVideoObject(QtTestVideoService *service): - QMediaObject(0, service), - testService(service) - { - } - - ~QtTestVideoObject() - { - delete testService; - } - - QtTestVideoService *testService; -}; - -void tst_QVideoWidget::nullObject() -{ - QVideoWidget widget; - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QVERIFY(widget.sizeHint().isEmpty()); - - widget.setFullScreen(true); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), true); - - widget.setAspectRatioMode(Qt::IgnoreAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); - - { - QSignalSpy spy(&widget, SIGNAL(brightnessChanged(int))); - - widget.setBrightness(100); - QCOMPARE(widget.brightness(), 100); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), 100); - - widget.setBrightness(100); - QCOMPARE(widget.brightness(), 100); - QCOMPARE(spy.count(), 1); - - widget.setBrightness(-120); - QCOMPARE(widget.brightness(), -100); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), -100); - } { - QSignalSpy spy(&widget, SIGNAL(contrastChanged(int))); - - widget.setContrast(100); - QCOMPARE(widget.contrast(), 100); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), 100); - - widget.setContrast(100); - QCOMPARE(widget.contrast(), 100); - QCOMPARE(spy.count(), 1); - - widget.setContrast(-120); - QCOMPARE(widget.contrast(), -100); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), -100); - } { - QSignalSpy spy(&widget, SIGNAL(hueChanged(int))); - - widget.setHue(100); - QCOMPARE(widget.hue(), 100); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), 100); - - widget.setHue(100); - QCOMPARE(widget.hue(), 100); - QCOMPARE(spy.count(), 1); - - widget.setHue(-120); - QCOMPARE(widget.hue(), -100); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), -100); - } { - QSignalSpy spy(&widget, SIGNAL(saturationChanged(int))); - - widget.setSaturation(100); - QCOMPARE(widget.saturation(), 100); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), 100); - - widget.setSaturation(100); - QCOMPARE(widget.saturation(), 100); - QCOMPARE(spy.count(), 1); - - widget.setSaturation(-120); - QCOMPARE(widget.saturation(), -100); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), -100); - } -} - -void tst_QVideoWidget::nullService() -{ - QtTestVideoObject object(0); - - QVideoWidget widget; - widget.setMediaObject(&object); - - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QVERIFY(widget.sizeHint().isEmpty()); - - widget.setFullScreen(true); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), true); - - widget.setAspectRatioMode(Qt::IgnoreAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); - - widget.setBrightness(100); - QCOMPARE(widget.brightness(), 100); - - widget.setContrast(100); - QCOMPARE(widget.contrast(), 100); - - widget.setHue(100); - QCOMPARE(widget.hue(), 100); - - widget.setSaturation(100); - QCOMPARE(widget.saturation(), 100); -} - -void tst_QVideoWidget::nullOutputControl() -{ - QtTestVideoObject object(new QtTestVideoService(0, 0, 0, 0)); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QVERIFY(widget.sizeHint().isEmpty()); - - widget.setFullScreen(true); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), true); - - widget.setBrightness(100); - QCOMPARE(widget.brightness(), 100); - - widget.setContrast(100); - QCOMPARE(widget.contrast(), 100); - - widget.setHue(100); - QCOMPARE(widget.hue(), 100); - - widget.setSaturation(100); - QCOMPARE(widget.saturation(), 100); -} - -void tst_QVideoWidget::noOutputs() -{ - QtTestVideoObject object(0, 0, 0); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QVERIFY(widget.sizeHint().isEmpty()); - - widget.setFullScreen(true); - QCOMPARE(widget.isFullScreen(), true); - - widget.setBrightness(100); - QCOMPARE(widget.brightness(), 100); - - widget.setContrast(100); - QCOMPARE(widget.contrast(), 100); - - widget.setHue(100); - QCOMPARE(widget.hue(), 100); - - widget.setSaturation(100); - QCOMPARE(widget.saturation(), 100); -} - -void tst_QVideoWidget::serviceDestroyed() -{ - QtTestVideoObject object(new QtTestWindowControl, new QtTestWidgetControl, 0); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - widget.setBrightness(100); - widget.setContrast(100); - widget.setHue(100); - widget.setSaturation(100); - - delete object.testService; - object.testService = 0; - - QCOMPARE(widget.mediaObject(), static_cast<QMediaObject *>(&object)); - - QCOMPARE(widget.brightness(), 100); - QCOMPARE(widget.contrast(), 100); - QCOMPARE(widget.hue(), 100); - QCOMPARE(widget.saturation(), 100); - - widget.setFullScreen(true); - QCOMPARE(widget.isFullScreen(), true); -} - -void tst_QVideoWidget::objectDestroyed() -{ - QtTestVideoObject *object = new QtTestVideoObject( - new QtTestWindowControl, - new QtTestWidgetControl, - 0); - - QVideoWidget widget; - widget.setMediaObject(object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - widget.setBrightness(100); - widget.setContrast(100); - widget.setHue(100); - widget.setSaturation(100); - - // Delete the media object without deleting the service. - QtTestVideoService *service = object->testService; - object->testService = 0; - - delete object; - object = 0; - - QCOMPARE(widget.mediaObject(), static_cast<QMediaObject *>(object)); - - QCOMPARE(service->outputControl->output(), QVideoOutputControl::NoOutput); - - QCOMPARE(widget.brightness(), 100); - QCOMPARE(widget.contrast(), 100); - QCOMPARE(widget.hue(), 100); - QCOMPARE(widget.saturation(), 100); - - widget.setFullScreen(true); - QCOMPARE(widget.isFullScreen(), true); - - delete service; -} - -void tst_QVideoWidget::setMediaObject() -{ - QMediaObject *nullObject = 0; - QtTestVideoObject windowObject(new QtTestWindowControl, 0, 0); - QtTestVideoObject widgetObject(0, new QtTestWidgetControl, 0); - QtTestVideoObject rendererObject(0, 0, new QtTestRendererControl); - - QVideoWidget widget; - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QCOMPARE(widget.mediaObject(), nullObject); - QCOMPARE(windowObject.testService->outputControl->output(), QVideoOutputControl::NoOutput); - QCOMPARE(widgetObject.testService->outputControl->output(), QVideoOutputControl::NoOutput); - QCOMPARE(rendererObject.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - widget.setMediaObject(&windowObject); - QCOMPARE(widget.mediaObject(), static_cast<QMediaObject *>(&windowObject)); - QCOMPARE(windowObject.testService->outputControl->output(), QVideoOutputControl::WindowOutput); - QVERIFY(windowObject.testService->windowControl->winId() != 0); - - - widget.setMediaObject(&widgetObject); - QCOMPARE(widget.mediaObject(), static_cast<QMediaObject *>(&widgetObject)); - QCOMPARE(widgetObject.testService->outputControl->output(), QVideoOutputControl::WidgetOutput); - - QCoreApplication::processEvents(QEventLoop::AllEvents); - QCOMPARE(widgetObject.testService->widgetControl->videoWidget()->isVisible(), true); - - QCOMPARE(windowObject.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - widget.setMediaObject(&rendererObject); - QCOMPARE(widget.mediaObject(), static_cast<QMediaObject *>(&rendererObject)); - QCOMPARE(rendererObject.testService->outputControl->output(), QVideoOutputControl::RendererOutput); - QVERIFY(rendererObject.testService->rendererControl->surface() != 0); - - QCOMPARE(widgetObject.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - widget.setMediaObject(0); - QCOMPARE(widget.mediaObject(), nullObject); - - QCOMPARE(rendererObject.testService->outputControl->output(), QVideoOutputControl::NoOutput); -} - -void tst_QVideoWidget::showWindowControl() -{ - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - object.testService->windowControl->setNativeSize(QSize(240, 180)); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::WindowOutput); - QVERIFY(object.testService->windowControl->winId() != 0); - - QVERIFY(object.testService->windowControl->repaintCount() > 0); - - widget.resize(640, 480); - QCOMPARE(object.testService->windowControl->displayRect(), QRect(0, 0, 640, 480)); - - widget.move(10, 10); - QCOMPARE(object.testService->windowControl->displayRect(), QRect(0, 0, 640, 480)); - - widget.hide(); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::WindowOutput); -} - -void tst_QVideoWidget::showWidgetControl() -{ - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::WidgetOutput); - QCOMPARE(object.testService->widgetControl->videoWidget()->isVisible(), true); - - widget.resize(640, 480); - - widget.move(10, 10); - - widget.hide(); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::WidgetOutput); - QCOMPARE(object.testService->widgetControl->videoWidget()->isVisible(), false); -} - -void tst_QVideoWidget::showRendererControl() -{ - QtTestVideoObject object(0, 0, new QtTestRendererControl); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::NoOutput); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::RendererOutput); - QVERIFY(object.testService->rendererControl->surface() != 0); - - widget.resize(640, 480); - - widget.move(10, 10); - - widget.hide(); - - QCOMPARE(object.testService->outputControl->output(), QVideoOutputControl::RendererOutput); -} - -void tst_QVideoWidget::aspectRatioWindowControl() -{ - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - object.testService->windowControl->setAspectRatioMode(Qt::IgnoreAspectRatio); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - // Test the aspect ratio defaults to keeping the aspect ratio. - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - - // Test the control has been informed of the aspect ratio change, post show. - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - QCOMPARE(object.testService->windowControl->aspectRatioMode(), Qt::KeepAspectRatio); - - // Test an aspect ratio change is enforced immediately while visible. - widget.setAspectRatioMode(Qt::IgnoreAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); - QCOMPARE(object.testService->windowControl->aspectRatioMode(), Qt::IgnoreAspectRatio); - - // Test an aspect ratio set while not visible is respected. - widget.hide(); - widget.setAspectRatioMode(Qt::KeepAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - widget.show(); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - QCOMPARE(object.testService->windowControl->aspectRatioMode(), Qt::KeepAspectRatio); -} - -void tst_QVideoWidget::aspectRatioWidgetControl() -{ - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - object.testService->widgetControl->setAspectRatioMode(Qt::IgnoreAspectRatio); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - // Test the aspect ratio defaults to keeping the aspect ratio. - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - - // Test the control has been informed of the aspect ratio change, post show. - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - QCOMPARE(object.testService->widgetControl->aspectRatioMode(), Qt::KeepAspectRatio); - - // Test an aspect ratio change is enforced immediately while visible. - widget.setAspectRatioMode(Qt::IgnoreAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); - QCOMPARE(object.testService->widgetControl->aspectRatioMode(), Qt::IgnoreAspectRatio); - - // Test an aspect ratio set while not visible is respected. - widget.hide(); - widget.setAspectRatioMode(Qt::KeepAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - widget.show(); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - QCOMPARE(object.testService->widgetControl->aspectRatioMode(), Qt::KeepAspectRatio); -} - -void tst_QVideoWidget::aspectRatioRendererControl() -{ - QtTestVideoObject object(0, 0, new QtTestRendererControl); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - // Test the aspect ratio defaults to keeping the aspect ratio. - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - - // Test the control has been informed of the aspect ratio change, post show. - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - - // Test an aspect ratio change is enforced immediately while visible. - widget.setAspectRatioMode(Qt::IgnoreAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); - - // Test an aspect ratio set while not visible is respected. - widget.hide(); - widget.setAspectRatioMode(Qt::KeepAspectRatio); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); - widget.show(); - QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); -} - -void tst_QVideoWidget::sizeHint_data() -{ - QTest::addColumn<QSize>("size"); - - QTest::newRow("720x576") - << QSize(720, 576); -} - -void tst_QVideoWidget::sizeHintWindowControl() -{ - QFETCH(QSize, size); - - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QVERIFY(widget.sizeHint().isEmpty()); - - object.testService->windowControl->setNativeSize(size); - QCOMPARE(widget.sizeHint(), size); -} - -void tst_QVideoWidget::sizeHintWidgetControl() -{ - QFETCH(QSize, size); - - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QVERIFY(widget.sizeHint().isEmpty()); - - object.testService->widgetControl->setSizeHint(size); - QCOMPARE(widget.sizeHint(), size); -} - -void tst_QVideoWidget::sizeHintRendererControl_data() -{ - QTest::addColumn<QSize>("frameSize"); - QTest::addColumn<QRect>("viewport"); - QTest::addColumn<QSize>("pixelAspectRatio"); - QTest::addColumn<QSize>("expectedSize"); - - QTest::newRow("640x480") - << QSize(640, 480) - << QRect(0, 0, 640, 480) - << QSize(1, 1) - << QSize(640, 480); - - QTest::newRow("800x600, (80,60, 640x480) viewport") - << QSize(800, 600) - << QRect(80, 60, 640, 480) - << QSize(1, 1) - << QSize(640, 480); - - QTest::newRow("800x600, (80,60, 640x480) viewport, 4:3") - << QSize(800, 600) - << QRect(80, 60, 640, 480) - << QSize(4, 3) - << QSize(853, 480); - -} - -void tst_QVideoWidget::sizeHintRendererControl() -{ - QFETCH(QSize, frameSize); - QFETCH(QRect, viewport); - QFETCH(QSize, pixelAspectRatio); - QFETCH(QSize, expectedSize); - - QtTestVideoObject object(0, 0, new QtTestRendererControl); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_ARGB32); - format.setViewport(viewport); - format.setPixelAspectRatio(pixelAspectRatio); - - QVERIFY(object.testService->rendererControl->surface()->start(format)); - - QCOMPARE(widget.sizeHint(), expectedSize); -} - -#ifndef Q_WS_X11 - -void tst_QVideoWidget::fullScreenWindowControl() -{ - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - Qt::WindowFlags windowFlags = widget.windowFlags(); - - QSignalSpy spy(&widget, SIGNAL(fullScreenChanged(bool))); - - // Test showing full screen with setFullScreen(true). - widget.setFullScreen(true); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->windowControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toBool(), true); - - // Test returning to normal with setFullScreen(false). - widget.setFullScreen(false); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->windowControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toBool(), false); - QCOMPARE(widget.windowFlags(), windowFlags); - - // Test showing full screen with showFullScreen(). - widget.showFullScreen(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->windowControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 3); - QCOMPARE(spy.value(2).value(0).toBool(), true); - - // Test returning to normal with showNormal(). - widget.showNormal(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->windowControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - QCOMPARE(spy.value(3).value(0).toBool(), false); - QCOMPARE(widget.windowFlags(), windowFlags); - - // Test setFullScreen(false) and showNormal() do nothing when isFullScreen() == false. - widget.setFullScreen(false); - QCOMPARE(object.testService->windowControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - widget.showNormal(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->windowControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - - // Test setFullScreen(true) and showFullScreen() do nothing when isFullScreen() == true. - widget.showFullScreen(); - QTest::qWaitForWindowShown(&widget); - widget.setFullScreen(true); - QCOMPARE(object.testService->windowControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 5); - widget.showFullScreen(); - QCOMPARE(object.testService->windowControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 5); - - // Test if the window control exits full screen mode, the widget follows suit. - object.testService->windowControl->setFullScreen(false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 6); - QCOMPARE(spy.value(5).value(0).toBool(), false); - - // Test if the window control enters full screen mode, the widget does nothing. - object.testService->windowControl->setFullScreen(false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 6); -} - -void tst_QVideoWidget::fullScreenWidgetControl() -{ - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - Qt::WindowFlags windowFlags = widget.windowFlags(); - - QSignalSpy spy(&widget, SIGNAL(fullScreenChanged(bool))); - - // Test showing full screen with setFullScreen(true). - widget.setFullScreen(true); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->widgetControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toBool(), true); - - // Test returning to normal with setFullScreen(false). - widget.setFullScreen(false); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->widgetControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toBool(), false); - QCOMPARE(widget.windowFlags(), windowFlags); - - // Test showing full screen with showFullScreen(). - widget.showFullScreen(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->widgetControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 3); - QCOMPARE(spy.value(2).value(0).toBool(), true); - - // Test returning to normal with showNormal(). - widget.showNormal(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(object.testService->widgetControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - QCOMPARE(spy.value(3).value(0).toBool(), false); - QCOMPARE(widget.windowFlags(), windowFlags); - - // Test setFullScreen(false) and showNormal() do nothing when isFullScreen() == false. - widget.setFullScreen(false); - QCOMPARE(object.testService->widgetControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - widget.showNormal(); - QCOMPARE(object.testService->widgetControl->isFullScreen(), false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - - // Test setFullScreen(true) and showFullScreen() do nothing when isFullScreen() == true. - widget.showFullScreen(); - QTest::qWaitForWindowShown(&widget); - widget.setFullScreen(true); - QCOMPARE(object.testService->widgetControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 5); - widget.showFullScreen(); - QCOMPARE(object.testService->widgetControl->isFullScreen(), true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 5); - - // Test if the window control exits full screen mode, the widget follows suit. - object.testService->widgetControl->setFullScreen(false); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 6); - QCOMPARE(spy.value(5).value(0).toBool(), false); - - // Test if the window control enters full screen mode, the widget does nothing. - object.testService->widgetControl->setFullScreen(false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 6); -} - - -void tst_QVideoWidget::fullScreenRendererControl() -{ - QtTestVideoObject object(0, 0, new QtTestRendererControl); - QVideoWidget widget; - widget.setMediaObject(&object); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - Qt::WindowFlags windowFlags = widget.windowFlags(); - - QSignalSpy spy(&widget, SIGNAL(fullScreenChanged(bool))); - - // Test showing full screen with setFullScreen(true). - widget.setFullScreen(true); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toBool(), true); - - // Test returning to normal with setFullScreen(false). - widget.setFullScreen(false); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toBool(), false); - QCOMPARE(widget.windowFlags(), windowFlags); - - // Test showing full screen with showFullScreen(). - widget.showFullScreen(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 3); - QCOMPARE(spy.value(2).value(0).toBool(), true); - - // Test returning to normal with showNormal(). - widget.showNormal(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - QCOMPARE(spy.value(3).value(0).toBool(), false); - QCOMPARE(widget.windowFlags(), windowFlags); - - // Test setFullScreen(false) and showNormal() do nothing when isFullScreen() == false. - widget.setFullScreen(false); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - widget.showNormal(); - QCOMPARE(widget.isFullScreen(), false); - QCOMPARE(spy.count(), 4); - - // Test setFullScreen(true) and showFullScreen() do nothing when isFullScreen() == true. - widget.showFullScreen(); - QTest::qWaitForWindowShown(&widget); - widget.setFullScreen(true); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 5); - widget.showFullScreen(); - QCOMPARE(widget.isFullScreen(), true); - QCOMPARE(spy.count(), 5); -} - -#endif - -void tst_QVideoWidget::color_data() -{ - QTest::addColumn<int>("controlValue"); - QTest::addColumn<int>("value"); - QTest::addColumn<int>("expectedValue"); - - QTest::newRow("12") - << 0 - << 12 - << 12; - QTest::newRow("-56") - << 87 - << -56 - << -56; - QTest::newRow("100") - << 32 - << 100 - << 100; - QTest::newRow("1294") - << 0 - << 1294 - << 100; - QTest::newRow("-102") - << 34 - << -102 - << -100; -} - -void tst_QVideoWidget::brightnessWindowControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - object.testService->windowControl->setBrightness(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - // Test the video widget resets the controls starting brightness to the default. - QCOMPARE(widget.brightness(), 0); - - QSignalSpy spy(&widget, SIGNAL(brightnessChanged(int))); - - // Test the video widget sets the brightness value, bounded if necessary and emits a changed - // signal. - widget.setBrightness(value); - QCOMPARE(widget.brightness(), expectedValue); - QCOMPARE(object.testService->windowControl->brightness(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - // Test the changed signal isn't emitted if the value is unchanged. - widget.setBrightness(value); - QCOMPARE(widget.brightness(), expectedValue); - QCOMPARE(object.testService->windowControl->brightness(), expectedValue); - QCOMPARE(spy.count(), 1); - - // Test the changed signal is emitted if the brightness is changed internally. - object.testService->windowControl->setBrightness(controlValue); - QCOMPARE(widget.brightness(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); -} - -void tst_QVideoWidget::brightnessWidgetControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - object.testService->widgetControl->setBrightness(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QCOMPARE(widget.brightness(), 0); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QSignalSpy spy(&widget, SIGNAL(brightnessChanged(int))); - - widget.setBrightness(value); - QCOMPARE(widget.brightness(), expectedValue); - QCOMPARE(object.testService->widgetControl->brightness(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setBrightness(value); - QCOMPARE(widget.brightness(), expectedValue); - QCOMPARE(object.testService->widgetControl->brightness(), expectedValue); - QCOMPARE(spy.count(), 1); - - object.testService->widgetControl->setBrightness(controlValue); - QCOMPARE(widget.brightness(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); -} - -void tst_QVideoWidget::brightnessRendererControl() -{ - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, 0, new QtTestRendererControl); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QSignalSpy spy(&widget, SIGNAL(brightnessChanged(int))); - - widget.setBrightness(value); - QCOMPARE(widget.brightness(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setBrightness(value); - QCOMPARE(widget.brightness(), expectedValue); - QCOMPARE(spy.count(), 1); -} - -void tst_QVideoWidget::contrastWindowControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - object.testService->windowControl->setContrast(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QCOMPARE(widget.contrast(), 0); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.contrast(), 0); - - QSignalSpy spy(&widget, SIGNAL(contrastChanged(int))); - - widget.setContrast(value); - QCOMPARE(widget.contrast(), expectedValue); - QCOMPARE(object.testService->windowControl->contrast(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setContrast(value); - QCOMPARE(widget.contrast(), expectedValue); - QCOMPARE(object.testService->windowControl->contrast(), expectedValue); - QCOMPARE(spy.count(), 1); - - object.testService->windowControl->setContrast(controlValue); - QCOMPARE(widget.contrast(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); -} - -void tst_QVideoWidget::contrastWidgetControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - object.testService->widgetControl->setContrast(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - QCOMPARE(widget.contrast(), 0); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.contrast(), 0); - - QSignalSpy spy(&widget, SIGNAL(contrastChanged(int))); - - widget.setContrast(value); - QCOMPARE(widget.contrast(), expectedValue); - QCOMPARE(object.testService->widgetControl->contrast(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setContrast(value); - QCOMPARE(widget.contrast(), expectedValue); - QCOMPARE(object.testService->widgetControl->contrast(), expectedValue); - QCOMPARE(spy.count(), 1); - - object.testService->widgetControl->setContrast(controlValue); - QCOMPARE(widget.contrast(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); -} - -void tst_QVideoWidget::contrastRendererControl() -{ - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, 0, new QtTestRendererControl); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QSignalSpy spy(&widget, SIGNAL(contrastChanged(int))); - - widget.setContrast(value); - QCOMPARE(widget.contrast(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setContrast(value); - QCOMPARE(widget.contrast(), expectedValue); - QCOMPARE(spy.count(), 1); -} - -void tst_QVideoWidget::hueWindowControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - object.testService->windowControl->setHue(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - QCOMPARE(widget.hue(), 0); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.hue(), 0); - - QSignalSpy spy(&widget, SIGNAL(hueChanged(int))); - - widget.setHue(value); - QCOMPARE(widget.hue(), expectedValue); - QCOMPARE(object.testService->windowControl->hue(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setHue(value); - QCOMPARE(widget.hue(), expectedValue); - QCOMPARE(object.testService->windowControl->hue(), expectedValue); - QCOMPARE(spy.count(), 1); - - object.testService->windowControl->setHue(controlValue); - QCOMPARE(widget.hue(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); -} - -void tst_QVideoWidget::hueWidgetControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - object.testService->widgetControl->setHue(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - QCOMPARE(widget.hue(), 0); - - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.hue(), 0); - - QSignalSpy spy(&widget, SIGNAL(hueChanged(int))); - - widget.setHue(value); - QCOMPARE(widget.hue(), expectedValue); - QCOMPARE(object.testService->widgetControl->hue(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setHue(value); - QCOMPARE(widget.hue(), expectedValue); - QCOMPARE(object.testService->widgetControl->hue(), expectedValue); - QCOMPARE(spy.count(), 1); - - object.testService->widgetControl->setHue(controlValue); - QCOMPARE(widget.hue(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); -} - -void tst_QVideoWidget::hueRendererControl() -{ - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, 0, new QtTestRendererControl); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QSignalSpy spy(&widget, SIGNAL(hueChanged(int))); - - widget.setHue(value); - QCOMPARE(widget.hue(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setHue(value); - QCOMPARE(widget.hue(), expectedValue); - QCOMPARE(spy.count(), 1); -} - -void tst_QVideoWidget::saturationWindowControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(new QtTestWindowControl, 0, 0); - object.testService->windowControl->setSaturation(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - QCOMPARE(widget.saturation(), 0); - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.saturation(), 0); - - QSignalSpy spy(&widget, SIGNAL(saturationChanged(int))); - - widget.setSaturation(value); - QCOMPARE(widget.saturation(), expectedValue); - QCOMPARE(object.testService->windowControl->saturation(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setSaturation(value); - QCOMPARE(widget.saturation(), expectedValue); - QCOMPARE(object.testService->windowControl->saturation(), expectedValue); - QCOMPARE(spy.count(), 1); - - object.testService->windowControl->setSaturation(controlValue); - QCOMPARE(widget.saturation(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); -} - -void tst_QVideoWidget::saturationWidgetControl() -{ - QFETCH(int, controlValue); - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, new QtTestWidgetControl, 0); - object.testService->widgetControl->setSaturation(controlValue); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - - QCOMPARE(widget.saturation(), 0); - widget.show(); - QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.saturation(), 0); - - QSignalSpy spy(&widget, SIGNAL(saturationChanged(int))); - - widget.setSaturation(value); - QCOMPARE(widget.saturation(), expectedValue); - QCOMPARE(object.testService->widgetControl->saturation(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setSaturation(value); - QCOMPARE(widget.saturation(), expectedValue); - QCOMPARE(object.testService->widgetControl->saturation(), expectedValue); - QCOMPARE(spy.count(), 1); - - object.testService->widgetControl->setSaturation(controlValue); - QCOMPARE(widget.saturation(), controlValue); - QCOMPARE(spy.count(), 2); - QCOMPARE(spy.value(1).value(0).toInt(), controlValue); - -} - -void tst_QVideoWidget::saturationRendererControl() -{ - QFETCH(int, value); - QFETCH(int, expectedValue); - - QtTestVideoObject object(0, 0, new QtTestRendererControl); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - QSignalSpy spy(&widget, SIGNAL(saturationChanged(int))); - - widget.setSaturation(value); - QCOMPARE(widget.saturation(), expectedValue); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.value(0).value(0).toInt(), expectedValue); - - widget.setSaturation(value); - QCOMPARE(widget.saturation(), expectedValue); - QCOMPARE(spy.count(), 1); -} - -static const uchar rgb32ImageData[] = -{ - 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, - 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00 -}; - -void tst_QVideoWidget::paintRendererControl() -{ - QtTestVideoObject object(0, 0, new QtTestRendererControl); - - QVideoWidget widget; - widget.setMediaObject(&object); - widget.setWindowFlags(Qt::X11BypassWindowManagerHint); - widget.show(); - QTest::qWaitForWindowShown(&widget); - - QPainterVideoSurface *surface = qobject_cast<QPainterVideoSurface *>( - object.testService->rendererControl->surface()); - - QVideoSurfaceFormat format(QSize(2, 2), QVideoFrame::Format_RGB32); - - QVERIFY(surface->start(format)); - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), true); - - QCoreApplication::processEvents(QEventLoop::AllEvents); - - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), true); - - QVideoFrame frame(sizeof(rgb32ImageData), QSize(2, 2), 8, QVideoFrame::Format_RGB32); - - frame.map(QAbstractVideoBuffer::WriteOnly); - memcpy(frame.bits(), rgb32ImageData, frame.mappedBytes()); - frame.unmap(); - - QVERIFY(surface->present(frame)); - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), false); - - //wait up to 2 seconds for the frame to be presented - for (int i=0; i<200 && !surface->isReady(); i++) - QTest::qWait(10); - - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), true); -} - -QTEST_MAIN(tst_QVideoWidget) - -#include "tst_qvideowidget.moc" diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 76e20b9..5d47aed 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -9514,6 +9514,8 @@ void tst_QWidget::destroyBackingStore() w.update(); QApplication::processEvents(); QCOMPARE(w.numPaintEvents, 2); +#else + QSKIP("Test case relies on developer build (AUTOTEST_EXPORT)", SkipAll); #endif } @@ -9992,6 +9994,7 @@ void tst_QWidget::focusProxyAndInputMethods() delete toplevel; } +#ifdef QT_BUILD_INTERNAL class scrollWidgetWBS : public QWidget { public: @@ -10011,9 +10014,11 @@ public: } } }; +#endif void tst_QWidget::scrollWithoutBackingStore() { +#ifdef QT_BUILD_INTERNAL scrollWidgetWBS scrollable; scrollable.resize(100,100); QLabel child(QString("@"),&scrollable); @@ -10027,6 +10032,9 @@ void tst_QWidget::scrollWithoutBackingStore() QCOMPARE(child.pos(),QPoint(25,25)); scrollable.enableBackingStore(); QCOMPARE(child.pos(),QPoint(25,25)); +#else + QSKIP("Test case relies on developer build (AUTOTEST_EXPORT)", SkipAll); +#endif } void tst_QWidget::taskQTBUG_7532_tabOrderWithFocusProxy() diff --git a/tests/auto/qwidgetaction/tst_qwidgetaction.cpp b/tests/auto/qwidgetaction/tst_qwidgetaction.cpp index 5dfcd43..53dc4b5 100644 --- a/tests/auto/qwidgetaction/tst_qwidgetaction.cpp +++ b/tests/auto/qwidgetaction/tst_qwidgetaction.cpp @@ -51,6 +51,8 @@ #include <qmainwindow.h> #include <qmenubar.h> +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES= @@ -190,8 +192,8 @@ void tst_QWidgetAction::visibilityUpdate() QVERIFY(action->isVisible()); action->setVisible(false); - QTest::qWait(100); //the call to hide is delayed by the toolbar layout - QVERIFY(!combo->isVisible()); + qApp->processEvents(); //the call to hide is delayed by the toolbar layout + QTRY_VERIFY(!combo->isVisible()); delete action; // action also deletes combo diff --git a/tests/auto/qxmlquery/tst_qxmlquery.cpp b/tests/auto/qxmlquery/tst_qxmlquery.cpp index be0d708..6fd9b93 100644 --- a/tests/auto/qxmlquery/tst_qxmlquery.cpp +++ b/tests/auto/qxmlquery/tst_qxmlquery.cpp @@ -857,7 +857,7 @@ void tst_QXmlQuery::bindVariableXSLTSuccess() const stylesheet.bindVariable(QLatin1String("paramSelectWithTypeIntBoundWithBindVariableRequired"), QVariant(QLatin1String("param5"))); - stylesheet.setQuery(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/parameters.xsl")))); + stylesheet.setQuery(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/parameters.xsl")))); QVERIFY(stylesheet.isValid()); @@ -1798,11 +1798,11 @@ void tst_QXmlQuery::setFocusQUrl() const { QXmlQuery query(QXmlQuery::XSLT20); - const TestURIResolver resolver(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); + const TestURIResolver resolver(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); query.setUriResolver(&resolver); QVERIFY(query.setFocus(QUrl(QLatin1String("arbitraryURI")))); - query.setQuery(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/copyWholeDocument.xsl")))); + query.setQuery(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/copyWholeDocument.xsl")))); QVERIFY(query.isValid()); QBuffer result; @@ -2997,7 +2997,7 @@ void tst_QXmlQuery::setInitialTemplateNameQXmlName() const QCOMPARE(query.initialTemplateName(), name); - query.setQuery(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/namedTemplate.xsl")))); + query.setQuery(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/namedTemplate.xsl")))); QVERIFY(query.isValid()); QBuffer result; @@ -3059,7 +3059,7 @@ void tst_QXmlQuery::setNetworkAccessManager() const /* Ensure fn:doc() picks up the right QNetworkAccessManager. */ { NetworkOverrider networkOverrider(QUrl(QLatin1String("tag:example.com:DOESNOTEXIST")), - QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/queries/simpleDocument.xml")))); + QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/queries/simpleDocument.xml")))); QXmlQuery query; query.setNetworkAccessManager(&networkOverrider); @@ -3075,7 +3075,7 @@ void tst_QXmlQuery::setNetworkAccessManager() const /* Ensure setQuery() is using the right network manager. */ { NetworkOverrider networkOverrider(QUrl(QLatin1String("tag:example.com:DOESNOTEXIST")), - QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/queries/concat.xq")))); + QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/queries/concat.xq")))); QXmlQuery query; query.setNetworkAccessManager(&networkOverrider); @@ -3135,7 +3135,7 @@ void tst_QXmlQuery::multipleDocsAndFocus() const query.setQuery(QLatin1String("string(doc('") + inputFile(QLatin1String(SRCDIR "../xmlpatterns/queries/simpleDocument.xml")) + QLatin1String("'))")); - query.setFocus(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); + query.setFocus(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); query.setQuery(QLatin1String("string(.)")); QStringList result; @@ -3159,11 +3159,11 @@ void tst_QXmlQuery::multipleEvaluationsWithDifferentFocus() const QXmlQuery query; QStringList result; - query.setFocus(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); + query.setFocus(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); query.setQuery(QLatin1String("string(.)")); QVERIFY(query.evaluateTo(&result)); - query.setFocus(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); + query.setFocus(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml")))); QVERIFY(query.evaluateTo(&result)); } diff --git a/tests/auto/xmlpatterns.pro b/tests/auto/xmlpatterns.pro index 923f2c4..b9244d6 100644 --- a/tests/auto/xmlpatterns.pro +++ b/tests/auto/xmlpatterns.pro @@ -36,6 +36,7 @@ SUBDIRS=\ xmlpatternsdiagnosticsts.depends = xmlpatternssdk xmlpatternsview.depends = xmlpatternssdk xmlpatternsxslts.depends = xmlpatternssdk +xmlpatternsxqts.depends = xmlpatternssdk xmlpatternsschemats.depends = xmlpatternssdk xmlpatternsxqts.depends = xmlpatternssdk diff --git a/tests/auto/xmlpatternsxqts/tst_suitetest.cpp b/tests/auto/xmlpatternsxqts/tst_suitetest.cpp index 64120c7..ec63858 100644 --- a/tests/auto/xmlpatternsxqts/tst_suitetest.cpp +++ b/tests/auto/xmlpatternsxqts/tst_suitetest.cpp @@ -89,10 +89,17 @@ void tst_SuiteTest::runTestSuite() const TestSuite::SuiteType suiteType; switch (m_suiteType) { - case XQuerySuite: suiteType = TestSuite::XQuerySuite; - case XsltSuite: suiteType = TestSuite::XsltSuite; - case XsdSuite: suiteType = TestSuite::XsdSuite; - default: break; + case XQuerySuite: + suiteType = TestSuite::XQuerySuite; + break; + case XsltSuite: + suiteType = TestSuite::XsltSuite; + break; + case XsdSuite: + suiteType = TestSuite::XsdSuite; + break; + default: + break; } TestSuite *const ts = TestSuite::openCatalog(catalogPath, errMsg, true, suiteType); |