on xenial help sign in
Add qmltest for DemoOverlay
commitcedbc3f50fe290e7a5635110e438892be0f62d06 authorMichael Terry <michael.terry@canonical.com> dateTue 30 Jul 2013, 17:09 (13 years ago) parent447982b
3 files changed+102
Components/DemoOverlay.qml+2 tests/qmltests/CMakeLists.txt+1 tests/qmltests/Components/tst_DemoOverlay.qml+99
Components/DemoOverlay.qml+2
@@ -46,6 +46,7 @@ Item {
4646 property color __orange_transparent: Qt.hsla(16.0/360.0, 0.83, 0.47, 0.4)
4747 property int __edge_margin: units.gu(4)
4848 property int __text_margin: units.gu(3)
49+ property int __anim_running: wholeAnimation.running // for testing
4950
5051 signal skip()
5152
@@ -94,6 +95,7 @@ Item {
9495
9596 Label {
9697 id: skipLabel
98+ objectName: "skipLabel"
9799 text: i18n.tr("Skip intro")
98100 color: overlay.__orange
99101 fontSize: "small"
tests/qmltests/CMakeLists.txt+1
@@ -25,6 +25,7 @@ add_qml_test(utils/Unity/Test UnityTest)
2525set(qmltest_DEFAULT_TARGETS qmluitests)
2626set(qmltest_DEFAULT_NO_ADD_TEST TRUE)
2727set(qmltest_DEFAULT_PROPERTIES "")
28+add_qml_test(Components DemoOverlay)
2829add_manual_qml_test(Components DragHandle IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)
2930add_qml_test(Components DraggingArea)
3031add_qml_test(Components FilterGrid IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins)
tests/qmltests/Components/tst_DemoOverlay.qmlnew file+99
@@ -0,0 +1,99 @@
1+/*
2+ * Copyright 2013 Canonical Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
17+import QtQuick 2.0
18+import QtTest 1.0
19+import Unity.Test 0.1 as UT
20+import "../../../Components"
21+
22+Item {
23+ id: root
24+ width: 700
25+ height: 500
26+
27+ DemoOverlay {
28+ id: top
29+ edge: "top"
30+ title: "Top"
31+ text: "Displayed on top left"
32+ x: 0
33+ y: 0
34+ width: parent.width/2
35+ height: parent.height/2
36+ }
37+
38+ DemoOverlay {
39+ id: right
40+ edge: "right"
41+ title: "Right"
42+ text: "Displayed on top right"
43+ x: parent.width/2
44+ y: 0
45+ width: parent.width/2
46+ height: parent.height/2
47+ }
48+
49+ DemoOverlay {
50+ id: left
51+ edge: "left"
52+ title: "Left"
53+ text: "Displayed on bottom right"
54+ x: parent.width/2
55+ y: parent.height/2
56+ width: parent.width/2
57+ height: parent.height/2
58+ enabled: false
59+ }
60+
61+ DemoOverlay {
62+ id: bottom
63+ edge: "bottom"
64+ title: "Bottom"
65+ text: "Displayed on bottom left"
66+ x: 0
67+ y: parent.height/2
68+ width: parent.width/2
69+ height: parent.height/2
70+ }
71+
72+ SignalSpy {
73+ id: signalSpy
74+ target: bottom
75+ }
76+
77+ UT.UnityTestCase {
78+ name: "DemoOverlay"
79+ when: windowShown
80+
81+ function test_animations() {
82+ compare(right.__anim_running, 1)
83+
84+ compare(left.__anim_running, 0)
85+ left.enabled = true
86+ compare(left.__anim_running, 1)
87+ }
88+
89+ function test_skip() {
90+ signalSpy.signalName = "skip"
91+ signalSpy.clear()
92+ var bottomSkip = findChild(bottom, "skipLabel")
93+ mousePress(bottomSkip, 1, 1)
94+ mouseRelease(bottomSkip, 1, 1)
95+ signalSpy.wait()
96+ compare(bottom.enabled, false)
97+ }
98+ }
99+}