on xenial help sign in
Merge new-header.
b2d0dd2Michał Sawicz
qml/Components/PageHeader.qml+16−6
@@ -43,7 +43,10 @@ Item {
43 signal backClicked()
43 signal backClicked()
44
44
45 function triggerSearch() {
45 function triggerSearch() {
46+ if (searchEntryEnabled) {
47+ headerContainer.showSearch = true;
46− if (searchEntryEnabled) searchTextField.forceActiveFocus();
48+ searchTextField.forceActiveFocus();
49+ }
47 }
50 }
48
51
49 function resetSearch(keepFocus) {
52 function resetSearch(keepFocus) {
@@ -89,10 +92,17 @@ Item {
89 }
92 }
90
93
91 InverseMouseArea {
94 InverseMouseArea {
92− anchors.fill: parent
95+ anchors { fill: parent; margins: units.gu(1); bottomMargin: units.gu(3) + bottomContainer.height }
93− visible: headerContainer.popover !== null
96+ visible: headerContainer.showSearch
94 onPressed: {
97 onPressed: {
98+ if (headerContainer.popover) {
95− PopupUtils.close(headerContainer.popover);
99+ PopupUtils.close(headerContainer.popover);
100+ }
101+ if (!searchTextField.text) {
102+ headerContainer.showSearch = false;
103+ }
104+ searchTextField.focus = false;
105+ mouse.accepted = false;
96 }
106 }
97 }
107 }
98
108
@@ -159,6 +169,7 @@ Item {
159 secondaryItem: AbstractButton {
169 secondaryItem: AbstractButton {
160 height: searchTextField.height
170 height: searchTextField.height
161 width: height
171 width: height
172+ enabled: searchTextField.text.length > 0
162
173
163 Image {
174 Image {
164 objectName: "clearIcon"
175 objectName: "clearIcon"
@@ -200,6 +211,7 @@ Item {
200
211
201 PageHeadStyle {
212 PageHeadStyle {
202 id: header
213 id: header
214+ objectName: "pageHeader"
203 anchors { left: parent.left; right: parent.right }
215 anchors { left: parent.left; right: parent.right }
204 height: headerContainer.height
216 height: headerContainer.height
205 contentHeight: height
217 contentHeight: height
@@ -271,8 +283,6 @@ Item {
271 right: parent.right
283 right: parent.right
272 }
284 }
273
285
274− Standard { enabled: false; text: i18n.tr("Recent searches") }
275−
276 Repeater {
286 Repeater {
277 id: recentSearches
287 id: recentSearches
278 model: searchHistory
288 model: searchHistory
tests/qmltests/Components/tst_PageHeader.qml+15−4
@@ -23,6 +23,7 @@ import Unity 0.2
23import Unity.Test 0.1 as UT
23import Unity.Test 0.1 as UT
24
24
25Item {
25Item {
26+ id: root
26 width: units.gu(110)
27 width: units.gu(110)
27 height: units.gu(30)
28 height: units.gu(30)
28
29
@@ -167,7 +168,14 @@ Item {
167 tryCompare(headerContainer.popover, "visible", true);
168 tryCompare(headerContainer.popover, "visible", true);
168 }
169 }
169
170
170− function test_resetSearch_closes_popup() {
171+ function test_tap_outside_closes_popup_data() {
172+ return [
173+ { tag: "with search text", searchText: "foobar", hideSearch: false },
174+ { tag: "without search text", searchText: "", hideSearch: true }
175+ ];
176+ }
177+
178+ function test_tap_outside_closes_popup(data) {
171 searchEnabled = true;
179 searchEnabled = true;
172 pageHeader.searchHistory.clear();
180 pageHeader.searchHistory.clear();
173
181
@@ -181,11 +189,14 @@ Item {
181 tryCompareFunction(function() { return headerContainer.popover !== null; }, true);
189 tryCompareFunction(function() { return headerContainer.popover !== null; }, true);
182 compare(headerContainer.popover.visible, true);
190 compare(headerContainer.popover.visible, true);
183
191
184− pageHeader.searchQuery = "test";
192+ pageHeader.searchQuery = data.searchText;
193+
194+ mouseClick(root, root.width / 2, root.height - 1);
195+
196+ tryCompare(headerContainer, "showSearch", !data.hideSearch);
185− tryCompareFunction( function() { return (headerContainer.popover===null || !headerContainer.popover.visible) }, true);
197+ tryCompareFunction(function() { return headerContainer.popover === null; }, true);
186
198
187 pageHeader.resetSearch();
199 pageHeader.resetSearch();
188− compare((headerContainer.popover===null || !headerContainer.popover.visible), true);
189 }
200 }
190 }
201 }
191
202
tests/qmltests/Dash/tst_DashContent.qml+4−64
@@ -193,7 +193,7 @@ Item {
193 dashContent.setCurrentScopeAtIndex(data.index, true, false);
193 dashContent.setCurrentScopeAtIndex(data.index, true, false);
194 tryCompareFunction(get_current_item_object_name, data.objectName)
194 tryCompareFunction(get_current_item_object_name, data.objectName)
195 var pageHeader = findChild(dashContent, "pageHeader");
195 var pageHeader = findChild(dashContent, "pageHeader");
196− compare(pageHeader.scope, scopesModel.getScope(data.index));
196+ compare(pageHeader.title, scopesModel.getScope(data.index).name);
197 }
197 }
198
198
199 function test_is_active_data() {
199 function test_is_active_data() {
@@ -215,67 +215,6 @@ Item {
215 tryCompare(scopesModel.getScope(2), "isActive", data.active2);
215 tryCompare(scopesModel.getScope(2), "isActive", data.active2);
216 }
216 }
217
217
218− function doFindMusicButton(parent) {
219− for (var i = 0; i < parent.children.length; i++) {
220− var c = parent.children[i];
221− if (UT.Util.isInstanceOf(c, "AbstractButton") && parent.x >= 0) {
222− for (var ii = 0; ii < c.children.length; ii++) {
223− var cc = c.children[ii];
224− if (UT.Util.isInstanceOf(cc, "Label") && cc.text == "Music") {
225− return c;
226− }
227− }
228− }
229− var r = doFindMusicButton(c);
230− if (r !== undefined) {
231− return r;
232− }
233− }
234− return undefined;
235− }
236−
237− function findMusicButton() {
238− // We need to find a AbstractButton that has a Label child
239− // with text Music and it's parent x is >= 0
240− var tabbar = findChild(dashContent, "tabbar");
241− return doFindMusicButton(tabbar);
242− }
243−
244− function test_tabBar_index_change() {
245− tryCompare(scopesModel, "loaded", true);
246− var tabbar = findChild(dashContent, "tabbar");
247−
248− tryCompare(dashContent, "currentIndex", 0);
249− tryCompare(tabbar, "selectedIndex", 0);
250− tryCompare(tabbar, "selectionMode", false);
251−
252− mouseClick(tabbar, units.gu(5), units.gu(5))
253−
254− tryCompare(tabbar, "selectionMode", true);
255− tryCompare(tabbar, "selectedIndex", 0);
256− tryCompare(dashContent, "currentIndex", 0);
257−
258− var button;
259− tryCompareFunction(function() { button = findMusicButton(); return button != undefined; }, true);
260− waitForRendering(button);
261−
262− tryCompareFunction(function() { return button.opacity > 0; }, true);
263− mouseClick(button, button.width / 2, button.height / 2)
264−
265− tryCompare(tabbar, "selectionMode", false);
266− tryCompare(tabbar, "selectedIndex", 1);
267− tryCompare(dashContent, "currentIndex", 1);
268− }
269−
270− function test_tabBar_listens_to_index_change() {
271− var tabbar = findChild(dashContent, "tabbar");
272− tryCompare(dashContent, "currentIndex", 0);
273− compare(tabbar.selectedIndex, 0);
274− var dashContentList = findChild(dashContent, "dashContentList");
275− dashContentList.currentIndex = 1;
276− compare(tabbar.selectedIndex, 1);
277− }
278−
279 function checkFlickMovingAndNotInteractive()
218 function checkFlickMovingAndNotInteractive()
280 {
219 {
281 var dashContentList = findChild(dashContent, "dashContentList");
220 var dashContentList = findChild(dashContent, "dashContentList");
@@ -316,8 +255,8 @@ Item {
316 }
255 }
317
256
318 function closePreview() {
257 function closePreview() {
319− var closePreviewMouseArea = findChild(dashContent, "dashContentPreviewList_pageHeader_backButton");
258+ var closePreviewMouseArea = findChild(dashContent, "pageHeader");
320− mouseClick(closePreviewMouseArea, closePreviewMouseArea.width / 2, closePreviewMouseArea.height / 2);
259+ mouseClick(closePreviewMouseArea, units.gu(2), units.gu(2));
321
260
322 var previewListView = findChild(dashContent, "dashContentPreviewList");
261 var previewListView = findChild(dashContent, "dashContentPreviewList");
323 tryCompare(previewListView, "open", false);
262 tryCompare(previewListView, "open", false);
@@ -459,6 +398,7 @@ Item {
459 compare(allButton.visible, true);
398 compare(allButton.visible, true);
460 compare(backButton.visible, true);
399 compare(backButton.visible, true);
461
400
401+ waitForRendering(departmentListView);
462 mouseClick(allButton, 0, 0);
402 mouseClick(allButton, 0, 0);
463 compare(dashDepartments.showList, false);
403 compare(dashDepartments.showList, false);
464 tryCompare(dashDepartments.currentDepartment, "departmentId", "middle2");
404 tryCompare(dashDepartments.currentDepartment, "departmentId", "middle2");
tests/qmltests/tst_Shell.qml−36
@@ -510,42 +510,6 @@ Item {
510 tryCompare(dash, "shown", data.expectedShown);
510 tryCompare(dash, "shown", data.expectedShown);
511 }
511 }
512
512
513− function test_searchIndicatorHidesOnAppFocus() {
514− var searchIndicator = findChild(shell, "container")
515− tryCompare(searchIndicator, "opacity", 1)
516− dragLauncherIntoView();
517−
518− // Launch an app from the launcher
519− tapOnAppIconInLauncher();
520− waitUntilApplicationWindowIsFullyVisible();
521−
522− tryCompare(searchIndicator, "opacity", 0);
523− }
524−
525− function test_searchIndicatorHidesOnGreeterShown() {
526− var searchIndicator = findChild(shell, "container")
527− var greeter = findChild(shell, "greeter");
528−
529− tryCompare(searchIndicator, "opacity", 1)
530−
531− greeter.show()
532− tryCompare(greeter, "shown", true)
533− tryCompare(searchIndicator, "opacity", 0)
534− }
535−
536− function test_searchIndicatorHideOnPreviewShown() {
537− var searchIndicator = findChild(shell, "container");
538− var dashContent = findChild(shell, "dashContent");
539−
540− verify(dashContent != null);
541−
542− tryCompare(searchIndicator, "opacity", 1);
543−
544− dashContent.previewOpen = true;
545−
546− tryCompare(searchIndicator, "opacity", 0);
547− }
548−
549 function test_focusRequestedHidesGreeter() {
513 function test_focusRequestedHidesGreeter() {
550 var greeter = findChild(shell, "greeter")
514 var greeter = findChild(shell, "greeter")
551
515