on xenial help sign in
Merge new-header.
commitb2d0dd28b1bc3efac104706222727d7e23ba28ac authorMichał Sawicz <michal.sawicz@canonical.com> dateSat 5 Jul 2014, 11:50 (12 years ago) parenta8a951b2f0fabb
4 files changed+35−110
qml/Components/PageHeader.qml+16−6 tests/qmltests/Components/tst_PageHeader.qml+15−4 tests/qmltests/Dash/tst_DashContent.qml+4−64 tests/qmltests/tst_Shell.qml−36
qml/Components/PageHeader.qml+16−6
@@ -43,7 +43,10 @@ Item {
4343 signal backClicked()
4444
4545 function triggerSearch() {
46− if (searchEntryEnabled) searchTextField.forceActiveFocus();
46+ if (searchEntryEnabled) {
47+ headerContainer.showSearch = true;
48+ searchTextField.forceActiveFocus();
49+ }
4750 }
4851
4952 function resetSearch(keepFocus) {
@@ -89,10 +92,17 @@ Item {
8992 }
9093
9194 InverseMouseArea {
92− anchors.fill: parent
93− visible: headerContainer.popover !== null
95+ anchors { fill: parent; margins: units.gu(1); bottomMargin: units.gu(3) + bottomContainer.height }
96+ visible: headerContainer.showSearch
9497 onPressed: {
95− PopupUtils.close(headerContainer.popover);
98+ if (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;
96106 }
97107 }
98108
@@ -159,6 +169,7 @@ Item {
159169 secondaryItem: AbstractButton {
160170 height: searchTextField.height
161171 width: height
172+ enabled: searchTextField.text.length > 0
162173
163174 Image {
164175 objectName: "clearIcon"
@@ -200,6 +211,7 @@ Item {
200211
201212 PageHeadStyle {
202213 id: header
214+ objectName: "pageHeader"
203215 anchors { left: parent.left; right: parent.right }
204216 height: headerContainer.height
205217 contentHeight: height
@@ -271,8 +283,6 @@ Item {
271283 right: parent.right
272284 }
273285
274− Standard { enabled: false; text: i18n.tr("Recent searches") }
275−
276286 Repeater {
277287 id: recentSearches
278288 model: searchHistory
tests/qmltests/Components/tst_PageHeader.qml+15−4
@@ -23,6 +23,7 @@ import Unity 0.2
2323import Unity.Test 0.1 as UT
2424
2525Item {
26+ id: root
2627 width: units.gu(110)
2728 height: units.gu(30)
2829
@@ -167,7 +168,14 @@ Item {
167168 tryCompare(headerContainer.popover, "visible", true);
168169 }
169170
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) {
171179 searchEnabled = true;
172180 pageHeader.searchHistory.clear();
173181
@@ -181,11 +189,14 @@ Item {
181189 tryCompareFunction(function() { return headerContainer.popover !== null; }, true);
182190 compare(headerContainer.popover.visible, true);
183191
184− pageHeader.searchQuery = "test";
185− tryCompareFunction( function() { return (headerContainer.popover===null || !headerContainer.popover.visible) }, true);
192+ pageHeader.searchQuery = data.searchText;
193+
194+ mouseClick(root, root.width / 2, root.height - 1);
195+
196+ tryCompare(headerContainer, "showSearch", !data.hideSearch);
197+ tryCompareFunction(function() { return headerContainer.popover === null; }, true);
186198
187199 pageHeader.resetSearch();
188− compare((headerContainer.popover===null || !headerContainer.popover.visible), true);
189200 }
190201 }
191202
tests/qmltests/Dash/tst_DashContent.qml+4−64
@@ -193,7 +193,7 @@ Item {
193193 dashContent.setCurrentScopeAtIndex(data.index, true, false);
194194 tryCompareFunction(get_current_item_object_name, data.objectName)
195195 var pageHeader = findChild(dashContent, "pageHeader");
196− compare(pageHeader.scope, scopesModel.getScope(data.index));
196+ compare(pageHeader.title, scopesModel.getScope(data.index).name);
197197 }
198198
199199 function test_is_active_data() {
@@ -215,67 +215,6 @@ Item {
215215 tryCompare(scopesModel.getScope(2), "isActive", data.active2);
216216 }
217217
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−
279218 function checkFlickMovingAndNotInteractive()
280219 {
281220 var dashContentList = findChild(dashContent, "dashContentList");
@@ -316,8 +255,8 @@ Item {
316255 }
317256
318257 function closePreview() {
319− var closePreviewMouseArea = findChild(dashContent, "dashContentPreviewList_pageHeader_backButton");
320− mouseClick(closePreviewMouseArea, closePreviewMouseArea.width / 2, closePreviewMouseArea.height / 2);
258+ var closePreviewMouseArea = findChild(dashContent, "pageHeader");
259+ mouseClick(closePreviewMouseArea, units.gu(2), units.gu(2));
321260
322261 var previewListView = findChild(dashContent, "dashContentPreviewList");
323262 tryCompare(previewListView, "open", false);
@@ -459,6 +398,7 @@ Item {
459398 compare(allButton.visible, true);
460399 compare(backButton.visible, true);
461400
401+ waitForRendering(departmentListView);
462402 mouseClick(allButton, 0, 0);
463403 compare(dashDepartments.showList, false);
464404 tryCompare(dashDepartments.currentDepartment, "departmentId", "middle2");
tests/qmltests/tst_Shell.qml−36
@@ -510,42 +510,6 @@ Item {
510510 tryCompare(dash, "shown", data.expectedShown);
511511 }
512512
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−
549513 function test_focusRequestedHidesGreeter() {
550514 var greeter = findChild(shell, "greeter")
551515