on xenial help sign in
Add a test for waitForBehaviors
e445c77Albert Astals Cid
tests/qmltests/utils/Unity/Test/tst_UnityTest.qml+31
@@ -30,6 +30,20 @@ TestCase {
30 id: testObject
30 id: testObject
31 }
31 }
32
32
33+ Item {
34+ id: item
35+ Behavior on height {
36+ NumberAnimation {
37+ duration: 500
38+ }
39+ }
40+ Behavior on width {
41+ NumberAnimation {
42+ duration: 100
43+ }
44+ }
45+ }
46+
33 function test_direct() {
47 function test_direct() {
34 compare(Util.isInstanceOf(rect, "QQuickRectangle"), true, "rect should be an instance of QQuickRectangle");
48 compare(Util.isInstanceOf(rect, "QQuickRectangle"), true, "rect should be an instance of QQuickRectangle");
35 compare(Util.isInstanceOf(Util, "TestUtil"), true, "Util should be an instance of TestUtil");
49 compare(Util.isInstanceOf(Util, "TestUtil"), true, "Util should be an instance of TestUtil");
@@ -52,4 +66,21 @@ TestCase {
52 function test_undefined() {
66 function test_undefined() {
53 compare(Util.isInstanceOf(undefined, "QObject"), false, "passing undefined should fail");
67 compare(Util.isInstanceOf(undefined, "QObject"), false, "passing undefined should fail");
54 }
68 }
69+
70+ function test_behavior_waiting() {
71+ item.height = 100;
72+ verify(item.height != 100);
73+
74+ item.width = 100;
75+ verify(item.width != 100);
76+
77+ var date1 = new Date();
78+ Util.waitForBehaviors(item);
79+ var date2 = new Date();
80+
81+ compare(item.height, 100);
82+ compare(item.width, 100);
83+
84+ verify(date2 - date1 >= 500);
85+ }
55}
86}