Merge lp:~macslow/unity/remote-add into lp:unity/5.0

Proposed by Mirco Müller
Status: Work in progress
Proposed branch: lp:~macslow/unity/remote-add
Merge into: lp:unity/5.0
Diff against target: 148 lines (+103/-12)
2 files modified
plugins/unityshell/src/LauncherController.cpp (+26/-12)
tests/test_launcher_controller.cpp (+77/-0)
To merge this branch: bzr merge lp:~macslow/unity/remote-add
Reviewer Review Type Date Requested Status
Conor Curran (community) Approve
Review via email: mp+121161@code.launchpad.net

Description of the change

Backported remote-add feature from unity 6.x series to 5.x and added a unit-test for it.

To post a comment you must log in.
Revision history for this message
Conor Curran (cjcurran) wrote :

Good work !

review: Approve
Revision history for this message
Andrea Azzarone (azzar1) wrote :

There are several indentation issues.

Also I know there is already a friend class to test the LauncherController but I'd prefer to do something like it:

* launcher_addrequest_special.emit(...)
* check if everthing is ok.

size_after = lc.launchers().size();
107 + EXPECT_EQ(size_before, size_after);

I think you need to get the number of icons in the launcher. lc.launcher() return a list of Launcher::Ptr (or something like that). Maybe you need something like that:

auto launcher = lc.launcher();
auto model = launcher.modeel() (or GetModel())
etc.

Unmerged revisions

2401. By Mirco Müller

Merged unit-test fixes for the backported remote-add functionality from unity 6.x

2400. By Mirco Müller

Backported remote-add functionality from 6.x to 5.x unity

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/LauncherController.cpp'
2--- plugins/unityshell/src/LauncherController.cpp 2012-07-26 13:12:26 +0000
3+++ plugins/unityshell/src/LauncherController.cpp 2012-08-24 11:17:32 +0000
4@@ -323,7 +323,11 @@
5 for (auto icon : bamf_icons)
6 {
7 if (icon->DesktopFile() == path)
8- return;
9+ {
10+ icon->Stick();
11+ Save();
12+ return;
13+ }
14 }
15
16 // Check if desktop file was supplied, or if it's set to SC's agent
17@@ -331,17 +335,27 @@
18 if (path.empty() || path == "software-center-agent")
19 return;
20
21- SoftwareCenterLauncherIcon::Ptr result = CreateSCLauncherIcon(path, aptdaemon_trans_id, icon_path);
22-
23- launcher_->ForceReveal(true);
24-
25- if (result)
26- {
27- result->SetQuirk(AbstractLauncherIcon::QUIRK_VISIBLE, false);
28- result->Animate(launcher_, icon_x, icon_y, icon_size);
29- RegisterIcon(result);
30- Save();
31- }
32+ if (aptdaemon_trans_id.empty())
33+ {
34+ AbstractLauncherIcon::Ptr result = CreateFavorite(path.c_str());
35+ if (result)
36+ RegisterIcon(result);
37+ }
38+ else
39+ {
40+ SoftwareCenterLauncherIcon::Ptr result = CreateSCLauncherIcon(path, aptdaemon_trans_id, icon_path);
41+
42+ launcher_->ForceReveal(true);
43+
44+ if (result)
45+ {
46+ result->SetQuirk(AbstractLauncherIcon::QUIRK_VISIBLE, false);
47+ result->Animate(launcher_, icon_x, icon_y, icon_size);
48+ RegisterIcon(result);
49+ }
50+ }
51+
52+ Save();
53 }
54
55 void Controller::Impl::OnSCIconAnimationComplete(AbstractLauncherIcon::Ptr icon)
56
57=== modified file 'tests/test_launcher_controller.cpp'
58--- tests/test_launcher_controller.cpp 2012-07-26 13:12:26 +0000
59+++ tests/test_launcher_controller.cpp 2012-08-24 11:17:32 +0000
60@@ -70,6 +70,19 @@
61 return lc.pimpl->edge_barriers_;
62 }
63
64+ // set of proxy functions to call private methods on the _Impl class
65+ AbstractLauncherIcon::Ptr CallImplCreateFavorite(const char *file_path)
66+ {
67+ return lc.pimpl->CreateFavorite(file_path);
68+ }
69+
70+ void CallImplOnLauncherAddRequestSpecial(std::string const& path, AbstractLauncherIcon::Ptr before,
71+ std::string const& aptdaemon_trans_id, std::string const& icon_path,
72+ int icon_x, int icon_y, int icon_size)
73+ {
74+ lc.pimpl->OnLauncherAddRequestSpecial(path, before, aptdaemon_trans_id, icon_path, icon_x, icon_y, icon_size);
75+ }
76+
77 MockUScreen uscreen;
78 dash::Settings settings;
79 panel::Style panel_style;
80@@ -199,4 +212,68 @@
81 }
82 }
83
84+TEST_F(TestLauncherController, OnLauncherAddRequestSpecial)
85+{
86+ std::string path = "nautilus";
87+ AbstractLauncherIcon::Ptr before = CallImplCreateFavorite("nautilus");
88+ std::string aptdaemon_trans_id = "aptdaemon_trans_id";
89+ std::string icon_path = "/usr/share/icons/ubuntu-mono-light/places/48/folder-home.svg";
90+ int x = 0;
91+ int y = 0;
92+ int size = 48;
93+ unsigned int size_before = 0;
94+ unsigned int size_after = 0;
95+
96+ size_before = lc.launchers().size();
97+ path.clear();
98+ aptdaemon_trans_id.clear();
99+ CallImplOnLauncherAddRequestSpecial(path,
100+ before,
101+ aptdaemon_trans_id,
102+ icon_path,
103+ x,
104+ y,
105+ size);
106+ size_after = lc.launchers().size();
107+ EXPECT_EQ(size_before, size_after);
108+
109+ size_before = size_after;
110+ path = "software-center-agent";
111+ CallImplOnLauncherAddRequestSpecial(path,
112+ before,
113+ aptdaemon_trans_id,
114+ icon_path,
115+ x,
116+ y,
117+ size);
118+ size_after = lc.launchers().size();
119+ EXPECT_EQ(size_before, size_after);
120+
121+ size_before = size_after;
122+ path = "nautilus";
123+ CallImplOnLauncherAddRequestSpecial(path,
124+ before,
125+ aptdaemon_trans_id,
126+ icon_path,
127+ x,
128+ y,
129+ size);
130+ size_after = lc.launchers().size();
131+ ASSERT_EQ(size_before, size_after);
132+
133+ size_before = size_after;
134+ aptdaemon_trans_id = "aptdaemon_trans_id";
135+ CallImplOnLauncherAddRequestSpecial(path,
136+ before,
137+ aptdaemon_trans_id,
138+ icon_path,
139+ x,
140+ y,
141+ size);
142+ size_after = lc.launchers().size();
143+ ASSERT_EQ(size_before, size_after);
144+
145+ // delete before;
146+}
147+
148 }

Subscribers

People subscribed via source and target branches

to all changes: