summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-02-20 08:04:29 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-02-20 08:04:29 (GMT)
commit30b45ba2b11342a9e7cc06b68237b68a68955213 (patch)
tree1018c188375b3217b31abe9b7a0883ee1184a447 /tests
parentce27cf24539e0c7971937e55d8539496ad51ee52 (diff)
parent8f10ca802dee1ed110f301191c4a56a85575033c (diff)
downloadQt-30b45ba2b11342a9e7cc06b68237b68a68955213.zip
Qt-30b45ba2b11342a9e7cc06b68237b68a68955213.tar.gz
Qt-30b45ba2b11342a9e7cc06b68237b68a68955213.tar.bz2
Merge remote branch 'origin/master' into qt-master-from-4.6
Conflicts: configure.exe src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp src/opengl/qgl.cpp
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/auto.pro17
-rw-r--r--tests/auto/declarative/declarative.pro7
-rw-r--r--tests/auto/declarative/layouts/tst_layouts.cpp26
-rw-r--r--tests/auto/declarative/qmlanimations/data/badtype4.qml4
-rw-r--r--tests/auto/declarative/qmlanimations/data/dontAutoStart.qml18
-rw-r--r--tests/auto/declarative/qmlanimations/data/dontStart.qml19
-rw-r--r--tests/auto/declarative/qmlanimations/data/dontStart2.qml19
-rw-r--r--tests/auto/declarative/qmlanimations/data/dotproperty.qml2
-rw-r--r--tests/auto/declarative/qmlanimations/data/mixedtype1.qml2
-rw-r--r--tests/auto/declarative/qmlanimations/data/mixedtype2.qml2
-rw-r--r--tests/auto/declarative/qmlanimations/data/properties2.qml2
-rw-r--r--tests/auto/declarative/qmlanimations/data/properties5.qml2
-rw-r--r--tests/auto/declarative/qmlanimations/data/propertiesTransition.qml2
-rw-r--r--tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml2
-rw-r--r--tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml2
-rw-r--r--tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml2
-rw-r--r--tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml2
-rw-r--r--tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp125
-rw-r--r--tests/auto/declarative/qmlbehaviors/data/dontStart.qml18
-rw-r--r--tests/auto/declarative/qmlbehaviors/data/explicit.qml (renamed from tests/auto/declarative/qmlbehaviors/data/nonSelecting.qml)0
-rw-r--r--tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml2
-rw-r--r--tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp54
-rw-r--r--tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp12
-rw-r--r--tests/auto/declarative/qmldebug/tst_qmldebug.cpp40
-rw-r--r--tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp1
-rw-r--r--tests/auto/declarative/qmldom/tst_qmldom.cpp2
-rw-r--r--tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp9
-rw-r--r--tests/auto/declarative/qmlengine/qmlengine.pro2
-rw-r--r--tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp134
-rw-r--r--tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.cpp22
-rw-r--r--tests/auto/declarative/qmlgraphicsflickable/tst_qmlgraphicsflickable.cpp79
-rw-r--r--tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp38
-rw-r--r--tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp74
-rw-r--r--tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp60
-rw-r--r--tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp12
-rw-r--r--tests/auto/declarative/qmlgraphicsmouseregion/data/dragproperties.qml28
-rw-r--r--tests/auto/declarative/qmlgraphicsmouseregion/qmlgraphicsmouseregion.pro9
-rw-r--r--tests/auto/declarative/qmlgraphicsmouseregion/tst_qmlgraphicsmouseregion.cpp139
-rw-r--r--tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp13
-rw-r--r--tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp23
-rw-r--r--tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml4
-rw-r--r--tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml4
-rw-r--r--tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml4
-rw-r--r--tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp194
-rw-r--r--tests/auto/declarative/qmlgraphicsrepeater/data/properties.qml11
-rw-r--r--tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp69
-rw-r--r--tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp47
-rw-r--r--tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml1
-rw-r--r--tests/auto/declarative/qmlgraphicstextinput/data/validators.qml2
-rw-r--r--tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp46
-rw-r--r--tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml1
-rw-r--r--tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp3
-rw-r--r--tests/auto/declarative/qmlimageprovider/data/exists.pngbin0 -> 2738 bytes
-rw-r--r--tests/auto/declarative/qmlimageprovider/data/exists1.pngbin0 -> 2738 bytes
-rw-r--r--tests/auto/declarative/qmlimageprovider/data/exists2.pngbin0 -> 2738 bytes
-rw-r--r--tests/auto/declarative/qmlimageprovider/qmlimageprovider.pro12
-rw-r--r--tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp166
-rw-r--r--tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp57
-rw-r--r--tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp30
-rw-r--r--tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp9
-rw-r--r--tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp14
-rw-r--r--tests/auto/declarative/qmlstates/tst_qmlstates.cpp54
-rw-r--r--tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp46
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/data/abort.reply1
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml2
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply1
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply1
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply1
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply1
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply1
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply1
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply1
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp92
-rwxr-xr-xtests/auto/declarative/runall.sh8
-rw-r--r--tests/auto/declarative/shared/debugutil.cpp21
-rw-r--r--tests/auto/declarative/shared/debugutil_p.h25
-rw-r--r--tests/auto/declarative/shared/testhttpserver.cpp11
-rw-r--r--tests/auto/declarative/visual/Package_Views/packageviews.qml2
-rw-r--r--tests/auto/declarative/visual/animation/bindinganimation/bindinganimation.qml2
-rw-r--r--tests/auto/declarative/visual/animation/easing/easing.qml2
-rw-r--r--tests/auto/declarative/visual/animation/loop/data/loop.0.pngbin0 -> 508 bytes
-rw-r--r--tests/auto/declarative/visual/animation/loop/data/loop.1.pngbin0 -> 507 bytes
-rw-r--r--tests/auto/declarative/visual/animation/loop/data/loop.2.pngbin0 -> 508 bytes
-rw-r--r--tests/auto/declarative/visual/animation/loop/data/loop.3.pngbin0 -> 508 bytes
-rw-r--r--tests/auto/declarative/visual/animation/loop/data/loop.4.pngbin0 -> 505 bytes
-rw-r--r--tests/auto/declarative/visual/animation/loop/data/loop.5.pngbin0 -> 508 bytes
-rw-r--r--tests/auto/declarative/visual/animation/loop/data/loop.qml1471
-rw-r--r--tests/auto/declarative/visual/animation/loop/loop.qml24
-rw-r--r--tests/auto/declarative/visual/animation/parallelAnimation/parallelAnimation.qml6
-rw-r--r--tests/auto/declarative/visual/animation/parentAction/parentAction.qml2
-rw-r--r--tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml4
-rw-r--r--tests/auto/declarative/visual/animation/reanchor/reanchor.qml2
-rw-r--r--tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml4
-rw-r--r--tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.qml2
-rw-r--r--tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml4
-rw-r--r--tests/auto/declarative/visual/qmlgraphicspositioners/dynamic.qml4
-rw-r--r--tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml4
-rw-r--r--tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml4
-rw-r--r--tests/auto/qgl_threads/qgl_threads.pro11
-rw-r--r--tests/auto/qgl_threads/tst_openglthreading.cpp480
-rw-r--r--tests/auto/qgl_threads/tst_openglthreading.h61
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp57
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp3
-rw-r--r--tests/auto/qgraphicsvideoitem/qgraphicsvideoitem.pro5
-rw-r--r--tests/auto/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp670
-rw-r--r--tests/auto/qlist/tst_qlist.cpp10
-rw-r--r--tests/auto/qmediacontent/qmediacontent.pro6
-rw-r--r--tests/auto/qmediacontent/tst_qmediacontent.cpp160
-rw-r--r--tests/auto/qmediaobject/qmediaobject.pro4
-rw-r--r--tests/auto/qmediaobject/tst_qmediaobject.cpp549
-rw-r--r--tests/auto/qmediaplayer/qmediaplayer.pro6
-rw-r--r--tests/auto/qmediaplayer/tst_qmediaplayer.cpp986
-rw-r--r--tests/auto/qmediaplaylist/qmediaplaylist.pro6
-rw-r--r--tests/auto/qmediaplaylist/tmp.unsupported_format0
-rw-r--r--tests/auto/qmediaplaylist/tst_qmediaplaylist.cpp593
-rw-r--r--tests/auto/qmediaplaylistnavigator/qmediaplaylistnavigator.pro6
-rw-r--r--tests/auto/qmediaplaylistnavigator/tst_qmediaplaylistnavigator.cpp316
-rw-r--r--tests/auto/qmediapluginloader/qmediapluginloader.pro6
-rw-r--r--tests/auto/qmediapluginloader/tst_qmediapluginloader.cpp121
-rw-r--r--tests/auto/qmediaresource/qmediaresource.pro6
-rw-r--r--tests/auto/qmediaresource/tst_qmediaresource.cpp516
-rw-r--r--tests/auto/qmediaservice/qmediaservice.pro6
-rw-r--r--tests/auto/qmediaservice/tst_qmediaservice.cpp211
-rw-r--r--tests/auto/qmediaserviceprovider/qmediaserviceprovider.pro6
-rw-r--r--tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp409
-rw-r--r--tests/auto/qmediatimerange/qmediatimerange.pro6
-rw-r--r--tests/auto/qmediatimerange/tst_qmediatimerange.cpp735
-rw-r--r--tests/auto/qmlaudio/qmlaudio.pro6
-rw-r--r--tests/auto/qmlaudio/tst_qmlaudio.cpp1200
-rw-r--r--tests/auto/qmlgraphicsvideo/qmlgraphicsvideo.pro6
-rw-r--r--tests/auto/qmlgraphicsvideo/tst_qmlgraphicsvideo.cpp911
-rw-r--r--tests/auto/qpathclipper/pathcompare.h126
-rw-r--r--tests/auto/qpathclipper/tst_qpathclipper.cpp107
-rw-r--r--tests/auto/qprinter/tst_qprinter.cpp10
-rw-r--r--tests/auto/qstatictext/qstatictext.pro4
-rw-r--r--tests/auto/qstatictext/tst_qstatictext.cpp451
-rw-r--r--tests/auto/qstring/tst_qstring.cpp50
-rw-r--r--tests/auto/qvideowidget/qvideowidget.pro6
-rw-r--r--tests/auto/qvideowidget/tst_qvideowidget.cpp1600
-rw-r--r--tests/benchmarks/corelib/tools/qvector/main.cpp (renamed from tests/benchmarks/qvector/main.cpp)0
-rw-r--r--tests/benchmarks/corelib/tools/qvector/outofline.cpp (renamed from tests/benchmarks/qvector/outofline.cpp)0
-rw-r--r--tests/benchmarks/corelib/tools/qvector/qrawvector.h (renamed from tests/benchmarks/qvector/qrawvector.h)0
-rw-r--r--tests/benchmarks/corelib/tools/qvector/qvector.pro (renamed from tests/benchmarks/qvector/qvector.pro)0
-rw-r--r--tests/benchmarks/corelib/tools/tools.pro3
-rw-r--r--tests/benchmarks/declarative/painting/data/63x63.pngbin0 -> 3077 bytes
-rw-r--r--tests/benchmarks/declarative/painting/data/63x63_opaque.pngbin0 -> 3440 bytes
-rw-r--r--tests/benchmarks/declarative/painting/data/64x64.pngbin0 -> 3101 bytes
-rw-r--r--tests/benchmarks/declarative/painting/data/64x64_opaque.pngbin0 -> 3588 bytes
-rw-r--r--tests/benchmarks/declarative/painting/paintbenchmark.cpp132
-rw-r--r--tests/benchmarks/gui/painting/painting.pro3
-rw-r--r--tests/benchmarks/gui/painting/qtracebench/qtracebench.pro10
-rw-r--r--tests/benchmarks/gui/painting/qtracebench/qtracebench.qrc10
-rw-r--r--tests/benchmarks/gui/painting/qtracebench/traces/basicdrawing.tracebin0 -> 366739 bytes
-rw-r--r--tests/benchmarks/gui/painting/qtracebench/traces/creator.tracebin0 -> 541031 bytes
-rw-r--r--tests/benchmarks/gui/painting/qtracebench/traces/qmlphoneconcept.tracebin0 -> 337439 bytes
-rw-r--r--tests/benchmarks/gui/painting/qtracebench/traces/qmlsamegame.tracebin0 -> 246423 bytes
-rw-r--r--tests/benchmarks/gui/painting/qtracebench/traces/textedit.tracebin0 -> 60042 bytes
-rw-r--r--tests/benchmarks/gui/painting/qtracebench/traces/webkit.tracebin0 -> 451391 bytes
-rw-r--r--tests/benchmarks/gui/painting/qtracebench/tst_qtracebench.cpp262
159 files changed, 13623 insertions, 729 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 96fb080..7ba6243 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -171,6 +171,7 @@ SUBDIRS += \
qgraphicsscene \
qgraphicssceneindex \
qgraphicstransform \
+ qgraphicsvideoitem \
qgraphicsview \
qgraphicswidget \
qgridlayout \
@@ -299,6 +300,19 @@ SUBDIRS += \
qaudioformat \
qaudiooutput \
qaudioinput \
+ qmediacontent \
+ qmediaobject \
+ qmediaplayer \
+ qmediaplaylist \
+ qmediaplaylistnavigator \
+ qmediapluginloader \
+ qmediaresource \
+ qmediaservice \
+ qmediaserviceprovider \
+ qmediatimerange \
+ qvideowidget \
+ qmlaudio \
+ qmlgraphicsvideo \
qspinbox \
qsplitter \
qsql \
@@ -322,6 +336,7 @@ SUBDIRS += \
qstandarditemmodel \
qstate \
qstatemachine \
+ qstatictext \
qstatusbar \
qstl \
qstring \
@@ -461,7 +476,7 @@ SUBDIRS += \
rcc \
windowsmobile
-contains(QT_CONFIG,opengl):SUBDIRS += qgl qglbuffer
+contains(QT_CONFIG,opengl):SUBDIRS += qgl qglbuffer qgl_threads
contains(QT_CONFIG,qt3support):!wince*:SUBDIRS += $$Q3SUBDIRS
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index 8773026..b4a0d0f 100644
--- a/tests/auto/declarative/declarative.pro
+++ b/tests/auto/declarative/declarative.pro
@@ -29,13 +29,13 @@ SUBDIRS += \
qmlgraphicsitem \ # Cover
qmlgraphicslistview \ # Cover
qmlgraphicsloader \ # Cover
+ qmlgraphicsmouseregion \ # Cover
qmlgraphicsparticles \ # Cover
qmlgraphicspathview \ # Cover
qmlgraphicspositioners \ # Cover
qmlgraphicstext \ # Cover
qmlgraphicstextedit \ # Cover
qmlgraphicstextinput \ # Cover
- qmlgraphicswebview \ # Cover
qmlinfo \ # Cover
qmlinstruction \ # Cover
qmllanguage \ # Cover
@@ -57,8 +57,13 @@ SUBDIRS += \
qmlgraphicsrepeater \ # Cover
qmlvaluetypes \ # Cover
qmlxmlhttprequest \ # Cover
+ qmlimageprovider \ # Cover
sql # Cover
+contains(QT_CONFIG, webkit) {
+ SUBDIRS += \
+ qmlgraphicswebview # Cover
+}
# Tests which should run in Pulse
PULSE_TESTS = $$SUBDIRS
diff --git a/tests/auto/declarative/layouts/tst_layouts.cpp b/tests/auto/declarative/layouts/tst_layouts.cpp
index 050df52..ee05574 100644
--- a/tests/auto/declarative/layouts/tst_layouts.cpp
+++ b/tests/auto/declarative/layouts/tst_layouts.cpp
@@ -69,10 +69,10 @@ void tst_QmlGraphicsLayouts::test_qml()
canvas->execute();
qApp->processEvents();
- QmlGraphicsLayoutItem *left = static_cast<QmlGraphicsLayoutItem*>(canvas->root()->findChild<QmlGraphicsItem*>("left"));
+ QmlGraphicsLayoutItem *left = static_cast<QmlGraphicsLayoutItem*>(canvas->rootObject()->findChild<QmlGraphicsItem*>("left"));
QVERIFY(left != 0);
- QmlGraphicsLayoutItem *right = static_cast<QmlGraphicsLayoutItem*>(canvas->root()->findChild<QmlGraphicsItem*>("right"));
+ QmlGraphicsLayoutItem *right = static_cast<QmlGraphicsLayoutItem*>(canvas->rootObject()->findChild<QmlGraphicsItem*>("right"));
QVERIFY(right != 0);
qreal l = QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
@@ -81,9 +81,13 @@ void tst_QmlGraphicsLayouts::test_qml()
qreal b = QApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin);
QVERIFY2(l == r && r == t && t == b, "Test assumes equal margins.");
qreal gvMargin = l;
+
+ QmlGraphicsItem *rootItem = qobject_cast<QmlGraphicsItem*>(canvas->rootObject());
+ QVERIFY(rootItem != 0);
+
//Preferred Size
- canvas->root()->setWidth(300 + 2*gvMargin);
- canvas->root()->setHeight(300 + 2*gvMargin);
+ rootItem->setWidth(300 + 2*gvMargin);
+ rootItem->setHeight(300 + 2*gvMargin);
QCOMPARE(left->x(), gvMargin);
QCOMPARE(left->y(), gvMargin);
@@ -96,8 +100,8 @@ void tst_QmlGraphicsLayouts::test_qml()
QCOMPARE(right->height(), 300.0);
//Minimum Size
- canvas->root()->setWidth(10+2*gvMargin);
- canvas->root()->setHeight(10+2*gvMargin);
+ rootItem->setWidth(10+2*gvMargin);
+ rootItem->setHeight(10+2*gvMargin);
QCOMPARE(left->x(), gvMargin);
QCOMPARE(left->width(), 100.0);
@@ -111,8 +115,8 @@ void tst_QmlGraphicsLayouts::test_qml()
/*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*/
- canvas->root()->setWidth(670 + 2*gvMargin);
- canvas->root()->setHeight(300 + 2*gvMargin);
+ rootItem->setWidth(670 + 2*gvMargin);
+ rootItem->setHeight(300 + 2*gvMargin);
QCOMPARE(left->x(), gvMargin);
QCOMPARE(left->width(), 270.0);
@@ -133,11 +137,7 @@ void tst_QmlGraphicsLayouts::test_cpp()
QmlView *tst_QmlGraphicsLayouts::createView(const QString &filename)
{
QmlView *canvas = new QmlView(0);
-
- QFile file(filename);
- file.open(QFile::ReadOnly);
- QString qml = file.readAll();
- canvas->setQml(qml, filename);
+ canvas->setSource(QUrl::fromLocalFile(filename));
return canvas;
}
diff --git a/tests/auto/declarative/qmlanimations/data/badtype4.qml b/tests/auto/declarative/qmlanimations/data/badtype4.qml
index a4cf265..2ffed37 100644
--- a/tests/auto/declarative/qmlanimations/data/badtype4.qml
+++ b/tests/auto/declarative/qmlanimations/data/badtype4.qml
@@ -21,7 +21,7 @@ Rectangle {
}
transitions: Transition {
//comment out each in turn to make sure each only animates the relevant property
- ColorAnimation { matchProperties: "x,color"; duration: 1000 } //x is real, color is color
- NumberAnimation { matchProperties: "x,color"; duration: 1000 } //x is real, color is color
+ ColorAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color
+ NumberAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color
}
}
diff --git a/tests/auto/declarative/qmlanimations/data/dontAutoStart.qml b/tests/auto/declarative/qmlanimations/data/dontAutoStart.qml
new file mode 100644
index 0000000..d9660b6
--- /dev/null
+++ b/tests/auto/declarative/qmlanimations/data/dontAutoStart.qml
@@ -0,0 +1,18 @@
+import Qt 4.6
+
+Rectangle {
+ id: wrapper
+ width: 600
+ height: 400
+
+ Rectangle {
+ id: redRect
+ width: 100; height: 100
+ color: Qt.rgba(1,0,0)
+ x: Behavior {
+ NumberAnimation { objectName: "MyAnim"; target: redRect; property: "y"; to: 300; repeat: true}
+ }
+
+ }
+
+}
diff --git a/tests/auto/declarative/qmlanimations/data/dontStart.qml b/tests/auto/declarative/qmlanimations/data/dontStart.qml
new file mode 100644
index 0000000..36417db
--- /dev/null
+++ b/tests/auto/declarative/qmlanimations/data/dontStart.qml
@@ -0,0 +1,19 @@
+import Qt 4.6
+
+Rectangle {
+ id: wrapper
+ width: 600
+ height: 400
+
+ Rectangle {
+ id: redRect
+ width: 100; height: 100
+ color: Qt.rgba(1,0,0)
+ x: SequentialAnimation {
+ running: false
+ NumberAnimation { objectName: "MyAnim"; running: true }
+ }
+
+ }
+
+}
diff --git a/tests/auto/declarative/qmlanimations/data/dontStart2.qml b/tests/auto/declarative/qmlanimations/data/dontStart2.qml
new file mode 100644
index 0000000..1a6540f
--- /dev/null
+++ b/tests/auto/declarative/qmlanimations/data/dontStart2.qml
@@ -0,0 +1,19 @@
+import Qt 4.6
+
+Rectangle {
+ id: wrapper
+ width: 600
+ height: 400
+
+ Rectangle {
+ id: redRect
+ width: 100; height: 100
+ color: Qt.rgba(1,0,0)
+
+ transitions: Transition {
+ SequentialAnimation {
+ NumberAnimation { id: myAnim; objectName: "MyAnim"; running: true }
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qmlanimations/data/dotproperty.qml b/tests/auto/declarative/qmlanimations/data/dotproperty.qml
index 369491f..08bb5d8 100644
--- a/tests/auto/declarative/qmlanimations/data/dotproperty.qml
+++ b/tests/auto/declarative/qmlanimations/data/dotproperty.qml
@@ -19,6 +19,6 @@ Rectangle {
PropertyChanges { target: myRect; border.color: "blue" }
}
transitions: Transition {
- ColorAnimation { matchProperties: "border.color"; duration: 1000 }
+ ColorAnimation { properties: "border.color"; duration: 1000 }
}
}
diff --git a/tests/auto/declarative/qmlanimations/data/mixedtype1.qml b/tests/auto/declarative/qmlanimations/data/mixedtype1.qml
index 87f4f16..b46270c 100644
--- a/tests/auto/declarative/qmlanimations/data/mixedtype1.qml
+++ b/tests/auto/declarative/qmlanimations/data/mixedtype1.qml
@@ -20,6 +20,6 @@ Rectangle {
PropertyChanges { target: myRect; x: 200; border.width: 10 }
}
transitions: Transition {
- PropertyAnimation { matchProperties: "x,border.width"; duration: 1000 } //x is real, border.width is int
+ PropertyAnimation { properties: "x,border.width"; duration: 1000 } //x is real, border.width is int
}
}
diff --git a/tests/auto/declarative/qmlanimations/data/mixedtype2.qml b/tests/auto/declarative/qmlanimations/data/mixedtype2.qml
index d555abd..15537f1 100644
--- a/tests/auto/declarative/qmlanimations/data/mixedtype2.qml
+++ b/tests/auto/declarative/qmlanimations/data/mixedtype2.qml
@@ -20,6 +20,6 @@ Rectangle {
PropertyChanges { target: myRect; x: 200; color: "blue" }
}
transitions: Transition {
- PropertyAnimation { matchProperties: "x,color"; duration: 1000 } //x is real, color is color
+ PropertyAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color
}
}
diff --git a/tests/auto/declarative/qmlanimations/data/properties2.qml b/tests/auto/declarative/qmlanimations/data/properties2.qml
index 86568ca..6c96155 100644
--- a/tests/auto/declarative/qmlanimations/data/properties2.qml
+++ b/tests/auto/declarative/qmlanimations/data/properties2.qml
@@ -9,6 +9,6 @@ Rectangle {
color: "red"
width: 50; height: 50
x: 100; y: 100
- x: NumberAnimation { matchTargets: theRect; matchProperties: "x"; to: 200; }
+ x: NumberAnimation { targets: theRect; properties: "x"; to: 200; }
}
}
diff --git a/tests/auto/declarative/qmlanimations/data/properties5.qml b/tests/auto/declarative/qmlanimations/data/properties5.qml
index 56e0be8..38396b1 100644
--- a/tests/auto/declarative/qmlanimations/data/properties5.qml
+++ b/tests/auto/declarative/qmlanimations/data/properties5.qml
@@ -9,6 +9,6 @@ Rectangle {
color: "red"
width: 50; height: 50
x: 100; y: 100
- x: NumberAnimation { matchTargets: theRect; matchProperties: "y"; to: 200; }
+ x: NumberAnimation { targets: theRect; properties: "y"; to: 200; }
}
}
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml
index 75603b9..2f7fd4a 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml
+++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml
@@ -19,7 +19,7 @@ Rectangle {
}
}
transitions: Transition {
- NumberAnimation { matchTargets: theRect; matchProperties: "x" }
+ NumberAnimation { targets: theRect; properties: "x" }
}
MouseRegion {
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml
index eedba7b..5aaaab8 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml
+++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml
@@ -19,7 +19,7 @@ Rectangle {
}
}
transitions: Transition {
- NumberAnimation { matchTargets: theRect; matchProperties: "y" }
+ NumberAnimation { targets: theRect; properties: "y" }
}
MouseRegion {
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml
index 301f796..b7ebb1b 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml
+++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml
@@ -19,7 +19,7 @@ Rectangle {
}
}
transitions: Transition {
- NumberAnimation { target: theRect; matchProperties: "x" }
+ NumberAnimation { target: theRect; properties: "x" }
}
MouseRegion {
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml
index 565c519..9034fc5 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml
+++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml
@@ -19,7 +19,7 @@ Rectangle {
}
}
transitions: Transition {
- NumberAnimation { matchTargets: theRect; property: "x" }
+ NumberAnimation { targets: theRect; property: "x" }
}
MouseRegion {
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml
index b541dab..3d8be51 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml
+++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml
@@ -19,7 +19,7 @@ Rectangle {
}
}
transitions: Transition {
- NumberAnimation { matchTargets: theItem; matchProperties: "x" }
+ NumberAnimation { targets: theItem; properties: "x" }
}
MouseRegion {
diff --git a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp
index 34bb7e3..9eae308 100644
--- a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp
+++ b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp
@@ -46,13 +46,15 @@
#include <private/qmlanimation_p.h>
#include <QVariantAnimation>
-class tst_animations : public QObject
+class tst_qmlanimations : public QObject
{
Q_OBJECT
public:
- tst_animations() {}
+ tst_qmlanimations() {}
private slots:
+ void initTestCase() { QmlEngine engine; } // ensure types are registered
+
void simpleProperty();
void simpleNumber();
void simpleColor();
@@ -69,6 +71,7 @@ private slots:
void invalidDuration();
void attached();
void propertyValueSourceDefaultStart();
+ void dontStart();
};
#define QTIMED_COMPARE(lhs, rhs) do { \
@@ -80,7 +83,7 @@ private slots:
QCOMPARE(lhs, rhs); \
} while (false)
-void tst_animations::simpleProperty()
+void tst_qmlanimations::simpleProperty()
{
QmlGraphicsRectangle rect;
QmlPropertyAnimation animation;
@@ -105,7 +108,7 @@ void tst_animations::simpleProperty()
QCOMPARE(rect.pos(), QPointF(100,100));
}
-void tst_animations::simpleNumber()
+void tst_qmlanimations::simpleNumber()
{
QmlGraphicsRectangle rect;
QmlNumberAnimation animation;
@@ -130,7 +133,7 @@ void tst_animations::simpleNumber()
QCOMPARE(rect.x(), qreal(100));
}
-void tst_animations::simpleColor()
+void tst_qmlanimations::simpleColor()
{
QmlGraphicsRectangle rect;
QmlColorAnimation animation;
@@ -164,7 +167,7 @@ void tst_animations::simpleColor()
QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1));
}
-void tst_animations::alwaysRunToEnd()
+void tst_qmlanimations::alwaysRunToEnd()
{
QmlGraphicsRectangle rect;
QmlPropertyAnimation animation;
@@ -184,7 +187,7 @@ void tst_animations::alwaysRunToEnd()
QTIMED_COMPARE(rect.x(), qreal(200));
}
-void tst_animations::complete()
+void tst_qmlanimations::complete()
{
QmlGraphicsRectangle rect;
QmlPropertyAnimation animation;
@@ -205,7 +208,7 @@ void tst_animations::complete()
QCOMPARE(rect.x(), qreal(200));
}
-void tst_animations::resume()
+void tst_qmlanimations::resume()
{
QmlGraphicsRectangle rect;
QmlPropertyAnimation animation;
@@ -217,7 +220,7 @@ void tst_animations::resume()
QVERIFY(animation.from() == 10);
animation.start();
- QTest::qWait(50);
+ QTest::qWait(100);
animation.pause();
qreal x = rect.x();
QVERIFY(x != qreal(200));
@@ -227,12 +230,12 @@ void tst_animations::resume()
animation.resume();
QVERIFY(animation.isRunning());
QVERIFY(!animation.isPaused());
- QTest::qWait(50);
+ QTest::qWait(100);
animation.stop();
QVERIFY(rect.x() > x);
}
-void tst_animations::dotProperty()
+void tst_qmlanimations::dotProperty()
{
QmlGraphicsRectangle rect;
QmlNumberAnimation animation;
@@ -251,12 +254,12 @@ void tst_animations::dotProperty()
QCOMPARE(rect.border()->width(), 5);
}
-void tst_animations::badTypes()
+void tst_qmlanimations::badTypes()
{
//don't crash
{
QmlView *view = new QmlView;
- view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/badtype1.qml"));
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/badtype1.qml"));
view->execute();
qApp->processEvents();
@@ -301,7 +304,7 @@ void tst_animations::badTypes()
}
}
-void tst_animations::badProperties()
+void tst_qmlanimations::badProperties()
{
//make sure we get a runtime error
{
@@ -310,14 +313,12 @@ void tst_animations::badProperties()
QmlComponent c1(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml"));
QByteArray message = "QML ColorAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml").toString().toUtf8() + ":18:9) Cannot animate non-existent property \"border.colr\"";
QTest::ignoreMessage(QtWarningMsg, message);
- QTest::ignoreMessage(QtWarningMsg, message); // why twice?
QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c1.create());
QVERIFY(rect);
QmlComponent c2(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml"));
message = "QML ColorAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml").toString().toUtf8() + ":18:9) Cannot animate read-only property \"border\"";
QTest::ignoreMessage(QtWarningMsg, message);
- QTest::ignoreMessage(QtWarningMsg, message); // why twice?
rect = qobject_cast<QmlGraphicsRectangle*>(c2.create());
QVERIFY(rect);
@@ -328,9 +329,9 @@ void tst_animations::badProperties()
//test animating mixed types with property animation in a transition
//for example, int + real; color + real; etc
-void tst_animations::mixedTypes()
+void tst_qmlanimations::mixedTypes()
{
- //assumes border.width stats a real -- not real robust
+ //assumes border.width stays a real -- not real robust
{
QmlEngine engine;
QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/mixedtype1.qml"));
@@ -364,7 +365,7 @@ void tst_animations::mixedTypes()
}
}
-void tst_animations::properties()
+void tst_qmlanimations::properties()
{
const int waitDuration = 300;
{
@@ -425,13 +426,12 @@ void tst_animations::properties()
QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
QVERIFY(myRect);
QTest::qWait(waitDuration);
- QEXPECT_FAIL("", "QTBUG-8072", Continue);
QTIMED_COMPARE(myRect->x(),qreal(100));
- QTIMED_COMPARE(myRect->y(),qreal(100));
+ QTIMED_COMPARE(myRect->y(),qreal(200));
}
}
-void tst_animations::propertiesTransition()
+void tst_qmlanimations::propertiesTransition()
{
const int waitDuration = 300;
{
@@ -470,9 +470,9 @@ void tst_animations::propertiesTransition()
QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
QVERIFY(myRect);
- QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition4.qml").toString().toUtf8() + ":22:9) matchTargets/matchProperties/exclude and target/property are mutually exclusive.");
rect->setState("moved");
QCOMPARE(myRect->x(),qreal(200));
+ QCOMPARE(myRect->y(),qreal(100));
}
{
@@ -483,9 +483,10 @@ void tst_animations::propertiesTransition()
QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
QVERIFY(myRect);
- QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition5.qml").toString().toUtf8() + ":22:9) matchTargets/matchProperties/exclude and target/property are mutually exclusive.");
rect->setState("moved");
- QCOMPARE(myRect->x(),qreal(200));
+ QCOMPARE(myRect->x(),qreal(100));
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
}
{
@@ -494,15 +495,30 @@ void tst_animations::propertiesTransition()
QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
QVERIFY(rect);
- //### should output warning at some point -- theItem doesn't exist
QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
QVERIFY(myRect);
rect->setState("moved");
- QCOMPARE(myRect->x(),qreal(200));
+ QCOMPARE(myRect->x(),qreal(100));
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
}
+
+ /*{
+ QmlEngine engine;
+ QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition6.qml"));
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
+ QVERIFY(myRect);
+ rect->setState("moved");
+ QCOMPARE(myRect->x(),qreal(100));
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(100));
+ }*/
}
-void tst_animations::easingStringConversion()
+void tst_qmlanimations::easingStringConversion()
{
QmlNumberAnimation *animation = new QmlNumberAnimation;
animation->setEasing("easeInOutQuad");
@@ -553,7 +569,7 @@ void tst_animations::easingStringConversion()
delete animation;
}
-void tst_animations::invalidDuration()
+void tst_qmlanimations::invalidDuration()
{
QmlPropertyAnimation *animation = new QmlPropertyAnimation;
QTest::ignoreMessage(QtWarningMsg, "QML PropertyAnimation (unknown location) Cannot set a duration of < 0");
@@ -566,7 +582,7 @@ void tst_animations::invalidDuration()
QCOMPARE(pauseAnimation->duration(), 250);
}
-void tst_animations::attached()
+void tst_qmlanimations::attached()
{
QmlEngine engine;
@@ -577,7 +593,7 @@ void tst_animations::attached()
QVERIFY(rect);
}
-void tst_animations::propertyValueSourceDefaultStart()
+void tst_qmlanimations::propertyValueSourceDefaultStart()
{
{
QmlEngine engine;
@@ -604,8 +620,53 @@ void tst_animations::propertyValueSourceDefaultStart()
QVERIFY(myAnim);
QVERIFY(myAnim->isRunning() == false);
}
+
+ {
+ QmlEngine engine;
+
+ QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontAutoStart.qml"));
+
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim && myAnim->qtAnimation());
+ QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
+ }
+}
+
+
+void tst_qmlanimations::dontStart()
+{
+ {
+ QmlEngine engine;
+
+ QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml"));
+
+ QTest::ignoreMessage(QtWarningMsg, "QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes");
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim && myAnim->qtAnimation());
+ QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
+ }
+
+ {
+ QmlEngine engine;
+
+ QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart2.qml"));
+
+ QTest::ignoreMessage(QtWarningMsg, "QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes");
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim && myAnim->qtAnimation());
+ QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
+ }
}
-QTEST_MAIN(tst_animations)
+QTEST_MAIN(tst_qmlanimations)
#include "tst_qmlanimations.moc"
diff --git a/tests/auto/declarative/qmlbehaviors/data/dontStart.qml b/tests/auto/declarative/qmlbehaviors/data/dontStart.qml
new file mode 100644
index 0000000..ba7cc9c
--- /dev/null
+++ b/tests/auto/declarative/qmlbehaviors/data/dontStart.qml
@@ -0,0 +1,18 @@
+import Qt 4.6
+
+Rectangle {
+ id: wrapper
+ width: 600
+ height: 400
+
+ Rectangle {
+ id: redRect
+ width: 100; height: 100
+ color: Qt.rgba(1,0,0)
+ x: Behavior {
+ NumberAnimation { objectName: "MyAnim"; running: true }
+ }
+
+ }
+
+}
diff --git a/tests/auto/declarative/qmlbehaviors/data/nonSelecting.qml b/tests/auto/declarative/qmlbehaviors/data/explicit.qml
index ba36d93..ba36d93 100644
--- a/tests/auto/declarative/qmlbehaviors/data/nonSelecting.qml
+++ b/tests/auto/declarative/qmlbehaviors/data/explicit.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml b/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml
index e9849eb..59cbd1a 100644
--- a/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml
+++ b/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml
@@ -8,7 +8,7 @@ Rectangle {
width: 100; height: 100; color: "green"
x: Behavior {
objectName: "MyBehavior";
- NumberAnimation { matchTargets: rect; matchProperties: "y"; duration: 200; }
+ NumberAnimation { targets: rect; properties: "y"; duration: 200; }
}
}
MouseRegion {
diff --git a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp
index 126c506..99ec728 100644
--- a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp
+++ b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp
@@ -46,11 +46,11 @@
#include <private/qmlbehavior_p.h>
#include <private/qmlanimation_p.h>
-class tst_behaviors : public QObject
+class tst_qmlbehaviors : public QObject
{
Q_OBJECT
public:
- tst_behaviors() {}
+ tst_qmlbehaviors() {}
private slots:
void simpleBehavior();
@@ -63,12 +63,14 @@ private slots:
//void transitionOverrides();
void group();
void emptyBehavior();
+ void explicitSelection();
void nonSelectingBehavior();
void reassignedAnimation();
void disabled();
+ void dontStart();
};
-void tst_behaviors::simpleBehavior()
+void tst_qmlbehaviors::simpleBehavior()
{
QmlEngine engine;
QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/simple.qml"));
@@ -82,7 +84,7 @@ void tst_behaviors::simpleBehavior()
QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
}
-void tst_behaviors::scriptTriggered()
+void tst_qmlbehaviors::scriptTriggered()
{
QmlEngine engine;
QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/scripttrigger.qml"));
@@ -95,7 +97,7 @@ void tst_behaviors::scriptTriggered()
QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
}
-void tst_behaviors::cppTriggered()
+void tst_qmlbehaviors::cppTriggered()
{
QmlEngine engine;
QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/cpptrigger.qml"));
@@ -111,7 +113,7 @@ void tst_behaviors::cppTriggered()
QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
}
-void tst_behaviors::loop()
+void tst_qmlbehaviors::loop()
{
QmlEngine engine;
QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/loop.qml"));
@@ -122,7 +124,7 @@ void tst_behaviors::loop()
rect->setState("moved");
}
-void tst_behaviors::colorBehavior()
+void tst_qmlbehaviors::colorBehavior()
{
QmlEngine engine;
QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/color.qml"));
@@ -135,7 +137,7 @@ void tst_behaviors::colorBehavior()
QVERIFY(color != QColor("red") && color != QColor("green")); //i.e. the behavior has been triggered
}
-void tst_behaviors::parentBehavior()
+void tst_qmlbehaviors::parentBehavior()
{
QmlEngine engine;
QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/parent.qml"));
@@ -152,7 +154,7 @@ void tst_behaviors::parentBehavior()
QVERIFY(parent == newParent);
}
-void tst_behaviors::replaceBinding()
+void tst_qmlbehaviors::replaceBinding()
{
QmlEngine engine;
QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/binding.qml"));
@@ -186,7 +188,7 @@ void tst_behaviors::replaceBinding()
QCOMPARE(innerRect->x(), (qreal)20);
}
-void tst_behaviors::group()
+void tst_qmlbehaviors::group()
{
{
QmlEngine engine;
@@ -213,7 +215,7 @@ void tst_behaviors::group()
}
}
-void tst_behaviors::emptyBehavior()
+void tst_qmlbehaviors::emptyBehavior()
{
QmlEngine engine;
QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/empty.qml"));
@@ -225,19 +227,23 @@ void tst_behaviors::emptyBehavior()
QCOMPARE(x, qreal(200)); //should change immediately
}
-void tst_behaviors::nonSelectingBehavior()
+void tst_qmlbehaviors::explicitSelection()
{
{
QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting.qml"));
+ QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/explicit.qml"));
QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
QVERIFY(rect);
rect->setState("moved");
+ QTest::qWait(100);
qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
- QCOMPARE(x, qreal(200)); //should change immediately
+ QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
}
+}
+void tst_qmlbehaviors::nonSelectingBehavior()
+{
{
QmlEngine engine;
QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting2.qml"));
@@ -250,7 +256,7 @@ void tst_behaviors::nonSelectingBehavior()
}
}
-void tst_behaviors::reassignedAnimation()
+void tst_qmlbehaviors::reassignedAnimation()
{
QmlEngine engine;
QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml"));
@@ -262,7 +268,7 @@ void tst_behaviors::reassignedAnimation()
rect->findChild<QmlBehavior*>("MyBehavior"))->animation())->duration(), 200);
}
-void tst_behaviors::disabled()
+void tst_qmlbehaviors::disabled()
{
QmlEngine engine;
QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/disabled.qml"));
@@ -273,9 +279,23 @@ void tst_behaviors::disabled()
rect->setState("moved");
qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
QCOMPARE(x, qreal(200)); //should change immediately
+}
+
+void tst_qmlbehaviors::dontStart()
+{
+ QmlEngine engine;
+
+ QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml"));
+
+ QTest::ignoreMessage(QtWarningMsg, "QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes");
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
+ QVERIFY(rect);
+ QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim && myAnim->qtAnimation());
+ QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
}
-QTEST_MAIN(tst_behaviors)
+QTEST_MAIN(tst_qmlbehaviors)
#include "tst_qmlbehaviors.moc"
diff --git a/tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp b/tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp
index bb607ae..4b5dc1d 100644
--- a/tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp
+++ b/tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp
@@ -44,11 +44,11 @@
#include <private/qmldatetimeformatter_p.h>
#include <QDebug>
-class tst_datetimeformatter : public QObject
+class tst_qmldatetimeformatter : public QObject
{
Q_OBJECT
public:
- tst_datetimeformatter() {}
+ tst_qmldatetimeformatter() {}
private slots:
void date();
@@ -56,7 +56,7 @@ private slots:
void dateTime();
};
-void tst_datetimeformatter::date()
+void tst_qmldatetimeformatter::date()
{
QmlEngine engine;
QmlComponent formatterComponent(&engine);
@@ -86,7 +86,7 @@ void tst_datetimeformatter::date()
delete formatter;
}
-void tst_datetimeformatter::time()
+void tst_qmldatetimeformatter::time()
{
QmlEngine engine;
QmlComponent formatterComponent(&engine);
@@ -119,7 +119,7 @@ void tst_datetimeformatter::time()
delete formatter;
}
-void tst_datetimeformatter::dateTime()
+void tst_qmldatetimeformatter::dateTime()
{
QmlEngine engine;
QmlComponent formatterComponent(&engine);
@@ -145,6 +145,6 @@ void tst_datetimeformatter::dateTime()
delete formatter;
}
-QTEST_MAIN(tst_datetimeformatter)
+QTEST_MAIN(tst_qmldatetimeformatter)
#include "tst_qmldatetimeformatter.moc"
diff --git a/tests/auto/declarative/qmldebug/tst_qmldebug.cpp b/tests/auto/declarative/qmldebug/tst_qmldebug.cpp
index effc2c5..2e668ad 100644
--- a/tests/auto/declarative/qmldebug/tst_qmldebug.cpp
+++ b/tests/auto/declarative/qmldebug/tst_qmldebug.cpp
@@ -288,10 +288,11 @@ void tst_QmlDebug::watch_property()
QmlDebugPropertyWatch *watch;
- QmlEngineDebug unconnected(0);
- watch = unconnected.addWatch(prop, this);
+ QmlEngineDebug *unconnected = new QmlEngineDebug(0);
+ watch = unconnected->addWatch(prop, this);
QCOMPARE(watch->state(), QmlDebugWatch::Dead);
delete watch;
+ delete unconnected;
watch = m_dbg->addWatch(QmlDebugPropertyReference(), this);
QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
@@ -346,10 +347,11 @@ void tst_QmlDebug::watch_object()
QmlDebugWatch *watch;
- QmlEngineDebug unconnected(0);
- watch = unconnected.addWatch(obj, this);
+ QmlEngineDebug *unconnected = new QmlEngineDebug(0);
+ watch = unconnected->addWatch(obj, this);
QCOMPARE(watch->state(), QmlDebugWatch::Dead);
delete watch;
+ delete unconnected;
watch = m_dbg->addWatch(QmlDebugObjectReference(), this);
QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
@@ -409,10 +411,11 @@ void tst_QmlDebug::watch_expression()
QmlDebugObjectExpressionWatch *watch;
- QmlEngineDebug unconnected(0);
- watch = unconnected.addWatch(obj, expr, this);
+ QmlEngineDebug *unconnected = new QmlEngineDebug(0);
+ watch = unconnected->addWatch(obj, expr, this);
QCOMPARE(watch->state(), QmlDebugWatch::Dead);
delete watch;
+ delete unconnected;
watch = m_dbg->addWatch(QmlDebugObjectReference(), expr, this);
QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
@@ -487,10 +490,11 @@ void tst_QmlDebug::queryAvailableEngines()
{
QmlDebugEnginesQuery *q_engines;
- QmlEngineDebug unconnected(0);
- q_engines = unconnected.queryAvailableEngines(0);
+ QmlEngineDebug *unconnected = new QmlEngineDebug(0);
+ q_engines = unconnected->queryAvailableEngines(0);
QCOMPARE(q_engines->state(), QmlDebugQuery::Error);
delete q_engines;
+ delete unconnected;
q_engines = m_dbg->queryAvailableEngines(this);
delete q_engines;
@@ -519,10 +523,11 @@ void tst_QmlDebug::queryRootContexts()
QmlDebugRootContextQuery *q_context;
- QmlEngineDebug unconnected(0);
- q_context = unconnected.queryRootContexts(engineId, this);
+ QmlEngineDebug *unconnected = new QmlEngineDebug(0);
+ q_context = unconnected->queryRootContexts(engineId, this);
QCOMPARE(q_context->state(), QmlDebugQuery::Error);
delete q_context;
+ delete unconnected;
q_context = m_dbg->queryRootContexts(engineId, this);
delete q_context;
@@ -563,10 +568,11 @@ void tst_QmlDebug::queryObject()
QmlDebugObjectQuery *q_obj = 0;
- QmlEngineDebug unconnected(0);
- q_obj = recursive ? unconnected.queryObjectRecursive(rootObject, this) : unconnected.queryObject(rootObject, this);
+ QmlEngineDebug *unconnected = new QmlEngineDebug(0);
+ q_obj = recursive ? unconnected->queryObjectRecursive(rootObject, this) : unconnected->queryObject(rootObject, this);
QCOMPARE(q_obj->state(), QmlDebugQuery::Error);
delete q_obj;
+ delete unconnected;
q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this);
delete q_obj;
@@ -637,10 +643,11 @@ void tst_QmlDebug::queryExpressionResult()
QmlDebugExpressionQuery *q_expr;
- QmlEngineDebug unconnected(0);
- q_expr = unconnected.queryExpressionResult(objectId, expr, this);
+ QmlEngineDebug *unconnected = new QmlEngineDebug(0);
+ q_expr = unconnected->queryExpressionResult(objectId, expr, this);
QCOMPARE(q_expr->state(), QmlDebugQuery::Error);
delete q_expr;
+ delete unconnected;
q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
delete q_expr;
@@ -801,9 +808,10 @@ class tst_QmlDebug_Factory : public QmlTestFactory
public:
QObject *createTest(QmlDebugTestData *data)
{
- QmlContext *c = new QmlContext(data->engine->rootContext());
+ tst_QmlDebug *test = new tst_QmlDebug(data);
+ QmlContext *c = new QmlContext(data->engine->rootContext(), test);
c->setObjectName("tst_QmlDebug_childContext");
- return new tst_QmlDebug(data);
+ return test;
}
};
diff --git a/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp b/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp
index 45a06c4..e9e31ca 100644
--- a/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp
+++ b/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp
@@ -167,6 +167,7 @@ void tst_QmlDebugService::objectToString()
obj->setObjectName("Hello");
QCOMPARE(QmlDebugService::objectToString(obj), QString("QObject: Hello"));
+ delete obj;
}
diff --git a/tests/auto/declarative/qmldom/tst_qmldom.cpp b/tests/auto/declarative/qmldom/tst_qmldom.cpp
index 6dbcedd..16cdef0 100644
--- a/tests/auto/declarative/qmldom/tst_qmldom.cpp
+++ b/tests/auto/declarative/qmldom/tst_qmldom.cpp
@@ -41,7 +41,7 @@
#include <qtest.h>
#include <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/qmldom.h>
+#include <QtDeclarative/private/qmldom_p.h>
#include <QtCore/QDebug>
#include <QtCore/QFile>
diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
index 4e66548..0ef836f 100644
--- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
+++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
@@ -45,7 +45,7 @@
#include <QtDeclarative/qmlcontext.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qdebug.h>
-#include <QtCore/private/qguard_p.h>
+#include <QtDeclarative/private/qmlguard_p.h>
#include <QtCore/qdir.h>
#include <QtCore/qnumeric.h>
#include <private/qmlengine_p.h>
@@ -835,9 +835,9 @@ void tst_qmlecmascript::dynamicCreation()
void tst_qmlecmascript::dynamicDestruction()
{
QmlComponent component(&engine, TEST_FILE("dynamicDeletion.qml"));
- QGuard<MyQmlObject> object = qobject_cast<MyQmlObject*>(component.create());
+ QmlGuard<MyQmlObject> object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object != 0);
- QGuard<QObject> createdQmlObject = 0;
+ QmlGuard<QObject> createdQmlObject = 0;
QMetaObject::invokeMethod(object, "create");
createdQmlObject = object->objectProperty();
@@ -846,10 +846,9 @@ void tst_qmlecmascript::dynamicDestruction()
QMetaObject::invokeMethod(object, "killOther");
QVERIFY(createdQmlObject);
- QTest::qWait(0);
QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion);
QVERIFY(createdQmlObject);
- for (int ii = 0; createdQmlObject && ii < 10; ++ii) {
+ for (int ii = 0; createdQmlObject && ii < 50; ++ii) { // After 5 seconds we should give up
if (createdQmlObject) {
QTest::qWait(100);
QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion);
diff --git a/tests/auto/declarative/qmlengine/qmlengine.pro b/tests/auto/declarative/qmlengine/qmlengine.pro
index 21d55a4..1a0e5f4 100644
--- a/tests/auto/declarative/qmlengine/qmlengine.pro
+++ b/tests/auto/declarative/qmlengine/qmlengine.pro
@@ -1,5 +1,5 @@
load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative webkit network
+contains(QT_CONFIG,declarative): QT += declarative network
macx:CONFIG -= app_bundle
SOURCES += tst_qmlengine.cpp
diff --git a/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp b/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp
index 24d6f44..aa6b56a 100644
--- a/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp
+++ b/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp
@@ -51,14 +51,14 @@ Q_DECLARE_METATYPE(QmlGraphicsAnchors::UsedAnchor)
Q_DECLARE_METATYPE(QmlGraphicsAnchorLine::AnchorLine)
-class tst_anchors : public QObject
+class tst_qmlgraphicsanchors : public QObject
{
Q_OBJECT
public:
- tst_anchors() {}
+ tst_qmlgraphicsanchors() {}
template<typename T>
- T *findItem(QmlGraphicsItem *parent, const QString &id);
+ T *findItem(QGraphicsObject *parent, const QString &id);
private slots:
void basicAnchors();
@@ -80,7 +80,7 @@ private slots:
Find an item with the specified id.
*/
template<typename T>
-T *tst_anchors::findItem(QmlGraphicsItem *parent, const QString &objectName)
+T *tst_qmlgraphicsanchors::findItem(QGraphicsObject *parent, const QString &objectName)
{
const QMetaObject &mo = T::staticMetaObject;
QList<QGraphicsItem *> children = parent->childItems();
@@ -99,83 +99,83 @@ T *tst_anchors::findItem(QmlGraphicsItem *parent, const QString &objectName)
return 0;
}
-void tst_anchors::basicAnchors()
+void tst_qmlgraphicsanchors::basicAnchors()
{
QmlView *view = new QmlView;
- view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/anchors.qml"));
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/anchors.qml"));
view->execute();
qApp->processEvents();
//sibling horizontal
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect1"))->x(), 26.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect2"))->x(), 122.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect3"))->x(), 74.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect4"))->x(), 16.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect5"))->x(), 112.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect6"))->x(), 64.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect1"))->x(), 26.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect2"))->x(), 122.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect3"))->x(), 74.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect4"))->x(), 16.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect5"))->x(), 112.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect6"))->x(), 64.0);
//parent horizontal
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect7"))->x(), 0.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect8"))->x(), 240.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect9"))->x(), 120.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect10"))->x(), -10.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect11"))->x(), 230.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect12"))->x(), 110.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect7"))->x(), 0.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect8"))->x(), 240.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect9"))->x(), 120.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect10"))->x(), -10.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect11"))->x(), 230.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect12"))->x(), 110.0);
//vertical
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect13"))->y(), 20.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect14"))->y(), 155.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect13"))->y(), 20.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect14"))->y(), 155.0);
//stretch
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect15"))->x(), 26.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect15"))->width(), 96.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect16"))->x(), 26.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect16"))->width(), 192.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect17"))->x(), -70.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect17"))->width(), 192.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect15"))->x(), 26.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect15"))->width(), 96.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect16"))->x(), 26.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect16"))->width(), 192.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect17"))->x(), -70.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect17"))->width(), 192.0);
//vertical stretch
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect18"))->y(), 20.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect18"))->height(), 40.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect18"))->y(), 20.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect18"))->height(), 40.0);
//more parent horizontal
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect19"))->x(), 115.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect20"))->x(), 235.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect21"))->x(), -5.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect19"))->x(), 115.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect20"))->x(), 235.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect21"))->x(), -5.0);
//centerIn
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect22"))->x(), 69.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect22"))->y(), 5.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect22"))->x(), 69.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect22"))->y(), 5.0);
//margins
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23"))->x(), 31.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23"))->y(), 5.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23"))->width(), 86.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect23"))->height(), 10.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect23"))->x(), 31.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect23"))->y(), 5.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect23"))->width(), 86.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect23"))->height(), 10.0);
// offsets
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect24"))->x(), 26.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect25"))->y(), 60.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("rect26"))->y(), 5.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect24"))->x(), 26.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect25"))->y(), 60.0);
+ QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect26"))->y(), 5.0);
//baseline
- QmlGraphicsText *text1 = findItem<QmlGraphicsText>(view->root(), QLatin1String("text1"));
- QmlGraphicsText *text2 = findItem<QmlGraphicsText>(view->root(), QLatin1String("text2"));
+ QmlGraphicsText *text1 = findItem<QmlGraphicsText>(view->rootObject(), QLatin1String("text1"));
+ QmlGraphicsText *text2 = findItem<QmlGraphicsText>(view->rootObject(), QLatin1String("text2"));
QCOMPARE(text1->y(), text2->y());
delete view;
}
// mostly testing that we don't crash
-void tst_anchors::loops()
+void tst_qmlgraphicsanchors::loops()
{
{
QmlView *view = new QmlView;
- view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/loop1.qml"));
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/loop1.qml"));
- QString expect = "QML Text (" + view->url().toString() + ":6:5" + ") Possible anchor loop detected on horizontal anchor.";
+ QString expect = "QML Text (" + view->source().toString() + ":6:5" + ") Possible anchor loop detected on horizontal anchor.";
QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
@@ -188,9 +188,9 @@ void tst_anchors::loops()
{
QmlView *view = new QmlView;
- view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/loop2.qml"));
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/loop2.qml"));
- QString expect = "QML Image (" + view->url().toString() + ":8:3" + ") Possible anchor loop detected on horizontal anchor.";
+ QString expect = "QML Image (" + view->source().toString() + ":8:3" + ") Possible anchor loop detected on horizontal anchor.";
QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
view->execute();
qApp->processEvents();
@@ -199,7 +199,7 @@ void tst_anchors::loops()
}
}
-void tst_anchors::illegalSets()
+void tst_qmlgraphicsanchors::illegalSets()
{
QFETCH(QString, qml);
QFETCH(QString, warning);
@@ -216,7 +216,7 @@ void tst_anchors::illegalSets()
delete o;
}
-void tst_anchors::illegalSets_data()
+void tst_qmlgraphicsanchors::illegalSets_data()
{
QTest::addColumn<QString>("qml");
QTest::addColumn<QString>("warning");
@@ -274,7 +274,7 @@ void tst_anchors::illegalSets_data()
<< "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling.";
}
-void tst_anchors::reset()
+void tst_qmlgraphicsanchors::reset()
{
QFETCH(QString, side);
QFETCH(QmlGraphicsAnchorLine::AnchorLine, anchorLine);
@@ -301,7 +301,7 @@ void tst_anchors::reset()
delete baseItem;
}
-void tst_anchors::reset_data()
+void tst_qmlgraphicsanchors::reset_data()
{
QTest::addColumn<QString>("side");
QTest::addColumn<QmlGraphicsAnchorLine::AnchorLine>("anchorLine");
@@ -317,7 +317,7 @@ void tst_anchors::reset_data()
QTest::newRow("baseline") << "baseline" << QmlGraphicsAnchorLine::Baseline << QmlGraphicsAnchors::HasBaselineAnchor;
}
-void tst_anchors::resetConvenience()
+void tst_qmlgraphicsanchors::resetConvenience()
{
QmlGraphicsItem *baseItem = new QmlGraphicsItem;
QmlGraphicsItem *item = new QmlGraphicsItem;
@@ -338,7 +338,7 @@ void tst_anchors::resetConvenience()
delete baseItem;
}
-void tst_anchors::nullItem()
+void tst_qmlgraphicsanchors::nullItem()
{
QFETCH(QString, side);
@@ -354,7 +354,7 @@ void tst_anchors::nullItem()
delete item;
}
-void tst_anchors::nullItem_data()
+void tst_qmlgraphicsanchors::nullItem_data()
{
QTest::addColumn<QString>("side");
@@ -368,13 +368,13 @@ void tst_anchors::nullItem_data()
QTest::newRow("baseline") << "baseline";
}
-void tst_anchors::crash1()
+void tst_qmlgraphicsanchors::crash1()
{
QmlView *view = new QmlView;
- view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/crash1.qml"));
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/crash1.qml"));
- QString expect = "QML Text (" + view->url().toString() + ":4:5" + ") Possible anchor loop detected on fill.";
+ QString expect = "QML Text (" + view->source().toString() + ":4:5" + ") Possible anchor loop detected on fill.";
QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); // XXX ideally, should be one message
view->execute();
@@ -383,15 +383,15 @@ void tst_anchors::crash1()
delete view;
}
-void tst_anchors::fill()
+void tst_qmlgraphicsanchors::fill()
{
QmlView *view = new QmlView;
- view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/fill.qml"));
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/fill.qml"));
view->execute();
qApp->processEvents();
- QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("filler"));
+ QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("filler"));
QCOMPARE(rect->x(), 0.0 + 10.0);
QCOMPARE(rect->y(), 0.0 + 30.0);
QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0);
@@ -409,15 +409,15 @@ void tst_anchors::fill()
delete view;
}
-void tst_anchors::centerIn()
+void tst_qmlgraphicsanchors::centerIn()
{
QmlView *view = new QmlView;
- view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/centerin.qml"));
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/centerin.qml"));
view->execute();
qApp->processEvents();
- QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("centered"));
+ QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("centered"));
QCOMPARE(rect->x(), 75.0 + 10);
QCOMPARE(rect->y(), 75.0 + 30);
//Alter Offsets (QTBUG-6631)
@@ -429,15 +429,15 @@ void tst_anchors::centerIn()
delete view;
}
-void tst_anchors::margins()
+void tst_qmlgraphicsanchors::margins()
{
QmlView *view = new QmlView;
- view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/margins.qml"));
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/margins.qml"));
view->execute();
qApp->processEvents();
- QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("filler"));
+ QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("filler"));
QCOMPARE(rect->x(), 5.0);
QCOMPARE(rect->y(), 6.0);
QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0);
@@ -454,6 +454,6 @@ void tst_anchors::margins()
delete view;
}
-QTEST_MAIN(tst_anchors)
+QTEST_MAIN(tst_qmlgraphicsanchors)
#include "tst_qmlgraphicsanchors.moc"
diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.cpp b/tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.cpp
index 136e4cd..2342f25 100644
--- a/tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.cpp
+++ b/tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.cpp
@@ -58,11 +58,11 @@
} while (false)
-class tst_animatedimage : public QObject
+class tst_qmlgraphicsanimatedimage : public QObject
{
Q_OBJECT
public:
- tst_animatedimage() {}
+ tst_qmlgraphicsanimatedimage() {}
private slots:
void play();
@@ -75,7 +75,7 @@ private slots:
void invalidSource();
};
-void tst_animatedimage::play()
+void tst_qmlgraphicsanimatedimage::play()
{
QmlEngine engine;
QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickman.qml"));
@@ -86,7 +86,7 @@ void tst_animatedimage::play()
delete anim;
}
-void tst_animatedimage::pause()
+void tst_qmlgraphicsanimatedimage::pause()
{
QmlEngine engine;
QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml"));
@@ -98,7 +98,7 @@ void tst_animatedimage::pause()
delete anim;
}
-void tst_animatedimage::stopped()
+void tst_qmlgraphicsanimatedimage::stopped()
{
QmlEngine engine;
QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanstopped.qml"));
@@ -110,7 +110,7 @@ void tst_animatedimage::stopped()
delete anim;
}
-void tst_animatedimage::setFrame()
+void tst_qmlgraphicsanimatedimage::setFrame()
{
QmlEngine engine;
QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml"));
@@ -122,7 +122,7 @@ void tst_animatedimage::setFrame()
delete anim;
}
-void tst_animatedimage::frameCount()
+void tst_qmlgraphicsanimatedimage::frameCount()
{
QmlEngine engine;
QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/colors.qml"));
@@ -134,7 +134,7 @@ void tst_animatedimage::frameCount()
delete anim;
}
-void tst_animatedimage::remote()
+void tst_qmlgraphicsanimatedimage::remote()
{
QFETCH(QString, fileName);
QFETCH(bool, paused);
@@ -159,7 +159,7 @@ void tst_animatedimage::remote()
delete anim;
}
-void tst_animatedimage::remote_data()
+void tst_qmlgraphicsanimatedimage::remote_data()
{
QTest::addColumn<QString>("fileName");
QTest::addColumn<bool>("paused");
@@ -168,7 +168,7 @@ void tst_animatedimage::remote_data()
QTest::newRow("paused") << "stickmanpause.qml" << true;
}
-void tst_animatedimage::invalidSource()
+void tst_qmlgraphicsanimatedimage::invalidSource()
{
QmlEngine engine;
QmlComponent component(&engine);
@@ -186,6 +186,6 @@ void tst_animatedimage::invalidSource()
QCOMPARE(anim->frameCount(), 0);
}
-QTEST_MAIN(tst_animatedimage)
+QTEST_MAIN(tst_qmlgraphicsanimatedimage)
#include "tst_qmlgraphicsanimatedimage.moc"
diff --git a/tests/auto/declarative/qmlgraphicsflickable/tst_qmlgraphicsflickable.cpp b/tests/auto/declarative/qmlgraphicsflickable/tst_qmlgraphicsflickable.cpp
index 7fdc4fb..b503571 100644
--- a/tests/auto/declarative/qmlgraphicsflickable/tst_qmlgraphicsflickable.cpp
+++ b/tests/auto/declarative/qmlgraphicsflickable/tst_qmlgraphicsflickable.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
#include <qtest.h>
+#include <QtTest/QSignalSpy>
#include <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlcomponent.h>
#include <private/qmlgraphicsflickable_p.h>
@@ -56,6 +57,10 @@ private slots:
void horizontalViewportSize();
void verticalViewportSize();
void properties();
+ void overShoot();
+ void maximumFlickVelocity();
+ void flickDeceleration();
+ void pressDelay();
private:
QmlEngine engine;
@@ -140,6 +145,80 @@ void tst_qmlgraphicsflickable::properties()
delete obj;
}
+void tst_qmlgraphicsflickable::overShoot()
+{
+ QmlComponent component(&engine);
+ component.setData("import Qt 4.6; Flickable { overShoot: false; }", QUrl::fromLocalFile(""));
+ QmlGraphicsFlickable *flickable = qobject_cast<QmlGraphicsFlickable*>(component.create());
+ QSignalSpy spy(flickable, SIGNAL(overShootChanged()));
+
+ QVERIFY(flickable);
+ QVERIFY(!flickable->overShoot());
+
+ flickable->setOverShoot(true);
+ QVERIFY(flickable->overShoot());
+ QCOMPARE(spy.count(),1);
+ flickable->setOverShoot(true);
+ QCOMPARE(spy.count(),1);
+
+ flickable->setOverShoot(false);
+ QVERIFY(!flickable->overShoot());
+ QCOMPARE(spy.count(),2);
+ flickable->setOverShoot(false);
+ QCOMPARE(spy.count(),2);
+}
+
+void tst_qmlgraphicsflickable::maximumFlickVelocity()
+{
+ QmlComponent component(&engine);
+ component.setData("import Qt 4.6; Flickable { maximumFlickVelocity: 1.0; }", QUrl::fromLocalFile(""));
+ QmlGraphicsFlickable *flickable = qobject_cast<QmlGraphicsFlickable*>(component.create());
+ QSignalSpy spy(flickable, SIGNAL(maximumFlickVelocityChanged()));
+
+ QVERIFY(flickable);
+ QCOMPARE(flickable->maximumFlickVelocity(), 1.0);
+
+ flickable->setMaximumFlickVelocity(2.0);
+ QCOMPARE(flickable->maximumFlickVelocity(), 2.0);
+ QCOMPARE(spy.count(),1);
+ flickable->setMaximumFlickVelocity(2.0);
+ QCOMPARE(spy.count(),1);
+}
+
+void tst_qmlgraphicsflickable::flickDeceleration()
+{
+ QmlComponent component(&engine);
+ component.setData("import Qt 4.6; Flickable { flickDeceleration: 1.0; }", QUrl::fromLocalFile(""));
+ QmlGraphicsFlickable *flickable = qobject_cast<QmlGraphicsFlickable*>(component.create());
+ QSignalSpy spy(flickable, SIGNAL(flickDecelerationChanged()));
+
+ QVERIFY(flickable);
+ QCOMPARE(flickable->flickDeceleration(), 1.0);
+
+ flickable->setFlickDeceleration(2.0);
+ QCOMPARE(flickable->flickDeceleration(), 2.0);
+ QCOMPARE(spy.count(),1);
+ flickable->setFlickDeceleration(2.0);
+ QCOMPARE(spy.count(),1);
+}
+
+void tst_qmlgraphicsflickable::pressDelay()
+{
+ QmlComponent component(&engine);
+ component.setData("import Qt 4.6; Flickable { pressDelay: 100; }", QUrl::fromLocalFile(""));
+ QmlGraphicsFlickable *flickable = qobject_cast<QmlGraphicsFlickable*>(component.create());
+ QSignalSpy spy(flickable, SIGNAL(pressDelayChanged()));
+
+ QVERIFY(flickable);
+ QCOMPARE(flickable->pressDelay(), 100);
+
+ flickable->setPressDelay(200);
+ QCOMPARE(flickable->pressDelay(), 200);
+ QCOMPARE(spy.count(),1);
+ flickable->setPressDelay(200);
+ QCOMPARE(spy.count(),1);
+}
+
QTEST_MAIN(tst_qmlgraphicsflickable)
#include "tst_qmlgraphicsflickable.moc"
diff --git a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp
index 40b54d2..00127e5 100644
--- a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp
+++ b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp
@@ -70,9 +70,9 @@ private slots:
private:
QmlView *createView(const QString &filename);
template<typename T>
- T *findItem(QmlGraphicsItem *parent, const QString &id, int index=-1);
+ T *findItem(QGraphicsObject *parent, const QString &id, int index=-1);
template<typename T>
- QList<T*> findItems(QmlGraphicsItem *parent, const QString &objectName);
+ QList<T*> findItems(QGraphicsObject *parent, const QString &objectName);
void dumpTree(QmlGraphicsItem *parent, int depth = 0);
};
@@ -160,7 +160,7 @@ void tst_QmlGraphicsGridView::items()
canvas->execute();
qApp->processEvents();
- QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->root(), "grid");
+ QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid");
QVERIFY(gridview != 0);
QmlGraphicsItem *viewport = gridview->viewport();
@@ -208,7 +208,7 @@ void tst_QmlGraphicsGridView::changed()
canvas->execute();
qApp->processEvents();
- QmlGraphicsFlickable *gridview = findItem<QmlGraphicsFlickable>(canvas->root(), "grid");
+ QmlGraphicsFlickable *gridview = findItem<QmlGraphicsFlickable>(canvas->rootObject(), "grid");
QVERIFY(gridview != 0);
QmlGraphicsItem *viewport = gridview->viewport();
@@ -241,7 +241,7 @@ void tst_QmlGraphicsGridView::inserted()
canvas->execute();
qApp->processEvents();
- QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->root(), "grid");
+ QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid");
QVERIFY(gridview != 0);
QmlGraphicsItem *viewport = gridview->viewport();
@@ -322,7 +322,7 @@ void tst_QmlGraphicsGridView::removed()
canvas->execute();
qApp->processEvents();
- QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->root(), "grid");
+ QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid");
QVERIFY(gridview != 0);
QmlGraphicsItem *viewport = gridview->viewport();
@@ -482,7 +482,7 @@ void tst_QmlGraphicsGridView::moved()
canvas->execute();
qApp->processEvents();
- QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->root(), "grid");
+ QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid");
QVERIFY(gridview != 0);
QmlGraphicsItem *viewport = gridview->viewport();
@@ -578,15 +578,12 @@ void tst_QmlGraphicsGridView::currentIndex()
ctxt->setContextProperty("testModel", &model);
QString filename(SRCDIR "/data/gridview-initCurrent.qml");
- QFile file(filename);
- file.open(QFile::ReadOnly);
- QString qml = file.readAll();
- canvas->setQml(qml, filename);
+ canvas->setSource(QUrl::fromLocalFile(filename));
canvas->execute();
qApp->processEvents();
- QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->root(), "grid");
+ QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid");
QVERIFY(gridview != 0);
QmlGraphicsItem *viewport = gridview->viewport();
@@ -722,7 +719,7 @@ void tst_QmlGraphicsGridView::changeFlow()
canvas->execute();
qApp->processEvents();
- QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->root(), "grid");
+ QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid");
QVERIFY(gridview != 0);
QmlGraphicsItem *viewport = gridview->viewport();
@@ -827,7 +824,7 @@ void tst_QmlGraphicsGridView::positionViewAtIndex()
canvas->execute();
qApp->processEvents();
- QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->root(), "grid");
+ QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid");
QVERIFY(gridview != 0);
QmlGraphicsItem *viewport = gridview->viewport();
@@ -907,10 +904,7 @@ QmlView *tst_QmlGraphicsGridView::createView(const QString &filename)
QmlView *canvas = new QmlView(0);
canvas->setFixedSize(240,320);
- QFile file(filename);
- file.open(QFile::ReadOnly);
- QString qml = file.readAll();
- canvas->setQml(qml, filename);
+ canvas->setSource(QUrl::fromLocalFile(filename));
return canvas;
}
@@ -920,10 +914,10 @@ QmlView *tst_QmlGraphicsGridView::createView(const QString &filename)
item must also evaluate the {index} expression equal to index
*/
template<typename T>
-T *tst_QmlGraphicsGridView::findItem(QmlGraphicsItem *parent, const QString &objectName, int index)
+T *tst_QmlGraphicsGridView::findItem(QGraphicsObject *parent, const QString &objectName, int index)
{
const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->QGraphicsObject::children().count() << "children";
+ //qDebug() << parent->childItems().count() << "children";
for (int i = 0; i < parent->childItems().count(); ++i) {
QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
if(!item)
@@ -950,11 +944,11 @@ T *tst_QmlGraphicsGridView::findItem(QmlGraphicsItem *parent, const QString &obj
}
template<typename T>
-QList<T*> tst_QmlGraphicsGridView::findItems(QmlGraphicsItem *parent, const QString &objectName)
+QList<T*> tst_QmlGraphicsGridView::findItems(QGraphicsObject *parent, const QString &objectName)
{
QList<T*> items;
const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->QGraphicsObject::children().count() << "children";
+ //qDebug() << parent->childItems().count() << "children";
for (int i = 0; i < parent->childItems().count(); ++i) {
QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
if(!item)
diff --git a/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp b/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp
index 6673ced2..820a6de 100644
--- a/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp
+++ b/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp
@@ -39,11 +39,12 @@
**
****************************************************************************/
#include <qtest.h>
+#include <QtTest/QSignalSpy>
#include <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlcomponent.h>
#include <QtDeclarative/qmlcontext.h>
#include <QtDeclarative/qmlview.h>
-#include <qmlgraphicsitem.h>
+#include <QtDeclarative/qmlgraphicsitem.h>
class tst_QmlGraphicsItem : public QObject
@@ -55,10 +56,13 @@ public:
private slots:
void keys();
void keyNavigation();
+ void smooth();
+ void clip();
private:
template<typename T>
- T *findItem(QmlGraphicsItem *parent, const QString &objectName);
+ T *findItem(QGraphicsObject *parent, const QString &objectName);
+ QmlEngine engine;
};
class KeysTestObject : public QObject
@@ -108,7 +112,7 @@ void tst_QmlGraphicsItem::keys()
QmlView *canvas = new QmlView(0);
canvas->setFixedSize(240,320);
- canvas->setUrl(QUrl::fromLocalFile(SRCDIR "/data/keys.qml"));
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keys.qml"));
KeysTestObject *testObject = new KeysTestObject;
canvas->rootContext()->setContextProperty("keysTestObject", testObject);
@@ -190,7 +194,7 @@ void tst_QmlGraphicsItem::keyNavigation()
QmlView *canvas = new QmlView(0);
canvas->setFixedSize(240,320);
- canvas->setUrl(QUrl::fromLocalFile(SRCDIR "/data/keynavigation.qml"));
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keynavigation.qml"));
canvas->execute();
canvas->show();
qApp->processEvents();
@@ -200,7 +204,7 @@ void tst_QmlGraphicsItem::keyNavigation()
QFocusEvent fe(QEvent::FocusIn);
QApplication::sendEvent(canvas, &fe);
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(canvas->root(), "item1");
+ QmlGraphicsItem *item = findItem<QmlGraphicsItem>(canvas->rootObject(), "item1");
QVERIFY(item);
QVERIFY(item->hasFocus());
@@ -209,7 +213,7 @@ void tst_QmlGraphicsItem::keyNavigation()
QApplication::sendEvent(canvas, &key);
QVERIFY(key.isAccepted());
- item = findItem<QmlGraphicsItem>(canvas->root(), "item2");
+ item = findItem<QmlGraphicsItem>(canvas->rootObject(), "item2");
QVERIFY(item);
QVERIFY(item->hasFocus());
@@ -218,7 +222,7 @@ void tst_QmlGraphicsItem::keyNavigation()
QApplication::sendEvent(canvas, &key);
QVERIFY(key.isAccepted());
- item = findItem<QmlGraphicsItem>(canvas->root(), "item4");
+ item = findItem<QmlGraphicsItem>(canvas->rootObject(), "item4");
QVERIFY(item);
QVERIFY(item->hasFocus());
@@ -227,7 +231,7 @@ void tst_QmlGraphicsItem::keyNavigation()
QApplication::sendEvent(canvas, &key);
QVERIFY(key.isAccepted());
- item = findItem<QmlGraphicsItem>(canvas->root(), "item3");
+ item = findItem<QmlGraphicsItem>(canvas->rootObject(), "item3");
QVERIFY(item);
QVERIFY(item->hasFocus());
@@ -236,21 +240,67 @@ void tst_QmlGraphicsItem::keyNavigation()
QApplication::sendEvent(canvas, &key);
QVERIFY(key.isAccepted());
- item = findItem<QmlGraphicsItem>(canvas->root(), "item1");
+ item = findItem<QmlGraphicsItem>(canvas->rootObject(), "item1");
QVERIFY(item);
QVERIFY(item->hasFocus());
}
+void tst_QmlGraphicsItem::smooth()
+{
+ QmlComponent component(&engine);
+ component.setData("import Qt 4.6; Item { smooth: false; }", QUrl::fromLocalFile(""));
+ QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(component.create());
+ QSignalSpy spy(item, SIGNAL(smoothChanged()));
+
+ QVERIFY(item);
+ QVERIFY(!item->smooth());
+
+ item->setSmooth(true);
+ QVERIFY(item->smooth());
+ QCOMPARE(spy.count(),1);
+ item->setSmooth(true);
+ QCOMPARE(spy.count(),1);
+
+ item->setSmooth(false);
+ QVERIFY(!item->smooth());
+ QCOMPARE(spy.count(),2);
+ item->setSmooth(false);
+ QCOMPARE(spy.count(),2);
+}
+
+void tst_QmlGraphicsItem::clip()
+{
+ QmlComponent component(&engine);
+ component.setData("import Qt 4.6\nItem { clip: false\n }", QUrl::fromLocalFile(""));
+ QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(component.create());
+ QSignalSpy spy(item, SIGNAL(clipChanged()));
+
+ QVERIFY(item);
+ QVERIFY(!item->clip());
+
+ item->setClip(true);
+ QVERIFY(item->clip());
+ QCOMPARE(spy.count(),1);
+ item->setClip(true);
+ QCOMPARE(spy.count(),1);
+
+ item->setClip(false);
+ QVERIFY(!item->clip());
+ QCOMPARE(spy.count(),2);
+ item->setClip(false);
+ QCOMPARE(spy.count(),2);
+}
+
template<typename T>
-T *tst_QmlGraphicsItem::findItem(QmlGraphicsItem *parent, const QString &objectName)
+T *tst_QmlGraphicsItem::findItem(QGraphicsObject *parent, const QString &objectName)
{
if (!parent)
return 0;
const QMetaObject &mo = T::staticMetaObject;
//qDebug() << parent->QGraphicsObject::children().count() << "children";
- for (int i = 0; i < parent->QGraphicsObject::children().count(); ++i) {
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->QGraphicsObject::children().at(i));
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
if(!item)
continue;
//qDebug() << "try" << item;
diff --git a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp
index 560e625..13ed41d 100644
--- a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp
+++ b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp
@@ -90,9 +90,9 @@ private:
template <class T> void clear();
QmlView *createView(const QString &filename);
template<typename T>
- T *findItem(QmlGraphicsItem *parent, const QString &id, int index=-1);
+ T *findItem(QGraphicsObject *parent, const QString &id, int index=-1);
template<typename T>
- QList<T*> findItems(QmlGraphicsItem *parent, const QString &objectName);
+ QList<T*> findItems(QGraphicsObject *parent, const QString &objectName);
void dumpTree(QmlGraphicsItem *parent, int depth = 0);
};
@@ -316,13 +316,13 @@ void tst_QmlGraphicsListView::items()
canvas->execute();
qApp->processEvents();
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list");
+ QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
QVERIFY(listview != 0);
QmlGraphicsItem *viewport = listview->viewport();
QVERIFY(viewport != 0);
- QMetaObject::invokeMethod(canvas->root(), "checkProperties");
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
QVERIFY(testObject->error() == false);
QVERIFY(listview->highlightItem() != 0);
@@ -343,20 +343,20 @@ void tst_QmlGraphicsListView::items()
// switch to other delegate
testObject->setAnimate(true);
- QMetaObject::invokeMethod(canvas->root(), "checkProperties");
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
QVERIFY(testObject->error() == false);
QVERIFY(listview->currentItem());
// set invalid highlight
testObject->setInvalidHighlight(true);
- QMetaObject::invokeMethod(canvas->root(), "checkProperties");
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
QVERIFY(testObject->error() == false);
QVERIFY(listview->currentItem());
QVERIFY(listview->highlightItem() == 0);
// back to normal highlight
testObject->setInvalidHighlight(false);
- QMetaObject::invokeMethod(canvas->root(), "checkProperties");
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
QVERIFY(testObject->error() == false);
QVERIFY(listview->currentItem());
QVERIFY(listview->highlightItem() != 0);
@@ -396,7 +396,7 @@ void tst_QmlGraphicsListView::changed()
canvas->execute();
qApp->processEvents();
- QmlGraphicsFlickable *listview = findItem<QmlGraphicsFlickable>(canvas->root(), "list");
+ QmlGraphicsFlickable *listview = findItem<QmlGraphicsFlickable>(canvas->rootObject(), "list");
QVERIFY(listview != 0);
QmlGraphicsItem *viewport = listview->viewport();
@@ -432,7 +432,7 @@ void tst_QmlGraphicsListView::inserted()
canvas->execute();
qApp->processEvents();
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list");
+ QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
QVERIFY(listview != 0);
QmlGraphicsItem *viewport = listview->viewport();
@@ -501,6 +501,8 @@ void tst_QmlGraphicsListView::inserted()
QCOMPARE(item->y(), i*20.0 - 20.0);
}
+// QCOMPARE(listview->viewportHeight(), model.count() * 20.0);
+
delete canvas;
}
@@ -523,7 +525,7 @@ void tst_QmlGraphicsListView::removed(bool animated)
canvas->execute();
qApp->processEvents();
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list");
+ QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
QVERIFY(listview != 0);
QmlGraphicsItem *viewport = listview->viewport();
@@ -665,7 +667,7 @@ void tst_QmlGraphicsListView::clear()
canvas->execute();
qApp->processEvents();
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list");
+ QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
QVERIFY(listview != 0);
QmlGraphicsItem *viewport = listview->viewport();
@@ -702,7 +704,7 @@ void tst_QmlGraphicsListView::moved()
canvas->execute();
qApp->processEvents();
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list");
+ QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
QVERIFY(listview != 0);
QmlGraphicsItem *viewport = listview->viewport();
@@ -795,7 +797,7 @@ void tst_QmlGraphicsListView::enforceRange()
canvas->execute();
qApp->processEvents();
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list");
+ QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
QVERIFY(listview != 0);
QCOMPARE(listview->preferredHighlightBegin(), 100.0);
@@ -843,7 +845,7 @@ void tst_QmlGraphicsListView::spacing()
canvas->execute();
qApp->processEvents();
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list");
+ QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
QVERIFY(listview != 0);
QmlGraphicsItem *viewport = listview->viewport();
@@ -898,7 +900,7 @@ void tst_QmlGraphicsListView::sections()
canvas->execute();
qApp->processEvents();
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list");
+ QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
QVERIFY(listview != 0);
QmlGraphicsItem *viewport = listview->viewport();
@@ -971,15 +973,12 @@ void tst_QmlGraphicsListView::currentIndex()
ctxt->setContextProperty("testWrap", QVariant(false));
QString filename(SRCDIR "/data/listview-initCurrent.qml");
- QFile file(filename);
- file.open(QFile::ReadOnly);
- QString qml = file.readAll();
- canvas->setQml(qml, filename);
+ canvas->setSource(QUrl::fromLocalFile(filename));
canvas->execute();
qApp->processEvents();
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list");
+ QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
QVERIFY(listview != 0);
QmlGraphicsItem *viewport = listview->viewport();
@@ -1061,13 +1060,13 @@ void tst_QmlGraphicsListView::itemList()
canvas->execute();
qApp->processEvents();
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "view");
+ QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "view");
QVERIFY(listview != 0);
QmlGraphicsItem *viewport = listview->viewport();
QVERIFY(viewport != 0);
- QmlGraphicsVisualItemModel *model = canvas->root()->findChild<QmlGraphicsVisualItemModel*>("itemModel");
+ QmlGraphicsVisualItemModel *model = canvas->rootObject()->findChild<QmlGraphicsVisualItemModel*>("itemModel");
QVERIFY(model != 0);
QVERIFY(model->count() == 3);
@@ -1112,7 +1111,7 @@ void tst_QmlGraphicsListView::cacheBuffer()
canvas->execute();
qApp->processEvents();
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list");
+ QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
QVERIFY(listview != 0);
QmlGraphicsItem *viewport = listview->viewport();
@@ -1164,7 +1163,7 @@ void tst_QmlGraphicsListView::positionViewAtIndex()
canvas->execute();
qApp->processEvents();
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "list");
+ QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
QVERIFY(listview != 0);
QmlGraphicsItem *viewport = listview->viewport();
@@ -1301,10 +1300,7 @@ QmlView *tst_QmlGraphicsListView::createView(const QString &filename)
QmlView *canvas = new QmlView(0);
canvas->setFixedSize(240,320);
- QFile file(filename);
- file.open(QFile::ReadOnly);
- QString qml = file.readAll();
- canvas->setQml(qml, filename);
+ canvas->setSource(QUrl::fromLocalFile(filename));
return canvas;
}
@@ -1314,10 +1310,10 @@ QmlView *tst_QmlGraphicsListView::createView(const QString &filename)
item must also evaluate the {index} expression equal to index
*/
template<typename T>
-T *tst_QmlGraphicsListView::findItem(QmlGraphicsItem *parent, const QString &objectName, int index)
+T *tst_QmlGraphicsListView::findItem(QGraphicsObject *parent, const QString &objectName, int index)
{
const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->QGraphicsObject::children().count() << "children";
+ //qDebug() << parent->childItems().count() << "children";
for (int i = 0; i < parent->childItems().count(); ++i) {
QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
if(!item)
@@ -1342,11 +1338,11 @@ T *tst_QmlGraphicsListView::findItem(QmlGraphicsItem *parent, const QString &obj
}
template<typename T>
-QList<T*> tst_QmlGraphicsListView::findItems(QmlGraphicsItem *parent, const QString &objectName)
+QList<T*> tst_QmlGraphicsListView::findItems(QGraphicsObject *parent, const QString &objectName)
{
QList<T*> items;
const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->QGraphicsObject::children().count() << "children";
+ //qDebug() << parent->childItems().count() << "children";
for (int i = 0; i < parent->childItems().count(); ++i) {
QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
if(!item)
diff --git a/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp b/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp
index b38e8de..2d3d5ee 100644
--- a/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp
+++ b/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp
@@ -42,6 +42,7 @@
#include <QtGui/QGraphicsWidget>
#include <QtGui/QGraphicsScene>
+#include <QSignalSpy>
#include <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlcomponent.h>
#include <private/qmlgraphicsloader_p.h>
@@ -259,6 +260,13 @@ void tst_QmlGraphicsLoader::sizeLoaderToItem()
loader->setHeight(30);
QCOMPARE(rect->width(), 180.0);
QCOMPARE(rect->height(), 30.0);
+
+ // notify
+ QSignalSpy spy(loader, SIGNAL(resizeModeChanged()));
+ loader->setResizeMode(QmlGraphicsLoader::NoResize);
+ QCOMPARE(spy.count(),1);
+ loader->setResizeMode(QmlGraphicsLoader::NoResize);
+ QCOMPARE(spy.count(),1);
}
void tst_QmlGraphicsLoader::sizeItemToLoader()
@@ -381,7 +389,7 @@ void tst_QmlGraphicsLoader::networkRequestUrl()
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- server.serveDirectory("data");
+ server.serveDirectory(SRCDIR "/data");
QmlComponent component(&engine);
component.setData(QByteArray("import Qt 4.6\nLoader { source: \"http://127.0.0.1:14445/Rect120x60.qml\" }"), TEST_FILE(""));
@@ -433,7 +441,7 @@ void tst_QmlGraphicsLoader::failNetworkRequest()
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- server.serveDirectory("data");
+ server.serveDirectory(SRCDIR "/data");
QTest::ignoreMessage(QtWarningMsg, "(:-1: Network error for URL http://127.0.0.1:14445/IDontExist.qml) ");
diff --git a/tests/auto/declarative/qmlgraphicsmouseregion/data/dragproperties.qml b/tests/auto/declarative/qmlgraphicsmouseregion/data/dragproperties.qml
new file mode 100644
index 0000000..5acb3e4
--- /dev/null
+++ b/tests/auto/declarative/qmlgraphicsmouseregion/data/dragproperties.qml
@@ -0,0 +1,28 @@
+import Qt 4.6
+Rectangle {
+ id: whiteRect
+ width: 200
+ height: 200
+ color: "white"
+ Rectangle {
+ id: blackRect
+ objectName: "blackrect"
+ color: "black"
+ y: 50
+ x: 50
+ width: 100
+ height: 100
+ opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200
+ Text { text: blackRect.opacity}
+ MouseRegion {
+ objectName: "mouseregion"
+ anchors.fill: parent
+ drag.target: blackRect
+ drag.axis: Drag.XandYAxis
+ drag.minimumX: 0
+ drag.maximumX: whiteRect.width-blackRect.width
+ drag.minimumY: 0
+ drag.maximumY: whiteRect.height-blackRect.height
+ }
+ }
+ } \ No newline at end of file
diff --git a/tests/auto/declarative/qmlgraphicsmouseregion/qmlgraphicsmouseregion.pro b/tests/auto/declarative/qmlgraphicsmouseregion/qmlgraphicsmouseregion.pro
new file mode 100644
index 0000000..7a7c8bd
--- /dev/null
+++ b/tests/auto/declarative/qmlgraphicsmouseregion/qmlgraphicsmouseregion.pro
@@ -0,0 +1,9 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui network
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/testhttpserver.h
+SOURCES += tst_qmlgraphicsmouseregion.cpp ../shared/testhttpserver.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsmouseregion/tst_qmlgraphicsmouseregion.cpp b/tests/auto/declarative/qmlgraphicsmouseregion/tst_qmlgraphicsmouseregion.cpp
new file mode 100644
index 0000000..82da9c8
--- /dev/null
+++ b/tests/auto/declarative/qmlgraphicsmouseregion/tst_qmlgraphicsmouseregion.cpp
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 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 <QtTest/QSignalSpy>
+#include <private/qmlgraphicsmouseregion_p.h>
+#include <QtDeclarative/qmlview.h>
+
+class tst_QmlGraphicsMouseRegion: public QObject
+{
+ Q_OBJECT
+private slots:
+ void dragProperties();
+private:
+ QmlView *createView(const QString &filename);
+};
+
+void tst_QmlGraphicsMouseRegion::dragProperties()
+{
+ QmlView *canvas = createView(SRCDIR "/data/dragproperties.qml");
+ canvas->execute();
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QmlGraphicsMouseRegion *mouseRegion = canvas->rootObject()->findChild<QmlGraphicsMouseRegion*>("mouseregion");
+ QmlGraphicsDrag *drag = mouseRegion->drag();
+ QVERIFY(mouseRegion != 0);
+ QVERIFY(drag != 0);
+
+ // target
+ QmlGraphicsItem *blackRect = canvas->rootObject()->findChild<QmlGraphicsItem*>("blackrect");
+ QVERIFY(blackRect != 0);
+ QVERIFY(blackRect == drag->target());
+ QmlGraphicsItem *rootItem = qobject_cast<QmlGraphicsItem*>(canvas->rootObject());
+ QVERIFY(rootItem != 0);
+ QSignalSpy targetSpy(drag, SIGNAL(targetChanged()));
+ drag->setTarget(rootItem);
+ QCOMPARE(targetSpy.count(),1);
+ drag->setTarget(rootItem);
+ QCOMPARE(targetSpy.count(),1);
+
+ // axis
+ QCOMPARE(drag->axis(), QmlGraphicsDrag::XandYAxis);
+ QSignalSpy axisSpy(drag, SIGNAL(axisChanged()));
+ drag->setAxis(QmlGraphicsDrag::XAxis);
+ QCOMPARE(drag->axis(), QmlGraphicsDrag::XAxis);
+ QCOMPARE(axisSpy.count(),1);
+ drag->setAxis(QmlGraphicsDrag::XAxis);
+ QCOMPARE(axisSpy.count(),1);
+
+ // minimum and maximum properties
+ QSignalSpy xminSpy(drag, SIGNAL(minimumXChanged()));
+ QSignalSpy xmaxSpy(drag, SIGNAL(maximumXChanged()));
+ QSignalSpy yminSpy(drag, SIGNAL(minimumYChanged()));
+ QSignalSpy ymaxSpy(drag, SIGNAL(maximumYChanged()));
+
+ QCOMPARE(drag->xmin(), 0.0);
+ QCOMPARE(drag->xmax(), rootItem->width()-blackRect->width());
+ QCOMPARE(drag->ymin(), 0.0);
+ QCOMPARE(drag->ymax(), rootItem->height()-blackRect->height());
+
+ drag->setXmin(10);
+ drag->setXmax(10);
+ drag->setYmin(10);
+ drag->setYmax(10);
+
+ QCOMPARE(drag->xmin(), 10.0);
+ QCOMPARE(drag->xmax(), 10.0);
+ QCOMPARE(drag->ymin(), 10.0);
+ QCOMPARE(drag->ymax(), 10.0);
+
+ QCOMPARE(xminSpy.count(),1);
+ QCOMPARE(xmaxSpy.count(),1);
+ QCOMPARE(yminSpy.count(),1);
+ QCOMPARE(ymaxSpy.count(),1);
+
+ drag->setXmin(10);
+ drag->setXmax(10);
+ drag->setYmin(10);
+ drag->setYmax(10);
+
+ QCOMPARE(xminSpy.count(),1);
+ QCOMPARE(xmaxSpy.count(),1);
+ QCOMPARE(yminSpy.count(),1);
+ QCOMPARE(ymaxSpy.count(),1);
+}
+
+QmlView *tst_QmlGraphicsMouseRegion::createView(const QString &filename)
+{
+ QmlView *canvas = new QmlView(0);
+ canvas->setFixedSize(240,320);
+
+ canvas->setSource(QUrl::fromLocalFile(filename));
+
+ return canvas;
+}
+
+QTEST_MAIN(tst_QmlGraphicsMouseRegion)
+
+#include "tst_qmlgraphicsmouseregion.moc"
diff --git a/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp b/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp
index d9ddf4b..a5c0b78 100644
--- a/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp
+++ b/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp
@@ -63,8 +63,8 @@ tst_QmlGraphicsParticles::tst_QmlGraphicsParticles()
void tst_QmlGraphicsParticles::properties()
{
QmlView *canvas = createView(SRCDIR "/data/particles.qml");
- QVERIFY(canvas->root());
- QmlGraphicsParticles* particles = canvas->root()->findChild<QmlGraphicsParticles*>("particles");
+ QVERIFY(canvas->rootObject());
+ QmlGraphicsParticles* particles = canvas->rootObject()->findChild<QmlGraphicsParticles*>("particles");
QVERIFY(particles);
particles->setSource(QUrl::fromLocalFile(SRCDIR "/data/particle.png"));
@@ -101,8 +101,8 @@ void tst_QmlGraphicsParticles::properties()
void tst_QmlGraphicsParticles::runs()
{
QmlView *canvas = createView(SRCDIR "/data/particles.qml");
- QVERIFY(canvas->root());
- QmlGraphicsParticles* particles = canvas->root()->findChild<QmlGraphicsParticles*>("particles");
+ QVERIFY(canvas->rootObject());
+ QmlGraphicsParticles* particles = canvas->rootObject()->findChild<QmlGraphicsParticles*>("particles");
QVERIFY(particles);
QTest::qWait(1000);//Run for one second. Test passes if it doesn't crash.
}
@@ -112,10 +112,7 @@ QmlView *tst_QmlGraphicsParticles::createView(const QString &filename)
QmlView *canvas = new QmlView(0);
canvas->setFixedSize(240,320);
- QFile file(filename);
- file.open(QFile::ReadOnly);
- QString qml = file.readAll();
- canvas->setQml(qml, filename);
+ canvas->setSource(QUrl::fromLocalFile(filename));
canvas->execute();
return canvas;
diff --git a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp b/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp
index 90e0de3..072f740 100644
--- a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp
+++ b/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp
@@ -71,9 +71,9 @@ private slots:
private:
QmlView *createView(const QString &filename);
template<typename T>
- T *findItem(QmlGraphicsItem *parent, const QString &objectName, int index=-1);
+ T *findItem(QGraphicsObject *parent, const QString &objectName, int index=-1);
template<typename T>
- QList<T*> findItems(QmlGraphicsItem *parent, const QString &objectName);
+ QList<T*> findItems(QGraphicsObject *parent, const QString &objectName);
};
class TestObject : public QObject
@@ -204,7 +204,7 @@ void tst_QmlGraphicsPathView::items()
canvas->execute();
qApp->processEvents();
- QmlGraphicsPathView *pathview = findItem<QmlGraphicsPathView>(canvas->root(), "view");
+ QmlGraphicsPathView *pathview = findItem<QmlGraphicsPathView>(canvas->rootObject(), "view");
QVERIFY(pathview != 0);
QCOMPARE(pathview->childItems().count(), model.count()); // assumes all are visible
@@ -326,10 +326,10 @@ void tst_QmlGraphicsPathView::dataModel()
canvas->execute();
qApp->processEvents();
- QmlGraphicsPathView *pathview = qobject_cast<QmlGraphicsPathView*>(canvas->root());
+ QmlGraphicsPathView *pathview = qobject_cast<QmlGraphicsPathView*>(canvas->rootObject());
QVERIFY(pathview != 0);
- QMetaObject::invokeMethod(canvas->root(), "checkProperties");
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
QVERIFY(testObject->error() == false);
QmlGraphicsItem *item = findItem<QmlGraphicsItem>(pathview, "wrapper", 0);
@@ -352,7 +352,7 @@ void tst_QmlGraphicsPathView::dataModel()
QCOMPARE(text->text(), model.name(2));
testObject->setPathItemCount(5);
- QMetaObject::invokeMethod(canvas->root(), "checkProperties");
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
QVERIFY(testObject->error() == false);
itemCount = findItems<QmlGraphicsItem>(pathview, "wrapper").count();
@@ -398,7 +398,7 @@ void tst_QmlGraphicsPathView::pathMoved()
canvas->execute();
qApp->processEvents();
- QmlGraphicsPathView *pathview = findItem<QmlGraphicsPathView>(canvas->root(), "view");
+ QmlGraphicsPathView *pathview = findItem<QmlGraphicsPathView>(canvas->rootObject(), "view");
QVERIFY(pathview != 0);
QmlGraphicsRectangle *firstItem = findItem<QmlGraphicsRectangle>(pathview, "wrapper", 0);
@@ -430,10 +430,7 @@ QmlView *tst_QmlGraphicsPathView::createView(const QString &filename)
QmlView *canvas = new QmlView(0);
canvas->setFixedSize(240,320);
- QFile file(filename);
- file.open(QFile::ReadOnly);
- QString qml = file.readAll();
- canvas->setQml(qml, filename);
+ canvas->setSource(QUrl::fromLocalFile(filename));
return canvas;
}
@@ -443,7 +440,7 @@ QmlView *tst_QmlGraphicsPathView::createView(const QString &filename)
item must also evaluate the {index} expression equal to index
*/
template<typename T>
-T *tst_QmlGraphicsPathView::findItem(QmlGraphicsItem *parent, const QString &objectName, int index)
+T *tst_QmlGraphicsPathView::findItem(QGraphicsObject *parent, const QString &objectName, int index)
{
const QMetaObject &mo = T::staticMetaObject;
//qDebug() << parent->childItems().count() << "children";
@@ -471,7 +468,7 @@ T *tst_QmlGraphicsPathView::findItem(QmlGraphicsItem *parent, const QString &obj
}
template<typename T>
-QList<T*> tst_QmlGraphicsPathView::findItems(QmlGraphicsItem *parent, const QString &objectName)
+QList<T*> tst_QmlGraphicsPathView::findItems(QGraphicsObject *parent, const QString &objectName)
{
QList<T*> items;
const QMetaObject &mo = T::staticMetaObject;
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml b/tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml
index 022019c..f6376a1 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml
+++ b/tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml
@@ -7,12 +7,12 @@ Item {
columns: 3
add: Transition {
NumberAnimation {
- matchProperties: "x,y";
+ properties: "x,y";
}
}
move: Transition {
NumberAnimation {
- matchProperties: "x,y";
+ properties: "x,y";
}
}
Rectangle {
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml b/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml
index eba165c..c113a36 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml
+++ b/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml
@@ -6,12 +6,12 @@ Item {
Row {
add: Transition {
NumberAnimation {
- matchProperties: "x";
+ properties: "x";
}
}
move: Transition {
NumberAnimation {
- matchProperties: "x";
+ properties: "x";
}
}
Rectangle {
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml b/tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml
index 8e3abbd..10f6cbb 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml
+++ b/tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml
@@ -6,12 +6,12 @@ Item {
Column {
add: Transition {
NumberAnimation {
- matchProperties: "y";
+ properties: "y";
}
}
move: Transition {
NumberAnimation {
- matchProperties: "y";
+ properties: "y";
}
}
Rectangle {
diff --git a/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp b/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp
index d6b4f87..b51266a 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp
+++ b/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp
@@ -43,6 +43,7 @@
#include <qmlview.h>
#include <private/qmlgraphicsrectangle_p.h>
#include <qmlexpression.h>
+#include "../../../shared/util.h"
class tst_QmlGraphicsPositioners : public QObject
{
@@ -75,15 +76,14 @@ void tst_QmlGraphicsPositioners::test_horizontal()
QmlView *canvas = createView(SRCDIR "/data/horizontal.qml");
canvas->execute();
- qApp->processEvents();
- QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
+ QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
- QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two");
+ QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
QVERIFY(two != 0);
- QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three");
+ QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
QVERIFY(three != 0);
QCOMPARE(one->x(), 0.0);
@@ -99,15 +99,14 @@ void tst_QmlGraphicsPositioners::test_horizontal_spacing()
QmlView *canvas = createView(SRCDIR "/data/horizontal-spacing.qml");
canvas->execute();
- qApp->processEvents();
- QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
+ QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
- QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two");
+ QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
QVERIFY(two != 0);
- QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three");
+ QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
QVERIFY(three != 0);
QCOMPARE(one->x(), 0.0);
@@ -123,30 +122,31 @@ void tst_QmlGraphicsPositioners::test_horizontal_animated()
QmlView *canvas = createView(SRCDIR "/data/horizontal-animated.qml");
canvas->execute();
- qApp->processEvents();
- //Note that they animate in
- QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
+ QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
- QCOMPARE(one->x(), -100.0);
- QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two");
+ QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
QVERIFY(two != 0);
- QCOMPARE(two->x(), -100.0);
- QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three");
+ QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
QVERIFY(three != 0);
+
+ //Note that they animate in
+ QCOMPARE(one->x(), -100.0);
+ QCOMPARE(two->x(), -100.0);
QCOMPARE(three->x(), -100.0);
- QTest::qWait(300);//Let the animation complete
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->opacity(), 0.0);
- QCOMPARE(two->x(), -100.0);//Not 'in' yet
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 50.0);
- QCOMPARE(three->y(), 0.0);
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(two->opacity(), 0.0);
+ QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet
+ QTRY_COMPARE(two->y(), 0.0);
+ QTRY_COMPARE(three->x(), 50.0);
+ QTRY_COMPARE(three->y(), 0.0);
//Add 'two'
two->setOpacity(1.0);
@@ -154,9 +154,9 @@ void tst_QmlGraphicsPositioners::test_horizontal_animated()
QTest::qWait(0);//Let the animation start
QCOMPARE(two->x(), -100.0);
QCOMPARE(three->x(), 50.0);
- QTest::qWait(300);//Let the animation complete
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(three->x(), 100.0);
+
+ QTRY_COMPARE(two->x(), 50.0);
+ QTRY_COMPARE(three->x(), 100.0);
}
void tst_QmlGraphicsPositioners::test_vertical()
@@ -164,15 +164,14 @@ void tst_QmlGraphicsPositioners::test_vertical()
QmlView *canvas = createView(SRCDIR "/data/vertical.qml");
canvas->execute();
- qApp->processEvents();
- QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
+ QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
- QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two");
+ QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
QVERIFY(two != 0);
- QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three");
+ QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
QVERIFY(three != 0);
QCOMPARE(one->x(), 0.0);
@@ -188,15 +187,14 @@ void tst_QmlGraphicsPositioners::test_vertical_spacing()
QmlView *canvas = createView(SRCDIR "/data/vertical-spacing.qml");
canvas->execute();
- qApp->processEvents();
- QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
+ QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
- QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two");
+ QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
QVERIFY(two != 0);
- QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three");
+ QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
QVERIFY(three != 0);
QCOMPARE(one->x(), 0.0);
@@ -212,41 +210,40 @@ void tst_QmlGraphicsPositioners::test_vertical_animated()
QmlView *canvas = createView(SRCDIR "/data/vertical-animated.qml");
canvas->execute();
- qApp->processEvents();
- QTest::qWait(0);//Let the animation start
//Note that they animate in
- QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
+ QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
QCOMPARE(one->y(), -100.0);
- QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two");
+ QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
QVERIFY(two != 0);
QCOMPARE(two->y(), -100.0);
- QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three");
+ QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
QVERIFY(three != 0);
QCOMPARE(three->y(), -100.0);
- QTest::qWait(300);//Let the animation complete
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(two->opacity(), 0.0);
- QCOMPARE(two->y(), -100.0);//Not 'in' yet
- QCOMPARE(two->x(), 0.0);
- QCOMPARE(three->y(), 50.0);
- QCOMPARE(three->x(), 0.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(two->opacity(), 0.0);
+ QTRY_COMPARE(two->y(), -100.0);//Not 'in' yet
+ QTRY_COMPARE(two->x(), 0.0);
+ QTRY_COMPARE(three->y(), 50.0);
+ QTRY_COMPARE(three->x(), 0.0);
//Add 'two'
two->setOpacity(1.0);
- QCOMPARE(two->opacity(), 1.0);
+ QTRY_COMPARE(two->opacity(), 1.0);
QTest::qWait(0);//Let the animation start
QCOMPARE(two->y(), -100.0);
QCOMPARE(three->y(), 50.0);
- QTest::qWait(300);//Let the animation complete
- QCOMPARE(two->y(), 50.0);
- QCOMPARE(three->y(), 100.0);
+
+ QTRY_COMPARE(two->y(), 50.0);
+ QTRY_COMPARE(three->y(), 100.0);
}
@@ -255,17 +252,16 @@ void tst_QmlGraphicsPositioners::test_grid()
QmlView *canvas = createView("data/grid.qml");
canvas->execute();
- qApp->processEvents();
- QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
+ QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
- QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two");
+ QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
QVERIFY(two != 0);
- QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three");
+ QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
QVERIFY(three != 0);
- QmlGraphicsRectangle *four = canvas->root()->findChild<QmlGraphicsRectangle*>("four");
+ QmlGraphicsRectangle *four = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("four");
QVERIFY(four != 0);
- QmlGraphicsRectangle *five = canvas->root()->findChild<QmlGraphicsRectangle*>("five");
+ QmlGraphicsRectangle *five = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("five");
QVERIFY(five != 0);
QCOMPARE(one->x(), 0.0);
@@ -285,17 +281,16 @@ void tst_QmlGraphicsPositioners::test_grid_spacing()
QmlView *canvas = createView("data/grid-spacing.qml");
canvas->execute();
- qApp->processEvents();
- QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
+ QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
- QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two");
+ QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
QVERIFY(two != 0);
- QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three");
+ QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
QVERIFY(three != 0);
- QmlGraphicsRectangle *four = canvas->root()->findChild<QmlGraphicsRectangle*>("four");
+ QmlGraphicsRectangle *four = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("four");
QVERIFY(four != 0);
- QmlGraphicsRectangle *five = canvas->root()->findChild<QmlGraphicsRectangle*>("five");
+ QmlGraphicsRectangle *five = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("five");
QVERIFY(five != 0);
QCOMPARE(one->x(), 0.0);
@@ -314,48 +309,47 @@ void tst_QmlGraphicsPositioners::test_grid_animated()
{
QmlView *canvas = createView(SRCDIR "/data/grid-animated.qml");
canvas->execute();
- qApp->processEvents();
- QTest::qWait(0);//Let the animation start
//Note that all animate in
- QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
+ QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
QCOMPARE(one->x(), -100.0);
QCOMPARE(one->y(), -100.0);
- QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two");
+ QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
QVERIFY(two != 0);
QCOMPARE(two->x(), -100.0);
QCOMPARE(two->y(), -100.0);
- QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three");
+ QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
QVERIFY(three != 0);
QCOMPARE(three->x(), -100.0);
QCOMPARE(three->y(), -100.0);
- QmlGraphicsRectangle *four = canvas->root()->findChild<QmlGraphicsRectangle*>("four");
+ QmlGraphicsRectangle *four = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("four");
QVERIFY(four != 0);
QCOMPARE(four->x(), -100.0);
QCOMPARE(four->y(), -100.0);
- QmlGraphicsRectangle *five = canvas->root()->findChild<QmlGraphicsRectangle*>("five");
+ QmlGraphicsRectangle *five = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("five");
QVERIFY(five != 0);
QCOMPARE(five->x(), -100.0);
QCOMPARE(five->y(), -100.0);
- QTest::qWait(300);//Let the animation complete
-
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(two->opacity(), 0.0);
- QCOMPARE(two->y(), -100.0);
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(three->x(), 50.0);
- QCOMPARE(four->y(), 0.0);
- QCOMPARE(four->x(), 100.0);
- QCOMPARE(five->y(), 50.0);
- QCOMPARE(five->x(), 0.0);
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
+
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(two->opacity(), 0.0);
+ QTRY_COMPARE(two->y(), -100.0);
+ QTRY_COMPARE(two->x(), -100.0);
+ QTRY_COMPARE(three->y(), 0.0);
+ QTRY_COMPARE(three->x(), 50.0);
+ QTRY_COMPARE(four->y(), 0.0);
+ QTRY_COMPARE(four->x(), 100.0);
+ QTRY_COMPARE(five->y(), 50.0);
+ QTRY_COMPARE(five->x(), 0.0);
//Add 'two'
two->setOpacity(1.0);
@@ -371,17 +365,17 @@ void tst_QmlGraphicsPositioners::test_grid_animated()
QCOMPARE(four->y(), 0.0);
QCOMPARE(five->x(), 0.0);
QCOMPARE(five->y(), 50.0);
- QTest::qWait(300);//Let the animation complete
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(three->x(), 100.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 50.0);
- QCOMPARE(five->x(), 50.0);
- QCOMPARE(five->y(), 50.0);
+ //Let the animation complete
+ QTRY_COMPARE(two->x(), 50.0);
+ QTRY_COMPARE(two->y(), 0.0);
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(three->x(), 100.0);
+ QTRY_COMPARE(three->y(), 0.0);
+ QTRY_COMPARE(four->x(), 0.0);
+ QTRY_COMPARE(four->y(), 50.0);
+ QTRY_COMPARE(five->x(), 50.0);
+ QTRY_COMPARE(five->y(), 50.0);
}
@@ -390,15 +384,14 @@ void tst_QmlGraphicsPositioners::test_repeater()
QmlView *canvas = createView("data/repeater.qml");
canvas->execute();
- qApp->processEvents();
- QmlGraphicsRectangle *one = canvas->root()->findChild<QmlGraphicsRectangle*>("one");
+ QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
QVERIFY(one != 0);
- QmlGraphicsRectangle *two = canvas->root()->findChild<QmlGraphicsRectangle*>("two");
+ QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
QVERIFY(two != 0);
- QmlGraphicsRectangle *three = canvas->root()->findChild<QmlGraphicsRectangle*>("three");
+ QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
QVERIFY(three != 0);
QCOMPARE(one->x(), 0.0);
@@ -413,10 +406,7 @@ QmlView *tst_QmlGraphicsPositioners::createView(const QString &filename)
{
QmlView *canvas = new QmlView(0);
- QFile file(filename);
- file.open(QFile::ReadOnly);
- QString xml = file.readAll();
- canvas->setQml(xml, filename);
+ canvas->setSource(QUrl::fromLocalFile(filename));
return canvas;
}
diff --git a/tests/auto/declarative/qmlgraphicsrepeater/data/properties.qml b/tests/auto/declarative/qmlgraphicsrepeater/data/properties.qml
new file mode 100644
index 0000000..550ce8d
--- /dev/null
+++ b/tests/auto/declarative/qmlgraphicsrepeater/data/properties.qml
@@ -0,0 +1,11 @@
+import Qt 4.6
+
+Row {
+ Repeater {
+ objectName: "repeater"
+ model: 5
+ Text {
+ text: "I'm item " + index
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp b/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp
index a81b990..9e3a028 100644
--- a/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp
+++ b/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp
@@ -38,12 +38,20 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+
#include <QtTest/QtTest>
+#include <QtTest/QSignalSpy>
#include <private/qlistmodelinterface_p.h>
-#include <qmlview.h>
+#include <QtDeclarative/qmlengine.h>
+#include <QtDeclarative/qmlview.h>
+#include <QtDeclarative/qmlcontext.h>
#include <private/qmlgraphicsrepeater_p.h>
#include <private/qmlgraphicstext_p.h>
-#include <qmlcontext.h>
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
+}
class tst_QmlGraphicsRepeater : public QObject
{
@@ -57,11 +65,12 @@ private slots:
void stringList();
void dataModel();
void itemModel();
+ void properties();
private:
QmlView *createView(const QString &filename);
template<typename T>
- T *findItem(QmlGraphicsItem *parent, const QString &id);
+ T *findItem(QGraphicsObject *parent, const QString &id);
};
class TestObject : public QObject
@@ -165,11 +174,11 @@ void tst_QmlGraphicsRepeater::numberModel()
canvas->execute();
qApp->processEvents();
- QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->root(), "repeater");
+ QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater");
QVERIFY(repeater != 0);
QCOMPARE(repeater->parentItem()->childItems().count(), 5+1);
- QMetaObject::invokeMethod(canvas->root(), "checkProperties");
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
QVERIFY(testObject->error() == false);
delete canvas;
@@ -191,7 +200,7 @@ void tst_QmlGraphicsRepeater::objectList()
canvas->execute();
qApp->processEvents();
- QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->root(), "repeater");
+ QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater");
QVERIFY(repeater != 0);
QCOMPARE(repeater->property("errors").toInt(), 0);//If this fails either they are out of order or can't find the object's data
QCOMPARE(repeater->property("instantiated").toInt(), 100);
@@ -218,10 +227,10 @@ void tst_QmlGraphicsRepeater::stringList()
canvas->execute();
qApp->processEvents();
- QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->root(), "repeater");
+ QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater");
QVERIFY(repeater != 0);
- QmlGraphicsItem *container = findItem<QmlGraphicsItem>(canvas->root(), "container");
+ QmlGraphicsItem *container = findItem<QmlGraphicsItem>(canvas->rootObject(), "container");
QVERIFY(container != 0);
QCOMPARE(container->childItems().count(), data.count() + 3);
@@ -271,10 +280,10 @@ void tst_QmlGraphicsRepeater::dataModel()
canvas->execute();
qApp->processEvents();
- QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->root(), "repeater");
+ QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater");
QVERIFY(repeater != 0);
- QmlGraphicsItem *container = findItem<QmlGraphicsItem>(canvas->root(), "container");
+ QmlGraphicsItem *container = findItem<QmlGraphicsItem>(canvas->rootObject(), "container");
QVERIFY(container != 0);
QCOMPARE(container->childItems().count(), 4);
@@ -296,16 +305,16 @@ void tst_QmlGraphicsRepeater::itemModel()
canvas->execute();
qApp->processEvents();
- QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->root(), "repeater");
+ QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater");
QVERIFY(repeater != 0);
- QmlGraphicsItem *container = findItem<QmlGraphicsItem>(canvas->root(), "container");
+ QmlGraphicsItem *container = findItem<QmlGraphicsItem>(canvas->rootObject(), "container");
QVERIFY(container != 0);
QCOMPARE(container->childItems().count(), 1);
testObject->setUseModel(true);
- QMetaObject::invokeMethod(canvas->root(), "checkProperties");
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
QVERIFY(testObject->error() == false);
QCOMPARE(container->childItems().count(), 4);
@@ -317,22 +326,46 @@ void tst_QmlGraphicsRepeater::itemModel()
delete canvas;
}
+void tst_QmlGraphicsRepeater::properties()
+{
+ QmlEngine engine;
+ QmlComponent component(&engine, TEST_FILE("/properties.qml"));
+
+ QmlGraphicsItem *rootObject = qobject_cast<QmlGraphicsItem*>(component.create());
+ QVERIFY(rootObject);
+
+ QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(rootObject, "repeater");
+ QVERIFY(repeater);
+
+ QSignalSpy modelSpy(repeater, SIGNAL(modelChanged()));
+ repeater->setModel(3);
+ QCOMPARE(modelSpy.count(),1);
+ repeater->setModel(3);
+ QCOMPARE(modelSpy.count(),1);
+
+ QSignalSpy delegateSpy(repeater, SIGNAL(delegateChanged()));
+
+ QmlComponent rectComponent(&engine);
+ rectComponent.setData("import Qt 4.6; Rectangle {}", QUrl::fromLocalFile(""));
+
+ repeater->setDelegate(&rectComponent);
+ QCOMPARE(delegateSpy.count(),1);
+ repeater->setDelegate(&rectComponent);
+ QCOMPARE(delegateSpy.count(),1);
+}
QmlView *tst_QmlGraphicsRepeater::createView(const QString &filename)
{
QmlView *canvas = new QmlView(0);
canvas->setFixedSize(240,320);
- QFile file(filename);
- file.open(QFile::ReadOnly);
- QString qml = file.readAll();
- canvas->setQml(qml, filename);
+ canvas->setSource(QUrl::fromLocalFile(filename));
return canvas;
}
template<typename T>
-T *tst_QmlGraphicsRepeater::findItem(QmlGraphicsItem *parent, const QString &objectName)
+T *tst_QmlGraphicsRepeater::findItem(QGraphicsObject *parent, const QString &objectName)
{
const QMetaObject &mo = T::staticMetaObject;
if (mo.cast(parent) && (objectName.isEmpty() || parent->objectName() == objectName))
diff --git a/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp b/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp
index 11fe689..cc2f929 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp
+++ b/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp
@@ -608,8 +608,8 @@ void tst_qmlgraphicstextedit::inputMethodHints()
canvas->show();
canvas->setFocus();
- QVERIFY(canvas->root() != 0);
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit *>(canvas->root());
+ QVERIFY(canvas->rootObject() != 0);
+ QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit *>(canvas->rootObject());
QVERIFY(textEditObject != 0);
QVERIFY(textEditObject->inputMethodHints() & Qt::ImhNoPredictiveText);
textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly);
@@ -622,7 +622,7 @@ void tst_qmlgraphicstextedit::cursorDelegate()
view->execute();
view->show();
view->setFocus();
- QmlGraphicsTextEdit *textEditObject = view->root()->findChild<QmlGraphicsTextEdit*>("textEditObject");
+ QmlGraphicsTextEdit *textEditObject = view->rootObject()->findChild<QmlGraphicsTextEdit*>("textEditObject");
QVERIFY(textEditObject != 0);
QVERIFY(textEditObject->findChild<QmlGraphicsItem*>("cursorInstance"));
//Test Delegate gets created
@@ -650,40 +650,34 @@ void tst_qmlgraphicstextedit::delegateLoading()
server.serveDirectory(SRCDIR "/data/httpslow", TestHTTPServer::Delay);
server.serveDirectory(SRCDIR "/data/http");
QmlView* view = new QmlView(0);
- view->setUrl(QUrl("http://localhost:42332/cursorHttpTestPass.qml"));
+ view->setSource(QUrl("http://localhost:42332/cursorHttpTestPass.qml"));
view->execute();
view->show();
view->setFocus();
- QTRY_VERIFY(view->root());//Wait for loading to finish.
- QmlGraphicsTextEdit *textEditObject = view->root()->findChild<QmlGraphicsTextEdit*>("textEditObject");
- // view->root()->dumpObjectTree();
+ QTRY_VERIFY(view->rootObject());//Wait for loading to finish.
+ QmlGraphicsTextEdit *textEditObject = view->rootObject()->findChild<QmlGraphicsTextEdit*>("textEditObject");
+ // view->rootObject()->dumpObjectTree();
QVERIFY(textEditObject != 0);
textEditObject->setFocus(true);
QmlGraphicsItem *delegate;
- delegate = view->root()->findChild<QmlGraphicsItem*>("delegateOkay");
+ delegate = view->rootObject()->findChild<QmlGraphicsItem*>("delegateOkay");
QVERIFY(delegate);
- delegate = view->root()->findChild<QmlGraphicsItem*>("delegateSlow");
+ delegate = view->rootObject()->findChild<QmlGraphicsItem*>("delegateSlow");
QVERIFY(delegate);
- view->setUrl(QUrl("http://localhost:42332/cursorHttpTestFail1.qml"));
+ view->setSource(QUrl("http://localhost:42332/cursorHttpTestFail1.qml"));
view->execute();
view->show();
view->setFocus();
- delegate = view->root()->findChild<QmlGraphicsItem*>("delegateOkay");
- QVERIFY(delegate);
- delegate = view->root()->findChild<QmlGraphicsItem*>("delegateFail");
- QVERIFY(!delegate);
- view->setUrl(QUrl("http://localhost:42332/cursorHttpTestFail2.qml"));
+ QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test
+ view->setSource(QUrl("http://localhost:42332/cursorHttpTestFail2.qml"));
view->execute();
view->show();
view->setFocus();
- delegate = view->root()->findChild<QmlGraphicsItem*>("delegateOkay");
- QVERIFY(delegate);
- delegate = view->root()->findChild<QmlGraphicsItem*>("delegateErrorA");
- QVERIFY(!delegate);
+ QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test
//ErrorB should get a component which is ready but component.create() returns null
//Not sure how to accomplish this with QmlGraphicsTextEdits cursor delegate
//###This could be a case of overzealous defensive programming
- //delegate = view->root()->findChild<QmlGraphicsItem*>("delegateErrorB");
+ //delegate = view->rootObject()->findChild<QmlGraphicsItem*>("delegateErrorB");
//QVERIFY(!delegate);
}
@@ -698,9 +692,9 @@ void tst_qmlgraphicstextedit::navigation()
canvas->show();
canvas->setFocus();
- QVERIFY(canvas->root() != 0);
+ QVERIFY(canvas->rootObject() != 0);
- QmlGraphicsItem *input = qobject_cast<QmlGraphicsItem *>(qvariant_cast<QObject *>(canvas->root()->property("myInput")));
+ QmlGraphicsItem *input = qobject_cast<QmlGraphicsItem *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
QVERIFY(input != 0);
QTRY_VERIFY(input->hasFocus() == true);
@@ -721,9 +715,9 @@ void tst_qmlgraphicstextedit::readOnly()
canvas->show();
canvas->setFocus();
- QVERIFY(canvas->root() != 0);
+ QVERIFY(canvas->rootObject() != 0);
- QmlGraphicsTextEdit *edit = qobject_cast<QmlGraphicsTextEdit *>(qvariant_cast<QObject *>(canvas->root()->property("myInput")));
+ QmlGraphicsTextEdit *edit = qobject_cast<QmlGraphicsTextEdit *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
QVERIFY(edit != 0);
QTRY_VERIFY(edit->hasFocus() == true);
@@ -750,10 +744,7 @@ QmlView *tst_qmlgraphicstextedit::createView(const QString &filename)
{
QmlView *canvas = new QmlView(0);
- QFile file(filename);
- file.open(QFile::ReadOnly);
- QString xml = file.readAll();
- canvas->setQml(xml, filename);
+ canvas->setSource(QUrl::fromLocalFile(filename));
return canvas;
}
diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml b/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml
index 7a2e914..493db5b 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml
+++ b/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml
@@ -11,6 +11,7 @@ Rectangle {
}
TextInput { id: input; focus: true
+ text: "Needs some text"
KeyNavigation.left: firstItem
KeyNavigation.right: lastItem
KeyNavigation.up: firstItem
diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml b/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml
index 673790d..0c81548 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml
+++ b/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml
@@ -1,4 +1,4 @@
-import Qt 4.6
+import Qt 4.7
Item {
property var intInput: intInput
diff --git a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp b/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp
index cf08bff..8b45fc7 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp
+++ b/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp
@@ -352,8 +352,8 @@ void tst_qmlgraphicstextinput::maxLength()
canvas->execute();
canvas->show();
canvas->setFocus();
- QVERIFY(canvas->root() != 0);
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput *>(canvas->root());
+ QVERIFY(canvas->rootObject() != 0);
+ QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput *>(canvas->rootObject());
QVERIFY(textinputObject != 0);
QVERIFY(textinputObject->text().isEmpty());
QVERIFY(textinputObject->maxLength() == 10);
@@ -381,8 +381,8 @@ void tst_qmlgraphicstextinput::masks()
canvas->execute();
canvas->show();
canvas->setFocus();
- QVERIFY(canvas->root() != 0);
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput *>(canvas->root());
+ QVERIFY(canvas->rootObject() != 0);
+ QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput *>(canvas->rootObject());
QVERIFY(textinputObject != 0);
QTRY_VERIFY(textinputObject->hasFocus() == true);
QVERIFY(textinputObject->text().length() == 0);
@@ -407,9 +407,9 @@ void tst_qmlgraphicstextinput::validators()
canvas->show();
canvas->setFocus();
- QVERIFY(canvas->root() != 0);
+ QVERIFY(canvas->rootObject() != 0);
- QmlGraphicsTextInput *intInput = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->root()->property("intInput")));
+ QmlGraphicsTextInput *intInput = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("intInput")));
QVERIFY(intInput);
intInput->setFocus(true);
QTRY_VERIFY(intInput->hasFocus());
@@ -430,7 +430,7 @@ void tst_qmlgraphicstextinput::validators()
QCOMPARE(intInput->text(), QLatin1String("11"));
QCOMPARE(intInput->hasAcceptableInput(), true);
- QmlGraphicsTextInput *dblInput = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->root()->property("dblInput")));
+ QmlGraphicsTextInput *dblInput = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("dblInput")));
QTRY_VERIFY(dblInput);
dblInput->setFocus(true);
QVERIFY(dblInput->hasFocus() == true);
@@ -459,7 +459,7 @@ void tst_qmlgraphicstextinput::validators()
QCOMPARE(dblInput->text(), QLatin1String("12.11"));
QCOMPARE(dblInput->hasAcceptableInput(), true);
- QmlGraphicsTextInput *strInput = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->root()->property("strInput")));
+ QmlGraphicsTextInput *strInput = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("strInput")));
QTRY_VERIFY(strInput);
strInput->setFocus(true);
QVERIFY(strInput->hasFocus() == true);
@@ -497,8 +497,8 @@ void tst_qmlgraphicstextinput::inputMethodHints()
canvas->show();
canvas->setFocus();
- QVERIFY(canvas->root() != 0);
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput *>(canvas->root());
+ QVERIFY(canvas->rootObject() != 0);
+ QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput *>(canvas->rootObject());
QVERIFY(textinputObject != 0);
QVERIFY(textinputObject->inputMethodHints() & Qt::ImhNoPredictiveText);
textinputObject->setInputMethodHints(Qt::ImhUppercaseOnly);
@@ -508,6 +508,7 @@ void tst_qmlgraphicstextinput::inputMethodHints()
/*
TextInput element should only handle left/right keys until the cursor reaches
the extent of the text, then they should ignore the keys.
+
*/
void tst_qmlgraphicstextinput::navigation()
{
@@ -516,16 +517,26 @@ void tst_qmlgraphicstextinput::navigation()
canvas->show();
canvas->setFocus();
- QVERIFY(canvas->root() != 0);
+ QVERIFY(canvas->rootObject() != 0);
- QmlGraphicsItem *input = qobject_cast<QmlGraphicsItem *>(qvariant_cast<QObject *>(canvas->root()->property("myInput")));
+ QmlGraphicsTextInput *input = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
QVERIFY(input != 0);
+ input->setCursorPosition(0);
QTRY_VERIFY(input->hasFocus() == true);
simulateKey(canvas, Qt::Key_Left);
QVERIFY(input->hasFocus() == false);
simulateKey(canvas, Qt::Key_Right);
QVERIFY(input->hasFocus() == true);
+ //QT-2944: If text is selected, then we should deselect first.
+ input->setCursorPosition(input->text().length());
+ input->setSelectionStart(0);
+ input->setSelectionEnd(input->text().length());
+ QVERIFY(input->selectionStart() != input->selectionEnd());
+ simulateKey(canvas, Qt::Key_Right);
+ QVERIFY(input->selectionStart() == input->selectionEnd());
+ QVERIFY(input->selectionStart() == input->text().length());
+ QVERIFY(input->hasFocus() == true);
simulateKey(canvas, Qt::Key_Right);
QVERIFY(input->hasFocus() == false);
simulateKey(canvas, Qt::Key_Left);
@@ -538,7 +549,7 @@ void tst_qmlgraphicstextinput::cursorDelegate()
view->execute();
view->show();
view->setFocus();
- QmlGraphicsTextInput *textInputObject = view->root()->findChild<QmlGraphicsTextInput*>("textInputObject");
+ QmlGraphicsTextInput *textInputObject = view->rootObject()->findChild<QmlGraphicsTextInput*>("textInputObject");
QVERIFY(textInputObject != 0);
QVERIFY(textInputObject->findChild<QmlGraphicsItem*>("cursorInstance"));
//Test Delegate gets created
@@ -567,9 +578,9 @@ void tst_qmlgraphicstextinput::readOnly()
canvas->show();
canvas->setFocus();
- QVERIFY(canvas->root() != 0);
+ QVERIFY(canvas->rootObject() != 0);
- QmlGraphicsTextInput *input = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->root()->property("myInput")));
+ QmlGraphicsTextInput *input = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
QVERIFY(input != 0);
QTRY_VERIFY(input->hasFocus() == true);
@@ -596,10 +607,7 @@ QmlView *tst_qmlgraphicstextinput::createView(const QString &filename)
{
QmlView *canvas = new QmlView(0);
- QFile file(filename);
- file.open(QFile::ReadOnly);
- QString xml = file.readAll();
- canvas->setQml(xml, filename);
+ canvas->setSource(QUrl::fromLocalFile(filename));
return canvas;
}
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml b/tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml
index b8524af..0bc8263 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml
+++ b/tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml
@@ -17,6 +17,7 @@ Grid {
WebView {
id: webView
+ width: 150 // force predictable for test
newWindowComponent: webViewPage
newWindowParent: pages
url: "newwindows.html"
diff --git a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp b/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp
index e7b996d..f3c39f8 100644
--- a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp
+++ b/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp
@@ -304,6 +304,9 @@ void tst_qmlgraphicswebview::multipleWindows()
QmlGraphicsGrid *grid = qobject_cast<QmlGraphicsGrid*>(component.create());
QVERIFY(grid != 0);
QTRY_COMPARE(grid->children().count(), 2+5); // Component, Loader, 5 WebViews
+ QmlGraphicsItem* popup = qobject_cast<QmlGraphicsItem*>(grid->children().at(3)); // first popup after Component, Loaded, original.
+ QVERIFY(popup != 0);
+ QTRY_COMPARE(popup->x(), 150.0);
}
void tst_qmlgraphicswebview::loadError()
diff --git a/tests/auto/declarative/qmlimageprovider/data/exists.png b/tests/auto/declarative/qmlimageprovider/data/exists.png
new file mode 100644
index 0000000..399bd0b
--- /dev/null
+++ b/tests/auto/declarative/qmlimageprovider/data/exists.png
Binary files differ
diff --git a/tests/auto/declarative/qmlimageprovider/data/exists1.png b/tests/auto/declarative/qmlimageprovider/data/exists1.png
new file mode 100644
index 0000000..399bd0b
--- /dev/null
+++ b/tests/auto/declarative/qmlimageprovider/data/exists1.png
Binary files differ
diff --git a/tests/auto/declarative/qmlimageprovider/data/exists2.png b/tests/auto/declarative/qmlimageprovider/data/exists2.png
new file mode 100644
index 0000000..399bd0b
--- /dev/null
+++ b/tests/auto/declarative/qmlimageprovider/data/exists2.png
Binary files differ
diff --git a/tests/auto/declarative/qmlimageprovider/qmlimageprovider.pro b/tests/auto/declarative/qmlimageprovider/qmlimageprovider.pro
new file mode 100644
index 0000000..0ef7739
--- /dev/null
+++ b/tests/auto/declarative/qmlimageprovider/qmlimageprovider.pro
@@ -0,0 +1,12 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+QT += network
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qmlimageprovider.cpp
+
+# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
+# LIBS += -lgcov
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp b/tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp
new file mode 100644
index 0000000..d07558a
--- /dev/null
+++ b/tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 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/QtTest>
+#include <QtDeclarative/qmlengine.h>
+#include <QtDeclarative/qmlimageprovider.h>
+#include <private/qmlgraphicsimage_p.h>
+
+// QmlImageProvider::request() is run in an idle thread where possible
+// Be generous in our timeout.
+#define TRY_WAIT(expr) \
+ do { \
+ for (int ii = 0; ii < 10; ++ii) { \
+ if ((expr)) break; \
+ QTest::qWait(100); \
+ } \
+ QVERIFY((expr)); \
+ } while (false)
+
+
+class tst_qmlimageprovider : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qmlimageprovider()
+ {
+ }
+
+private slots:
+ void imageSource();
+ void imageSource_data();
+ void removeProvider();
+
+private:
+ QmlEngine engine;
+};
+
+class TestProvider : public QmlImageProvider
+{
+public:
+ QImage request(const QString &id) {
+ QImage image;
+ image.load(SRCDIR "/data/" + id);
+ return image;
+ }
+};
+
+void tst_qmlimageprovider::imageSource_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("exists") << "image://test/exists.png" << "";
+ QTest::newRow("missing") << "image://test/no-such-file.png"
+ << "\"Failed to get image from provider: image://test/no-such-file.png\" ";
+ QTest::newRow("unknown provider") << "image://bogus/exists.png"
+ << "\"Failed to get image from provider: image://bogus/exists.png\" ";
+}
+
+void tst_qmlimageprovider::imageSource()
+{
+ QFETCH(QString, source);
+ QFETCH(QString, error);
+
+ if (!error.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
+
+ engine.addImageProvider("test", new TestProvider);
+ QVERIFY(engine.imageProvider("test") != 0);
+
+ QString componentStr = "import Qt 4.6\nImage { source: \"" + source + "\" }";
+ QmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ TRY_WAIT(obj->status() == QmlGraphicsImage::Loading);
+
+ QCOMPARE(obj->source(), QUrl(source));
+
+ if (error.isEmpty()) {
+ TRY_WAIT(obj->status() == QmlGraphicsImage::Ready);
+ QCOMPARE(obj->width(), 100.);
+ QCOMPARE(obj->height(), 100.);
+ QCOMPARE(obj->fillMode(), QmlGraphicsImage::Stretch);
+ QCOMPARE(obj->progress(), 1.0);
+ } else {
+ TRY_WAIT(obj->status() == QmlGraphicsImage::Error);
+ }
+
+ delete obj;
+}
+
+void tst_qmlimageprovider::removeProvider()
+{
+ engine.addImageProvider("test2", new TestProvider);
+ QVERIFY(engine.imageProvider("test2") != 0);
+
+ // add provider, confirm it works
+ QString componentStr = "import Qt 4.6\nImage { source: \"image://test2/exists1.png\" }";
+ QmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ TRY_WAIT(obj->status() == QmlGraphicsImage::Loading);
+ TRY_WAIT(obj->status() == QmlGraphicsImage::Ready);
+
+ QCOMPARE(obj->width(), 100.0);
+
+ // remove the provider and confirm
+ QString error("\"Failed to get image from provider: image://test2/exists2.png\" ");
+ QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
+
+ engine.removeImageProvider("test2");
+
+ obj->setSource(QUrl("image://test2/exists2.png"));
+
+ TRY_WAIT(obj->status() == QmlGraphicsImage::Loading);
+ TRY_WAIT(obj->status() == QmlGraphicsImage::Error);
+
+ delete obj;
+}
+
+
+QTEST_MAIN(tst_qmlimageprovider)
+
+#include "tst_qmlimageprovider.moc"
diff --git a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp
index fa45a01..e70c7f1 100644
--- a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp
+++ b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp
@@ -51,6 +51,8 @@ public:
tst_QmlListModel() {}
private slots:
+ void static_types();
+ void static_types_data();
void static_i18n();
void static_nestedElements();
void static_nestedElements_data();
@@ -223,6 +225,59 @@ void tst_QmlListModel::dynamic()
QCOMPARE(actual,result);
}
+void tst_QmlListModel::static_types_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QVariant>("value");
+
+ QTest::newRow("string")
+ << "ListElement { foo: \"bar\" }"
+ << QVariant(QString("bar"));
+
+ QTest::newRow("real")
+ << "ListElement { foo: 10.5 }"
+ << QVariant(10.5);
+
+ QTest::newRow("real0")
+ << "ListElement { foo: 0 }"
+ << QVariant(double(0));
+
+ QTest::newRow("bool")
+ << "ListElement { foo: false }"
+ << QVariant(false);
+
+ QTest::newRow("bool")
+ << "ListElement { foo: true }"
+ << QVariant(true);
+}
+
+void tst_QmlListModel::static_types()
+{
+ QFETCH(QString, qml);
+ QFETCH(QVariant, value);
+
+ qml = "import Qt 4.6\nListModel { " + qml + " }";
+
+ QmlEngine engine;
+ QmlComponent component(&engine);
+ component.setData(qml.toUtf8(),
+ QUrl::fromLocalFile(QString("dummy.qml")));
+ QVERIFY(!component.isError());
+
+ QmlListModel *obj = qobject_cast<QmlListModel*>(component.create());
+ QVERIFY(obj != 0);
+
+ QScriptValue actual = obj->get(0).property(QLatin1String("foo"));
+
+ QCOMPARE(actual.isString(), value.type() == QVariant::String);
+ QCOMPARE(actual.isBoolean(), value.type() == QVariant::Bool);
+ QCOMPARE(actual.isNumber(), value.type() == QVariant::Double);
+
+ QCOMPARE(actual.toString(), value.toString());
+
+ delete obj;
+}
+
void tst_QmlListModel::error_data()
{
QTest::addColumn<QString>("qml");
@@ -246,7 +301,7 @@ void tst_QmlListModel::error_data()
QTest::newRow("bindings not allowed in ListElement")
<< "import Qt 4.6\nRectangle { id: rect; ListModel { ListElement { foo: rect.color } } }"
- << "QTBUG-6203 ListElement should not allow binding its data to something";
+ << "ListElement: cannot use script for property value";
QTest::newRow("random object list properties allowed in ListElement")
<< "import Qt 4.6\nListModel { ListElement { foo: [ ListElement { bar: 123 } ] } }"
diff --git a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
index d668bf6..91ff727 100644
--- a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
+++ b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
@@ -122,6 +122,9 @@ private slots:
//writeToReadOnly();
+ // Bugs
+ void crashOnValueProperty();
+
private:
QmlEngine engine;
};
@@ -208,6 +211,9 @@ private:
QUrl m_url;
};
+QML_DECLARE_TYPE(PropertyObject);
+QML_DEFINE_TYPE(Test,1,0,PropertyObject,PropertyObject);
+
void tst_qmlmetaproperty::qmlmetaproperty_object()
{
QObject object; // Has no default property
@@ -1118,6 +1124,30 @@ void tst_qmlmetaproperty::writeObjectToQmlList()
QCOMPARE(container->qmlChildren()->at(1), object);
}
+void tst_qmlmetaproperty::crashOnValueProperty()
+{
+ QmlEngine *engine = new QmlEngine;
+ QmlComponent component(engine);
+
+ component.setData("import Test 1.0\nPropertyObject { wrectProperty.x: 10 }", QUrl());
+ PropertyObject *obj = qobject_cast<PropertyObject*>(component.create());
+ QVERIFY(obj != 0);
+
+ QmlMetaProperty p = QmlMetaProperty::createProperty(obj, "wrectProperty.x", qmlContext(obj));
+ QCOMPARE(p.name(), QString("wrectProperty.x"));
+
+ QCOMPARE(p.read(), QVariant(10));
+
+ //don't crash once the engine is deleted
+ delete engine;
+ engine = 0;
+
+ QCOMPARE(p.propertyTypeName(), "int");
+ QCOMPARE(p.read(), QVariant(10));
+ p.write(QVariant(20));
+ QCOMPARE(p.read(), QVariant(20));
+}
+
QTEST_MAIN(tst_qmlmetaproperty)
#include "tst_qmlmetaproperty.moc"
diff --git a/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp b/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp
index 4ca132e..6d1887f 100644
--- a/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp
+++ b/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp
@@ -157,9 +157,12 @@ void tst_qmlmetatype::copy()
QT_COPY_TEST(QStringList, QStringList() << "QML" << "Rocks");
QT_COPY_TEST(QByteArray, QByteArray("0x1102DDD"));
QT_COPY_TEST(QBitArray, QBitArray(102, true));
- QT_COPY_TEST(QDate, QDate::currentDate());
- QT_COPY_TEST(QTime, QTime::currentTime());
- QT_COPY_TEST(QDateTime, QDateTime::currentDateTime());
+ QDate cd = QDate::currentDate();
+ QT_COPY_TEST(QDate, cd);
+ QTime ct = QTime::currentTime();
+ QT_COPY_TEST(QTime, ct);
+ QDateTime cdt = QDateTime::currentDateTime();
+ QT_COPY_TEST(QDateTime, cdt);
QT_COPY_TEST(QUrl, QUrl("http://www.nokia.com"));
QT_COPY_TEST(QLocale, QLocale(QLocale::English, QLocale::Australia));
QT_COPY_TEST(QRect, QRect(-10, 10, 102, 99));
diff --git a/tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp b/tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp
index 3161cbc..30f2fea 100644
--- a/tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp
+++ b/tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp
@@ -45,12 +45,12 @@
#include <private/qnumberformat_p.h>
#include <private/qmlnumberformatter_p.h>
-class tst_numberformat : public QObject
+class tst_qmlnumberformatter : public QObject
{
Q_OBJECT
public:
- tst_numberformat();
-
+ tst_qmlnumberformatter();
+
void init() {}
void initTestCase() {}
@@ -67,7 +67,7 @@ private:
QStringList texts;
};
-tst_numberformat::tst_numberformat()
+tst_qmlnumberformatter::tst_qmlnumberformatter()
{
strings << "100.0"
<< "12345"
@@ -177,7 +177,7 @@ tst_numberformat::tst_numberformat()
<< "texts.size()" << texts.size();
}
-void tst_numberformat::text_data()
+void tst_qmlnumberformatter::text_data()
{
QTest::addColumn<QString>("string");
QTest::addColumn<QString>("format");
@@ -194,7 +194,7 @@ void tst_numberformat::text_data()
}
-void tst_numberformat::text()
+void tst_qmlnumberformatter::text()
{
QFETCH(QString, string);
QFETCH(QString, format);
@@ -217,6 +217,6 @@ void tst_numberformat::text()
delete formatter;
}
-QTEST_MAIN(tst_numberformat)
+QTEST_MAIN(tst_qmlnumberformatter)
#include "tst_qmlnumberformatter.moc"
diff --git a/tests/auto/declarative/qmlstates/tst_qmlstates.cpp b/tests/auto/declarative/qmlstates/tst_qmlstates.cpp
index 4402d03..81145a8 100644
--- a/tests/auto/declarative/qmlstates/tst_qmlstates.cpp
+++ b/tests/auto/declarative/qmlstates/tst_qmlstates.cpp
@@ -46,11 +46,11 @@
#include <private/qmlpropertychanges_p.h>
#include <private/qmlstategroup_p.h>
-class tst_states : public QObject
+class tst_qmlstates : public QObject
{
Q_OBJECT
public:
- tst_states() {}
+ tst_qmlstates() {}
private:
static QByteArray fullDataPath(const QString &path);
@@ -81,12 +81,12 @@ private slots:
void nonExistantProperty();
};
-QByteArray tst_states::fullDataPath(const QString &path)
+QByteArray tst_qmlstates::fullDataPath(const QString &path)
{
return QUrl::fromLocalFile(SRCDIR + path).toString().toUtf8();
}
-void tst_states::basicChanges()
+void tst_qmlstates::basicChanges()
{
QmlEngine engine;
@@ -156,7 +156,7 @@ void tst_states::basicChanges()
}
}
-void tst_states::basicExtension()
+void tst_qmlstates::basicExtension()
{
QmlEngine engine;
@@ -220,7 +220,7 @@ void tst_states::basicExtension()
}
}
-void tst_states::basicBinding()
+void tst_qmlstates::basicBinding()
{
QmlEngine engine;
@@ -346,7 +346,7 @@ Q_SIGNALS:
QML_DECLARE_TYPE(MyRect)
QML_DEFINE_TYPE(Qt.test, 1, 0, MyRectangle,MyRect);
-void tst_states::signalOverride()
+void tst_qmlstates::signalOverride()
{
QmlEngine engine;
@@ -383,7 +383,7 @@ void tst_states::signalOverride()
}
}
-void tst_states::signalOverrideCrash()
+void tst_qmlstates::signalOverrideCrash()
{
QmlEngine engine;
@@ -395,7 +395,7 @@ void tst_states::signalOverrideCrash()
rect->doSomething();
}
-void tst_states::parentChange()
+void tst_qmlstates::parentChange()
{
QmlEngine engine;
@@ -462,7 +462,7 @@ void tst_states::parentChange()
}
}
-void tst_states::parentChangeErrors()
+void tst_qmlstates::parentChangeErrors()
{
QmlEngine engine;
@@ -499,7 +499,7 @@ void tst_states::parentChangeErrors()
}
}
-void tst_states::anchorChanges()
+void tst_qmlstates::anchorChanges()
{
QmlEngine engine;
@@ -527,7 +527,7 @@ void tst_states::anchorChanges()
delete rect;
}
-void tst_states::anchorChanges2()
+void tst_qmlstates::anchorChanges2()
{
QmlEngine engine;
@@ -548,7 +548,7 @@ void tst_states::anchorChanges2()
delete rect;
}
-void tst_states::anchorChanges3()
+void tst_qmlstates::anchorChanges3()
{
QmlEngine engine;
@@ -594,7 +594,7 @@ void tst_states::anchorChanges3()
delete rect;
}
-void tst_states::anchorChanges4()
+void tst_qmlstates::anchorChanges4()
{
QmlEngine engine;
@@ -625,7 +625,7 @@ void tst_states::anchorChanges4()
delete rect;
}
-void tst_states::anchorChanges5()
+void tst_qmlstates::anchorChanges5()
{
QmlEngine engine;
@@ -656,7 +656,7 @@ void tst_states::anchorChanges5()
delete rect;
}
-void tst_states::script()
+void tst_qmlstates::script()
{
QmlEngine engine;
@@ -675,7 +675,7 @@ void tst_states::script()
}
}
-void tst_states::restoreEntryValues()
+void tst_qmlstates::restoreEntryValues()
{
QmlEngine engine;
@@ -692,7 +692,7 @@ void tst_states::restoreEntryValues()
QCOMPARE(rect->color(),QColor("blue"));
}
-void tst_states::explicitChanges()
+void tst_qmlstates::explicitChanges()
{
QmlEngine engine;
@@ -722,7 +722,7 @@ void tst_states::explicitChanges()
QCOMPARE(rect->color(),QColor("yellow"));
}
-void tst_states::propertyErrors()
+void tst_qmlstates::propertyErrors()
{
QmlEngine engine;
QmlComponent rectComponent(&engine, SRCDIR "/data/propertyErrors.qml");
@@ -736,7 +736,7 @@ void tst_states::propertyErrors()
rect->setState("blue");
}
-void tst_states::incorrectRestoreBug()
+void tst_qmlstates::incorrectRestoreBug()
{
QmlEngine engine;
@@ -762,7 +762,7 @@ void tst_states::incorrectRestoreBug()
QCOMPARE(rect->color(),QColor("green"));
}
-void tst_states::autoStateAtStartupRestoreBug()
+void tst_qmlstates::autoStateAtStartupRestoreBug()
{
QmlEngine engine;
@@ -779,7 +779,7 @@ void tst_states::autoStateAtStartupRestoreBug()
delete obj;
}
-void tst_states::deletingChange()
+void tst_qmlstates::deletingChange()
{
QmlEngine engine;
@@ -811,7 +811,7 @@ void tst_states::deletingChange()
delete rect;
}
-void tst_states::deletingState()
+void tst_qmlstates::deletingState()
{
QmlEngine engine;
@@ -842,7 +842,7 @@ void tst_states::deletingState()
delete rect;
}
-void tst_states::tempState()
+void tst_qmlstates::tempState()
{
QmlEngine engine;
@@ -856,7 +856,7 @@ void tst_states::tempState()
QCOMPARE(rect->state(), QLatin1String("idle"));
}
-void tst_states::illegalTempState()
+void tst_qmlstates::illegalTempState()
{
QmlEngine engine;
@@ -869,7 +869,7 @@ void tst_states::illegalTempState()
QCOMPARE(rect->state(), QLatin1String("placed"));
}
-void tst_states::nonExistantProperty()
+void tst_qmlstates::nonExistantProperty()
{
QmlEngine engine;
@@ -882,6 +882,6 @@ void tst_states::nonExistantProperty()
QCOMPARE(rect->state(), QLatin1String("blue"));
}
-QTEST_MAIN(tst_states)
+QTEST_MAIN(tst_qmlstates)
#include "tst_qmlstates.moc"
diff --git a/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp b/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp
index 47b35f7..f99d3ce 100644
--- a/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp
+++ b/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp
@@ -46,11 +46,11 @@
#include <private/qmlvaluetype_p.h>
#include "testtypes.h"
-class tst_valuetypes : public QObject
+class tst_qmlvaluetypes : public QObject
{
Q_OBJECT
public:
- tst_valuetypes() {}
+ tst_qmlvaluetypes() {}
private slots:
void point();
@@ -84,7 +84,7 @@ inline QUrl TEST_FILE(const QString &filename)
return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
}
-void tst_valuetypes::point()
+void tst_qmlvaluetypes::point()
{
{
QmlComponent component(&engine, TEST_FILE("point_read.qml"));
@@ -109,7 +109,7 @@ void tst_valuetypes::point()
}
}
-void tst_valuetypes::pointf()
+void tst_qmlvaluetypes::pointf()
{
{
QmlComponent component(&engine, TEST_FILE("pointf_read.qml"));
@@ -134,7 +134,7 @@ void tst_valuetypes::pointf()
}
}
-void tst_valuetypes::size()
+void tst_qmlvaluetypes::size()
{
{
QmlComponent component(&engine, TEST_FILE("size_read.qml"));
@@ -159,7 +159,7 @@ void tst_valuetypes::size()
}
}
-void tst_valuetypes::sizef()
+void tst_qmlvaluetypes::sizef()
{
{
QmlComponent component(&engine, TEST_FILE("sizef_read.qml"));
@@ -184,7 +184,7 @@ void tst_valuetypes::sizef()
}
}
-void tst_valuetypes::rect()
+void tst_qmlvaluetypes::rect()
{
{
QmlComponent component(&engine, TEST_FILE("rect_read.qml"));
@@ -211,7 +211,7 @@ void tst_valuetypes::rect()
}
}
-void tst_valuetypes::rectf()
+void tst_qmlvaluetypes::rectf()
{
{
QmlComponent component(&engine, TEST_FILE("rectf_read.qml"));
@@ -238,7 +238,7 @@ void tst_valuetypes::rectf()
}
}
-void tst_valuetypes::vector3d()
+void tst_qmlvaluetypes::vector3d()
{
{
QmlComponent component(&engine, TEST_FILE("vector3d_read.qml"));
@@ -264,7 +264,7 @@ void tst_valuetypes::vector3d()
}
}
-void tst_valuetypes::font()
+void tst_qmlvaluetypes::font()
{
{
QmlComponent component(&engine, TEST_FILE("font_read.qml"));
@@ -337,7 +337,7 @@ void tst_valuetypes::font()
}
// Test bindings can write to value types
-void tst_valuetypes::bindingAssignment()
+void tst_qmlvaluetypes::bindingAssignment()
{
QmlComponent component(&engine, TEST_FILE("bindingAssignment.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
@@ -353,7 +353,7 @@ void tst_valuetypes::bindingAssignment()
}
// Test bindings can read from value types
-void tst_valuetypes::bindingRead()
+void tst_qmlvaluetypes::bindingRead()
{
QmlComponent component(&engine, TEST_FILE("bindingRead.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
@@ -369,7 +369,7 @@ void tst_valuetypes::bindingRead()
}
// Test static values can assign to value types
-void tst_valuetypes::staticAssignment()
+void tst_qmlvaluetypes::staticAssignment()
{
QmlComponent component(&engine, TEST_FILE("staticAssignment.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
@@ -381,7 +381,7 @@ void tst_valuetypes::staticAssignment()
}
// Test scripts can read/write value types
-void tst_valuetypes::scriptAccess()
+void tst_qmlvaluetypes::scriptAccess()
{
QmlComponent component(&engine, TEST_FILE("scriptAccess.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
@@ -395,7 +395,7 @@ void tst_valuetypes::scriptAccess()
}
// Test that assigning a constant from script removes any binding
-void tst_valuetypes::autoBindingRemoval()
+void tst_qmlvaluetypes::autoBindingRemoval()
{
{
QmlComponent component(&engine, TEST_FILE("autoBindingRemoval.qml"));
@@ -466,7 +466,7 @@ void tst_valuetypes::autoBindingRemoval()
}
// Test that property value sources assign to value types
-void tst_valuetypes::valueSources()
+void tst_qmlvaluetypes::valueSources()
{
QmlComponent component(&engine, TEST_FILE("valueSources.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
@@ -489,7 +489,7 @@ static void checkNoErrors(QmlComponent& component)
}
// Test that property value interceptors can be applied to value types
-void tst_valuetypes::valueInterceptors()
+void tst_qmlvaluetypes::valueInterceptors()
{
QmlComponent component(&engine, TEST_FILE("valueInterceptors.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
@@ -507,7 +507,7 @@ void tst_valuetypes::valueInterceptors()
}
// Test that you can't assign a binding to the "root" value type, and a sub-property
-void tst_valuetypes::bindingConflict()
+void tst_qmlvaluetypes::bindingConflict()
{
QmlComponent component(&engine, TEST_FILE("bindingConflict.qml"));
QCOMPARE(component.isError(), true);
@@ -524,7 +524,7 @@ void tst_valuetypes::bindingConflict()
// Test that accessing a reference to a valuetype after the owning object is deleted
// doesn't crash
-void tst_valuetypes::deletedObject()
+void tst_qmlvaluetypes::deletedObject()
{
QmlComponent component(&engine, TEST_FILE("deletedObject.qml"));
QTest::ignoreMessage(QtDebugMsg, "Test: 2");
@@ -542,7 +542,7 @@ void tst_valuetypes::deletedObject()
}
// Test that value types can be assigned to another value type property in a binding
-void tst_valuetypes::bindingVariantCopy()
+void tst_qmlvaluetypes::bindingVariantCopy()
{
QmlComponent component(&engine, TEST_FILE("bindingVariantCopy.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
@@ -554,7 +554,7 @@ void tst_valuetypes::bindingVariantCopy()
}
// Test that value types can be assigned to another value type property in script
-void tst_valuetypes::scriptVariantCopy()
+void tst_qmlvaluetypes::scriptVariantCopy()
{
QmlComponent component(&engine, TEST_FILE("scriptVariantCopy.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
@@ -571,7 +571,7 @@ void tst_valuetypes::scriptVariantCopy()
// Test that the value type classes can be used manually
-void tst_valuetypes::cppClasses()
+void tst_qmlvaluetypes::cppClasses()
{
CPP_TEST(QmlPointValueType, QPoint(19, 33));
CPP_TEST(QmlPointFValueType, QPointF(33.6, -23));
@@ -583,6 +583,6 @@ void tst_valuetypes::cppClasses()
CPP_TEST(QmlFontValueType, QFont("Helvetica"));
}
-QTEST_MAIN(tst_valuetypes)
+QTEST_MAIN(tst_qmlvaluetypes)
#include "tst_qmlvaluetypes.moc"
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply b/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply
index 35b11f4..7ae6951 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply
+++ b/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply
@@ -1,2 +1,3 @@
HTTP/1.0 200 OK
+Connection: close
Content-type: text/html; charset=UTF-8
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml b/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml
index 02a8083..8d67fad 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml
+++ b/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml
@@ -42,7 +42,7 @@ QtObject {
openedException = true;
}
- var headers = "content-type: text/html; charset=UTF-8\r\ntest-header: TestValue\r\nmultitest-header: TestValue, SecondTestValue\r\ncontent-length: 11";
+ var headers = "connection: close\r\ncontent-type: text/html; charset=UTF-8\r\ntest-header: TestValue\r\nmultitest-header: TestValue, SecondTestValue\r\ncontent-length: 11";
// Test to the end
x.onreadystatechange = function() {
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply
index 62ec67b..c4b4bb2 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply
+++ b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply
@@ -1,4 +1,5 @@
HTTP/1.0 200 OK
+Connection: close
Content-type: text/html; charset=UTF-8
Test-Header: TestValue
MultiTest-Header: TestValue
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply b/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply
index 35b11f4..7ae6951 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply
+++ b/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply
@@ -1,2 +1,3 @@
HTTP/1.0 200 OK
+Connection: close
Content-type: text/html; charset=UTF-8
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply
index 35b11f4..7ae6951 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply
+++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply
@@ -1,2 +1,3 @@
HTTP/1.0 200 OK
+Connection: close
Content-type: text/html; charset=UTF-8
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply
index 35b11f4..7ae6951 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply
+++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply
@@ -1,2 +1,3 @@
HTTP/1.0 200 OK
+Connection: close
Content-type: text/html; charset=UTF-8
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply
index 35b11f4..7ae6951 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply
+++ b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply
@@ -1,2 +1,3 @@
HTTP/1.0 200 OK
+Connection: close
Content-type: text/html; charset=UTF-8
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply b/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply
index 35b11f4..7ae6951 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply
+++ b/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply
@@ -1,2 +1,3 @@
HTTP/1.0 200 OK
+Connection: close
Content-type: text/html; charset=UTF-8
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply b/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply
index 964a7a8..2e29f56 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply
+++ b/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply
@@ -1,2 +1,3 @@
HTTP/1.0 404 Document not found
+Connection: close
Content-type: text/html; charset=UTF-8
diff --git a/tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp b/tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp
index 54738f6..e675566 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp
+++ b/tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp
@@ -48,11 +48,11 @@
#define SERVER_PORT 14445
-class tst_xmlhttprequest : public QObject
+class tst_qmlxmlhttprequest : public QObject
{
Q_OBJECT
public:
- tst_xmlhttprequest() {}
+ tst_qmlxmlhttprequest() {}
private slots:
void initTestCase() {
@@ -123,7 +123,7 @@ inline QUrl TEST_FILE(const QString &filename)
}
// Test that the dom exception codes are correct
-void tst_xmlhttprequest::domExceptionCodes()
+void tst_qmlxmlhttprequest::domExceptionCodes()
{
QmlComponent component(&engine, TEST_FILE("domExceptionCodes.qml"));
QObject *object = component.create();
@@ -160,7 +160,7 @@ void tst_xmlhttprequest::domExceptionCodes()
} while (false)
-void tst_xmlhttprequest::callbackException_data()
+void tst_qmlxmlhttprequest::callbackException_data()
{
QTest::addColumn<QString>("which");
QTest::addColumn<int>("line");
@@ -170,7 +170,7 @@ void tst_xmlhttprequest::callbackException_data()
QTest::newRow("on-done") << "4" << 15;
}
-void tst_xmlhttprequest::callbackException()
+void tst_qmlxmlhttprequest::callbackException()
{
// Test exception reporting for exceptions thrown at various points.
@@ -194,7 +194,7 @@ void tst_xmlhttprequest::callbackException()
// Test that the state value properties on the XMLHttpRequest constructor have the correct values.
// ### WebKit does not do this, but it seems to fit the standard and QML better
-void tst_xmlhttprequest::staticStateValues()
+void tst_qmlxmlhttprequest::staticStateValues()
{
QmlComponent component(&engine, TEST_FILE("staticStateValues.qml"));
QObject *object = component.create();
@@ -210,7 +210,7 @@ void tst_xmlhttprequest::staticStateValues()
}
// Test that the state value properties on instances have the correct values.
-void tst_xmlhttprequest::instanceStateValues()
+void tst_qmlxmlhttprequest::instanceStateValues()
{
QmlComponent component(&engine, TEST_FILE("instanceStateValues.qml"));
QObject *object = component.create();
@@ -226,7 +226,7 @@ void tst_xmlhttprequest::instanceStateValues()
}
// Test calling constructor
-void tst_xmlhttprequest::constructor()
+void tst_qmlxmlhttprequest::constructor()
{
QmlComponent component(&engine, TEST_FILE("constructor.qml"));
QObject *object = component.create();
@@ -239,7 +239,7 @@ void tst_xmlhttprequest::constructor()
}
// Test that all the properties are set correctly before any request is sent
-void tst_xmlhttprequest::defaultState()
+void tst_qmlxmlhttprequest::defaultState()
{
QmlComponent component(&engine, TEST_FILE("defaultState.qml"));
QObject *object = component.create();
@@ -255,7 +255,7 @@ void tst_xmlhttprequest::defaultState()
}
// Test valid XMLHttpRequest.open() calls
-void tst_xmlhttprequest::open()
+void tst_qmlxmlhttprequest::open()
{
// Relative url
{
@@ -353,7 +353,7 @@ void tst_xmlhttprequest::open()
}
// Test that calling XMLHttpRequest.open() with an invalid method raises an exception
-void tst_xmlhttprequest::open_invalid_method()
+void tst_qmlxmlhttprequest::open_invalid_method()
{
QmlComponent component(&engine, TEST_FILE("open_invalid_method.qml"));
QObject *object = component.create();
@@ -365,7 +365,7 @@ void tst_xmlhttprequest::open_invalid_method()
}
// Test that calling XMLHttpRequest.open() with sync raises an exception
-void tst_xmlhttprequest::open_sync()
+void tst_qmlxmlhttprequest::open_sync()
{
QmlComponent component(&engine, TEST_FILE("open_sync.qml"));
QObject *object = component.create();
@@ -377,7 +377,7 @@ void tst_xmlhttprequest::open_sync()
}
// Calling with incorrect arg count raises an exception
-void tst_xmlhttprequest::open_arg_count()
+void tst_qmlxmlhttprequest::open_arg_count()
{
{
QmlComponent component(&engine, TEST_FILE("open_arg_count.1.qml"));
@@ -401,7 +401,7 @@ void tst_xmlhttprequest::open_arg_count()
}
// Test valid setRequestHeader() calls
-void tst_xmlhttprequest::setRequestHeader()
+void tst_qmlxmlhttprequest::setRequestHeader()
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
@@ -421,7 +421,7 @@ void tst_xmlhttprequest::setRequestHeader()
}
// Test setting headers before open() throws exception
-void tst_xmlhttprequest::setRequestHeader_unsent()
+void tst_qmlxmlhttprequest::setRequestHeader_unsent()
{
QmlComponent component(&engine, TEST_FILE("setRequestHeader_unsent.qml"));
QObject *object = component.create();
@@ -432,7 +432,7 @@ void tst_xmlhttprequest::setRequestHeader_unsent()
delete object;
}
-void tst_xmlhttprequest::setRequestHeader_illegalName_data()
+void tst_qmlxmlhttprequest::setRequestHeader_illegalName_data()
{
QTest::addColumn<QString>("name");
@@ -461,7 +461,7 @@ void tst_xmlhttprequest::setRequestHeader_illegalName_data()
}
// Tests that using illegal header names has no effect
-void tst_xmlhttprequest::setRequestHeader_illegalName()
+void tst_qmlxmlhttprequest::setRequestHeader_illegalName()
{
QFETCH(QString, name);
@@ -491,7 +491,7 @@ void tst_xmlhttprequest::setRequestHeader_illegalName()
}
// Test that attempting to set a header after a request is sent throws an exception
-void tst_xmlhttprequest::setRequestHeader_sent()
+void tst_qmlxmlhttprequest::setRequestHeader_sent()
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
@@ -513,7 +513,7 @@ void tst_xmlhttprequest::setRequestHeader_sent()
}
// Invalid arg count throws exception
-void tst_xmlhttprequest::setRequestHeader_args()
+void tst_qmlxmlhttprequest::setRequestHeader_args()
{
QmlComponent component(&engine, TEST_FILE("setRequestHeader_args.qml"));
QObject *object = component.create();
@@ -525,7 +525,7 @@ void tst_xmlhttprequest::setRequestHeader_args()
}
// Test that calling send() in UNSENT state throws an exception
-void tst_xmlhttprequest::send_unsent()
+void tst_qmlxmlhttprequest::send_unsent()
{
QmlComponent component(&engine, TEST_FILE("send_unsent.qml"));
QObject *object = component.create();
@@ -537,7 +537,7 @@ void tst_xmlhttprequest::send_unsent()
}
// Test attempting to resend a sent request throws an exception
-void tst_xmlhttprequest::send_alreadySent()
+void tst_qmlxmlhttprequest::send_alreadySent()
{
QmlComponent component(&engine, TEST_FILE("send_alreadySent.qml"));
QObject *object = component.create();
@@ -550,7 +550,7 @@ void tst_xmlhttprequest::send_alreadySent()
}
// Test that send for a GET or HEAD ignores data
-void tst_xmlhttprequest::send_ignoreData()
+void tst_qmlxmlhttprequest::send_ignoreData()
{
{
TestHTTPServer server(SERVER_PORT);
@@ -592,7 +592,7 @@ void tst_xmlhttprequest::send_ignoreData()
}
// Test that send()'ing data works
-void tst_xmlhttprequest::send_withdata()
+void tst_qmlxmlhttprequest::send_withdata()
{
// No content-type
{
@@ -729,7 +729,7 @@ void tst_xmlhttprequest::send_withdata()
}
// Test abort() has no effect in unsent state
-void tst_xmlhttprequest::abort_unsent()
+void tst_qmlxmlhttprequest::abort_unsent()
{
QmlComponent component(&engine, TEST_FILE("abort_unsent.qml"));
QObject *object = component.beginCreate(engine.rootContext());
@@ -750,7 +750,7 @@ void tst_xmlhttprequest::abort_unsent()
}
// Test abort() cancels an open (but unsent) request
-void tst_xmlhttprequest::abort_opened()
+void tst_qmlxmlhttprequest::abort_opened()
{
QmlComponent component(&engine, TEST_FILE("abort_opened.qml"));
QObject *object = component.beginCreate(engine.rootContext());
@@ -771,7 +771,7 @@ void tst_xmlhttprequest::abort_opened()
}
// Test abort() aborts in progress send
-void tst_xmlhttprequest::abort()
+void tst_qmlxmlhttprequest::abort()
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
@@ -795,7 +795,7 @@ void tst_xmlhttprequest::abort()
delete object;
}
-void tst_xmlhttprequest::getResponseHeader()
+void tst_qmlxmlhttprequest::getResponseHeader()
{
QmlEngine engine; // Avoid cookie contamination
@@ -835,7 +835,7 @@ void tst_xmlhttprequest::getResponseHeader()
}
// Test getResponseHeader throws an exception in an invalid state
-void tst_xmlhttprequest::getResponseHeader_unsent()
+void tst_qmlxmlhttprequest::getResponseHeader_unsent()
{
QmlComponent component(&engine, TEST_FILE("getResponseHeader_unsent.qml"));
QObject *object = component.create();
@@ -847,7 +847,7 @@ void tst_xmlhttprequest::getResponseHeader_unsent()
}
// Test getResponseHeader throws an exception in an invalid state
-void tst_xmlhttprequest::getResponseHeader_sent()
+void tst_qmlxmlhttprequest::getResponseHeader_sent()
{
QmlComponent component(&engine, TEST_FILE("getResponseHeader_sent.qml"));
QObject *object = component.create();
@@ -859,7 +859,7 @@ void tst_xmlhttprequest::getResponseHeader_sent()
}
// Invalid arg count throws exception
-void tst_xmlhttprequest::getResponseHeader_args()
+void tst_qmlxmlhttprequest::getResponseHeader_args()
{
QmlComponent component(&engine, TEST_FILE("getResponseHeader_args.qml"));
QObject *object = component.create();
@@ -870,7 +870,7 @@ void tst_xmlhttprequest::getResponseHeader_args()
delete object;
}
-void tst_xmlhttprequest::getAllResponseHeaders()
+void tst_qmlxmlhttprequest::getAllResponseHeaders()
{
QmlEngine engine; // Avoid cookie contamination
@@ -903,7 +903,7 @@ void tst_xmlhttprequest::getAllResponseHeaders()
}
// Test getAllResponseHeaders throws an exception in an invalid state
-void tst_xmlhttprequest::getAllResponseHeaders_unsent()
+void tst_qmlxmlhttprequest::getAllResponseHeaders_unsent()
{
QmlComponent component(&engine, TEST_FILE("getAllResponseHeaders_unsent.qml"));
QObject *object = component.create();
@@ -915,7 +915,7 @@ void tst_xmlhttprequest::getAllResponseHeaders_unsent()
}
// Test getAllResponseHeaders throws an exception in an invalid state
-void tst_xmlhttprequest::getAllResponseHeaders_sent()
+void tst_qmlxmlhttprequest::getAllResponseHeaders_sent()
{
QmlComponent component(&engine, TEST_FILE("getAllResponseHeaders_sent.qml"));
QObject *object = component.create();
@@ -927,7 +927,7 @@ void tst_xmlhttprequest::getAllResponseHeaders_sent()
}
// Invalid arg count throws exception
-void tst_xmlhttprequest::getAllResponseHeaders_args()
+void tst_qmlxmlhttprequest::getAllResponseHeaders_args()
{
QmlComponent component(&engine, TEST_FILE("getAllResponseHeaders_args.qml"));
QObject *object = component.create();
@@ -938,7 +938,7 @@ void tst_xmlhttprequest::getAllResponseHeaders_args()
delete object;
}
-void tst_xmlhttprequest::status()
+void tst_qmlxmlhttprequest::status()
{
{
TestHTTPServer server(SERVER_PORT);
@@ -995,7 +995,7 @@ void tst_xmlhttprequest::status()
}
}
-void tst_xmlhttprequest::statusText()
+void tst_qmlxmlhttprequest::statusText()
{
{
TestHTTPServer server(SERVER_PORT);
@@ -1052,7 +1052,7 @@ void tst_xmlhttprequest::statusText()
}
}
-void tst_xmlhttprequest::responseText()
+void tst_qmlxmlhttprequest::responseText()
{
{
TestHTTPServer server(SERVER_PORT);
@@ -1138,7 +1138,7 @@ void tst_xmlhttprequest::responseText()
// Test that calling hte XMLHttpRequest methods on a non-XMLHttpRequest object
// throws an exception
-void tst_xmlhttprequest::invalidMethodUsage()
+void tst_qmlxmlhttprequest::invalidMethodUsage()
{
QmlComponent component(&engine, TEST_FILE("invalidMethodUsage.qml"));
QObject *object = component.create();
@@ -1162,7 +1162,7 @@ void tst_xmlhttprequest::invalidMethodUsage()
}
// Test that XMLHttpRequest transparently redirects
-void tst_xmlhttprequest::redirects()
+void tst_qmlxmlhttprequest::redirects()
{
{
TestHTTPServer server(SERVER_PORT);
@@ -1227,7 +1227,7 @@ void tst_xmlhttprequest::redirects()
}
}
-void tst_xmlhttprequest::responseXML_invalid()
+void tst_qmlxmlhttprequest::responseXML_invalid()
{
QmlComponent component(&engine, TEST_FILE("responseXML_invalid.qml"));
QObject *object = component.create();
@@ -1241,7 +1241,7 @@ void tst_xmlhttprequest::responseXML_invalid()
}
// Test the Document DOM element
-void tst_xmlhttprequest::document()
+void tst_qmlxmlhttprequest::document()
{
QmlComponent component(&engine, TEST_FILE("document.qml"));
QObject *object = component.create();
@@ -1255,7 +1255,7 @@ void tst_xmlhttprequest::document()
}
// Test the Element DOM element
-void tst_xmlhttprequest::element()
+void tst_qmlxmlhttprequest::element()
{
QmlComponent component(&engine, TEST_FILE("element.qml"));
QObject *object = component.create();
@@ -1269,7 +1269,7 @@ void tst_xmlhttprequest::element()
}
// Test the Attr DOM element
-void tst_xmlhttprequest::attr()
+void tst_qmlxmlhttprequest::attr()
{
QmlComponent component(&engine, TEST_FILE("attr.qml"));
QObject *object = component.create();
@@ -1283,7 +1283,7 @@ void tst_xmlhttprequest::attr()
}
// Test the Text DOM element
-void tst_xmlhttprequest::text()
+void tst_qmlxmlhttprequest::text()
{
QmlComponent component(&engine, TEST_FILE("text.qml"));
QObject *object = component.create();
@@ -1297,7 +1297,7 @@ void tst_xmlhttprequest::text()
}
// Test the CDataSection DOM element
-void tst_xmlhttprequest::cdata()
+void tst_qmlxmlhttprequest::cdata()
{
QmlComponent component(&engine, TEST_FILE("cdata.qml"));
QObject *object = component.create();
@@ -1310,6 +1310,6 @@ void tst_xmlhttprequest::cdata()
delete object;
}
-QTEST_MAIN(tst_xmlhttprequest)
+QTEST_MAIN(tst_qmlxmlhttprequest)
#include "tst_qmlxmlhttprequest.moc"
diff --git a/tests/auto/declarative/runall.sh b/tests/auto/declarative/runall.sh
index 5e32c90..39485d3 100755
--- a/tests/auto/declarative/runall.sh
+++ b/tests/auto/declarative/runall.sh
@@ -46,13 +46,19 @@ sleep 1
trap "kill $!" EXIT
export DISPLAY=:7
-make -k -j1 install 2>&1 |
+( make -k -j1 install 2>&1;
+ for exe in $(make install | sed -n 's/^install .* "\([^"]*qt4\/tst_[^"]*\)".*/\1/p')
+ do
+ $exe
+ done
+) |
while read line
do
case "$line" in
make*Error) echo "$line";;
make*Stop) echo "$line";;
make*) ;;
+ install*) ;;
*/qmake*) ;;
*/bin/moc*) ;;
*targ.debug*) ;;
diff --git a/tests/auto/declarative/shared/debugutil.cpp b/tests/auto/declarative/shared/debugutil.cpp
index 56518d7..864bb63 100644
--- a/tests/auto/declarative/shared/debugutil.cpp
+++ b/tests/auto/declarative/shared/debugutil.cpp
@@ -47,6 +47,8 @@
#include "debugutil_p.h"
+#include <iostream>
+
bool QmlDebugTest::waitForSignal(QObject *receiver, const char *member, int timeout) {
QEventLoop loop;
QTimer timer;
@@ -117,21 +119,22 @@ void QmlDebugTestClient::messageReceived(const QByteArray &ba)
tst_QmlDebug_Thread::tst_QmlDebug_Thread(QmlDebugTestData *data, QmlTestFactory *factory)
- : m_ready(false), m_data(data), m_factory(factory)
+ : m_data(data), m_factory(factory)
{
}
void tst_QmlDebug_Thread::run()
{
- QTest::qWait(1000);
+ bool ok = false;
QmlDebugConnection conn;
conn.connectToHost("127.0.0.1", 3768);
- bool ok = conn.waitForConnected(5000);
+ ok = conn.waitForConnected();
Q_ASSERT(ok);
- while (!m_ready)
- QTest::qWait(100);
+ QEventLoop loop;
+ connect(m_data, SIGNAL(engineCreated()), &loop, SLOT(quit()));
+ loop.exec();
m_data->conn = &conn;
@@ -139,10 +142,10 @@ void tst_QmlDebug_Thread::run()
QObject *test = m_factory->createTest(m_data);
Q_ASSERT(test);
int code = QTest::qExec(test, QCoreApplication::arguments());
+ delete test;
emit testsFinished(code);
}
-
int QmlDebugTest::runTests(QmlTestFactory *factory, const QList<QByteArray> &qml)
{
qputenv("QML_DEBUG_SERVER_PORT", "3768");
@@ -152,7 +155,8 @@ int QmlDebugTest::runTests(QmlTestFactory *factory, const QList<QByteArray> &qml
tst_QmlDebug_Thread thread(&data, factory);
QObject::connect(&thread, SIGNAL(testsFinished(int)), &data, SLOT(testsFinished(int)));
- thread.start();
+
+ QmlDebugService::notifyOnServerStart(&thread, "start");
QmlEngine engine; // blocks until client connects
@@ -165,7 +169,7 @@ int QmlDebugTest::runTests(QmlTestFactory *factory, const QList<QByteArray> &qml
// start the test
data.engine = &engine;
- thread.m_ready = true;
+ emit data.engineCreated();
loop.exec();
thread.wait();
@@ -173,4 +177,3 @@ int QmlDebugTest::runTests(QmlTestFactory *factory, const QList<QByteArray> &qml
return data.exitCode;
}
-
diff --git a/tests/auto/declarative/shared/debugutil_p.h b/tests/auto/declarative/shared/debugutil_p.h
index d32e8ac..6815b3c 100644
--- a/tests/auto/declarative/shared/debugutil_p.h
+++ b/tests/auto/declarative/shared/debugutil_p.h
@@ -51,6 +51,15 @@
#include <private/qmldebugservice_p.h>
#include <private/qmlgraphicsitem_p.h>
+class QmlTestFactory;
+
+class QmlDebugTest
+{
+public:
+ static bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000);
+
+ static int runTests(QmlTestFactory *factory, const QList<QByteArray> &qml = QList<QByteArray>());
+};
class QmlDebugTestData : public QObject
{
@@ -68,8 +77,14 @@ public:
QList<QmlGraphicsItem *> items;
+signals:
+ void engineCreated();
+
public slots:
void testsFinished(int code);
+
+private:
+ friend class QmlDebugTest;
};
@@ -82,14 +97,6 @@ public:
virtual QObject *createTest(QmlDebugTestData *data) = 0;
};
-
-namespace QmlDebugTest {
-
- bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000);
-
- int runTests(QmlTestFactory *factory, const QList<QByteArray> &qml = QList<QByteArray>());
-}
-
class QmlDebugTestService : public QmlDebugService
{
Q_OBJECT
@@ -132,8 +139,6 @@ public:
void run();
- bool m_ready;
-
signals:
void testsFinished(int);
diff --git a/tests/auto/declarative/shared/testhttpserver.cpp b/tests/auto/declarative/shared/testhttpserver.cpp
index fe2b2cf..5d56327 100644
--- a/tests/auto/declarative/shared/testhttpserver.cpp
+++ b/tests/auto/declarative/shared/testhttpserver.cpp
@@ -190,13 +190,14 @@ void TestHTTPServer::disconnected()
--ii;
}
}
+ socket->disconnect();
socket->deleteLater();
}
void TestHTTPServer::readyRead()
{
QTcpSocket *socket = qobject_cast<QTcpSocket *>(sender());
- if (!socket) return;
+ if (!socket || socket->state() == QTcpSocket::ClosingState) return;
QByteArray ba = socket->readAll();
@@ -222,14 +223,14 @@ void TestHTTPServer::readyRead()
QByteArray data = ba.mid(ii);
qWarning() << "TestHTTPServer: Unexpected data" << data << "\nExpected: " << waitData;
m_hasFailed = true;
- socket->disconnect();
+ socket->disconnectFromHost();
return;
}
}
if (waitData.isEmpty()) {
socket->write(replyData);
- socket->disconnect();
+ socket->disconnectFromHost();
}
}
@@ -316,8 +317,8 @@ void TestHTTPServer::serveGET(QTcpSocket *socket, const QByteArray &data)
}
dataCache.remove(socket);
- if (close)
- socket->close();
+ if (close)
+ socket->disconnectFromHost();
}
}
diff --git a/tests/auto/declarative/visual/Package_Views/packageviews.qml b/tests/auto/declarative/visual/Package_Views/packageviews.qml
index c8016b6..dcfe7de 100644
--- a/tests/auto/declarative/visual/Package_Views/packageviews.qml
+++ b/tests/auto/declarative/visual/Package_Views/packageviews.qml
@@ -64,7 +64,7 @@ Rectangle {
from: "*"; to: "*"
SequentialAnimation {
ParentAction{}
- NumberAnimation { matchProperties: "x,y,width"; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "x,y,width"; easing: "easeInOutQuad" }
}
}
]
diff --git a/tests/auto/declarative/visual/animation/bindinganimation/bindinganimation.qml b/tests/auto/declarative/visual/animation/bindinganimation/bindinganimation.qml
index 732eb59..5230ca4 100644
--- a/tests/auto/declarative/visual/animation/bindinganimation/bindinganimation.qml
+++ b/tests/auto/declarative/visual/animation/bindinganimation/bindinganimation.qml
@@ -28,7 +28,7 @@ Rectangle {
transitions: [
Transition {
NumberAnimation {
- matchProperties: "x"
+ properties: "x"
}
}
]
diff --git a/tests/auto/declarative/visual/animation/easing/easing.qml b/tests/auto/declarative/visual/animation/easing/easing.qml
index 1e8e907..f81400b 100644
--- a/tests/auto/declarative/visual/animation/easing/easing.qml
+++ b/tests/auto/declarative/visual/animation/easing/easing.qml
@@ -176,7 +176,7 @@ Rectangle {
to: "to"
reversible: true
NumberAnimation {
- matchProperties: "x"
+ properties: "x"
easing: type
duration: 1000
}
diff --git a/tests/auto/declarative/visual/animation/loop/data/loop.0.png b/tests/auto/declarative/visual/animation/loop/data/loop.0.png
new file mode 100644
index 0000000..f4301d3
--- /dev/null
+++ b/tests/auto/declarative/visual/animation/loop/data/loop.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/animation/loop/data/loop.1.png b/tests/auto/declarative/visual/animation/loop/data/loop.1.png
new file mode 100644
index 0000000..ceb0e20
--- /dev/null
+++ b/tests/auto/declarative/visual/animation/loop/data/loop.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/animation/loop/data/loop.2.png b/tests/auto/declarative/visual/animation/loop/data/loop.2.png
new file mode 100644
index 0000000..197c8c0
--- /dev/null
+++ b/tests/auto/declarative/visual/animation/loop/data/loop.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/animation/loop/data/loop.3.png b/tests/auto/declarative/visual/animation/loop/data/loop.3.png
new file mode 100644
index 0000000..3a4327e
--- /dev/null
+++ b/tests/auto/declarative/visual/animation/loop/data/loop.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/animation/loop/data/loop.4.png b/tests/auto/declarative/visual/animation/loop/data/loop.4.png
new file mode 100644
index 0000000..2397719
--- /dev/null
+++ b/tests/auto/declarative/visual/animation/loop/data/loop.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/animation/loop/data/loop.5.png b/tests/auto/declarative/visual/animation/loop/data/loop.5.png
new file mode 100644
index 0000000..70d91a2
--- /dev/null
+++ b/tests/auto/declarative/visual/animation/loop/data/loop.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/animation/loop/data/loop.qml b/tests/auto/declarative/visual/animation/loop/data/loop.qml
new file mode 100644
index 0000000..8804d44
--- /dev/null
+++ b/tests/auto/declarative/visual/animation/loop/data/loop.qml
@@ -0,0 +1,1471 @@
+import Qt.VisualTest 4.6
+
+VisualTest {
+ Frame {
+ msec: 0
+ }
+ Frame {
+ msec: 16
+ hash: "eff7cc4b163dceb6084270cc589393f1"
+ }
+ Frame {
+ msec: 32
+ hash: "1012b52727ae98522061945e32a6269a"
+ }
+ Frame {
+ msec: 48
+ hash: "06c3f3c1fa014b0eb7341e0a45ca16e4"
+ }
+ Frame {
+ msec: 64
+ hash: "71ecb0af25649c056310d3b865d4144d"
+ }
+ Frame {
+ msec: 80
+ hash: "e249fe5b113797433f96a2f84d47e42b"
+ }
+ Frame {
+ msec: 96
+ hash: "2a7256921c25c79c22263f2b48d4e98c"
+ }
+ Frame {
+ msec: 112
+ hash: "8657944b456402622f2991a0c9acc2fb"
+ }
+ Frame {
+ msec: 128
+ hash: "c919a94cd7afb1fbad4c88537af00869"
+ }
+ Frame {
+ msec: 144
+ hash: "303b5057d94e328f9447a01d54eea93d"
+ }
+ Frame {
+ msec: 160
+ hash: "72eb974dc008c9454935b18b47d4d9e6"
+ }
+ Frame {
+ msec: 176
+ hash: "545f258cb0ec7f5d951b74cc7d3f4f0d"
+ }
+ Frame {
+ msec: 192
+ hash: "3b3d6046fb01adf7c8a7f67bbc46d28e"
+ }
+ Frame {
+ msec: 208
+ hash: "12f7556076cf7a4c2f029dab80e666e7"
+ }
+ Frame {
+ msec: 224
+ hash: "fab272c7dce2bbee4042764d38c7ceb5"
+ }
+ Frame {
+ msec: 240
+ hash: "ff8addee408527bbaed1819bae07c23f"
+ }
+ Frame {
+ msec: 256
+ hash: "53eb6f575db2af3635139e5ddbd7b2f9"
+ }
+ Frame {
+ msec: 272
+ hash: "a2fa1cf169acb8ff26a2c5ec1f1d5c81"
+ }
+ Frame {
+ msec: 288
+ hash: "ab8d5d6d146ed11b92bc93e78f28e50c"
+ }
+ Frame {
+ msec: 304
+ hash: "0fbfc6609b082008e44592067b18ab63"
+ }
+ Frame {
+ msec: 320
+ hash: "7fbeda19c19c62a0af5f7f98e633993f"
+ }
+ Frame {
+ msec: 336
+ hash: "1882b591bc9d4e79d69d0baecb78b700"
+ }
+ Frame {
+ msec: 352
+ hash: "dde429007f876206f3ec0c68d239983e"
+ }
+ Frame {
+ msec: 368
+ hash: "b656bdba2978a9a1af511cc2bb0cb59a"
+ }
+ Frame {
+ msec: 384
+ hash: "1f6573bf67b2893c94f0c2d40213dc73"
+ }
+ Frame {
+ msec: 400
+ hash: "f5786fb532300a1b2f820251fc17c775"
+ }
+ Frame {
+ msec: 416
+ hash: "a0e9c4bd3b6c4cdadd40bdf3ca5e2986"
+ }
+ Frame {
+ msec: 432
+ hash: "073f74ab23a1173025b3c63424ce2697"
+ }
+ Frame {
+ msec: 448
+ hash: "1ac1367d21e346c6c652a88b9ea25bfc"
+ }
+ Frame {
+ msec: 464
+ hash: "f62720308dc9ae67c3856bc3afb32b75"
+ }
+ Frame {
+ msec: 480
+ hash: "066476a57efba802d2497bc3731a3583"
+ }
+ Frame {
+ msec: 496
+ hash: "fb965028a760e8d0a4d81fd982a18ff3"
+ }
+ Frame {
+ msec: 512
+ hash: "ba008abd1a7a73c750b909d57c043649"
+ }
+ Frame {
+ msec: 528
+ hash: "4c974470953f74d1ee7bcd0f4a4c48cf"
+ }
+ Frame {
+ msec: 544
+ hash: "ea233f3476da26c90d67b7775b718aa2"
+ }
+ Frame {
+ msec: 560
+ hash: "e12c3b810c0aa628d7a3827453bea9f3"
+ }
+ Frame {
+ msec: 576
+ hash: "7451954ca0465c430fc4bae84f6d97cb"
+ }
+ Frame {
+ msec: 592
+ hash: "503e40f193a8b099daa4013eddc2f664"
+ }
+ Frame {
+ msec: 608
+ hash: "1f81acf94f325a51faa7aa61e73f8a25"
+ }
+ Frame {
+ msec: 624
+ hash: "0257d7d53eda8afe182a9f97ef451679"
+ }
+ Frame {
+ msec: 640
+ hash: "cfc260bdc977ef16311840022cc85378"
+ }
+ Frame {
+ msec: 656
+ hash: "27483f0b89d727b32722ea153fad30ad"
+ }
+ Frame {
+ msec: 672
+ hash: "355afa11b8e7b24a353d1aa79daf7564"
+ }
+ Frame {
+ msec: 688
+ hash: "bbc1d55f346719476f471a2294227bda"
+ }
+ Frame {
+ msec: 704
+ hash: "9bbab5ff75219d8bd65022c6d061e57a"
+ }
+ Frame {
+ msec: 720
+ hash: "ff0699f02845f3c5cf5aabb19198c346"
+ }
+ Frame {
+ msec: 736
+ hash: "26768e09270ade4c5b484154e7042f43"
+ }
+ Frame {
+ msec: 752
+ hash: "31c9ae63071de3fb2f7e1836a22515cb"
+ }
+ Frame {
+ msec: 768
+ hash: "783ce2acdae8d87883151532c9293336"
+ }
+ Frame {
+ msec: 784
+ hash: "86b9fd739f437127e0cc4d7dcd4284bd"
+ }
+ Frame {
+ msec: 800
+ hash: "5e1d6e164dd184cc197d514e5ff60a4c"
+ }
+ Frame {
+ msec: 816
+ hash: "13063a8d73704165d64dd2a95803ec0f"
+ }
+ Frame {
+ msec: 832
+ hash: "c244e0c0d60f4be2e017bba21a17ab3f"
+ }
+ Frame {
+ msec: 848
+ hash: "b3bd657873f1b49c888b9b98d8c0e23f"
+ }
+ Frame {
+ msec: 864
+ hash: "65a011e4f62ecddd820bdbdeb0084b65"
+ }
+ Frame {
+ msec: 880
+ hash: "86018de7b4a93b267fe94c4de9e61bab"
+ }
+ Frame {
+ msec: 896
+ hash: "44827055c99ae3ed924c101c9d1be5c5"
+ }
+ Frame {
+ msec: 912
+ hash: "1c31fcb20ec1abc7ea815b703ae05363"
+ }
+ Frame {
+ msec: 928
+ hash: "9d7825b7b05ca696846a4116ab27f966"
+ }
+ Frame {
+ msec: 944
+ hash: "61b6690dd14fc76dbac4d785bbddb8ee"
+ }
+ Frame {
+ msec: 960
+ image: "loop.0.png"
+ }
+ Frame {
+ msec: 976
+ hash: "2cc40e1119060483ae067f3881af0391"
+ }
+ Frame {
+ msec: 992
+ hash: "9747fdff3429f7a2dbc9e3173ad43a67"
+ }
+ Frame {
+ msec: 1008
+ hash: "e68058b9565138f2d7f0f96b74c38dec"
+ }
+ Frame {
+ msec: 1024
+ hash: "f32aceabb929471dffd73bf0290e75a2"
+ }
+ Frame {
+ msec: 1040
+ hash: "9112838cc8f9a0cfb94e0ef6ca7eca71"
+ }
+ Frame {
+ msec: 1056
+ hash: "53bd2c46e3a11db0ee151a6a0311b3a8"
+ }
+ Frame {
+ msec: 1072
+ hash: "d5105f958a592324e53aae4a83beb049"
+ }
+ Frame {
+ msec: 1088
+ hash: "862249432e6fc6114b63284ad9c97cb6"
+ }
+ Frame {
+ msec: 1104
+ hash: "3e6a6f505aa146a6789434d265ad4d3b"
+ }
+ Frame {
+ msec: 1120
+ hash: "0f5b2b05f72b86bd2b0a6d0ea2b6bf37"
+ }
+ Frame {
+ msec: 1136
+ hash: "922520f7ec954d6d1061208cbd63877e"
+ }
+ Frame {
+ msec: 1152
+ hash: "d1c02f3ce4bcc96e0c3d2503a0e9aa48"
+ }
+ Frame {
+ msec: 1168
+ hash: "ebb41112b687ecb062dedc3b49cb93fc"
+ }
+ Frame {
+ msec: 1184
+ hash: "7bc87d71d532aa52abc26ac9c1cbb665"
+ }
+ Frame {
+ msec: 1200
+ hash: "1a7a81f851c8817cac3cc0cb7ac07971"
+ }
+ Frame {
+ msec: 1216
+ hash: "ca17c870c55f2947bb5f85d28f30ee7c"
+ }
+ Frame {
+ msec: 1232
+ hash: "48b123cfd6d2ea1c2bc9f2ba822ec7bf"
+ }
+ Frame {
+ msec: 1248
+ hash: "2a6b8aecef26793e200993dc1e25fd95"
+ }
+ Frame {
+ msec: 1264
+ hash: "f10a0a11ed54a910fe434311f67343a4"
+ }
+ Frame {
+ msec: 1280
+ hash: "47b6e1beabdcd3cd3d21d77c62e5bed8"
+ }
+ Frame {
+ msec: 1296
+ hash: "1eea7eb2853a9e7a1a69738667457b7a"
+ }
+ Frame {
+ msec: 1312
+ hash: "9e018f9e7a5ba22bbb9be3049373124a"
+ }
+ Frame {
+ msec: 1328
+ hash: "d63069a8e7b0eb5611cc34caaecef2fb"
+ }
+ Frame {
+ msec: 1344
+ hash: "def9383a090e4454343725f1a7c4fb3d"
+ }
+ Frame {
+ msec: 1360
+ hash: "fd3036e559fd31eeadb0032666a95864"
+ }
+ Frame {
+ msec: 1376
+ hash: "cf9f82b9e2a03f63f75b6ac113b3d4e5"
+ }
+ Frame {
+ msec: 1392
+ hash: "346e7f597cfb4fc51d5393e705deddd5"
+ }
+ Frame {
+ msec: 1408
+ hash: "0d6d6cb2ca808f5a57acfa32e10fc335"
+ }
+ Frame {
+ msec: 1424
+ hash: "9a660a0fed41211a37d3ac82be40f81a"
+ }
+ Frame {
+ msec: 1440
+ hash: "df3fd60ecbd517879e00e8112c49bed4"
+ }
+ Frame {
+ msec: 1456
+ hash: "cd86fe5894e5d061f7ffe37913f00ce6"
+ }
+ Frame {
+ msec: 1472
+ hash: "a5fdb825c18d43f3ae18f5c28e715174"
+ }
+ Frame {
+ msec: 1488
+ hash: "0fdfb5f9463def560da6c19acf96bafb"
+ }
+ Frame {
+ msec: 1504
+ hash: "8849a36af064503dbccad69a35b6ab03"
+ }
+ Frame {
+ msec: 1520
+ hash: "baeb4f90b0e2efc09225dbb5dd003e9e"
+ }
+ Frame {
+ msec: 1536
+ hash: "86922e71c80976ef3aa2cab18f86c010"
+ }
+ Frame {
+ msec: 1552
+ hash: "10d166d7da9949370a66251415522186"
+ }
+ Frame {
+ msec: 1568
+ hash: "ada1608055b221dc9f1f7650a9764930"
+ }
+ Frame {
+ msec: 1584
+ hash: "dd25ffb9a6bf009139b2942f9cc1f8e7"
+ }
+ Frame {
+ msec: 1600
+ hash: "dc4a1c44d08328965b53ff079a8fa57b"
+ }
+ Frame {
+ msec: 1616
+ hash: "d3d88cf635ba38e5035732cb36014417"
+ }
+ Frame {
+ msec: 1632
+ hash: "be5e44f6b9978ba3b9ae878ae5758a96"
+ }
+ Frame {
+ msec: 1648
+ hash: "34f193daf199ab45310be2b407499e57"
+ }
+ Frame {
+ msec: 1664
+ hash: "d87c854e1c16642dba0d87e25f0e416f"
+ }
+ Frame {
+ msec: 1680
+ hash: "08c404f4efd27695071ad52fbfa57c0b"
+ }
+ Frame {
+ msec: 1696
+ hash: "84828f8e0cace1a39d9b7f19b6e4cbaa"
+ }
+ Frame {
+ msec: 1712
+ hash: "8a0c6e1f597e699c3e2be816ae4e1dd4"
+ }
+ Frame {
+ msec: 1728
+ hash: "9aecb0c464fb140725f34ad94ede367a"
+ }
+ Frame {
+ msec: 1744
+ hash: "a298b3ab2939819ced7e7f903ec63be4"
+ }
+ Frame {
+ msec: 1760
+ hash: "99789b6e168355a3960986c7d1f21f82"
+ }
+ Frame {
+ msec: 1776
+ hash: "ebd37ee719ca460480521fd4ec284a3f"
+ }
+ Frame {
+ msec: 1792
+ hash: "9c9b3fb5b623d3deaf9920c99279d71b"
+ }
+ Frame {
+ msec: 1808
+ hash: "8f0be6d4d6fd7f66a43fd604e17717dd"
+ }
+ Frame {
+ msec: 1824
+ hash: "854defd35cf3315e4501583756814ff6"
+ }
+ Frame {
+ msec: 1840
+ hash: "fd7157aef6dfb303472cd33b176f91d8"
+ }
+ Frame {
+ msec: 1856
+ hash: "e6521a3c74c190c193af2c913e5326e2"
+ }
+ Frame {
+ msec: 1872
+ hash: "19862dcb88fcbbb2c4ecdc42821c7fef"
+ }
+ Frame {
+ msec: 1888
+ hash: "5e29a9f9c6c4131c5b71f84d24503ad2"
+ }
+ Frame {
+ msec: 1904
+ hash: "140e63c071ef77d26034d0bb6a5d5b7a"
+ }
+ Frame {
+ msec: 1920
+ image: "loop.1.png"
+ }
+ Frame {
+ msec: 1936
+ hash: "7f79dd50a0af8e8871191ee80afcad0f"
+ }
+ Frame {
+ msec: 1952
+ hash: "a5eb3334044999f56c759ce8727d627f"
+ }
+ Frame {
+ msec: 1968
+ hash: "3fb70a7591b6decfa44f7cad18f73855"
+ }
+ Frame {
+ msec: 1984
+ hash: "3fab99be73f7f12b9463dea359fc86d2"
+ }
+ Frame {
+ msec: 2000
+ hash: "50ce6b869e42c949b84cf2dd0cca3af9"
+ }
+ Frame {
+ msec: 2016
+ hash: "5369125b23e2f954c18f2fd4e0ba6f6a"
+ }
+ Frame {
+ msec: 2032
+ hash: "a76f624be0db97ec4450b10f748065df"
+ }
+ Frame {
+ msec: 2048
+ hash: "3fb70a7591b6decfa44f7cad18f73855"
+ }
+ Frame {
+ msec: 2064
+ hash: "dada267799b6e57acfcc5de3b8822c7c"
+ }
+ Frame {
+ msec: 2080
+ hash: "72c0bf8225504e86ff023242b84513a8"
+ }
+ Frame {
+ msec: 2096
+ hash: "1e8b095c39bd359637b1b9c975ee514c"
+ }
+ Frame {
+ msec: 2112
+ hash: "19862dcb88fcbbb2c4ecdc42821c7fef"
+ }
+ Frame {
+ msec: 2128
+ hash: "60c95993a894e1c6e2d476db365b7746"
+ }
+ Frame {
+ msec: 2144
+ hash: "854defd35cf3315e4501583756814ff6"
+ }
+ Frame {
+ msec: 2160
+ hash: "15e8959bfa4d206b2f0607322b21cba6"
+ }
+ Frame {
+ msec: 2176
+ hash: "ebd37ee719ca460480521fd4ec284a3f"
+ }
+ Frame {
+ msec: 2192
+ hash: "6d278926822d044fff04c3f182dcb058"
+ }
+ Frame {
+ msec: 2208
+ hash: "9aecb0c464fb140725f34ad94ede367a"
+ }
+ Frame {
+ msec: 2224
+ hash: "b36f70f138e6deecf5b105bcd89d1a15"
+ }
+ Frame {
+ msec: 2240
+ hash: "08c404f4efd27695071ad52fbfa57c0b"
+ }
+ Frame {
+ msec: 2256
+ hash: "6469d0bee7ab280639b565ebf174f251"
+ }
+ Frame {
+ msec: 2272
+ hash: "be5e44f6b9978ba3b9ae878ae5758a96"
+ }
+ Frame {
+ msec: 2288
+ hash: "5214e578bc78b729ddf35c140093c0da"
+ }
+ Frame {
+ msec: 2304
+ hash: "dd25ffb9a6bf009139b2942f9cc1f8e7"
+ }
+ Frame {
+ msec: 2320
+ hash: "2ddf31aeac4815be56848703a9b5aa14"
+ }
+ Frame {
+ msec: 2336
+ hash: "86922e71c80976ef3aa2cab18f86c010"
+ }
+ Frame {
+ msec: 2352
+ hash: "d8415ba4fb19b62b838ef2e09ae7607a"
+ }
+ Frame {
+ msec: 2368
+ hash: "0fdfb5f9463def560da6c19acf96bafb"
+ }
+ Frame {
+ msec: 2384
+ hash: "68fac60713af7cb130e92fa381be411c"
+ }
+ Frame {
+ msec: 2400
+ hash: "df3fd60ecbd517879e00e8112c49bed4"
+ }
+ Frame {
+ msec: 2416
+ hash: "64e49282d97ba864d2f6be632ae048e4"
+ }
+ Frame {
+ msec: 2432
+ hash: "346e7f597cfb4fc51d5393e705deddd5"
+ }
+ Frame {
+ msec: 2448
+ hash: "f302a9ce45187ff1001c967a4c753b2b"
+ }
+ Frame {
+ msec: 2464
+ hash: "def9383a090e4454343725f1a7c4fb3d"
+ }
+ Frame {
+ msec: 2480
+ hash: "fd177a7ae3b5b9205fd38e955be327e0"
+ }
+ Frame {
+ msec: 2496
+ hash: "1eea7eb2853a9e7a1a69738667457b7a"
+ }
+ Frame {
+ msec: 2512
+ hash: "32b16dd62ccf06e44be38fd5885f297e"
+ }
+ Frame {
+ msec: 2528
+ hash: "2a6b8aecef26793e200993dc1e25fd95"
+ }
+ Frame {
+ msec: 2544
+ hash: "8637606843905d6ae3f95fcb745f2a6e"
+ }
+ Frame {
+ msec: 2560
+ hash: "1a7a81f851c8817cac3cc0cb7ac07971"
+ }
+ Frame {
+ msec: 2576
+ hash: "704ca30ddc0a637f3d1cd4926a6f7983"
+ }
+ Frame {
+ msec: 2592
+ hash: "d1c02f3ce4bcc96e0c3d2503a0e9aa48"
+ }
+ Frame {
+ msec: 2608
+ hash: "7759418b4fe412857ab8e7294f5a3206"
+ }
+ Frame {
+ msec: 2624
+ hash: "3e6a6f505aa146a6789434d265ad4d3b"
+ }
+ Frame {
+ msec: 2640
+ hash: "3e6089b47573cd53b0a220275202c80b"
+ }
+ Frame {
+ msec: 2656
+ hash: "53bd2c46e3a11db0ee151a6a0311b3a8"
+ }
+ Frame {
+ msec: 2672
+ hash: "f30202ae354a587c5949a16c1f8b95c3"
+ }
+ Frame {
+ msec: 2688
+ hash: "66f78a34fe9d297af1ae8e98f84ead55"
+ }
+ Frame {
+ msec: 2704
+ hash: "3e2fc29876812fe57ea008a71db299a4"
+ }
+ Frame {
+ msec: 2720
+ hash: "7234b6df2220e418ef8ebe8f1c82bf26"
+ }
+ Frame {
+ msec: 2736
+ hash: "82dd491c3b34e702a24ece8e55761a6f"
+ }
+ Frame {
+ msec: 2752
+ hash: "d7f1065f5c42088dfc5ce36687fd8010"
+ }
+ Frame {
+ msec: 2768
+ hash: "15bfbb0261b66ccbe3b34d0ac807165c"
+ }
+ Frame {
+ msec: 2784
+ hash: "69963ce07eb434d787588b21fd020fa3"
+ }
+ Frame {
+ msec: 2800
+ hash: "2fb9e078573ebd1a5cf0f615c97f1d20"
+ }
+ Frame {
+ msec: 2816
+ hash: "31fa31ed47ea16390be8ea9d41f483e7"
+ }
+ Frame {
+ msec: 2832
+ hash: "0f9ed8cd5cfbdab03bcb05cf6dd92620"
+ }
+ Frame {
+ msec: 2848
+ hash: "a0e737132ae642c465e991e770ab3e34"
+ }
+ Frame {
+ msec: 2864
+ hash: "d57cc5045f01ab4e7eb72575aef22a10"
+ }
+ Frame {
+ msec: 2880
+ image: "loop.2.png"
+ }
+ Frame {
+ msec: 2896
+ hash: "df41be1fa564353ceb2088af209610d3"
+ }
+ Frame {
+ msec: 2912
+ hash: "2d294613ed10dfdbca829b43b6990574"
+ }
+ Frame {
+ msec: 2928
+ hash: "0a278a4ec3626442c94ef2da30771171"
+ }
+ Frame {
+ msec: 2944
+ hash: "7071526c830fdfde9d520ad1578d27a8"
+ }
+ Frame {
+ msec: 2960
+ hash: "ad02e7b90f223d3fc5a433bc4ffbee9e"
+ }
+ Frame {
+ msec: 2976
+ hash: "e7ef412697c7df3887980ed1b079ffd5"
+ }
+ Frame {
+ msec: 2992
+ hash: "ebda21f95079b37f4862b42523bbc1c0"
+ }
+ Frame {
+ msec: 3008
+ hash: "6e8889e9b44ff8ed44e228d97fb5034c"
+ }
+ Frame {
+ msec: 3024
+ hash: "f32aceabb929471dffd73bf0290e75a2"
+ }
+ Frame {
+ msec: 3040
+ hash: "9112838cc8f9a0cfb94e0ef6ca7eca71"
+ }
+ Frame {
+ msec: 3056
+ hash: "53bd2c46e3a11db0ee151a6a0311b3a8"
+ }
+ Frame {
+ msec: 3072
+ hash: "d5105f958a592324e53aae4a83beb049"
+ }
+ Frame {
+ msec: 3088
+ hash: "862249432e6fc6114b63284ad9c97cb6"
+ }
+ Frame {
+ msec: 3104
+ hash: "3e6a6f505aa146a6789434d265ad4d3b"
+ }
+ Frame {
+ msec: 3120
+ hash: "0f5b2b05f72b86bd2b0a6d0ea2b6bf37"
+ }
+ Frame {
+ msec: 3136
+ hash: "922520f7ec954d6d1061208cbd63877e"
+ }
+ Frame {
+ msec: 3152
+ hash: "d1c02f3ce4bcc96e0c3d2503a0e9aa48"
+ }
+ Frame {
+ msec: 3168
+ hash: "ebb41112b687ecb062dedc3b49cb93fc"
+ }
+ Frame {
+ msec: 3184
+ hash: "7bc87d71d532aa52abc26ac9c1cbb665"
+ }
+ Frame {
+ msec: 3200
+ hash: "1a7a81f851c8817cac3cc0cb7ac07971"
+ }
+ Frame {
+ msec: 3216
+ hash: "ca17c870c55f2947bb5f85d28f30ee7c"
+ }
+ Frame {
+ msec: 3232
+ hash: "48b123cfd6d2ea1c2bc9f2ba822ec7bf"
+ }
+ Frame {
+ msec: 3248
+ hash: "2a6b8aecef26793e200993dc1e25fd95"
+ }
+ Frame {
+ msec: 3264
+ hash: "f10a0a11ed54a910fe434311f67343a4"
+ }
+ Frame {
+ msec: 3280
+ hash: "47b6e1beabdcd3cd3d21d77c62e5bed8"
+ }
+ Frame {
+ msec: 3296
+ hash: "1eea7eb2853a9e7a1a69738667457b7a"
+ }
+ Frame {
+ msec: 3312
+ hash: "9e018f9e7a5ba22bbb9be3049373124a"
+ }
+ Frame {
+ msec: 3328
+ hash: "d63069a8e7b0eb5611cc34caaecef2fb"
+ }
+ Frame {
+ msec: 3344
+ hash: "def9383a090e4454343725f1a7c4fb3d"
+ }
+ Frame {
+ msec: 3360
+ hash: "fd3036e559fd31eeadb0032666a95864"
+ }
+ Frame {
+ msec: 3376
+ hash: "cf9f82b9e2a03f63f75b6ac113b3d4e5"
+ }
+ Frame {
+ msec: 3392
+ hash: "346e7f597cfb4fc51d5393e705deddd5"
+ }
+ Frame {
+ msec: 3408
+ hash: "0d6d6cb2ca808f5a57acfa32e10fc335"
+ }
+ Frame {
+ msec: 3424
+ hash: "9a660a0fed41211a37d3ac82be40f81a"
+ }
+ Frame {
+ msec: 3440
+ hash: "df3fd60ecbd517879e00e8112c49bed4"
+ }
+ Frame {
+ msec: 3456
+ hash: "cd86fe5894e5d061f7ffe37913f00ce6"
+ }
+ Frame {
+ msec: 3472
+ hash: "a5fdb825c18d43f3ae18f5c28e715174"
+ }
+ Frame {
+ msec: 3488
+ hash: "0fdfb5f9463def560da6c19acf96bafb"
+ }
+ Frame {
+ msec: 3504
+ hash: "8849a36af064503dbccad69a35b6ab03"
+ }
+ Frame {
+ msec: 3520
+ hash: "baeb4f90b0e2efc09225dbb5dd003e9e"
+ }
+ Frame {
+ msec: 3536
+ hash: "86922e71c80976ef3aa2cab18f86c010"
+ }
+ Frame {
+ msec: 3552
+ hash: "10d166d7da9949370a66251415522186"
+ }
+ Frame {
+ msec: 3568
+ hash: "ada1608055b221dc9f1f7650a9764930"
+ }
+ Frame {
+ msec: 3584
+ hash: "dd25ffb9a6bf009139b2942f9cc1f8e7"
+ }
+ Frame {
+ msec: 3600
+ hash: "dc4a1c44d08328965b53ff079a8fa57b"
+ }
+ Frame {
+ msec: 3616
+ hash: "d3d88cf635ba38e5035732cb36014417"
+ }
+ Frame {
+ msec: 3632
+ hash: "be5e44f6b9978ba3b9ae878ae5758a96"
+ }
+ Frame {
+ msec: 3648
+ hash: "34f193daf199ab45310be2b407499e57"
+ }
+ Frame {
+ msec: 3664
+ hash: "d87c854e1c16642dba0d87e25f0e416f"
+ }
+ Frame {
+ msec: 3680
+ hash: "08c404f4efd27695071ad52fbfa57c0b"
+ }
+ Frame {
+ msec: 3696
+ hash: "84828f8e0cace1a39d9b7f19b6e4cbaa"
+ }
+ Frame {
+ msec: 3712
+ hash: "8a0c6e1f597e699c3e2be816ae4e1dd4"
+ }
+ Frame {
+ msec: 3728
+ hash: "9aecb0c464fb140725f34ad94ede367a"
+ }
+ Frame {
+ msec: 3744
+ hash: "a298b3ab2939819ced7e7f903ec63be4"
+ }
+ Frame {
+ msec: 3760
+ hash: "99789b6e168355a3960986c7d1f21f82"
+ }
+ Frame {
+ msec: 3776
+ hash: "ebd37ee719ca460480521fd4ec284a3f"
+ }
+ Frame {
+ msec: 3792
+ hash: "9c9b3fb5b623d3deaf9920c99279d71b"
+ }
+ Frame {
+ msec: 3808
+ hash: "8f0be6d4d6fd7f66a43fd604e17717dd"
+ }
+ Frame {
+ msec: 3824
+ hash: "854defd35cf3315e4501583756814ff6"
+ }
+ Frame {
+ msec: 3840
+ image: "loop.3.png"
+ }
+ Frame {
+ msec: 3856
+ hash: "e6521a3c74c190c193af2c913e5326e2"
+ }
+ Frame {
+ msec: 3872
+ hash: "19862dcb88fcbbb2c4ecdc42821c7fef"
+ }
+ Frame {
+ msec: 3888
+ hash: "5e29a9f9c6c4131c5b71f84d24503ad2"
+ }
+ Frame {
+ msec: 3904
+ hash: "140e63c071ef77d26034d0bb6a5d5b7a"
+ }
+ Frame {
+ msec: 3920
+ hash: "72c0bf8225504e86ff023242b84513a8"
+ }
+ Frame {
+ msec: 3936
+ hash: "7f79dd50a0af8e8871191ee80afcad0f"
+ }
+ Frame {
+ msec: 3952
+ hash: "a5eb3334044999f56c759ce8727d627f"
+ }
+ Frame {
+ msec: 3968
+ hash: "3fb70a7591b6decfa44f7cad18f73855"
+ }
+ Frame {
+ msec: 3984
+ hash: "3fab99be73f7f12b9463dea359fc86d2"
+ }
+ Frame {
+ msec: 4000
+ hash: "50ce6b869e42c949b84cf2dd0cca3af9"
+ }
+ Frame {
+ msec: 4016
+ hash: "5369125b23e2f954c18f2fd4e0ba6f6a"
+ }
+ Frame {
+ msec: 4032
+ hash: "a76f624be0db97ec4450b10f748065df"
+ }
+ Frame {
+ msec: 4048
+ hash: "3fb70a7591b6decfa44f7cad18f73855"
+ }
+ Frame {
+ msec: 4064
+ hash: "dada267799b6e57acfcc5de3b8822c7c"
+ }
+ Frame {
+ msec: 4080
+ hash: "72c0bf8225504e86ff023242b84513a8"
+ }
+ Frame {
+ msec: 4096
+ hash: "1e8b095c39bd359637b1b9c975ee514c"
+ }
+ Frame {
+ msec: 4112
+ hash: "19862dcb88fcbbb2c4ecdc42821c7fef"
+ }
+ Frame {
+ msec: 4128
+ hash: "60c95993a894e1c6e2d476db365b7746"
+ }
+ Frame {
+ msec: 4144
+ hash: "854defd35cf3315e4501583756814ff6"
+ }
+ Frame {
+ msec: 4160
+ hash: "15e8959bfa4d206b2f0607322b21cba6"
+ }
+ Frame {
+ msec: 4176
+ hash: "ebd37ee719ca460480521fd4ec284a3f"
+ }
+ Frame {
+ msec: 4192
+ hash: "6d278926822d044fff04c3f182dcb058"
+ }
+ Frame {
+ msec: 4208
+ hash: "9aecb0c464fb140725f34ad94ede367a"
+ }
+ Frame {
+ msec: 4224
+ hash: "b36f70f138e6deecf5b105bcd89d1a15"
+ }
+ Frame {
+ msec: 4240
+ hash: "08c404f4efd27695071ad52fbfa57c0b"
+ }
+ Frame {
+ msec: 4256
+ hash: "6469d0bee7ab280639b565ebf174f251"
+ }
+ Frame {
+ msec: 4272
+ hash: "be5e44f6b9978ba3b9ae878ae5758a96"
+ }
+ Frame {
+ msec: 4288
+ hash: "5214e578bc78b729ddf35c140093c0da"
+ }
+ Frame {
+ msec: 4304
+ hash: "dd25ffb9a6bf009139b2942f9cc1f8e7"
+ }
+ Frame {
+ msec: 4320
+ hash: "2ddf31aeac4815be56848703a9b5aa14"
+ }
+ Frame {
+ msec: 4336
+ hash: "86922e71c80976ef3aa2cab18f86c010"
+ }
+ Frame {
+ msec: 4352
+ hash: "d8415ba4fb19b62b838ef2e09ae7607a"
+ }
+ Frame {
+ msec: 4368
+ hash: "0fdfb5f9463def560da6c19acf96bafb"
+ }
+ Frame {
+ msec: 4384
+ hash: "68fac60713af7cb130e92fa381be411c"
+ }
+ Frame {
+ msec: 4400
+ hash: "df3fd60ecbd517879e00e8112c49bed4"
+ }
+ Frame {
+ msec: 4416
+ hash: "64e49282d97ba864d2f6be632ae048e4"
+ }
+ Frame {
+ msec: 4432
+ hash: "346e7f597cfb4fc51d5393e705deddd5"
+ }
+ Frame {
+ msec: 4448
+ hash: "f302a9ce45187ff1001c967a4c753b2b"
+ }
+ Frame {
+ msec: 4464
+ hash: "def9383a090e4454343725f1a7c4fb3d"
+ }
+ Frame {
+ msec: 4480
+ hash: "fd177a7ae3b5b9205fd38e955be327e0"
+ }
+ Frame {
+ msec: 4496
+ hash: "1eea7eb2853a9e7a1a69738667457b7a"
+ }
+ Frame {
+ msec: 4512
+ hash: "32b16dd62ccf06e44be38fd5885f297e"
+ }
+ Frame {
+ msec: 4528
+ hash: "2a6b8aecef26793e200993dc1e25fd95"
+ }
+ Frame {
+ msec: 4544
+ hash: "8637606843905d6ae3f95fcb745f2a6e"
+ }
+ Frame {
+ msec: 4560
+ hash: "1a7a81f851c8817cac3cc0cb7ac07971"
+ }
+ Frame {
+ msec: 4576
+ hash: "704ca30ddc0a637f3d1cd4926a6f7983"
+ }
+ Frame {
+ msec: 4592
+ hash: "d1c02f3ce4bcc96e0c3d2503a0e9aa48"
+ }
+ Frame {
+ msec: 4608
+ hash: "7759418b4fe412857ab8e7294f5a3206"
+ }
+ Frame {
+ msec: 4624
+ hash: "3e6a6f505aa146a6789434d265ad4d3b"
+ }
+ Frame {
+ msec: 4640
+ hash: "3e6089b47573cd53b0a220275202c80b"
+ }
+ Frame {
+ msec: 4656
+ hash: "53bd2c46e3a11db0ee151a6a0311b3a8"
+ }
+ Frame {
+ msec: 4672
+ hash: "f30202ae354a587c5949a16c1f8b95c3"
+ }
+ Frame {
+ msec: 4688
+ hash: "66f78a34fe9d297af1ae8e98f84ead55"
+ }
+ Frame {
+ msec: 4704
+ hash: "3e2fc29876812fe57ea008a71db299a4"
+ }
+ Frame {
+ msec: 4720
+ hash: "7234b6df2220e418ef8ebe8f1c82bf26"
+ }
+ Frame {
+ msec: 4736
+ hash: "82dd491c3b34e702a24ece8e55761a6f"
+ }
+ Frame {
+ msec: 4752
+ hash: "d7f1065f5c42088dfc5ce36687fd8010"
+ }
+ Frame {
+ msec: 4768
+ hash: "15bfbb0261b66ccbe3b34d0ac807165c"
+ }
+ Frame {
+ msec: 4784
+ hash: "69963ce07eb434d787588b21fd020fa3"
+ }
+ Frame {
+ msec: 4800
+ image: "loop.4.png"
+ }
+ Frame {
+ msec: 4816
+ hash: "31fa31ed47ea16390be8ea9d41f483e7"
+ }
+ Frame {
+ msec: 4832
+ hash: "0f9ed8cd5cfbdab03bcb05cf6dd92620"
+ }
+ Frame {
+ msec: 4848
+ hash: "a0e737132ae642c465e991e770ab3e34"
+ }
+ Frame {
+ msec: 4864
+ hash: "d57cc5045f01ab4e7eb72575aef22a10"
+ }
+ Frame {
+ msec: 4880
+ hash: "d57e1a10e48938e1f7fc219220fe1204"
+ }
+ Frame {
+ msec: 4896
+ hash: "df41be1fa564353ceb2088af209610d3"
+ }
+ Frame {
+ msec: 4912
+ hash: "2d294613ed10dfdbca829b43b6990574"
+ }
+ Frame {
+ msec: 4928
+ hash: "0a278a4ec3626442c94ef2da30771171"
+ }
+ Frame {
+ msec: 4944
+ hash: "7071526c830fdfde9d520ad1578d27a8"
+ }
+ Frame {
+ msec: 4960
+ hash: "ad02e7b90f223d3fc5a433bc4ffbee9e"
+ }
+ Frame {
+ msec: 4976
+ hash: "e7ef412697c7df3887980ed1b079ffd5"
+ }
+ Frame {
+ msec: 4992
+ hash: "ebda21f95079b37f4862b42523bbc1c0"
+ }
+ Frame {
+ msec: 5008
+ hash: "6e8889e9b44ff8ed44e228d97fb5034c"
+ }
+ Frame {
+ msec: 5024
+ hash: "f32aceabb929471dffd73bf0290e75a2"
+ }
+ Frame {
+ msec: 5040
+ hash: "9112838cc8f9a0cfb94e0ef6ca7eca71"
+ }
+ Frame {
+ msec: 5056
+ hash: "53bd2c46e3a11db0ee151a6a0311b3a8"
+ }
+ Frame {
+ msec: 5072
+ hash: "d5105f958a592324e53aae4a83beb049"
+ }
+ Frame {
+ msec: 5088
+ hash: "862249432e6fc6114b63284ad9c97cb6"
+ }
+ Frame {
+ msec: 5104
+ hash: "3e6a6f505aa146a6789434d265ad4d3b"
+ }
+ Frame {
+ msec: 5120
+ hash: "0f5b2b05f72b86bd2b0a6d0ea2b6bf37"
+ }
+ Frame {
+ msec: 5136
+ hash: "922520f7ec954d6d1061208cbd63877e"
+ }
+ Frame {
+ msec: 5152
+ hash: "d1c02f3ce4bcc96e0c3d2503a0e9aa48"
+ }
+ Frame {
+ msec: 5168
+ hash: "ebb41112b687ecb062dedc3b49cb93fc"
+ }
+ Frame {
+ msec: 5184
+ hash: "7bc87d71d532aa52abc26ac9c1cbb665"
+ }
+ Frame {
+ msec: 5200
+ hash: "1a7a81f851c8817cac3cc0cb7ac07971"
+ }
+ Frame {
+ msec: 5216
+ hash: "ca17c870c55f2947bb5f85d28f30ee7c"
+ }
+ Frame {
+ msec: 5232
+ hash: "48b123cfd6d2ea1c2bc9f2ba822ec7bf"
+ }
+ Frame {
+ msec: 5248
+ hash: "2a6b8aecef26793e200993dc1e25fd95"
+ }
+ Frame {
+ msec: 5264
+ hash: "f10a0a11ed54a910fe434311f67343a4"
+ }
+ Frame {
+ msec: 5280
+ hash: "47b6e1beabdcd3cd3d21d77c62e5bed8"
+ }
+ Frame {
+ msec: 5296
+ hash: "1eea7eb2853a9e7a1a69738667457b7a"
+ }
+ Frame {
+ msec: 5312
+ hash: "9e018f9e7a5ba22bbb9be3049373124a"
+ }
+ Frame {
+ msec: 5328
+ hash: "d63069a8e7b0eb5611cc34caaecef2fb"
+ }
+ Frame {
+ msec: 5344
+ hash: "def9383a090e4454343725f1a7c4fb3d"
+ }
+ Frame {
+ msec: 5360
+ hash: "fd3036e559fd31eeadb0032666a95864"
+ }
+ Frame {
+ msec: 5376
+ hash: "cf9f82b9e2a03f63f75b6ac113b3d4e5"
+ }
+ Frame {
+ msec: 5392
+ hash: "346e7f597cfb4fc51d5393e705deddd5"
+ }
+ Frame {
+ msec: 5408
+ hash: "0d6d6cb2ca808f5a57acfa32e10fc335"
+ }
+ Frame {
+ msec: 5424
+ hash: "9a660a0fed41211a37d3ac82be40f81a"
+ }
+ Frame {
+ msec: 5440
+ hash: "df3fd60ecbd517879e00e8112c49bed4"
+ }
+ Frame {
+ msec: 5456
+ hash: "cd86fe5894e5d061f7ffe37913f00ce6"
+ }
+ Frame {
+ msec: 5472
+ hash: "a5fdb825c18d43f3ae18f5c28e715174"
+ }
+ Frame {
+ msec: 5488
+ hash: "0fdfb5f9463def560da6c19acf96bafb"
+ }
+ Frame {
+ msec: 5504
+ hash: "8849a36af064503dbccad69a35b6ab03"
+ }
+ Frame {
+ msec: 5520
+ hash: "baeb4f90b0e2efc09225dbb5dd003e9e"
+ }
+ Frame {
+ msec: 5536
+ hash: "86922e71c80976ef3aa2cab18f86c010"
+ }
+ Frame {
+ msec: 5552
+ hash: "10d166d7da9949370a66251415522186"
+ }
+ Frame {
+ msec: 5568
+ hash: "ada1608055b221dc9f1f7650a9764930"
+ }
+ Frame {
+ msec: 5584
+ hash: "dd25ffb9a6bf009139b2942f9cc1f8e7"
+ }
+ Frame {
+ msec: 5600
+ hash: "dc4a1c44d08328965b53ff079a8fa57b"
+ }
+ Frame {
+ msec: 5616
+ hash: "d3d88cf635ba38e5035732cb36014417"
+ }
+ Frame {
+ msec: 5632
+ hash: "be5e44f6b9978ba3b9ae878ae5758a96"
+ }
+ Frame {
+ msec: 5648
+ hash: "34f193daf199ab45310be2b407499e57"
+ }
+ Frame {
+ msec: 5664
+ hash: "d87c854e1c16642dba0d87e25f0e416f"
+ }
+ Frame {
+ msec: 5680
+ hash: "08c404f4efd27695071ad52fbfa57c0b"
+ }
+ Frame {
+ msec: 5696
+ hash: "84828f8e0cace1a39d9b7f19b6e4cbaa"
+ }
+ Frame {
+ msec: 5712
+ hash: "8a0c6e1f597e699c3e2be816ae4e1dd4"
+ }
+ Frame {
+ msec: 5728
+ hash: "9aecb0c464fb140725f34ad94ede367a"
+ }
+ Frame {
+ msec: 5744
+ hash: "a298b3ab2939819ced7e7f903ec63be4"
+ }
+ Frame {
+ msec: 5760
+ image: "loop.5.png"
+ }
+ Frame {
+ msec: 5776
+ hash: "ebd37ee719ca460480521fd4ec284a3f"
+ }
+ Frame {
+ msec: 5792
+ hash: "9c9b3fb5b623d3deaf9920c99279d71b"
+ }
+ Frame {
+ msec: 5808
+ hash: "8f0be6d4d6fd7f66a43fd604e17717dd"
+ }
+ Frame {
+ msec: 5824
+ hash: "854defd35cf3315e4501583756814ff6"
+ }
+ Frame {
+ msec: 5840
+ hash: "fd7157aef6dfb303472cd33b176f91d8"
+ }
+ Frame {
+ msec: 5856
+ hash: "e6521a3c74c190c193af2c913e5326e2"
+ }
+}
diff --git a/tests/auto/declarative/visual/animation/loop/loop.qml b/tests/auto/declarative/visual/animation/loop/loop.qml
new file mode 100644
index 0000000..f6049ae
--- /dev/null
+++ b/tests/auto/declarative/visual/animation/loop/loop.qml
@@ -0,0 +1,24 @@
+import Qt 4.6
+
+Rectangle {
+ id: wrapper
+ width: 600
+ height: 100
+
+ Rectangle {
+ id: redRect
+ width: 100; height: 100
+ color: Qt.rgba(1,0,0)
+ /* This should produce an animation that starts at 0, animates smoothly
+ to 100, jumps to 200, animates smoothly to 400, animates smoothly
+ back to 100, jumps to 200, and so on.
+ */
+ x: SequentialAnimation {
+ repeat: true
+ NumberAnimation { to: 100; duration: 1000 }
+ NumberAnimation { from: 200; to: 400; duration: 1000 }
+ }
+
+ }
+
+}
diff --git a/tests/auto/declarative/visual/animation/parallelAnimation/parallelAnimation.qml b/tests/auto/declarative/visual/animation/parallelAnimation/parallelAnimation.qml
index 9e0422f..7021e05 100644
--- a/tests/auto/declarative/visual/animation/parallelAnimation/parallelAnimation.qml
+++ b/tests/auto/declarative/visual/animation/parallelAnimation/parallelAnimation.qml
@@ -34,10 +34,10 @@ Rectangle {
}
transitions: Transition {
- PropertyAnimation { matchTargets: redRect; matchProperties: "x,color"; duration: 300 }
+ PropertyAnimation { targets: redRect; properties: "x,color"; duration: 300 }
ParallelAnimation {
- NumberAnimation { matchTargets: redRect2; matchProperties: "x"; duration: 300 }
- ColorAnimation { matchTargets: redRect2; matchProperties: "color"; duration: 300 }
+ NumberAnimation { targets: redRect2; properties: "x"; duration: 300 }
+ ColorAnimation { targets: redRect2; properties: "color"; duration: 300 }
}
}
}
diff --git a/tests/auto/declarative/visual/animation/parentAction/parentAction.qml b/tests/auto/declarative/visual/animation/parentAction/parentAction.qml
index 1e3f402..e4f4406 100644
--- a/tests/auto/declarative/visual/animation/parentAction/parentAction.qml
+++ b/tests/auto/declarative/visual/animation/parentAction/parentAction.qml
@@ -49,7 +49,7 @@ Rectangle {
SequentialAnimation {
ColorAnimation { duration: 500}
ParentAction {}
- NumberAnimation { matchProperties: "rotation, scale"; duration: 1000 }
+ NumberAnimation { properties: "rotation, scale"; duration: 1000 }
}
}
}
diff --git a/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml b/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml
index b670166..68671e1 100644
--- a/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml
+++ b/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml
@@ -27,8 +27,8 @@ Rectangle {
reversible: true
SequentialAnimation {
ColorAnimation {}
- PropertyAction { matchProperties: "x" }
- NumberAnimation { matchProperties: "y"; easing: "InOutQuad" }
+ PropertyAction { properties: "x" }
+ NumberAnimation { properties: "y"; easing: "InOutQuad" }
}
}
}
diff --git a/tests/auto/declarative/visual/animation/reanchor/reanchor.qml b/tests/auto/declarative/visual/animation/reanchor/reanchor.qml
index 1cc68a9..359346f 100644
--- a/tests/auto/declarative/visual/animation/reanchor/reanchor.qml
+++ b/tests/auto/declarative/visual/animation/reanchor/reanchor.qml
@@ -52,7 +52,7 @@ Rectangle {
}]
transitions: Transition {
- NumberAnimation { matchProperties: "x,y,width,height" }
+ NumberAnimation { properties: "x,y,width,height" }
}
MouseRegion {
diff --git a/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml b/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml
index 872701b..f121906 100644
--- a/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml
+++ b/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml
@@ -27,9 +27,9 @@ Rectangle {
transitions: Transition {
SequentialAnimation {
- NumberAnimation { matchProperties: "x"; easing: "InOutQuad" }
+ NumberAnimation { properties: "x"; easing: "InOutQuad" }
ScriptAction { stateChangeScriptName: "setColor" }
- NumberAnimation { matchProperties: "y"; easing: "InOutQuad" }
+ NumberAnimation { properties: "y"; easing: "InOutQuad" }
}
}
}
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.qml b/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.qml
index c376e39..db70298 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.qml
+++ b/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.qml
@@ -7034,4 +7034,4 @@ VisualTest {
}
Frame {
msec: 23264
- hash: "8443c45791c906a9fe23831844f48a1c \ No newline at end of file
+ hash: "8443c45791c906a9fe23831844f48a1c
diff --git a/tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml b/tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml
index 64adb61..c33a319 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml
+++ b/tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml
@@ -36,7 +36,7 @@ Rectangle {
}
transitions: Transition {
- NumberAnimation { easing: "easeInOutQuad"; matchProperties: "angle"; duration: 3000 }
+ NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 3000 }
}
}
@@ -64,7 +64,7 @@ Rectangle {
}
transitions: Transition {
- NumberAnimation { easing: "easeInOutQuad"; matchProperties: "angle"; duration: 3000 }
+ NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 3000 }
}
}
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/dynamic.qml b/tests/auto/declarative/visual/qmlgraphicspositioners/dynamic.qml
index 4b03749..f45e9a4 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/dynamic.qml
+++ b/tests/auto/declarative/visual/qmlgraphicspositioners/dynamic.qml
@@ -37,7 +37,7 @@ Item {
Row{
y:20
id: row2
- move: Transition{NumberAnimation{matchProperties:"x"}}
+ move: Transition{NumberAnimation{properties:"x"}}
Repeater{
id: repeater
model: 0;
@@ -48,7 +48,7 @@ Item {
Rectangle{id: r2c; width:20; height:20; color: "blue"}
}
Row{
- move: Transition{NumberAnimation{matchProperties:"x"}}
+ move: Transition{NumberAnimation{properties:"x"}}
y:40
id: row3
Rectangle{id: r3a; width:20; height:20; color: "red"}
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml b/tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml
index 2faefc1..e0c5db4 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml
+++ b/tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml
@@ -11,8 +11,8 @@ import Qt 4.6
Rectangle { id:bottom; color: "black"; width: 3; height: 1; x: -1; anchors.bottom: parent.bottom;}
opacity: 1
opacity: SequentialAnimation { running: cPage.parent.focus == true; repeat: true;
- NumberAnimation { matchProperties: "opacity"; to: 1; duration: 500; easing: "easeInQuad"}
- NumberAnimation { matchProperties: "opacity"; to: 0; duration: 500; easing: "easeOutQuad"}
+ NumberAnimation { properties: "opacity"; to: 1; duration: 500; easing: "easeInQuad"}
+ NumberAnimation { properties: "opacity"; to: 0; duration: 500; easing: "easeOutQuad"}
}
}
width: 1;
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml b/tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml
index d10755c..0038664 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml
+++ b/tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml
@@ -11,8 +11,8 @@ import Qt 4.6
Rectangle { id:bottom; color: "black"; width: 3; height: 1; x: -1; anchors.bottom: parent.bottom;}
opacity: 1
opacity: SequentialAnimation { running: cPage.parent.focus == true; repeat: true;
- NumberAnimation { matchProperties: "opacity"; to: 1; duration: 500; easing: "easeInQuad"}
- NumberAnimation { matchProperties: "opacity"; to: 0; duration: 500; easing: "easeOutQuad"}
+ NumberAnimation { properties: "opacity"; to: 1; duration: 500; easing: "easeInQuad"}
+ NumberAnimation { properties: "opacity"; to: 0; duration: 500; easing: "easeOutQuad"}
}
}
width: 1;
diff --git a/tests/auto/qgl_threads/qgl_threads.pro b/tests/auto/qgl_threads/qgl_threads.pro
new file mode 100644
index 0000000..9312c05
--- /dev/null
+++ b/tests/auto/qgl_threads/qgl_threads.pro
@@ -0,0 +1,11 @@
+############################################################
+# Project file for autotest for file qgl.h
+############################################################
+
+load(qttest_p4)
+requires(contains(QT_CONFIG,opengl))
+QT += opengl
+
+HEADERS += tst_openglthreading.h
+SOURCES += tst_openglthreading.cpp
+
diff --git a/tests/auto/qgl_threads/tst_openglthreading.cpp b/tests/auto/qgl_threads/tst_openglthreading.cpp
new file mode 100644
index 0000000..cf100cb
--- /dev/null
+++ b/tests/auto/qgl_threads/tst_openglthreading.cpp
@@ -0,0 +1,480 @@
+/****************************************************************************
+**
+** 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/QtCore>
+#include <QtGui/QtGui>
+#include <QtOpenGL/QtOpenGL>
+#include "tst_openglthreading.h"
+
+#ifdef Q_WS_X11
+#include <private/qt_x11_p.h>
+#endif
+
+#define RUNNING_TIME 5000
+
+tst_OpenGLThreading::tst_OpenGLThreading(QObject *parent)
+ : QObject(parent)
+{
+}
+
+
+
+/*
+
+ swapInThread
+
+ The purpose of this testcase is to verify that it is possible to do rendering into
+ a GL context from the GUI thread, then swap the contents in from a background thread.
+
+ The usecase for this is to have the background thread do the waiting for vertical
+ sync while the GUI thread is idle.
+
+ Currently the locking is handled directly in the paintEvent(). For the actual usecase
+ in Qt, the locking is done in the windowsurface before starting any drawing while
+ unlocking is done after all drawing has been done.
+ */
+
+
+class SwapThread : public QThread
+{
+ Q_OBJECT
+public:
+ SwapThread(QGLWidget *widget)
+ : m_widget(widget)
+ {
+ moveToThread(this);
+ }
+
+ void run() {
+ QTime time;
+ time.start();
+ while (time.elapsed() < RUNNING_TIME) {
+ lock();
+ wait();
+
+ m_widget->makeCurrent();
+ m_widget->swapBuffers();
+ m_widget->doneCurrent();
+ unlock();
+ }
+ }
+
+ void lock() { m_mutex.lock(); }
+ void unlock() { m_mutex.unlock(); }
+
+ void wait() { m_wait_condition.wait(&m_mutex); }
+ void notify() { m_wait_condition.wakeAll(); }
+
+private:
+ QGLWidget *m_widget;
+ QMutex m_mutex;
+ QWaitCondition m_wait_condition;
+};
+
+class ForegroundWidget : public QGLWidget
+{
+public:
+ ForegroundWidget(const QGLFormat &format)
+ : QGLWidget(format), m_thread(0)
+ {
+ setAutoBufferSwap(false);
+ }
+
+ void paintEvent(QPaintEvent *)
+ {
+ m_thread->lock();
+ makeCurrent();
+ QPainter p(this);
+ p.fillRect(rect(), QColor(rand() % 256, rand() % 256, rand() % 256));
+ p.setPen(Qt::red);
+ p.setFont(QFont("SansSerif", 24));
+ p.drawText(rect(), Qt::AlignCenter, "This is an autotest");
+ p.end();
+ doneCurrent();
+ m_thread->notify();
+ m_thread->unlock();
+
+ update();
+ }
+
+ void setThread(SwapThread *thread) {
+ m_thread = thread;
+ }
+
+ SwapThread *m_thread;
+};
+
+void tst_OpenGLThreading::swapInThread()
+{
+#ifdef Q_OS_MAC
+ QSKIP("OpenGL threading tests are currently disabled on mac as they were causing reboots", SkipAll);
+#endif
+
+ QGLFormat format;
+ format.setSwapInterval(1);
+ ForegroundWidget widget(format);
+ SwapThread thread(&widget);
+ widget.setThread(&thread);
+ widget.show();
+
+ QTest::qWaitForWindowShown(&widget);
+ thread.start();
+
+ while (thread.isRunning()) {
+ qApp->processEvents();
+ }
+
+ widget.hide();
+
+ QVERIFY(true);
+}
+
+
+
+
+
+
+
+/*
+ textureUploadInThread
+
+ The purpose of this testcase is to verify that doing texture uploads in a background
+ thread is possible and that it works.
+ */
+
+class CreateAndUploadThread : public QThread
+{
+ Q_OBJECT
+public:
+ CreateAndUploadThread(QGLWidget *shareWidget)
+ {
+ m_gl = new QGLWidget(0, shareWidget);
+ moveToThread(this);
+ }
+
+ ~CreateAndUploadThread()
+ {
+ delete m_gl;
+ }
+
+ void run() {
+ m_gl->makeCurrent();
+ QTime time;
+ time.start();
+ while (time.elapsed() < RUNNING_TIME) {
+ QImage image(400, 300, QImage::Format_RGB32);
+ QPainter p(&image);
+ p.fillRect(image.rect(), QColor(rand() % 256, rand() % 256, rand() % 256));
+ p.setPen(Qt::red);
+ p.setFont(QFont("SansSerif", 24));
+ p.drawText(image.rect(), Qt::AlignCenter, "This is an autotest");
+ p.end();
+ m_gl->bindTexture(image, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption);
+ createdAndUploaded(image);
+ }
+ }
+
+signals:
+ void createdAndUploaded(const QImage &image);
+
+private:
+ QGLWidget *m_gl;
+};
+
+class TextureDisplay : public QGLWidget
+{
+ Q_OBJECT
+public:
+ void paintEvent(QPaintEvent *) {
+ QPainter p(this);
+ for (int i=0; i<m_images.size(); ++i) {
+ p.drawImage(m_positions.at(i), m_images.at(i));
+ m_positions[i] += QPoint(1, 1);
+ }
+ update();
+ }
+
+public slots:
+ void receiveImage(const QImage &image) {
+ m_images << image;
+ m_positions << QPoint(-rand() % width() / 2, -rand() % height() / 2);
+
+ if (m_images.size() > 100) {
+ m_images.takeFirst();
+ m_positions.takeFirst();
+ }
+ }
+
+private:
+ QList <QImage> m_images;
+ QList <QPoint> m_positions;
+};
+
+void tst_OpenGLThreading::textureUploadInThread()
+{
+#ifdef Q_OS_MAC
+ QSKIP("OpenGL threading tests are currently disabled on mac as they were causing reboots", SkipAll);
+#endif
+
+ TextureDisplay display;
+ CreateAndUploadThread thread(&display);
+
+ connect(&thread, SIGNAL(createdAndUploaded(QImage)), &display, SLOT(receiveImage(QImage)));
+
+ display.show();
+ QTest::qWaitForWindowShown(&display);
+
+ thread.start();
+
+ while (thread.isRunning()) {
+ qApp->processEvents();
+ }
+
+ QVERIFY(true);
+}
+
+
+
+
+
+
+/*
+ renderInThread
+
+ This test sets up a scene and renders it in a different thread.
+ For simplicity, the scene is simply a bunch of rectangles, but
+ if that works, we're in good shape..
+ */
+
+static inline float qrandom() { return (rand() % 100) / 100.f; }
+
+void renderAScene(int w, int h)
+{
+#ifdef QT_OPENGL_ES_2
+ QGLShaderProgram program;
+ program.addShaderFromSourceCode(QGLShader::Vertex, "attribute highp vec2 pos; void main() { gl_Position = vec4(pos.xy, 1.0, 1.0); }");
+ program.addShaderFromSourceCode(QGLShader::Fragment, "uniform lowp vec4 color; void main() { gl_FragColor = color; }");
+ program.bindAttributeLocation("pos", 0);
+ program.bind();
+ int colorId = program.uniformLocation("color");
+
+ glEnableVertexAttribArray(0);
+
+ for (int i=0; i<1000; ++i) {
+ GLfloat pos[] = {
+ (rand() % 100) / 100.,
+ (rand() % 100) / 100.,
+ (rand() % 100) / 100.,
+ (rand() % 100) / 100.,
+ (rand() % 100) / 100.,
+ (rand() % 100) / 100.
+ };
+
+ glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, pos);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
+ }
+#else
+ glViewport(0, 0, w, h);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum(0, w, h, 0, 1, 100);
+ glTranslated(0, 0, -1);
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+
+ for (int i=0;i<1000; ++i) {
+ glBegin(GL_TRIANGLES);
+ glColor3f(qrandom(), qrandom(), qrandom());
+ glVertex2f(qrandom() * w, qrandom() * h);
+ glColor3f(qrandom(), qrandom(), qrandom());
+ glVertex2f(qrandom() * w, qrandom() * h);
+ glColor3f(qrandom(), qrandom(), qrandom());
+ glVertex2f(qrandom() * w, qrandom() * h);
+ glEnd();
+ }
+#endif
+}
+
+class ThreadSafeGLWidget : public QGLWidget
+{
+public:
+ void paintEvent(QPaintEvent *)
+ {
+ // ignored as we're anyway swapping as fast as we can
+ };
+
+ void resizeEvent(QResizeEvent *e)
+ {
+ mutex.lock();
+ newSize = e->size();
+ mutex.unlock();
+ };
+
+ QMutex mutex;
+ QSize newSize;
+};
+
+class SceneRenderingThread : public QThread
+{
+ Q_OBJECT
+public:
+ SceneRenderingThread(ThreadSafeGLWidget *widget)
+ : m_widget(widget)
+ {
+ moveToThread(this);
+ m_size = widget->size();
+ }
+
+ void run() {
+ QTime time;
+ time.start();
+ failure = false;
+
+ m_widget->makeCurrent();
+
+ while (time.elapsed() < RUNNING_TIME && !failure) {
+
+
+ m_widget->mutex.lock();
+ QSize s = m_widget->newSize;
+ m_widget->mutex.unlock();
+
+ if (s != m_size) {
+ glViewport(0, 0, s.width(), s.height());
+ }
+
+ if (QGLContext::currentContext() != m_widget->context()) {
+ failure = true;
+ break;
+ }
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ int w = m_widget->width();
+ int h = m_widget->height();
+
+ renderAScene(w, h);
+
+ int color;
+ glReadPixels(w / 2, h / 2, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &color);
+
+ m_widget->swapBuffers();
+ }
+
+ m_widget->doneCurrent();
+ }
+
+ bool failure;
+
+private:
+ ThreadSafeGLWidget *m_widget;
+ QSize m_size;
+};
+
+void tst_OpenGLThreading::renderInThread_data()
+{
+ QTest::addColumn<bool>("resize");
+ QTest::addColumn<bool>("update");
+
+ QTest::newRow("basic") << false << false;
+ QTest::newRow("with-resize") << true << false;
+ QTest::newRow("with-update") << false << true;
+ QTest::newRow("with-resize-and-update") << true << true;
+}
+
+void tst_OpenGLThreading::renderInThread()
+{
+#ifdef Q_OS_MAC
+ QSKIP("OpenGL threading tests are currently disabled on mac as they were causing reboots", SkipAll);
+#endif
+
+ QFETCH(bool, resize);
+ QFETCH(bool, update);
+
+ ThreadSafeGLWidget widget;
+ widget.resize(200, 200);
+ SceneRenderingThread thread(&widget);
+
+ widget.show();
+ QTest::qWaitForWindowShown(&widget);
+ widget.doneCurrent();
+
+ thread.start();
+
+ int value = 10;
+ while (thread.isRunning()) {
+ if (resize)
+ widget.resize(200 + value, 200 + value);
+ if (update)
+ widget.update(100 + value, 100 + value, 20, 20);
+ qApp->processEvents();
+ value = -value;
+
+#ifdef Q_WS_WIN
+ Sleep(100);
+#else
+ usleep(100 * 1000);
+#endif
+ }
+
+ QVERIFY(!thread.failure);
+}
+
+
+
+
+int main(int argc, char **argv)
+{
+#ifdef Q_WS_X11
+ XInitThreads();
+#endif
+
+ QApplication app(argc, argv);
+ QTEST_DISABLE_KEYPAD_NAVIGATION \
+
+ tst_OpenGLThreading tc;
+ return QTest::qExec(&tc, argc, argv);
+}
+
+#include "tst_openglthreading.moc"
diff --git a/tests/auto/qgl_threads/tst_openglthreading.h b/tests/auto/qgl_threads/tst_openglthreading.h
new file mode 100644
index 0000000..c4b55cd
--- /dev/null
+++ b/tests/auto/qgl_threads/tst_openglthreading.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#ifndef TST_OPENGLTHREADING_H
+#define TST_OPENGLTHREADING_H
+
+#include <QObject>
+
+class tst_OpenGLThreading : public QObject
+{
+Q_OBJECT
+public:
+ explicit tst_OpenGLThreading(QObject *parent = 0);
+
+private slots:
+ void swapInThread();
+ void textureUploadInThread();
+
+ void renderInThread_data();
+ void renderInThread();
+};
+
+#endif // TST_OPENGLTHREADING_H
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 7c1b97e..269ec24 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -438,6 +438,7 @@ private slots:
void QTBUG_6738_missingUpdateWithSetParent();
void QTBUG_7714_fullUpdateDiscardingOpacityUpdate2();
void QT_2653_fullUpdateDiscardingOpacityUpdate();
+ void QT_2649_focusScope();
private:
QList<QGraphicsItem *> paintedItems;
@@ -10002,5 +10003,61 @@ void tst_QGraphicsItem::QTBUG_7714_fullUpdateDiscardingOpacityUpdate2()
QTRY_COMPARE(view.repaints, 1);
}
+void tst_QGraphicsItem::QT_2649_focusScope()
+{
+ QGraphicsScene *scene = new QGraphicsScene;
+
+ QGraphicsRectItem *subFocusItem = new QGraphicsRectItem;
+ subFocusItem->setFlags(QGraphicsItem::ItemIsFocusable);
+ subFocusItem->setFocus();
+ QCOMPARE(subFocusItem->focusItem(), (QGraphicsItem *)subFocusItem);
+
+ QGraphicsRectItem *scope = new QGraphicsRectItem;
+ scope->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIsFocusScope);
+ scope->setFocus();
+ subFocusItem->setParentItem(scope);
+ QCOMPARE(subFocusItem->focusItem(), (QGraphicsItem *)subFocusItem);
+ QCOMPARE(subFocusItem->focusScopeItem(), (QGraphicsItem *)0);
+ QCOMPARE(scope->focusItem(), (QGraphicsItem *)subFocusItem);
+ QCOMPARE(scope->focusScopeItem(), (QGraphicsItem *)subFocusItem);
+
+ QGraphicsRectItem *rootItem = new QGraphicsRectItem;
+ rootItem->setFlags(QGraphicsItem::ItemIsFocusable);
+ scope->setParentItem(rootItem);
+ QCOMPARE(rootItem->focusItem(), (QGraphicsItem *)subFocusItem);
+ QCOMPARE(rootItem->focusScopeItem(), (QGraphicsItem *)0);
+ QCOMPARE(subFocusItem->focusItem(), (QGraphicsItem *)subFocusItem);
+ QCOMPARE(subFocusItem->focusScopeItem(), (QGraphicsItem *)0);
+ QCOMPARE(scope->focusItem(), (QGraphicsItem *)subFocusItem);
+ QCOMPARE(scope->focusScopeItem(), (QGraphicsItem *)subFocusItem);
+
+ scene->addItem(rootItem);
+
+ QEvent windowActivate(QEvent::WindowActivate);
+ qApp->sendEvent(scene, &windowActivate);
+ scene->setFocus();
+
+ QCOMPARE(rootItem->focusItem(), (QGraphicsItem *)subFocusItem);
+ QCOMPARE(scope->focusItem(), (QGraphicsItem *)subFocusItem);
+ QCOMPARE(subFocusItem->focusItem(), (QGraphicsItem *)subFocusItem);
+ QCOMPARE(rootItem->focusScopeItem(), (QGraphicsItem *)0);
+ QCOMPARE(scope->focusScopeItem(), (QGraphicsItem *)subFocusItem);
+ QCOMPARE(subFocusItem->focusScopeItem(), (QGraphicsItem *)0);
+ QVERIFY(subFocusItem->hasFocus());
+
+ //If we hide the focusScope, the entire subFocus chain should be cleared
+ scope->hide();
+
+ QCOMPARE(rootItem->focusItem(), (QGraphicsItem *)0);
+ QCOMPARE(scope->focusItem(), (QGraphicsItem *)0);
+ QCOMPARE(subFocusItem->focusItem(), (QGraphicsItem *)0);
+ QCOMPARE(rootItem->focusScopeItem(), (QGraphicsItem *)0);
+ QCOMPARE(scope->focusScopeItem(), (QGraphicsItem *)subFocusItem);
+ QCOMPARE(subFocusItem->focusScopeItem(), (QGraphicsItem *)0);
+ QVERIFY(!subFocusItem->hasFocus());
+
+ delete scene;
+}
+
QTEST_MAIN(tst_QGraphicsItem)
#include "tst_qgraphicsitem.moc"
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index 469ded0..2ef0419 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -50,6 +50,7 @@
#include <private/qgraphicssceneindex_p.h>
#include <math.h>
#include "../../shared/util.h"
+#include "../qpathclipper/pathcompare.h"
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#include <windows.h>
@@ -3560,7 +3561,7 @@ void tst_QGraphicsScene::task250680_childClip()
QPainterPath path;
path.addRect(-25, -25, 50, 50);
- QCOMPARE(rect->clipPath(), path);
+ QVERIFY(QPathCompare::comparePaths(rect->clipPath().simplified(), path));
QCOMPARE(scene.items(QRectF(320, 240, 5, 5)).size(), 2);
rect->rotate(45);
diff --git a/tests/auto/qgraphicsvideoitem/qgraphicsvideoitem.pro b/tests/auto/qgraphicsvideoitem/qgraphicsvideoitem.pro
new file mode 100644
index 0000000..da00baf
--- /dev/null
+++ b/tests/auto/qgraphicsvideoitem/qgraphicsvideoitem.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+SOURCES += tst_qgraphicsvideoitem.cpp
+
+QT += multimedia
+requires(contains(QT_CONFIG, multimedia))
diff --git a/tests/auto/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp b/tests/auto/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp
new file mode 100644
index 0000000..7fb6005
--- /dev/null
+++ b/tests/auto/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp
@@ -0,0 +1,670 @@
+/****************************************************************************
+**
+** 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 <QtMultimedia/qgraphicsvideoitem.h>
+
+#include <QtGui/qapplication.h>
+#include <QtGui/qgraphicsscene.h>
+#include <QtGui/qgraphicsview.h>
+#include <QtMultimedia/qabstractvideosurface.h>
+#include <QtMultimedia/qmediaobject.h>
+#include <QtMultimedia/qmediaservice.h>
+#include <QtMultimedia/qvideooutputcontrol.h>
+#include <QtMultimedia/qvideorenderercontrol.h>
+#include <QtMultimedia/qvideosurfaceformat.h>
+
+#include <QtMultimedia/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/qlist/tst_qlist.cpp b/tests/auto/qlist/tst_qlist.cpp
index 59b2c7b..a590fca 100644
--- a/tests/auto/qlist/tst_qlist.cpp
+++ b/tests/auto/qlist/tst_qlist.cpp
@@ -60,6 +60,7 @@ private slots:
void length() const;
void lengthSignature() const;
void append() const;
+ void mid() const;
};
void tst_QList::length() const
@@ -129,5 +130,14 @@ void tst_QList::append() const
}
+void tst_QList::mid() const
+{
+ QList<QString> list;
+ list << "foo" << "bar" << "baz" << "bak" << "buck" << "hello" << "kitty";
+
+ QCOMPARE(list.mid(3, 3),
+ QList<QString>() << "bak" << "buck" << "hello");
+}
+
QTEST_APPLESS_MAIN(tst_QList)
#include "tst_qlist.moc"
diff --git a/tests/auto/qmediacontent/qmediacontent.pro b/tests/auto/qmediacontent/qmediacontent.pro
new file mode 100644
index 0000000..f7884f6
--- /dev/null
+++ b/tests/auto/qmediacontent/qmediacontent.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+
+SOURCES += tst_qmediacontent.cpp
+
+QT = core multimedia
+
diff --git a/tests/auto/qmediacontent/tst_qmediacontent.cpp b/tests/auto/qmediacontent/tst_qmediacontent.cpp
new file mode 100644
index 0000000..35dd0a9
--- /dev/null
+++ b/tests/auto/qmediacontent/tst_qmediacontent.cpp
@@ -0,0 +1,160 @@
+/****************************************************************************
+**
+** 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 <QtMultimedia/qmediacontent.h>
+
+
+class tst_QMediaContent : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testNull();
+ void testUrlCtor();
+ 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::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
new file mode 100644
index 0000000..e59bfdc
--- /dev/null
+++ b/tests/auto/qmediaobject/qmediaobject.pro
@@ -0,0 +1,4 @@
+load(qttest_p4)
+
+SOURCES += tst_qmediaobject.cpp
+QT = core multimedia
diff --git a/tests/auto/qmediaobject/tst_qmediaobject.cpp b/tests/auto/qmediaobject/tst_qmediaobject.cpp
new file mode 100644
index 0000000..2128b35
--- /dev/null
+++ b/tests/auto/qmediaobject/tst_qmediaobject.cpp
@@ -0,0 +1,549 @@
+/****************************************************************************
+**
+** 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 <QtMultimedia/qmediaobject.h>
+#include <QtMultimedia/qmediaservice.h>
+#include <QtMultimedia/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<QtMultimedia::MetaData> availableMetaData() const { return m_data.keys(); }
+
+ bool isWritable() const { return m_writable; }
+ void setWritable(bool writable) { emit writableChanged(m_writable = writable); }
+
+ QVariant metaData(QtMultimedia::MetaData key) const { return m_data.value(key); }
+ void setMetaData(QtMultimedia::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<QtMultimedia::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(QtMultimedia::Title, title);
+ object.setExtendedMetaData(titleKey, title);
+
+ QCOMPARE(object.metaData(QtMultimedia::Title).toString(), QString());
+ QCOMPARE(object.extendedMetaData(titleKey).toString(), QString());
+ QCOMPARE(object.availableMetaData(), QList<QtMultimedia::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(QtMultimedia::AlbumArtist, artist);
+ service.metaData.m_data.insert(QtMultimedia::Title, title);
+ service.metaData.m_data.insert(QtMultimedia::Genre, genre);
+
+ QCOMPARE(object.metaData(QtMultimedia::AlbumArtist).toString(), artist);
+ QCOMPARE(object.metaData(QtMultimedia::Title).toString(), title);
+
+ QList<QtMultimedia::MetaData> metaDataKeys = object.availableMetaData();
+ QCOMPARE(metaDataKeys.size(), 3);
+ QVERIFY(metaDataKeys.contains(QtMultimedia::AlbumArtist));
+ QVERIFY(metaDataKeys.contains(QtMultimedia::Title));
+ QVERIFY(metaDataKeys.contains(QtMultimedia::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(QtMultimedia::Title, title);
+ QCOMPARE(object.metaData(QtMultimedia::Title).toString(), title);
+ QCOMPARE(service.metaData.m_data.value(QtMultimedia::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
new file mode 100644
index 0000000..21008f9
--- /dev/null
+++ b/tests/auto/qmediaplayer/qmediaplayer.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+
+SOURCES += tst_qmediaplayer.cpp
+
+QT = core multimedia
+
diff --git a/tests/auto/qmediaplayer/tst_qmediaplayer.cpp b/tests/auto/qmediaplayer/tst_qmediaplayer.cpp
new file mode 100644
index 0000000..a96e08d
--- /dev/null
+++ b/tests/auto/qmediaplayer/tst_qmediaplayer.cpp
@@ -0,0 +1,986 @@
+/****************************************************************************
+**
+** 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 <QtMultimedia/qmediaplayer.h>
+#include <QtMultimedia/qmediaplayercontrol.h>
+#include <QtMultimedia/qmediaplaylist.h>
+#include <QtMultimedia/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
new file mode 100644
index 0000000..b114bda
--- /dev/null
+++ b/tests/auto/qmediaplaylist/qmediaplaylist.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+
+SOURCES = tst_qmediaplaylist.cpp
+
+QT = core multimedia
+
diff --git a/tests/auto/qmediaplaylist/tmp.unsupported_format b/tests/auto/qmediaplaylist/tmp.unsupported_format
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/qmediaplaylist/tmp.unsupported_format
diff --git a/tests/auto/qmediaplaylist/tst_qmediaplaylist.cpp b/tests/auto/qmediaplaylist/tst_qmediaplaylist.cpp
new file mode 100644
index 0000000..383a407
--- /dev/null
+++ b/tests/auto/qmediaplaylist/tst_qmediaplaylist.cpp
@@ -0,0 +1,593 @@
+/****************************************************************************
+**
+** 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 <QtMultimedia/qmediaservice.h>
+#include <QtMultimedia/qmediaplaylist.h>
+#include <QtMultimedia/qmediaplaylistcontrol.h>
+#include <QtMultimedia/qmediaplaylistnavigator.h>
+#include <QtMultimedia/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
new file mode 100644
index 0000000..ea9bc0f
--- /dev/null
+++ b/tests/auto/qmediaplaylistnavigator/qmediaplaylistnavigator.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+
+SOURCES = tst_qmediaplaylistnavigator.cpp
+
+QT = core multimedia
+
diff --git a/tests/auto/qmediaplaylistnavigator/tst_qmediaplaylistnavigator.cpp b/tests/auto/qmediaplaylistnavigator/tst_qmediaplaylistnavigator.cpp
new file mode 100644
index 0000000..9130db0
--- /dev/null
+++ b/tests/auto/qmediaplaylistnavigator/tst_qmediaplaylistnavigator.cpp
@@ -0,0 +1,316 @@
+/****************************************************************************
+**
+** 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 <QtMultimedia/qlocalmediaplaylistprovider.h>
+#include <QtMultimedia/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
new file mode 100644
index 0000000..66950e9
--- /dev/null
+++ b/tests/auto/qmediapluginloader/qmediapluginloader.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+
+SOURCES = tst_qmediapluginloader.cpp
+
+QT = core multimedia
+
diff --git a/tests/auto/qmediapluginloader/tst_qmediapluginloader.cpp b/tests/auto/qmediapluginloader/tst_qmediapluginloader.cpp
new file mode 100644
index 0000000..0d35b05
--- /dev/null
+++ b/tests/auto/qmediapluginloader/tst_qmediapluginloader.cpp
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** 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 <QtMultimedia/private/qmediapluginloader_p.h>
+#include <QtMultimedia/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
new file mode 100644
index 0000000..c8e3d9c
--- /dev/null
+++ b/tests/auto/qmediaresource/qmediaresource.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+
+SOURCES = tst_qmediaresource.cpp
+
+QT = core multimedia network
+
diff --git a/tests/auto/qmediaresource/tst_qmediaresource.cpp b/tests/auto/qmediaresource/tst_qmediaresource.cpp
new file mode 100644
index 0000000..546c415
--- /dev/null
+++ b/tests/auto/qmediaresource/tst_qmediaresource.cpp
@@ -0,0 +1,516 @@
+/****************************************************************************
+**
+** 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 <QtMultimedia/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
new file mode 100644
index 0000000..f877665
--- /dev/null
+++ b/tests/auto/qmediaservice/qmediaservice.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+
+SOURCES = tst_qmediaservice.cpp
+
+QT = core gui multimedia
+
diff --git a/tests/auto/qmediaservice/tst_qmediaservice.cpp b/tests/auto/qmediaservice/tst_qmediaservice.cpp
new file mode 100644
index 0000000..35f661d
--- /dev/null
+++ b/tests/auto/qmediaservice/tst_qmediaservice.cpp
@@ -0,0 +1,211 @@
+/****************************************************************************
+**
+** 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 <QtMultimedia/qvideodevicecontrol.h>
+#include <QtMultimedia/qmediacontrol.h>
+#include <QtMultimedia/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"
+Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlA, QtTestMediaControlA_iid)
+
+
+class QtTestMediaControlB : public QMediaControl
+{
+ Q_OBJECT
+};
+
+#define QtTestMediaControlB_iid "com.nokia.QtTestMediaControlB"
+Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlB, QtTestMediaControlB_iid)
+
+
+class QtTestMediaControlC : public QMediaControl
+{
+ Q_OBJECT
+};
+
+#define QtTestMediaControlC_iid "com.nokia.QtTestMediaControlC"
+Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlC, QtTestMediaControlA_iid) // Yes A.
+
+class QtTestMediaControlD : public QMediaControl
+{
+ Q_OBJECT
+};
+
+#define QtTestMediaControlD_iid "com.nokia.QtTestMediaControlD"
+Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlD, QtTestMediaControlD_iid)
+
+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
new file mode 100644
index 0000000..9aaa9e5
--- /dev/null
+++ b/tests/auto/qmediaserviceprovider/qmediaserviceprovider.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+
+SOURCES = tst_qmediaserviceprovider.cpp
+
+QT = core gui multimedia
+
diff --git a/tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp b/tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp
new file mode 100644
index 0000000..9bca189
--- /dev/null
+++ b/tests/auto/qmediaserviceprovider/tst_qmediaserviceprovider.cpp
@@ -0,0 +1,409 @@
+/****************************************************************************
+**
+** 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 <QtMultimedia/qmediaserviceprovider.h>
+#include <QtMultimedia/qmediaserviceproviderplugin.h>
+#include <QtMultimedia/private/qmediapluginloader_p.h>
+#include <QtMultimedia/qmediaobject.h>
+#include <QtMultimedia/qmediaservice.h>
+#include <QtMultimedia/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;
+ }
+
+ QtMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const
+ {
+ if (codecs.contains(QLatin1String("mpeg4")))
+ return QtMultimedia::NotSupported;
+
+ if (mimeType == "audio/ogg") {
+ return QtMultimedia::ProbablySupported;
+ }
+
+ return QtMultimedia::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;
+ }
+
+ QtMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const
+ {
+ Q_UNUSED(codecs);
+
+ if (mimeType == "audio/wav")
+ return QtMultimedia::PreferedService;
+
+ return QtMultimedia::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 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;
+
+ 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()),
+ QtMultimedia::MaybeSupported);
+
+ QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider();
+
+ if (provider == 0)
+ QSKIP("No default provider", SkipSingle);
+
+ QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/ogv", QStringList()),
+ QtMultimedia::MaybeSupported);
+
+ QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "audio/ogg", QStringList()),
+ QtMultimedia::ProbablySupported);
+
+ //while the service returns PreferredService, provider should return ProbablySupported
+ QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "audio/wav", QStringList()),
+ QtMultimedia::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"),
+ QtMultimedia::MaybeSupported);
+
+ QCOMPARE(provider->hasSupport(QByteArray("non existing service"), "video/ogv", QStringList()),
+ QtMultimedia::NotSupported);
+
+ QCOMPARE(QMediaPlayer::hasSupport("video/ogv"), QtMultimedia::MaybeSupported);
+ QCOMPARE(QMediaPlayer::hasSupport("audio/ogg"), QtMultimedia::ProbablySupported);
+ QCOMPARE(QMediaPlayer::hasSupport("audio/wav"), QtMultimedia::ProbablySupported);
+
+ //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"));
+}
+
+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
new file mode 100644
index 0000000..b1b436e
--- /dev/null
+++ b/tests/auto/qmediatimerange/qmediatimerange.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+
+SOURCES = tst_qmediatimerange.cpp
+
+QT = core multimedia
+
diff --git a/tests/auto/qmediatimerange/tst_qmediatimerange.cpp b/tests/auto/qmediatimerange/tst_qmediatimerange.cpp
new file mode 100644
index 0000000..54de3f1
--- /dev/null
+++ b/tests/auto/qmediatimerange/tst_qmediatimerange.cpp
@@ -0,0 +1,735 @@
+/****************************************************************************
+**
+** 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 <QtMultimedia/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/qmlaudio/qmlaudio.pro b/tests/auto/qmlaudio/qmlaudio.pro
new file mode 100644
index 0000000..fe18761
--- /dev/null
+++ b/tests/auto/qmlaudio/qmlaudio.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+SOURCES += tst_qmlaudio.cpp
+
+QT += multimedia declarative
+requires(contains(QT_CONFIG, multimedia))
+requires(contains(QT_CONFIG, declarative))
diff --git a/tests/auto/qmlaudio/tst_qmlaudio.cpp b/tests/auto/qmlaudio/tst_qmlaudio.cpp
new file mode 100644
index 0000000..068317f
--- /dev/null
+++ b/tests/auto/qmlaudio/tst_qmlaudio.cpp
@@ -0,0 +1,1200 @@
+/****************************************************************************
+**
+** 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 <QtMultimedia/private/qmlaudio_p.h>
+
+#include <QtGui/qapplication.h>
+#include <QtMultimedia/qmediaplayercontrol.h>
+#include <QtMultimedia/qmediaservice.h>
+#include <QtMultimedia/qmetadatacontrol.h>
+
+
+class tst_QmlAudio : public QObject
+{
+ Q_OBJECT
+public slots:
+ void initTestCase();
+
+private slots:
+ void nullPlayerControl();
+ void nullMetaDataControl();
+ void nullService();
+
+ void source();
+ 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(QtMultimedia::MetaData);
+Q_DECLARE_METATYPE(QmlAudio::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(QtMultimedia::MetaData key) const { return m_metaData.value(key); }
+ void setMetaData(QtMultimedia::MetaData key, const QVariant &value) {
+ m_metaData.insert(key, value); emit metaDataChanged(); }
+ void setMetaData(const QMap<QtMultimedia::MetaData, QVariant> &metaData) {
+ m_metaData = metaData; emit metaDataChanged(); }
+
+ QList<QtMultimedia::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<QtMultimedia::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_QmlAudio::initTestCase()
+{
+ qRegisterMetaType<QmlAudio::Error>();
+}
+
+void tst_QmlAudio::nullPlayerControl()
+{
+ QtTestMetaDataControl metaDataControl;
+ QtTestMediaServiceProvider provider(0, &metaDataControl);
+
+ QmlAudio audio;
+
+ QCOMPARE(audio.source(), QUrl());
+ audio.setSource(QUrl("http://example.com"));
+ QCOMPARE(audio.source(), QUrl());
+
+ QCOMPARE(audio.isPlaying(), false);
+ audio.setPlaying(true);
+ QCOMPARE(audio.isPlaying(), 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(), 0);
+
+ QCOMPARE(audio.volume(), qreal(0));
+ audio.setVolume(50);
+ QCOMPARE(audio.volume(), qreal(0));
+
+ QCOMPARE(audio.isMuted(), false);
+ audio.setMuted(true);
+ QCOMPARE(audio.isMuted(), false);
+
+ QCOMPARE(audio.bufferProgress(), qreal(0));
+
+ QCOMPARE(audio.isSeekable(), false);
+
+ QCOMPARE(audio.playbackRate(), qreal(1.0));
+
+ QCOMPARE(audio.status(), QmlAudio::NoMedia);
+
+ QCOMPARE(audio.error(), QmlAudio::ServiceMissing);
+}
+
+void tst_QmlAudio::nullMetaDataControl()
+{
+ QtTestMediaPlayerControl playerControl;
+ QtTestMediaServiceProvider provider(&playerControl, 0);
+
+ QmlAudio audio;
+
+ QCOMPARE(audio.metaObject()->indexOfProperty("title"), -1);
+ QCOMPARE(audio.metaObject()->indexOfProperty("genre"), -1);
+ QCOMPARE(audio.metaObject()->indexOfProperty("description"), -1);
+}
+
+void tst_QmlAudio::nullService()
+{
+ QtTestMediaServiceProvider provider(0);
+
+ QmlAudio audio;
+
+ QCOMPARE(audio.source(), QUrl());
+ audio.setSource(QUrl("http://example.com"));
+ QCOMPARE(audio.source(), QUrl());
+
+ QCOMPARE(audio.isPlaying(), false);
+ audio.setPlaying(true);
+ QCOMPARE(audio.isPlaying(), 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(), 0);
+
+ QCOMPARE(audio.volume(), qreal(0));
+ audio.setVolume(50);
+ QCOMPARE(audio.volume(), qreal(0));
+
+ QCOMPARE(audio.isMuted(), false);
+ audio.setMuted(true);
+ QCOMPARE(audio.isMuted(), false);
+
+ QCOMPARE(audio.bufferProgress(), qreal(0));
+
+ QCOMPARE(audio.isSeekable(), false);
+
+ QCOMPARE(audio.playbackRate(), qreal(1.0));
+
+ QCOMPARE(audio.status(), QmlAudio::NoMedia);
+
+ QCOMPARE(audio.error(), QmlAudio::ServiceMissing);
+
+ QCOMPARE(audio.metaObject()->indexOfProperty("title"), -1);
+ QCOMPARE(audio.metaObject()->indexOfProperty("genre"), -1);
+ QCOMPARE(audio.metaObject()->indexOfProperty("description"), -1);
+}
+
+void tst_QmlAudio::source()
+{
+ const QUrl url1("http://example.com");
+ const QUrl url2("file:///local/path");
+ const QUrl url3;
+
+ QtTestMediaServiceProvider provider;
+ QmlAudio audio;
+
+ 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_QmlAudio::playing()
+{
+ QtTestMediaServiceProvider provider;
+ QmlAudio 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;
+
+ 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_QmlAudio::paused()
+{
+ QtTestMediaServiceProvider provider;
+ QmlAudio 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;
+
+ 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_QmlAudio::duration()
+{
+ QtTestMediaServiceProvider provider;
+ QmlAudio audio;
+
+ 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_QmlAudio::position()
+{
+ QtTestMediaServiceProvider provider;
+ QmlAudio audio;
+
+ QSignalSpy spy(&audio, SIGNAL(positionChanged()));
+
+ QCOMPARE(audio.position(), 0);
+
+ // QmlAudio 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(), 3);
+
+ // 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(), 4);
+
+ connect(&audio, SIGNAL(positionChanged()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+
+ provider.playerControl()->updateState(QMediaPlayer::PlayingState);
+ QTestEventLoop::instance().enterLoop(1);
+ QVERIFY(spy.count() > 4 && spy.count() < 7); // 5 or 6
+
+ provider.playerControl()->updateState(QMediaPlayer::PausedState);
+ QTestEventLoop::instance().enterLoop(1);
+ QVERIFY(spy.count() < 7);
+}
+
+void tst_QmlAudio::volume()
+{
+ QtTestMediaServiceProvider provider;
+ QmlAudio audio;
+
+ QSignalSpy spy(&audio, SIGNAL(volumeChanged()));
+
+ QCOMPARE(audio.volume(), qreal(0.5));
+
+ 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(), 2);
+
+ provider.playerControl()->setVolume(30);
+ QCOMPARE(audio.volume(), qreal(0.3));
+ QCOMPARE(spy.count(), 3);
+}
+
+void tst_QmlAudio::muted()
+{
+ QtTestMediaServiceProvider provider;
+ QmlAudio audio;
+
+ 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_QmlAudio::bufferProgress()
+{
+ QtTestMediaServiceProvider provider;
+ QmlAudio audio;
+
+ 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_QmlAudio::seekable()
+{
+ QtTestMediaServiceProvider provider;
+ QmlAudio audio;
+
+ 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_QmlAudio::playbackRate()
+{
+ QtTestMediaServiceProvider provider;
+ QmlAudio audio;
+
+ 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_QmlAudio::status()
+{
+ QtTestMediaServiceProvider provider;
+ QmlAudio audio;
+
+ 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(), QmlAudio::NoMedia);
+
+ // Set media, start loading.
+ provider.playerControl()->updateMediaStatus(QMediaPlayer::LoadingMedia);
+ QCOMPARE(audio.status(), QmlAudio::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(), QmlAudio::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(), QmlAudio::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(), QmlAudio::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(), QmlAudio::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(), QmlAudio::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(), QmlAudio::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(), QmlAudio::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(), QmlAudio::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_QmlAudio::metaData_data()
+{
+ QTest::addColumn<QByteArray>("propertyName");
+ QTest::addColumn<QtMultimedia::MetaData>("propertyKey");
+ QTest::addColumn<QVariant>("value1");
+ QTest::addColumn<QVariant>("value2");
+
+ QTest::newRow("title")
+ << QByteArray("title")
+ << QtMultimedia::Title
+ << QVariant(QString::fromLatin1("This is a title"))
+ << QVariant(QString::fromLatin1("This is another title"));
+
+ QTest::newRow("genre")
+ << QByteArray("genre")
+ << QtMultimedia::Genre
+ << QVariant(QString::fromLatin1("rock"))
+ << QVariant(QString::fromLatin1("pop"));
+
+ QTest::newRow("trackNumber")
+ << QByteArray("trackNumber")
+ << QtMultimedia::TrackNumber
+ << QVariant(8)
+ << QVariant(12);
+}
+
+void tst_QmlAudio::metaData()
+{
+ QFETCH(QByteArray, propertyName);
+ QFETCH(QtMultimedia::MetaData, propertyKey);
+ QFETCH(QVariant, value1);
+ QFETCH(QVariant, value2);
+
+ QtTestMediaServiceProvider provider;
+ QmlAudio audio;
+
+ 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_QmlAudio::error()
+{
+ const QString errorString = QLatin1String("Failed to open device.");
+
+ QtTestMediaServiceProvider provider;
+ QmlAudio audio;
+
+ QSignalSpy errorSpy(&audio, SIGNAL(error(QmlAudio::Error,QString)));
+ QSignalSpy errorChangedSpy(&audio, SIGNAL(errorChanged()));
+
+ QCOMPARE(audio.error(), QmlAudio::NoError);
+ QCOMPARE(audio.errorString(), QString());
+
+ provider.playerControl()->emitError(QMediaPlayer::ResourceError, errorString);
+
+ QCOMPARE(audio.error(), QmlAudio::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(), QmlAudio::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(), QmlAudio::NoError);
+ QCOMPARE(audio.errorString(), QString());
+ QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(errorChangedSpy.count(), 2);
+}
+
+
+QTEST_MAIN(tst_QmlAudio)
+
+#include "tst_qmlaudio.moc"
diff --git a/tests/auto/qmlgraphicsvideo/qmlgraphicsvideo.pro b/tests/auto/qmlgraphicsvideo/qmlgraphicsvideo.pro
new file mode 100644
index 0000000..0a83124
--- /dev/null
+++ b/tests/auto/qmlgraphicsvideo/qmlgraphicsvideo.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+SOURCES += tst_qmlgraphicsvideo.cpp
+
+QT += multimedia declarative
+requires(contains(QT_CONFIG, multimedia))
+requires(contains(QT_CONFIG, declarative))
diff --git a/tests/auto/qmlgraphicsvideo/tst_qmlgraphicsvideo.cpp b/tests/auto/qmlgraphicsvideo/tst_qmlgraphicsvideo.cpp
new file mode 100644
index 0000000..0da094d
--- /dev/null
+++ b/tests/auto/qmlgraphicsvideo/tst_qmlgraphicsvideo.cpp
@@ -0,0 +1,911 @@
+/****************************************************************************
+**
+** 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 <QtMultimedia/private/qmlgraphicsvideo_p.h>
+
+#include <QtGui/qapplication.h>
+#include <QtMultimedia/qabstractvideosurface.h>
+#include <QtMultimedia/qgraphicsvideoitem.h>
+#include <QtMultimedia/qmediaplayercontrol.h>
+#include <QtMultimedia/qmediaservice.h>
+#include <QtMultimedia/qvideooutputcontrol.h>
+#include <QtMultimedia/qvideorenderercontrol.h>
+#include <QtMultimedia/qvideosurfaceformat.h>
+
+
+class tst_QmlGraphicsVideo : 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(QtMultimedia::MetaData);
+Q_DECLARE_METATYPE(QmlGraphicsVideo::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_QmlGraphicsVideo::initTestCase()
+{
+ qRegisterMetaType<QmlGraphicsVideo::Error>();
+}
+
+void tst_QmlGraphicsVideo::nullPlayerControl()
+{
+ QtTestMediaServiceProvider provider(0, 0, 0);
+
+ QmlGraphicsVideo video;
+
+ QCOMPARE(video.source(), QUrl());
+ video.setSource(QUrl("http://example.com"));
+ QCOMPARE(video.source(), QUrl());
+
+ QCOMPARE(video.isPlaying(), false);
+ video.setPlaying(true);
+ QCOMPARE(video.isPlaying(), 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(), 0);
+
+ QCOMPARE(video.volume(), qreal(0));
+ video.setVolume(50);
+ QCOMPARE(video.volume(), qreal(0));
+
+ QCOMPARE(video.isMuted(), false);
+ video.setMuted(true);
+ QCOMPARE(video.isMuted(), false);
+
+ 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(), QmlGraphicsVideo::NoMedia);
+
+ QCOMPARE(video.error(), QmlGraphicsVideo::ServiceMissing);
+}
+
+void tst_QmlGraphicsVideo::nullService()
+{
+ QtTestMediaServiceProvider provider(0);
+
+ QmlGraphicsVideo video;
+
+ QCOMPARE(video.source(), QUrl());
+ video.setSource(QUrl("http://example.com"));
+ QCOMPARE(video.source(), QUrl());
+
+ QCOMPARE(video.isPlaying(), false);
+ video.setPlaying(true);
+ QCOMPARE(video.isPlaying(), 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(), 0);
+
+ QCOMPARE(video.volume(), qreal(0));
+ video.setVolume(50);
+ QCOMPARE(video.volume(), qreal(0));
+
+ QCOMPARE(video.isMuted(), false);
+ video.setMuted(true);
+ QCOMPARE(video.isMuted(), false);
+
+ 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(), QmlGraphicsVideo::NoMedia);
+
+ QCOMPARE(video.error(), QmlGraphicsVideo::ServiceMissing);
+
+ QCOMPARE(video.metaObject()->indexOfProperty("title"), -1);
+ QCOMPARE(video.metaObject()->indexOfProperty("genre"), -1);
+ QCOMPARE(video.metaObject()->indexOfProperty("description"), -1);
+}
+
+void tst_QmlGraphicsVideo::playing()
+{
+ QtTestMediaServiceProvider provider;
+ QmlGraphicsVideo video;
+
+ 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_QmlGraphicsVideo::paused()
+{
+ QtTestMediaServiceProvider provider;
+ QmlGraphicsVideo video;
+
+ 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_QmlGraphicsVideo::error()
+{
+ const QString errorString = QLatin1String("Failed to open device.");
+
+ QtTestMediaServiceProvider provider;
+ QmlGraphicsVideo video;
+
+ QSignalSpy errorSpy(&video, SIGNAL(error(QmlGraphicsVideo::Error,QString)));
+ QSignalSpy errorChangedSpy(&video, SIGNAL(errorChanged()));
+
+ QCOMPARE(video.error(), QmlGraphicsVideo::NoError);
+ QCOMPARE(video.errorString(), QString());
+
+ provider.playerControl()->emitError(QMediaPlayer::ResourceError, errorString);
+
+ QCOMPARE(video.error(), QmlGraphicsVideo::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(), QmlGraphicsVideo::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(), QmlGraphicsVideo::NoError);
+ QCOMPARE(video.errorString(), QString());
+ QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(errorChangedSpy.count(), 2);
+}
+
+
+void tst_QmlGraphicsVideo::hasAudio()
+{
+ QtTestMediaServiceProvider provider;
+ QmlGraphicsVideo video;
+
+ 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_QmlGraphicsVideo::hasVideo()
+{
+ QtTestMediaServiceProvider provider;
+ QmlGraphicsVideo video;
+
+ 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_QmlGraphicsVideo::fillMode()
+{
+ QtTestMediaServiceProvider provider;
+ QmlGraphicsVideo video;
+
+ QList<QGraphicsItem *> children = video.childItems();
+ QCOMPARE(children.count(), 1);
+ QGraphicsVideoItem *videoItem = qgraphicsitem_cast<QGraphicsVideoItem *>(children.first());
+ QVERIFY(videoItem != 0);
+
+ QCOMPARE(video.fillMode(), QmlGraphicsVideo::PreserveAspectFit);
+
+ video.setFillMode(QmlGraphicsVideo::PreserveAspectCrop);
+ QCOMPARE(video.fillMode(), QmlGraphicsVideo::PreserveAspectCrop);
+ QCOMPARE(videoItem->aspectRatioMode(), Qt::KeepAspectRatioByExpanding);
+
+ video.setFillMode(QmlGraphicsVideo::Stretch);
+ QCOMPARE(video.fillMode(), QmlGraphicsVideo::Stretch);
+ QCOMPARE(videoItem->aspectRatioMode(), Qt::IgnoreAspectRatio);
+
+ video.setFillMode(QmlGraphicsVideo::PreserveAspectFit);
+ QCOMPARE(video.fillMode(), QmlGraphicsVideo::PreserveAspectFit);
+ QCOMPARE(videoItem->aspectRatioMode(), Qt::KeepAspectRatio);
+}
+
+void tst_QmlGraphicsVideo::geometry()
+{
+ QtTestMediaServiceProvider provider;
+ QmlGraphicsVideo video;
+
+ 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_QmlGraphicsVideo)
+
+#include "tst_qmlgraphicsvideo.moc"
diff --git a/tests/auto/qpathclipper/pathcompare.h b/tests/auto/qpathclipper/pathcompare.h
new file mode 100644
index 0000000..eb25e4c
--- /dev/null
+++ b/tests/auto/qpathclipper/pathcompare.h
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+#ifndef PATHCOMPARE_H
+#define PATHCOMPARE_H
+
+#include <qmath.h>
+
+namespace QPathCompare {
+
+static const int precision = 8;
+static const qreal epsilon = qPow(0.1, precision);
+
+static inline bool fuzzyIsZero(qreal x, qreal relative)
+{
+ if (qAbs(relative) < epsilon)
+ return qAbs(x) < epsilon;
+ else
+ return qAbs(x / relative) < epsilon;
+}
+
+static bool fuzzyCompare(const QPointF &a, const QPointF &b)
+{
+ const QPointF delta = a - b;
+
+ const qreal x = qMax(qAbs(a.x()), qAbs(b.x()));
+ const qreal y = qMax(qAbs(a.y()), qAbs(b.y()));
+
+ return fuzzyIsZero(delta.x(), x) && fuzzyIsZero(delta.y(), y);
+}
+
+static bool isClosed(const QPainterPath &path)
+{
+ if (path.elementCount() == 0)
+ return false;
+
+ QPointF first = path.elementAt(0);
+ QPointF last = path.elementAt(path.elementCount() - 1);
+
+ return fuzzyCompare(first, last);
+}
+
+// rotation and direction independent path comparison
+// allows paths to be shifted or reversed relative to each other
+static bool comparePaths(const QPainterPath &actual, const QPainterPath &expected)
+{
+ const int endActual = isClosed(actual) ? actual.elementCount() - 1 : actual.elementCount();
+ const int endExpected = isClosed(expected) ? expected.elementCount() - 1 : expected.elementCount();
+
+ if (endActual != endExpected)
+ return false;
+
+ for (int i = 0; i < endActual; ++i) {
+ int k = 0;
+ for (k = 0; k < endActual; ++k) {
+ int i1 = k;
+ int i2 = (i + k) % endActual;
+
+ QPointF a = actual.elementAt(i1);
+ QPointF b = expected.elementAt(i2);
+
+ if (!fuzzyCompare(a, b))
+ break;
+ }
+
+ if (k == endActual)
+ return true;
+
+ for (k = 0; k < endActual; ++k) {
+ int i1 = k;
+ int i2 = (i + endActual - k) % endActual;
+
+ QPointF a = actual.elementAt(i1);
+ QPointF b = expected.elementAt(i2);
+
+ if (!fuzzyCompare(a, b))
+ break;
+ }
+
+ if (k == endActual)
+ return true;
+ }
+
+ return false;
+}
+
+}
+
+#endif
diff --git a/tests/auto/qpathclipper/tst_qpathclipper.cpp b/tests/auto/qpathclipper/tst_qpathclipper.cpp
index 5b49545..38d253a 100644
--- a/tests/auto/qpathclipper/tst_qpathclipper.cpp
+++ b/tests/auto/qpathclipper/tst_qpathclipper.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "private/qpathclipper_p.h"
#include "paths.h"
+#include "pathcompare.h"
#include <QtTest/QtTest>
@@ -336,13 +337,17 @@ static QPainterPath samplePath13()
static QPainterPath samplePath14()
{
QPainterPath path;
- path.moveTo(QPointF(100, 180));
- path.lineTo(QPointF(100, 80));
- path.lineTo(QPointF(120, 80));
- path.lineTo(QPointF(120, 100));
- path.lineTo(QPointF(160, 100));
- path.lineTo(QPointF(160, 180));
- path.lineTo(QPointF(100, 180));
+
+ path.moveTo(160, 80);
+ path.lineTo(160, 180);
+ path.lineTo(100, 180);
+ path.lineTo(100, 80);
+ path.lineTo(160, 80);
+ path.moveTo(160, 80);
+ path.lineTo(160, 100);
+ path.lineTo(120, 100);
+ path.lineTo(120, 80);
+
return path;
}
@@ -426,82 +431,6 @@ void tst_QPathClipper::clip_data()
<< samplePath14();
}
-static const int precision = 8;
-static const qreal epsilon = pow(0.1, precision);
-
-static inline bool fuzzyIsZero(qreal x, qreal relative)
-{
- if (qAbs(relative) < epsilon)
- return qAbs(x) < epsilon;
- else
- return qAbs(x / relative) < epsilon;
-}
-
-static bool fuzzyCompare(const QPointF &a, const QPointF &b)
-{
- const QPointF delta = a - b;
-
- const qreal x = qMax(qAbs(a.x()), qAbs(b.x()));
- const qreal y = qMax(qAbs(a.y()), qAbs(b.y()));
-
- return fuzzyIsZero(delta.x(), x) && fuzzyIsZero(delta.y(), y);
-}
-
-static bool isClosed(const QPainterPath &path)
-{
- if (path.elementCount() == 0)
- return false;
-
- QPointF first = path.elementAt(0);
- QPointF last = path.elementAt(path.elementCount() - 1);
-
- return fuzzyCompare(first, last);
-}
-
-// rotation and direction independent path comparison
-// allows paths to be shifted or reversed relative to each other
-static bool comparePaths(const QPainterPath &actual, const QPainterPath &expected)
-{
- const int endActual = isClosed(actual) ? actual.elementCount() - 1 : actual.elementCount();
- const int endExpected = isClosed(expected) ? expected.elementCount() - 1 : expected.elementCount();
-
- if (endActual != endExpected)
- return false;
-
- for (int i = 0; i < endActual; ++i) {
- int k = 0;
- for (k = 0; k < endActual; ++k) {
- int i1 = k;
- int i2 = (i + k) % endActual;
-
- QPointF a = actual.elementAt(i1);
- QPointF b = expected.elementAt(i2);
-
- if (!fuzzyCompare(a, b))
- break;
- }
-
- if (k == endActual)
- return true;
-
- for (k = 0; k < endActual; ++k) {
- int i1 = k;
- int i2 = (i + endActual - k) % endActual;
-
- QPointF a = actual.elementAt(i1);
- QPointF b = expected.elementAt(i2);
-
- if (!fuzzyCompare(a, b))
- break;
- }
-
- if (k == endActual)
- return true;
- }
-
- return false;
-}
-
// sanity check to make sure comparePaths declared above works
void tst_QPathClipper::testComparePaths()
{
@@ -511,12 +440,12 @@ void tst_QPathClipper::testComparePaths()
a.addRect(0, 0, 10, 10);
b.addRect(0, 0, 10.00001, 10.00001);
- QVERIFY(!comparePaths(a, b));
+ QVERIFY(!QPathCompare::comparePaths(a, b));
b = QPainterPath();
b.addRect(0, 0, 10.00000000001, 10.00000000001);
- QVERIFY(comparePaths(a, b));
+ QVERIFY(QPathCompare::comparePaths(a, b));
b = QPainterPath();
b.moveTo(10, 0);
@@ -524,9 +453,9 @@ void tst_QPathClipper::testComparePaths()
b.lineTo(0, 10);
b.lineTo(10, 10);
- QVERIFY(comparePaths(a, b));
+ QVERIFY(QPathCompare::comparePaths(a, b));
b.lineTo(10, 0);
- QVERIFY(comparePaths(a, b));
+ QVERIFY(QPathCompare::comparePaths(a, b));
b = QPainterPath();
b.moveTo(10, 0);
@@ -534,7 +463,7 @@ void tst_QPathClipper::testComparePaths()
b.lineTo(0, 0);
b.lineTo(10, 10);
- QVERIFY(!comparePaths(a, b));
+ QVERIFY(!QPathCompare::comparePaths(a, b));
}
void tst_QPathClipper::clip()
@@ -549,7 +478,7 @@ void tst_QPathClipper::clip()
QPathClipper clipper(subject, clip);
QPainterPath x = clipper.clip(op);
- QVERIFY(comparePaths(x, result));
+ QVERIFY(QPathCompare::comparePaths(x, result));
}
static inline QPointF randomPointInRect(const QRectF &rect)
diff --git a/tests/auto/qprinter/tst_qprinter.cpp b/tests/auto/qprinter/tst_qprinter.cpp
index b1ff425..7e8ce84 100644
--- a/tests/auto/qprinter/tst_qprinter.cpp
+++ b/tests/auto/qprinter/tst_qprinter.cpp
@@ -106,7 +106,7 @@ private slots:
void testCustomPageSizes();
void printDialogCompleter();
- void testActualNumCopies();
+ void testCopyCount();
void taskQTBUG4497_reusePrinterOnDifferentFiles();
@@ -455,7 +455,7 @@ void tst_QPrinter::testNonExistentPrinter()
printer.pageSize();
printer.orientation();
printer.fullPage();
- printer.setNumCopies(1);
+ printer.setCopyCount(1);
printer.printerName();
// nor metrics
@@ -966,11 +966,11 @@ void tst_QPrinter::printDialogCompleter()
#endif
}
-void tst_QPrinter::testActualNumCopies()
+void tst_QPrinter::testCopyCount()
{
QPrinter p;
- p.setNumCopies(15);
- QCOMPARE(p.actualNumCopies(), 15);
+ p.setCopyCount(15);
+ QCOMPARE(p.copyCount(), 15);
}
static void printPage(QPainter *painter)
diff --git a/tests/auto/qstatictext/qstatictext.pro b/tests/auto/qstatictext/qstatictext.pro
new file mode 100644
index 0000000..a759a90
--- /dev/null
+++ b/tests/auto/qstatictext/qstatictext.pro
@@ -0,0 +1,4 @@
+load(qttest_p4)
+QT = core gui opengl
+SOURCES += tst_qstatictext.cpp
+
diff --git a/tests/auto/qstatictext/tst_qstatictext.cpp b/tests/auto/qstatictext/tst_qstatictext.cpp
new file mode 100644
index 0000000..68f05c1
--- /dev/null
+++ b/tests/auto/qstatictext/tst_qstatictext.cpp
@@ -0,0 +1,451 @@
+/****************************************************************************
+**
+** 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 <QtGui/QApplication>
+#include <QtGui/QPainter>
+#include <QtGui/QImage>
+
+#include <qstatictext.h>
+#include <private/qstatictext_p.h>
+
+// #define DEBUG_SAVE_IMAGE
+
+class tst_QStaticText: public QObject
+{
+ Q_OBJECT
+private slots:
+ void init();
+ void cleanup();
+
+ void constructionAndDestruction();
+ void drawToPoint_data();
+ void drawToPoint();
+ void drawToRect_data();
+ void drawToRect();
+ void setFont();
+ void setMaximumSize();
+ void prepareToCorrectData();
+ void prepareToWrongData();
+
+ void translatedPainter();
+ void rotatedPainter();
+ void scaledPainter();
+ void projectedPainter();
+ void rotatedScaledAndTranslatedPainter();
+ void transformationChanged();
+};
+
+void tst_QStaticText::init()
+{
+}
+
+void tst_QStaticText::cleanup()
+{
+}
+
+void tst_QStaticText::constructionAndDestruction()
+{
+ QStaticText text("My text");
+}
+
+Q_DECLARE_METATYPE(QStaticText::PerformanceHint)
+void tst_QStaticText::drawToPoint_data()
+{
+ QTest::addColumn<QStaticText::PerformanceHint>("performanceHint");
+
+ QTest::newRow("Moderate caching") << QStaticText::ModerateCaching;
+ QTest::newRow("Aggressive caching") << QStaticText::AggressiveCaching;
+}
+
+void tst_QStaticText::drawToPoint()
+{
+ QFETCH(QStaticText::PerformanceHint, performanceHint);
+
+ QPixmap imageDrawText(1000, 1000);
+ imageDrawText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawText);
+ p.drawText(11, 12, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ }
+
+ QPixmap imageDrawStaticText(1000, 1000);
+ imageDrawStaticText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawStaticText);
+ QStaticText text("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ text.setTextFormat(Qt::PlainText);
+ text.setPerformanceHint(performanceHint);
+ p.drawStaticText(QPointF(11, 12), text);
+ }
+
+ QCOMPARE(imageDrawStaticText, imageDrawText);
+}
+
+void tst_QStaticText::drawToRect_data()
+{
+ QTest::addColumn<QStaticText::PerformanceHint>("performanceHint");
+
+ QTest::newRow("Moderate caching") << QStaticText::ModerateCaching;
+ QTest::newRow("Aggressive caching") << QStaticText::AggressiveCaching;
+}
+
+void tst_QStaticText::drawToRect()
+{
+ QFETCH(QStaticText::PerformanceHint, performanceHint);
+
+ QPixmap imageDrawText(1000, 1000);
+ imageDrawText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawText);
+ p.drawText(QRectF(11, 12, 10, 500), "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ }
+
+ QPixmap imageDrawStaticText(1000, 1000);
+ imageDrawStaticText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawStaticText);
+ QStaticText text("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", QSizeF(10, 500));
+ text.setPerformanceHint(performanceHint);
+ text.setTextFormat(Qt::PlainText);
+ p.drawStaticText(QPointF(11, 12), text);
+ }
+
+ QCOMPARE(imageDrawStaticText, imageDrawText);
+}
+
+void tst_QStaticText::prepareToCorrectData()
+{
+ QTransform transform;
+ transform.scale(2.0, 2.0);
+ transform.rotate(90, Qt::ZAxis);
+
+ QPixmap imageDrawText(1000, 1000);
+ imageDrawText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawText);
+ p.setTransform(transform);
+ p.drawText(11, 12, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ }
+
+ QPixmap imageDrawStaticText(1000, 1000);
+ imageDrawStaticText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawStaticText);
+ p.setTransform(transform);
+ QStaticText text("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ text.prepare(transform, p.font());
+ text.setTextFormat(Qt::PlainText);
+ p.drawStaticText(QPointF(11, 12), text);
+ }
+
+ QCOMPARE(imageDrawStaticText, imageDrawText);
+}
+
+void tst_QStaticText::prepareToWrongData()
+{
+ QTransform transform;
+ transform.scale(2.0, 2.0);
+ transform.rotate(90, Qt::ZAxis);
+
+ QPixmap imageDrawText(1000, 1000);
+ imageDrawText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawText);
+ p.drawText(11, 12, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ }
+
+ QPixmap imageDrawStaticText(1000, 1000);
+ imageDrawStaticText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawStaticText);
+ QStaticText text("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ text.prepare(transform, p.font());
+ text.setTextFormat(Qt::PlainText);
+ p.drawStaticText(QPointF(11, 12), text);
+ }
+
+ QCOMPARE(imageDrawStaticText, imageDrawText);
+}
+
+
+void tst_QStaticText::setFont()
+{
+ QFont font = QApplication::font();
+ font.setBold(true);
+ font.setPointSize(28);
+
+ QPixmap imageDrawText(1000, 1000);
+ imageDrawText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawText);
+ p.drawText(0, 0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+
+ p.setFont(font);
+ p.drawText(11, 120, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ }
+
+ QPixmap imageDrawStaticText(1000, 1000);
+ imageDrawStaticText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawStaticText);
+
+ QStaticText text;
+ text.setText("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ text.setTextFormat(Qt::PlainText);
+
+ p.drawStaticText(0, 0, text);
+
+ p.setFont(font);
+ p.drawStaticText(11, 120, text);
+ }
+
+ QCOMPARE(imageDrawStaticText, imageDrawText);
+}
+
+void tst_QStaticText::setMaximumSize()
+{
+ QPixmap imageDrawText(1000, 1000);
+ imageDrawText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawText);
+ p.drawText(QRectF(11, 12, 10, 500), "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ }
+
+ QPixmap imageDrawStaticText(1000, 1000);
+ imageDrawStaticText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawStaticText);
+ QStaticText text("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ text.setMaximumSize(QSizeF(10, 500));
+ p.drawStaticText(QPointF(11, 12), text);
+ }
+
+ QCOMPARE(imageDrawStaticText, imageDrawText);
+}
+
+void tst_QStaticText::translatedPainter()
+{
+ QPixmap imageDrawText(1000, 1000);
+ imageDrawText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawText);
+ p.translate(100, 200);
+
+ p.drawText(11, 12, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ }
+
+ QPixmap imageDrawStaticText(1000, 1000);
+ imageDrawStaticText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawStaticText);
+ p.translate(100, 200);
+
+ QStaticText text("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ text.setTextFormat(Qt::PlainText);
+
+ p.drawStaticText(QPointF(11, 12), text);
+ }
+
+ QCOMPARE(imageDrawStaticText, imageDrawText);
+}
+
+void tst_QStaticText::rotatedPainter()
+{
+ QPixmap imageDrawText(1000, 1000);
+ imageDrawText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawText);
+ p.rotate(30.0);
+ p.drawText(0, 0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ }
+
+ QPixmap imageDrawStaticText(1000, 1000);
+ imageDrawStaticText.fill(Qt::white);
+ {
+ QStaticText text("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ text.setTextFormat(Qt::PlainText);
+
+ QPainter p(&imageDrawStaticText);
+ p.rotate(30.0);
+ p.drawStaticText(QPoint(0, 0), text);
+ }
+
+#if defined(DEBUG_SAVE_IMAGE)
+ imageDrawText.save("rotatedPainter_imageDrawText.png");
+ imageDrawStaticText.save("rotatedPainter_imageDrawStaticText.png");
+#endif
+
+ QCOMPARE(imageDrawStaticText, imageDrawText);
+}
+
+void tst_QStaticText::scaledPainter()
+{
+ QPixmap imageDrawText(1000, 1000);
+ imageDrawText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawText);
+ p.scale(2.0, 0.2);
+
+ p.drawText(11, 12, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ }
+
+ QPixmap imageDrawStaticText(1000, 1000);
+ imageDrawStaticText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawStaticText);
+ p.scale(2.0, 0.2);
+
+ QStaticText text("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ text.setTextFormat(Qt::PlainText);
+
+ p.drawStaticText(QPointF(11, 12), text);
+ }
+
+ QCOMPARE(imageDrawStaticText, imageDrawText);
+}
+
+void tst_QStaticText::projectedPainter()
+{
+ QTransform transform;
+ transform.rotate(90, Qt::XAxis);
+
+ QPixmap imageDrawText(1000, 1000);
+ imageDrawText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawText);
+ p.setTransform(transform);
+
+ p.drawText(11, 12, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ }
+
+ QPixmap imageDrawStaticText(1000, 1000);
+ imageDrawStaticText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawStaticText);
+ p.setTransform(transform);
+
+ QStaticText text("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ text.setTextFormat(Qt::PlainText);
+
+ p.drawStaticText(QPointF(11, 12), text);
+ }
+
+ QCOMPARE(imageDrawStaticText, imageDrawText);
+
+}
+
+void tst_QStaticText::rotatedScaledAndTranslatedPainter()
+{
+ QPixmap imageDrawText(1000, 1000);
+ imageDrawText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawText);
+ p.rotate(45.0);
+ p.scale(2.0, 2.0);
+ p.translate(100, 200);
+
+ p.drawText(11, 12, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ }
+
+ QPixmap imageDrawStaticText(1000, 1000);
+ imageDrawStaticText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawStaticText);
+ p.rotate(45.0);
+ p.scale(2.0, 2.0);
+ p.translate(100, 200);
+
+ QStaticText text("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ text.setTextFormat(Qt::PlainText);
+
+ p.drawStaticText(QPointF(11, 12), text);
+ }
+
+#if defined(DEBUG_SAVE_IMAGE)
+ imageDrawText.save("rotatedScaledAndPainter_imageDrawText.png");
+ imageDrawStaticText.save("rotatedScaledAndPainter_imageDrawStaticText.png");
+#endif
+
+ QCOMPARE(imageDrawStaticText, imageDrawText);
+}
+
+void tst_QStaticText::transformationChanged()
+{
+ QPixmap imageDrawText(1000, 1000);
+ imageDrawText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawText);
+ p.rotate(33.0);
+ p.scale(0.5, 0.7);
+
+ p.drawText(0, 0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+
+ p.scale(7.0, 5.0);
+ p.drawText(0, 0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ }
+
+ QPixmap imageDrawStaticText(1000, 1000);
+ imageDrawStaticText.fill(Qt::white);
+ {
+ QPainter p(&imageDrawStaticText);
+ p.rotate(33.0);
+ p.scale(0.5, 0.7);
+
+ QStaticText text("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ text.setTextFormat(Qt::PlainText);
+
+ p.drawStaticText(QPointF(0, 0), text);
+
+ p.scale(7.0, 5.0);
+ p.drawStaticText(QPointF(0, 0), text);
+ }
+
+#if defined(DEBUG_SAVE_IMAGE)
+ imageDrawText.save("transformationChanged_imageDrawText.png");
+ imageDrawStaticText.save("transformationChanged_imageDrawStaticText.png");
+#endif
+
+ QCOMPARE(imageDrawStaticText, imageDrawText);
+}
+
+QTEST_MAIN(tst_QStaticText)
+#include "tst_qstatictext.moc"
diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp
index c9b3436..9c9524a 100644
--- a/tests/auto/qstring/tst_qstring.cpp
+++ b/tests/auto/qstring/tst_qstring.cpp
@@ -120,6 +120,7 @@ private slots:
void operator_eqeq_nullstring();
void operator_smaller();
void insert();
+ void simplified_data();
void simplified();
void trimmed();
void toLower();
@@ -1592,16 +1593,51 @@ void tst_QString::trimmed()
QCOMPARE(a.trimmed(),(QString)"a");
}
+void tst_QString::simplified_data()
+{
+ QTest::addColumn<QString>("full" );
+ QTest::addColumn<QString>("simple" );
+
+ QTest::newRow("null") << QString() << QString();
+ QTest::newRow("empty") << "" << "";
+ QTest::newRow("one char") << "a" << "a";
+ QTest::newRow("one word") << "foo" << "foo";
+ QTest::newRow("chars trivial") << "a b" << "a b";
+ QTest::newRow("words trivial") << "foo bar" << "foo bar";
+ QTest::newRow("allspace") << " \t\v " << "";
+ QTest::newRow("char trailing") << "a " << "a";
+ QTest::newRow("char trailing tab") << "a\t" << "a";
+ QTest::newRow("char multitrailing") << "a " << "a";
+ QTest::newRow("char multitrailing tab") << "a \t" << "a";
+ QTest::newRow("char leading") << " a" << "a";
+ QTest::newRow("char leading tab") << "\ta" << "a";
+ QTest::newRow("char multileading") << " a" << "a";
+ QTest::newRow("char multileading tab") << "\t a" << "a";
+ QTest::newRow("chars apart") << "a b" << "a b";
+ QTest::newRow("words apart") << "foo bar" << "foo bar";
+ QTest::newRow("enclosed word") << " foo \t " << "foo";
+ QTest::newRow("enclosed chars apart") << " a b " << "a b";
+ QTest::newRow("enclosed words apart") << " foo bar " << "foo bar";
+ QTest::newRow("chars apart posttab") << "a \tb" << "a b";
+ QTest::newRow("chars apart pretab") << "a\t b" << "a b";
+ QTest::newRow("many words") << " just some random\ttext here" << "just some random text here";
+}
+
void tst_QString::simplified()
{
- QString j;
- j.simplified();
+ QFETCH(QString, full);
+ QFETCH(QString, simple);
- QString a;
- a = "a ";
- QCOMPARE(a.simplified(),(QString)"a");
- a=" a b ";
- QCOMPARE(a.simplified(),(QString)"a b");
+ QString result = full.simplified();
+ if (simple.isNull()) {
+ QVERIFY2(result.isNull(), qPrintable("'" + full + "' did not yield null: " + result));
+ } else if (simple.isEmpty()) {
+ QVERIFY2(result.isEmpty() && !result.isNull(), qPrintable("'" + full + "' did not yield empty: " + result));
+ } else {
+ QCOMPARE(result, simple);
+ if (full == simple)
+ QVERIFY(result.isSharedWith(full));
+ }
}
void tst_QString::insert()
diff --git a/tests/auto/qvideowidget/qvideowidget.pro b/tests/auto/qvideowidget/qvideowidget.pro
new file mode 100644
index 0000000..ca0fc24
--- /dev/null
+++ b/tests/auto/qvideowidget/qvideowidget.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+
+SOURCES = tst_qvideowidget.cpp
+
+QT = core gui multimedia
+
diff --git a/tests/auto/qvideowidget/tst_qvideowidget.cpp b/tests/auto/qvideowidget/tst_qvideowidget.cpp
new file mode 100644
index 0000000..f703055
--- /dev/null
+++ b/tests/auto/qvideowidget/tst_qvideowidget.cpp
@@ -0,0 +1,1600 @@
+/****************************************************************************
+**
+** 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 <QtMultimedia/qvideowidget.h>
+
+#include <QtMultimedia/qmediaobject.h>
+#include <QtMultimedia/qmediaservice.h>
+#include <QtMultimedia/private/qpaintervideosurface_p.h>
+#include <QtMultimedia/qvideooutputcontrol.h>
+#include <QtMultimedia/qvideowindowcontrol.h>
+#include <QtMultimedia/qvideowidgetcontrol.h>
+#include <QtMultimedia/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(QVideoWidget::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(QVideoWidget::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(); }
+
+ QVideoWidget::AspectRatioMode aspectRatioMode() const { return m_aspectRatioMode; }
+ void setAspectRatioMode(QVideoWidget::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;
+ QVideoWidget::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(QVideoWidget::KeepAspectRatio)
+ , m_fullScreen(false)
+ {
+ }
+
+ bool isFullScreen() const { return m_fullScreen; }
+ void setFullScreen(bool fullScreen) { emit fullScreenChanged(m_fullScreen = fullScreen); }
+
+ QVideoWidget::AspectRatioMode aspectRatioMode() const { return m_aspectRatioMode; }
+ void setAspectRatioMode(QVideoWidget::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;
+ QVideoWidget::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(QVideoWidget::IgnoreAspectRatio);
+ QCOMPARE(widget.aspectRatioMode(), QVideoWidget::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(QVideoWidget::IgnoreAspectRatio);
+ QCOMPARE(widget.aspectRatioMode(), QVideoWidget::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(QVideoWidget::IgnoreAspectRatio);
+
+ QVideoWidget widget;
+ widget.setMediaObject(&object);
+ widget.setWindowFlags(Qt::X11BypassWindowManagerHint);
+
+ // Test the aspect ratio defaults to keeping the aspect ratio.
+ QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio);
+
+ // Test the control has been informed of the aspect ratio change, post show.
+ widget.show();
+ QTest::qWaitForWindowShown(&widget);
+ QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio);
+ QCOMPARE(object.testService->windowControl->aspectRatioMode(), QVideoWidget::KeepAspectRatio);
+
+ // Test an aspect ratio change is enforced immediately while visible.
+ widget.setAspectRatioMode(QVideoWidget::IgnoreAspectRatio);
+ QCOMPARE(widget.aspectRatioMode(), QVideoWidget::IgnoreAspectRatio);
+ QCOMPARE(object.testService->windowControl->aspectRatioMode(), QVideoWidget::IgnoreAspectRatio);
+
+ // Test an aspect ratio set while not visible is respected.
+ widget.hide();
+ widget.setAspectRatioMode(QVideoWidget::KeepAspectRatio);
+ QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio);
+ widget.show();
+ QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio);
+ QCOMPARE(object.testService->windowControl->aspectRatioMode(), QVideoWidget::KeepAspectRatio);
+}
+
+void tst_QVideoWidget::aspectRatioWidgetControl()
+{
+ QtTestVideoObject object(0, new QtTestWidgetControl, 0);
+ object.testService->widgetControl->setAspectRatioMode(QVideoWidget::IgnoreAspectRatio);
+
+ QVideoWidget widget;
+ widget.setMediaObject(&object);
+ widget.setWindowFlags(Qt::X11BypassWindowManagerHint);
+
+ // Test the aspect ratio defaults to keeping the aspect ratio.
+ QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio);
+
+ // Test the control has been informed of the aspect ratio change, post show.
+ widget.show();
+ QTest::qWaitForWindowShown(&widget);
+ QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio);
+ QCOMPARE(object.testService->widgetControl->aspectRatioMode(), QVideoWidget::KeepAspectRatio);
+
+ // Test an aspect ratio change is enforced immediately while visible.
+ widget.setAspectRatioMode(QVideoWidget::IgnoreAspectRatio);
+ QCOMPARE(widget.aspectRatioMode(), QVideoWidget::IgnoreAspectRatio);
+ QCOMPARE(object.testService->widgetControl->aspectRatioMode(), QVideoWidget::IgnoreAspectRatio);
+
+ // Test an aspect ratio set while not visible is respected.
+ widget.hide();
+ widget.setAspectRatioMode(QVideoWidget::KeepAspectRatio);
+ QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio);
+ widget.show();
+ QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio);
+ QCOMPARE(object.testService->widgetControl->aspectRatioMode(), QVideoWidget::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(), QVideoWidget::KeepAspectRatio);
+
+ // Test the control has been informed of the aspect ratio change, post show.
+ widget.show();
+ QTest::qWaitForWindowShown(&widget);
+ QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio);
+
+ // Test an aspect ratio change is enforced immediately while visible.
+ widget.setAspectRatioMode(QVideoWidget::IgnoreAspectRatio);
+ QCOMPARE(widget.aspectRatioMode(), QVideoWidget::IgnoreAspectRatio);
+
+ // Test an aspect ratio set while not visible is respected.
+ widget.hide();
+ widget.setAspectRatioMode(QVideoWidget::KeepAspectRatio);
+ QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio);
+ widget.show();
+ QCOMPARE(widget.aspectRatioMode(), QVideoWidget::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);
+
+ QCoreApplication::processEvents(QEventLoop::AllEvents);
+
+ QCOMPARE(surface->isActive(), true);
+ QCOMPARE(surface->isReady(), true);
+}
+
+QTEST_MAIN(tst_QVideoWidget)
+
+#include "tst_qvideowidget.moc"
diff --git a/tests/benchmarks/qvector/main.cpp b/tests/benchmarks/corelib/tools/qvector/main.cpp
index 6393eda..6393eda 100644
--- a/tests/benchmarks/qvector/main.cpp
+++ b/tests/benchmarks/corelib/tools/qvector/main.cpp
diff --git a/tests/benchmarks/qvector/outofline.cpp b/tests/benchmarks/corelib/tools/qvector/outofline.cpp
index e8d036e..e8d036e 100644
--- a/tests/benchmarks/qvector/outofline.cpp
+++ b/tests/benchmarks/corelib/tools/qvector/outofline.cpp
diff --git a/tests/benchmarks/qvector/qrawvector.h b/tests/benchmarks/corelib/tools/qvector/qrawvector.h
index 1824d20..1824d20 100644
--- a/tests/benchmarks/qvector/qrawvector.h
+++ b/tests/benchmarks/corelib/tools/qvector/qrawvector.h
diff --git a/tests/benchmarks/qvector/qvector.pro b/tests/benchmarks/corelib/tools/qvector/qvector.pro
index adb30c9..adb30c9 100644
--- a/tests/benchmarks/qvector/qvector.pro
+++ b/tests/benchmarks/corelib/tools/qvector/qvector.pro
diff --git a/tests/benchmarks/corelib/tools/tools.pro b/tests/benchmarks/corelib/tools/tools.pro
index 12c23fc..681a6c6 100644
--- a/tests/benchmarks/corelib/tools/tools.pro
+++ b/tests/benchmarks/corelib/tools/tools.pro
@@ -7,4 +7,5 @@ SUBDIRS = \
qregexp \
qstring \
qstringbuilder \
- qstringlist
+ qstringlist \
+ qvector
diff --git a/tests/benchmarks/declarative/painting/data/63x63.png b/tests/benchmarks/declarative/painting/data/63x63.png
new file mode 100644
index 0000000..d9efda8
--- /dev/null
+++ b/tests/benchmarks/declarative/painting/data/63x63.png
Binary files differ
diff --git a/tests/benchmarks/declarative/painting/data/63x63_opaque.png b/tests/benchmarks/declarative/painting/data/63x63_opaque.png
new file mode 100644
index 0000000..d142908
--- /dev/null
+++ b/tests/benchmarks/declarative/painting/data/63x63_opaque.png
Binary files differ
diff --git a/tests/benchmarks/declarative/painting/data/64x64.png b/tests/benchmarks/declarative/painting/data/64x64.png
new file mode 100644
index 0000000..b149f33
--- /dev/null
+++ b/tests/benchmarks/declarative/painting/data/64x64.png
Binary files differ
diff --git a/tests/benchmarks/declarative/painting/data/64x64_opaque.png b/tests/benchmarks/declarative/painting/data/64x64_opaque.png
new file mode 100644
index 0000000..94c07f3
--- /dev/null
+++ b/tests/benchmarks/declarative/painting/data/64x64_opaque.png
Binary files differ
diff --git a/tests/benchmarks/declarative/painting/paintbenchmark.cpp b/tests/benchmarks/declarative/painting/paintbenchmark.cpp
index d6a873c..9231b67 100644
--- a/tests/benchmarks/declarative/painting/paintbenchmark.cpp
+++ b/tests/benchmarks/declarative/painting/paintbenchmark.cpp
@@ -48,10 +48,7 @@
#include <QVBoxLayout>
#include <QTime>
#include <QDebug>
-
-#ifdef HAVE_STATICTEXT
-#include <private/qstatictext_p.h>
-#endif
+#include <QStaticText>
int iterations = 20;
const int count = 600;
@@ -60,6 +57,7 @@ const int spacing = 36;
QSizeF size(1000, 800);
const qreal lineWidth = 1000;
QString strings[lines];
+QGLWidget *testWidget = 0;
void paint_QTextLayout(QPainter &p, bool useCache)
{
@@ -105,7 +103,6 @@ void paint_QTextLayout_cache(QPainter &p)
paint_QTextLayout(p, true);
}
-#ifdef HAVE_STATICTEXT
void paint_QStaticText(QPainter &p, bool useOptimizations)
{
static QStaticText *staticText[lines];
@@ -113,7 +110,10 @@ void paint_QStaticText(QPainter &p, bool useOptimizations)
if (first) {
for (int i = 0; i < lines; ++i) {
staticText[i] = new QStaticText(strings[i]);
- staticText[i]->setUseBackendOptimizations(useOptimizations);
+ if (useOptimizations)
+ staticText[i]->setPerformanceHint(QStaticText::AggressiveCaching);
+ else
+ staticText[i]->setPerformanceHint(QStaticText::ModerateCaching);
}
first = false;
}
@@ -133,7 +133,6 @@ void paint_QStaticText_optimizations(QPainter &p)
{
paint_QStaticText(p, true);
}
-#endif
void paint_QPixmapCachedText(QPainter &p)
{
@@ -160,6 +159,15 @@ void paint_QPixmapCachedText(QPainter &p)
void paint_RoundedRect(QPainter &p)
{
+ static bool first = true;
+ if (first) {
+ if (testWidget) {
+ QGLFormat format = testWidget->format();
+ if (!format.sampleBuffers())
+ qWarning() << "Cannot paint antialiased rounded rect without sampleBuffers";
+ }
+ first = false;
+ }
p.setRenderHint(QPainter::Antialiasing, true);
p.setPen(Qt::black);
p.setBrush(Qt::red);
@@ -174,27 +182,101 @@ void paint_RoundedRect(QPainter &p)
void paint_QPixmapCachedRoundedRect(QPainter &p)
{
static bool first = true;
- static QPixmap cacheRect[lines];
+ static QPixmap cacheRect;
if (first) {
- for (int i = 0; i < lines; ++i) {
- QSize size((i+1)*50, spacing-1);
- cacheRect[i] = QPixmap(size);
- cacheRect[i].fill(Qt::transparent);
- QPainter paint(&cacheRect[i]);
- paint.setRenderHint(QPainter::Antialiasing);
- paint.setPen(Qt::black);
- paint.setBrush(Qt::red);
- paint.drawRoundedRect(QRect(QPoint(0,0), size), 8, 8);
+ const int pw = 0;
+ const int radius = 8;
+ cacheRect = QPixmap(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2);
+ cacheRect.fill(Qt::transparent);
+ QPainter paint(&cacheRect);
+ paint.setRenderHint(QPainter::Antialiasing);
+ paint.setPen(Qt::black);
+ paint.setBrush(Qt::red);
+ if (pw%2)
+ paint.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, cacheRect.width()-(pw+1), cacheRect.height()-(pw+1)), radius, radius);
+ else
+ paint.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, cacheRect.width()-pw, cacheRect.height()-pw), radius, radius);
+
+ first = false;
+ }
+ for (int i = 0; i < count; i++) {
+ for (int j = 0; j < lines; ++j) {
+ QSize size((j+1)*50, spacing-1);
+
+ p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, true);
+
+ const int pw = 0;
+
+ int xOffset = (cacheRect.width()-1)/2;
+ int yOffset = (cacheRect.height()-1)/2;
+
+ QMargins margins(xOffset, yOffset, xOffset, yOffset);
+ QTileRules rules(Qt::StretchTile, Qt::StretchTile);
+ //NOTE: even though our item may have qreal-based width and height, qDrawBorderPixmap only supports QRects
+ qDrawBorderPixmap(&p, QRect(-pw/2, j*spacing-pw/2, size.width()+pw, size.height()+pw), margins, cacheRect, cacheRect.rect(), margins, rules);
}
+ }
+}
+
+void paint_QPixmap63x63_opaque(QPainter &p)
+{
+ static bool first = true;
+ static QPixmap pm;
+ if (first) {
+ pm.load("data/63x63_opaque.png");
first = false;
}
for (int i = 0; i < count; i++) {
for (int j = 0; j < lines; ++j) {
- p.drawPixmap(0,j*spacing,cacheRect[j]);
+ p.drawPixmap((i%10) * 64,j*spacing, pm);
}
}
}
+void paint_QPixmap64x64_opaque(QPainter &p)
+{
+ static bool first = true;
+ static QPixmap pm;
+ if (first) {
+ pm.load("data/64x64_opaque.png");
+ first = false;
+ }
+ for (int i = 0; i < count; i++) {
+ for (int j = 0; j < lines; ++j) {
+ p.drawPixmap((i%10) * 64,j*spacing, pm);
+ }
+ }
+}
+
+void paint_QPixmap63x63(QPainter &p)
+{
+ static bool first = true;
+ static QPixmap pm;
+ if (first) {
+ pm.load("data/63x63.png");
+ first = false;
+ }
+ for (int i = 0; i < count; i++) {
+ for (int j = 0; j < lines; ++j) {
+ p.drawPixmap((i%10) * 64,j*spacing, pm);
+ }
+ }
+}
+
+void paint_QPixmap64x64(QPainter &p)
+{
+ static bool first = true;
+ static QPixmap pm;
+ if (first) {
+ pm.load("data/64x64.png");
+ first = false;
+ }
+ for (int i = 0; i < count; i++) {
+ for (int j = 0; j < lines; ++j) {
+ p.drawPixmap((i%10) * 64,j*spacing, pm);
+ }
+ }
+}
typedef void(*PaintFunc)(QPainter &);
struct {
@@ -203,13 +285,15 @@ struct {
} funcs[] = {
{ "QTextLayoutNoCache", &paint_QTextLayout_noCache },
{ "QTextLayoutWithCache", &paint_QTextLayout_cache },
-#ifdef HAVE_STATICTEXT
{ "QStaticTextNoBackendOptimizations", &paint_QStaticText_noOptimizations },
{ "QStaticTextWithBackendOptimizations", &paint_QStaticText_optimizations },
-#endif
{ "CachedText", &paint_QPixmapCachedText },
{ "RoundedRect", &paint_RoundedRect },
{ "CachedRoundedRect", &paint_QPixmapCachedRoundedRect },
+ { "QPixmap63x63_opaque", &paint_QPixmap63x63_opaque },
+ { "QPixmap64x64_opaque", &paint_QPixmap64x64_opaque },
+ { "QPixmap63x63", &paint_QPixmap63x63 },
+ { "QPixmap64x64", &paint_QPixmap64x64 },
{ 0, 0 }
};
@@ -231,7 +315,7 @@ public:
void paintEvent(QPaintEvent *) {
static int last = 0;
static bool firstRun = true;
- if (firstRun == 0) {
+ if (firstRun) {
timer.start();
firstRun = false;
} else {
@@ -297,11 +381,11 @@ int main(int argc, char *argv[])
QWidget w;
QGLFormat format = QGLFormat::defaultFormat();
format.setSampleBuffers(sampleBuffers);
- MyGLWidget *glw = new MyGLWidget(format);
- glw->setAutoFillBackground(false);
+ testWidget = new MyGLWidget(format);
+ testWidget->setAutoFillBackground(false);
QVBoxLayout *layout = new QVBoxLayout(&w);
w.setLayout(layout);
- layout->addWidget(glw);
+ layout->addWidget(testWidget);
w.showFullScreen();
app.exec();
diff --git a/tests/benchmarks/gui/painting/painting.pro b/tests/benchmarks/gui/painting/painting.pro
index 878567d..2c042b5 100644
--- a/tests/benchmarks/gui/painting/painting.pro
+++ b/tests/benchmarks/gui/painting/painting.pro
@@ -2,4 +2,5 @@ TEMPLATE = subdirs
SUBDIRS = \
qpainter \
qregion \
- qtransform
+ qtransform \
+ qtracebench
diff --git a/tests/benchmarks/gui/painting/qtracebench/qtracebench.pro b/tests/benchmarks/gui/painting/qtracebench/qtracebench.pro
new file mode 100644
index 0000000..56ec8bb
--- /dev/null
+++ b/tests/benchmarks/gui/painting/qtracebench/qtracebench.pro
@@ -0,0 +1,10 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = tst_qtracebench
+
+INCLUDEPATH += . $$QT_SOURCE_TREE/src/3rdparty/harfbuzz/src
+
+RESOURCES += qtracebench.qrc
+
+SOURCES += tst_qtracebench.cpp
+
diff --git a/tests/benchmarks/gui/painting/qtracebench/qtracebench.qrc b/tests/benchmarks/gui/painting/qtracebench/qtracebench.qrc
new file mode 100644
index 0000000..5569550
--- /dev/null
+++ b/tests/benchmarks/gui/painting/qtracebench/qtracebench.qrc
@@ -0,0 +1,10 @@
+<RCC>
+ <qresource>
+ <file>traces/basicdrawing.trace</file>
+ <file>traces/webkit.trace</file>
+ <file>traces/textedit.trace</file>
+ <file>traces/creator.trace</file>
+ <file>traces/qmlphoneconcept.trace</file>
+ <file>traces/qmlsamegame.trace</file>
+ </qresource>
+</RCC>
diff --git a/tests/benchmarks/gui/painting/qtracebench/traces/basicdrawing.trace b/tests/benchmarks/gui/painting/qtracebench/traces/basicdrawing.trace
new file mode 100644
index 0000000..0241d08
--- /dev/null
+++ b/tests/benchmarks/gui/painting/qtracebench/traces/basicdrawing.trace
Binary files differ
diff --git a/tests/benchmarks/gui/painting/qtracebench/traces/creator.trace b/tests/benchmarks/gui/painting/qtracebench/traces/creator.trace
new file mode 100644
index 0000000..55ee9e1
--- /dev/null
+++ b/tests/benchmarks/gui/painting/qtracebench/traces/creator.trace
Binary files differ
diff --git a/tests/benchmarks/gui/painting/qtracebench/traces/qmlphoneconcept.trace b/tests/benchmarks/gui/painting/qtracebench/traces/qmlphoneconcept.trace
new file mode 100644
index 0000000..835ebfa
--- /dev/null
+++ b/tests/benchmarks/gui/painting/qtracebench/traces/qmlphoneconcept.trace
Binary files differ
diff --git a/tests/benchmarks/gui/painting/qtracebench/traces/qmlsamegame.trace b/tests/benchmarks/gui/painting/qtracebench/traces/qmlsamegame.trace
new file mode 100644
index 0000000..1d76195
--- /dev/null
+++ b/tests/benchmarks/gui/painting/qtracebench/traces/qmlsamegame.trace
Binary files differ
diff --git a/tests/benchmarks/gui/painting/qtracebench/traces/textedit.trace b/tests/benchmarks/gui/painting/qtracebench/traces/textedit.trace
new file mode 100644
index 0000000..998716d
--- /dev/null
+++ b/tests/benchmarks/gui/painting/qtracebench/traces/textedit.trace
Binary files differ
diff --git a/tests/benchmarks/gui/painting/qtracebench/traces/webkit.trace b/tests/benchmarks/gui/painting/qtracebench/traces/webkit.trace
new file mode 100644
index 0000000..43e752d
--- /dev/null
+++ b/tests/benchmarks/gui/painting/qtracebench/traces/webkit.trace
Binary files differ
diff --git a/tests/benchmarks/gui/painting/qtracebench/tst_qtracebench.cpp b/tests/benchmarks/gui/painting/qtracebench/tst_qtracebench.cpp
new file mode 100644
index 0000000..ff2633d
--- /dev/null
+++ b/tests/benchmarks/gui/painting/qtracebench/tst_qtracebench.cpp
@@ -0,0 +1,262 @@
+/****************************************************************************
+**
+** 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 <QtGui>
+
+#include <private/qpaintengineex_p.h>
+#include <private/qpaintbuffer_p.h>
+
+//TESTED_FILES=
+
+class ReplayWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ ReplayWidget(const QString &filename);
+
+ void paintEvent(QPaintEvent *event);
+ void resizeEvent(QResizeEvent *event);
+
+ bool done() const { return m_done; }
+ qreal result() const { return m_result; }
+
+public slots:
+ void updateRect();
+
+public:
+ QList<QRegion> updates;
+ QPaintBuffer buffer;
+
+ int currentFrame;
+ int currentIteration;
+ QTime timer;
+
+ QList<uint> visibleUpdates;
+ QList<uint> iterationTimes;
+ QString filename;
+
+ bool m_done;
+ qreal m_result;
+
+ uint m_total;
+};
+
+void ReplayWidget::updateRect()
+{
+ if (!visibleUpdates.isEmpty())
+ update(updates.at(visibleUpdates.at(currentFrame)));
+}
+
+void ReplayWidget::paintEvent(QPaintEvent *)
+{
+ if (m_done)
+ return;
+
+ QPainter p(this);
+
+ // if partial updates don't work
+ // p.setClipRegion(frames.at(currentFrame).updateRegion);
+
+ buffer.draw(&p, visibleUpdates.at(currentFrame));
+
+ ++currentFrame;
+ if (currentFrame >= visibleUpdates.size()) {
+ currentFrame = 0;
+ ++currentIteration;
+
+ uint currentElapsed = timer.isNull() ? 0 : timer.elapsed();
+ timer.restart();
+
+ m_total += currentElapsed;
+
+ // warm up for at most 5 iterations or half a second
+ if (currentIteration >= 5 || m_total >= 500) {
+ iterationTimes << currentElapsed;
+
+ if (iterationTimes.size() >= 5) {
+ qreal mean = 0;
+ qreal stddev = 0;
+ uint min = INT_MAX;
+
+ for (int i = 0; i < iterationTimes.size(); ++i) {
+ mean += iterationTimes.at(i);
+ min = qMin(min, iterationTimes.at(i));
+ }
+
+ mean /= qreal(iterationTimes.size());
+
+ for (int i = 0; i < iterationTimes.size(); ++i) {
+ qreal delta = iterationTimes.at(i) - mean;
+ stddev += delta * delta;
+ }
+
+ stddev = qSqrt(stddev / iterationTimes.size());
+
+ qSort(iterationTimes.begin(), iterationTimes.end());
+ uint median = iterationTimes.at(iterationTimes.size() / 2);
+
+ stddev = 100 * stddev / mean;
+ // do 100 iterations, break earlier if we spend more than 5 seconds or have a low std deviation after 2 seconds
+ if (iterationTimes.size() >= 100 || m_total >= 5000 || (m_total >= 2000 && stddev < 4)) {
+ printf("%s, iterations: %d, frames: %d, min(ms): %d, median(ms): %d, stddev: %f %%, max(fps): %f\n", qPrintable(filename),
+ iterationTimes.size(), visibleUpdates.size(), min, median, stddev, 1000. * visibleUpdates.size() / min);
+ m_result = min;
+ m_done = true;
+ return;
+ }
+ }
+ }
+ }
+}
+
+void ReplayWidget::resizeEvent(QResizeEvent *event)
+{
+ visibleUpdates.clear();
+
+ QRect bounds = rect();
+ for (int i = 0; i < updates.size(); ++i) {
+ if (updates.at(i).intersects(bounds))
+ visibleUpdates << i;
+ }
+
+ if (visibleUpdates.size() != updates.size())
+ printf("Warning: skipped %d frames due to limited resolution\n", updates.size() - visibleUpdates.size());
+
+}
+
+ReplayWidget::ReplayWidget(const QString &filename_)
+ : currentFrame(0)
+ , currentIteration(0)
+ , filename(filename_)
+ , m_done(false)
+ , m_result(0)
+ , m_total(0)
+{
+ setWindowTitle(filename);
+ QFile file(filename);
+
+ if (!file.open(QIODevice::ReadOnly)) {
+ printf("Failed to load input file '%s'\n", qPrintable(filename_));
+ return;
+ }
+
+ QDataStream in(&file);
+
+ char *data;
+ uint size;
+ in.readBytes(data, size);
+ bool isTraceFile = size >= 7 && qstrncmp(data, "qttrace", 7) == 0;
+ uint version = 0;
+ if (size == 9 && qstrncmp(data, "qttraceV2", 9) == 0) {
+ in.setFloatingPointPrecision(QDataStream::SinglePrecision);
+ in >> version;
+ }
+
+ delete [] data;
+ if (!isTraceFile) {
+ printf("File '%s' is not a trace file\n", qPrintable(filename_));
+ return;
+ }
+
+ in >> buffer >> updates;
+
+ resize(buffer.boundingRect().size().toSize());
+
+ setAutoFillBackground(false);
+ setAttribute(Qt::WA_NoSystemBackground);
+}
+
+
+class tst_QTraceBench : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void trace();
+ void trace_data();
+};
+
+static const QLatin1String prefix(":/traces/");
+
+void tst_QTraceBench::trace_data()
+{
+ QTest::addColumn<QString>("filename");
+
+ QTest::newRow("basicdrawing") << (prefix + "basicdrawing.trace");
+ QTest::newRow("webkit") << (prefix + "webkit.trace");
+ QTest::newRow("creator") << (prefix + "creator.trace");
+ QTest::newRow("textedit") << (prefix + "textedit.trace");
+ QTest::newRow("qmlphoneconcept") << (prefix + "qmlphoneconcept.trace");
+ QTest::newRow("qmlsamegame") << (prefix + "qmlsamegame.trace");
+}
+
+void tst_QTraceBench::trace()
+{
+ QFETCH(QString, filename);
+
+ QFile file(filename);
+ if (!file.exists()) {
+ qWarning() << "Missing file" << filename;
+ return;
+ }
+
+ ReplayWidget widget(filename);
+
+ if (widget.updates.isEmpty()) {
+ qWarning() << "No trace updates" << filename;
+ return;
+ }
+
+ widget.show();
+ QTest::qWaitForWindowShown(&widget);
+
+ while (!widget.done()) {
+ widget.updateRect();
+ QApplication::processEvents();
+ }
+
+ QTest::setBenchmarkResult(widget.result(), QTest::WalltimeMilliseconds);
+}
+
+QTEST_MAIN(tst_QTraceBench)
+#include "tst_qtracebench.moc"