Merge lp:~pete-woods/hud/no-suggestions-for-legacy-queries into lp:hud/14.04

Proposed by Pete Woods
Status: Superseded
Proposed branch: lp:~pete-woods/hud/no-suggestions-for-legacy-queries
Merge into: lp:hud/14.04
Prerequisite: lp:~pete-woods/hud/dbusmenu-open-crash
Diff against target: 484 lines (+114/-49)
16 files modified
service/Factory.cpp (+3/-2)
service/Factory.h (+2/-1)
service/HudServiceImpl.cpp (+7/-4)
service/HudServiceImpl.h (+2/-1)
service/ItemStore.cpp (+6/-1)
service/ItemStore.h (+3/-1)
service/Query.h (+5/-0)
service/QueryImpl.cpp (+7/-6)
service/QueryImpl.h (+5/-3)
service/Window.h (+3/-1)
service/WindowImpl.cpp (+3/-2)
service/WindowImpl.h (+2/-1)
tests/unit/service/Mocks.h (+3/-2)
tests/unit/service/TestHudService.cpp (+17/-13)
tests/unit/service/TestItemStore.cpp (+32/-2)
tests/unit/service/TestQuery.cpp (+14/-9)
To merge this branch: bzr merge lp:~pete-woods/hud/no-suggestions-for-legacy-queries
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Indicator Applet Developers Pending
Review via email: mp+206993@code.launchpad.net

This proposal has been superseded by a proposal from 2014-02-24.

Commit message

Make legacy queries return no suggestions for the empty search string

Description of the change

* Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
  * Yes
 * Did you build your software in a clean sbuild/pbuilder chroot or ppa?
  * Yes
 * Did you build your software in a clean sbuild/pbuilder armhf chroot or ppa?
  * Yes
 * Has your component "TestPlan” been executed successfully on emulator, N4?
  * Yes
 * Has a 5 minute exploratory testing run been executed on N4?
  * Yes
 * If you changed the packaging (debian), did you subscribe a core-dev to this MP?
  * N/A
 * If you changed the UI, did you subscribe the design-reviewers to this MP?
  * No change
 * What components might get impacted by your changes?
  * Unity7
  * Unity8
 * Have you requested review by the teams of these owning components?
  * Yes

Check List:
https://wiki.ubuntu.com/Process/Merges/Checklists/hud

Test Plan:
https://wiki.ubuntu.com/Process/Merges/TestPlan/hud

Silo:
<missing>

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
375. By Pete Woods

Change GTK documentation so that it builds with the new glib version Fixes: 1287580

376. By PS Jenkins bot

