diff options
author | Gunnar Sletta <gunnar@sletta.org> | 2014-10-08 18:14:43 +0200 |
---|---|---|
committer | Gunnar Sletta <gunnar@sletta.org> | 2014-10-10 14:15:55 +0200 |
commit | 624844f3db601b48205d7f545732870d45d78300 (patch) | |
tree | f1eae2a4cb05b0b42291bfdd5ea43069ac7c0c1b | |
parent | 2b5e9534450404fba3bdf89f304d0504ae8587dd (diff) |
Stabilize and fix comparisons in animator tests.
compare() will compare properties of objects and neither Qt.rgba nor
image.pixel created objects has enumeratable properties so compare
is pretty much useless. Use verify + == which will rely on toString()
which is ok.
A few of the tests relied on execution order of signals emitted on
animation.running being changed and would occasionally fail.
Change-Id: I531c7f21b58a922a6be9ca2b6de120a68209a6d6
Reviewed-by: Michael Brasser <michael.brasser@live.com>
-rw-r--r-- | tests/auto/qmltest/animators/tst_behavior.qml | 7 | ||||
-rw-r--r-- | tests/auto/qmltest/animators/tst_mixedparallel.qml | 4 | ||||
-rw-r--r-- | tests/auto/qmltest/animators/tst_mixedsequential.qml | 4 | ||||
-rw-r--r-- | tests/auto/qmltest/animators/tst_opacity.qml | 3 | ||||
-rw-r--r-- | tests/auto/qmltest/animators/tst_parallel.qml | 4 | ||||
-rw-r--r-- | tests/auto/qmltest/animators/tst_rotation.qml | 5 | ||||
-rw-r--r-- | tests/auto/qmltest/animators/tst_scale.qml | 5 | ||||
-rw-r--r-- | tests/auto/qmltest/animators/tst_transformorigin.qml | 72 | ||||
-rw-r--r-- | tests/auto/qmltest/animators/tst_transition.qml | 6 | ||||
-rw-r--r-- | tests/auto/qmltest/animators/tst_x.qml | 7 | ||||
-rw-r--r-- | tests/auto/qmltest/animators/tst_y.qml | 7 |
11 files changed, 60 insertions, 64 deletions
diff --git a/tests/auto/qmltest/animators/tst_behavior.qml b/tests/auto/qmltest/animators/tst_behavior.qml index 0b74a74d53..87b0efff17 100644 --- a/tests/auto/qmltest/animators/tst_behavior.qml +++ b/tests/auto/qmltest/animators/tst_behavior.qml @@ -47,8 +47,9 @@ Item { compare(box.scaleChangeCounter, 1); compare(box.scale, 2); var image = grabImage(root); - compare(image.pixel(0, 0), Qt.rgba(1, 0, 0, 1)); - compare(image.pixel(199, 199), Qt.rgba(0, 0, 1, 1)); + + verify(image.pixel(0, 0) == Qt.rgba(1, 0, 0)); + verify(image.pixel(199, 199) == Qt.rgba(0, 0, 1)); } } @@ -58,7 +59,7 @@ Item { } Timer { - interval: 1000; + interval: 100; repeat: false running: true onTriggered: box.scale = 2 diff --git a/tests/auto/qmltest/animators/tst_mixedparallel.qml b/tests/auto/qmltest/animators/tst_mixedparallel.qml index da5fb9c7ea..2b6ebfc17a 100644 --- a/tests/auto/qmltest/animators/tst_mixedparallel.qml +++ b/tests/auto/qmltest/animators/tst_mixedparallel.qml @@ -48,8 +48,8 @@ Item { compare(box.scale, 2); compare(box.rotation, 180); var image = grabImage(root); - compare(image.pixel(0, 0), Qt.rgba(0, 0, 1, 1)); - compare(image.pixel(199, 199), Qt.rgba(1, 0, 0, 1)); + verify(image.pixel(0, 0) == Qt.rgba(0, 0, 1)); + verify(image.pixel(199, 199) == Qt.rgba(1, 0, 0)); } } diff --git a/tests/auto/qmltest/animators/tst_mixedsequential.qml b/tests/auto/qmltest/animators/tst_mixedsequential.qml index 02caa3cae0..6165cf5438 100644 --- a/tests/auto/qmltest/animators/tst_mixedsequential.qml +++ b/tests/auto/qmltest/animators/tst_mixedsequential.qml @@ -48,8 +48,8 @@ Item { compare(box.scale, 2); compare(box.rotation, 180); var image = grabImage(root); - compare(image.pixel(0, 0), Qt.rgba(0, 0, 1, 1)); - compare(image.pixel(199, 199), Qt.rgba(1, 0, 0, 1)); + verify(image.pixel(0, 0) == Qt.rgba(0, 0, 1)); + verify(image.pixel(199, 199) == Qt.rgba(1, 0, 0)); } } diff --git a/tests/auto/qmltest/animators/tst_opacity.qml b/tests/auto/qmltest/animators/tst_opacity.qml index e8c3edd46c..37603a9ced 100644 --- a/tests/auto/qmltest/animators/tst_opacity.qml +++ b/tests/auto/qmltest/animators/tst_opacity.qml @@ -42,10 +42,9 @@ Item { TestCase { id: testCase name: "animators-opacity" - when: !animation.running + when: box.opacity == 0.5 function test_endresult() { compare(box.opacityChangeCounter, 1); - compare(box.opacity, 0.5); var image = grabImage(root); compare(image.red(50, 50), 255); verify(image.green(50, 50) > 0); diff --git a/tests/auto/qmltest/animators/tst_parallel.qml b/tests/auto/qmltest/animators/tst_parallel.qml index e9efbda237..7702dd7dd8 100644 --- a/tests/auto/qmltest/animators/tst_parallel.qml +++ b/tests/auto/qmltest/animators/tst_parallel.qml @@ -49,8 +49,8 @@ Item { compare(box.scale, 2); compare(box.rotation, 180); var image = grabImage(root); - compare(image.pixel(0, 0), Qt.rgba(0, 0, 1, 1)); - compare(image.pixel(199, 199), Qt.rgba(1, 0, 0, 1)); + verify(image.pixel(0, 0) == Qt.rgba(0, 0, 1)); + verify(image.pixel(199, 199) == Qt.rgba(1, 0, 0)); } } diff --git a/tests/auto/qmltest/animators/tst_rotation.qml b/tests/auto/qmltest/animators/tst_rotation.qml index 8c29df0623..9ff4278527 100644 --- a/tests/auto/qmltest/animators/tst_rotation.qml +++ b/tests/auto/qmltest/animators/tst_rotation.qml @@ -42,12 +42,11 @@ Item { TestCase { id: testCase name: "animators-rotation" - when: !animation.running + when: box.rotation == 180 function test_endresult() { compare(box.rotationChangeCounter, 1); - compare(box.rotation, 180); var image = grabImage(root); - compare(image.pixel(50, 50), Qt.rgba(0, 0, 1)); + verify(image.pixel(50, 50) == Qt.rgba(0, 0, 1)); } } diff --git a/tests/auto/qmltest/animators/tst_scale.qml b/tests/auto/qmltest/animators/tst_scale.qml index 83ab2e5746..10f3430c84 100644 --- a/tests/auto/qmltest/animators/tst_scale.qml +++ b/tests/auto/qmltest/animators/tst_scale.qml @@ -42,12 +42,11 @@ Item { TestCase { id: testCase name: "animators-scale" - when: !animation.running + when: box.scale == 2; function test_endresult() { compare(box.scaleChangeCounter, 1); - compare(box.scale, 2); var image = grabImage(root); - compare(image.pixel(0, 0), Qt.rgba(1, 0, 0)); + verify(image.pixel(0, 0) == Qt.rgba(1, 0, 0)); } } diff --git a/tests/auto/qmltest/animators/tst_transformorigin.qml b/tests/auto/qmltest/animators/tst_transformorigin.qml index 5dfe070e80..bd3483dad5 100644 --- a/tests/auto/qmltest/animators/tst_transformorigin.qml +++ b/tests/auto/qmltest/animators/tst_transformorigin.qml @@ -61,60 +61,60 @@ Item { // topleft - compare(image.pixel(40, 40), white); - compare(image.pixel(60, 40), white); - compare(image.pixel(40, 60), white); - compare(image.pixel(60, 60), blue); + verify(image.pixel(40, 40) == white); + verify(image.pixel(60, 40) == white); + verify(image.pixel(40, 60) == white); + verify(image.pixel(60, 60) == blue); // top - compare(image.pixel(140, 40), white); - compare(image.pixel(160, 40), white); - compare(image.pixel(140, 60), blue); - compare(image.pixel(160, 60), blue); + verify(image.pixel(140, 40) == white); + verify(image.pixel(160, 40) == white); + verify(image.pixel(140, 60) == blue); + verify(image.pixel(160, 60) == blue); // topright - compare(image.pixel(240, 40), white); - compare(image.pixel(260, 40), white); - compare(image.pixel(240, 60), blue); - compare(image.pixel(260, 60), white); + verify(image.pixel(240, 40) == white); + verify(image.pixel(260, 40) == white); + verify(image.pixel(240, 60) == blue); + verify(image.pixel(260, 60) == white); // left - compare(image.pixel(40, 140), white); - compare(image.pixel(60, 140), blue); - compare(image.pixel(40, 160), white); - compare(image.pixel(60, 160), blue); + verify(image.pixel(40, 140) == white); + verify(image.pixel(60, 140) == blue); + verify(image.pixel(40, 160) == white); + verify(image.pixel(60, 160) == blue); // center - compare(image.pixel(140, 140), blue); - compare(image.pixel(160, 140), blue); - compare(image.pixel(140, 160), blue); - compare(image.pixel(160, 160), blue); + verify(image.pixel(140, 140) == blue); + verify(image.pixel(160, 140) == blue); + verify(image.pixel(140, 160) == blue); + verify(image.pixel(160, 160) == blue); // right - compare(image.pixel(240, 140), blue); - compare(image.pixel(260, 140), white); - compare(image.pixel(240, 160), blue); - compare(image.pixel(260, 160), white); + verify(image.pixel(240, 140) == blue); + verify(image.pixel(260, 140) == white); + verify(image.pixel(240, 160) == blue); + verify(image.pixel(260, 160) == white); // bottomleft - compare(image.pixel(40, 240), white); - compare(image.pixel(60, 240), blue); - compare(image.pixel(40, 260), white); - compare(image.pixel(60, 260), white); + verify(image.pixel(40, 240) == white); + verify(image.pixel(60, 240) == blue); + verify(image.pixel(40, 260) == white); + verify(image.pixel(60, 260) == white); // bottom - compare(image.pixel(140, 240), blue); - compare(image.pixel(160, 240), blue); - compare(image.pixel(140, 260), white); - compare(image.pixel(160, 260), white); + verify(image.pixel(140, 240) == blue); + verify(image.pixel(160, 240) == blue); + verify(image.pixel(140, 260) == white); + verify(image.pixel(160, 260) == white); // bottomright - compare(image.pixel(240, 240), blue); - compare(image.pixel(260, 240), white); - compare(image.pixel(240, 260), white); - compare(image.pixel(260, 260), white); + verify(image.pixel(240, 240) == blue); + verify(image.pixel(260, 240) == white); + verify(image.pixel(240, 260) == white); + verify(image.pixel(260, 260) == white); } } diff --git a/tests/auto/qmltest/animators/tst_transition.qml b/tests/auto/qmltest/animators/tst_transition.qml index 72dcd343a7..67230d2adf 100644 --- a/tests/auto/qmltest/animators/tst_transition.qml +++ b/tests/auto/qmltest/animators/tst_transition.qml @@ -47,8 +47,8 @@ Item { compare(box.scaleChangeCounter, 1); compare(box.scale, 2); var image = grabImage(root); - compare(image.pixel(0, 0), Qt.rgba(1, 0, 0)); - compare(image.pixel(199, 199), Qt.rgba(0, 0, 1)); + verify(image.pixel(0, 0) == Qt.rgba(1, 0, 0)); + verify(image.pixel(199, 199) == Qt.rgba(0, 0, 1)); } } @@ -75,7 +75,7 @@ Item { } Timer { - interval: 1000; + interval: 100; repeat: false running: true onTriggered: root.state = "two" diff --git a/tests/auto/qmltest/animators/tst_x.qml b/tests/auto/qmltest/animators/tst_x.qml index 8236a82797..35e410e8e2 100644 --- a/tests/auto/qmltest/animators/tst_x.qml +++ b/tests/auto/qmltest/animators/tst_x.qml @@ -42,13 +42,12 @@ Item { TestCase { id: testCase name: "animators-x" - when: !animation.running + when: box.x == 100 function test_endresult() { compare(box.xChangeCounter, 1); - compare(box.x, 100); var image = grabImage(root); - compare(image.pixel(100, 50), Qt.rgba(1, 0, 0)); - compare(image.pixel(99, 50), Qt.rgba(1, 1, 1)); // outside on the left + verify(image.pixel(100, 0) == Qt.rgba(1, 0, 0)); + verify(image.pixel(99, 0) == Qt.rgba(1, 1, 1)); // outside on the left } } diff --git a/tests/auto/qmltest/animators/tst_y.qml b/tests/auto/qmltest/animators/tst_y.qml index 37400ebd85..79fd50e8bf 100644 --- a/tests/auto/qmltest/animators/tst_y.qml +++ b/tests/auto/qmltest/animators/tst_y.qml @@ -42,13 +42,12 @@ Item { TestCase { id: testCase name: "animators-y" - when: !animation.running + when: box.y == 100 function test_endresult() { compare(box.yChangeCounter, 1); - compare(box.y, 100); var image = grabImage(root); - compare(image.pixel(50, 100), Qt.rgba(1, 0, 0)); - compare(image.pixel(50, 99), Qt.rgba(1, 1, 1)); // outside on the left + verify(image.pixel(0, 100) == Qt.rgba(1, 0, 0)); + verify(image.pixel(0, 99) == Qt.rgba(1, 1, 1)); // outside on the top } } |