Merge lp:~3v1n0/unity/swcenter-icon-fixes into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Christopher Townsend
Approved revision: no longer in the source branch.
Merged at revision: 3487
Proposed branch: lp:~3v1n0/unity/swcenter-icon-fixes
Merge into: lp:unity
Diff against target: 1194 lines (+406/-221)
15 files modified
UnityCore/Variant.cpp (+52/-0)
UnityCore/Variant.h (+1/-0)
launcher/ApplicationLauncherIcon.cpp (+12/-9)
launcher/Launcher.cpp (+8/-14)
launcher/Launcher.h (+3/-4)
launcher/LauncherController.cpp (+1/-2)
launcher/LauncherDragWindow.cpp (+6/-6)
launcher/LauncherDragWindow.h (+7/-8)
launcher/SoftwareCenterLauncherIcon.cpp (+63/-62)
launcher/SoftwareCenterLauncherIcon.h (+10/-12)
tests/mock-application.h (+12/-1)
tests/test_application_launcher_icon.cpp (+78/-4)
tests/test_glib_variant.cpp (+38/-5)
tests/test_launcher_drag_window.cpp (+28/-52)
tests/test_software_center_launcher_icon.cpp (+87/-42)
To merge this branch: bzr merge lp:~3v1n0/unity/swcenter-icon-fixes
Reviewer Review Type Date Requested Status
Christopher Townsend Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+182959@code.launchpad.net

Commit message

ApplicationLauncherIcon: make sure we unstick an icon, update its URI and resave it in order

Also improving a lot the SoftwareCenterLauncherIcon code and the install behaviour.

Description of the change

Improvements to glib::Variant, LauncherDragWindow, ApplicationLauncherIcon and SoftwareCenterLauncherIcon.
Added nicer animation when installing applications from SW center: now a new empty space is created on the launcher as soon as the icon starts to fly to that position, that then is filled only once the animation is completed.

As always, added new tests.

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
Christopher Townsend (townsend) wrote :

Sweet! This looks good.

I do see something that may or may not be a problem.

When installing an application from the Dash, the icon immediately shows up on the Launcher and shows the progress inside the icon. However, when installing from the Software Center, the icon does not show up until the application is fully installed.

Also, another difference between Dash vs. Software Center is that after the application is installed, when installing via Dash, the icon is urgent, but when installing via Software Center, it is not.

I'm not sure if these are bugs or intended behavior or should even be addressed in the MP.

Otherwise, this looks really good and works quite well.

review: Needs Information
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

That behavior is different only due to the clients you're using (sw center and the lens).

They had this different behavior, but now (you need to use lp:software-center trunk) they're quite similar. So, give a try with that if you prefer.

Revision history for this message
Christopher Townsend (townsend) wrote :

