Merge lp:~3v1n0/unity/stick-launcher-icon-on-drag into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 2822
Proposed branch: lp:~3v1n0/unity/stick-launcher-icon-on-drag
Merge into: lp:unity
Diff against target: 52 lines (+21/-3)
2 files modified
launcher/Launcher.cpp (+1/-3)
tests/test_launcher.cpp (+20/-0)
To merge this branch: bzr merge lp:~3v1n0/unity/stick-launcher-icon-on-drag
Reviewer Review Type Date Requested Status
Nick Dedekind (community) Approve
jenkins continuous-integration Pending
Review via email: mp+128721@code.launchpad.net

Commit message

Launcher: stick a dragged icon if its position has been changed.

Description of the change

As requested by design: when any launcher icon has changed its position after being reordered, it should be sticked (i.e. its position should be saved).

Unit tests updated/added.

To post a comment you must log in.
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/Launcher.cpp'
2--- launcher/Launcher.cpp 2012-10-05 14:20:42 +0000
3+++ launcher/Launcher.cpp 2012-10-09 14:12:19 +0000
4@@ -2054,9 +2054,7 @@
5 {
6 if (!_drag_window->Cancelled() && _model->IconIndex(_drag_icon) != _drag_icon_position)
7 {
8- if (_drag_icon->GetIconType() == AbstractLauncherIcon::IconType::DEVICE)
9- _drag_icon->Stick(false);
10-
11+ _drag_icon->Stick(false);
12 _model->Save();
13 }
14
15
16=== modified file 'tests/test_launcher.cpp'
17--- tests/test_launcher.cpp 2012-09-28 15:18:21 +0000
18+++ tests/test_launcher.cpp 2012-10-09 14:12:19 +0000
19@@ -362,6 +362,7 @@
20
21 bool model_saved = false;
22 model_->saved.connect([&model_saved] { model_saved = true; });
23+ EXPECT_CALL(*icon2, Stick(false));
24
25 ASSERT_NE(launcher_->GetDragIconPosition(), model_->IconIndex(icon2));
26 launcher_->EndIconDrag();
27@@ -423,6 +424,25 @@
28 EXPECT_EQ(launcher_->GetDraggedIcon(), nullptr);
29 }
30
31+TEST_F(TestLauncher, DragLauncherIconSticksApplicationIcon)
32+{
33+ auto const& icons = AddMockIcons(1);
34+
35+ MockMockLauncherIcon::Ptr app(new MockMockLauncherIcon(AbstractLauncherIcon::IconType::APPLICATION));
36+ model_->AddIcon(app);
37+
38+ // Start dragging app icon
39+ launcher_->StartIconDrag(app);
40+ launcher_->ShowDragWindow();
41+
42+ // Moving app icon to the beginning
43+ auto const& center = icons[0]->GetCenter(launcher_->monitor());
44+ launcher_->UpdateDragWindowPosition(center.x, center.y);
45+
46+ EXPECT_CALL(*app, Stick(false));
47+ launcher_->EndIconDrag();
48+}
49+
50 TEST_F(TestLauncher, DragLauncherIconSticksDeviceIcon)
51 {
52 auto const& icons = AddMockIcons(1);