@@ -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