Merge lp:~3v1n0/unity/appicon-log-zeitgeist-events into lp:unity
- appicon-log-zeitgeist-events
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Marco Trevisan (Treviño) |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3502 |
Proposed branch: | lp:~3v1n0/unity/appicon-log-zeitgeist-events |
Merge into: | lp:unity |
Diff against target: |
810 lines (+196/-59) 14 files modified
launcher/ApplicationLauncherIcon.cpp (+46/-5) launcher/ApplicationLauncherIcon.h (+4/-0) launcher/Launcher.cpp (+1/-2) launcher/LauncherController.cpp (+11/-12) launcher/LauncherControllerPrivate.h (+1/-1) launcher/SoftwareCenterLauncherIcon.cpp (+1/-1) tests/mock-application.h (+17/-0) tests/test_application_launcher_icon.cpp (+66/-8) tests/test_launcher.cpp (+3/-7) tests/test_launcher_controller.cpp (+27/-7) tests/test_software_center_launcher_icon.cpp (+7/-1) tests/test_trash_launcher_icon.cpp (+7/-14) unity-shared/ApplicationManager.h (+2/-1) unity-shared/DesktopApplicationManager.cpp (+3/-0) |
To merge this branch: | bzr merge lp:~3v1n0/unity/appicon-log-zeitgeist-events |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Andrea Azzarone (community) | Approve | ||
Review via email: mp+185049@code.launchpad.net |
Commit message
ApplicationLaun
Description of the change
ApplicationLauncher icon now logs zeitgeist events (done by the Unity actor) when the user iteracts with the icons, so both the applications is sticked, unsticked and closed.
Added unit tests to verify the ApplicationLaun
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3547
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3547
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'launcher/ApplicationLauncherIcon.cpp' |
2 | --- launcher/ApplicationLauncherIcon.cpp 2013-09-05 20:24:41 +0000 |
3 | +++ launcher/ApplicationLauncherIcon.cpp 2013-09-11 13:28:28 +0000 |
4 | @@ -32,6 +32,7 @@ |
5 | #include "FavoriteStore.h" |
6 | #include "Launcher.h" |
7 | #include "MultiMonitor.h" |
8 | +#include "unity-shared/DesktopApplicationManager.h" |
9 | #include "unity-shared/GnomeFileManager.h" |
10 | #include "unity-shared/UBusMessages.h" |
11 | |
12 | @@ -99,6 +100,11 @@ |
13 | SetApplication(nullptr); |
14 | } |
15 | |
16 | +ApplicationPtr ApplicationLauncherIcon::GetApplication() const |
17 | +{ |
18 | + return app_; |
19 | +} |
20 | + |
21 | void ApplicationLauncherIcon::SetApplication(ApplicationPtr const& app) |
22 | { |
23 | if (app_ == app) |
24 | @@ -120,12 +126,12 @@ |
25 | SetupApplicationSignalsConnections(); |
26 | |
27 | // Let's update the icon properties to match the new application ones |
28 | - app_->desktop_file.changed.emit(app_->desktop_file()); |
29 | app_->title.changed.emit(app_->title()); |
30 | app_->icon.changed.emit(app_->icon()); |
31 | app_->visible.changed.emit(app_->visible()); |
32 | app_->active.changed.emit(app_->active()); |
33 | app_->running.changed.emit(app_->running()); |
34 | + app_->desktop_file.changed.emit(app_->desktop_file()); |
35 | |
36 | // Make sure we set the LauncherIcon stick bit too... |
37 | if (app_->sticky()) |
38 | @@ -228,6 +234,7 @@ |
39 | |
40 | void ApplicationLauncherIcon::Remove() |
41 | { |
42 | + LogUnityEvent(ApplicationEventType::LEAVE); |
43 | /* Removing the unity-seen flag to the wrapped bamf application, on remove |
44 | * request we make sure that if the application is re-opened while the |
45 | * removal process is still ongoing, the application will be shown on the |
46 | @@ -529,8 +536,11 @@ |
47 | { |
48 | glib::Object<GFile> file(f, glib::AddRef()); |
49 | _source_manager.AddTimeoutSeconds(1, [this, file] { |
50 | - if (!g_file_query_exists (file, nullptr)) |
51 | + if (!g_file_query_exists(file, nullptr)) |
52 | + { |
53 | UnStick(); |
54 | + LogUnityEvent(ApplicationEventType::DELETE); |
55 | + } |
56 | return false; |
57 | }); |
58 | break; |
59 | @@ -561,7 +571,7 @@ |
60 | uri_changed.emit(new_uri); |
61 | |
62 | if (update_saved_uri) |
63 | - SimpleLauncherIcon::Stick(); |
64 | + Stick(); |
65 | } |
66 | } |
67 | |
68 | @@ -577,7 +587,7 @@ |
69 | GVariantBuilder xids_builder; |
70 | g_variant_builder_init(&xids_builder, G_VARIANT_TYPE ("au")); |
71 | |
72 | - for (auto& window : GetWindows()) |
73 | + for (auto const& window : GetWindows()) |
74 | g_variant_builder_add(&xids_builder, "u", window->window_id()); |
75 | |
76 | variant::BuilderWrapper(builder) |
77 | @@ -848,9 +858,17 @@ |
78 | app_->sticky = true; |
79 | |
80 | if (RemoteUri().empty()) |
81 | - app_->CreateLocalDesktopFile(); |
82 | + { |
83 | + if (save) |
84 | + app_->CreateLocalDesktopFile(); |
85 | + } |
86 | else |
87 | + { |
88 | SimpleLauncherIcon::Stick(save); |
89 | + |
90 | + if (save) |
91 | + LogUnityEvent(ApplicationEventType::ACCESS); |
92 | + } |
93 | } |
94 | |
95 | void ApplicationLauncherIcon::UnStick() |
96 | @@ -858,6 +876,7 @@ |
97 | if (!IsSticky()) |
98 | return; |
99 | |
100 | + LogUnityEvent(ApplicationEventType::ACCESS); |
101 | SimpleLauncherIcon::UnStick(); |
102 | SetQuirk(Quirk::VISIBLE, app_->visible()); |
103 | app_->sticky = false; |
104 | @@ -878,6 +897,28 @@ |
105 | } |
106 | } |
107 | |
108 | +void ApplicationLauncherIcon::LogUnityEvent(ApplicationEventType type) |
109 | +{ |
110 | + if (RemoteUri().empty()) |
111 | + return; |
112 | + |
113 | + auto const& unity_app = ApplicationManager::Default().GetUnityApplication(); |
114 | + unity_app->LogEvent(type, GetSubject()); |
115 | +} |
116 | + |
117 | +ApplicationSubjectPtr ApplicationLauncherIcon::GetSubject() |
118 | +{ |
119 | + auto subject = std::make_shared<desktop::ApplicationSubject>(); |
120 | + subject->uri = RemoteUri(); |
121 | + subject->current_uri = subject->uri(); |
122 | + subject->interpretation = ZEITGEIST_NFO_SOFTWARE; |
123 | + subject->manifestation = ZEITGEIST_NFO_SOFTWARE_ITEM; |
124 | + subject->mimetype = "application/x-desktop"; |
125 | + subject->text = tooltip_text(); |
126 | + |
127 | + return subject; |
128 | +} |
129 | + |
130 | void ApplicationLauncherIcon::EnsureMenuItemsDefaultReady() |
131 | { |
132 | if (_menu_items.size() == MenuItemType::SIZE) |
133 | |
134 | === modified file 'launcher/ApplicationLauncherIcon.h' |
135 | --- launcher/ApplicationLauncherIcon.h 2013-09-05 20:24:41 +0000 |
136 | +++ launcher/ApplicationLauncherIcon.h 2013-09-11 13:28:28 +0000 |
137 | @@ -74,6 +74,8 @@ |
138 | |
139 | protected: |
140 | void SetApplication(ApplicationPtr const& app); |
141 | + ApplicationPtr GetApplication() const; |
142 | + |
143 | void Remove(); |
144 | void UpdateIconGeometries(std::vector<nux::Point3> center); |
145 | void OnCenterStabilized(std::vector<nux::Point3> center); |
146 | @@ -84,6 +86,7 @@ |
147 | void OnDndLeave(); |
148 | void OpenInstanceLauncherIcon(Time timestamp) override; |
149 | void ToggleSticky(); |
150 | + void LogUnityEvent(ApplicationEventType); |
151 | bool IsFileManager(); |
152 | |
153 | bool OnShouldHighlightOnDrag(DndData const& dnd_data); |
154 | @@ -129,6 +132,7 @@ |
155 | WindowList GetWindows(WindowFilterMask filter = 0, int monitor = -1); |
156 | const std::set<std::string> GetSupportedTypes(); |
157 | WindowList GetWindowsOnCurrentDesktopInStackingOrder(); |
158 | + ApplicationSubjectPtr GetSubject(); |
159 | |
160 | ApplicationPtr app_; |
161 | std::string _remote_uri; |
162 | |
163 | === modified file 'launcher/Launcher.cpp' |
164 | --- launcher/Launcher.cpp 2013-09-05 13:01:20 +0000 |
165 | +++ launcher/Launcher.cpp 2013-09-11 13:28:28 +0000 |
166 | @@ -2129,8 +2129,7 @@ |
167 | { |
168 | if (!_drag_window->Cancelled() && _model->IconIndex(_drag_icon) != _drag_icon_position) |
169 | { |
170 | - _drag_icon->Stick(false); |
171 | - _model->Save(); |
172 | + _drag_icon->Stick(true); |
173 | } |
174 | |
175 | auto const& icon_center = _drag_icon->GetCenter(monitor); |
176 | |
177 | === modified file 'launcher/LauncherController.cpp' |
178 | --- launcher/LauncherController.cpp 2013-08-28 16:43:08 +0000 |
179 | +++ launcher/LauncherController.cpp 2013-09-11 13:28:28 +0000 |
180 | @@ -363,18 +363,18 @@ |
181 | |
182 | if (icon) |
183 | { |
184 | - icon->Stick(false); |
185 | model_->ReorderAfter(icon, icon_before); |
186 | + icon->Stick(true); |
187 | } |
188 | else |
189 | { |
190 | if (icon_before) |
191 | - RegisterIcon(CreateFavoriteIcon(icon_uri), icon_before->SortPriority()); |
192 | + RegisterIcon(CreateFavoriteIcon(icon_uri, true), icon_before->SortPriority()); |
193 | else |
194 | - RegisterIcon(CreateFavoriteIcon(icon_uri)); |
195 | + RegisterIcon(CreateFavoriteIcon(icon_uri, true)); |
196 | + |
197 | + SaveIconsOrder(); |
198 | } |
199 | - |
200 | - SaveIconsOrder(); |
201 | } |
202 | |
203 | void Controller::Impl::AddFavoriteKeepingOldPosition(FavoriteList& icons, std::string const& icon_uri) const |
204 | @@ -472,8 +472,6 @@ |
205 | { |
206 | existing_icon_entry->UnStick(); |
207 | } |
208 | - |
209 | - SortAndUpdate(); |
210 | } |
211 | } |
212 | else |
213 | @@ -485,8 +483,9 @@ |
214 | { |
215 | if (sticky) |
216 | { |
217 | - favorite_store.AddFavorite(target_uri, -1); |
218 | - RegisterIcon(CreateFavoriteIcon(target_uri)); |
219 | + auto prio = GetLastIconPriority<ApplicationLauncherIcon>("", true); |
220 | + RegisterIcon(CreateFavoriteIcon(target_uri, true), prio); |
221 | + SaveIconsOrder(); |
222 | } |
223 | else |
224 | { |
225 | @@ -855,7 +854,7 @@ |
226 | RegisterIcon(icon, GetLastIconPriority<VolumeLauncherIcon>(local::DEVICES_URI)); |
227 | } |
228 | |
229 | -AbstractLauncherIcon::Ptr Controller::Impl::CreateFavoriteIcon(std::string const& icon_uri) |
230 | +AbstractLauncherIcon::Ptr Controller::Impl::CreateFavoriteIcon(std::string const& icon_uri, bool emit_signal) |
231 | { |
232 | AbstractLauncherIcon::Ptr result; |
233 | |
234 | @@ -914,7 +913,7 @@ |
235 | } |
236 | |
237 | if (result) |
238 | - result->Stick(false); |
239 | + result->Stick(emit_signal); |
240 | |
241 | return result; |
242 | } |
243 | @@ -945,11 +944,11 @@ |
244 | if (!app) |
245 | return result; |
246 | |
247 | - app->sticky = true; |
248 | if (app->seen) |
249 | return result; |
250 | |
251 | result = new SoftwareCenterLauncherIcon(app, aptdaemon_trans_id, icon_path); |
252 | + result->Stick(false); |
253 | |
254 | return result; |
255 | } |
256 | |
257 | === modified file 'launcher/LauncherControllerPrivate.h' |
258 | --- launcher/LauncherControllerPrivate.h 2013-08-07 19:47:00 +0000 |
259 | +++ launcher/LauncherControllerPrivate.h 2013-09-11 13:28:28 +0000 |
260 | @@ -88,7 +88,7 @@ |
261 | |
262 | void RegisterIcon(AbstractLauncherIcon::Ptr const& icon, int priority = std::numeric_limits<int>::min()); |
263 | |
264 | - AbstractLauncherIcon::Ptr CreateFavoriteIcon(std::string const& icon_uri); |
265 | + AbstractLauncherIcon::Ptr CreateFavoriteIcon(std::string const& icon_uri, bool emit_signal = false); |
266 | AbstractLauncherIcon::Ptr GetIconByUri(std::string const& icon_uri); |
267 | SoftwareCenterLauncherIcon::Ptr CreateSCLauncherIcon(std::string const& file_path, std::string const& aptdaemon_trans_id, std::string const& icon_path); |
268 | |
269 | |
270 | === modified file 'launcher/SoftwareCenterLauncherIcon.cpp' |
271 | --- launcher/SoftwareCenterLauncherIcon.cpp 2013-08-29 16:34:28 +0000 |
272 | +++ launcher/SoftwareCenterLauncherIcon.cpp 2013-09-11 13:28:28 +0000 |
273 | @@ -220,7 +220,7 @@ |
274 | // exchange the temp Application with the real one |
275 | auto& app_manager = ApplicationManager::Default(); |
276 | auto const& new_app = app_manager.GetApplicationForDesktopFile(new_desktop_path); |
277 | - new_app->sticky = IsSticky(); |
278 | + if (new_app) new_app->sticky = IsSticky(); |
279 | SetApplication(new_app); |
280 | Stick(); |
281 | |
282 | |
283 | === modified file 'tests/mock-application.h' |
284 | --- tests/mock-application.h 2013-09-06 11:58:03 +0000 |
285 | +++ tests/mock-application.h 2013-09-11 13:28:28 +0000 |
286 | @@ -362,6 +362,23 @@ |
287 | AppMap app_map_; |
288 | }; |
289 | |
290 | +struct TestUnityAppBase : testing::Test |
291 | +{ |
292 | + TestUnityAppBase() |
293 | + { |
294 | + auto const& unity_app = unity::ApplicationManager::Default().GetUnityApplication(); |
295 | + unity_app_ = std::static_pointer_cast<MockApplication>(unity_app); |
296 | + } |
297 | + |
298 | + ~TestUnityAppBase() |
299 | + { |
300 | + Mock::VerifyAndClearExpectations(unity_app_.get()); |
301 | + unity_app_->actions_log_.clear(); |
302 | + } |
303 | + |
304 | + MockApplication::Ptr unity_app_; |
305 | +}; |
306 | + |
307 | } |
308 | |
309 | #endif |
310 | |
311 | === modified file 'tests/test_application_launcher_icon.cpp' |
312 | --- tests/test_application_launcher_icon.cpp 2013-09-05 20:25:56 +0000 |
313 | +++ tests/test_application_launcher_icon.cpp 2013-09-11 13:28:28 +0000 |
314 | @@ -27,6 +27,7 @@ |
315 | #include "ApplicationLauncherIcon.h" |
316 | #include "FavoriteStore.h" |
317 | #include "StandaloneWindowManager.h" |
318 | +#include "ZeitgeistUtils.h" |
319 | #include "mock-application.h" |
320 | #include "test_utils.h" |
321 | |
322 | @@ -64,6 +65,8 @@ |
323 | bool LauncherIconIsSticky() const { return LauncherIcon::IsSticky(); } |
324 | |
325 | using ApplicationLauncherIcon::IsFileManager; |
326 | + using ApplicationLauncherIcon::LogUnityEvent; |
327 | + using ApplicationLauncherIcon::Remove; |
328 | }; |
329 | |
330 | MATCHER_P(AreArgsEqual, a, "") |
331 | @@ -75,11 +78,12 @@ |
332 | arg.monitor == a.monitor; |
333 | } |
334 | |
335 | -struct TestApplicationLauncherIcon : Test |
336 | +struct TestApplicationLauncherIcon : testmocks::TestUnityAppBase |
337 | { |
338 | virtual void SetUp() override |
339 | { |
340 | WM = dynamic_cast<StandaloneWindowManager*>(&WindowManager::Default()); |
341 | + |
342 | usc_app = std::make_shared<MockApplication::Nice>(USC_DESKTOP, "softwarecenter"); |
343 | usc_icon = new NiceMock<MockApplicationLauncherIcon>(usc_app); |
344 | ASSERT_EQ(usc_icon->DesktopFile(), USC_DESKTOP); |
345 | @@ -143,9 +147,9 @@ |
346 | } |
347 | |
348 | StandaloneWindowManager* WM; |
349 | - std::shared_ptr<MockApplication> usc_app; |
350 | - std::shared_ptr<MockApplication> empty_app; |
351 | - std::shared_ptr<MockApplication> mock_app; |
352 | + MockApplication::Ptr usc_app; |
353 | + MockApplication::Ptr empty_app; |
354 | + MockApplication::Ptr mock_app; |
355 | MockApplicationLauncherIcon::Ptr usc_icon; |
356 | MockApplicationLauncherIcon::Ptr empty_icon; |
357 | MockApplicationLauncherIcon::Ptr mock_icon; |
358 | @@ -188,6 +192,7 @@ |
359 | { |
360 | bool saved = false; |
361 | usc_icon->position_saved.connect([&saved] {saved = true;}); |
362 | + EXPECT_CALL(*unity_app_, LogEvent(_, _)).Times(0); |
363 | |
364 | usc_icon->Stick(false); |
365 | EXPECT_TRUE(usc_app->sticky()); |
366 | @@ -203,6 +208,7 @@ |
367 | { |
368 | bool saved = false; |
369 | mock_icon->position_saved.connect([&saved] {saved = true;}); |
370 | + EXPECT_CALL(*unity_app_, LogEvent(_, _)).Times(0); |
371 | |
372 | mock_icon->Stick(false); |
373 | EXPECT_TRUE(mock_app->sticky()); |
374 | @@ -218,6 +224,7 @@ |
375 | { |
376 | bool saved = false; |
377 | usc_icon->position_saved.connect([&saved] {saved = true;}); |
378 | + EXPECT_CALL(*unity_app_, LogEvent(ApplicationEventType::ACCESS, _)); |
379 | |
380 | usc_icon->Stick(true); |
381 | EXPECT_TRUE(usc_app->sticky()); |
382 | @@ -230,6 +237,7 @@ |
383 | { |
384 | bool saved = false; |
385 | mock_icon->position_saved.connect([&saved] {saved = true;}); |
386 | + EXPECT_CALL(*unity_app_, LogEvent(_, _)).Times(0); |
387 | |
388 | mock_icon->Stick(true); |
389 | EXPECT_TRUE(mock_app->sticky()); |
390 | @@ -257,7 +265,7 @@ |
391 | EXPECT_FALSE(icon->LauncherIconIsSticky()); |
392 | } |
393 | |
394 | -TEST_F(TestApplicationLauncherIcon, StickAndSaveDesktopApplication) |
395 | +TEST_F(TestApplicationLauncherIcon, StickAndSaveDesktopAppDontCreateNewDesktop) |
396 | { |
397 | EXPECT_CALL(*usc_app, CreateLocalDesktopFile()).Times(0); |
398 | usc_icon->Stick(true); |
399 | @@ -265,7 +273,7 @@ |
400 | EXPECT_TRUE(usc_icon->IsSticky()); |
401 | } |
402 | |
403 | -TEST_F(TestApplicationLauncherIcon, StickAndSaveDesktopLessApplication) |
404 | +TEST_F(TestApplicationLauncherIcon, StickAndSaveDesktopLessAppCreatesNewDesktop) |
405 | { |
406 | auto app = std::make_shared<MockApplication::Nice>(); |
407 | MockApplicationLauncherIcon::Ptr icon(new NiceMock<MockApplicationLauncherIcon>(app)); |
408 | @@ -284,10 +292,10 @@ |
409 | |
410 | bool forgot = false; |
411 | bool removed = false; |
412 | + usc_icon->Stick(); |
413 | usc_icon->position_forgot.connect([&forgot] {forgot = true;}); |
414 | usc_icon->remove.connect([&removed] (AbstractLauncherIcon::Ptr const&) { removed = true; }); |
415 | |
416 | - usc_icon->Stick(); |
417 | usc_icon->UnStick(); |
418 | EXPECT_FALSE(usc_app->sticky()); |
419 | EXPECT_FALSE(usc_icon->IsSticky()); |
420 | @@ -303,10 +311,10 @@ |
421 | |
422 | bool forgot = false; |
423 | bool removed = false; |
424 | + usc_icon->Stick(); |
425 | usc_icon->position_forgot.connect([&forgot] {forgot = true;}); |
426 | usc_icon->remove.connect([&removed] (AbstractLauncherIcon::Ptr const&) { removed = true; }); |
427 | |
428 | - usc_icon->Stick(); |
429 | usc_icon->UnStick(); |
430 | EXPECT_FALSE(usc_app->sticky()); |
431 | EXPECT_FALSE(usc_icon->IsSticky()); |
432 | @@ -315,6 +323,28 @@ |
433 | EXPECT_FALSE(removed); |
434 | } |
435 | |
436 | +TEST_F(TestApplicationLauncherIcon, UnstickDesktopAppLogEvents) |
437 | +{ |
438 | + usc_icon->Stick(); |
439 | + |
440 | + { |
441 | + InSequence order; |
442 | + EXPECT_CALL(*unity_app_, LogEvent(ApplicationEventType::ACCESS, _)); |
443 | + EXPECT_CALL(*unity_app_, LogEvent(ApplicationEventType::LEAVE, _)); |
444 | + } |
445 | + |
446 | + usc_icon->UnStick(); |
447 | +} |
448 | + |
449 | +TEST_F(TestApplicationLauncherIcon, UnstickDesktopLessAppLogEvent) |
450 | +{ |
451 | + auto app = std::make_shared<MockApplication::Nice>(); |
452 | + MockApplicationLauncherIcon::Ptr icon(new NiceMock<MockApplicationLauncherIcon>(app)); |
453 | + |
454 | + EXPECT_CALL(*unity_app_, LogEvent(ApplicationEventType::ACCESS, _)).Times(0); |
455 | + icon->UnStick(); |
456 | +} |
457 | + |
458 | TEST_F(TestApplicationLauncherIcon, VisibleChanged) |
459 | { |
460 | usc_app->visible_ = true; |
461 | @@ -1051,4 +1081,32 @@ |
462 | EXPECT_FALSE(mock_icon->AllowDetailViewInSwitcher()); |
463 | } |
464 | |
465 | +TEST_F(TestApplicationLauncherIcon, LogUnityEventDesktopLess) |
466 | +{ |
467 | + EXPECT_CALL(*unity_app_, LogEvent(_, _)).Times(0); |
468 | + mock_icon->LogUnityEvent(ApplicationEventType::ACCESS); |
469 | +} |
470 | + |
471 | +MATCHER_P(ApplicationSubjectEquals, other, "") { return *arg == *other; } |
472 | + |
473 | +TEST_F(TestApplicationLauncherIcon, LogUnityEventDesktop) |
474 | +{ |
475 | + auto subject = std::make_shared<testmocks::MockApplicationSubject>(); |
476 | + subject->uri = usc_icon->RemoteUri(); |
477 | + subject->current_uri = subject->uri(); |
478 | + subject->text = usc_icon->tooltip_text(); |
479 | + subject->interpretation = ZEITGEIST_NFO_SOFTWARE; |
480 | + subject->manifestation = ZEITGEIST_NFO_SOFTWARE_ITEM; |
481 | + subject->mimetype = "application/x-desktop"; |
482 | + |
483 | + EXPECT_CALL(*unity_app_, LogEvent(ApplicationEventType::ACCESS, ApplicationSubjectEquals(subject))); |
484 | + usc_icon->LogUnityEvent(ApplicationEventType::ACCESS); |
485 | +} |
486 | + |
487 | +TEST_F(TestApplicationLauncherIcon, RemoveLogEvent) |
488 | +{ |
489 | + EXPECT_CALL(*unity_app_, LogEvent(ApplicationEventType::LEAVE, _)); |
490 | + usc_icon->Remove(); |
491 | +} |
492 | + |
493 | } |
494 | |
495 | === modified file 'tests/test_launcher.cpp' |
496 | --- tests/test_launcher.cpp 2013-08-09 12:09:34 +0000 |
497 | +++ tests/test_launcher.cpp 2013-09-11 13:28:28 +0000 |
498 | @@ -351,9 +351,7 @@ |
499 | auto const& center3 = icon3->GetCenter(launcher_->monitor()); |
500 | launcher_->UpdateDragWindowPosition(center3.x, center3.y); |
501 | |
502 | - bool model_saved = false; |
503 | - model_->saved.connect([&model_saved] { model_saved = true; }); |
504 | - EXPECT_CALL(*icon2, Stick(false)); |
505 | + EXPECT_CALL(*icon2, Stick(true)); |
506 | |
507 | ASSERT_NE(launcher_->_drag_icon_position, model_->IconIndex(icon2)); |
508 | launcher_->EndIconDrag(); |
509 | @@ -364,8 +362,6 @@ |
510 | ASSERT_EQ(*it, icon3); it++; |
511 | ASSERT_EQ(*it, icon2); |
512 | |
513 | - EXPECT_TRUE(model_saved); |
514 | - |
515 | // Let's wait the drag icon animation to be completed |
516 | Utils::WaitUntilMSec([this] { return launcher_->GetDraggedIcon(); }, false, 2000); |
517 | EXPECT_EQ(launcher_->GetDraggedIcon(), nullptr); |
518 | @@ -430,7 +426,7 @@ |
519 | auto const& center = icons[0]->GetCenter(launcher_->monitor()); |
520 | launcher_->UpdateDragWindowPosition(center.x, center.y); |
521 | |
522 | - EXPECT_CALL(*app, Stick(false)); |
523 | + EXPECT_CALL(*app, Stick(true)); |
524 | launcher_->EndIconDrag(); |
525 | } |
526 | |
527 | @@ -449,7 +445,7 @@ |
528 | auto const& center = icons[0]->GetCenter(launcher_->monitor()); |
529 | launcher_->UpdateDragWindowPosition(center.x, center.y); |
530 | |
531 | - EXPECT_CALL(*device, Stick(false)); |
532 | + EXPECT_CALL(*device, Stick(true)); |
533 | launcher_->EndIconDrag(); |
534 | } |
535 | |
536 | |
537 | === modified file 'tests/test_launcher_controller.cpp' |
538 | --- tests/test_launcher_controller.cpp 2013-09-05 20:25:56 +0000 |
539 | +++ tests/test_launcher_controller.cpp 2013-09-11 13:28:28 +0000 |
540 | @@ -196,7 +196,7 @@ |
541 | |
542 | namespace launcher |
543 | { |
544 | -struct TestLauncherController : public testing::Test |
545 | +struct TestLauncherController : testmocks::TestUnityAppBase |
546 | { |
547 | TestLauncherController() |
548 | : logger_output_(std::make_shared<helper::CaptureLogOutput>()) |
549 | @@ -574,6 +574,7 @@ |
550 | { |
551 | std::string desktop_file = app::BZR_HANDLE_PATCH; |
552 | std::string icon_uri = FavoriteStore::URI_PREFIX_APP + DesktopUtilities::GetDesktopID(desktop_file); |
553 | + EXPECT_CALL(*unity_app_, LogEvent(_, _)).Times(0); |
554 | auto const& fav = lc.Impl()->CreateFavoriteIcon(icon_uri); |
555 | |
556 | ASSERT_TRUE(fav.IsValid()); |
557 | @@ -588,6 +589,7 @@ |
558 | { |
559 | std::string desktop_file = app::BZR_HANDLE_PATCH; |
560 | std::string icon_uri = FavoriteStore::URI_PREFIX_APP + desktop_file; |
561 | + EXPECT_CALL(*unity_app_, LogEvent(_, _)).Times(0); |
562 | auto const& fav = lc.Impl()->CreateFavoriteIcon(icon_uri); |
563 | |
564 | ASSERT_TRUE(fav.IsValid()); |
565 | @@ -925,6 +927,8 @@ |
566 | auto const& model = lc.Impl()->model_; |
567 | int icon_index = 0; |
568 | |
569 | + EXPECT_CALL(*unity_app_, LogEvent(_, _)).Times(0); |
570 | + |
571 | favorite_store.SetFavorites({ FavoriteStore::URI_PREFIX_APP + app::UBUNTU_ONE, |
572 | FavoriteStore::URI_PREFIX_APP + app::SW_CENTER, |
573 | places::DEVICES_URI, |
574 | @@ -1171,6 +1175,7 @@ |
575 | std::string desktop = app::BZR_HANDLE_PATCH; |
576 | std::string icon_uri = FavoriteStore::URI_PREFIX_APP + desktop; |
577 | ASSERT_FALSE(lc.Impl()->GetIconByUri(icon_uri).IsValid()); |
578 | + EXPECT_CALL(*unity_app_, LogEvent(ApplicationEventType::ACCESS, _)); |
579 | |
580 | auto app_icons = model->GetSublist<ApplicationLauncherIcon>(); |
581 | auto const& second_app = *(std::next(app_icons.begin())); |
582 | @@ -1180,6 +1185,7 @@ |
583 | auto const& new_icon = lc.Impl()->GetIconByUri(icon_uri); |
584 | ASSERT_TRUE(new_icon.IsValid()); |
585 | EXPECT_EQ(model->IconIndex(new_icon), model->IconIndex(second_app) + 1); |
586 | + EXPECT_TRUE(favorite_store.IsFavorite(icon_uri)); |
587 | } |
588 | |
589 | TEST_F(TestLauncherController, LauncherAddRequestApplicationStick) |
590 | @@ -1195,10 +1201,12 @@ |
591 | auto const& first_app = app_icons.front(); |
592 | ASSERT_LT(model->IconIndex(first_app), model->IconIndex(bamf_icon)); |
593 | |
594 | - EXPECT_CALL(*bamf_icon, Stick(false)); |
595 | + EXPECT_CALL(*bamf_icon, Stick(true)); |
596 | + EXPECT_CALL(*unity_app_, LogEvent(ApplicationEventType::ACCESS, _)); |
597 | lc.launcher().add_request.emit(icon_file_uri, first_app); |
598 | |
599 | EXPECT_EQ(model->IconIndex(bamf_icon), model->IconIndex(first_app) + 1); |
600 | + EXPECT_TRUE(favorite_store.IsFavorite(bamf_icon->RemoteUri())); |
601 | } |
602 | |
603 | TEST_F(TestLauncherController, LauncherAddRequestDeviceAdd) |
604 | @@ -1220,6 +1228,7 @@ |
605 | ASSERT_TRUE(new_icon.IsValid()); |
606 | EXPECT_EQ(new_icon, device_icon); |
607 | EXPECT_EQ(model->IconIndex(new_icon), model->IconIndex(first_app) + 1); |
608 | + EXPECT_TRUE(favorite_store.IsFavorite(icon_uri)); |
609 | } |
610 | |
611 | TEST_F(TestLauncherController, LauncherAddRequestDeviceStick) |
612 | @@ -1232,10 +1241,11 @@ |
613 | auto const& second_app = *(std::next(app_icons.begin())); |
614 | ASSERT_LT(model->IconIndex(second_app), model->IconIndex(device_icon)); |
615 | |
616 | - EXPECT_CALL(*device_icon, Stick(false)); |
617 | + EXPECT_CALL(*device_icon, Stick(true)); |
618 | lc.launcher().add_request.emit(device_icon->RemoteUri(), second_app); |
619 | |
620 | EXPECT_EQ(model->IconIndex(device_icon), model->IconIndex(second_app) + 1); |
621 | + EXPECT_TRUE(favorite_store.IsFavorite(device_icon->RemoteUri())); |
622 | } |
623 | |
624 | TEST_F(TestLauncherController, LauncherRemoveRequestApplicationUnStickAndQuit) |
625 | @@ -1282,11 +1292,13 @@ |
626 | std::string desktop = app::BZR_HANDLE_PATCH; |
627 | std::string icon_uri = FavoriteStore::URI_PREFIX_APP + desktop; |
628 | ASSERT_FALSE(lc.Impl()->GetIconByUri(icon_uri).IsValid()); |
629 | + EXPECT_CALL(*unity_app_, LogEvent(_, _)).Times(0); |
630 | |
631 | lc.Impl()->OnLauncherAddRequestSpecial(desktop, "", "", 0, 0, 32); |
632 | |
633 | auto const& sw_center_icon = lc.Impl()->GetIconByUri(icon_uri); |
634 | ASSERT_TRUE(sw_center_icon.IsValid()); |
635 | + EXPECT_TRUE(sw_center_icon->IsSticky()); |
636 | EXPECT_NE(dynamic_cast<SoftwareCenterLauncherIcon*>(sw_center_icon.GetPointer()), nullptr); |
637 | } |
638 | |
639 | @@ -1457,6 +1469,7 @@ |
640 | { |
641 | std::string icon_uri = FavoriteStore::URI_PREFIX_APP + app::BZR_HANDLE_PATCH; |
642 | |
643 | + EXPECT_CALL(*unity_app_, LogEvent(_, _)).Times(0); |
644 | favorite_store.favorite_added.emit(icon_uri, "", true); |
645 | |
646 | auto const& new_icon = lc.Impl()->GetIconByUri(icon_uri); |
647 | @@ -1471,6 +1484,8 @@ |
648 | |
649 | auto app_icons = model->GetSublist<ApplicationLauncherIcon>(); |
650 | auto const& first_app = app_icons.front(); |
651 | + |
652 | + EXPECT_CALL(*unity_app_, LogEvent(_, _)).Times(0); |
653 | favorite_store.favorite_added.emit(icon_uri, first_app->RemoteUri(), true); |
654 | |
655 | auto const& new_icon = lc.Impl()->GetIconByUri(icon_uri); |
656 | @@ -1487,6 +1502,8 @@ |
657 | |
658 | auto app_icons = model->GetSublist<ApplicationLauncherIcon>(); |
659 | auto const& first_app = app_icons.front(); |
660 | + |
661 | + EXPECT_CALL(*unity_app_, LogEvent(_, _)).Times(0); |
662 | favorite_store.favorite_added.emit(icon_uri, first_app->RemoteUri(), false); |
663 | |
664 | auto const& new_icon = lc.Impl()->GetIconByUri(icon_uri); |
665 | @@ -1761,6 +1778,7 @@ |
666 | lc.Impl()->RegisterIcon(app_icon); |
667 | ASSERT_FALSE(favorite_store.IsFavorite(app_icon->RemoteUri())); |
668 | |
669 | + EXPECT_CALL(*app_icon, Stick(true)); |
670 | const std::string icon_uri = FavoriteStore::URI_PREFIX_APP + desktop_file; |
671 | lc.Impl()->OnLauncherUpdateIconStickyState(icon_uri, true); |
672 | |
673 | @@ -1787,15 +1805,17 @@ |
674 | { |
675 | std::string desktop = app::BZR_HANDLE_PATCH; |
676 | std::string icon_uri = FavoriteStore::URI_PREFIX_APP + desktop; |
677 | + auto const& model = lc.Impl()->model_; |
678 | + auto app_icons = model->GetSublist<ApplicationLauncherIcon>(); |
679 | + EXPECT_CALL(*unity_app_, LogEvent(ApplicationEventType::ACCESS, _)); |
680 | |
681 | lc.Impl()->OnLauncherUpdateIconStickyState(icon_uri, true); |
682 | |
683 | - // Make sure that the icon now exists and is sticky |
684 | - EXPECT_TRUE(favorite_store.IsFavorite(icon_uri)); |
685 | - |
686 | auto const& icon = lc.Impl()->GetIconByUri(icon_uri); |
687 | ASSERT_TRUE(icon.IsValid()); |
688 | - ASSERT_TRUE(icon->IsSticky()); |
689 | + EXPECT_TRUE(icon->IsSticky()); |
690 | + EXPECT_EQ(model->IconIndex(icon), model->IconIndex(app_icons.back()) + 1); |
691 | + EXPECT_TRUE(favorite_store.IsFavorite(icon_uri)); |
692 | } |
693 | |
694 | } |
695 | |
696 | === modified file 'tests/test_software_center_launcher_icon.cpp' |
697 | --- tests/test_software_center_launcher_icon.cpp 2013-09-05 20:25:56 +0000 |
698 | +++ tests/test_software_center_launcher_icon.cpp 2013-09-11 13:28:28 +0000 |
699 | @@ -52,7 +52,7 @@ |
700 | const std::string USC_APP_INSTALL_DESKTOP = "/usr/share/app-install/desktop/software-center:ubuntu-software-center.desktop"; |
701 | } |
702 | |
703 | -struct TestSoftwareCenterLauncherIcon : testing::Test |
704 | +struct TestSoftwareCenterLauncherIcon : testmocks::TestUnityAppBase |
705 | { |
706 | TestSoftwareCenterLauncherIcon() |
707 | : usc(std::make_shared<MockApplication::Nice>(USC_APP_INSTALL_DESKTOP, FINAL_ICON, APP_NAME)) |
708 | @@ -199,6 +199,12 @@ |
709 | EXPECT_EQ(icon.icon_name(), usc->icon()); |
710 | } |
711 | |
712 | +TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedLogsEvent) |
713 | +{ |
714 | + EXPECT_CALL(*unity_app_, LogEvent(ApplicationEventType::ACCESS, _)); |
715 | + icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success"))); |
716 | +} |
717 | + |
718 | TEST_F(TestSoftwareCenterLauncherIcon, AnimateToInvalidPosition) |
719 | { |
720 | EXPECT_FALSE(icon.Animate(CreateLauncher(), 1, 2)); |
721 | |
722 | === modified file 'tests/test_trash_launcher_icon.cpp' |
723 | --- tests/test_trash_launcher_icon.cpp 2013-09-06 11:51:28 +0000 |
724 | +++ tests/test_trash_launcher_icon.cpp 2013-09-11 13:28:28 +0000 |
725 | @@ -31,7 +31,7 @@ |
726 | namespace |
727 | { |
728 | |
729 | -struct TestTrashLauncherIcon : Test |
730 | +struct TestTrashLauncherIcon : testmocks::TestUnityAppBase |
731 | { |
732 | TestTrashLauncherIcon() |
733 | : fm_(std::make_shared<NiceMock<MockFileManager>>()) |
734 | @@ -116,10 +116,6 @@ |
735 | EXPECT_CALL(*fm_, TrashFile(_)).WillRepeatedly(Return(true)); |
736 | std::vector<ApplicationSubjectPtr> subjects; |
737 | |
738 | - auto const& unity_app = ApplicationManager::Default().GetUnityApplication(); |
739 | - auto const& unity_mock_app = std::static_pointer_cast<testmocks::MockApplication>(unity_app); |
740 | - unity_mock_app->actions_log_.clear(); |
741 | - |
742 | for (auto const& uri : data.Uris()) |
743 | { |
744 | auto subject = std::make_shared<testmocks::MockApplicationSubject>(); |
745 | @@ -127,14 +123,14 @@ |
746 | subject->origin = glib::gchar_to_string(g_path_get_dirname(uri.c_str())); |
747 | subject->text = glib::gchar_to_string(g_path_get_basename(uri.c_str())); |
748 | subjects.push_back(subject); |
749 | - EXPECT_CALL(*unity_mock_app, LogEvent(ApplicationEventType::DELETE, ApplicationSubjectEquals(subject))); |
750 | + EXPECT_CALL(*unity_app_, LogEvent(ApplicationEventType::DELETE, ApplicationSubjectEquals(subject))); |
751 | } |
752 | |
753 | icon.AcceptDrop(data); |
754 | |
755 | - EXPECT_FALSE(unity_mock_app->actions_log_.empty()); |
756 | + EXPECT_FALSE(unity_app_->actions_log_.empty()); |
757 | for (auto const& subject : subjects) |
758 | - ASSERT_TRUE(unity_mock_app->HasLoggedEvent(ApplicationEventType::DELETE, subject)); |
759 | + ASSERT_TRUE(unity_app_->HasLoggedEvent(ApplicationEventType::DELETE, subject)); |
760 | } |
761 | |
762 | TEST_F(TestTrashLauncherIcon, AcceptDropFailsDoesNotLogEvents) |
763 | @@ -145,16 +141,13 @@ |
764 | EXPECT_CALL(*fm_, TrashFile(_)).WillRepeatedly(Return(false)); |
765 | std::vector<ApplicationSubjectPtr> subjects; |
766 | |
767 | - auto const& unity_app = ApplicationManager::Default().GetUnityApplication(); |
768 | - auto const& unity_mock_app = std::static_pointer_cast<testmocks::MockApplication>(unity_app); |
769 | - unity_mock_app->actions_log_.clear(); |
770 | - EXPECT_CALL(*unity_mock_app, LogEvent(ApplicationEventType::DELETE, _)).Times(0); |
771 | + EXPECT_CALL(*unity_app_, LogEvent(ApplicationEventType::DELETE, _)).Times(0); |
772 | |
773 | icon.AcceptDrop(data); |
774 | |
775 | - EXPECT_TRUE(unity_mock_app->actions_log_.empty()); |
776 | + EXPECT_TRUE(unity_app_->actions_log_.empty()); |
777 | for (auto const& subject : subjects) |
778 | - ASSERT_FALSE(unity_mock_app->HasLoggedEvent(ApplicationEventType::DELETE, subject)); |
779 | + ASSERT_FALSE(unity_app_->HasLoggedEvent(ApplicationEventType::DELETE, subject)); |
780 | } |
781 | |
782 | } |
783 | |
784 | === modified file 'unity-shared/ApplicationManager.h' |
785 | --- unity-shared/ApplicationManager.h 2013-09-05 20:24:41 +0000 |
786 | +++ unity-shared/ApplicationManager.h 2013-09-11 13:28:28 +0000 |
787 | @@ -46,7 +46,8 @@ |
788 | { |
789 | CREATE, |
790 | DELETE, |
791 | - ACCESS |
792 | + ACCESS, |
793 | + LEAVE |
794 | }; |
795 | |
796 | class ApplicationWindow |
797 | |
798 | === modified file 'unity-shared/DesktopApplicationManager.cpp' |
799 | --- unity-shared/DesktopApplicationManager.cpp 2013-09-05 20:24:41 +0000 |
800 | +++ unity-shared/DesktopApplicationManager.cpp 2013-09-11 13:28:28 +0000 |
801 | @@ -51,6 +51,9 @@ |
802 | case ApplicationEventType::ACCESS: |
803 | zg_event_interpretation = ZEITGEIST_ZG_ACCESS_EVENT; |
804 | break; |
805 | + case ApplicationEventType::LEAVE: |
806 | + zg_event_interpretation = ZEITGEIST_ZG_LEAVE_EVENT; |
807 | + break; |
808 | } |
809 | |
810 | auto const& id = desktop_id(); |
LGTM.