Merge lp:~azzar1/unity/lp-1152733 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 3211
Proposed branch: lp:~azzar1/unity/lp-1152733
Merge into: lp:unity
Diff against target: 1365 lines (+570/-348)
17 files modified
UnityCore/FilesystemLenses.h (+4/-4)
UnityCore/HomeLens.cpp (+8/-3)
UnityCore/HomeLens.h (+5/-4)
UnityCore/Lenses.h (+3/-0)
dash/ApplicationStarter.h (+40/-0)
dash/ApplicationStarterImp.cpp (+72/-0)
dash/ApplicationStarterImp.h (+34/-0)
dash/CMakeLists.txt (+1/-0)
dash/DashController.cpp (+2/-1)
dash/DashView.cpp (+21/-66)
dash/DashView.h (+6/-3)
dash/ResultViewGrid.cpp (+2/-1)
dash/StandaloneDash.cpp (+3/-1)
tests/CMakeLists.txt (+1/-0)
tests/mock-lenses.h (+271/-0)
tests/test_dash_view.cpp (+67/-0)
tests/test_home_lens.cpp (+30/-265)
To merge this branch: bzr merge lp:~azzar1/unity/lp-1152733
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Brandon Schaefer (community) Approve
Review via email: mp+153020@code.launchpad.net

Commit message

Export the event timestamp on dash icon click.

Description of the change

== Problem ==
Nautilus windows don't get the the focus when opened via the dash.

== Fix ==
Export the event timestamp on dash icon click. Please keep in mind that the diff is not so small but I just moved code for the most.

