summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2010-02-23 05:41:25 (GMT)
committerJoona Petrell <joona.t.petrell@nokia.com>2010-02-23 07:34:07 (GMT)
commit23fb8f6e4f3f6fe4ae7611de84f09cc0095e240c (patch)
tree1a750425c167e2184c565345ff76886ab1871d8c /tests
parentcb3cd645082bda7b5142ceff31e5795f2d047c39 (diff)
downloadQt-23fb8f6e4f3f6fe4ae7611de84f09cc0095e240c.zip
Qt-23fb8f6e4f3f6fe4ae7611de84f09cc0095e240c.tar.gz
Qt-23fb8f6e4f3f6fe4ae7611de84f09cc0095e240c.tar.bz2
Add missing NOTIFY signals to positioners, particles and webview
Reviewed-by: Aaron Kennedy
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qmlgraphicsparticles/data/particlemotion.qml33
-rw-r--r--tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp88
-rw-r--r--tests/auto/declarative/qmlgraphicspositioners/data/propertychanges.qml39
-rw-r--r--tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp59
-rw-r--r--tests/auto/declarative/qmlgraphicswebview/data/propertychanges.qml33
-rw-r--r--tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp109
6 files changed, 360 insertions, 1 deletions
diff --git a/tests/auto/declarative/qmlgraphicsparticles/data/particlemotion.qml b/tests/auto/declarative/qmlgraphicsparticles/data/particlemotion.qml
new file mode 100644
index 0000000..ace61fe
--- /dev/null
+++ b/tests/auto/declarative/qmlgraphicsparticles/data/particlemotion.qml
@@ -0,0 +1,33 @@
+import Qt 4.6
+Rectangle {
+ width: 240
+ height: 320
+ color: "black"
+ Particles {
+ objectName: "particles"
+ anchors.fill: parent
+ width: 1
+ height: 1
+ source: "particle.png"
+ lifeSpan: 5000
+ count: 200
+ angle: 270
+ angleDeviation: 45
+ velocity: 50
+ velocityDeviation: 30
+ ParticleMotionGravity {
+ objectName: "motionGravity"
+ yattractor: 1000
+ xattractor: 0
+ acceleration: 25
+ }
+ }
+ resources: [
+ ParticleMotionWander {
+ objectName: "motionWander"
+ xvariance: 30
+ yvariance: 30
+ pace: 100
+ }
+ ]
+} \ No newline at end of file
diff --git a/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp b/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp
index 195c367..9436772 100644
--- a/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp
+++ b/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
#include <QtTest/QtTest>
+#include <QtTest/QSignalSpy>
#include <qmlview.h>
#include <private/qmlgraphicsparticles_p.h>
@@ -50,6 +51,8 @@ public:
private slots:
void properties();
+ void motionGravity();
+ void motionWander();
void runs();
private:
QmlView *createView(const QString &filename);
@@ -98,6 +101,91 @@ void tst_QmlGraphicsParticles::properties()
QCOMPARE(particles->emissionRate(), 12);
}
+void tst_QmlGraphicsParticles::motionGravity()
+{
+ QmlView *canvas = createView(SRCDIR "/data/particlemotion.qml");
+ QVERIFY(canvas->rootObject());
+ QmlGraphicsParticles* particles = canvas->rootObject()->findChild<QmlGraphicsParticles*>("particles");
+ QVERIFY(particles);
+
+ QmlGraphicsParticleMotionGravity* motionGravity = canvas->rootObject()->findChild<QmlGraphicsParticleMotionGravity*>("motionGravity");
+ QCOMPARE(particles->motion(), motionGravity);
+
+ QSignalSpy xattractorSpy(motionGravity, SIGNAL(xattractorChanged()));
+ QSignalSpy yattractorSpy(motionGravity, SIGNAL(yattractorChanged()));
+ QSignalSpy accelerationSpy(motionGravity, SIGNAL(accelerationChanged()));
+
+ QCOMPARE(motionGravity->xAttractor(), 0.0);
+ QCOMPARE(motionGravity->yAttractor(), 1000.0);
+ QCOMPARE(motionGravity->acceleration(), 25.0);
+
+ motionGravity->setXAttractor(20.0);
+ motionGravity->setYAttractor(10.0);
+ motionGravity->setAcceleration(10.0);
+
+ QCOMPARE(motionGravity->xAttractor(), 20.0);
+ QCOMPARE(motionGravity->yAttractor(), 10.0);
+ QCOMPARE(motionGravity->acceleration(), 10.0);
+
+ QCOMPARE(xattractorSpy.count(), 1);
+ QCOMPARE(yattractorSpy.count(), 1);
+ QCOMPARE(accelerationSpy.count(), 1);
+
+ motionGravity->setXAttractor(20.0);
+ motionGravity->setYAttractor(10.0);
+ motionGravity->setAcceleration(10.0);
+
+ QCOMPARE(xattractorSpy.count(), 1);
+ QCOMPARE(yattractorSpy.count(), 1);
+ QCOMPARE(accelerationSpy.count(), 1);
+}
+
+void tst_QmlGraphicsParticles::motionWander()
+{
+ QmlView *canvas = createView(SRCDIR "/data/particlemotion.qml");
+ QVERIFY(canvas->rootObject());
+ QmlGraphicsParticles* particles = canvas->rootObject()->findChild<QmlGraphicsParticles*>("particles");
+ QVERIFY(particles);
+
+ QSignalSpy motionSpy(particles, SIGNAL(motionChanged()));
+ QmlGraphicsParticleMotionWander* motionWander = canvas->rootObject()->findChild<QmlGraphicsParticleMotionWander*>("motionWander");
+
+ particles->setMotion(motionWander);
+ QCOMPARE(particles->motion(),motionWander);
+ QCOMPARE(motionSpy.count(), 1);
+
+ particles->setMotion(motionWander);
+ QCOMPARE(motionSpy.count(), 1);
+
+ QSignalSpy xvarianceSpy(motionWander, SIGNAL(xvarianceChanged()));
+ QSignalSpy yvarianceSpy(motionWander, SIGNAL(yvarianceChanged()));
+ QSignalSpy paceSpy(motionWander, SIGNAL(paceChanged()));
+
+ QCOMPARE(motionWander->xVariance(), 30.0);
+ QCOMPARE(motionWander->yVariance(), 30.0);
+ QCOMPARE(motionWander->pace(), 100.0);
+
+ motionWander->setXVariance(20.0);
+ motionWander->setYVariance(10.0);
+ motionWander->setPace(10.0);
+
+ QCOMPARE(motionWander->xVariance(), 20.0);
+ QCOMPARE(motionWander->yVariance(), 10.0);
+ QCOMPARE(motionWander->pace(), 10.0);
+
+ QCOMPARE(xvarianceSpy.count(), 1);
+ QCOMPARE(yvarianceSpy.count(), 1);
+ QCOMPARE(paceSpy.count(), 1);
+
+ motionWander->setXVariance(20.0);
+ motionWander->setYVariance(10.0);
+ motionWander->setPace(10.0);
+
+ QCOMPARE(xvarianceSpy.count(), 1);
+ QCOMPARE(yvarianceSpy.count(), 1);
+ QCOMPARE(paceSpy.count(), 1);
+}
+
void tst_QmlGraphicsParticles::runs()
{
QmlView *canvas = createView(SRCDIR "/data/particles.qml");
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/propertychanges.qml b/tests/auto/declarative/qmlgraphicspositioners/data/propertychanges.qml
new file mode 100644
index 0000000..c3dc7bf
--- /dev/null
+++ b/tests/auto/declarative/qmlgraphicspositioners/data/propertychanges.qml
@@ -0,0 +1,39 @@
+import Qt 4.6
+
+Grid {
+ id: myGrid
+
+ width: 270
+ height: 270
+ x: 3
+ y: 3
+ columns: 4
+ spacing: 3
+
+ add: columnTransition
+ move: columnTransition
+
+ Repeater {
+ model: 20
+ Rectangle { color: "black"; width: 50; height: 50 }
+ }
+
+ data: [
+ Transition {
+ id: rowTransition
+ objectName: "rowTransition"
+ NumberAnimation {
+ properties: "x,y";
+ easing: "easeOutInCubic"
+ }
+ },
+ Transition {
+ id: columnTransition
+ objectName: "columnTransition"
+ NumberAnimation {
+ properties: "x,y";
+ easing: "easeOutInCubic"
+ }
+ }
+ ]
+}
diff --git a/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp b/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp
index 348f59b..5089dc5 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp
+++ b/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp
@@ -42,6 +42,8 @@
#include <private/qlistmodelinterface_p.h>
#include <qmlview.h>
#include <private/qmlgraphicsrectangle_p.h>
+#include <private/qmlgraphicspositioners_p.h>
+#include <private/qmltransition_p.h>
#include <qmlexpression.h>
#include "../../../shared/util.h"
@@ -61,7 +63,7 @@ private slots:
void test_grid();
void test_grid_spacing();
void test_grid_animated();
-
+ void test_propertychanges();
void test_repeater();
private:
QmlView *createView(const QString &filename);
@@ -361,6 +363,61 @@ void tst_QmlGraphicsPositioners::test_grid_animated()
QTRY_COMPARE(five->y(), 50.0);
}
+void tst_QmlGraphicsPositioners::test_propertychanges()
+{
+ QmlView *canvas = createView("data/propertychanges.qml");
+
+ QmlGraphicsGrid *grid = qobject_cast<QmlGraphicsGrid*>(canvas->rootObject());
+ QmlTransition *rowTransition = canvas->rootObject()->findChild<QmlTransition*>("rowTransition");
+ QmlTransition *columnTransition = canvas->rootObject()->findChild<QmlTransition*>("columnTransition");
+
+ QSignalSpy addSpy(grid, SIGNAL(addChanged()));
+ QSignalSpy moveSpy(grid, SIGNAL(moveChanged()));
+ QSignalSpy columnsSpy(grid, SIGNAL(columnsChanged()));
+ QSignalSpy rowsSpy(grid, SIGNAL(rowsChanged()));
+
+ QVERIFY(grid);
+ QVERIFY(rowTransition);
+ QVERIFY(columnTransition);
+ QCOMPARE(grid->add(), columnTransition);
+ QCOMPARE(grid->move(), columnTransition);
+ QCOMPARE(grid->columns(), 4);
+ QCOMPARE(grid->rows(), -1);
+
+ grid->setAdd(rowTransition);
+ grid->setMove(rowTransition);
+ QCOMPARE(grid->add(), rowTransition);
+ QCOMPARE(grid->move(), rowTransition);
+ QCOMPARE(addSpy.count(),1);
+ QCOMPARE(moveSpy.count(),1);
+
+ grid->setAdd(rowTransition);
+ grid->setMove(rowTransition);
+ QCOMPARE(addSpy.count(),1);
+ QCOMPARE(moveSpy.count(),1);
+
+ grid->setAdd(0);
+ grid->setMove(0);
+ QCOMPARE(addSpy.count(),2);
+ QCOMPARE(moveSpy.count(),2);
+
+ grid->setColumns(-1);
+ grid->setRows(3);
+ QCOMPARE(grid->columns(), -1);
+ QCOMPARE(grid->rows(), 3);
+ QCOMPARE(columnsSpy.count(),1);
+ QCOMPARE(rowsSpy.count(),1);
+
+ grid->setColumns(-1);
+ grid->setRows(3);
+ QCOMPARE(columnsSpy.count(),1);
+ QCOMPARE(rowsSpy.count(),1);
+
+ grid->setColumns(2);
+ grid->setRows(2);
+ QCOMPARE(columnsSpy.count(),2);
+ QCOMPARE(rowsSpy.count(),2);
+}
void tst_QmlGraphicsPositioners::test_repeater()
{
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/propertychanges.qml b/tests/auto/declarative/qmlgraphicswebview/data/propertychanges.qml
new file mode 100644
index 0000000..3dd4e51
--- /dev/null
+++ b/tests/auto/declarative/qmlgraphicswebview/data/propertychanges.qml
@@ -0,0 +1,33 @@
+import Qt 4.6
+
+Item {
+ width: 240
+ height: 160
+ Grid {
+ anchors.fill: parent
+ objectName: "newWindowParent"
+ id: newWindowParent
+ }
+
+ Row {
+ anchors.fill: parent
+ id: oldWindowParent
+ objectName: "oldWindowParent"
+ }
+
+ Loader {
+ sourceComponent: webViewComponent
+ }
+ Component {
+ id: webViewComponent
+ WebView {
+ id: webView
+ objectName: "webView"
+ newWindowComponent: webViewComponent
+ newWindowParent: oldWindowParent
+ url: "basic.html"
+ renderingEnabled: true
+ pressGrabTime: 200
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp b/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp
index f3c39f8..5815e22 100644
--- a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp
+++ b/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
#include <qtest.h>
+#include <QtTest/QSignalSpy>
#include "../../../shared/util.h"
#include <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlcomponent.h>
@@ -69,6 +70,10 @@ private slots:
void javaScript();
void cleanupTestCase();
void pixelCache();
+ void newWindowParent();
+ void newWindowComponent();
+ void renderingEnabled();
+ void pressGrabTime();
private:
void checkNoErrors(const QmlComponent& component);
@@ -335,6 +340,10 @@ void tst_qmlgraphicswebview::setHtml()
QmlGraphicsWebView *wv = qobject_cast<QmlGraphicsWebView*>(component.create());
QVERIFY(wv != 0);
QCOMPARE(wv->html(),QString("<html><head></head><body><p>This is a <b>string</b> set on the WebView</p></body></html>"));
+
+ QSignalSpy spy(wv, SIGNAL(htmlChanged()));
+ wv->setHtml(QString("<html><head><title>Basic</title></head><body><p>text</p></body></html>"));
+ QCOMPARE(spy.count(),1);
}
void tst_qmlgraphicswebview::elementAreaAt()
@@ -391,6 +400,106 @@ void tst_qmlgraphicswebview::pixelCache()
QCOMPARE(wv->pixelsPainted(), expected*3); // repainted
}
+void tst_qmlgraphicswebview::newWindowParent()
+{
+ QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+ checkNoErrors(component);
+ QmlGraphicsItem *rootItem = qobject_cast<QmlGraphicsItem*>(component.create());
+ QmlGraphicsWebView *wv = rootItem->findChild<QmlGraphicsWebView*>("webView");
+ QVERIFY(rootItem != 0);
+ QVERIFY(wv != 0);
+ QTRY_COMPARE(wv->progress(), 1.0);
+
+ QmlGraphicsItem* oldWindowParent = rootItem->findChild<QmlGraphicsItem*>("oldWindowParent");
+ QCOMPARE(wv->newWindowParent(), oldWindowParent);
+ QSignalSpy newWindowParentSpy(wv, SIGNAL(newWindowParentChanged()));
+
+ QmlGraphicsItem* newWindowParent = rootItem->findChild<QmlGraphicsItem*>("newWindowParent");
+ wv->setNewWindowParent(newWindowParent);
+ QVERIFY(oldWindowParent);
+ QVERIFY(oldWindowParent->childItems().count() == 0);
+ QCOMPARE(wv->newWindowParent(), newWindowParent);
+ QCOMPARE(newWindowParentSpy.count(),1);
+
+ wv->setNewWindowParent(newWindowParent);
+ QCOMPARE(newWindowParentSpy.count(),1);
+
+ wv->setNewWindowParent(0);
+ QCOMPARE(newWindowParentSpy.count(),2);
+}
+
+void tst_qmlgraphicswebview::newWindowComponent()
+{
+ QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+ checkNoErrors(component);
+ QmlGraphicsItem *rootItem = qobject_cast<QmlGraphicsItem*>(component.create());
+ QmlGraphicsWebView *wv = rootItem->findChild<QmlGraphicsWebView*>("webView");
+ QVERIFY(rootItem != 0);
+ QVERIFY(wv != 0);
+ QTRY_COMPARE(wv->progress(), 1.0);
+
+ QmlComponent substituteComponent(&engine);
+ substituteComponent.setData("import Qt 4.6; WebView { objectName: 'newWebView'; url: 'basic.html'; }", QUrl::fromLocalFile(""));
+ QSignalSpy newWindowComponentSpy(wv, SIGNAL(newWindowComponentChanged()));
+
+ wv->setNewWindowComponent(&substituteComponent);
+ QCOMPARE(wv->newWindowComponent(), &substituteComponent);
+ QCOMPARE(newWindowComponentSpy.count(),1);
+
+ wv->setNewWindowComponent(&substituteComponent);
+ QCOMPARE(newWindowComponentSpy.count(),1);
+
+ wv->setNewWindowComponent(0);
+ QCOMPARE(newWindowComponentSpy.count(),2);
+}
+
+void tst_qmlgraphicswebview::renderingEnabled()
+{
+ QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+ checkNoErrors(component);
+ QmlGraphicsItem *rootItem = qobject_cast<QmlGraphicsItem*>(component.create());
+ QmlGraphicsWebView *wv = rootItem->findChild<QmlGraphicsWebView*>("webView");
+ QVERIFY(rootItem != 0);
+ QVERIFY(wv != 0);
+ QTRY_COMPARE(wv->progress(), 1.0);
+
+ QVERIFY(wv->renderingEnabled());
+ QSignalSpy renderingEnabledSpy(wv, SIGNAL(renderingEnabledChanged()));
+
+ wv->setRenderingEnabled(false);
+ QVERIFY(!wv->renderingEnabled());
+ QCOMPARE(renderingEnabledSpy.count(),1);
+
+ wv->setRenderingEnabled(false);
+ QCOMPARE(renderingEnabledSpy.count(),1);
+
+ wv->setRenderingEnabled(true);
+ QCOMPARE(renderingEnabledSpy.count(),2);
+}
+
+void tst_qmlgraphicswebview::pressGrabTime()
+{
+ QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+ checkNoErrors(component);
+ QmlGraphicsItem *rootItem = qobject_cast<QmlGraphicsItem*>(component.create());
+ QmlGraphicsWebView *wv = rootItem->findChild<QmlGraphicsWebView*>("webView");
+ QVERIFY(rootItem != 0);
+ QVERIFY(wv != 0);
+ QTRY_COMPARE(wv->progress(), 1.0);
+ QCOMPARE(wv->pressGrabTime(), 200);
+ QSignalSpy pressGrabTimeSpy(wv, SIGNAL(pressGrabTimeChanged()));
+
+ wv->setPressGrabTime(100);
+ QCOMPARE(wv->pressGrabTime(), 100);
+ QCOMPARE(pressGrabTimeSpy.count(),1);
+
+ wv->setPressGrabTime(100);
+ QCOMPARE(pressGrabTimeSpy.count(),1);
+
+ wv->setPressGrabTime(0);
+ QCOMPARE(pressGrabTimeSpy.count(),2);
+}
+
QTEST_MAIN(tst_qmlgraphicswebview)
#include "tst_qmlgraphicswebview.moc"