on xenial help sign in
More background tests.
46355d4Michał Sawicz
tests/qmltests/Components/tst_Background.qml+35−1
@@ -33,8 +33,15 @@ Rectangle {
33 name: "Background"
33 name: "Background"
34 when: windowShown
34 when: windowShown
35
35
36+ SignalSpy {
37+ id: loadedSpy
38+ target: background
39+ signalName: "loaded"
40+ }
41+
36 function cleanup() {
42 function cleanup() {
37 background.style = "";
43 background.style = "";
44+ loadedSpy.clear();
38 }
45 }
39
46
40 function test_style_data() {
47 function test_style_data() {
@@ -49,8 +56,35 @@ Rectangle {
49 function test_style(data) {
56 function test_style(data) {
50 background.style = data.style;
57 background.style = data.style;
51 expectFail("empty", "Empty style should not create a background.");
58 expectFail("empty", "Empty style should not create a background.");
52− tryCompareFunction(function() { return background.item === null }, false);
59+ loadedSpy.wait();
53 compare(background.item.objectName, data.tag, "Background should be %1".arg(data.style));
60 compare(background.item.objectName, data.tag, "Background should be %1".arg(data.style));
54 }
61 }
62+
63+ function test_solid() {
64+ background.style = "color:///black";
65+ loadedSpy.wait();
66+
67+ verify(Qt.colorEqual(background.item.color, "black"),
68+ "Solid color not equal: %1 != black".arg(background.item.color));
69+ }
70+
71+ function test_gradient() {
72+ background.style = "gradient:///black/red";
73+ loadedSpy.wait();
74+
75+ var stops = background.item.gradient.stops;
76+
77+ verify(Qt.colorEqual(stops[0].color, "black"),
78+ "Top gradient color not equal: %1 != black".arg(stops[0].color));
79+ verify(Qt.colorEqual(stops[1].color, "red"),
80+ "Bottom gradient color not equal: %1 != black".arg(stops[1].color));
81+ }
82+
83+ function test_image() {
84+ background.style = "/some/path";
85+ loadedSpy.wait();
86+
87+ compare(background.item.source, Qt.resolvedUrl("/some/path"), "Image path is incorrect.");
88+ }
55 }
89 }
56}
90}