== Test ==
Unit test added. Just tests ApplicationStarter*::Launch is getting called.

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Awesome, confirmed working here. Tests pass. LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Approved!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UnityCore/FilesystemLenses.h'
2--- UnityCore/FilesystemLenses.h 2012-03-29 04:40:53 +0000
3+++ UnityCore/FilesystemLenses.h 2013-03-12 22:36:20 +0000
4@@ -82,10 +82,10 @@
5
6 ~FilesystemLenses();
7
8- LensList GetLenses() const;
9- Lens::Ptr GetLens(std::string const& lens_id) const;
10- Lens::Ptr GetLensAtIndex(std::size_t index) const;
11- Lens::Ptr GetLensForShortcut(std::string const& lens_shortcut) const;
12+ LensList GetLenses() const override;
13+ Lens::Ptr GetLens(std::string const& lens_id) const override;
14+ Lens::Ptr GetLensAtIndex(std::size_t index) const override;
15+ Lens::Ptr GetLensForShortcut(std::string const& lens_shortcut) const override;
16
17 sigc::signal<void> lenses_loaded;
18
19
20=== modified file 'UnityCore/HomeLens.cpp'
21--- UnityCore/HomeLens.cpp 2012-11-14 08:57:56 +0000
22+++ UnityCore/HomeLens.cpp 2013-03-12 22:36:20 +0000
23@@ -1116,14 +1116,14 @@
24 delete pimpl;
25 }
26
27-void HomeLens::AddLenses(Lenses& lenses)
28+void HomeLens::AddLenses(Lenses::Ptr const& lenses)
29 {
30- for (auto lens : lenses.GetLenses())
31+ for (auto lens : lenses->GetLenses())
32 {
33 pimpl->OnLensAdded(lens);
34 }
35
36- lenses.lens_added.connect(sigc::mem_fun(pimpl, &HomeLens::Impl::OnLensAdded));
37+ lenses->lens_added.connect(sigc::mem_fun(pimpl, &HomeLens::Impl::OnLensAdded));
38 }
39
40 Lenses::LensList HomeLens::GetLenses() const
41@@ -1158,6 +1158,11 @@
42 return Lens::Ptr();
43 }
44
45+Lens::Ptr HomeLens::GetLensForShortcut(std::string const& lens_shortcut) const
46+{
47+ return Lens::Ptr();
48+}
49+
50 void HomeLens::GlobalSearch(std::string const& search_string, SearchFinishedCallback const& cb)
51 {
52 LOG_WARN(logger) << "Global search not enabled for HomeLens class."
53
54=== modified file 'UnityCore/HomeLens.h'
55--- UnityCore/HomeLens.h 2012-11-12 11:07:23 +0000
56+++ UnityCore/HomeLens.h 2013-03-12 22:36:20 +0000
57@@ -63,11 +63,12 @@
58 MergeMode merge_mode = MergeMode::OWNER_LENS);
59 virtual ~HomeLens();
60
61- void AddLenses(Lenses& lenses);
62+ void AddLenses(Lenses::Ptr const& lenses);
63
64- Lenses::LensList GetLenses() const;
65- Lens::Ptr GetLens(std::string const& lens_id) const;
66- Lens::Ptr GetLensAtIndex(std::size_t index) const;
67+ Lenses::LensList GetLenses() const override;
68+ Lens::Ptr GetLens(std::string const& lens_id) const override;
69+ Lens::Ptr GetLensAtIndex(std::size_t index) const override;
70+ Lens::Ptr GetLensForShortcut(std::string const& lens_shortcut) const override;
71
72 void GlobalSearch(std::string const& search_string, SearchFinishedCallback const& cb);
73 void Search(std::string const& search_string, SearchFinishedCallback const& cb);
74
75=== modified file 'UnityCore/Lenses.h'
76--- UnityCore/Lenses.h 2011-07-27 17:35:31 +0000
77+++ UnityCore/Lenses.h 2013-03-12 22:36:20 +0000
78@@ -20,6 +20,7 @@
79 #ifndef UNITY_LENSES_H
80 #define UNITY_LENSES_H
81
82+#include <memory>
83 #include <sigc++/trackable.h>
84 #include <sigc++/signal.h>
85
86@@ -33,6 +34,7 @@
87 class Lenses : public sigc::trackable, boost::noncopyable
88 {
89 public:
90+ typedef std::shared_ptr<Lenses> Ptr;
91 typedef std::vector<Lens::Ptr> LensList;
92
93 /**
94@@ -45,6 +47,7 @@
95 virtual LensList GetLenses() const = 0;
96 virtual Lens::Ptr GetLens(std::string const& lens_id) const = 0;
97 virtual Lens::Ptr GetLensAtIndex(std::size_t index) const = 0;
98+ virtual Lens::Ptr GetLensForShortcut(std::string const& lens_shortcut) const = 0;
99
100 nux::ROProperty<std::size_t> count;
101
102
103=== added file 'dash/ApplicationStarter.h'
104--- dash/ApplicationStarter.h 1970-01-01 00:00:00 +0000
105+++ dash/ApplicationStarter.h 2013-03-12 22:36:20 +0000
106@@ -0,0 +1,40 @@
107+/*
108+ * Copyright (C) 2013 Canonical Ltd
109+ *
110+ * This program is free software: you can redistribute it and/or modify
111+ * it under the terms of the GNU General Public License version 3 as
112+ * published by the Free Software Foundation.
113+ *
114+ * This program is distributed in the hope that it will be useful,
115+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
116+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
117+ * GNU General Public License for more details.
118+ *
119+ * You should have received a copy of the GNU General Public License
120+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
121+ *
122+ * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
123+ */
124+
125+#ifndef UNITY_SHARED_APPLICATION_STARTER_H
126+#define UNITY_SHARED_APPLICATION_STARTER_H
127+
128+#include <boost/noncopyable.hpp>
129+#include <memory>
130+#include <string>
131+
132+#include <X11/X.h>
133+
134+namespace unity {
135+
136+class ApplicationStarter : boost::noncopyable
137+{
138+public:
139+ typedef std::shared_ptr<ApplicationStarter> Ptr;
140+
141+ virtual bool Launch(std::string const& application_name, Time timestamp) = 0;
142+};
143+
144+}
145+
146+#endif
147
148=== added file 'dash/ApplicationStarterImp.cpp'
149--- dash/ApplicationStarterImp.cpp 1970-01-01 00:00:00 +0000
150+++ dash/ApplicationStarterImp.cpp 2013-03-12 22:36:20 +0000
151@@ -0,0 +1,72 @@
152+/*
153+ * Copyright (C) 2013 Canonical Ltd
154+ *
155+ * This program is free software: you can redistribute it and/or modify
156+ * it under the terms of the GNU General Public License version 3 as
157+ * published by the Free Software Foundation.
158+ *
159+ * This program is distributed in the hope that it will be useful,
160+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
161+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
162+ * GNU General Public License for more details.
163+ *
164+ * You should have received a copy of the GNU General Public License
165+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
166+ *
167+ * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
168+ */
169+
170+#include "ApplicationStarterImp.h"
171+
172+#include <gdk/gdk.h>
173+#include <gio/gdesktopappinfo.h>
174+
175+#include <NuxCore/Logger.h>
176+#include <UnityCore/GLibWrapper.h>
177+
178+namespace unity {
179+
180+DECLARE_LOGGER(logger, "unity.applicationstarterimp");
181+
182+bool ApplicationStarterImp::Launch(std::string const& application_name, Time timestamp)
183+{
184+ std::string id = application_name;
185+
186+ LOG_DEBUG(logger) << "Launching " << id;
187+
188+ GdkDisplay* display = gdk_display_get_default();
189+ glib::Object<GdkAppLaunchContext> app_launch_context(gdk_display_get_app_launch_context(display));
190+
191+ if (timestamp >= 0)
192+ gdk_app_launch_context_set_timestamp(app_launch_context, timestamp);
193+
194+ while (true)
195+ {
196+ glib::Object<GDesktopAppInfo> info(g_desktop_app_info_new(id.c_str()));
197+
198+ if (info)
199+ {
200+ glib::Error error;
201+ g_app_info_launch(glib::object_cast<GAppInfo>(info), nullptr,
202+ glib::object_cast<GAppLaunchContext>(app_launch_context), &error);
203+
204+ if (error)
205+ LOG_WARNING(logger) << "Unable to launch " << id << ":" << error;
206+ else
207+ return true;
208+
209+ break;
210+ }
211+
212+ // Try to replace the next - with a / and do the lookup again.
213+ auto pos = id.find_first_of('-');
214+ if (pos != std::string::npos)
215+ id.replace(pos, 1, "/");
216+ else
217+ break;
218+ }
219+
220+ return false;
221+}
222+
223+}
224
225=== added file 'dash/ApplicationStarterImp.h'
226--- dash/ApplicationStarterImp.h 1970-01-01 00:00:00 +0000
227+++ dash/ApplicationStarterImp.h 2013-03-12 22:36:20 +0000
228@@ -0,0 +1,34 @@
229+/*
230+ * Copyright (C) 2013 Canonical Ltd
231+ *
232+ * This program is free software: you can redistribute it and/or modify
233+ * it under the terms of the GNU General Public License version 3 as
234+ * published by the Free Software Foundation.
235+ *
236+ * This program is distributed in the hope that it will be useful,
237+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
238+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
239+ * GNU General Public License for more details.
240+ *
241+ * You should have received a copy of the GNU General Public License
242+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
243+ *
244+ * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
245+ */
246+
247+#ifndef UNITY_SHARED_APPLICATION_STARTER_IMP_H
248+#define UNITY_SHARED_APPLICATION_STARTER_IMP_H
249+
250+#include "ApplicationStarter.h"
251+
252+namespace unity {
253+
254+class ApplicationStarterImp : public ApplicationStarter
255+{
256+public:
257+ bool Launch(std::string const& application_name, Time timestamp) override;
258+};
259+
260+}
261+
262+#endif
263
264=== modified file 'dash/CMakeLists.txt'
265--- dash/CMakeLists.txt 2013-01-28 23:57:38 +0000
266+++ dash/CMakeLists.txt 2013-03-12 22:36:20 +0000
267@@ -19,6 +19,7 @@
268 # Headers & Sources
269 #
270 set (DASH_SOURCES
271+ ApplicationStarterImp.cpp
272 CoverflowResultView.cpp
273 DashController.cpp
274 DashView.cpp
275
276=== modified file 'dash/DashController.cpp'
277--- dash/DashController.cpp 2013-03-06 13:13:37 +0000
278+++ dash/DashController.cpp 2013-03-12 22:36:20 +0000
279@@ -23,6 +23,7 @@
280 #include <Nux/HLayout.h>
281 #include <UnityCore/GLibWrapper.h>
282
283+#include "ApplicationStarterImp.h"
284 #include "unity-shared/DashStyle.h"
285 #include "unity-shared/PanelStyle.h"
286 #include "unity-shared/UBusMessages.h"
287@@ -139,7 +140,7 @@
288
289 void Controller::SetupDashView()
290 {
291- view_ = new DashView();
292+ view_ = new DashView(std::make_shared<FilesystemLenses>(), std::make_shared<ApplicationStarterImp>());
293 AddChild(view_);
294
295 nux::HLayout* layout = new nux::HLayout(NUX_TRACKER_LOCATION);
296
297=== modified file 'dash/DashView.cpp'
298--- dash/DashView.cpp 2013-02-26 12:57:59 +0000
299+++ dash/DashView.cpp 2013-03-12 22:36:20 +0000
300@@ -24,7 +24,6 @@
301
302 #include <math.h>
303
304-#include <gio/gdesktopappinfo.h>
305 #include <glib/gi18n-lib.h>
306 #include <gtk/gtk.h>
307
308@@ -110,13 +109,16 @@
309
310 NUX_IMPLEMENT_OBJECT_TYPE(DashView);
311
312-DashView::DashView()
313+DashView::DashView(Lenses::Ptr const& lenses, ApplicationStarter::Ptr const& application_starter)
314 : nux::View(NUX_TRACKER_LOCATION)
315+ , lenses_(lenses)
316 , home_lens_(new HomeLens(_("Home"), _("Home screen"), _("Search your computer and online sources")))
317+ , application_starter_(application_starter)
318 , preview_container_(nullptr)
319 , preview_displaying_(false)
320 , preview_navigation_mode_(previews::Navigation::NONE)
321 , last_activated_uri_("")
322+ , last_activated_timestamp_(0)
323 , search_in_progress_(false)
324 , activate_on_finish_(false)
325 , visible_(false)
326@@ -137,11 +139,14 @@
327 SetupViews();
328 SetupUBusConnections();
329
330- lenses_.lens_added.connect(sigc::mem_fun(this, &DashView::OnLensAdded));
331+ lenses_->lens_added.connect(sigc::mem_fun(this, &DashView::OnLensAdded));
332 mouse_down.connect(sigc::mem_fun(this, &DashView::OnMouseButtonDown));
333 preview_state_machine_.PreviewActivated.connect(sigc::mem_fun(this, &DashView::BuildPreview));
334 Relayout();
335
336+ for (auto lens : lenses_->GetLenses())
337+ lenses_->lens_added.emit(lens);
338+
339 home_lens_->AddLenses(lenses_);
340 lens_bar_->Activate("home.lens");
341
342@@ -195,7 +200,8 @@
343 int row_height = 0;
344 int results_to_the_left = 0;
345 int results_to_the_right = 0;
346- g_variant_get(data, "(iiiiii)", &column_x, &row_y, &column_width, &row_height, &results_to_the_left, &results_to_the_right);
347+ g_variant_get(data, "(iiiiiii)", &last_activated_timestamp_, &column_x, &row_y, &column_width, &row_height, &results_to_the_left, &results_to_the_right);
348+
349 preview_state_machine_.SetSplitPosition(SplitPosition::CONTENT_AREA, row_y);
350 preview_state_machine_.left_results = results_to_the_left;
351 preview_state_machine_.right_results = results_to_the_right;
352@@ -470,7 +476,7 @@
353
354 if (active_lens_view_->lens()->id() == "home.lens")
355 {
356- for (auto lens : lenses_.GetLenses())
357+ for (auto lens : lenses_->GetLenses())
358 {
359 lens->view_type = ViewType::HOME_VIEW;
360 LOG_DEBUG(logger) << "Setting ViewType " << ViewType::HOME_VIEW
361@@ -508,7 +514,7 @@
362 visible_ = false;
363 renderer_.AboutToHide();
364
365- for (auto lens : lenses_.GetLenses())
366+ for (auto lens : lenses_->GetLenses())
367 {
368 lens->view_type = ViewType::HIDDEN;
369 LOG_DEBUG(logger) << "Setting ViewType " << ViewType::HIDDEN
370@@ -1152,9 +1158,9 @@
371
372 void DashView::UpdateLensFilter(std::string lens_id, std::string filter_name, std::string value)
373 {
374- if (lenses_.GetLens(lens_id))
375+ if (lenses_->GetLens(lens_id))
376 {
377- Lens::Ptr lens = lenses_.GetLens(lens_id);
378+ Lens::Ptr lens = lenses_->GetLens(lens_id);
379
380 Filters::Ptr filters = lens->filters;
381
382@@ -1219,7 +1225,6 @@
383
384 void DashView::OnLensAdded(Lens::Ptr& lens)
385 {
386- std::string id = lens->id;
387 lens_bar_->AddLens(lens);
388
389 nux::ObjectPtr<LensView> view(new LensView(lens, search_bar_->show_filters()));
390@@ -1366,70 +1371,20 @@
391
392 if (g_str_has_prefix(uri.c_str(), "application://"))
393 {
394- std::string appname = uri.substr(14);
395- return LaunchApp(appname);
396+ std::string const& appname = uri.substr(14);
397+ return application_starter_->Launch(appname, last_activated_timestamp_);
398 }
399 else if (g_str_has_prefix(uri.c_str(), "unity-runner://"))
400 {
401- std::string appname = uri.substr(15);
402- return LaunchApp(appname);
403+ std::string const& appname = uri.substr(15);
404+ return application_starter_->Launch(appname, last_activated_timestamp_);
405 }
406 else
407- return gtk_show_uri(NULL, uri.c_str(), CurrentTime, NULL);
408+ return gtk_show_uri(NULL, uri.c_str(), last_activated_timestamp_, NULL);
409
410 return false;
411 }
412
413-bool DashView::LaunchApp(std::string const& appname)
414-{
415- GDesktopAppInfo* info;
416- bool ret = false;
417- char *id = g_strdup(appname.c_str());
418- int i = 0;
419-
420- LOG_DEBUG(logger) << "Launching " << appname;
421-
422- while (id != NULL)
423- {
424- info = g_desktop_app_info_new(id);
425- if (info != NULL)
426- {
427- GError* error = NULL;
428-
429- g_app_info_launch(G_APP_INFO(info), NULL, NULL, &error);
430- if (error)
431- {
432- g_warning("Unable to launch %s: %s", id, error->message);
433- g_error_free(error);
434- }
435- else
436- ret = true;
437- g_object_unref(info);
438- break;
439- }
440-
441- /* Try to replace the next - with a / and do the lookup again.
442- * If we set id=NULL we'll exit the outer loop */
443- for (i = 0; ; i++)
444- {
445- if (id[i] == '-')
446- {
447- id[i] = '/';
448- break;
449- }
450- else if (id[i] == '\0')
451- {
452- g_free(id);
453- id = NULL;
454- break;
455- }
456- }
457- }
458-
459- g_free(id);
460- return ret;
461-}
462-
463 void DashView::DisableBlur()
464 {
465 renderer_.DisableBlur();
466@@ -1452,7 +1407,7 @@
467
468 std::string const DashView::GetIdForShortcutActivation(std::string const& shortcut) const
469 {
470- Lens::Ptr lens = lenses_.GetLensForShortcut(shortcut);
471+ Lens::Ptr lens = lenses_->GetLensForShortcut(shortcut);
472 if (lens)
473 return lens->id;
474 return "";
475@@ -1462,7 +1417,7 @@
476 {
477 std::vector<char> result;
478
479- for (Lens::Ptr lens: lenses_.GetLenses())
480+ for (Lens::Ptr lens: lenses_->GetLenses())
481 {
482 std::string shortcut = lens->shortcut;
483 if(shortcut.size() > 0)
484
485=== modified file 'dash/DashView.h'
486--- dash/DashView.h 2013-01-28 23:57:38 +0000
487+++ dash/DashView.h 2013-03-12 22:36:20 +0000
488@@ -28,6 +28,7 @@
489 #include <UnityCore/HomeLens.h>
490 #include <UnityCore/GLibSource.h>
491
492+#include "ApplicationStarter.h"
493 #include "LensBar.h"
494 #include "LensView.h"
495 #include "previews/PreviewContainer.h"
496@@ -58,7 +59,7 @@
497 typedef std::map<std::string, nux::ObjectPtr<LensView>> LensViews;
498
499 public:
500- DashView();
501+ DashView(Lenses::Ptr const& lenses, ApplicationStarter::Ptr const& application_starter);
502 ~DashView();
503
504 void AboutToShow();
505@@ -131,10 +132,12 @@
506 nux::Area* KeyNavIteration(nux::KeyNavDirection direction);
507
508 UBusManager ubus_manager_;
509- FilesystemLenses lenses_;
510+ Lenses::Ptr lenses_;
511 HomeLens::Ptr home_lens_;
512 LensViews lens_views_;
513
514+ ApplicationStarter::Ptr application_starter_;
515+
516 // View related
517 PreviewStateMachine preview_state_machine_;
518 previews::PreviewContainer::Ptr preview_container_;
519@@ -159,7 +162,7 @@
520 OverlayRenderer renderer_;
521
522 std::string last_activated_uri_;
523- // we're passing this back to g_* functions, so we'll keep the g* type
524+ Time last_activated_timestamp_;
525 bool search_in_progress_;
526 bool activate_on_finish_;
527
528
529=== modified file 'dash/ResultViewGrid.cpp'
530--- dash/ResultViewGrid.cpp 2013-01-09 13:33:36 +0000
531+++ dash/ResultViewGrid.cpp 2013-03-12 22:36:20 +0000
532@@ -208,7 +208,8 @@
533 }
534
535 active_index_ = index;
536- glib::Variant data(g_variant_new("(iiiiii)", column_x, row_y, column_width, row_height, left_results, right_results));
537+ auto timestamp = nux::GetWindowThread()->GetGraphicsDisplay().GetCurrentEvent().x11_timestamp;
538+ glib::Variant data(g_variant_new("(iiiiiii)", timestamp, column_x, row_y, column_width, row_height, left_results, right_results));
539 UriActivated.emit(uri, type, data);
540 }
541
542
543=== modified file 'dash/StandaloneDash.cpp'
544--- dash/StandaloneDash.cpp 2012-11-29 10:19:01 +0000
545+++ dash/StandaloneDash.cpp 2013-03-12 22:36:20 +0000
546@@ -28,6 +28,7 @@
547 #include <NuxCore/AnimationController.h>
548 #include <NuxCore/Logger.h>
549
550+#include "ApplicationStarterImp.h"
551 #include "unity-shared/BGHash.h"
552 #include "unity-shared/FontSettings.h"
553 #include "DashView.h"
554@@ -64,7 +65,8 @@
555 {
556 layout = new nux::HLayout(NUX_TRACKER_LOCATION);
557
558- DashView* view = new DashView();
559+ DashView* view = new DashView(std::make_shared<unity::dash::FilesystemLenses>(),
560+ std::make_shared<unity::ApplicationStarterImp>());
561 view->DisableBlur();
562 view->SetMinMaxSize(WIDTH, HEIGHT);
563 layout->AddView (view, 1, nux::MINOR_POSITION_CENTER);
564
565=== modified file 'tests/CMakeLists.txt'
566--- tests/CMakeLists.txt 2013-03-08 12:46:41 +0000
567+++ tests/CMakeLists.txt 2013-03-12 22:36:20 +0000
568@@ -202,6 +202,7 @@
569 test_application_launcher_icon.cpp
570 test_bamf_application.cpp
571 test_bfb_launcher_icon.cpp
572+ test_dash_view.cpp
573 test_dashview_impl.cpp
574 test_dash_controller.cpp
575 test_desktop_launcher_icon.cpp
576
577=== added file 'tests/mock-lenses.h'
578--- tests/mock-lenses.h 1970-01-01 00:00:00 +0000
579+++ tests/mock-lenses.h 2013-03-12 22:36:20 +0000
580@@ -0,0 +1,271 @@
581+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
582+/*
583+* Copyright (C) 2013 Canonical Ltd
584+*
585+* This program is free software: you can redistribute it and/or modify
586+* it under the terms of the GNU General Public License version 3 as
587+* published by the Free Software Foundation.
588+*
589+* This program is distributed in the hope that it will be useful,
590+* but WITHOUT ANY WARRANTY; without even the implied warranty of
591+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
592+* GNU General Public License for more details.
593+*
594+* You should have received a copy of the GNU General Public License
595+* along with this program. If not, see <http://www.gnu.org/licenses/>.
596+*
597+*/
598+
599+#ifndef UNITY_TESTS_MOCK_LENSES_H
600+#define UNITY_TESTS_MOCK_LENSES_H
601+
602+#include <dee.h>
603+
604+#include <UnityCore/GLibWrapper.h>
605+#include <UnityCore/GLibSource.h>
606+#include <UnityCore/Lens.h>
607+#include <UnityCore/Lenses.h>
608+
609+namespace testmocks {
610+
611+/*
612+ * FORWARDS
613+ */
614+
615+class MockTestLens;
616+
617+/*
618+ * Mock Lens instance that does not use DBus. The default search does like this:
619+ * For input "bar" output:
620+ *
621+ * i = 0
622+ * for letter in "bar":
623+ * put result row [ "uri+$letter+$lens_id", "icon+$letter+$lens_id", i % 3, "mime+$letter+$lens_id", ...]
624+ * i++
625+ *
626+ * The mock lens has 3 categories:
627+ *
628+ * 0) "cat0+$lens_id"
629+ * 1) "cat1+$lens_id"
630+ * 2) "Shared cat"
631+ */
632+class MockTestLens : public unity::dash::Lens
633+{
634+public:
635+ typedef std::shared_ptr<MockTestLens> Ptr;
636+
637+ MockTestLens(std::string const& id, std::string const& name, std::string const& description, std::string const& search_hint)
638+ : Lens(id, "", "", name, "lens-icon.png",
639+ description, search_hint, true, "",
640+ unity::dash::ModelType::LOCAL)
641+ , num_results_(-1)
642+ , provides_personal_results_(true)
643+ {
644+ search_in_global(true);
645+ connected.SetGetterFunction(sigc::mem_fun(this, &MockTestLens::force_connected));
646+ provides_personal_content.SetGetterFunction(sigc::mem_fun(this, &MockTestLens::get_provides_personal_results));
647+
648+ DeeModel* cats = categories()->model();
649+ DeeModel* results = global_results()->model();
650+ DeeModel* flters = filters()->model();
651+
652+ // Set model schemas
653+ dee_model_set_schema(cats, "s", "s", "s", "a{sv}", NULL);
654+ dee_model_set_schema(results, "s", "s", "u", "s", "s", "s", "s", NULL);
655+ dee_model_set_schema(flters, "s", "s", "s", "s", "a{sv}", "b", "b", "b", NULL);
656+
657+ // Populate categories model
658+ std::ostringstream cat0, cat1;
659+ cat0 << "cat0+" << id;
660+ cat1 << "cat1+" << id;
661+ GVariantBuilder b;
662+ g_variant_builder_init(&b, G_VARIANT_TYPE_VARDICT);
663+ GVariant *asv = g_variant_builder_end(&b);
664+
665+ dee_model_append(cats, cat0.str().c_str(), "icon.png", "tile-vertical", asv);
666+ dee_model_append(cats, cat1.str().c_str(), "icon.png", "tile-vertical", asv);
667+ dee_model_append(cats, "Shared cat", "icon.png", "tile-vertical", asv);
668+ }
669+
670+ virtual ~MockTestLens() {}
671+
672+ bool force_connected()
673+ {
674+ return true;
675+ }
676+
677+ bool get_provides_personal_results()
678+ {
679+ return provides_personal_results_;
680+ }
681+
682+ virtual void DoGlobalSearch(std::string const& search_string)
683+ {
684+ DeeModel* model = global_results()->model();
685+ GVariant** row_buf = g_new(GVariant*, 8);
686+
687+ row_buf[1] = g_variant_new_string("");
688+ row_buf[3] = g_variant_new_string("");
689+ row_buf[5] = g_variant_new_string("");
690+ row_buf[6] = g_variant_new_string("");
691+ row_buf[7] = NULL;
692+
693+ unsigned int i;
694+ unsigned int results_count = search_string.size();
695+ if (num_results_ >= 0) results_count = static_cast<unsigned>(num_results_);
696+ for (i = 0; i < results_count; i++)
697+ {
698+ std::ostringstream uri;
699+ char res_id(i >= search_string.size() ? '-' : search_string.at(i));
700+ uri << "uri+" << res_id << "+" << id();
701+ row_buf[0] = g_variant_new_string(uri.str().c_str());
702+ row_buf[2] = g_variant_new_uint32(i % 3);
703+ unity::glib::String name(g_strdup_printf("%s - %d",
704+ results_base_name_.empty() ?
705+ search_string.c_str() : results_base_name_.c_str(),
706+ i));
707+ row_buf[4] = g_variant_new_string(name);
708+
709+ dee_model_append_row(model, row_buf);
710+ }
711+
712+ g_free(row_buf);
713+ }
714+
715+ void GlobalSearch(std::string const& search_string,
716+ SearchFinishedCallback const& cb)
717+ {
718+ /* Dispatch search async, because that's what it'd normally do */
719+ source_manager_.Add(new unity::glib::Idle([this, search_string, cb] ()
720+ {
721+ DoGlobalSearch(search_string);
722+ cb(Lens::Hints(), unity::glib::Error());
723+ return false;
724+ }));
725+ }
726+
727+ void Search(std::string const& search_string, SearchFinishedCallback const& cb)
728+ {
729+ /* Dispatch search async, because that's what it'd normally do */
730+ source_manager_.Add(new unity::glib::Idle([search_string, cb] ()
731+ {
732+ cb(Lens::Hints(), unity::glib::Error());
733+ return false;
734+ }));
735+ }
736+
737+ void Activate(std::string const& uri)
738+ {
739+
740+ }
741+
742+ void Preview(std::string const& uri)
743+ {
744+
745+ }
746+
747+ void SetResultsBaseName(std::string const& name)
748+ {
749+ results_base_name_ = name;
750+ }
751+
752+ void SetNumResults(int count)
753+ {
754+ num_results_ = count;
755+ }
756+
757+ void SetProvidesPersonalResults(bool value)
758+ {
759+ provides_personal_results_ = value;
760+ }
761+
762+private:
763+ std::string results_base_name_;
764+ int num_results_;
765+ bool provides_personal_results_;
766+ unity::glib::SourceManager source_manager_;
767+};
768+
769+/*
770+ * Mock Lenses class
771+ */
772+class MockTestLenses : public unity::dash::Lenses
773+{
774+public:
775+ typedef std::shared_ptr<MockTestLenses> Ptr;
776+
777+ MockTestLenses()
778+ {
779+ count.SetGetterFunction(sigc::mem_fun(&list_, &unity::dash::Lenses::LensList::size));
780+ }
781+
782+ virtual ~MockTestLenses() {}
783+
784+ unity::dash::Lenses::LensList GetLenses() const
785+ {
786+ return list_;
787+ }
788+
789+ unity::dash::Lens::Ptr GetLens(std::string const& lens_id) const
790+ {
791+ for (auto lens : list_)
792+ {
793+ if (lens->id() == lens_id)
794+ return lens;
795+ }
796+ return unity::dash::Lens::Ptr();
797+ }
798+
799+ unity::dash::Lens::Ptr GetLensAtIndex(std::size_t index) const
800+ {
801+ return list_.at(index);
802+ }
803+
804+ unity::dash::Lens::Ptr GetLensForShortcut(std::string const& lens_shortcut) const override
805+ {
806+ return unity::dash::Lens::Ptr();
807+ }
808+
809+
810+protected:
811+ unity::dash::Lenses::LensList list_;
812+};
813+
814+class TwoMockTestLenses : public MockTestLenses
815+{
816+public:
817+ TwoMockTestLenses()
818+ : lens_1_(new MockTestLens("first.lens", "First Lens", "The very first lens", "First search hint"))
819+ , lens_2_(new MockTestLens("second.lens", "Second Lens", "The second lens", "Second search hint"))
820+ {
821+ list_.push_back(lens_1_);
822+ list_.push_back(lens_2_);
823+ }
824+
825+private:
826+ unity::dash::Lens::Ptr lens_1_;
827+ unity::dash::Lens::Ptr lens_2_;
828+};
829+
830+class ThreeMockTestLenses : public MockTestLenses
831+{
832+public:
833+ ThreeMockTestLenses()
834+ : lens_1_(new MockTestLens("first.lens", "First Lens", "The very first lens", "First search hint"))
835+ , lens_2_(new MockTestLens("second.lens", "Second Lens", "The second lens", "Second search hint"))
836+ , lens_3_(new MockTestLens("applications.lens", "Applications", "The applications lens", "Search applications"))
837+ {
838+ list_.push_back(lens_1_);
839+ list_.push_back(lens_2_);
840+ list_.push_back(lens_3_);
841+ }
842+
843+private:
844+ unity::dash::Lens::Ptr lens_1_;
845+ unity::dash::Lens::Ptr lens_2_;
846+ unity::dash::Lens::Ptr lens_3_;
847+};
848+
849+}
850+
851+#endif
852
853=== added file 'tests/test_dash_view.cpp'
854--- tests/test_dash_view.cpp 1970-01-01 00:00:00 +0000
855+++ tests/test_dash_view.cpp 2013-03-12 22:36:20 +0000
856@@ -0,0 +1,67 @@
857+/*
858+ * Copyright (C) 2013 Canonical Ltd
859+ *
860+ * This program is free software: you can redistribute it and/or modify
861+ * it under the terms of the GNU General Public License version 3 as
862+ * published by the Free Software Foundation.
863+ *
864+ * This program is distributed in the hope that it will be useful,
865+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
866+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
867+ * GNU General Public License for more details.
868+ *
869+ * You should have received a copy of the GNU General Public License
870+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
871+ *
872+ * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
873+ */
874+
875+#include <gmock/gmock.h>
876+
877+#include <UnityCore/Lenses.h>
878+
879+#include "ApplicationStarter.h"
880+#include "DashView.h"
881+#include "unity-shared/DashStyle.h"
882+#include "unity-shared/PanelStyle.h"
883+#include "unity-shared/UnitySettings.h"
884+
885+#include "mock-lenses.h"
886+
887+using namespace unity::dash;
888+using namespace testing;
889+
890+namespace {
891+
892+struct MockApplicationStarter : public unity::ApplicationStarter {
893+ typedef std::shared_ptr<MockApplicationStarter> Ptr;
894+ MOCK_METHOD2(Launch, bool(std::string const&, Time));
895+};
896+
897+
898+struct TestDashView : public testing::Test {
899+ TestDashView()
900+ : lenses_(std::make_shared<testmocks::ThreeMockTestLenses>())
901+ , application_starter_(std::make_shared<MockApplicationStarter>())
902+ , dash_view_(new DashView(lenses_, application_starter_))
903+ {}
904+
905+ unity::Settings unity_settings_;
906+ Style dash_style;
907+ unity::panel::Style panel_style;
908+ Lenses::Ptr lenses_;
909+ MockApplicationStarter::Ptr application_starter_;
910+ nux::ObjectPtr<DashView> dash_view_;
911+};
912+
913+
914+TEST_F(TestDashView, LensActivatedSignal)
915+{
916+ EXPECT_CALL(*application_starter_, Launch("uri", _)).Times(1);
917+ lenses_->GetLensAtIndex(0)->activated.emit("0xaabbcc:application://uri", NOT_HANDLED, Lens::Hints());
918+
919+ EXPECT_CALL(*application_starter_, Launch("uri", _)).Times(1);
920+ lenses_->GetLensAtIndex(0)->activated.emit("0xaabbcc:unity-runner://uri", NOT_HANDLED, Lens::Hints());
921+}
922+
923+}
924
925=== modified file 'tests/test_home_lens.cpp'
926--- tests/test_home_lens.cpp 2012-11-14 08:57:56 +0000
927+++ tests/test_home_lens.cpp 2013-03-12 22:36:20 +0000
928@@ -1,7 +1,5 @@
929 #include <gtest/gtest.h>
930 #include <glib-object.h>
931-#include <dee.h>
932-#include <string>
933 #include <iostream>
934 #include <stdexcept>
935 #include <map>
936@@ -9,254 +7,21 @@
937 #include <sigc++/signal.h>
938 #include <sigc++/trackable.h>
939
940-#include <UnityCore/GLibWrapper.h>
941-#include <UnityCore/GLibSource.h>
942+
943 #include <UnityCore/Variant.h>
944 #include <UnityCore/HomeLens.h>
945-#include <UnityCore/Lens.h>
946-#include <UnityCore/Lenses.h>
947
948 #include "test_utils.h"
949+#include "mock-lenses.h"
950
951 using namespace std;
952 using namespace unity;
953 using namespace unity::dash;
954+using namespace testmocks;
955
956 namespace
957 {
958
959-/*
960- * FORWARDS
961- */
962-
963-class StaticTestLens;
964-
965-/*
966- * Mock Lens instance that does not use DBus. The default search does like this:
967- * For input "bar" output:
968- *
969- * i = 0
970- * for letter in "bar":
971- * put result row [ "uri+$letter+$lens_id", "icon+$letter+$lens_id", i % 3, "mime+$letter+$lens_id", ...]
972- * i++
973- *
974- * The mock lens has 3 categories:
975- *
976- * 0) "cat0+$lens_id"
977- * 1) "cat1+$lens_id"
978- * 2) "Shared cat"
979- */
980-class StaticTestLens : public Lens
981-{
982-public:
983- typedef std::shared_ptr<StaticTestLens> Ptr;
984-
985- StaticTestLens(string const& id, string const& name, string const& description, string const& search_hint)
986- : Lens(id, "", "", name, "lens-icon.png",
987- description, search_hint, true, "",
988- ModelType::LOCAL)
989- , num_results_(-1)
990- , provides_personal_results_(true)
991- {
992- search_in_global(true);
993- connected.SetGetterFunction(sigc::mem_fun(this, &StaticTestLens::force_connected));
994- provides_personal_content.SetGetterFunction(sigc::mem_fun(this, &StaticTestLens::get_provides_personal_results));
995-
996- DeeModel* cats = categories()->model();
997- DeeModel* results = global_results()->model();
998- DeeModel* flters = filters()->model();
999-
1000- // Set model schemas
1001- dee_model_set_schema(cats, "s", "s", "s", "a{sv}", NULL);
1002- dee_model_set_schema(results, "s", "s", "u", "s", "s", "s", "s", NULL);
1003- dee_model_set_schema(flters, "s", "s", "s", "s", "a{sv}", "b", "b", "b", NULL);
1004-
1005- // Populate categories model
1006- ostringstream cat0, cat1;
1007- cat0 << "cat0+" << id;
1008- cat1 << "cat1+" << id;
1009- GVariantBuilder b;
1010- g_variant_builder_init(&b, G_VARIANT_TYPE_VARDICT);
1011- GVariant *asv = g_variant_builder_end(&b);
1012-
1013- dee_model_append(cats, cat0.str().c_str(), "icon.png", "tile-vertical", asv);
1014- dee_model_append(cats, cat1.str().c_str(), "icon.png", "tile-vertical", asv);
1015- dee_model_append(cats, "Shared cat", "icon.png", "tile-vertical", asv);
1016- }
1017-
1018- virtual ~StaticTestLens() {}
1019-
1020- bool force_connected()
1021- {
1022- return true;
1023- }
1024-
1025- bool get_provides_personal_results()
1026- {
1027- return provides_personal_results_;
1028- }
1029-
1030- virtual void DoGlobalSearch(string const& search_string)
1031- {
1032- DeeModel* model = global_results()->model();
1033- GVariant** row_buf = g_new(GVariant*, 8);
1034-
1035- row_buf[1] = g_variant_new_string("");
1036- row_buf[3] = g_variant_new_string("");
1037- row_buf[5] = g_variant_new_string("");
1038- row_buf[6] = g_variant_new_string("");
1039- row_buf[7] = NULL;
1040-
1041- unsigned int i;
1042- unsigned int results_count = search_string.size();
1043- if (num_results_ >= 0) results_count = static_cast<unsigned>(num_results_);
1044- for (i = 0; i < results_count; i++)
1045- {
1046- ostringstream uri;
1047- char res_id(i >= search_string.size() ? '-' : search_string.at(i));
1048- uri << "uri+" << res_id << "+" << id();
1049- row_buf[0] = g_variant_new_string(uri.str().c_str());
1050- row_buf[2] = g_variant_new_uint32(i % 3);
1051- glib::String name(g_strdup_printf("%s - %d",
1052- results_base_name_.empty() ?
1053- search_string.c_str() : results_base_name_.c_str(),
1054- i));
1055- row_buf[4] = g_variant_new_string(name);
1056-
1057- dee_model_append_row(model, row_buf);
1058- }
1059-
1060- g_free(row_buf);
1061- }
1062-
1063- void GlobalSearch(string const& search_string,
1064- SearchFinishedCallback const& cb)
1065- {
1066- /* Dispatch search async, because that's what it'd normally do */
1067- source_manager_.Add(new glib::Idle([this, search_string, cb] ()
1068- {
1069- DoGlobalSearch(search_string);
1070- cb(Lens::Hints(), glib::Error());
1071- return false;
1072- }));
1073- }
1074-
1075- void Search(string const& search_string, SearchFinishedCallback const& cb)
1076- {
1077- /* Dispatch search async, because that's what it'd normally do */
1078- source_manager_.Add(new glib::Idle([search_string, cb] ()
1079- {
1080- cb(Lens::Hints(), glib::Error());
1081- return false;
1082- }));
1083- }
1084-
1085- void Activate(string const& uri)
1086- {
1087-
1088- }
1089-
1090- void Preview(string const& uri)
1091- {
1092-
1093- }
1094-
1095- void SetResultsBaseName(string const& name)
1096- {
1097- results_base_name_ = name;
1098- }
1099-
1100- void SetNumResults(int count)
1101- {
1102- num_results_ = count;
1103- }
1104-
1105- void SetProvidesPersonalResults(bool value)
1106- {
1107- provides_personal_results_ = value;
1108- }
1109-
1110-private:
1111- string results_base_name_;
1112- int num_results_;
1113- bool provides_personal_results_;
1114- glib::SourceManager source_manager_;
1115-};
1116-
1117-/*
1118- * Mock Lenses class
1119- */
1120-class StaticTestLenses : public Lenses
1121-{
1122-public:
1123- typedef std::shared_ptr<StaticTestLenses> Ptr;
1124-
1125- StaticTestLenses()
1126- {
1127- count.SetGetterFunction(sigc::mem_fun(&list_, &Lenses::LensList::size));
1128- }
1129-
1130- virtual ~StaticTestLenses() {}
1131-
1132- Lenses::LensList GetLenses() const
1133- {
1134- return list_;
1135- }
1136-
1137- Lens::Ptr GetLens(std::string const& lens_id) const
1138- {
1139- for (auto lens : list_)
1140- {
1141- if (lens->id() == lens_id)
1142- return lens;
1143- }
1144- return Lens::Ptr();
1145- }
1146-
1147- Lens::Ptr GetLensAtIndex(std::size_t index) const
1148- {
1149- return list_.at(index);
1150- }
1151-
1152-protected:
1153- Lenses::LensList list_;
1154-};
1155-
1156-class TwoStaticTestLenses : public StaticTestLenses
1157-{
1158-public:
1159- TwoStaticTestLenses()
1160- : lens_1_(new StaticTestLens("first.lens", "First Lens", "The very first lens", "First search hint"))
1161- , lens_2_(new StaticTestLens("second.lens", "Second Lens", "The second lens", "Second search hint"))
1162- {
1163- list_.push_back(lens_1_);
1164- list_.push_back(lens_2_);
1165- }
1166-
1167-private:
1168- Lens::Ptr lens_1_;
1169- Lens::Ptr lens_2_;
1170-};
1171-
1172-class ThreeStaticTestLenses : public StaticTestLenses
1173-{
1174-public:
1175- ThreeStaticTestLenses()
1176- : lens_1_(new StaticTestLens("first.lens", "First Lens", "The very first lens", "First search hint"))
1177- , lens_2_(new StaticTestLens("second.lens", "Second Lens", "The second lens", "Second search hint"))
1178- , lens_3_(new StaticTestLens("applications.lens", "Applications", "The applications lens", "Search applications"))
1179- {
1180- list_.push_back(lens_1_);
1181- list_.push_back(lens_2_);
1182- list_.push_back(lens_3_);
1183- }
1184-
1185-private:
1186- Lens::Ptr lens_1_;
1187- Lens::Ptr lens_2_;
1188- Lens::Ptr lens_3_;
1189-};
1190-
1191 TEST(TestHomeLens, TestConstruction)
1192 {
1193 HomeLens home_lens_("name", "description", "searchhint");
1194@@ -286,7 +51,7 @@
1195 TEST(TestHomeLens, TestTwoStaticLenses)
1196 {
1197 HomeLens home_lens_("name", "description", "searchhint");
1198- TwoStaticTestLenses lenses_;
1199+ std::shared_ptr<Lenses> lenses_ = std::make_shared<TwoMockTestLenses>();
1200
1201 home_lens_.AddLenses(lenses_);
1202
1203@@ -312,7 +77,7 @@
1204 {
1205 HomeLens home_lens_("name", "description", "searchhint",
1206 HomeLens::MergeMode::DISPLAY_NAME);
1207- TwoStaticTestLenses lenses_;
1208+ std::shared_ptr<Lenses> lenses_ = std::make_shared<TwoMockTestLenses>();
1209 DeeModel* cats = home_lens_.categories()->model();
1210 DeeModelIter* iter;
1211 unsigned int cat0_first = 0,
1212@@ -347,7 +112,7 @@
1213 {
1214 HomeLens home_lens_("name", "description", "searchhint",
1215 HomeLens::MergeMode::OWNER_LENS);
1216- TwoStaticTestLenses lenses_;
1217+ std::shared_ptr<Lenses> lenses_ = std::make_shared<TwoMockTestLenses>();
1218 DeeModel* cats = home_lens_.categories()->model();
1219 DeeModelIter* iter;
1220 const unsigned int NAME_COLUMN = 0;
1221@@ -371,7 +136,7 @@
1222 TEST(TestHomeLens, TestIgnoreFilters)
1223 {
1224 HomeLens home_lens_("name", "description", "searchhint");
1225- TwoStaticTestLenses lenses_;
1226+ std::shared_ptr<Lenses> lenses_ = std::make_shared<TwoMockTestLenses>();
1227 DeeModel* filters = home_lens_.filters()->model();
1228
1229 EXPECT_EQ(dee_model_get_n_rows(filters), 0);
1230@@ -381,7 +146,7 @@
1231 {
1232 HomeLens home_lens_("name", "description", "searchhint",
1233 HomeLens::MergeMode::DISPLAY_NAME);
1234- TwoStaticTestLenses lenses_;
1235+ std::shared_ptr<Lenses> lenses_ = std::make_shared<TwoMockTestLenses>();
1236 DeeModel* results = home_lens_.results()->model();
1237 DeeModel* cats = home_lens_.categories()->model();
1238 DeeModel* filters = home_lens_.filters()->model();
1239@@ -440,7 +205,7 @@
1240 {
1241 HomeLens home_lens_("name", "description", "searchhint",
1242 HomeLens::MergeMode::OWNER_LENS);
1243- ThreeStaticTestLenses lenses_;
1244+ std::shared_ptr<Lenses> lenses_ = std::make_shared<ThreeMockTestLenses>();
1245 DeeModel* results = home_lens_.results()->model();
1246 DeeModel* cats = home_lens_.categories()->model();
1247 DeeModel* filters = home_lens_.filters()->model();
1248@@ -491,14 +256,14 @@
1249 {
1250 HomeLens home_lens_("name", "description", "searchhint",
1251 HomeLens::MergeMode::OWNER_LENS);
1252- ThreeStaticTestLenses lenses_;
1253+ std::shared_ptr<Lenses> lenses_ = std::make_shared<ThreeMockTestLenses>();
1254 // the lens is added as third, so must have cat == 2
1255 unsigned int apps_lens_cat = 2;
1256
1257 home_lens_.AddLenses(lenses_);
1258- Lens::Ptr apps_lens = lenses_.GetLens("applications.lens");
1259+ Lens::Ptr apps_lens = lenses_->GetLens("applications.lens");
1260
1261- auto static_lens = dynamic_pointer_cast<StaticTestLens>(apps_lens);
1262+ auto static_lens = dynamic_pointer_cast<MockTestLens>(apps_lens);
1263 static_lens->SetNumResults(1);
1264
1265 bool order_changed = false;
1266@@ -535,14 +300,14 @@
1267 {
1268 HomeLens home_lens_("name", "description", "searchhint",
1269 HomeLens::MergeMode::OWNER_LENS);
1270- ThreeStaticTestLenses lenses_;
1271+ std::shared_ptr<Lenses> lenses_ = std::make_shared<ThreeMockTestLenses>();
1272 // the lens is added as third, so must have cat == 2
1273 unsigned int apps_lens_cat = 2;
1274
1275 home_lens_.AddLenses(lenses_);
1276- Lens::Ptr apps_lens = lenses_.GetLens("applications.lens");
1277+ Lens::Ptr apps_lens = lenses_->GetLens("applications.lens");
1278
1279- auto static_lens = dynamic_pointer_cast<StaticTestLens>(apps_lens);
1280+ auto static_lens = dynamic_pointer_cast<MockTestLens>(apps_lens);
1281 static_lens->SetResultsBaseName("noapes");
1282 static_lens->SetNumResults(1);
1283
1284@@ -579,7 +344,7 @@
1285 {
1286 HomeLens home_lens_("name", "description", "searchhint",
1287 HomeLens::MergeMode::OWNER_LENS);
1288- ThreeStaticTestLenses lenses_;
1289+ std::shared_ptr<Lenses> lenses_ = std::make_shared<ThreeMockTestLenses>();
1290 unsigned int lens1_cat = 0;
1291 unsigned int lens2_cat = 1;
1292 // the lens is added as third, so must have cat == 2
1293@@ -587,14 +352,14 @@
1294
1295 home_lens_.AddLenses(lenses_);
1296
1297- Lens::Ptr lens = lenses_.GetLensAtIndex(2);
1298- auto static_lens = dynamic_pointer_cast<StaticTestLens>(lens);
1299+ Lens::Ptr lens = lenses_->GetLensAtIndex(2);
1300+ auto static_lens = dynamic_pointer_cast<MockTestLens>(lens);
1301 static_lens->SetResultsBaseName("noapes"); // no exact match in apps lens
1302 static_lens->SetNumResults(2);
1303
1304- static_lens = dynamic_pointer_cast<StaticTestLens>(lenses_.GetLensAtIndex(0));
1305+ static_lens = dynamic_pointer_cast<MockTestLens>(lenses_->GetLensAtIndex(0));
1306 static_lens->SetNumResults(1);
1307- static_lens = dynamic_pointer_cast<StaticTestLens>(lenses_.GetLensAtIndex(1));
1308+ static_lens = dynamic_pointer_cast<MockTestLens>(lenses_->GetLensAtIndex(1));
1309 static_lens->SetNumResults(3);
1310
1311 bool order_changed = false;
1312@@ -638,7 +403,7 @@
1313 {
1314 HomeLens home_lens_("name", "description", "searchhint",
1315 HomeLens::MergeMode::OWNER_LENS);
1316- ThreeStaticTestLenses lenses_;
1317+ std::shared_ptr<Lenses> lenses_ = std::make_shared<ThreeMockTestLenses>();
1318 unsigned int lens1_cat = 0;
1319 unsigned int lens2_cat = 1;
1320 // the lens is added as third, so must have cat == 2
1321@@ -652,14 +417,14 @@
1322 * lens3 -> 2 results (apps.lens)
1323 */
1324
1325- Lens::Ptr lens = lenses_.GetLensAtIndex(2);
1326- auto static_lens = dynamic_pointer_cast<StaticTestLens>(lens);
1327+ Lens::Ptr lens = lenses_->GetLensAtIndex(2);
1328+ auto static_lens = dynamic_pointer_cast<MockTestLens>(lens);
1329 static_lens->SetResultsBaseName("noapes"); // no exact match in apps lens
1330 static_lens->SetNumResults(2);
1331
1332- static_lens = dynamic_pointer_cast<StaticTestLens>(lenses_.GetLensAtIndex(0));
1333+ static_lens = dynamic_pointer_cast<MockTestLens>(lenses_->GetLensAtIndex(0));
1334 static_lens->SetNumResults(1);
1335- static_lens = dynamic_pointer_cast<StaticTestLens>(lenses_.GetLensAtIndex(1));
1336+ static_lens = dynamic_pointer_cast<MockTestLens>(lenses_->GetLensAtIndex(1));
1337 static_lens->SetNumResults(3);
1338 static_lens->SetProvidesPersonalResults(false);
1339
1340@@ -698,7 +463,7 @@
1341 {
1342 HomeLens home_lens_("name", "description", "searchhint",
1343 HomeLens::MergeMode::OWNER_LENS);
1344- ThreeStaticTestLenses lenses_;
1345+ std::shared_ptr<Lenses> lenses_ = std::make_shared<ThreeMockTestLenses>();
1346 unsigned int lens1_cat = 0;
1347 unsigned int lens2_cat = 1;
1348 // the lens is added as third, so must have cat == 2
1349@@ -712,13 +477,13 @@
1350 * lens3 -> 0 results (apps.lens)
1351 */
1352
1353- Lens::Ptr lens = lenses_.GetLensAtIndex(2);
1354- auto static_lens = dynamic_pointer_cast<StaticTestLens>(lens);
1355+ Lens::Ptr lens = lenses_->GetLensAtIndex(2);
1356+ auto static_lens = dynamic_pointer_cast<MockTestLens>(lens);
1357 static_lens->SetNumResults(0);
1358
1359- static_lens = dynamic_pointer_cast<StaticTestLens>(lenses_.GetLensAtIndex(0));
1360+ static_lens = dynamic_pointer_cast<MockTestLens>(lenses_->GetLensAtIndex(0));
1361 static_lens->SetNumResults(1);
1362- static_lens = dynamic_pointer_cast<StaticTestLens>(lenses_.GetLensAtIndex(1));
1363+ static_lens = dynamic_pointer_cast<MockTestLens>(lenses_->GetLensAtIndex(1));
1364 static_lens->SetNumResults(3);
1365 static_lens->SetProvidesPersonalResults(false);
1366