Since the behavior I was questioning is part of the Software Center, then I'm approving this.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UnityCore/Variant.cpp'
2--- UnityCore/Variant.cpp 2013-07-10 16:34:55 +0000
3+++ UnityCore/Variant.cpp 2013-08-29 17:07:13 +0000
4@@ -70,6 +70,10 @@
5 }
6 else
7 {
8+ auto const& variant = GetVariant();
9+ if (variant)
10+ return variant.GetString();
11+
12 LOG_ERROR(logger) << "You're trying to extract a String from a variant which is of type "
13 << g_variant_type_peek_string(g_variant_get_type(variant_));
14 }
15@@ -94,6 +98,10 @@
16 }
17 else
18 {
19+ auto const& variant = GetVariant();
20+ if (variant)
21+ return variant.GetInt32();
22+
23 LOG_ERROR(logger) << "You're trying to extract an Int32 from a variant which is of type "
24 << g_variant_type_peek_string(g_variant_get_type(variant_));
25 }
26@@ -118,6 +126,10 @@
27 }
28 else
29 {
30+ auto const& variant = GetVariant();
31+ if (variant)
32+ return variant.GetUInt32();
33+
34 LOG_ERROR(logger) << "You're trying to extract an UInt32 from a variant which is of type "
35 << g_variant_type_peek_string(g_variant_get_type(variant_));
36 }
37@@ -141,6 +153,10 @@
38 }
39 else
40 {
41+ auto const& variant = GetVariant();
42+ if (variant)
43+ return variant.GetInt64();
44+
45 LOG_ERROR(logger) << "You're trying to extract an Int64 from a variant which is of type "
46 << g_variant_type_peek_string(g_variant_get_type(variant_));
47 }
48@@ -165,6 +181,10 @@
49 }
50 else
51 {
52+ auto const& variant = GetVariant();
53+ if (variant)
54+ return variant.GetUInt64();
55+
56 LOG_ERROR(logger) << "You're trying to extract an UInt64 from a variant which is of type "
57 << g_variant_type_peek_string(g_variant_get_type(variant_));
58 }
59@@ -189,6 +209,10 @@
60 }
61 else
62 {
63+ auto const& variant = GetVariant();
64+ if (variant)
65+ return variant.GetBool();
66+
67 LOG_ERROR(logger) << "You're trying to extract a Boolean from a variant which is of type "
68 << g_variant_type_peek_string(g_variant_get_type(variant_));
69 }
70@@ -213,6 +237,10 @@
71 }
72 else
73 {
74+ auto const& variant = GetVariant();
75+ if (variant)
76+ return variant.GetDouble();
77+
78 LOG_ERROR(logger) << "You're trying to extract a Double from a variant which is of type "
79 << g_variant_type_peek_string(g_variant_get_type(variant_));
80 }
81@@ -225,6 +253,30 @@
82 return static_cast<float>(GetDouble());
83 }
84
85+Variant Variant::GetVariant() const
86+{
87+ Variant value;
88+
89+ if (!variant_)
90+ return value;
91+
92+ if (g_variant_is_of_type(variant_, G_VARIANT_TYPE_VARIANT))
93+ {
94+ value = Variant(g_variant_get_variant(variant_), StealRef());
95+ }
96+ else if (g_variant_is_of_type(variant_, G_VARIANT_TYPE("(v)")))
97+ {
98+ g_variant_get(variant_, "(v)", &value);
99+ }
100+ else
101+ {
102+ LOG_ERROR(logger) << "You're trying to extract a Variant from a variant which is of type "
103+ << g_variant_type_peek_string(g_variant_get_type(variant_));
104+ }
105+
106+ return value;
107+}
108+
109 bool Variant::ASVToHints(HintsMap& hints) const
110 {
111 GVariantIter* hints_iter;
112
113=== modified file 'UnityCore/Variant.h'
114--- UnityCore/Variant.h 2013-05-17 22:53:57 +0000
115+++ UnityCore/Variant.h 2013-08-29 17:07:13 +0000
116@@ -56,6 +56,7 @@
117 bool GetBool() const;
118 double GetDouble() const;
119 float GetFloat() const;
120+ Variant GetVariant() const;
121
122 bool ASVToHints(HintsMap& hints) const;
123 static Variant FromHints(HintsMap const& hints);
124
125=== modified file 'launcher/ApplicationLauncherIcon.cpp'
126--- launcher/ApplicationLauncherIcon.cpp 2013-08-07 16:43:38 +0000
127+++ launcher/ApplicationLauncherIcon.cpp 2013-08-29 17:07:13 +0000
128@@ -111,11 +111,11 @@
129 }
130
131 signals_conn_.Clear();
132+ app_ = app;
133
134 if (!app)
135 return;
136
137- app_ = app;
138 app_->seen = true;
139 SetupApplicationSignalsConnections();
140
141@@ -545,12 +545,6 @@
142 break;
143 }
144 });
145-
146- if (app_->sticky() && old_uri != new_uri)
147- {
148- UnStick();
149- Stick();
150- }
151 }
152 else if (app_->sticky())
153 {
154@@ -558,7 +552,17 @@
155 }
156
157 if (old_uri != new_uri)
158+ {
159+ bool update_saved_uri = (!filename.empty() && app_->sticky());
160+
161+ if (update_saved_uri)
162+ SimpleLauncherIcon::UnStick();
163+
164 uri_changed.emit(new_uri);
165+
166+ if (update_saved_uri)
167+ SimpleLauncherIcon::Stick();
168+ }
169 }
170
171 std::string ApplicationLauncherIcon::DesktopFile() const
172@@ -725,7 +729,6 @@
173 // any or they're filtered for the environment we're in
174 const gchar** nicks = indicator_desktop_shortcuts_get_nicks(_desktop_shortcuts);
175
176-
177 for (int index = 0; nicks[index]; ++index)
178 {
179 // Build a dbusmenu item for each nick that is the desktop
180@@ -856,7 +859,7 @@
181 return;
182
183 SimpleLauncherIcon::UnStick();
184- SetQuirk(Quirk::VISIBLE, app_->running());
185+ SetQuirk(Quirk::VISIBLE, app_->visible());
186 app_->sticky = false;
187
188 if (!app_->running())
189
190=== modified file 'launcher/Launcher.cpp'
191--- launcher/Launcher.cpp 2013-07-17 21:48:22 +0000
192+++ launcher/Launcher.cpp 2013-08-29 17:07:13 +0000
193@@ -2099,11 +2099,9 @@
194 _drag_icon_position = _model->IconIndex(icon);
195
196 HideDragWindow();
197- _offscreen_drag_texture = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(GetWidth(), GetWidth(), 1, nux::BITFMT_R8G8B8A8);
198- _drag_window = new LauncherDragWindow(_offscreen_drag_texture,
199- std::bind(&Launcher::RenderIconToTexture, this,
200- _1,
201- _drag_icon, _offscreen_drag_texture));
202+
203+ auto cb = std::bind(&Launcher::RenderIconToTexture, this, _1, _2, _drag_icon);
204+ _drag_window = new LauncherDragWindow(GetWidth(), cb);
205 ShowDragWindow();
206
207 ubus_.SendMessage(UBUS_LAUNCHER_ICON_START_DND);
208@@ -2135,10 +2133,9 @@
209 _model->Save();
210 }
211
212- _drag_window->on_anim_completed_conn_ = _drag_window->anim_completed.connect(sigc::mem_fun(this, &Launcher::OnDragWindowAnimCompleted));
213-
214 auto const& icon_center = _drag_icon->GetCenter(monitor);
215- _drag_window->SetAnimationTarget(icon_center.x, icon_center.y),
216+ _drag_window->SetAnimationTarget(icon_center.x, icon_center.y);
217+ _drag_window->anim_completed.connect(sigc::mem_fun(this, &Launcher::OnDragWindowAnimCompleted));
218 _drag_window->StartQuickAnimation();
219 }
220 }
221@@ -2571,7 +2568,7 @@
222 return AbstractLauncherIcon::Ptr();
223 }
224
225-void Launcher::RenderIconToTexture(nux::GraphicsEngine& GfxContext, AbstractLauncherIcon::Ptr const& icon, nux::ObjectPtr<nux::IOpenGLBaseTexture> texture)
226+void Launcher::RenderIconToTexture(nux::GraphicsEngine& GfxContext, nux::ObjectPtr<nux::IOpenGLBaseTexture> const& texture, AbstractLauncherIcon::Ptr const& icon)
227 {
228 RenderArg arg;
229 struct timespec current;
230@@ -2596,11 +2593,8 @@
231 GfxContext.GetRenderStates().GetBlend(alpha, src, dest);
232 GfxContext.GetRenderStates().SetBlend(false);
233
234- GfxContext.QRP_Color(0,
235- 0,
236- texture->GetWidth(),
237- texture->GetHeight(),
238- nux::Color(0.0f, 0.0f, 0.0f, 0.0f));
239+ GfxContext.QRP_Color(0, 0, texture->GetWidth(), texture->GetHeight(),
240+ nux::color::Transparent);
241
242 GfxContext.GetRenderStates().SetBlend(alpha, src, dest);
243
244
245=== modified file 'launcher/Launcher.h'
246--- launcher/Launcher.h 2013-07-01 21:20:51 +0000
247+++ launcher/Launcher.h 2013-08-29 17:07:13 +0000
248@@ -107,7 +107,7 @@
249 };
250
251 nux::ObjectPtr<nux::View> const& GetActiveTooltip() const;
252- nux::ObjectPtr<LauncherDragWindow> const& GetDraggedIcon() const;
253+ LauncherDragWindow::Ptr const& GetDraggedIcon() const;
254
255 virtual void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
256 virtual void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
257@@ -153,7 +153,7 @@
258
259 static const int ANIM_DURATION_SHORT;
260
261- void RenderIconToTexture(nux::GraphicsEngine& GfxContext, AbstractLauncherIcon::Ptr const& icon, nux::ObjectPtr<nux::IOpenGLBaseTexture> texture);
262+ void RenderIconToTexture(nux::GraphicsEngine&, nux::ObjectPtr<nux::IOpenGLBaseTexture> const&, AbstractLauncherIcon::Ptr const&);
263
264 #ifdef NUX_GESTURES_SUPPORT
265 virtual nux::GestureDeliveryRequest GestureEvent(const nux::GestureEvent &event);
266@@ -393,8 +393,7 @@
267 float _last_reveal_progress;
268
269 nux::Point2 _mouse_position;
270- nux::ObjectPtr<nux::IOpenGLBaseTexture> _offscreen_drag_texture;
271- nux::ObjectPtr<LauncherDragWindow> _drag_window;
272+ LauncherDragWindow::Ptr _drag_window;
273 LauncherHideMachine _hide_machine;
274 LauncherHoverMachine _hover_machine;
275 TooltipManager tooltip_manager_;
276
277=== modified file 'launcher/LauncherController.cpp'
278--- launcher/LauncherController.cpp 2013-08-07 19:47:00 +0000
279+++ launcher/LauncherController.cpp 2013-08-29 17:07:13 +0000
280@@ -528,8 +528,7 @@
281 // This will ensure that the center of the new icon is set, so that
282 // the animation could be done properly.
283 sources_.AddIdle([this, icon_x, icon_y, result] {
284- result->Animate(CurrentLauncher(), icon_x, icon_y);
285- return false;
286+ return !result->Animate(CurrentLauncher(), icon_x, icon_y);
287 });
288 }
289 else
290
291=== modified file 'launcher/LauncherDragWindow.cpp'
292--- launcher/LauncherDragWindow.cpp 2013-08-09 12:09:34 +0000
293+++ launcher/LauncherDragWindow.cpp 2013-08-29 17:07:13 +0000
294@@ -41,16 +41,16 @@
295
296 NUX_IMPLEMENT_OBJECT_TYPE(LauncherDragWindow);
297
298-LauncherDragWindow::LauncherDragWindow(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture,
299- std::function<void(nux::GraphicsEngine &)> const &deferred_icon_render_func)
300+LauncherDragWindow::LauncherDragWindow(unsigned size, DeferredIconRenderer const& renderer_func)
301 : nux::BaseWindow("")
302 , icon_rendered_(false)
303- , deferred_icon_render_func_(deferred_icon_render_func)
304+ , renderer_func_(renderer_func)
305 , animation_speed_(QUICK_ANIMATION_SPEED)
306 , cancelled_(false)
307- , texture_(texture)
308+ , texture_(nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(
309+ size, size, 1, nux::BITFMT_R8G8B8A8))
310 {
311- SetBaseSize(texture_->GetWidth(), texture_->GetHeight());
312+ SetBaseSize(size, size);
313
314 key_down.connect([this] (unsigned long, unsigned long keysym, unsigned long, const char*, unsigned short) {
315 if (keysym == NUX_VK_ESCAPE)
316@@ -158,7 +158,7 @@
317 // Render the icon if we haven't already
318 if (!icon_rendered_)
319 {
320- deferred_icon_render_func_ (GfxContext);
321+ renderer_func_(GfxContext, texture_);
322 icon_rendered_ = true;
323 }
324
325
326=== modified file 'launcher/LauncherDragWindow.h'
327--- launcher/LauncherDragWindow.h 2013-07-01 21:20:51 +0000
328+++ launcher/LauncherDragWindow.h 2013-08-29 17:07:13 +0000
329@@ -38,12 +38,12 @@
330 {
331 NUX_DECLARE_OBJECT_TYPE(LauncherDragWindow, nux::BaseWindow);
332 public:
333- LauncherDragWindow(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture,
334- std::function<void(nux::GraphicsEngine &)> const &deferred_icon_render_func);
335+ typedef nux::ObjectPtr<LauncherDragWindow> Ptr;
336+ typedef std::function<void(nux::GraphicsEngine&, nux::ObjectPtr<nux::IOpenGLBaseTexture> const&)> DeferredIconRenderer;
337+
338+ LauncherDragWindow(unsigned size, DeferredIconRenderer const&);
339 ~LauncherDragWindow();
340
341- void DrawContent(nux::GraphicsEngine& gfxContext, bool forceDraw);
342-
343 void SetAnimationTarget(int x, int y);
344 void StartQuickAnimation();
345 void StartSlowAnimation();
346@@ -53,21 +53,20 @@
347
348 sigc::signal<void> anim_completed;
349 sigc::signal<void> drag_cancel_request;
350- connection::Wrapper on_anim_completed_conn_;
351
352 protected:
353+ void DrawContent(nux::GraphicsEngine& gfxContext, bool forceDraw);
354 bool InspectKeyEvent(unsigned int event_type, unsigned int keysym, const char* character);
355 bool AcceptKeyNavFocus();
356-
357 virtual bool DrawContentOnNuxLayer() const;
358
359 private:
360 void StartAnimation();
361 bool OnAnimationTimeout();
362 void CancelDrag();
363-
364+
365 bool icon_rendered_;
366- std::function<void(nux::GraphicsEngine &)> deferred_icon_render_func_;
367+ DeferredIconRenderer renderer_func_;
368
369 float animation_speed_;
370 bool cancelled_;
371
372=== modified file 'launcher/SoftwareCenterLauncherIcon.cpp'
373--- launcher/SoftwareCenterLauncherIcon.cpp 2013-08-07 16:44:38 +0000
374+++ launcher/SoftwareCenterLauncherIcon.cpp 2013-08-29 17:07:13 +0000
375@@ -31,6 +31,7 @@
376 #include "LauncherDragWindow.h"
377 #include "LauncherModel.h"
378 #include "DesktopUtilities.h"
379+#include "MultiMonitor.h"
380
381 namespace unity
382 {
383@@ -39,29 +40,31 @@
384
385 namespace
386 {
387-const std::string SOURCE_SHOW_TOOLTIP = "ShowTooltip";
388-const std::string SOURCE_HIDE_TOOLTIP = "HideTooltip";
389 const int INSTALL_TIP_DURATION = 1500;
390 }
391
392 NUX_IMPLEMENT_OBJECT_TYPE(SoftwareCenterLauncherIcon);
393-
394 SoftwareCenterLauncherIcon::SoftwareCenterLauncherIcon(ApplicationPtr const& app,
395 std::string const& aptdaemon_trans_id,
396 std::string const& icon_path)
397 : ApplicationLauncherIcon(app)
398- , aptdaemon_trans_("org.debian.apt",
399- aptdaemon_trans_id,
400- "org.debian.apt.transaction",
401- G_BUS_TYPE_SYSTEM,
402- G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START)
403- , finished_(true)
404+ , aptdaemon_trans_(std::make_shared<glib::DBusProxy>("org.debian.apt",
405+ aptdaemon_trans_id,
406+ "org.debian.apt.transaction",
407+ G_BUS_TYPE_SYSTEM,
408+ G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START))
409+ , finished_(false)
410 , needs_urgent_(false)
411 , aptdaemon_trans_id_(aptdaemon_trans_id)
412 {
413 SetQuirk(Quirk::VISIBLE, false);
414- aptdaemon_trans_.Connect("PropertyChanged", sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnPropertyChanged));
415- aptdaemon_trans_.Connect("Finished", sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnFinished));
416+ aptdaemon_trans_->Connect("PropertyChanged", sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnPropertyChanged));
417+ aptdaemon_trans_->Connect("Finished", sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnFinished));
418+ aptdaemon_trans_->GetProperty("Progress", [this] (GVariant *value) {
419+ int32_t progress = glib::Variant(value).GetInt32();
420+ SetProgress(progress/100.0f);
421+ SetQuirk(Quirk::PROGRESS, (progress > 0));
422+ });
423
424 if (!icon_path.empty())
425 icon_name = icon_path;
426@@ -70,51 +73,57 @@
427 tooltip_text = _("Waiting to install");
428 }
429
430-void SoftwareCenterLauncherIcon::Animate(nux::ObjectPtr<Launcher> const& launcher, int start_x, int start_y)
431+bool SoftwareCenterLauncherIcon::Animate(nux::ObjectPtr<Launcher> const& launcher, int start_x, int start_y)
432 {
433 using namespace std::placeholders;
434
435- launcher_ = launcher;
436-
437- // FIXME: this needs testing, if there is no useful coordinates
438- // then do not animate
439 if (start_x <= 0 && start_y <= 0)
440 {
441 SetQuirk(Quirk::VISIBLE, true);
442- return;
443+ return true;
444 }
445
446- icon_texture_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(
447- launcher->GetWidth(),
448- launcher->GetWidth(),
449- 1,
450- nux::BITFMT_R8G8B8A8);
451-
452- drag_window_ = new LauncherDragWindow(icon_texture_,
453- std::bind (&Launcher::RenderIconToTexture,
454- launcher.GetPointer(),
455- _1,
456- AbstractLauncherIcon::Ptr(this),
457- icon_texture_));
458+ int monitor = launcher->monitor();
459+ auto const& icon_center = GetCenter(monitor);
460+
461+ if (icon_center.x == 0 && icon_center.y == 0)
462+ return false;
463+
464+ auto* floating_icon = new SimpleLauncherIcon(GetIconType());
465+ AbstractLauncherIcon::Ptr floating_icon_ptr(floating_icon);
466+ floating_icon->icon_name = icon_name();
467+
468+ // Transform this in a spacer-icon and make it visible only on launcher's monitor
469+ for (unsigned i = 0; i < monitors::MAX; ++i)
470+ SetVisibleOnMonitor(i, static_cast<int>(i) == monitor);
471+
472+ icon_name = "";
473+ SetQuirk(Quirk::VISIBLE, true);
474+
475+ auto rcb = std::bind(&Launcher::RenderIconToTexture, launcher.GetPointer(), _1, _2, floating_icon_ptr);
476+ drag_window_ = new LauncherDragWindow(launcher->GetWidth(), rcb);
477+ drag_window_->SetBaseXY(start_x, start_y);
478+ drag_window_->SetAnimationTarget(icon_center.x, icon_center.y + (launcher->GetIconSize() / 2));
479
480 launcher->ForceReveal(true);
481-
482- auto const& icon_center = GetCenter(launcher->monitor());
483- drag_window_->SetBaseXY(start_x, start_y);
484 drag_window_->ShowWindow(true);
485- drag_window_->SetAnimationTarget(icon_center.x, icon_center.y + (launcher->GetIconSize() / 2));
486- drag_window_->on_anim_completed_conn_ = drag_window_->anim_completed.connect(sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnDragAnimationFinished));
487+
488+ auto cb = sigc::bind(sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnDragAnimationFinished), launcher, floating_icon->icon_name());
489+ drag_window_->anim_completed.connect(cb);
490 drag_window_->StartSlowAnimation();
491+
492+ return true;
493 }
494
495-void SoftwareCenterLauncherIcon::OnDragAnimationFinished()
496+void SoftwareCenterLauncherIcon::OnDragAnimationFinished(nux::ObjectPtr<Launcher> const& launcher, std::string const& final_icon)
497 {
498+ icon_name = final_icon;
499 drag_window_->ShowWindow(false);
500- drag_window_ = nullptr;
501- launcher_->ForceReveal(false);
502- launcher_ = nullptr;
503- icon_texture_ = nullptr;
504- SetQuirk(Quirk::VISIBLE, true);
505+ drag_window_.Release();
506+ launcher->ForceReveal(false);
507+
508+ for (unsigned i = 0; i < monitors::MAX; ++i)
509+ SetVisibleOnMonitor(i, true);
510 }
511
512 void SoftwareCenterLauncherIcon::ActivateLauncherIcon(ActionArg arg)
513@@ -142,8 +151,8 @@
514 // app-install-data points to the "wrong" one in /usr/share/app-install
515 //
516 // So:
517- // - if there is a desktop file already and it startswith
518- // /usr/share/app-install/desktop, then transform to
519+ // - if there is a desktop file already and it startswith
520+ // /usr/share/app-install/desktop, then transform to
521 // /usr/share/application
522 // - if there is a desktop file with prefix /tmp/software-center-agent:
523 // transform to /usr/share/application
524@@ -168,10 +177,10 @@
525 }
526 filename = DesktopUtilities::GetDesktopPathById(filename);
527 return filename;
528- }
529+ }
530 else if (desktop_file.find("/tmp/software-center-agent:") == 0)
531 {
532- // by convention the software-center-agent uses
533+ // by convention the software-center-agent uses
534 // /usr/share/applications/$pkgname.desktop
535 // or
536 // /usr/share/applications/extras-$pkgname.desktop
537@@ -197,10 +206,7 @@
538
539 void SoftwareCenterLauncherIcon::OnFinished(GVariant *params)
540 {
541- glib::String exit_state;
542- g_variant_get_child(params, 0, "s", &exit_state);
543-
544- if (exit_state.Str() == "exit-success")
545+ if (glib::Variant(params).GetString() == "exit-success")
546 {
547 SetQuirk(Quirk::PROGRESS, false);
548 SetQuirk(Quirk::URGENT, true);
549@@ -223,39 +229,34 @@
550 _source_manager.AddTimeout(INSTALL_TIP_DURATION, [this] {
551 HideTooltip();
552 return false;
553- }, SOURCE_HIDE_TOOLTIP);
554+ });
555 return false;
556- }, SOURCE_SHOW_TOOLTIP);
557+ });
558 }
559 else
560 {
561 // failure condition, remove icon again
562 UnStick();
563 }
564+
565+ aptdaemon_trans_.reset();
566 };
567
568 void SoftwareCenterLauncherIcon::OnPropertyChanged(GVariant* params)
569 {
570- gint32 progress;
571- glib::String property_name;
572-
573- g_variant_get_child(params, 0, "s", &property_name);
574-
575- if (property_name.Str() == "Progress")
576+ glib::Variant property_name(g_variant_get_child_value(params, 0), glib::StealRef());
577+
578+ if (property_name.GetString() == "Progress")
579 {
580- GVariant* property_value = nullptr;
581- g_variant_get_child(params, 1, "v", &property_value);
582- g_variant_get(property_value, "i", &progress);
583+ int32_t progress = glib::Variant(g_variant_get_child_value(params, 1), glib::StealRef()).GetInt32();
584
585 if (progress < 100)
586 {
587 SetQuirk(Quirk::PROGRESS, true);
588- finished_ = false;
589- tooltip_text = _("Installing…");
590+ tooltip_text = _("Installing…");
591 }
592
593 SetProgress(progress/100.0f);
594- g_variant_unref(property_value);
595 }
596 }
597
598
599=== modified file 'launcher/SoftwareCenterLauncherIcon.h'
600--- launcher/SoftwareCenterLauncherIcon.h 2013-08-05 08:01:45 +0000
601+++ launcher/SoftwareCenterLauncherIcon.h 2013-08-29 17:07:13 +0000
602@@ -42,27 +42,25 @@
603 std::string const& aptdaemon_trans_id,
604 std::string const& icon_path);
605
606- void Animate(nux::ObjectPtr<Launcher> const& launcher, int start_x, int start_y);
607+ bool Animate(nux::ObjectPtr<Launcher> const& launcher, int start_x, int start_y);
608
609+protected:
610 std::string GetName() const;
611+ void ActivateLauncherIcon(ActionArg arg);
612
613-protected:
614+private:
615 std::string GetActualDesktopFileAfterInstall();
616- void ActivateLauncherIcon(ActionArg arg);
617 void OnFinished(GVariant *params);
618 void OnPropertyChanged(GVariant* params);
619-
620-private:
621- void OnDragAnimationFinished();
622-
623- glib::DBusProxy aptdaemon_trans_;
624-
625- nux::ObjectPtr<nux::IOpenGLBaseTexture> icon_texture_;
626- nux::ObjectPtr<LauncherDragWindow> drag_window_;
627- nux::ObjectPtr<Launcher> launcher_;
628+ void OnDragAnimationFinished(nux::ObjectPtr<Launcher> const&, std::string const&);
629+
630+ glib::DBusProxy::Ptr aptdaemon_trans_;
631+ LauncherDragWindow::Ptr drag_window_;
632 bool finished_;
633 bool needs_urgent_;
634 std::string aptdaemon_trans_id_;
635+
636+ friend class TestSoftwareCenterLauncherIcon;
637 };
638
639 }
640
641=== modified file 'tests/mock-application.h'
642--- tests/mock-application.h 2013-08-07 16:44:38 +0000
643+++ tests/mock-application.h 2013-08-29 17:07:13 +0000
644@@ -175,8 +175,19 @@
645 }
646
647 void SetRunState(bool state) {
648+ if (running_ == state)
649+ return;
650+
651 running_ = state;
652- running.changed.emit(state);
653+ running.changed.emit(running_);
654+ }
655+
656+ void SetVisibility(bool state) {
657+ if (visible_ == state)
658+ return;
659+
660+ visible_ = state;
661+ visible.changed.emit(visible_);
662 }
663
664 bool SetSeen(bool const& param) {
665
666=== modified file 'tests/test_application_launcher_icon.cpp'
667--- tests/test_application_launcher_icon.cpp 2013-08-07 16:44:38 +0000
668+++ tests/test_application_launcher_icon.cpp 2013-08-29 17:07:13 +0000
669@@ -280,9 +280,13 @@
670
671 TEST_F(TestApplicationLauncherIcon, UnstickNotRunning)
672 {
673+ usc_app->SetRunState(false);
674+ usc_app->SetVisibility(true);
675+
676 bool forgot = false;
677- usc_app->running_ = false;
678+ bool removed = false;
679 usc_icon->position_forgot.connect([&forgot] {forgot = true;});
680+ usc_icon->remove.connect([&removed] (AbstractLauncherIcon::Ptr const&) { removed = true; });
681
682 usc_icon->Stick();
683 usc_icon->UnStick();
684@@ -290,13 +294,18 @@
685 EXPECT_FALSE(usc_icon->IsSticky());
686 EXPECT_FALSE(usc_icon->IsVisible());
687 EXPECT_TRUE(forgot);
688+ EXPECT_TRUE(removed);
689 }
690
691 TEST_F(TestApplicationLauncherIcon, UnstickRunning)
692 {
693+ usc_app->SetRunState(true);
694+ usc_app->SetVisibility(true);
695+
696 bool forgot = false;
697- usc_app->running_ = true;
698+ bool removed = false;
699 usc_icon->position_forgot.connect([&forgot] {forgot = true;});
700+ usc_icon->remove.connect([&removed] (AbstractLauncherIcon::Ptr const&) { removed = true; });
701
702 usc_icon->Stick();
703 usc_icon->UnStick();
704@@ -304,6 +313,7 @@
705 EXPECT_FALSE(usc_icon->IsSticky());
706 EXPECT_TRUE(usc_icon->IsVisible());
707 EXPECT_TRUE(forgot);
708+ EXPECT_FALSE(removed);
709 }
710
711 TEST_F(TestApplicationLauncherIcon, VisibleChanged)
712@@ -390,6 +400,34 @@
713 EXPECT_TRUE(forgot);
714 }
715
716+TEST_F(TestApplicationLauncherIcon, UpdateDesktopEmptyForgetsIconPositionAndUpdatesUri)
717+{
718+ usc_icon->Stick(true);
719+
720+ bool forgot = false;
721+ bool uri_updated = false;
722+ bool saved = false;
723+
724+ usc_icon->position_forgot.connect([&forgot, &uri_updated] {
725+ ASSERT_FALSE(uri_updated);
726+ forgot = true;
727+ });
728+ usc_icon->uri_changed.connect([&forgot, &uri_updated] (std::string const&) {
729+ ASSERT_TRUE(forgot);
730+ uri_updated = true;
731+ });
732+ usc_icon->position_saved.connect([&saved] { saved = false; });
733+
734+ usc_app->desktop_file_ = "";
735+ usc_app->desktop_file.changed.emit(usc_app->desktop_file_);
736+
737+ EXPECT_FALSE(usc_app->sticky());
738+ EXPECT_FALSE(usc_icon->IsSticky());
739+ EXPECT_TRUE(forgot);
740+ EXPECT_TRUE(uri_updated);
741+ EXPECT_FALSE(saved);
742+}
743+
744 TEST_F(TestApplicationLauncherIcon, UpdateDesktopUpdatesIconUri)
745 {
746 bool updated = false;
747@@ -408,16 +446,52 @@
748 EXPECT_TRUE(updated);
749 }
750
751-
752 TEST_F(TestApplicationLauncherIcon, UpdateDesktopDoesntUpdatesIconUri)
753 {
754 bool updated = false;
755- usc_icon->uri_changed.connect([&updated] (std::string const& new_uri) { updated = true; });
756+ usc_icon->uri_changed.connect([&updated] (std::string const&) { updated = true; });
757 usc_app->desktop_file.changed.emit(usc_app->desktop_file_);
758
759 EXPECT_FALSE(updated);
760 }
761
762+TEST_F(TestApplicationLauncherIcon, UpdateDesktopForgetsOldPositionUpdatesUriAndSavesAgain)
763+{
764+ usc_icon->Stick(true);
765+
766+ bool forgot = false;
767+ bool uri_updated = false;
768+ bool saved = false;
769+ bool removed = false;
770+
771+ usc_icon->position_forgot.connect([&] {
772+ ASSERT_FALSE(uri_updated);
773+ ASSERT_FALSE(saved);
774+ forgot = true;
775+ });
776+ usc_icon->uri_changed.connect([&] (std::string const&) {
777+ ASSERT_FALSE(saved);
778+ ASSERT_TRUE(forgot);
779+ uri_updated = true;
780+ });
781+ usc_icon->position_saved.connect([&] {
782+ ASSERT_TRUE(forgot);
783+ ASSERT_TRUE(uri_updated);
784+ saved = true;
785+ });
786+ usc_icon->remove.connect([&removed] (AbstractLauncherIcon::Ptr const&) { removed = true; });
787+
788+ usc_app->desktop_file_ = UM_DESKTOP;
789+ usc_app->desktop_file.changed.emit(usc_app->desktop_file_);
790+
791+ ASSERT_FALSE(removed);
792+ EXPECT_TRUE(usc_app->sticky());
793+ EXPECT_TRUE(usc_icon->IsSticky());
794+ EXPECT_TRUE(forgot);
795+ EXPECT_TRUE(uri_updated);
796+ EXPECT_TRUE(saved);
797+}
798+
799 TEST_F(TestApplicationLauncherIcon, RemoteUri)
800 {
801 EXPECT_EQ(usc_icon->RemoteUri(), FavoriteStore::URI_PREFIX_APP + DesktopUtilities::GetDesktopID(USC_DESKTOP));
802
803=== modified file 'tests/test_glib_variant.cpp'
804--- tests/test_glib_variant.cpp 2013-07-10 16:32:43 +0000
805+++ tests/test_glib_variant.cpp 2013-08-29 17:07:13 +0000
806@@ -168,8 +168,8 @@
807 EXPECT_EQ(hints["guint32-key"].GetUInt32(), (guint32)-2);
808 EXPECT_EQ(hints["gint64-key"].GetInt64(), (gint64)-3);
809 EXPECT_EQ(hints["guint64-key"].GetUInt64(), (guint64)-4);
810- EXPECT_EQ(hints["float-key"].GetFloat(), (float)1.1);
811- EXPECT_EQ(hints["double-key"].GetDouble(), (double)2.2);
812+ EXPECT_FLOAT_EQ(hints["float-key"].GetFloat(), 1.1);
813+ EXPECT_DOUBLE_EQ(hints["double-key"].GetDouble(), 2.2);
814 EXPECT_EQ(hints["bool-key"].GetBool(), true);
815
816 // throw away all references to the original variant
817@@ -185,8 +185,8 @@
818 EXPECT_EQ(hints["guint32-key"].GetUInt32(), (guint32)-2);
819 EXPECT_EQ(hints["gint64-key"].GetInt64(), (gint64)-3);
820 EXPECT_EQ(hints["guint64-key"].GetUInt64(), (guint64)-4);
821- EXPECT_EQ(hints["float-key"].GetFloat(), (float)1.1);
822- EXPECT_EQ(hints["double-key"].GetDouble(), (double)2.2);
823+ EXPECT_FLOAT_EQ(hints["float-key"].GetFloat(), 1.1);
824+ EXPECT_DOUBLE_EQ(hints["double-key"].GetDouble(), 2.2);
825 EXPECT_EQ(hints["bool-key"].GetBool(), true);
826 }
827
828@@ -203,6 +203,9 @@
829
830 Variant v4;
831 EXPECT_EQ(v4.GetString(), "");
832+
833+ Variant v5(g_variant_new_variant(g_variant_new_string("Yeah!!!")));
834+ EXPECT_EQ(v5.GetString(), "Yeah!!!");
835 }
836
837 TEST(TestGLibVariant, GetInt32)
838@@ -220,6 +223,10 @@
839
840 Variant v4;
841 EXPECT_EQ(v4.GetInt32(), 0);
842+
843+ value = g_random_int_range(G_MININT, G_MAXINT);
844+ Variant v5(g_variant_new_variant(g_variant_new_int32(value)));
845+ EXPECT_EQ(v5.GetInt32(), value);
846 }
847
848 TEST(TestGLibVariant, GetUInt32)
849@@ -237,6 +244,10 @@
850
851 Variant v4;
852 EXPECT_EQ(v4.GetUInt32(), 0);
853+
854+ value = g_random_int();
855+ Variant v5(g_variant_new_variant(g_variant_new_uint32(value)));
856+ EXPECT_EQ(v5.GetUInt32(), value);
857 }
858
859 TEST(TestGLibVariant, GetBool)
860@@ -254,7 +265,29 @@
861
862 Variant v4;
863 EXPECT_EQ(v4.GetBool(), false);
864-}
865+
866+ value = (g_random_int() % 2) ? TRUE : FALSE;
867+ Variant v5(g_variant_new_variant(g_variant_new_boolean(value)));
868+ EXPECT_EQ(v5.GetBool(), value);
869+}
870+
871+TEST(TestGLibVariant, GetVariant)
872+{
873+ Variant value(g_variant_new_uint32(g_random_int()));
874+ Variant v1(g_variant_new_variant(value));
875+ EXPECT_TRUE(ValuesEqual(v1.GetVariant(), value));
876+
877+ value = g_variant_new_boolean((g_random_int() % 2) ? TRUE : FALSE);
878+ Variant v2(g_variant_new("(v)", static_cast<GVariant*>(value)));
879+ EXPECT_TRUE(ValuesEqual(v2.GetVariant(), value));
880+
881+ Variant v3(g_variant_new("(vs)", static_cast<GVariant*>(value), "fooostring"));
882+ EXPECT_FALSE(v3.GetVariant());
883+
884+ Variant v4;
885+ EXPECT_FALSE(v4.GetVariant());
886+}
887+
888
889
890 } // Namespace
891
892=== modified file 'tests/test_launcher_drag_window.cpp'
893--- tests/test_launcher_drag_window.cpp 2013-05-15 04:40:36 +0000
894+++ tests/test_launcher_drag_window.cpp 2013-08-29 17:07:13 +0000
895@@ -29,91 +29,66 @@
896
897 namespace
898 {
899-const int ICON_WIDTH = 10;
900-const int ICON_HEIGHT = 15;
901+const int ICON_SIZE = 15;
902 }
903
904 namespace unity
905 {
906 namespace launcher
907 {
908-class StubLauncherDragWindow : public LauncherDragWindow
909-{
910- public:
911-
912- StubLauncherDragWindow(nux::ObjectPtr<nux::IOpenGLBaseTexture> const &texture,
913- std::function<void(nux::GraphicsEngine&)> const &callback)
914- : LauncherDragWindow(texture, callback)
915- {}
916-
917- protected:
918-
919- bool DrawContentOnNuxLayer() const { return false; }
920+namespace
921+{
922+
923+struct StubLauncherDragWindow : public LauncherDragWindow
924+{
925+ struct DrawCallback
926+ {
927+ MOCK_METHOD0(callback, void());
928+ };
929+
930+ StubLauncherDragWindow()
931+ : LauncherDragWindow(ICON_SIZE, std::bind(&DrawCallback::callback, &cb))
932+ {}
933+
934+ bool DrawContentOnNuxLayer() const { return false; }
935+ using LauncherDragWindow::DrawContent;
936+
937+ DrawCallback cb;
938 };
939
940 struct TestLauncherDragWindow : public testing::Test
941 {
942 TestLauncherDragWindow()
943- : texture(new nux::IOpenGLBaseTexture(nux::RTTEXTURE, ICON_WIDTH, ICON_HEIGHT, 24, 1, nux::BITFMT_R8G8B8A8))
944- , drag_window(new LauncherDragWindow(texture,
945- [](nux::GraphicsEngine &){
946- }))
947+ : drag_window(new StubLauncherDragWindow())
948 {}
949
950- nux::ObjectPtr<nux::IOpenGLBaseTexture> texture;
951- nux::ObjectPtr<LauncherDragWindow> drag_window;
952-};
953-
954-class DrawCallback
955-{
956- public:
957-
958- MOCK_METHOD0(callback, void());
959+ nux::ObjectPtr<StubLauncherDragWindow> drag_window;
960 };
961 }
962
963 TEST_F(TestLauncherDragWindow, Construction)
964 {
965- EXPECT_EQ(drag_window->GetBaseWidth(), ICON_WIDTH);
966- EXPECT_EQ(drag_window->GetBaseHeight(), ICON_HEIGHT);
967+ EXPECT_EQ(drag_window->GetBaseWidth(), ICON_SIZE);
968+ EXPECT_EQ(drag_window->GetBaseHeight(), ICON_SIZE);
969 EXPECT_FALSE(drag_window->Animating());
970 EXPECT_FALSE(drag_window->Cancelled());
971 }
972
973 TEST_F(TestLauncherDragWindow, NoDrawOnConstruction)
974 {
975- DrawCallback cb;
976-
977- EXPECT_CALL(cb, callback()).Times(0);
978-
979- drag_window.Adopt(new StubLauncherDragWindow (texture,
980- std::bind(&DrawCallback::callback,
981- &cb)));
982+ EXPECT_CALL(drag_window->cb, callback()).Times(0);
983+ drag_window = new StubLauncherDragWindow();
984 }
985
986 TEST_F(TestLauncherDragWindow, DrawOnFirstPaint)
987 {
988- DrawCallback cb;
989-
990- drag_window.Adopt(new StubLauncherDragWindow (texture,
991- std::bind(&DrawCallback::callback,
992- &cb)));
993-
994- EXPECT_CALL(cb, callback()).Times(1);
995-
996+ EXPECT_CALL(drag_window->cb, callback()).Times(1);
997 drag_window->DrawContent(*(nux::GetGraphicsDisplay()->GetGraphicsEngine()), false);
998 }
999
1000 TEST_F(TestLauncherDragWindow, NoDrawOnSecondPaint)
1001 {
1002- DrawCallback cb;
1003-
1004- drag_window.Adopt(new StubLauncherDragWindow (texture,
1005- std::bind(&DrawCallback::callback,
1006- &cb)));
1007-
1008- EXPECT_CALL(cb, callback()).Times(1);
1009-
1010+ EXPECT_CALL(drag_window->cb, callback()).Times(1);
1011 drag_window->DrawContent(*(nux::GetGraphicsDisplay()->GetGraphicsEngine()), false);
1012 drag_window->DrawContent(*(nux::GetGraphicsDisplay()->GetGraphicsEngine()), false);
1013 }
1014@@ -154,3 +129,4 @@
1015 }
1016
1017 }
1018+}
1019
1020=== modified file 'tests/test_software_center_launcher_icon.cpp'
1021--- tests/test_software_center_launcher_icon.cpp 2013-08-07 16:44:38 +0000
1022+++ tests/test_software_center_launcher_icon.cpp 2013-08-29 17:07:13 +0000
1023@@ -27,6 +27,7 @@
1024
1025 #include "mock-application.h"
1026 #include "FavoriteStore.h"
1027+#include "MultiMonitor.h"
1028 #include "SoftwareCenterLauncherIcon.h"
1029 #include "Launcher.h"
1030 #include "PanelStyle.h"
1031@@ -41,32 +42,50 @@
1032 {
1033 namespace launcher
1034 {
1035+namespace
1036+{
1037+const std::string PRE_INSTALL_ICON = "sw-center-launcher-icon";
1038+const std::string FINAL_ICON = "softwarecenter";
1039+const std::string APP_NAME = "Ubuntu Software Center";
1040 const std::string LOCAL_DATA_DIR = BUILDDIR"/tests/data";
1041 const std::string USC_DESKTOP = LOCAL_DATA_DIR+"/applications/ubuntu-software-center.desktop";
1042 const std::string USC_APP_INSTALL_DESKTOP = "/usr/share/app-install/desktop/software-center:ubuntu-software-center.desktop";
1043-
1044-class MockSoftwareCenterLauncherIcon : public SoftwareCenterLauncherIcon
1045-{
1046-public:
1047- MockSoftwareCenterLauncherIcon(ApplicationPtr const& app,
1048- std::string const& aptdaemon_trans_id,
1049- std::string const& icon_path)
1050- : SoftwareCenterLauncherIcon(app, aptdaemon_trans_id, icon_path)
1051- {}
1052-
1053- using SoftwareCenterLauncherIcon::GetActualDesktopFileAfterInstall;
1054- using SoftwareCenterLauncherIcon::GetRemoteUri;
1055- using SoftwareCenterLauncherIcon::OnFinished;
1056- using SoftwareCenterLauncherIcon::OnPropertyChanged;
1057-};
1058+}
1059
1060 struct TestSoftwareCenterLauncherIcon : testing::Test
1061 {
1062 TestSoftwareCenterLauncherIcon()
1063- : usc(std::make_shared<MockApplication::Nice>(USC_APP_INSTALL_DESKTOP, "softwarecenter", "Ubuntu Software Center"))
1064- , icon(usc, "/com/canonical/unity/test/object/path", "")
1065+ : usc(std::make_shared<MockApplication::Nice>(USC_APP_INSTALL_DESKTOP, FINAL_ICON, APP_NAME))
1066+ , icon(usc, "/com/canonical/unity/test/object/path", PRE_INSTALL_ICON)
1067 {}
1068
1069+ struct MockSoftwareCenterLauncherIcon : SoftwareCenterLauncherIcon
1070+ {
1071+ MockSoftwareCenterLauncherIcon(ApplicationPtr const& app,
1072+ std::string const& aptdaemon_trans_id,
1073+ std::string const& icon_path)
1074+ : SoftwareCenterLauncherIcon(app, aptdaemon_trans_id, icon_path)
1075+ {}
1076+
1077+ using SoftwareCenterLauncherIcon::GetActualDesktopFileAfterInstall;
1078+ using SoftwareCenterLauncherIcon::GetRemoteUri;
1079+ using SoftwareCenterLauncherIcon::OnFinished;
1080+ using SoftwareCenterLauncherIcon::OnPropertyChanged;
1081+ using SoftwareCenterLauncherIcon::drag_window_;
1082+ };
1083+
1084+ nux::ObjectPtr<Launcher> CreateLauncher()
1085+ {
1086+ launcher_win = new MockableBaseWindow("");
1087+ nux::ObjectPtr<Launcher> launcher(new Launcher(launcher_win.GetPointer()));
1088+ launcher->options = Options::Ptr(new Options);
1089+ launcher->SetModel(LauncherModel::Ptr(new LauncherModel));
1090+ return launcher;
1091+ }
1092+
1093+ Settings settings;
1094+ panel::Style panel;
1095+ nux::ObjectPtr<MockableBaseWindow> launcher_win;
1096 MockApplication::Ptr usc;
1097 MockSoftwareCenterLauncherIcon icon;
1098 };
1099@@ -74,8 +93,9 @@
1100 TEST_F(TestSoftwareCenterLauncherIcon, Construction)
1101 {
1102 EXPECT_FALSE(icon.IsVisible());
1103- EXPECT_EQ(icon.position(), AbstractLauncherIcon::Position::FLOATING);
1104- EXPECT_EQ(icon.tooltip_text(), "Waiting to install");
1105+ EXPECT_EQ(AbstractLauncherIcon::Position::FLOATING, icon.position());
1106+ EXPECT_EQ("Waiting to install", icon.tooltip_text());
1107+ EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name());
1108 }
1109
1110 TEST_F(TestSoftwareCenterLauncherIcon, DesktopFileTransformTrivial)
1111@@ -169,35 +189,60 @@
1112 {
1113 icon.tooltip_text = "FooText";
1114 icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success")));
1115- EXPECT_EQ("Ubuntu Software Center", icon.tooltip_text());
1116+ EXPECT_EQ(icon.tooltip_text(), usc->title());
1117 }
1118
1119 TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedUpdatesIcon)
1120 {
1121 icon.icon_name = "foo-icon";
1122 icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success")));
1123- EXPECT_EQ("softwarecenter", icon.icon_name());
1124-}
1125-
1126-TEST_F(TestSoftwareCenterLauncherIcon, Animate)
1127-{
1128- ASSERT_FALSE(icon.IsVisible());
1129-
1130- Settings settings;
1131- panel::Style panel;
1132- nux::ObjectPtr<MockableBaseWindow> win(new MockableBaseWindow(""));
1133- nux::ObjectPtr<Launcher> launcher(new Launcher(win.GetPointer()));
1134- launcher->options = Options::Ptr(new Options);
1135- launcher->SetModel(LauncherModel::Ptr(new LauncherModel));
1136-
1137- icon.Animate(launcher, 1, 2);
1138- Utils::WaitForTimeoutMSec(500);
1139-
1140- EXPECT_TRUE(icon.IsVisible());
1141-}
1142-
1143-struct InstallProgress : TestSoftwareCenterLauncherIcon, testing::WithParamInterface<int> {};
1144-INSTANTIATE_TEST_CASE_P(TestSoftwareCenterLauncherIcon, InstallProgress, testing::Range<int>(0, 99, 10));
1145+ EXPECT_EQ(icon.icon_name(), usc->icon());
1146+}
1147+
1148+TEST_F(TestSoftwareCenterLauncherIcon, AnimateToInvalidPosition)
1149+{
1150+ EXPECT_FALSE(icon.Animate(CreateLauncher(), 1, 2));
1151+ EXPECT_FALSE(icon.IsVisible());
1152+ EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name());
1153+}
1154+
1155+TEST_F(TestSoftwareCenterLauncherIcon, AnimateFromInvalidPosition)
1156+{
1157+ EXPECT_TRUE(icon.Animate(CreateLauncher(), 0, 0));
1158+ EXPECT_TRUE(icon.IsVisible());
1159+ EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name());
1160+}
1161+
1162+struct MultiMonitor : TestSoftwareCenterLauncherIcon, WithParamInterface<unsigned> {};
1163+INSTANTIATE_TEST_CASE_P(TestSoftwareCenterLauncherIcon, MultiMonitor, Range<unsigned>(0, monitors::MAX, 1));
1164+
1165+TEST_P(/*TestSoftwareCenterLauncherIcon*/MultiMonitor, Animate)
1166+{
1167+ auto launcher = CreateLauncher();
1168+ launcher->monitor = GetParam();
1169+ icon.SetCenter({1, 1, 0}, launcher->monitor(), nux::Geometry());
1170+ EXPECT_TRUE(icon.Animate(launcher, 2, 2));
1171+ EXPECT_TRUE(icon.IsVisible());
1172+ EXPECT_EQ("", icon.icon_name());
1173+
1174+ for (unsigned i = 0; i < monitors::MAX; ++i)
1175+ ASSERT_EQ(static_cast<int>(i) == launcher->monitor(), icon.IsVisibleOnMonitor(i));
1176+
1177+ bool animated = false;
1178+ ASSERT_TRUE(icon.drag_window_);
1179+ icon.drag_window_->anim_completed.connect([&animated] { animated = true; });
1180+ Utils::WaitUntilMSec(animated);
1181+ ASSERT_TRUE(animated);
1182+
1183+ EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name());
1184+ EXPECT_FALSE(icon.drag_window_);
1185+
1186+ for (unsigned i = 0; i < monitors::MAX; ++i)
1187+ ASSERT_TRUE(icon.IsVisibleOnMonitor(i));
1188+}
1189+
1190+struct InstallProgress : TestSoftwareCenterLauncherIcon, WithParamInterface<int> {};
1191+INSTANTIATE_TEST_CASE_P(TestSoftwareCenterLauncherIcon, InstallProgress, Range<int>(0, 99, 10));
1192
1193 TEST_P(/*TestSoftwareCenterLauncherIcon*/InstallProgress, InstallEmblems)
1194 {