diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-06-10 10:01:12 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-06-10 10:01:27 +0200 |
commit | 8a793defa79bd332742cadeabfe05cbaa5516877 (patch) | |
tree | 85f28038d29452fae858723dc7b7e5f0df9dcb42 /tests | |
parent | cbc86ae4d4af719f201e5f62aa07ef4a763eecee (diff) | |
parent | e4fc75edaedead3092aace3a29a0aafdd0e86a77 (diff) |
Merge remote-tracking branch 'origin/release' into stable
Change-Id: Iafc0497812acb7850cd4e72c49d63ec9c9320b58
Diffstat (limited to 'tests')
3 files changed, 83 insertions, 14 deletions
diff --git a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp index 327716f1b5..ca212d333b 100644 --- a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp +++ b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp @@ -66,6 +66,8 @@ private slots: void crashBug(); void QTBUG_17868(); void metaObjectAccessibility(); + void QTBUG_31226(); + void QTBUG_29836(); }; void tst_QQmlPropertyMap::insert() @@ -286,13 +288,17 @@ class MyEnhancedPropertyMap : public QQmlPropertyMap { Q_OBJECT public: - MyEnhancedPropertyMap() : QQmlPropertyMap(this, 0) {} + MyEnhancedPropertyMap() : QQmlPropertyMap(this, 0), m_testSlotCalled(false) {} + bool testSlotCalled() const { return m_testSlotCalled; } signals: void testSignal(); public slots: - void testSlot() {} + void testSlot() { m_testSlotCalled = true; } + +private: + bool m_testSlotCalled; }; void tst_QQmlPropertyMap::metaObjectAccessibility() @@ -312,6 +318,57 @@ void tst_QQmlPropertyMap::metaObjectAccessibility() QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString())); } +void tst_QQmlPropertyMap::QTBUG_31226() +{ + /* Instantiate a property map from QML, and verify that property changes + * made from C++ are visible from QML */ + QQmlEngine engine; + QQmlContext context(&engine); + qmlRegisterType<QQmlPropertyMap>("QTBUG_31226", 1, 0, "PropertyMap"); + QQmlComponent c(&engine); + c.setData("import QtQuick 2.0\nimport QTBUG_31226 1.0\n" + "Item {\n" + " property string myProp\n" + " PropertyMap { id: qmlPropertyMap; objectName: \"qmlPropertyMap\" }\n" + " Timer { interval: 5; running: true; onTriggered: { myProp = qmlPropertyMap.greeting; } }\n" + "}", + QUrl()); + QObject *obj = c.create(&context); + QVERIFY(obj); + + QQmlPropertyMap *qmlPropertyMap = obj->findChild<QQmlPropertyMap*>(QString("qmlPropertyMap")); + QVERIFY(qmlPropertyMap); + + qmlPropertyMap->insert("greeting", QString("Hello world!")); + QTRY_COMPARE(obj->property("myProp").toString(), QString("Hello world!")); + + delete obj; + +} + +void tst_QQmlPropertyMap::QTBUG_29836() +{ + MyEnhancedPropertyMap map; + QCOMPARE(map.testSlotCalled(), false); + + QQmlEngine engine; + QQmlContext context(&engine); + context.setContextProperty("enhancedMap", &map); + QQmlComponent c(&engine); + c.setData("import QtQuick 2.0\n" + "Item {\n" + " Timer { interval: 5; running: true; onTriggered: enhancedMap.testSlot() }\n" + "}", + QUrl()); + QObject *obj = c.create(&context); + QVERIFY(obj); + + QTRY_COMPARE(map.testSlotCalled(), true); + + delete obj; + +} + QTEST_MAIN(tst_QQmlPropertyMap) #include "tst_qqmlpropertymap.moc" diff --git a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp index 73474afbd7..0377eaa71d 100644 --- a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp +++ b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp @@ -190,9 +190,6 @@ void tst_qquickanimatedimage::mirror_running() QImage frame0_expected = frame0.transformed(transform); QImage frame1_expected = frame1.transformed(transform); -#ifdef Q_OS_MAC - QSKIP("QTBUG-31370 - sometimes fails on Mac"); -#endif QCOMPARE(frame0_flipped, frame0_expected); QCOMPARE(frame1_flipped, frame1_expected); @@ -204,29 +201,28 @@ void tst_qquickanimatedimage::mirror_notRunning() QFETCH(QUrl, fileUrl); QQuickView window; + window.setSource(fileUrl); window.show(); + QTRY_VERIFY(window.isExposed()); - window.setSource(fileUrl); QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(window.rootObject()); QVERIFY(anim); int width = anim->property("width").toInt(); - QPixmap screenshot = QPixmap::fromImage(window.grabWindow()); + QImage screenshot = window.grabWindow(); QTransform transform; transform.translate(width, 0).scale(-1, 1.0); - QPixmap expected = screenshot.transformed(transform); + QImage expected = screenshot.transformed(transform); int frame = anim->currentFrame(); bool playing = anim->isPlaying(); bool paused = anim->isPlaying(); anim->setProperty("mirror", true); - screenshot = QPixmap::fromImage(window.grabWindow()); + screenshot = window.grabWindow(); -#ifdef Q_OS_MAC - QSKIP("QTBUG-31370 - sometimes fails on Mac"); -#endif + screenshot.save("screen.png"); QCOMPARE(screenshot, expected); // mirroring should not change the current frame or playing status diff --git a/tests/auto/quick/touchmouse/tst_touchmouse.cpp b/tests/auto/quick/touchmouse/tst_touchmouse.cpp index 15a4f0cc27..4779942406 100644 --- a/tests/auto/quick/touchmouse/tst_touchmouse.cpp +++ b/tests/auto/quick/touchmouse/tst_touchmouse.cpp @@ -195,8 +195,9 @@ void tst_TouchMouse::simpleTouchEvent() window->setSource(testFileUrl("singleitem.qml")); window->show(); - window->requestActivate(); QVERIFY(QTest::qWaitForWindowExposed(window)); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); QVERIFY(window->rootObject() != 0); EventItem *eventItem1 = window->rootObject()->findChild<EventItem*>("eventItem1"); @@ -344,7 +345,9 @@ void tst_TouchMouse::mouse() window->setSource(testFileUrl("twoitems.qml")); window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); QVERIFY(window->rootObject() != 0); EventItem *eventItem1 = window->rootObject()->findChild<EventItem*>("eventItem1"); @@ -376,7 +379,9 @@ void tst_TouchMouse::touchOverMouse() window->setSource(testFileUrl("twoitems.qml")); window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); QVERIFY(window->rootObject() != 0); EventItem *eventItem1 = window->rootObject()->findChild<EventItem*>("eventItem1"); @@ -417,7 +422,9 @@ void tst_TouchMouse::mouseOverTouch() window->setSource(testFileUrl("twoitems.qml")); window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); QVERIFY(window->rootObject() != 0); EventItem *eventItem1 = window->rootObject()->findChild<EventItem*>("eventItem1"); @@ -461,7 +468,9 @@ void tst_TouchMouse::buttonOnFlickable() window->setSource(testFileUrl("buttononflickable.qml")); window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); QVERIFY(window->rootObject() != 0); QQuickFlickable *flickable = window->rootObject()->findChild<QQuickFlickable*>("flickable"); @@ -569,7 +578,9 @@ void tst_TouchMouse::buttonOnTouch() QQuickView *window = createView(); window->setSource(testFileUrl("buttonontouch.qml")); window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); QVERIFY(window->rootObject() != 0); QQuickPinchArea *pinchArea = window->rootObject()->findChild<QQuickPinchArea*>("pincharea"); @@ -691,7 +702,9 @@ void tst_TouchMouse::pinchOnFlickable() QQuickView *window = createView(); window->setSource(testFileUrl("pinchonflickable.qml")); window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); QVERIFY(window->rootObject() != 0); QQuickPinchArea *pinchArea = window->rootObject()->findChild<QQuickPinchArea*>("pincharea"); @@ -758,7 +771,9 @@ void tst_TouchMouse::flickableOnPinch() QQuickView *window = createView(); window->setSource(testFileUrl("flickableonpinch.qml")); window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); QVERIFY(window->rootObject() != 0); QQuickPinchArea *pinchArea = window->rootObject()->findChild<QQuickPinchArea*>("pincharea"); @@ -935,8 +950,9 @@ void tst_TouchMouse::tapOnDismissiveTopMouseAreaClicksBottomOne() window->setSource(testFileUrl("twoMouseAreas.qml")); window->show(); - window->requestActivate(); QVERIFY(QTest::qWaitForWindowExposed(window)); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); QVERIFY(window->rootObject() != 0); QQuickMouseArea *bottomMouseArea = |