Merge lp:~3v1n0/unity/launcher-controller-ensure-new into lp:unity
- launcher-controller-ensure-new
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Marco Trevisan (Treviño) |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2521 |
Proposed branch: | lp:~3v1n0/unity/launcher-controller-ensure-new |
Merge into: | lp:unity |
Diff against target: |
985 lines (+566/-172) 11 files modified
launcher/EdgeBarrierController.cpp (+18/-5) launcher/EdgeBarrierController.h (+1/-0) launcher/LauncherController.cpp (+29/-161) launcher/LauncherController.h (+2/-0) launcher/LauncherControllerPrivate.h (+163/-0) tests/CMakeLists.txt (+9/-0) tests/test_edge_barrier_controller.cpp (+48/-1) tests/test_launcher_controller.cpp (+202/-0) tests/test_uscreen_mock.h (+85/-0) unity-shared/UScreen.cpp (+4/-3) unity-shared/UScreen.h (+5/-2) |
To merge this branch: | bzr merge lp:~3v1n0/unity/launcher-controller-ensure-new |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andrea Azzarone (community) | Approve | ||
jenkins (community) | continuous-integration | Needs Fixing | |
Review via email: mp+116775@code.launchpad.net |
Commit message
LauncherController: Rewritten EnsureLaunchers() added tests, fix a crash caused by invalid barrier subscriptions.
Description of the change
Rewritten the EnsureLaunchers() method LauncherController and added unit tests for it.
As discussed with Tim LauncherControl
jenkins (martin-mrazik+qa) wrote : | # |
Sam Spilsbury (smspillaz) wrote : | # |
Looks good.
There are some merge markers in added file 'tests/
General comments:
* If you want to avoid the friend declaration, you can do something like this:
class TestLauncherExp
{
public:
virtual void ExpectNumContro
...
}
LauncherCont
{
...
}
::testing:
EXPECT_CALL (mock_launcher_
This method is pretty ugly though, and the friend might be better. Generally speaking, testing implementation details isn't really recommended, but in this case we want to do that.
* Its a bit unclear as to how UScreen.
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
> Looks good.
>
> There are some merge markers in added file
> 'tests/
Yeah, fixed...
> General comments:
>
> * If you want to avoid the friend declaration, you can do something like
> [...]
> This method is pretty ugly though, and the friend might be better.
Yes, that's what I generally do, but I didn't want all this even for future testing...
> Generally speaking, testing implementation details isn't really recommended,
> but in this case we want to do that.
Yep, that's the fact.
> * Its a bit unclear as to how UScreen.
> launchers to be added to an lc it doesn't know about, unless some singleton
> knows about lc, and that's pretty confusing.
As you can see, int SetupFakeMultim
jenkins (martin-mrazik+qa) wrote : | # |
FAILED: Continuous integration, rev:2554
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Martin Mrazik (mrazik) wrote : | # |
Sorry for the jenkins failure. I'm looking into this.
Unity Merger (unity-merger) wrote : | # |
The Jenkins job https:/
Not merging it.
Martin Mrazik (mrazik) wrote : | # |
Now I'm a bit confused. I thought the CI failure is because our jenkins quantal slaves were not 100% up-to-date as I was able to compile the latest trunk on my quantal laptop with staging PPA.
Now it looks like the unity-merger has a similar problem so let me look close into this.
Preview Diff
1 | === modified file 'launcher/EdgeBarrierController.cpp' | |||
2 | --- launcher/EdgeBarrierController.cpp 2012-07-20 19:26:15 +0000 | |||
3 | +++ launcher/EdgeBarrierController.cpp 2012-07-26 13:13:33 +0000 | |||
4 | @@ -15,6 +15,7 @@ | |||
5 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
6 | 16 | * | 16 | * |
7 | 17 | * Authored by: Jason Smith <jason.smith@canonical.com> | 17 | * Authored by: Jason Smith <jason.smith@canonical.com> |
8 | 18 | * Marco Trevisan <marco.trevisan@canonical.com> | ||
9 | 18 | */ | 19 | */ |
10 | 19 | 20 | ||
11 | 20 | #include "EdgeBarrierController.h" | 21 | #include "EdgeBarrierController.h" |
12 | @@ -157,7 +158,7 @@ | |||
13 | 157 | unsigned int monitor = owner->index; | 158 | unsigned int monitor = owner->index; |
14 | 158 | bool process = true; | 159 | bool process = true; |
15 | 159 | 160 | ||
17 | 160 | if (monitor <= subscribers_.size()) | 161 | if (monitor < subscribers_.size()) |
18 | 161 | { | 162 | { |
19 | 162 | auto subscriber = subscribers_[monitor]; | 163 | auto subscriber = subscribers_[monitor]; |
20 | 163 | 164 | ||
21 | @@ -206,20 +207,32 @@ | |||
22 | 206 | 207 | ||
23 | 207 | void EdgeBarrierController::Subscribe(EdgeBarrierSubscriber* subscriber, unsigned int monitor) | 208 | void EdgeBarrierController::Subscribe(EdgeBarrierSubscriber* subscriber, unsigned int monitor) |
24 | 208 | { | 209 | { |
26 | 209 | if (pimpl->subscribers_.size() <= monitor) | 210 | if (monitor >= pimpl->subscribers_.size()) |
27 | 210 | pimpl->subscribers_.resize(monitor + 1); | 211 | pimpl->subscribers_.resize(monitor + 1); |
28 | 211 | 212 | ||
29 | 213 | auto const& monitors = UScreen::GetDefault()->GetMonitors(); | ||
30 | 212 | pimpl->subscribers_[monitor] = subscriber; | 214 | pimpl->subscribers_[monitor] = subscriber; |
32 | 213 | pimpl->SetupBarriers(UScreen::GetDefault()->GetMonitors()); | 215 | pimpl->ResizeBarrierList(monitors); |
33 | 216 | pimpl->SetupBarriers(monitors); | ||
34 | 214 | } | 217 | } |
35 | 215 | 218 | ||
36 | 216 | void EdgeBarrierController::Unsubscribe(EdgeBarrierSubscriber* subscriber, unsigned int monitor) | 219 | void EdgeBarrierController::Unsubscribe(EdgeBarrierSubscriber* subscriber, unsigned int monitor) |
37 | 217 | { | 220 | { |
39 | 218 | if (pimpl->subscribers_.size() < monitor || pimpl->subscribers_[monitor] != subscriber) | 221 | if (monitor >= pimpl->subscribers_.size() || pimpl->subscribers_[monitor] != subscriber) |
40 | 219 | return; | 222 | return; |
41 | 220 | 223 | ||
42 | 224 | auto const& monitors = UScreen::GetDefault()->GetMonitors(); | ||
43 | 221 | pimpl->subscribers_[monitor] = nullptr; | 225 | pimpl->subscribers_[monitor] = nullptr; |
45 | 222 | pimpl->SetupBarriers(UScreen::GetDefault()->GetMonitors()); | 226 | pimpl->ResizeBarrierList(monitors); |
46 | 227 | pimpl->SetupBarriers(monitors); | ||
47 | 228 | } | ||
48 | 229 | |||
49 | 230 | EdgeBarrierSubscriber* EdgeBarrierController::GetSubscriber(unsigned int monitor) | ||
50 | 231 | { | ||
51 | 232 | if (monitor >= pimpl->subscribers_.size()) | ||
52 | 233 | return nullptr; | ||
53 | 234 | |||
54 | 235 | return pimpl->subscribers_[monitor]; | ||
55 | 223 | } | 236 | } |
56 | 224 | 237 | ||
57 | 225 | void EdgeBarrierController::ProcessBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event) | 238 | void EdgeBarrierController::ProcessBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event) |
58 | 226 | 239 | ||
59 | === modified file 'launcher/EdgeBarrierController.h' | |||
60 | --- launcher/EdgeBarrierController.h 2012-07-20 18:33:58 +0000 | |||
61 | +++ launcher/EdgeBarrierController.h 2012-07-26 13:13:33 +0000 | |||
62 | @@ -43,6 +43,7 @@ | |||
63 | 43 | 43 | ||
64 | 44 | void Subscribe(EdgeBarrierSubscriber* subscriber, unsigned int monitor); | 44 | void Subscribe(EdgeBarrierSubscriber* subscriber, unsigned int monitor); |
65 | 45 | void Unsubscribe(EdgeBarrierSubscriber* subscriber, unsigned int monitor); | 45 | void Unsubscribe(EdgeBarrierSubscriber* subscriber, unsigned int monitor); |
66 | 46 | EdgeBarrierSubscriber* GetSubscriber(unsigned int monitor); | ||
67 | 46 | 47 | ||
68 | 47 | protected: | 48 | protected: |
69 | 48 | void ProcessBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event); | 49 | void ProcessBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event); |
70 | 49 | 50 | ||
71 | === modified file 'launcher/LauncherController.cpp' | |||
72 | --- launcher/LauncherController.cpp 2012-07-25 02:39:32 +0000 | |||
73 | +++ launcher/LauncherController.cpp 2012-07-26 13:13:33 +0000 | |||
74 | @@ -30,23 +30,15 @@ | |||
75 | 30 | #include "BamfLauncherIcon.h" | 30 | #include "BamfLauncherIcon.h" |
76 | 31 | #include "DesktopLauncherIcon.h" | 31 | #include "DesktopLauncherIcon.h" |
77 | 32 | #include "DeviceLauncherIcon.h" | 32 | #include "DeviceLauncherIcon.h" |
78 | 33 | #include "DeviceLauncherSection.h" | ||
79 | 34 | #include "EdgeBarrierController.h" | ||
80 | 35 | #include "FavoriteStore.h" | 33 | #include "FavoriteStore.h" |
81 | 36 | #include "HudLauncherIcon.h" | 34 | #include "HudLauncherIcon.h" |
82 | 37 | #include "Launcher.h" | ||
83 | 38 | #include "LauncherController.h" | 35 | #include "LauncherController.h" |
87 | 39 | #include "LauncherEntryRemote.h" | 36 | #include "LauncherControllerPrivate.h" |
85 | 40 | #include "LauncherEntryRemoteModel.h" | ||
86 | 41 | #include "AbstractLauncherIcon.h" | ||
88 | 42 | #include "SoftwareCenterLauncherIcon.h" | 37 | #include "SoftwareCenterLauncherIcon.h" |
89 | 43 | #include "LauncherModel.h" | ||
90 | 44 | #include "VolumeMonitorWrapper.h" | ||
91 | 45 | #include "unity-shared/WindowManager.h" | 38 | #include "unity-shared/WindowManager.h" |
92 | 46 | #include "TrashLauncherIcon.h" | 39 | #include "TrashLauncherIcon.h" |
93 | 47 | #include "BFBLauncherIcon.h" | 40 | #include "BFBLauncherIcon.h" |
94 | 48 | #include "unity-shared/UScreen.h" | 41 | #include "unity-shared/UScreen.h" |
95 | 49 | #include "unity-shared/UBusWrapper.h" | ||
96 | 50 | #include "unity-shared/UBusMessages.h" | 42 | #include "unity-shared/UBusMessages.h" |
97 | 51 | #include "unity-shared/TimeUtil.h" | 43 | #include "unity-shared/TimeUtil.h" |
98 | 52 | 44 | ||
99 | @@ -93,120 +85,7 @@ | |||
100 | 93 | } | 85 | } |
101 | 94 | } | 86 | } |
102 | 95 | 87 | ||
217 | 96 | class Controller::Impl | 88 | |
104 | 97 | { | ||
105 | 98 | public: | ||
106 | 99 | Impl(Display* display, Controller* parent); | ||
107 | 100 | ~Impl(); | ||
108 | 101 | |||
109 | 102 | void UpdateNumWorkspaces(int workspaces); | ||
110 | 103 | |||
111 | 104 | Launcher* CreateLauncher(int monitor); | ||
112 | 105 | |||
113 | 106 | void Save(); | ||
114 | 107 | void SortAndUpdate(); | ||
115 | 108 | |||
116 | 109 | nux::ObjectPtr<Launcher> CurrentLauncher(); | ||
117 | 110 | |||
118 | 111 | void OnIconAdded(AbstractLauncherIcon::Ptr icon); | ||
119 | 112 | void OnIconRemoved(AbstractLauncherIcon::Ptr icon); | ||
120 | 113 | |||
121 | 114 | void OnLauncherAddRequest(char* path, AbstractLauncherIcon::Ptr before); | ||
122 | 115 | void OnLauncherAddRequestSpecial(std::string const& path, std::string const& aptdaemon_trans_id, | ||
123 | 116 | std::string const& icon_path, int icon_x, int icon_y, int icon_size); | ||
124 | 117 | void OnLauncherRemoveRequest(AbstractLauncherIcon::Ptr icon); | ||
125 | 118 | void OnSCIconAnimationComplete(AbstractLauncherIcon::Ptr icon); | ||
126 | 119 | |||
127 | 120 | void OnLauncherEntryRemoteAdded(LauncherEntryRemote::Ptr const& entry); | ||
128 | 121 | void OnLauncherEntryRemoteRemoved(LauncherEntryRemote::Ptr const& entry); | ||
129 | 122 | |||
130 | 123 | void OnFavoriteStoreFavoriteAdded(std::string const& entry, std::string const& pos, bool before); | ||
131 | 124 | void OnFavoriteStoreFavoriteRemoved(std::string const& entry); | ||
132 | 125 | void OnFavoriteStoreReordered(); | ||
133 | 126 | |||
134 | 127 | |||
135 | 128 | void InsertExpoAction(); | ||
136 | 129 | void RemoveExpoAction(); | ||
137 | 130 | |||
138 | 131 | void InsertDesktopIcon(); | ||
139 | 132 | void RemoveDesktopIcon(); | ||
140 | 133 | |||
141 | 134 | void SendHomeActivationRequest(); | ||
142 | 135 | |||
143 | 136 | int MonitorWithMouse(); | ||
144 | 137 | |||
145 | 138 | void InsertTrash(); | ||
146 | 139 | |||
147 | 140 | void RegisterIcon(AbstractLauncherIcon::Ptr icon); | ||
148 | 141 | |||
149 | 142 | AbstractLauncherIcon::Ptr CreateFavorite(const char* file_path); | ||
150 | 143 | |||
151 | 144 | SoftwareCenterLauncherIcon::Ptr CreateSCLauncherIcon(std::string const& file_path, std::string const& aptdaemon_trans_id, std::string const& icon_path); | ||
152 | 145 | |||
153 | 146 | void SetupBamf(); | ||
154 | 147 | |||
155 | 148 | void EnsureLaunchers(int primary, std::vector<nux::Geometry> const& monitors); | ||
156 | 149 | |||
157 | 150 | void OnExpoActivated(); | ||
158 | 151 | |||
159 | 152 | void OnScreenChanged(int primary_monitor, std::vector<nux::Geometry>& monitors); | ||
160 | 153 | |||
161 | 154 | void OnWindowFocusChanged (guint32 xid); | ||
162 | 155 | |||
163 | 156 | void OnViewOpened(BamfMatcher* matcher, BamfView* view); | ||
164 | 157 | |||
165 | 158 | void ReceiveMouseDownOutsideArea(int x, int y, unsigned long button_flags, unsigned long key_flags); | ||
166 | 159 | |||
167 | 160 | void ReceiveLauncherKeyPress(unsigned long eventType, | ||
168 | 161 | unsigned long keysym, | ||
169 | 162 | unsigned long state, | ||
170 | 163 | const char* character, | ||
171 | 164 | unsigned short keyCount); | ||
172 | 165 | |||
173 | 166 | static void OnBusAcquired(GDBusConnection* connection, const gchar* name, gpointer user_data); | ||
174 | 167 | static void OnDBusMethodCall(GDBusConnection* connection, const gchar* sender, const gchar* object_path, | ||
175 | 168 | const gchar* interface_name, const gchar* method_name, | ||
176 | 169 | GVariant* parameters, GDBusMethodInvocation* invocation, | ||
177 | 170 | gpointer user_data); | ||
178 | 171 | |||
179 | 172 | static GDBusInterfaceVTable interface_vtable; | ||
180 | 173 | |||
181 | 174 | Controller* parent_; | ||
182 | 175 | LauncherModel::Ptr model_; | ||
183 | 176 | nux::ObjectPtr<Launcher> launcher_; | ||
184 | 177 | nux::ObjectPtr<Launcher> keyboard_launcher_; | ||
185 | 178 | int sort_priority_; | ||
186 | 179 | AbstractVolumeMonitorWrapper::Ptr volume_monitor_; | ||
187 | 180 | DeviceLauncherSection device_section_; | ||
188 | 181 | LauncherEntryRemoteModel remote_model_; | ||
189 | 182 | AbstractLauncherIcon::Ptr expo_icon_; | ||
190 | 183 | AbstractLauncherIcon::Ptr desktop_icon_; | ||
191 | 184 | int num_workspaces_; | ||
192 | 185 | bool show_desktop_icon_; | ||
193 | 186 | Display* display_; | ||
194 | 187 | |||
195 | 188 | bool launcher_open; | ||
196 | 189 | bool launcher_keynav; | ||
197 | 190 | bool launcher_grabbed; | ||
198 | 191 | bool reactivate_keynav; | ||
199 | 192 | int reactivate_index; | ||
200 | 193 | bool keynav_restore_window_; | ||
201 | 194 | int launcher_key_press_time_; | ||
202 | 195 | unsigned int dbus_owner_; | ||
203 | 196 | |||
204 | 197 | ui::EdgeBarrierController edge_barriers_; | ||
205 | 198 | |||
206 | 199 | LauncherList launchers; | ||
207 | 200 | |||
208 | 201 | glib::Object<BamfMatcher> matcher_; | ||
209 | 202 | glib::Signal<void, BamfMatcher*, BamfView*> view_opened_signal_; | ||
210 | 203 | glib::SourceManager sources_; | ||
211 | 204 | UBusManager ubus; | ||
212 | 205 | |||
213 | 206 | sigc::connection on_expoicon_activate_connection_; | ||
214 | 207 | sigc::connection launcher_key_press_connection_; | ||
215 | 208 | sigc::connection launcher_event_outside_connection_; | ||
216 | 209 | }; | ||
218 | 210 | 89 | ||
219 | 211 | GDBusInterfaceVTable Controller::Impl::interface_vtable = | 90 | GDBusInterfaceVTable Controller::Impl::interface_vtable = |
220 | 212 | { Controller::Impl::OnDBusMethodCall, NULL, NULL}; | 91 | { Controller::Impl::OnDBusMethodCall, NULL, NULL}; |
221 | @@ -316,41 +195,35 @@ | |||
222 | 316 | unsigned int num_monitors = monitors.size(); | 195 | unsigned int num_monitors = monitors.size(); |
223 | 317 | unsigned int num_launchers = parent_->multiple_launchers ? num_monitors : 1; | 196 | unsigned int num_launchers = parent_->multiple_launchers ? num_monitors : 1; |
224 | 318 | unsigned int launchers_size = launchers.size(); | 197 | unsigned int launchers_size = launchers.size(); |
257 | 319 | unsigned int last_monitor = 0; | 198 | unsigned int last_launcher = 0; |
258 | 320 | 199 | ||
259 | 321 | if (num_launchers == 1) | 200 | for (unsigned int i = 0; i < num_launchers; i++, last_launcher++) |
260 | 322 | { | 201 | { |
261 | 323 | if (launchers_size == 0) | 202 | if (i >= launchers_size) |
262 | 324 | { | 203 | { |
263 | 325 | launchers.push_back(nux::ObjectPtr<Launcher>(CreateLauncher(primary))); | 204 | launchers.push_back(nux::ObjectPtr<Launcher>(CreateLauncher(i))); |
264 | 326 | } | 205 | } |
265 | 327 | else if (!launchers[0].IsValid()) | 206 | else if (!launchers[i]) |
266 | 328 | { | 207 | { |
267 | 329 | launchers[0] = nux::ObjectPtr<Launcher>(CreateLauncher(primary)); | 208 | launchers[i] = nux::ObjectPtr<Launcher>(CreateLauncher(i)); |
268 | 330 | } | 209 | } |
269 | 331 | 210 | ||
270 | 332 | launchers[0]->monitor(primary); | 211 | int monitor = (num_launchers == 1) ? primary : i; |
271 | 333 | launchers[0]->Resize(); | 212 | |
272 | 334 | last_monitor = 1; | 213 | if (launchers[i]->monitor() != monitor) |
273 | 335 | } | 214 | { |
274 | 336 | else | 215 | edge_barriers_.Unsubscribe(launchers[i].GetPointer(), launchers[i]->monitor); |
275 | 337 | { | 216 | } |
276 | 338 | for (unsigned int i = 0; i < num_monitors; i++, last_monitor++) | 217 | |
277 | 339 | { | 218 | launchers[i]->monitor(monitor); |
278 | 340 | if (i >= launchers_size) | 219 | launchers[i]->Resize(); |
279 | 341 | { | 220 | edge_barriers_.Subscribe(launchers[i].GetPointer(), launchers[i]->monitor); |
280 | 342 | launchers.push_back(nux::ObjectPtr<Launcher>(CreateLauncher(i))); | 221 | } |
281 | 343 | } | 222 | |
282 | 344 | 223 | for (unsigned int i = last_launcher; i < launchers_size; ++i) | |
251 | 345 | launchers[i]->monitor(i); | ||
252 | 346 | launchers[i]->Resize(); | ||
253 | 347 | } | ||
254 | 348 | } | ||
255 | 349 | |||
256 | 350 | for (unsigned int i = last_monitor; i < launchers_size; ++i) | ||
283 | 351 | { | 224 | { |
284 | 352 | auto launcher = launchers[i]; | 225 | auto launcher = launchers[i]; |
286 | 353 | if (launcher.IsValid()) | 226 | if (launcher) |
287 | 354 | { | 227 | { |
288 | 355 | parent_->RemoveChild(launcher.GetPointer()); | 228 | parent_->RemoveChild(launcher.GetPointer()); |
289 | 356 | launcher->GetParent()->UnReference(); | 229 | launcher->GetParent()->UnReference(); |
290 | @@ -359,11 +232,6 @@ | |||
291 | 359 | } | 232 | } |
292 | 360 | 233 | ||
293 | 361 | launchers.resize(num_launchers); | 234 | launchers.resize(num_launchers); |
294 | 362 | |||
295 | 363 | for (size_t i = 0; i < launchers.size(); ++i) | ||
296 | 364 | { | ||
297 | 365 | edge_barriers_.Subscribe(launchers[i].GetPointer(), launchers[i]->monitor); | ||
298 | 366 | } | ||
299 | 367 | } | 235 | } |
300 | 368 | 236 | ||
301 | 369 | void Controller::Impl::OnScreenChanged(int primary_monitor, std::vector<nux::Geometry>& monitors) | 237 | void Controller::Impl::OnScreenChanged(int primary_monitor, std::vector<nux::Geometry>& monitors) |
302 | 370 | 238 | ||
303 | === modified file 'launcher/LauncherController.h' | |||
304 | --- launcher/LauncherController.h 2012-06-18 02:57:23 +0000 | |||
305 | +++ launcher/LauncherController.h 2012-07-26 13:13:33 +0000 | |||
306 | @@ -35,6 +35,7 @@ | |||
307 | 35 | class AbstractLauncherIcon; | 35 | class AbstractLauncherIcon; |
308 | 36 | class Launcher; | 36 | class Launcher; |
309 | 37 | class LauncherModel; | 37 | class LauncherModel; |
310 | 38 | class TestLauncherController; | ||
311 | 38 | 39 | ||
312 | 39 | class Controller : public unity::debug::Introspectable, public sigc::trackable | 40 | class Controller : public unity::debug::Introspectable, public sigc::trackable |
313 | 40 | { | 41 | { |
314 | @@ -86,6 +87,7 @@ | |||
315 | 86 | void AddProperties(GVariantBuilder* builder); | 87 | void AddProperties(GVariantBuilder* builder); |
316 | 87 | 88 | ||
317 | 88 | private: | 89 | private: |
318 | 90 | friend class TestLauncherController; | ||
319 | 89 | class Impl; | 91 | class Impl; |
320 | 90 | std::unique_ptr<Impl> pimpl; | 92 | std::unique_ptr<Impl> pimpl; |
321 | 91 | }; | 93 | }; |
322 | 92 | 94 | ||
323 | === added file 'launcher/LauncherControllerPrivate.h' | |||
324 | --- launcher/LauncherControllerPrivate.h 1970-01-01 00:00:00 +0000 | |||
325 | +++ launcher/LauncherControllerPrivate.h 2012-07-26 13:13:33 +0000 | |||
326 | @@ -0,0 +1,163 @@ | |||
327 | 1 | /* | ||
328 | 2 | * Copyright 2012 Canonical Ltd. | ||
329 | 3 | * | ||
330 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
331 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
332 | 6 | * by the Free Software Foundation. | ||
333 | 7 | * | ||
334 | 8 | * This program is distributed in the hope that it will be useful, but | ||
335 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
336 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
337 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
338 | 12 | * | ||
339 | 13 | * You should have received a copy of the GNU General Public License | ||
340 | 14 | * version 3 along with this program. If not, see | ||
341 | 15 | * <http://www.gnu.org/licenses/> | ||
342 | 16 | * | ||
343 | 17 | * Authored by: Jason Smith <jason.smith@canonical.com> | ||
344 | 18 | * Tim Penhey <tim.penhey@canonical.com> | ||
345 | 19 | * Marco Trevisan (Treviño) <marco.trevisan@canonical.com> | ||
346 | 20 | * | ||
347 | 21 | */ | ||
348 | 22 | |||
349 | 23 | #ifndef LAUNCHER_CONTROLLER_PRIVATE_H | ||
350 | 24 | #define LAUNCHER_CONTROLLER_PRIVATE_H | ||
351 | 25 | |||
352 | 26 | #include <Nux/Nux.h> | ||
353 | 27 | |||
354 | 28 | #include "AbstractLauncherIcon.h" | ||
355 | 29 | #include "DeviceLauncherSection.h" | ||
356 | 30 | #include "EdgeBarrierController.h" | ||
357 | 31 | #include "LauncherController.h" | ||
358 | 32 | #include "Launcher.h" | ||
359 | 33 | #include "LauncherEntryRemote.h" | ||
360 | 34 | #include "LauncherEntryRemoteModel.h" | ||
361 | 35 | #include "LauncherModel.h" | ||
362 | 36 | #include "SoftwareCenterLauncherIcon.h" | ||
363 | 37 | #include "unity-shared/UBusWrapper.h" | ||
364 | 38 | #include "VolumeMonitorWrapper.h" | ||
365 | 39 | |||
366 | 40 | namespace unity | ||
367 | 41 | { | ||
368 | 42 | namespace launcher | ||
369 | 43 | { | ||
370 | 44 | |||
371 | 45 | class Controller::Impl | ||
372 | 46 | { | ||
373 | 47 | public: | ||
374 | 48 | Impl(Display* display, Controller* parent); | ||
375 | 49 | ~Impl(); | ||
376 | 50 | |||
377 | 51 | void UpdateNumWorkspaces(int workspaces); | ||
378 | 52 | |||
379 | 53 | Launcher* CreateLauncher(int monitor); | ||
380 | 54 | |||
381 | 55 | void Save(); | ||
382 | 56 | void SortAndUpdate(); | ||
383 | 57 | |||
384 | 58 | nux::ObjectPtr<Launcher> CurrentLauncher(); | ||
385 | 59 | |||
386 | 60 | void OnIconAdded(AbstractLauncherIcon::Ptr icon); | ||
387 | 61 | void OnIconRemoved(AbstractLauncherIcon::Ptr icon); | ||
388 | 62 | |||
389 | 63 | void OnLauncherAddRequest(char* path, AbstractLauncherIcon::Ptr before); | ||
390 | 64 | void OnLauncherAddRequestSpecial(std::string const& path, std::string const& aptdaemon_trans_id, | ||
391 | 65 | std::string const& icon_path, int icon_x, int icon_y, int icon_size); | ||
392 | 66 | void OnLauncherRemoveRequest(AbstractLauncherIcon::Ptr icon); | ||
393 | 67 | void OnSCIconAnimationComplete(AbstractLauncherIcon::Ptr icon); | ||
394 | 68 | |||
395 | 69 | void OnLauncherEntryRemoteAdded(LauncherEntryRemote::Ptr const& entry); | ||
396 | 70 | void OnLauncherEntryRemoteRemoved(LauncherEntryRemote::Ptr const& entry); | ||
397 | 71 | |||
398 | 72 | void OnFavoriteStoreFavoriteAdded(std::string const& entry, std::string const& pos, bool before); | ||
399 | 73 | void OnFavoriteStoreFavoriteRemoved(std::string const& entry); | ||
400 | 74 | void OnFavoriteStoreReordered(); | ||
401 | 75 | |||
402 | 76 | |||
403 | 77 | void InsertExpoAction(); | ||
404 | 78 | void RemoveExpoAction(); | ||
405 | 79 | |||
406 | 80 | void InsertDesktopIcon(); | ||
407 | 81 | void RemoveDesktopIcon(); | ||
408 | 82 | |||
409 | 83 | void SendHomeActivationRequest(); | ||
410 | 84 | |||
411 | 85 | int MonitorWithMouse(); | ||
412 | 86 | |||
413 | 87 | void InsertTrash(); | ||
414 | 88 | |||
415 | 89 | void RegisterIcon(AbstractLauncherIcon::Ptr icon); | ||
416 | 90 | |||
417 | 91 | AbstractLauncherIcon::Ptr CreateFavorite(const char* file_path); | ||
418 | 92 | |||
419 | 93 | SoftwareCenterLauncherIcon::Ptr CreateSCLauncherIcon(std::string const& file_path, std::string const& aptdaemon_trans_id, std::string const& icon_path); | ||
420 | 94 | |||
421 | 95 | void SetupBamf(); | ||
422 | 96 | |||
423 | 97 | void EnsureLaunchers(int primary, std::vector<nux::Geometry> const& monitors); | ||
424 | 98 | |||
425 | 99 | void OnExpoActivated(); | ||
426 | 100 | |||
427 | 101 | void OnScreenChanged(int primary_monitor, std::vector<nux::Geometry>& monitors); | ||
428 | 102 | |||
429 | 103 | void OnWindowFocusChanged (guint32 xid); | ||
430 | 104 | |||
431 | 105 | void OnViewOpened(BamfMatcher* matcher, BamfView* view); | ||
432 | 106 | |||
433 | 107 | void ReceiveMouseDownOutsideArea(int x, int y, unsigned long button_flags, unsigned long key_flags); | ||
434 | 108 | |||
435 | 109 | void ReceiveLauncherKeyPress(unsigned long eventType, | ||
436 | 110 | unsigned long keysym, | ||
437 | 111 | unsigned long state, | ||
438 | 112 | const char* character, | ||
439 | 113 | unsigned short keyCount); | ||
440 | 114 | |||
441 | 115 | static void OnBusAcquired(GDBusConnection* connection, const gchar* name, gpointer user_data); | ||
442 | 116 | static void OnDBusMethodCall(GDBusConnection* connection, const gchar* sender, const gchar* object_path, | ||
443 | 117 | const gchar* interface_name, const gchar* method_name, | ||
444 | 118 | GVariant* parameters, GDBusMethodInvocation* invocation, | ||
445 | 119 | gpointer user_data); | ||
446 | 120 | |||
447 | 121 | static GDBusInterfaceVTable interface_vtable; | ||
448 | 122 | |||
449 | 123 | Controller* parent_; | ||
450 | 124 | LauncherModel::Ptr model_; | ||
451 | 125 | nux::ObjectPtr<Launcher> launcher_; | ||
452 | 126 | nux::ObjectPtr<Launcher> keyboard_launcher_; | ||
453 | 127 | int sort_priority_; | ||
454 | 128 | AbstractVolumeMonitorWrapper::Ptr volume_monitor_; | ||
455 | 129 | DeviceLauncherSection device_section_; | ||
456 | 130 | LauncherEntryRemoteModel remote_model_; | ||
457 | 131 | AbstractLauncherIcon::Ptr expo_icon_; | ||
458 | 132 | AbstractLauncherIcon::Ptr desktop_icon_; | ||
459 | 133 | int num_workspaces_; | ||
460 | 134 | bool show_desktop_icon_; | ||
461 | 135 | Display* display_; | ||
462 | 136 | |||
463 | 137 | bool launcher_open; | ||
464 | 138 | bool launcher_keynav; | ||
465 | 139 | bool launcher_grabbed; | ||
466 | 140 | bool reactivate_keynav; | ||
467 | 141 | int reactivate_index; | ||
468 | 142 | bool keynav_restore_window_; | ||
469 | 143 | int launcher_key_press_time_; | ||
470 | 144 | unsigned int dbus_owner_; | ||
471 | 145 | |||
472 | 146 | ui::EdgeBarrierController edge_barriers_; | ||
473 | 147 | |||
474 | 148 | LauncherList launchers; | ||
475 | 149 | |||
476 | 150 | glib::Object<BamfMatcher> matcher_; | ||
477 | 151 | glib::Signal<void, BamfMatcher*, BamfView*> view_opened_signal_; | ||
478 | 152 | glib::SourceManager sources_; | ||
479 | 153 | UBusManager ubus; | ||
480 | 154 | |||
481 | 155 | sigc::connection on_expoicon_activate_connection_; | ||
482 | 156 | sigc::connection launcher_key_press_connection_; | ||
483 | 157 | sigc::connection launcher_event_outside_connection_; | ||
484 | 158 | }; | ||
485 | 159 | |||
486 | 160 | } // launcher namespace | ||
487 | 161 | } // unity namespace | ||
488 | 162 | |||
489 | 163 | #endif | ||
490 | 0 | 164 | ||
491 | === modified file 'tests/CMakeLists.txt' | |||
492 | --- tests/CMakeLists.txt 2012-07-24 23:09:24 +0000 | |||
493 | +++ tests/CMakeLists.txt 2012-07-26 13:13:33 +0000 | |||
494 | @@ -217,6 +217,7 @@ | |||
495 | 217 | test_hud_view.cpp | 217 | test_hud_view.cpp |
496 | 218 | test_icon_loader.cpp | 218 | test_icon_loader.cpp |
497 | 219 | test_im_text_entry.cpp | 219 | test_im_text_entry.cpp |
498 | 220 | test_launcher_controller.cpp | ||
499 | 220 | test_keyboard_util.cpp | 221 | test_keyboard_util.cpp |
500 | 221 | test_resultviewgrid.cpp | 222 | test_resultviewgrid.cpp |
501 | 222 | test_single_monitor_launcher_icon.cpp | 223 | test_single_monitor_launcher_icon.cpp |
502 | @@ -239,9 +240,11 @@ | |||
503 | 239 | ${CMAKE_SOURCE_DIR}/hud/HudView.cpp | 240 | ${CMAKE_SOURCE_DIR}/hud/HudView.cpp |
504 | 240 | ${CMAKE_SOURCE_DIR}/launcher/AbstractLauncherIcon.cpp | 241 | ${CMAKE_SOURCE_DIR}/launcher/AbstractLauncherIcon.cpp |
505 | 241 | ${CMAKE_SOURCE_DIR}/launcher/BamfLauncherIcon.cpp | 242 | ${CMAKE_SOURCE_DIR}/launcher/BamfLauncherIcon.cpp |
506 | 243 | ${CMAKE_SOURCE_DIR}/launcher/BFBLauncherIcon.cpp | ||
507 | 242 | ${CMAKE_SOURCE_DIR}/launcher/CairoBaseWindow.cpp | 244 | ${CMAKE_SOURCE_DIR}/launcher/CairoBaseWindow.cpp |
508 | 243 | ${CMAKE_SOURCE_DIR}/launcher/DNDCollectionWindow.cpp | 245 | ${CMAKE_SOURCE_DIR}/launcher/DNDCollectionWindow.cpp |
509 | 244 | ${CMAKE_SOURCE_DIR}/launcher/Decaymulator.cpp | 246 | ${CMAKE_SOURCE_DIR}/launcher/Decaymulator.cpp |
510 | 247 | ${CMAKE_SOURCE_DIR}/launcher/DesktopLauncherIcon.cpp | ||
511 | 245 | ${CMAKE_SOURCE_DIR}/launcher/DeviceLauncherIcon.cpp | 248 | ${CMAKE_SOURCE_DIR}/launcher/DeviceLauncherIcon.cpp |
512 | 246 | ${CMAKE_SOURCE_DIR}/launcher/DeviceLauncherSection.cpp | 249 | ${CMAKE_SOURCE_DIR}/launcher/DeviceLauncherSection.cpp |
513 | 247 | ${CMAKE_SOURCE_DIR}/launcher/DevicesSettings.cpp | 250 | ${CMAKE_SOURCE_DIR}/launcher/DevicesSettings.cpp |
514 | @@ -251,9 +254,12 @@ | |||
515 | 251 | ${CMAKE_SOURCE_DIR}/launcher/FavoriteStoreGSettings.cpp | 254 | ${CMAKE_SOURCE_DIR}/launcher/FavoriteStoreGSettings.cpp |
516 | 252 | ${CMAKE_SOURCE_DIR}/launcher/FavoriteStorePrivate.cpp | 255 | ${CMAKE_SOURCE_DIR}/launcher/FavoriteStorePrivate.cpp |
517 | 253 | ${CMAKE_SOURCE_DIR}/launcher/GeisAdapter.cpp | 256 | ${CMAKE_SOURCE_DIR}/launcher/GeisAdapter.cpp |
518 | 257 | ${CMAKE_SOURCE_DIR}/launcher/HudLauncherIcon.cpp | ||
519 | 254 | ${CMAKE_SOURCE_DIR}/launcher/Launcher.cpp | 258 | ${CMAKE_SOURCE_DIR}/launcher/Launcher.cpp |
520 | 259 | ${CMAKE_SOURCE_DIR}/launcher/LauncherController.cpp | ||
521 | 255 | ${CMAKE_SOURCE_DIR}/launcher/LauncherDragWindow.cpp | 260 | ${CMAKE_SOURCE_DIR}/launcher/LauncherDragWindow.cpp |
522 | 256 | ${CMAKE_SOURCE_DIR}/launcher/LauncherEntryRemote.cpp | 261 | ${CMAKE_SOURCE_DIR}/launcher/LauncherEntryRemote.cpp |
523 | 262 | ${CMAKE_SOURCE_DIR}/launcher/LauncherEntryRemoteModel.cpp | ||
524 | 257 | ${CMAKE_SOURCE_DIR}/launcher/LauncherHideMachine.cpp | 263 | ${CMAKE_SOURCE_DIR}/launcher/LauncherHideMachine.cpp |
525 | 258 | ${CMAKE_SOURCE_DIR}/launcher/LauncherHoverMachine.cpp | 264 | ${CMAKE_SOURCE_DIR}/launcher/LauncherHoverMachine.cpp |
526 | 259 | ${CMAKE_SOURCE_DIR}/launcher/LauncherIcon.cpp | 265 | ${CMAKE_SOURCE_DIR}/launcher/LauncherIcon.cpp |
527 | @@ -271,11 +277,14 @@ | |||
528 | 271 | ${CMAKE_SOURCE_DIR}/launcher/QuicklistView.cpp | 277 | ${CMAKE_SOURCE_DIR}/launcher/QuicklistView.cpp |
529 | 272 | ${CMAKE_SOURCE_DIR}/launcher/SimpleLauncherIcon.cpp | 278 | ${CMAKE_SOURCE_DIR}/launcher/SimpleLauncherIcon.cpp |
530 | 273 | ${CMAKE_SOURCE_DIR}/launcher/SingleMonitorLauncherIcon.cpp | 279 | ${CMAKE_SOURCE_DIR}/launcher/SingleMonitorLauncherIcon.cpp |
531 | 280 | ${CMAKE_SOURCE_DIR}/launcher/SoftwareCenterLauncherIcon.cpp | ||
532 | 274 | ${CMAKE_SOURCE_DIR}/launcher/SpacerLauncherIcon.cpp | 281 | ${CMAKE_SOURCE_DIR}/launcher/SpacerLauncherIcon.cpp |
533 | 275 | ${CMAKE_SOURCE_DIR}/launcher/SwitcherController.cpp | 282 | ${CMAKE_SOURCE_DIR}/launcher/SwitcherController.cpp |
534 | 276 | ${CMAKE_SOURCE_DIR}/launcher/SwitcherModel.cpp | 283 | ${CMAKE_SOURCE_DIR}/launcher/SwitcherModel.cpp |
535 | 277 | ${CMAKE_SOURCE_DIR}/launcher/SwitcherView.cpp | 284 | ${CMAKE_SOURCE_DIR}/launcher/SwitcherView.cpp |
536 | 278 | ${CMAKE_SOURCE_DIR}/launcher/Tooltip.cpp | 285 | ${CMAKE_SOURCE_DIR}/launcher/Tooltip.cpp |
537 | 286 | ${CMAKE_SOURCE_DIR}/launcher/TrashLauncherIcon.cpp | ||
538 | 287 | ${CMAKE_SOURCE_DIR}/launcher/VolumeMonitorWrapper.cpp | ||
539 | 279 | ${CMAKE_SOURCE_DIR}/unity-shared/Animator.cpp | 288 | ${CMAKE_SOURCE_DIR}/unity-shared/Animator.cpp |
540 | 280 | ${CMAKE_SOURCE_DIR}/unity-shared/BackgroundEffectHelper.cpp | 289 | ${CMAKE_SOURCE_DIR}/unity-shared/BackgroundEffectHelper.cpp |
541 | 281 | ${CMAKE_SOURCE_DIR}/unity-shared/DashStyle.cpp | 290 | ${CMAKE_SOURCE_DIR}/unity-shared/DashStyle.cpp |
542 | 282 | 291 | ||
543 | === modified file 'tests/test_edge_barrier_controller.cpp' | |||
544 | --- tests/test_edge_barrier_controller.cpp 2012-07-20 18:34:34 +0000 | |||
545 | +++ tests/test_edge_barrier_controller.cpp 2012-07-26 13:13:33 +0000 | |||
546 | @@ -20,9 +20,9 @@ | |||
547 | 20 | 20 | ||
548 | 21 | #include <gmock/gmock.h> | 21 | #include <gmock/gmock.h> |
549 | 22 | #include "test_utils.h" | 22 | #include "test_utils.h" |
550 | 23 | #include "test_uscreen_mock.h" | ||
551 | 23 | 24 | ||
552 | 24 | #include "EdgeBarrierController.h" | 25 | #include "EdgeBarrierController.h" |
553 | 25 | #include "MultiMonitor.h" | ||
554 | 26 | 26 | ||
555 | 27 | using namespace unity; | 27 | using namespace unity; |
556 | 28 | using namespace unity::ui; | 28 | using namespace unity::ui; |
557 | @@ -53,6 +53,11 @@ | |||
558 | 53 | { | 53 | { |
559 | 54 | EdgeBarrierController::ProcessBarrierEvent(owner, event); | 54 | EdgeBarrierController::ProcessBarrierEvent(owner, event); |
560 | 55 | } | 55 | } |
561 | 56 | |||
562 | 57 | EdgeBarrierSubscriber* GetSubscriber(unsigned int monitor) | ||
563 | 58 | { | ||
564 | 59 | return EdgeBarrierController::GetSubscriber(monitor); | ||
565 | 60 | } | ||
566 | 56 | }; | 61 | }; |
567 | 57 | 62 | ||
568 | 58 | class TestBarrierSubscriber : public EdgeBarrierSubscriber | 63 | class TestBarrierSubscriber : public EdgeBarrierSubscriber |
569 | @@ -79,6 +84,8 @@ | |||
570 | 79 | bc.options()->edge_resist = true; | 84 | bc.options()->edge_resist = true; |
571 | 80 | bc.options()->edge_passed_disabled_ms = 150; | 85 | bc.options()->edge_passed_disabled_ms = 150; |
572 | 81 | 86 | ||
573 | 87 | uscreen.SetupFakeMultiMonitor(); | ||
574 | 88 | |||
575 | 82 | for (int i = 0; i < max_num_monitors; ++i) | 89 | for (int i = 0; i < max_num_monitors; ++i) |
576 | 83 | { | 90 | { |
577 | 84 | // By default we assume that no subscriber handles the events!!! | 91 | // By default we assume that no subscriber handles the events!!! |
578 | @@ -93,12 +100,38 @@ | |||
579 | 93 | } | 100 | } |
580 | 94 | 101 | ||
581 | 95 | TestBarrierSubscriber subscribers_[max_num_monitors]; | 102 | TestBarrierSubscriber subscribers_[max_num_monitors]; |
582 | 103 | MockUScreen uscreen; | ||
583 | 96 | MockEdgeBarrierController bc; | 104 | MockEdgeBarrierController bc; |
584 | 97 | }; | 105 | }; |
585 | 98 | 106 | ||
586 | 99 | TEST_F(TestEdgeBarrierController, Construction) | 107 | TEST_F(TestEdgeBarrierController, Construction) |
587 | 100 | { | 108 | { |
588 | 101 | EXPECT_TRUE(bc.sticky_edges); | 109 | EXPECT_TRUE(bc.sticky_edges); |
589 | 110 | |||
590 | 111 | for (int i = 0; i < max_num_monitors; ++i) | ||
591 | 112 | ASSERT_EQ(bc.GetSubscriber(i), &subscribers_[i]); | ||
592 | 113 | } | ||
593 | 114 | |||
594 | 115 | TEST_F(TestEdgeBarrierController, Unsubscribe) | ||
595 | 116 | { | ||
596 | 117 | for (int i = 0; i < max_num_monitors; ++i) | ||
597 | 118 | { | ||
598 | 119 | bc.Unsubscribe(&subscribers_[i], i); | ||
599 | 120 | ASSERT_EQ(bc.GetSubscriber(i), nullptr); | ||
600 | 121 | } | ||
601 | 122 | } | ||
602 | 123 | |||
603 | 124 | TEST_F(TestEdgeBarrierController, UnsubscribeInvalid) | ||
604 | 125 | { | ||
605 | 126 | bc.Unsubscribe(&subscribers_[2], 1); | ||
606 | 127 | ASSERT_EQ(bc.GetSubscriber(2), &subscribers_[2]); | ||
607 | 128 | } | ||
608 | 129 | |||
609 | 130 | TEST_F(TestEdgeBarrierController, SubscriberReplace) | ||
610 | 131 | { | ||
611 | 132 | TestBarrierSubscriber handling_subscriber(true); | ||
612 | 133 | bc.Subscribe(&handling_subscriber, 0); | ||
613 | 134 | EXPECT_EQ(bc.GetSubscriber(0), &handling_subscriber); | ||
614 | 102 | } | 135 | } |
615 | 103 | 136 | ||
616 | 104 | TEST_F(TestEdgeBarrierController, ProcessHandledEvent) | 137 | TEST_F(TestEdgeBarrierController, ProcessHandledEvent) |
617 | @@ -141,6 +174,20 @@ | |||
618 | 141 | bc.ProcessBarrierEvent(&owner, breaking_barrier_event); | 174 | bc.ProcessBarrierEvent(&owner, breaking_barrier_event); |
619 | 142 | } | 175 | } |
620 | 143 | 176 | ||
621 | 177 | TEST_F(TestEdgeBarrierController, ProcessUnHandledEventBreakingBarrierOnMaxMonitor) | ||
622 | 178 | { | ||
623 | 179 | int monitor = max_num_monitors; | ||
624 | 180 | |||
625 | 181 | MockPointerBarrier owner(monitor); | ||
626 | 182 | auto breaking_barrier_event = MakeBarrierEvent(0, true); | ||
627 | 183 | |||
628 | 184 | // This was leading to a crash, see bug #1020075 | ||
629 | 185 | // you can reproduce this repeating this test multiple times using the | ||
630 | 186 | // --gtest_repeat=X command line | ||
631 | 187 | EXPECT_CALL(owner, ReleaseBarrier(_)); | ||
632 | 188 | bc.ProcessBarrierEvent(&owner, breaking_barrier_event); | ||
633 | 189 | } | ||
634 | 190 | |||
635 | 144 | TEST_F(TestEdgeBarrierController, ProcessUnHandledEventNotBreakingBarrier) | 191 | TEST_F(TestEdgeBarrierController, ProcessUnHandledEventNotBreakingBarrier) |
636 | 145 | { | 192 | { |
637 | 146 | int monitor = 2; | 193 | int monitor = 2; |
638 | 147 | 194 | ||
639 | === added file 'tests/test_launcher_controller.cpp' | |||
640 | --- tests/test_launcher_controller.cpp 1970-01-01 00:00:00 +0000 | |||
641 | +++ tests/test_launcher_controller.cpp 2012-07-26 13:13:33 +0000 | |||
642 | @@ -0,0 +1,202 @@ | |||
643 | 1 | /* | ||
644 | 2 | * Copyright 2012 Canonical Ltd. | ||
645 | 3 | * | ||
646 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
647 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
648 | 6 | * by the Free Software Foundation. | ||
649 | 7 | * | ||
650 | 8 | * This program is distributed in the hope that it will be useful, but | ||
651 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
652 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
653 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
654 | 12 | * | ||
655 | 13 | * You should have received a copy of the GNU General Public License | ||
656 | 14 | * version 3 along with this program. If not, see | ||
657 | 15 | * <http://www.gnu.org/licenses/> | ||
658 | 16 | * | ||
659 | 17 | * Authored by: Marco Trevisan (Treviño) <marco.trevisan@canonical.com> | ||
660 | 18 | */ | ||
661 | 19 | |||
662 | 20 | #include <gmock/gmock.h> | ||
663 | 21 | #include "test_uscreen_mock.h" | ||
664 | 22 | |||
665 | 23 | #include "FavoriteStore.h" | ||
666 | 24 | #include "LauncherController.h" | ||
667 | 25 | #include "LauncherControllerPrivate.h" | ||
668 | 26 | #include "PanelStyle.h" | ||
669 | 27 | #include "UnitySettings.h" | ||
670 | 28 | |||
671 | 29 | using namespace unity::launcher; | ||
672 | 30 | using namespace testing; | ||
673 | 31 | |||
674 | 32 | namespace unity | ||
675 | 33 | { | ||
676 | 34 | |||
677 | 35 | class MockFavoriteStore : public FavoriteStore | ||
678 | 36 | { | ||
679 | 37 | public: | ||
680 | 38 | FavoriteList const& GetFavorites() | ||
681 | 39 | { | ||
682 | 40 | return fav_list_; | ||
683 | 41 | }; | ||
684 | 42 | |||
685 | 43 | void AddFavorite(std::string const& desktop_path, int position) {}; | ||
686 | 44 | void RemoveFavorite(std::string const& desktop_path) {}; | ||
687 | 45 | void MoveFavorite(std::string const& desktop_path, int position) {}; | ||
688 | 46 | void SetFavorites(FavoriteList const& desktop_paths) {}; | ||
689 | 47 | |||
690 | 48 | private: | ||
691 | 49 | FavoriteList fav_list_; | ||
692 | 50 | }; | ||
693 | 51 | |||
694 | 52 | namespace launcher | ||
695 | 53 | { | ||
696 | 54 | class TestLauncherController : public testing::Test | ||
697 | 55 | { | ||
698 | 56 | public: | ||
699 | 57 | TestLauncherController() | ||
700 | 58 | : lc(nux::GetGraphicsDisplay()->GetX11Display()) | ||
701 | 59 | {} | ||
702 | 60 | |||
703 | 61 | virtual void SetUp() | ||
704 | 62 | { | ||
705 | 63 | lc.options = std::make_shared<Options>(); | ||
706 | 64 | lc.multiple_launchers = true; | ||
707 | 65 | } | ||
708 | 66 | |||
709 | 67 | protected: | ||
710 | 68 | ui::EdgeBarrierController &GetBarrierController() | ||
711 | 69 | { | ||
712 | 70 | return lc.pimpl->edge_barriers_; | ||
713 | 71 | } | ||
714 | 72 | |||
715 | 73 | MockUScreen uscreen; | ||
716 | 74 | Settings settings; | ||
717 | 75 | panel::Style panel_style; | ||
718 | 76 | MockFavoriteStore favorite_store; | ||
719 | 77 | GeisAdapter geis_adapter; | ||
720 | 78 | Controller lc; | ||
721 | 79 | }; | ||
722 | 80 | } | ||
723 | 81 | |||
724 | 82 | TEST_F(TestLauncherController, Construction) | ||
725 | 83 | { | ||
726 | 84 | EXPECT_NE(lc.options(), nullptr); | ||
727 | 85 | EXPECT_TRUE(lc.multiple_launchers()); | ||
728 | 86 | } | ||
729 | 87 | |||
730 | 88 | TEST_F(TestLauncherController, MultimonitorMultipleLaunchers) | ||
731 | 89 | { | ||
732 | 90 | lc.multiple_launchers = true; | ||
733 | 91 | uscreen.SetupFakeMultiMonitor(); | ||
734 | 92 | |||
735 | 93 | ASSERT_EQ(lc.launchers().size(), max_num_monitors); | ||
736 | 94 | |||
737 | 95 | for (int i = 0; i < max_num_monitors; ++i) | ||
738 | 96 | { | ||
739 | 97 | EXPECT_EQ(lc.launchers()[i]->monitor(), i); | ||
740 | 98 | } | ||
741 | 99 | } | ||
742 | 100 | |||
743 | 101 | TEST_F(TestLauncherController, MultimonitorSingleLauncher) | ||
744 | 102 | { | ||
745 | 103 | lc.multiple_launchers = false; | ||
746 | 104 | uscreen.SetupFakeMultiMonitor(0, false); | ||
747 | 105 | |||
748 | 106 | for (int i = 0; i < max_num_monitors; ++i) | ||
749 | 107 | { | ||
750 | 108 | uscreen.SetPrimary(i); | ||
751 | 109 | ASSERT_EQ(lc.launchers().size(), 1); | ||
752 | 110 | EXPECT_EQ(lc.launcher().monitor(), i); | ||
753 | 111 | } | ||
754 | 112 | } | ||
755 | 113 | |||
756 | 114 | TEST_F(TestLauncherController, MultimonitorSwitchToMultipleLaunchers) | ||
757 | 115 | { | ||
758 | 116 | lc.multiple_launchers = false; | ||
759 | 117 | uscreen.SetupFakeMultiMonitor(); | ||
760 | 118 | |||
761 | 119 | ASSERT_EQ(lc.launchers().size(), 1); | ||
762 | 120 | |||
763 | 121 | lc.multiple_launchers = true; | ||
764 | 122 | EXPECT_EQ(lc.launchers().size(), max_num_monitors); | ||
765 | 123 | } | ||
766 | 124 | |||
767 | 125 | TEST_F(TestLauncherController, MultimonitorSwitchToSingleLauncher) | ||
768 | 126 | { | ||
769 | 127 | lc.multiple_launchers = true; | ||
770 | 128 | int primary = 3; | ||
771 | 129 | uscreen.SetupFakeMultiMonitor(primary); | ||
772 | 130 | |||
773 | 131 | ASSERT_EQ(lc.launchers().size(), max_num_monitors); | ||
774 | 132 | |||
775 | 133 | lc.multiple_launchers = false; | ||
776 | 134 | EXPECT_EQ(lc.launchers().size(), 1); | ||
777 | 135 | EXPECT_EQ(lc.launcher().monitor(), primary); | ||
778 | 136 | } | ||
779 | 137 | |||
780 | 138 | TEST_F(TestLauncherController, MultimonitorSwitchToSingleMonitor) | ||
781 | 139 | { | ||
782 | 140 | uscreen.SetupFakeMultiMonitor(); | ||
783 | 141 | ASSERT_EQ(lc.launchers().size(), max_num_monitors); | ||
784 | 142 | |||
785 | 143 | uscreen.Reset(); | ||
786 | 144 | EXPECT_EQ(lc.launchers().size(), 1); | ||
787 | 145 | EXPECT_EQ(lc.launcher().monitor(), 0); | ||
788 | 146 | } | ||
789 | 147 | |||
790 | 148 | TEST_F(TestLauncherController, MultimonitorRemoveMiddleMonitor) | ||
791 | 149 | { | ||
792 | 150 | uscreen.SetupFakeMultiMonitor(); | ||
793 | 151 | ASSERT_EQ(lc.launchers().size(), max_num_monitors); | ||
794 | 152 | |||
795 | 153 | std::vector<nux::Geometry> &monitors = uscreen.GetMonitors(); | ||
796 | 154 | monitors.erase(monitors.begin() + monitors.size()/2); | ||
797 | 155 | uscreen.changed.emit(uscreen.GetPrimaryMonitor(), uscreen.GetMonitors()); | ||
798 | 156 | ASSERT_EQ(lc.launchers().size(), max_num_monitors - 1); | ||
799 | 157 | |||
800 | 158 | for (int i = 0; i < max_num_monitors - 1; ++i) | ||
801 | 159 | EXPECT_EQ(lc.launchers()[i]->monitor(), i); | ||
802 | 160 | } | ||
803 | 161 | |||
804 | 162 | TEST_F(TestLauncherController, SingleMonitorSwitchToMultimonitor) | ||
805 | 163 | { | ||
806 | 164 | ASSERT_EQ(lc.launchers().size(), 1); | ||
807 | 165 | |||
808 | 166 | uscreen.SetupFakeMultiMonitor(); | ||
809 | 167 | |||
810 | 168 | EXPECT_EQ(lc.launchers().size(), max_num_monitors); | ||
811 | 169 | } | ||
812 | 170 | |||
813 | 171 | TEST_F(TestLauncherController, MultiMonitorEdgeBarrierSubscriptions) | ||
814 | 172 | { | ||
815 | 173 | uscreen.SetupFakeMultiMonitor(); | ||
816 | 174 | |||
817 | 175 | for (int i = 0; i < max_num_monitors; ++i) | ||
818 | 176 | ASSERT_EQ(GetBarrierController().GetSubscriber(i), lc.launchers()[i].GetPointer()); | ||
819 | 177 | } | ||
820 | 178 | |||
821 | 179 | TEST_F(TestLauncherController, SingleMonitorEdgeBarrierSubscriptionsUpdates) | ||
822 | 180 | { | ||
823 | 181 | lc.multiple_launchers = false; | ||
824 | 182 | uscreen.SetupFakeMultiMonitor(0, false); | ||
825 | 183 | |||
826 | 184 | for (int i = 0; i < max_num_monitors; ++i) | ||
827 | 185 | { | ||
828 | 186 | uscreen.SetPrimary(i); | ||
829 | 187 | |||
830 | 188 | for (int j = 0; j < max_num_monitors; ++j) | ||
831 | 189 | { | ||
832 | 190 | if (j == i) | ||
833 | 191 | { | ||
834 | 192 | ASSERT_EQ(GetBarrierController().GetSubscriber(j), &lc.launcher()); | ||
835 | 193 | } | ||
836 | 194 | else | ||
837 | 195 | { | ||
838 | 196 | ASSERT_EQ(GetBarrierController().GetSubscriber(j), nullptr); | ||
839 | 197 | } | ||
840 | 198 | } | ||
841 | 199 | } | ||
842 | 200 | } | ||
843 | 201 | |||
844 | 202 | } | ||
845 | 0 | 203 | ||
846 | === added file 'tests/test_uscreen_mock.h' | |||
847 | --- tests/test_uscreen_mock.h 1970-01-01 00:00:00 +0000 | |||
848 | +++ tests/test_uscreen_mock.h 2012-07-26 13:13:33 +0000 | |||
849 | @@ -0,0 +1,85 @@ | |||
850 | 1 | /* | ||
851 | 2 | * Copyright 2012 Canonical Ltd. | ||
852 | 3 | * | ||
853 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
854 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
855 | 6 | * by the Free Software Foundation. | ||
856 | 7 | * | ||
857 | 8 | * This program is distributed in the hope that it will be useful, but | ||
858 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
859 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
860 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
861 | 12 | * | ||
862 | 13 | * You should have received a copy of the GNU General Public License | ||
863 | 14 | * version 3 along with this program. If not, see | ||
864 | 15 | * <http://www.gnu.org/licenses/> | ||
865 | 16 | * | ||
866 | 17 | * Authored by: Marco Trevisan (Treviño) <marco.trevisan@canonical.com> | ||
867 | 18 | |||
868 | 19 | */ | ||
869 | 20 | |||
870 | 21 | #ifndef TEST_USCREEN_MOCK_H | ||
871 | 22 | #define TEST_USCREEN_MOCK_H | ||
872 | 23 | |||
873 | 24 | #include "MultiMonitor.h" | ||
874 | 25 | #include "UScreen.h" | ||
875 | 26 | |||
876 | 27 | namespace unity | ||
877 | 28 | { | ||
878 | 29 | |||
879 | 30 | const unsigned MONITOR_WIDTH = 1024; | ||
880 | 31 | const unsigned MONITOR_HEIGHT = 768; | ||
881 | 32 | |||
882 | 33 | class MockUScreen : public UScreen | ||
883 | 34 | { | ||
884 | 35 | public: | ||
885 | 36 | MockUScreen() | ||
886 | 37 | { | ||
887 | 38 | Reset(false); | ||
888 | 39 | } | ||
889 | 40 | |||
890 | 41 | ~MockUScreen() | ||
891 | 42 | { | ||
892 | 43 | if (default_screen_ == this) | ||
893 | 44 | default_screen_ = nullptr; | ||
894 | 45 | } | ||
895 | 46 | |||
896 | 47 | void Reset(bool emit = true) | ||
897 | 48 | { | ||
898 | 49 | default_screen_ = this; | ||
899 | 50 | primary_ = 0; | ||
900 | 51 | monitors_ = {nux::Geometry(0, 0, MONITOR_WIDTH, MONITOR_HEIGHT)}; | ||
901 | 52 | |||
902 | 53 | changed.emit(primary_, monitors_); | ||
903 | 54 | } | ||
904 | 55 | |||
905 | 56 | void SetupFakeMultiMonitor(int primary = 0, bool emit_update = true) | ||
906 | 57 | { | ||
907 | 58 | SetPrimary(primary, false); | ||
908 | 59 | monitors_.clear(); | ||
909 | 60 | |||
910 | 61 | for (int i = 0, total_width = 0; i < max_num_monitors; ++i) | ||
911 | 62 | { | ||
912 | 63 | monitors_.push_back(nux::Geometry(MONITOR_WIDTH, MONITOR_HEIGHT, total_width, 0)); | ||
913 | 64 | total_width += MONITOR_WIDTH; | ||
914 | 65 | |||
915 | 66 | if (emit_update) | ||
916 | 67 | changed.emit(GetPrimaryMonitor(), GetMonitors()); | ||
917 | 68 | } | ||
918 | 69 | } | ||
919 | 70 | |||
920 | 71 | void SetPrimary(int primary, bool emit = true) | ||
921 | 72 | { | ||
922 | 73 | if (primary_ != primary) | ||
923 | 74 | { | ||
924 | 75 | primary_ = primary; | ||
925 | 76 | |||
926 | 77 | if (emit) | ||
927 | 78 | changed.emit(primary_, monitors_); | ||
928 | 79 | } | ||
929 | 80 | } | ||
930 | 81 | }; | ||
931 | 82 | |||
932 | 83 | } | ||
933 | 84 | |||
934 | 85 | #endif | ||
935 | 0 | \ No newline at end of file | 86 | \ No newline at end of file |
936 | 1 | 87 | ||
937 | === modified file 'unity-shared/UScreen.cpp' | |||
938 | --- unity-shared/UScreen.cpp 2012-06-18 02:57:23 +0000 | |||
939 | +++ unity-shared/UScreen.cpp 2012-07-26 13:13:33 +0000 | |||
940 | @@ -24,17 +24,18 @@ | |||
941 | 24 | 24 | ||
942 | 25 | namespace | 25 | namespace |
943 | 26 | { | 26 | { |
944 | 27 | static UScreen* default_screen_ = nullptr; | ||
945 | 28 | nux::logging::Logger logger("unity.screen"); | 27 | nux::logging::Logger logger("unity.screen"); |
946 | 29 | } | 28 | } |
947 | 30 | 29 | ||
948 | 30 | UScreen* UScreen::default_screen_ = nullptr; | ||
949 | 31 | |||
950 | 31 | UScreen::UScreen() | 32 | UScreen::UScreen() |
952 | 32 | : screen_(gdk_screen_get_default(), glib::AddRef()) | 33 | : primary_(0) |
953 | 34 | , screen_(gdk_screen_get_default(), glib::AddRef()) | ||
954 | 33 | , proxy_("org.freedesktop.UPower", | 35 | , proxy_("org.freedesktop.UPower", |
955 | 34 | "/org/freedesktop/UPower", | 36 | "/org/freedesktop/UPower", |
956 | 35 | "org.freedesktop.UPower", | 37 | "org.freedesktop.UPower", |
957 | 36 | G_BUS_TYPE_SYSTEM) | 38 | G_BUS_TYPE_SYSTEM) |
958 | 37 | , primary_(0) | ||
959 | 38 | { | 39 | { |
960 | 39 | size_changed_signal_.Connect(screen_, "size-changed", sigc::mem_fun(this, &UScreen::Changed)); | 40 | size_changed_signal_.Connect(screen_, "size-changed", sigc::mem_fun(this, &UScreen::Changed)); |
961 | 40 | monitors_changed_signal_.Connect(screen_, "monitors-changed", sigc::mem_fun(this, &UScreen::Changed)); | 41 | monitors_changed_signal_.Connect(screen_, "monitors-changed", sigc::mem_fun(this, &UScreen::Changed)); |
962 | 41 | 42 | ||
963 | === modified file 'unity-shared/UScreen.h' | |||
964 | --- unity-shared/UScreen.h 2012-06-18 02:57:23 +0000 | |||
965 | +++ unity-shared/UScreen.h 2012-07-26 13:13:33 +0000 | |||
966 | @@ -55,14 +55,17 @@ | |||
967 | 55 | void Changed(GdkScreen* screen); | 55 | void Changed(GdkScreen* screen); |
968 | 56 | void Refresh(); | 56 | void Refresh(); |
969 | 57 | 57 | ||
971 | 58 | private: | 58 | protected: |
972 | 59 | static UScreen* default_screen_; | ||
973 | 59 | std::vector<nux::Geometry> monitors_; | 60 | std::vector<nux::Geometry> monitors_; |
974 | 61 | int primary_; | ||
975 | 62 | |||
976 | 63 | private: | ||
977 | 60 | glib::Object<GdkScreen> screen_; | 64 | glib::Object<GdkScreen> screen_; |
978 | 61 | glib::DBusProxy proxy_; | 65 | glib::DBusProxy proxy_; |
979 | 62 | glib::Signal<void, GdkScreen*> size_changed_signal_; | 66 | glib::Signal<void, GdkScreen*> size_changed_signal_; |
980 | 63 | glib::Signal<void, GdkScreen*> monitors_changed_signal_; | 67 | glib::Signal<void, GdkScreen*> monitors_changed_signal_; |
981 | 64 | glib::Source::UniquePtr refresh_idle_; | 68 | glib::Source::UniquePtr refresh_idle_; |
982 | 65 | int primary_; | ||
983 | 66 | }; | 69 | }; |
984 | 67 | 70 | ||
985 | 68 | } // Namespace | 71 | } // Namespace |
FAILED: Continuous integration, rev:2553 jenkins. qa.ubuntu. com/job/ unity-ci/ 124/ jenkins. qa.ubuntu. com/job/ unity-ci/ ./distribution= quantal, flavor= amd64/124/ console jenkins. qa.ubuntu. com/job/ unity-ci/ ./distribution= quantal, flavor= i386/124/ console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://