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

Proposed by Michael Zanetti
Status: Merged
Approved by: Albert Astals Cid
Approved revision: no longer in the source branch.
Merged at revision: 560
Proposed branch: lp:~mzanetti/unity/phablet-pageheader-tests
Merge into: lp:unity/phablet
Diff against target: 234 lines (+192/-2)
3 files modified
Components/PageHeader.qml (+8/-2)
tests/qmluitests/Components/CMakeLists.txt (+1/-0)
tests/qmluitests/Components/tst_PageHeader.qml (+183/-0)
To merge this branch: bzr merge lp:~mzanetti/unity/phablet-pageheader-tests
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Albert Astals Cid (community) Approve
Review via email: mp+157711@code.launchpad.net

Commit message

tests for PageHeader and SearchHistoryModel

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
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Doesn't merge cleanly anymore

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Looks good

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
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/PageHeader.qml'
2--- Components/PageHeader.qml 2013-03-19 12:50:42 +0000
3+++ Components/PageHeader.qml 2013-04-09 12:26:24 +0000
4@@ -34,7 +34,10 @@
5 height: units.gu(8.5)
6 implicitHeight: units.gu(8.5)
7
8- function triggerSearch() { searchField.forceActiveFocus() }
9+ function triggerSearch() {
10+ if (searchEntryEnabled) searchField.forceActiveFocus()
11+ }
12+
13 function resetSearch() {
14 searchHistory.addQuery(searchField.text);
15 searchField.text = "";
16@@ -72,6 +75,7 @@
17
18 Item {
19 id: textContainer
20+
21 width: header.width
22 height: header.height
23
24@@ -97,10 +101,12 @@
25
26 Item {
27 id: searchContainer
28+ objectName: "searchContainer"
29
30 visible: searchEntryEnabled
31
32- property bool narrowMode: parent.width < units.gu(60)
33+ property bool narrowMode: parent.width < label.contentWidth + units.gu(50)
34+
35 property bool active: searchField.text != "" || searchField.activeFocus
36 property var popover: null
37
38
39=== modified file 'tests/qmluitests/Components/CMakeLists.txt'
40--- tests/qmluitests/Components/CMakeLists.txt 2013-04-08 17:08:40 +0000
41+++ tests/qmluitests/Components/CMakeLists.txt 2013-04-09 12:26:24 +0000
42@@ -5,3 +5,4 @@
43 add_qml_test(Showable)
44 add_qml_test(Stage)
45 add_qml_test(Tile)
46+add_qml_test(PageHeader)
47
48=== added file 'tests/qmluitests/Components/tst_PageHeader.qml'
49--- tests/qmluitests/Components/tst_PageHeader.qml 1970-01-01 00:00:00 +0000
50+++ tests/qmluitests/Components/tst_PageHeader.qml 2013-04-09 12:26:24 +0000
51@@ -0,0 +1,183 @@
52+/*
53+ * Copyright 2013 Canonical Ltd.
54+ *
55+ * This program is free software; you can redistribute it and/or modify
56+ * it under the terms of the GNU General Public License as published by
57+ * the Free Software Foundation; version 3.
58+ *
59+ * This program is distributed in the hope that it will be useful,
60+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
61+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
62+ * GNU General Public License for more details.
63+ *
64+ * You should have received a copy of the GNU General Public License
65+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
66+ */
67+
68+import QtQuick 2.0
69+import QtTest 1.0
70+import ".."
71+import "../../../Components"
72+import Ubuntu.Components 0.1
73+
74+Item {
75+ width: units.gu(110)
76+ height: units.gu(30)
77+
78+ UnityTestCase {
79+ name: "PageHeaderTest"
80+ when: windowShown
81+
82+ property alias searchEnabled : pageHeader.searchEntryEnabled
83+ property alias searchQuery : pageHeader.searchQuery
84+
85+ function test_search_disabled() {
86+ searchEnabled = false
87+ pageHeader.resetSearch()
88+
89+ pageHeader.triggerSearch()
90+ keyClick(Qt.Key_S)
91+
92+ compare(searchQuery, "", "Search entry not disabled properly (could still type in textfield).")
93+ }
94+
95+ function test_search_enable() {
96+ searchEnabled = true
97+ pageHeader.resetSearch()
98+
99+ pageHeader.triggerSearch()
100+ typeString("test")
101+
102+ compare(searchQuery, "test", "Typing in the search field did not change searchQuery")
103+ }
104+
105+ function test_search_hard_coded() {
106+ searchEnabled = true
107+ pageHeader.triggerSearch()
108+ searchQuery = "test1"
109+ typeString("test2")
110+ compare(searchQuery, "test1test2", "Setting searchQuery text does not update the TextField")
111+ }
112+
113+ function test_reset_search() {
114+ searchEnabled = true
115+ pageHeader.resetSearch()
116+
117+ pageHeader.triggerSearch()
118+ keyClick(Qt.Key_S)
119+
120+ compare(searchQuery, "s", "Could not type in TextField.")
121+
122+ pageHeader.resetSearch()
123+ compare(searchQuery, "", "Reset search did not reset searchQuery correctly.")
124+ }
125+
126+ function test_move_search_by_width()
127+ {
128+ searchEnabled = true
129+ pageHeader.resetSearch()
130+
131+ var searchContainer = findChild(pageHeader, "searchContainer")
132+
133+ parent.width = units.gu(40)
134+
135+ verify(searchContainer !== undefined)
136+ verify(searchContainer.y <= 0)
137+
138+ pageHeader.triggerSearch()
139+ verify(searchContainer.y >= 0)
140+
141+ pageHeader.resetSearch()
142+ verify(searchContainer.y <= 0)
143+
144+ parent.width = units.gu(110)
145+ verify(searchContainer.y >= 0)
146+
147+ pageHeader.triggerSearch()
148+ tryCompare(searchContainer.width, units.gu(40))
149+ }
150+
151+ function test_history() {
152+ pageHeader.searchHistory.clear()
153+ compare(pageHeader.searchHistory.count, 0)
154+
155+ pageHeader.triggerSearch()
156+ typeString("humppa1")
157+ pageHeader.resetSearch()
158+
159+ compare(pageHeader.searchHistory.count, 1)
160+ compare(pageHeader.searchHistory.get(0).query, "humppa1")
161+
162+ pageHeader.triggerSearch()
163+ typeString("humppa2")
164+ pageHeader.resetSearch()
165+
166+ compare(pageHeader.searchHistory.count, 2)
167+ compare(pageHeader.searchHistory.get(0).query, "humppa2")
168+
169+ pageHeader.triggerSearch()
170+ typeString("humppa3")
171+ pageHeader.resetSearch()
172+
173+ compare(pageHeader.searchHistory.count, 3)
174+ compare(pageHeader.searchHistory.get(0).query, "humppa3")
175+
176+ pageHeader.triggerSearch()
177+ typeString("humppa4")
178+ pageHeader.resetSearch()
179+
180+ compare(pageHeader.searchHistory.count, 3)
181+ compare(pageHeader.searchHistory.get(0).query, "humppa4")
182+ }
183+ }
184+
185+ Column {
186+ anchors.fill: parent
187+ spacing: units.gu(1)
188+
189+ PageHeader {
190+ id: pageHeader
191+ anchors {
192+ left: parent.left
193+ right: parent.right
194+ }
195+
196+ searchEntryEnabled: true
197+ text: "%^$%^%^&%^&%^$%GHR%"
198+ }
199+
200+ Row {
201+ spacing: units.gu(1)
202+ anchors {
203+ left: parent.left
204+ right: parent.right
205+ }
206+ Button {
207+ text: "Set search query programmatically"
208+ onClicked: pageHeader.searchQuery = "testsearch"
209+ width: units.gu(40)
210+ }
211+ Label {
212+ text: "searchQuery: \"" + pageHeader.searchQuery + "\""
213+ anchors.verticalCenter: parent.verticalCenter
214+ }
215+ }
216+
217+ Row {
218+ spacing: units.gu(1)
219+ anchors {
220+ left: parent.left
221+ right: parent.right
222+ }
223+ Button {
224+ text: "Clear history model"
225+ onClicked: pageHeader.searchHistory.clear()
226+ width: units.gu(40)
227+ }
228+ Label {
229+ text: "History count: " + pageHeader.searchHistory.count
230+ anchors.verticalCenter: parent.verticalCenter
231+ }
232+ }
233+ }
234+}

Subscribers

People subscribed via source and target branches