summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2010-02-24 05:29:32 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2010-02-24 05:29:32 (GMT)
commit40256d682e1a552c9566a744a66cc6fe008b578b (patch)
treefde8c15bc9a8622daf240638b351c1960ddf0591 /tests
parent0f93f08d1d2dd8cbaaf80d13244c1b655f122357 (diff)
parent8848b63187cf1b073891bdd6998273a8869bb033 (diff)
downloadQt-40256d682e1a552c9566a744a66cc6fe008b578b.zip
Qt-40256d682e1a552c9566a744a66cc6fe008b578b.tar.gz
Qt-40256d682e1a552c9566a744a66cc6fe008b578b.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qml
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativeimage/data/colors1.pngbin0 -> 1655 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp18
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/autoNotifyConnection.qml6
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/testtypes.h6
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp17
5 files changed, 41 insertions, 6 deletions
diff --git a/tests/auto/declarative/qdeclarativeimage/data/colors1.png b/tests/auto/declarative/qdeclarativeimage/data/colors1.png
new file mode 100644
index 0000000..dfb62f3
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeimage/data/colors1.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
index 821386b..ed2095b 100644
--- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
+++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
@@ -112,13 +112,17 @@ void tst_qdeclarativeimage::imageSource_data()
{
QTest::addColumn<QString>("source");
QTest::addColumn<bool>("remote");
+ QTest::addColumn<bool>("async");
QTest::addColumn<QString>("error");
- QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << false << "";
+ QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << false << false << "";
+ QTest::newRow("local async") << QUrl::fromLocalFile(SRCDIR "/data/colors1.png").toString() << false << true << "";
QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << false
- << "Cannot open QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() + "\" ) ";
- QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << "";
- QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true
+ << false << "Cannot open QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() + "\" ) ";
+ QTest::newRow("local async not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString() << false
+ << true << "\"Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString() + "\" ";
+ QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << false << "";
+ QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true << false
<< "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" ";
}
@@ -126,6 +130,7 @@ void tst_qdeclarativeimage::imageSource()
{
QFETCH(QString, source);
QFETCH(bool, remote);
+ QFETCH(bool, async);
QFETCH(QString, error);
TestHTTPServer server(SERVER_PORT);
@@ -137,13 +142,14 @@ void tst_qdeclarativeimage::imageSource()
if (!error.isEmpty())
QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
- QString componentStr = "import Qt 4.6\nImage { source: \"" + source + "\" }";
+ QString componentStr = "import Qt 4.6\nImage { source: \"" + source + "\"; asynchronous: "
+ + (async ? QLatin1String("true") : QLatin1String("false")) + " }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create());
QVERIFY(obj != 0);
- if (remote)
+ if (remote || async)
TRY_WAIT(obj->status() == QDeclarativeImage::Loading);
QCOMPARE(obj->source(), remote ? source : QUrl(source));
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/autoNotifyConnection.qml b/tests/auto/declarative/qdeclarativelanguage/data/autoNotifyConnection.qml
new file mode 100644
index 0000000..640fb54
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/autoNotifyConnection.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+MyQmlObject {
+ property bool receivedNotify : false
+ onPropertyWithNotifyChanged: { receivedNotify = true; }
+}
+
diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h
index 2c06416..1a8bd11 100644
--- a/tests/auto/declarative/qdeclarativelanguage/testtypes.h
+++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.h
@@ -102,6 +102,7 @@ class MyQmlObject : public QObject, public MyInterface, public QDeclarativeParse
Q_PROPERTY(int onLiteralSignal READ onLiteralSignal WRITE setOnLiteralSignal);
Q_PROPERTY(MyCustomVariantType customType READ customType WRITE setCustomType);
Q_PROPERTY(MyQmlObject *qmlobjectProperty READ qmlobject WRITE setQmlobject)
+ Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal)
Q_INTERFACES(MyInterface QDeclarativeParserStatus)
public:
@@ -137,6 +138,9 @@ public:
MyCustomVariantType customType() const { return m_custom; }
void setCustomType(const MyCustomVariantType &v) { m_custom = v; }
+
+ int propertyWithNotify() const { return m_propertyWithNotify; }
+ void setPropertyWithNotify(int i) { m_propertyWithNotify = i; emit oddlyNamedNotifySignal(); }
public slots:
void basicSlot() { qWarning("MyQmlObject::basicSlot"); }
void basicSlotWithArgs(int v) { qWarning("MyQmlObject::basicSlotWithArgs(%d)", v); }
@@ -144,6 +148,7 @@ public slots:
signals:
void basicSignal();
void basicParameterizedSignal(int parameter);
+ void oddlyNamedNotifySignal();
private:
friend class tst_qdeclarativelanguage;
@@ -151,6 +156,7 @@ private:
MyInterface *m_interface;
MyQmlObject *m_qmlobject;
MyCustomVariantType m_custom;
+ int m_propertyWithNotify;
};
QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
QML_DECLARE_TYPE(MyQmlObject);
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index d6b5f0c..9d68ba9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -88,6 +88,7 @@ private slots:
void rootAsQmlComponent();
void inlineQmlComponents();
void idProperty();
+ void autoNotifyConnection();
void assignSignal();
void dynamicProperties();
void dynamicPropertiesNested();
@@ -511,6 +512,22 @@ void tst_qdeclarativelanguage::idProperty()
QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child));
}
+// Tests automatic connection to notify signals if "onBlahChanged" syntax is used
+// even if the notify signal for "blah" is not called "blahChanged"
+void tst_qdeclarativelanguage::autoNotifyConnection()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("autoNotifyConnection.qml"));
+ VERIFY_ERRORS(0);
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QMetaProperty prop = object->metaObject()->property(object->metaObject()->indexOfProperty("receivedNotify"));
+ QVERIFY(prop.isValid());
+
+ QCOMPARE(prop.read(object), QVariant::fromValue(false));
+ object->setPropertyWithNotify(1);
+ QCOMPARE(prop.read(object), QVariant::fromValue(true));
+}
+
// Tests that signals can be assigned to
void tst_qdeclarativelanguage::assignSignal()
{