aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/testlib/qmldir
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2016-11-17 15:18:17 +0100
committerMitch Curtis <mitch.curtis@qt.io>2016-12-14 07:20:30 +0000
commit7aaebe557476c088d339f1b4b114a671885c4ea8 (patch)
tree827ca5f0b3e94b705d9a1a62597181eb28ff1893 /src/imports/testlib/qmldir
parent9fbc5aa8866bbc19cc0db9f5f247276f36f3e283 (diff)
TestCase: add createTemporaryObject(), createTemporaryQmlObject()
A typical pattern with QML tests is to dynamically create an item and then destroy it at the end of the test function: TestCase { id: testCase name: "MyTest" when: windowShown function test_click() { var item = Qt.createQmlObject("import QtQuick 2.0; Item {}", testCase); verify(item); // Test item... item.destroy(); } } The problem with this pattern is that any failures in the test function will cause the call to item.destroy() to be skipped, leaving the item hanging around in the scene until the test case has finished. This can result in interference with future tests; for example, by blocking input events or producing unrelated debug output that makes it difficult to follow the code's execution. By calling e.g. createTemporaryQmlObject() instead, the object is guaranteed to be destroyed at the end of the test function: TestCase { id: testCase name: "MyTest" when: windowShown function test_click() { var item = createTemporaryObject("import QtQuick 2.0; Item {}", testCase); verify(item); // Test item... // Don't need to worry about destroying "item" here. } } [ChangeLog][TestCase] Added createTemporaryObject() and createTemporaryQmlObject() functions that can be used to ensure that dynamically created objects are destroyed at the end of each test function. Change-Id: I483342052462aa86464c86bf2082892712dceb58 Task-number: QTBUG-56361 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'src/imports/testlib/qmldir')
-rw-r--r--src/imports/testlib/qmldir1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/imports/testlib/qmldir b/src/imports/testlib/qmldir
index 9da8ebb4be..e5757f6a88 100644
--- a/src/imports/testlib/qmldir
+++ b/src/imports/testlib/qmldir
@@ -3,4 +3,5 @@ plugin qmltestplugin
classname QTestQmlModule
typeinfo plugins.qmltypes
TestCase 1.0 TestCase.qml
+TestCase 1.2 TestCase.qml
SignalSpy 1.0 SignalSpy.qml