diff options
Diffstat (limited to 'src/imports/testlib')
-rw-r--r-- | src/imports/testlib/TestCase.qml | 4 | ||||
-rw-r--r-- | src/imports/testlib/testcase.qdoc | 25 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml index 41e1686a27..883a864e59 100644 --- a/src/imports/testlib/TestCase.qml +++ b/src/imports/testlib/TestCase.qml @@ -284,6 +284,10 @@ Item { } } + function grabImage(item) { + return qtest_results.grabImage(item); + } + function tryCompare(obj, prop, value, timeout) { if (!timeout) timeout = 5000 diff --git a/src/imports/testlib/testcase.qdoc b/src/imports/testlib/testcase.qdoc index b7f9a10703..469614da6d 100644 --- a/src/imports/testlib/testcase.qdoc +++ b/src/imports/testlib/testcase.qdoc @@ -374,6 +374,31 @@ */ /*! + \qmlmethod object TestCase::grabImage(item) + + Returns a snapshot image object of the given \a item. + + The returned image object has the following methods: + \list + \li red(x, y) Returns the red channel value of the pixel at \a x, \a y position + \li green(x, y) Returns the green channel value of the pixel at \a x, \a y position + \li blue(x, y) Returns the blue channel value of the pixel at \a x, \a y position + \li alpha(x, y) Returns the alpha channel value of the pixel at \a x, \a y position + \li pixel(x, y) Returns the color value of the pixel at \a x, \a y position + For example: + + \code + var image = grabImage(rect); + compare(image.red(10, 10), 255); + compare(image.pixel(20, 20), Qt.rgba(255, 0, 0, 255); + \endcode + + \endlist + + \sa +*/ + +/*! \qmlmethod TestCase::skip(message = "") Skips the current test case and prints the optional \a message. |