diff options
author | Glenn Watson <glenn.watson@nokia.com> | 2012-07-02 09:10:49 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-04 03:31:04 +0200 |
commit | f18b66ac6cfc734d217ec9d44876774f25e5d900 (patch) | |
tree | 7d8dffc65886f87a88c76d1ec29adca00d23b167 /tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp | |
parent | ac9b09d4299bae22f6aa4b5423092167761d1c8d (diff) |
Make Behaviors work correctly with value types.
When a value type is referenced by sub-component a grouped
property is built. This code path did not handle behaviors being
declared on the entire value type. Add support for value interceptors
in this code path. Also issue an additional write to the value
type property before calling the interceptor on components
that are not being intercepted, so that the other
sub-components don't get stale values during write back.
Task-number: QTBUG-22625
Change-Id: I3365f422dfa1ab2e536e19575efcceceffb85e10
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp')
-rw-r--r-- | tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index 0c890dea74..f038b9dbfb 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -95,6 +95,8 @@ private slots: void bindingsSpliceCorrectly(); void nonValueTypeComparison(); void initializeByWrite(); + void groupedInterceptors(); + void groupedInterceptors_data(); private: QQmlEngine engine; @@ -1346,6 +1348,45 @@ void tst_qqmlvaluetypes::initializeByWrite() delete object; } +void tst_qqmlvaluetypes::groupedInterceptors_data() +{ + QTest::addColumn<QString>("qmlfile"); + QTest::addColumn<QColor>("expectedInitialColor"); + QTest::addColumn<QColor>("setColor"); + QTest::addColumn<QColor>("expectedFinalColor"); + + QColor c0, c1, c2; + c0.setRgbF(0.1f, 0.2f, 0.3f, 0.4f); + c1.setRgbF(0.2f, 0.4f, 0.6f, 0.8f); + c2.setRgbF(0.8f, 0.6f, 0.4f, 0.2f); + + QTest::newRow("value-interceptor") << QString::fromLatin1("grouped_interceptors_value.qml") << c0 << c1 << c2; + QTest::newRow("component-interceptor") << QString::fromLatin1("grouped_interceptors_component.qml") << QColor(128, 0, 255) << QColor(50, 100, 200) << QColor(0, 100, 200); + QTest::newRow("ignore-interceptor") << QString::fromLatin1("grouped_interceptors_ignore.qml") << QColor(128, 0, 255) << QColor(50, 100, 200) << QColor(128, 100, 200); +} + +void tst_qqmlvaluetypes::groupedInterceptors() +{ + QFETCH(QString, qmlfile); + QFETCH(QColor, expectedInitialColor); + QFETCH(QColor, setColor); + QFETCH(QColor, expectedFinalColor); + + QQmlComponent component(&engine, testFileUrl(qmlfile)); + QObject *object = component.create(); + QVERIFY(object != 0); + + QColor initialColor = object->property("color").value<QColor>(); + QCOMPARE(initialColor, expectedInitialColor); + + object->setProperty("color", setColor); + + QColor finalColor = object->property("color").value<QColor>(); + QCOMPARE(finalColor, expectedFinalColor); + + delete object; +} + QTEST_MAIN(tst_qqmlvaluetypes) #include "tst_qqmlvaluetypes.moc" |