Merge lp:~mzanetti/unity/phablet-tile-tests into lp:unity/phablet

Proposed by Michael Zanetti
Status: Merged
Approved by: Andrea Cimitan
Approved revision: no longer in the source branch.
Merged at revision: 553
Proposed branch: lp:~mzanetti/unity/phablet-tile-tests
Merge into: lp:unity/phablet
Diff against target: 110 lines (+73/-0)
3 files modified
Components/Tile.qml (+3/-0)
tests/qmluitests/CMakeLists.txt (+1/-0)
tests/qmluitests/tst_Tile.qml (+69/-0)
To merge this branch: bzr merge lp:~mzanetti/unity/phablet-tile-tests
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Andrea Cimitan (community) Approve
Review via email: mp+157630@code.launchpad.net

Commit message

added tests for Tile.qml

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Andrea Cimitan (cimi) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Components/Tile.qml'
2--- Components/Tile.qml 2013-02-12 14:33:50 +0000
3+++ Components/Tile.qml 2013-04-08 11:55:25 +0000
4@@ -38,6 +38,7 @@
5 height: imageHeight
6 image: Image {
7 id: image
8+ objectName: "image"
9 sourceSize { width: icon.width; height: icon.height }
10 asynchronous: true
11 cache: false
12@@ -46,6 +47,7 @@
13
14 UbuntuShape {
15 id: borderPressed
16+ objectName: "borderPressed"
17
18 anchors.fill: icon
19 radius: "medium"
20@@ -64,6 +66,7 @@
21
22 Label {
23 id: label
24+ objectName: "label"
25 anchors {
26 baseline: parent.bottom
27 left: parent.left
28
29=== modified file 'tests/qmluitests/CMakeLists.txt'
30--- tests/qmluitests/CMakeLists.txt 2013-04-08 09:05:29 +0000
31+++ tests/qmluitests/CMakeLists.txt 2013-04-08 11:55:25 +0000
32@@ -16,3 +16,4 @@
33 add_qml_test(Revealer)
34 add_qml_test(Showable)
35 add_qml_test(Stage)
36+add_qml_test(Tile)
37
38=== added file 'tests/qmluitests/tst_Tile.qml'
39--- tests/qmluitests/tst_Tile.qml 1970-01-01 00:00:00 +0000
40+++ tests/qmluitests/tst_Tile.qml 2013-04-08 11:55:25 +0000
41@@ -0,0 +1,69 @@
42+/*
43+ * Copyright 2013 Canonical Ltd.
44+ *
45+ * This program is free software; you can redistribute it and/or modify
46+ * it under the terms of the GNU General Public License as published by
47+ * the Free Software Foundation; version 3.
48+ *
49+ * This program is distributed in the hope that it will be useful,
50+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
51+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
52+ * GNU General Public License for more details.
53+ *
54+ * You should have received a copy of the GNU General Public License
55+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
56+ */
57+
58+import QtQuick 2.0
59+import QtTest 1.0
60+import "../../Components"
61+import Ubuntu.Components 0.1
62+
63+Item {
64+ id: root
65+ width: units.gu(20)
66+ height: units.gu(24)
67+
68+ property bool helper: false
69+
70+ UnityTestCase {
71+ name: "TileTest"
72+ when: windowShown
73+
74+ function test_click_highlight() {
75+ var border = findChild(tile, "borderPressed")
76+ compare(border.opacity, 0)
77+ mousePress(root, 1, 1)
78+ tryCompare(border, "opacity", 1)
79+ mouseRelease(root, 1, 1)
80+ tryCompare(border, "opacity", 0)
81+ }
82+
83+ function test_resize_image_data() {
84+ return [
85+ {tag: "small", w: 1, h: 1, click: true},
86+ {tag: "large", w: units.gu(20), h: units.gu(20), click: true},
87+ // If image is too large to fit, text will be moved outside of the scene and click should fail
88+ {tag: "too large", w: units.gu(40), h: units.gu(40), click: false}
89+ ]
90+ }
91+
92+ function test_resize_image(data) {
93+ tile.imageWidth = data.w
94+ tile.imageHeight = data.h
95+ var label = findChild(tile, "label")
96+ mousePress(label, 1, 1)
97+ tryCompare(tile, "pressed", data.click)
98+ mouseRelease(label, 1, 1)
99+ }
100+ }
101+
102+ Tile {
103+ id: tile
104+ anchors.fill: parent
105+ source: "../../graphics/clock@18.png"
106+ text: "Testing rocks, debugging sucks!"
107+ imageWidth: width
108+ imageHeight: width
109+ }
110+}

Subscribers

People subscribed via source and target branches