@@ -36,6 +36,16 @@ Item {
3636
3737 function init() {
3838 searchEnabled = true;
39+
40+ // Reset to initial state
41+ pageHeader.searchQuery = "";
42+ pageHeader.closePopup();
43+ pageHeader.searchHistory.clear();
44+
45+ // Check initial state
46+ var headerContainer = findChild(pageHeader, "headerContainer");
47+ tryCompareFunction(function() { return headerContainer.popover === null; }, true);
48+ compare(pageHeader.searchHistory.count, 0);
3949 }
4050
4151 function test_search_disabled() {
@@ -80,9 +90,6 @@ Item {
8090 }
8191
8292 function test_history() {
83− pageHeader.searchHistory.clear()
84− compare(pageHeader.searchHistory.count, 0)
85−
8693 pageHeader.triggerSearch()
8794 typeString("humppa1")
8895 pageHeader.resetSearch()
@@ -168,14 +175,14 @@ Item {
168175 tryCompare(headerContainer.popover, "visible", true);
169176 }
170177
171− function test_tap_outside_closes_popup_data() {
178+ function test_popup_closing_data() {
172179 return [
173180 { tag: "with search text", searchText: "foobar", hideSearch: false },
174181 { tag: "without search text", searchText: "", hideSearch: true }
175182 ];
176183 }
177184
178− function test_tap_outside_closes_popup(data) {
185+ function test_popup_closing(data) {
179186 searchEnabled = true;
180187 pageHeader.searchHistory.clear();
181188
@@ -191,7 +198,11 @@ Item {
191198
192199 pageHeader.searchQuery = data.searchText;
193200
194− mouseClick(root, root.width / 2, root.height - 1);
201+ if (data.searchText == "") {
202+ // When the text is empty the user can also close the
203+ // popup by clicking outside the header instead of by starting a search
204+ mouseClick(root, root.width / 2, root.height - 1);
205+ }
195206
196207 tryCompare(headerContainer, "showSearch", !data.hideSearch);
197208 tryCompareFunction(function() { return headerContainer.popover === null; }, true);