aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Akulich <akulichalexander@gmail.com>2021-09-16 20:03:23 +0300
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-09-25 12:23:21 +0000
commit78490dce1fdcadb5fca5caa44b61e45963e4baf9 (patch)
treeeb506c13f520a25fb63a9cb6de132df83cc48d0d
parente70e2f7d98f7763463413bfd6d2f9300e48087b4 (diff)
tst_grabImage: Fix the cases were visually comparing invisible items
TestCase item has 'visible: false' set by default, and the grabImage() gets the data from QWindow surface. Make the root item visible so the test can get some data and actually check something. Also check the color of some grabbed pixels to see if we're working with the blank window background (before the root item 'visible' changed to 'true') or with the target item (after the fix). Change-Id: I107799a7442a62d44786003179e4595694c651a7 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit aed93ada4e58db8f1c36d7ed2c1074a514caf45a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--tests/auto/qmltest/selftests/tst_grabImage.qml5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/auto/qmltest/selftests/tst_grabImage.qml b/tests/auto/qmltest/selftests/tst_grabImage.qml
index 7ce7e93a07..714bc07f27 100644
--- a/tests/auto/qmltest/selftests/tst_grabImage.qml
+++ b/tests/auto/qmltest/selftests/tst_grabImage.qml
@@ -34,6 +34,7 @@ TestCase {
id: testCase
name: "tst_grabImage"
when: windowShown
+ visible: true
function test_equals() {
var rect = createTemporaryQmlObject("import QtQuick 2.0; Rectangle { color: 'red'; width: 10; height: 10; }", testCase);
@@ -47,6 +48,8 @@ TestCase {
// Don't change anything...
newImage = grabImage(rect);
try {
+ // Check that we actually grabbed something
+ compare(newImage.pixel(0, 0), "#ff0000")
compare(newImage.size, oldImage.size);
verify(newImage.equals(oldImage));
} catch (ex) {
@@ -86,6 +89,8 @@ TestCase {
try {
verify(grabbedImage2.equals(grabbedImage))
+ // Check that we actually grabbed, saved, and loaded something
+ compare(grabbedImage2.pixel(0, 0), "#ff0000")
} catch (ex) {
grabbedImage2.save("tst_grabImage_test_save2.png")
throw ex;