Releasing 13.10.1+14.04.20140304-0ubuntu1

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'service/Factory.cpp'
2--- service/Factory.cpp 2014-02-15 10:23:45 +0000
3+++ service/Factory.cpp 2014-02-19 10:17:23 +0000
4@@ -88,9 +88,10 @@
5 return m_sessionBus;
6 }
7
8-Query::Ptr Factory::newQuery(const QString &query, const QString &sender) {
9+Query::Ptr Factory::newQuery(const QString &query, const QString &sender,
10+ Query::EmptyBehaviour emptyBehaviour) {
11 return Query::Ptr(
12- new QueryImpl(m_queryCounter++, query, sender,
13+ new QueryImpl(m_queryCounter++, query, sender, emptyBehaviour,
14 *singletonHudService(), singletonApplicationList(),
15 singletonVoice(), sessionBus()));
16 }
17
18=== modified file 'service/Factory.h'
19--- service/Factory.h 2014-02-15 10:23:45 +0000
20+++ service/Factory.h 2014-02-19 10:17:23 +0000
21@@ -60,7 +60,8 @@
22
23 virtual QSharedPointer<ComCanonicalAppMenuRegistrarInterface> singletonAppmenu();
24
25- virtual Query::Ptr newQuery(const QString &query, const QString &sender);
26+ virtual Query::Ptr newQuery(const QString &query, const QString &sender,
27+ Query::EmptyBehaviour emptyBehaviour);
28
29 virtual ApplicationList::Ptr singletonApplicationList();
30
31
32=== modified file 'service/HudServiceImpl.cpp'
33--- service/HudServiceImpl.cpp 2013-12-17 16:37:55 +0000
34+++ service/HudServiceImpl.cpp 2014-02-19 10:17:23 +0000
35@@ -62,8 +62,8 @@
36 }
37
38 Query::Ptr HudServiceImpl::createQuery(const QString &query,
39- const QString &sender) {
40- Query::Ptr hudQuery(m_factory.newQuery(query, sender));
41+ const QString &sender, Query::EmptyBehaviour emptyBehaviour) {
42+ Query::Ptr hudQuery(m_factory.newQuery(query, sender, emptyBehaviour));
43 m_queries[hudQuery->path()] = hudQuery;
44
45 return hudQuery;
46@@ -73,7 +73,9 @@
47 QString &resultsName, QString &appstackName, int &modelRevision) {
48 QString sender(messageSender());
49
50- Query::Ptr hudQuery(createQuery(query, sender));
51+ Query::Ptr hudQuery(
52+ createQuery(query, sender,
53+ Query::EmptyBehaviour::SHOW_SUGGESTIONS));
54
55 resultsName = hudQuery->resultsModel();
56 appstackName = hudQuery->appstackModel();
57@@ -104,7 +106,8 @@
58
59 Query::Ptr query(m_legacyQueries[sender]);
60 if (query.isNull()) {
61- query = createQuery(queryString, sender);
62+ query = createQuery(queryString, sender,
63+ Query::EmptyBehaviour::NO_SUGGESTIONS);
64 m_legacyQueries[sender] = query;
65 } else {
66 query->UpdateQuery(queryString);
67
68=== modified file 'service/HudServiceImpl.h'
69--- service/HudServiceImpl.h 2013-12-17 16:37:55 +0000
70+++ service/HudServiceImpl.h 2014-02-19 10:17:23 +0000
71@@ -74,7 +74,8 @@
72 void CloseQuery(const QDBusVariant &querykey);
73
74 protected:
75- Query::Ptr createQuery(const QString &query, const QString &service);
76+ Query::Ptr createQuery(const QString &query, const QString &service,
77+ Query::EmptyBehaviour emptyBehaviour);
78
79 QScopedPointer<HudAdaptor> m_adaptor;
80
81
82=== modified file 'service/ItemStore.cpp'
83--- service/ItemStore.cpp 2014-02-15 10:23:45 +0000
84+++ service/ItemStore.cpp 2014-02-19 10:17:23 +0000
85@@ -150,10 +150,15 @@
86 return result;
87 }
88
89-void ItemStore::search(const QString &query, QList<Result> &results) {
90+void ItemStore::search(const QString &query,
91+ Query::EmptyBehaviour emptyBehaviour, QList<Result> &results) {
92 QStringMatcher stringMatcher(query, Qt::CaseInsensitive);
93
94 if (query.isEmpty()) {
95+ if (emptyBehaviour == Query::EmptyBehaviour::NO_SUGGESTIONS) {
96+ return;
97+ }
98+
99 QMap<unsigned int, DocumentID> tempResults;
100
101 for (auto it(m_items.constBegin()); it != m_items.constEnd(); ++it) {
102
103=== modified file 'service/ItemStore.h'
104--- service/ItemStore.h 2014-02-15 10:23:45 +0000
105+++ service/ItemStore.h 2014-02-19 10:17:23 +0000
106@@ -20,6 +20,7 @@
107 #define HUD_SERVICE_ITEMSTORE_H_
108
109 #include <service/Item.h>
110+#include <service/Query.h>
111 #include <service/Result.h>
112 #include <service/SearchSettings.h>
113 #include <service/UsageTracker.h>
114@@ -50,7 +51,8 @@
115
116 void indexMenu(const QMenu *menu);
117
118- void search(const QString &query, QList<Result> &results);
119+ void search(const QString &query, Query::EmptyBehaviour emptyBehaviour,
120+ QList<Result> &results);
121
122 void execute(unsigned long long commandId);
123
124
125=== modified file 'service/Query.h'
126--- service/Query.h 2013-11-18 09:37:43 +0000
127+++ service/Query.h 2014-02-19 10:17:23 +0000
128@@ -39,6 +39,11 @@
129 public:
130 typedef QSharedPointer<Query> Ptr;
131
132+ enum class EmptyBehaviour {
133+ SHOW_SUGGESTIONS,
134+ NO_SUGGESTIONS,
135+ };
136+
137 explicit Query(QObject *parent = 0);
138
139 virtual ~Query();
140
141=== modified file 'service/QueryImpl.cpp'
142--- service/QueryImpl.cpp 2013-12-20 14:44:11 +0000
143+++ service/QueryImpl.cpp 2014-02-19 10:17:23 +0000
144@@ -30,13 +30,14 @@
145 using namespace hud::service;
146
147 QueryImpl::QueryImpl(unsigned int id, const QString &query,
148- const QString &sender, HudService &service,
149- ApplicationList::Ptr applicationList, Voice::Ptr voice,
150- const QDBusConnection &connection, QObject *parent) :
151+ const QString &sender, EmptyBehaviour emptyBehaviour,
152+ HudService &service, ApplicationList::Ptr applicationList,
153+ Voice::Ptr voice, const QDBusConnection &connection, QObject *parent) :
154 Query(parent), m_adaptor(new QueryAdaptor(this)), m_connection(
155 connection), m_path(DBusTypes::queryPath(id)), m_service(
156- service), m_applicationList(applicationList), m_voice(voice), m_query(
157- query), m_serviceWatcher(sender, m_connection,
158+ service), m_emptyBehaviour(emptyBehaviour), m_applicationList(
159+ applicationList), m_voice(voice), m_query(query), m_serviceWatcher(
160+ sender, m_connection,
161 QDBusServiceWatcher::WatchForUnregistration) {
162
163 connect(&m_serviceWatcher, SIGNAL(serviceUnregistered(const QString &)),
164@@ -202,7 +203,7 @@
165 // Hold onto a token for the active window
166 updateToken(window);
167
168- m_windowToken->search(m_query, m_results);
169+ m_windowToken->search(m_query, m_emptyBehaviour, m_results);
170
171 notifyPropertyChanged("com.canonical.hud.query", "ToolbarItems");
172 }
173
174=== modified file 'service/QueryImpl.h'
175--- service/QueryImpl.h 2013-12-17 16:37:55 +0000
176+++ service/QueryImpl.h 2014-02-19 10:17:23 +0000
177@@ -43,9 +43,9 @@
178 Q_OBJECT
179 public:
180 QueryImpl(unsigned int id, const QString &query, const QString &sender,
181- HudService &service, ApplicationList::Ptr applicationList,
182- Voice::Ptr voice, const QDBusConnection &connection,
183- QObject *parent = 0);
184+ EmptyBehaviour emptyBehaviour, HudService &service,
185+ ApplicationList::Ptr applicationList, Voice::Ptr voice,
186+ const QDBusConnection &connection, QObject *parent = 0);
187
188 virtual ~QueryImpl();
189
190@@ -98,6 +98,8 @@
191
192 HudService &m_service;
193
194+ EmptyBehaviour m_emptyBehaviour;
195+
196 ApplicationList::Ptr m_applicationList;
197
198 Voice::Ptr m_voice;
199
200=== modified file 'service/Window.h'
201--- service/Window.h 2013-12-09 10:53:01 +0000
202+++ service/Window.h 2014-02-19 10:17:23 +0000
203@@ -19,6 +19,7 @@
204 #ifndef HUD_SERVICE_WINDOW_H_
205 #define HUD_SERVICE_WINDOW_H_
206
207+#include <service/Query.h>
208 #include <service/Result.h>
209 #include <service/WindowContext.h>
210
211@@ -35,7 +36,8 @@
212
213 virtual ~WindowToken();
214
215- virtual void search(const QString &query, QList<Result> &results) = 0;
216+ virtual void search(const QString &query,
217+ Query::EmptyBehaviour emptyBehaviour, QList<Result> &results) = 0;
218
219 virtual void execute(unsigned long long commandId) = 0;
220
221
222=== modified file 'service/WindowImpl.cpp'
223--- service/WindowImpl.cpp 2014-02-05 16:51:38 +0000
224+++ service/WindowImpl.cpp 2014-02-19 10:17:23 +0000
225@@ -45,8 +45,9 @@
226 return m_tokens;
227 }
228
229-void WindowTokenImpl::search(const QString &query, QList<Result> &results) {
230- m_items->search(query, results);
231+void WindowTokenImpl::search(const QString &query,
232+ Query::EmptyBehaviour emptyBehaviour, QList<Result> &results) {
233+ m_items->search(query, emptyBehaviour, results);
234 }
235
236 void WindowTokenImpl::execute(unsigned long long commandId) {
237
238=== modified file 'service/WindowImpl.h'
239--- service/WindowImpl.h 2013-12-20 13:19:01 +0000
240+++ service/WindowImpl.h 2014-02-19 10:17:23 +0000
241@@ -44,7 +44,8 @@
242
243 virtual ~WindowTokenImpl();
244
245- void search(const QString &query, QList<Result> &results) override;
246+ void search(const QString &query, Query::EmptyBehaviour emptyBehaviour,
247+ QList<Result> &results) override;
248
249 void execute(unsigned long long commandId) override;
250
251
252=== modified file 'tests/unit/service/Mocks.h'
253--- tests/unit/service/Mocks.h 2013-12-19 12:58:11 +0000
254+++ tests/unit/service/Mocks.h 2014-02-19 10:17:23 +0000
255@@ -34,7 +34,7 @@
256
257 MOCK_METHOD0(sessionBus, QDBusConnection());
258
259- MOCK_METHOD2(newQuery, Query::Ptr( const QString &, const QString &));
260+ MOCK_METHOD3(newQuery, Query::Ptr( const QString &, const QString &, Query::EmptyBehaviour));
261
262 MOCK_METHOD1(newApplication, Application::Ptr(const QString &));
263
264@@ -106,7 +106,8 @@
265
266 class MockWindowToken: public WindowToken {
267 public:
268- MOCK_METHOD2(search, void(const QString &, QList<Result> &));
269+ MOCK_METHOD3(search, void(const QString &,
270+ Query::EmptyBehaviour emptyBehaviour, QList<Result> &));
271
272 MOCK_METHOD1(execute, void(unsigned long long));
273
274
275=== modified file 'tests/unit/service/TestHudService.cpp'
276--- tests/unit/service/TestHudService.cpp 2013-11-21 09:20:54 +0000
277+++ tests/unit/service/TestHudService.cpp 2014-02-19 10:17:23 +0000
278@@ -53,7 +53,8 @@
279 };
280
281 TEST_F(TestHudService, OpenCloseQuery) {
282- HudServiceImpl hudService(factory, applicationList, dbus.sessionConnection());
283+ HudServiceImpl hudService(factory, applicationList,
284+ dbus.sessionConnection());
285
286 QDBusObjectPath queryPath("/path/query0");
287 QString resultsModel("com.canonical.hud.results0");
288@@ -63,7 +64,7 @@
289 ON_CALL(*query, resultsModel()).WillByDefault(Return(resultsModel));
290 ON_CALL(*query, appstackModel()).WillByDefault(Return(appstackModel));
291
292- EXPECT_CALL(factory, newQuery(QString("query text"), QString("local"))).Times(
293+ EXPECT_CALL(factory, newQuery(QString("query text"), QString("local"), Query::EmptyBehaviour::SHOW_SUGGESTIONS)).Times(
294 1).WillOnce(Return(query));
295
296 QString resultsName;
297@@ -83,7 +84,8 @@
298 }
299
300 TEST_F(TestHudService, CloseUnknownQuery) {
301- HudServiceImpl hudService(factory, applicationList, dbus.sessionConnection());
302+ HudServiceImpl hudService(factory, applicationList,
303+ dbus.sessionConnection());
304
305 QDBusObjectPath queryPath("/path/query0");
306
307@@ -93,7 +95,8 @@
308 }
309
310 TEST_F(TestHudService, CreateMultipleQueries) {
311- HudServiceImpl hudService(factory, applicationList, dbus.sessionConnection());
312+ HudServiceImpl hudService(factory, applicationList,
313+ dbus.sessionConnection());
314
315 QDBusObjectPath queryPath0("/path/query0");
316 QString resultsModel0("com.canonical.hud.results0");
317@@ -111,10 +114,10 @@
318 ON_CALL(*query1, resultsModel()).WillByDefault(Return(resultsModel1));
319 ON_CALL(*query1, appstackModel()).WillByDefault(Return(appstackModel1));
320
321- EXPECT_CALL(factory, newQuery(QString("query0"), QString("local"))).Times(1).WillOnce(
322- Return(query0));
323- EXPECT_CALL(factory, newQuery(QString("query1"), QString("local"))).Times(1).WillOnce(
324- Return(query1));
325+ EXPECT_CALL(factory, newQuery(QString("query0"), QString("local"), Query::EmptyBehaviour::SHOW_SUGGESTIONS)).Times(
326+ 1).WillOnce(Return(query0));
327+ EXPECT_CALL(factory, newQuery(QString("query1"), QString("local"), Query::EmptyBehaviour::SHOW_SUGGESTIONS)).Times(
328+ 1).WillOnce(Return(query1));
329
330 int modelRevision;
331 QString resultsName;
332@@ -153,7 +156,8 @@
333 ON_CALL(*applicationList, focusedApplication()).WillByDefault(
334 Return(application));
335
336- HudServiceImpl hudService(factory, applicationList, dbus.sessionConnection());
337+ HudServiceImpl hudService(factory, applicationList,
338+ dbus.sessionConnection());
339
340 QDBusObjectPath queryPath("/path/query0");
341 QList<Result> results;
342@@ -172,7 +176,7 @@
343 ON_CALL(*query, path()).WillByDefault(ReturnRef(queryPath));
344 ON_CALL(*query, results()).WillByDefault(ReturnRef(results));
345
346- EXPECT_CALL(factory, newQuery(QString("query text"), QString("local"))).Times(
347+ EXPECT_CALL(factory, newQuery(QString("query text"), QString("local"), Query::EmptyBehaviour::NO_SUGGESTIONS)).Times(
348 1).WillOnce(Return(query));
349
350 QList<Suggestion> suggestions;
351@@ -213,13 +217,13 @@
352
353 QSharedPointer<MockApplication> application(
354 new NiceMock<MockApplication>());
355- ON_CALL(*application, path()).WillByDefault(
356- ReturnRef(path));
357+ ON_CALL(*application, path()).WillByDefault(ReturnRef(path));
358
359 EXPECT_CALL(*applicationList, ensureApplication(QString("app-id"))).WillOnce(
360 Return(application));
361
362- HudServiceImpl hudService(factory, applicationList, dbus.sessionConnection());
363+ HudServiceImpl hudService(factory, applicationList,
364+ dbus.sessionConnection());
365
366 EXPECT_EQ(path, hudService.RegisterApplication("app-id"));
367 }
368
369=== modified file 'tests/unit/service/TestItemStore.cpp'
370--- tests/unit/service/TestItemStore.cpp 2014-02-17 09:58:27 +0000
371+++ tests/unit/service/TestItemStore.cpp 2014-02-19 10:17:23 +0000
372@@ -44,7 +44,7 @@
373 /* Test a set of strings */
374 string search(const QString &query) {
375 QList<Result> results;
376- store->search(query, results);
377+ store->search(query, Query::EmptyBehaviour::SHOW_SUGGESTIONS, results);
378
379 QString result;
380
381@@ -257,7 +257,7 @@
382 Return(3));
383
384 QList<Result> results;
385- store->search("", results);
386+ store->search("", Query::EmptyBehaviour::SHOW_SUGGESTIONS, results);
387 ASSERT_EQ(4, results.size());
388 EXPECT_EQ(QString("Three"), results.at(0).commandName());
389 EXPECT_EQ(QString("Four"), results.at(1).commandName());
390@@ -265,6 +265,36 @@
391 EXPECT_EQ(QString("Two"), results.at(3).commandName());
392 }
393
394+TEST_F(TestItemStore, BlankSearchNoSuggestions) {
395+ QMenu root;
396+
397+ QMenu file("&File");
398+ file.addAction("&One");
399+ file.addAction("&Two");
400+ file.addAction("T&hree");
401+ file.addAction("Fou&r");
402+ root.addMenu(&file);
403+
404+ store->indexMenu(&root);
405+
406+ ON_CALL(*usageTracker,
407+ usage(QString("app-id"), QString("File||One"))).WillByDefault(
408+ Return(2));
409+ ON_CALL(*usageTracker,
410+ usage(QString("app-id"), QString("File||Two"))).WillByDefault(
411+ Return(0));
412+ ON_CALL(*usageTracker,
413+ usage(QString("app-id"), QString("File||Three"))).WillByDefault(
414+ Return(4));
415+ ON_CALL(*usageTracker,
416+ usage(QString("app-id"), QString("File||Four"))).WillByDefault(
417+ Return(3));
418+
419+ QList<Result> results;
420+ store->search("", Query::EmptyBehaviour::NO_SUGGESTIONS, results);
421+ ASSERT_TRUE(results.empty());
422+}
423+
424 TEST_F(TestItemStore, ExecuteMarksHistory) {
425 QMenu root;
426
427
428=== modified file 'tests/unit/service/TestQuery.cpp'
429--- tests/unit/service/TestQuery.cpp 2013-12-09 11:11:18 +0000
430+++ tests/unit/service/TestQuery.cpp 2014-02-19 10:17:23 +0000
431@@ -113,13 +113,15 @@
432
433 EXPECT_CALL(*window, activate()).WillOnce(Return(windowToken));
434
435- EXPECT_CALL(*windowToken, search(queryString, _)).WillOnce(
436- Invoke([&expectedResults](const QString &, QList<Result> &results) {
437+ EXPECT_CALL(*windowToken, search(queryString, Query::EmptyBehaviour::SHOW_SUGGESTIONS, _)).WillOnce(
438+ Invoke(
439+ [&expectedResults](const QString &, Query::EmptyBehaviour, QList<Result> &results) {
440 results.append(expectedResults);
441 }));
442
443- QueryImpl query(0, queryString, "keep.alive", *hudService, applicationList,
444- voice, dbus.sessionConnection());
445+ QueryImpl query(0, queryString, "keep.alive",
446+ Query::EmptyBehaviour::SHOW_SUGGESTIONS, *hudService,
447+ applicationList, voice, dbus.sessionConnection());
448
449 const QList<Result> results(query.results());
450 ASSERT_EQ(expectedResults.size(), results.size());
451@@ -129,8 +131,9 @@
452 }
453
454 TEST_F(TestQuery, ExecuteCommand) {
455- QueryImpl query(0, "query", "keep.alive", *hudService, applicationList,
456- voice, dbus.sessionConnection());
457+ QueryImpl query(0, "query", "keep.alive",
458+ Query::EmptyBehaviour::SHOW_SUGGESTIONS, *hudService,
459+ applicationList, voice, dbus.sessionConnection());
460
461 EXPECT_CALL(*windowToken, execute(123));
462 query.ExecuteCommand(QDBusVariant(123), 12345);
463@@ -144,7 +147,8 @@
464 keepAliveService->start(dbus.sessionConnection());
465
466 Query::Ptr query(
467- new QueryImpl(0, "query", "keep.alive", *hudService,
468+ new QueryImpl(0, "query", "keep.alive",
469+ Query::EmptyBehaviour::SHOW_SUGGESTIONS, *hudService,
470 applicationList, voice, dbus.sessionConnection()));
471
472 EXPECT_CALL(*hudService, closeQuery(query->path())).WillOnce(
473@@ -169,8 +173,9 @@
474 }
475
476 TEST_F(TestQuery, VoiceQuery) {
477- QueryImpl query(0, "query", "keep.alive", *hudService, applicationList,
478- voice, dbus.sessionConnection());
479+ QueryImpl query(0, "query", "keep.alive",
480+ Query::EmptyBehaviour::SHOW_SUGGESTIONS, *hudService,
481+ applicationList, voice, dbus.sessionConnection());
482
483 EXPECT_CALL(*voice, listen(QList<QStringList>()
484 << (QStringList() << "command1" << "command2"))).WillOnce(

Subscribers

People subscribed via source and target branches