From 8e8357ffe9099b16a51e9dc8ef8649fbde27c53f Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 10 Dec 2010 14:37:53 +1000 Subject: Convert the documentation into qdoc form Use "make docs" to generate the documentation under "doc/html". --- src/imports/testlib/testcase.qdoc | 40 ++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/imports/testlib/testcase.qdoc b/src/imports/testlib/testcase.qdoc index 83faae0..5805467 100644 --- a/src/imports/testlib/testcase.qdoc +++ b/src/imports/testlib/testcase.qdoc @@ -90,6 +90,10 @@ the test framework will sort the functions on ascending order of name. This can help when there are two tests that must be run in order. + Multiple TestCase elements can be supplied. The test program will exit + once they have all completed. If a test case doesn't need to run + (because a precondition has failed), then \l optional can be set to true. + \section1 Data-driven tests Table data can be provided to a test using a function name that ends @@ -168,13 +172,31 @@ \qmlproperty bool TestCase::when This property should be set to true when the application wants - the test cases to run. The default value is true. + the test cases to run. The default value is true. In the following + example, a test is run when the user presses the mouse button: \code - TestCase { - name: "ButtonTests" - when: button.pressed - ... + Rectangle { + id: foo + width: 640; height: 480 + color: "cyan" + + MouseArea { + id: area + anchors.fill: parent + } + + property bool bar: true + + TestCase { + name: "ItemTests" + when: area.pressed + id: test1 + + function test_bar() { + verify(bar) + } + } } \endcode @@ -291,6 +313,14 @@ changes value based on asynchronous events. Use compare() for testing synchronous property changes. + \code + tryCompare(img, "status", BorderImage.Ready) + compare(img.width, 120) + compare(img.height, 120) + compare(img.horizontalTileMode, BorderImage.Stretch) + compare(img.verticalTileMode, BorderImage.Stretch) + \endcode + \sa compare() */ -- cgit v1.2.3