@@ -0,0 +1,154 @@
2+ * Copyright 2013 Canonical Ltd.
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+import "../../../Components"
20+import Ubuntu.Components 0.1
21+import Unity.Test 0.1 as UT
22+import "tst_LazyImage"
32+ rightMargin: 2 * parent.width / 3
38+ anchors { fill: parent; margins: units.gu(5) }
44+ verticalAlignment: Text.AlignBottom
55+ verticalAlignment: Text.AlignBottom
60+ sourceSize.width: units.gu(30)
67+ verticalAlignment: Text.AlignBottom
72+ sourceSize.height: units.gu(10)
81+ leftMargin: parent.width / 3
90+ anchors { fill: parent; margins: units.gu(3) }
92+ ImageControls { id: controls1; image: lazy1 }
93+ ImageControls { id: controls2; image: lazy2 }
94+ ImageControls { id: controls3; image: lazy3 }
102+ function cleanup() {
104+ tryCompare(lazy1, "width", units.gu(10));
106+ tryCompare(lazy2, "height", units.gu(10));
108+ tryCompare(lazy3, "width", units.gu(10));
111+ function test_lazyimage_data() {
113+ {tag: "Unbound Blank", image: lazy1, func: controls1.blank, width: units.gu(10), height: units.gu(10), placeholder: true},
114+ {tag: "Unbound Wide", image: lazy1, func: controls1.wide, transition: "readyTransition", width: 160, height: 80},
115+ {tag: "Unbound Square", image: lazy1, func: controls1.square, transition: "readyTransition", width: 160, height: 160},
116+ {tag: "Unbound Portrait", image: lazy1, func: controls1.portrait, transition: "readyTransition", width: 80, height: 160},
117+ {tag: "Unbound Bad path", image: lazy1, func: controls1.badpath, transition: "genericTransition", width: units.gu(10), height: units.gu(10), placeholder: true, error: true},
118+ {tag: "Width-bound Blank", image: lazy2, func: controls2.blank, width: units.gu(30), height: units.gu(10), placeholder: true},
119+ {tag: "Width-bound Wide", image: lazy2, func: controls2.wide, transition: "readyTransition", width: units.gu(30), height: units.gu(15)},
120+ {tag: "Width-bound Square", image: lazy2, func: controls2.square, transition: "readyTransition", width: units.gu(30), height: units.gu(30)},
121+ {tag: "Width-bound Portrait", image: lazy2, func: controls2.portrait, transition: "readyTransition", width: units.gu(30), height: units.gu(60)},
122+ {tag: "Width-bound Bad path", image: lazy2, func: controls2.badpath, transition: "genericTransition", width: units.gu(30), height: units.gu(10), placeholder: true, error: true},
123+ {tag: "Height-bound Blank", image: lazy3, func: controls3.blank, width: units.gu(10), height: units.gu(10), placeholder: true},
124+ {tag: "Height-bound Wide", image: lazy3, func: controls3.wide, transition: "readyTransition", width: units.gu(20), height: units.gu(10)},
125+ {tag: "Height-bound Square", image: lazy3, func: controls3.square, transition: "readyTransition", width: units.gu(10), height: units.gu(10)},
126+ {tag: "Height-bound Portrait", image: lazy3, func: controls3.portrait, transition: "readyTransition", width: units.gu(5), height: units.gu(10)},
127+ {tag: "Height-bound Bad path", image: lazy3, func: controls3.badpath, transition: "genericTransition", width: units.gu(10), height: units.gu(10), placeholder: true, error: true},
131+ function test_lazyimage(data) {
134+ if (data.transition) {
135+ // wait for the transition to complete
136+ var transition = findInvisibleChild(data.image, data.transition);
137+ tryCompare(transition, "running", true);
138+ tryCompare(transition, "running", false);
141+ // check the dimensions
142+ compare(data.image.width, data.width);
143+ compare(data.image.height, data.height);
145+ // check the placeholder
146+ var placeholder = findChild(data.image, "placeholder");
147+ compare(placeholder.visible, data.placeholder ? true : false);
149+ // check the error image
150+ var error = findChild(data.image, "errorImage");
151+ compare(error.visible, data.error ? true : false);