Merge lp:~azzar1/unity/fix-985883 into lp:unity
- fix-985883
- Merge into trunk
Proposed by
Andrea Azzarone
Status: | Merged |
---|---|
Approved by: | Brandon Schaefer |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2696 |
Proposed branch: | lp:~azzar1/unity/fix-985883 |
Merge into: | lp:unity |
Diff against target: |
679 lines (+255/-81) 14 files modified
plugins/unityshell/src/unityshell.cpp (+3/-1) shortcuts/AbstractShortcutHint.h (+8/-12) shortcuts/BaseWindowRaiser.h (+47/-0) shortcuts/BaseWindowRaiserImp.cpp (+33/-0) shortcuts/BaseWindowRaiserImp.h (+39/-0) shortcuts/CMakeLists.txt (+1/-0) shortcuts/MockShortcutHint.h (+7/-9) shortcuts/ShortcutController.cpp (+15/-15) shortcuts/ShortcutController.h (+17/-18) shortcuts/ShortcutModel.cpp (+5/-12) shortcuts/ShortcutModel.h (+8/-13) shortcuts/StandaloneShortcuts.cpp (+3/-1) tests/CMakeLists.txt (+7/-0) tests/test_shortcut_controller.cpp (+62/-0) |
To merge this branch: | bzr merge lp:~azzar1/unity/fix-985883 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Brandon Schaefer (community) | Approve | ||
Review via email: mp+123716@code.launchpad.net |
Commit message
Raise shortcut overlay on show.
Description of the change
== Problem ==
Dash - When the Dash is already open, holding the SUPER key should display the 'keyboard shortcuts overlay' on top of the Dash
== Fix ==
Use PushToFront to raise the BaseWindow.
== Test ==
Unit test added. I know that BaseWindowRaiser is not the best solution. Maybe we should pass nux::BaseWindow to shortcut:
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'plugins/unityshell/src/unityshell.cpp' |
2 | --- plugins/unityshell/src/unityshell.cpp 2012-09-07 12:40:24 +0000 |
3 | +++ plugins/unityshell/src/unityshell.cpp 2012-09-11 10:45:23 +0000 |
4 | @@ -25,6 +25,7 @@ |
5 | #include <Nux/BaseWindow.h> |
6 | #include <Nux/WindowCompositor.h> |
7 | |
8 | +#include "BaseWindowRaiserImp.h" |
9 | #include "IconRenderer.h" |
10 | #include "Launcher.h" |
11 | #include "LauncherIcon.h" |
12 | @@ -2960,7 +2961,8 @@ |
13 | |
14 | // Setup Shortcut Hint |
15 | InitHints(); |
16 | - shortcut_controller_ = std::make_shared<shortcut::Controller>(hints_); |
17 | + auto base_window_raiser_ = std::make_shared<shortcut::BaseWindowRaiserImp>(); |
18 | + shortcut_controller_ = std::make_shared<shortcut::Controller>(hints_, base_window_raiser_); |
19 | AddChild(shortcut_controller_.get()); |
20 | |
21 | AddChild(dash_controller_.get()); |
22 | |
23 | === modified file 'shortcuts/AbstractShortcutHint.h' |
24 | --- shortcuts/AbstractShortcutHint.h 2012-05-07 22:28:17 +0000 |
25 | +++ shortcuts/AbstractShortcutHint.h 2012-09-11 10:45:23 +0000 |
26 | @@ -14,12 +14,13 @@ |
27 | * You should have received a copy of the GNU General Public License |
28 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
29 | * |
30 | - * Authored by: Andrea Azzarone <azzaronea@gmail.com> |
31 | + * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> |
32 | */ |
33 | |
34 | #ifndef UNITYSHELL_ABSTRACT_SHORTCUT_ICON_H |
35 | #define UNITYSHELL_ABSTRACT_SHORTCUT_ICON_H |
36 | |
37 | +#include <memory> |
38 | #include <string> |
39 | |
40 | #include <Nux/Nux.h> |
41 | @@ -44,7 +45,7 @@ |
42 | { |
43 | public: |
44 | typedef std::shared_ptr<AbstractHint> Ptr; |
45 | - // Ctor |
46 | + |
47 | AbstractHint(std::string const& category, |
48 | std::string const& prefix, |
49 | std::string const& postfix, |
50 | @@ -61,10 +62,8 @@ |
51 | , arg1(arg1) |
52 | , arg2(arg2) |
53 | , arg3(arg3) |
54 | - { |
55 | - } |
56 | + {} |
57 | |
58 | - // Copy ctor |
59 | AbstractHint(unity::shortcut::AbstractHint const& obj) |
60 | : category(obj.category()) |
61 | , prefix(obj.prefix()) |
62 | @@ -76,13 +75,10 @@ |
63 | , arg3(obj.arg3()) |
64 | , value(obj.value()) |
65 | , shortkey(obj.shortkey()) |
66 | - { |
67 | - } |
68 | + {} |
69 | |
70 | - // Dtor |
71 | virtual ~AbstractHint(){}; |
72 | |
73 | - // Public Methods |
74 | virtual bool Fill() = 0; |
75 | |
76 | // Properties |
77 | @@ -98,7 +94,7 @@ |
78 | nux::Property<std::string> shortkey; |
79 | }; |
80 | |
81 | -} // namespace shortcut |
82 | -} // namespace unity |
83 | +} |
84 | +} |
85 | |
86 | -#endif // UNITYSHELL_ABSTRACT_SHORTCUT_ICON_H |
87 | +#endif |
88 | |
89 | === added file 'shortcuts/BaseWindowRaiser.h' |
90 | --- shortcuts/BaseWindowRaiser.h 1970-01-01 00:00:00 +0000 |
91 | +++ shortcuts/BaseWindowRaiser.h 2012-09-11 10:45:23 +0000 |
92 | @@ -0,0 +1,47 @@ |
93 | +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
94 | +/* |
95 | + * Copyright (C) 2012 Canonical Ltd |
96 | + * |
97 | + * This program is free software: you can redistribute it and/or modify |
98 | + * it under the terms of the GNU General Public License version 3 as |
99 | + * published by the Free Software Foundation. |
100 | + * |
101 | + * This program is distributed in the hope that it will be useful, |
102 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
103 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
104 | + * GNU General Public License for more details. |
105 | + * |
106 | + * You should have received a copy of the GNU General Public License |
107 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
108 | + * |
109 | + * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> |
110 | + */ |
111 | + |
112 | +#ifndef UNITYSHELL_BASE_WINDOW_RAISER_H |
113 | +#define UNITYSHELL_BASE_WINDOW_RAISER_H |
114 | + |
115 | +#include <boost/noncopyable.hpp> |
116 | +#include <memory> |
117 | + |
118 | +#include <Nux/Nux.h> |
119 | +#include <Nux/BaseWindow.h> |
120 | + |
121 | +namespace unity |
122 | +{ |
123 | +namespace shortcut |
124 | +{ |
125 | + |
126 | +class BaseWindowRaiser : boost::noncopyable |
127 | +{ |
128 | +public: |
129 | + typedef std::shared_ptr<BaseWindowRaiser> Ptr; |
130 | + |
131 | + virtual ~BaseWindowRaiser() {}; |
132 | + |
133 | + virtual void Raise(nux::ObjectPtr<nux::BaseWindow> window) = 0; |
134 | +}; |
135 | + |
136 | +} |
137 | +} |
138 | + |
139 | +#endif |
140 | |
141 | === added file 'shortcuts/BaseWindowRaiserImp.cpp' |
142 | --- shortcuts/BaseWindowRaiserImp.cpp 1970-01-01 00:00:00 +0000 |
143 | +++ shortcuts/BaseWindowRaiserImp.cpp 2012-09-11 10:45:23 +0000 |
144 | @@ -0,0 +1,33 @@ |
145 | +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
146 | +/* |
147 | + * Copyright (C) 2012 Canonical Ltd |
148 | + * |
149 | + * This program is free software: you can redistribute it and/or modify |
150 | + * it under the terms of the GNU General Public License version 3 as |
151 | + * published by the Free Software Foundation. |
152 | + * |
153 | + * This program is distributed in the hope that it will be useful, |
154 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
155 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
156 | + * GNU General Public License for more details. |
157 | + * |
158 | + * You should have received a copy of the GNU General Public License |
159 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
160 | + * |
161 | + * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> |
162 | + */ |
163 | + |
164 | +#include "BaseWindowRaiserImp.h" |
165 | + |
166 | +namespace unity |
167 | +{ |
168 | +namespace shortcut |
169 | +{ |
170 | + |
171 | +void BaseWindowRaiserImp::Raise(nux::ObjectPtr<nux::BaseWindow> window) |
172 | +{ |
173 | + window->PushToFront(); |
174 | +} |
175 | + |
176 | +} |
177 | +} |
178 | |
179 | === added file 'shortcuts/BaseWindowRaiserImp.h' |
180 | --- shortcuts/BaseWindowRaiserImp.h 1970-01-01 00:00:00 +0000 |
181 | +++ shortcuts/BaseWindowRaiserImp.h 2012-09-11 10:45:23 +0000 |
182 | @@ -0,0 +1,39 @@ |
183 | +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
184 | +/* |
185 | + * Copyright (C) 2012 Canonical Ltd |
186 | + * |
187 | + * This program is free software: you can redistribute it and/or modify |
188 | + * it under the terms of the GNU General Public License version 3 as |
189 | + * published by the Free Software Foundation. |
190 | + * |
191 | + * This program is distributed in the hope that it will be useful, |
192 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
193 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
194 | + * GNU General Public License for more details. |
195 | + * |
196 | + * You should have received a copy of the GNU General Public License |
197 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
198 | + * |
199 | + * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> |
200 | + */ |
201 | + |
202 | +#ifndef UNITYSHELL_BASE_WINDOW_RAISER_IMP_H |
203 | +#define UNITYSHELL_BASE_WINDOW_RAISER_IMP_H |
204 | + |
205 | +#include "BaseWindowRaiser.h" |
206 | + |
207 | +namespace unity |
208 | +{ |
209 | +namespace shortcut |
210 | +{ |
211 | + |
212 | +class BaseWindowRaiserImp : public BaseWindowRaiser |
213 | +{ |
214 | +public: |
215 | + virtual void Raise(nux::ObjectPtr<nux::BaseWindow> window); |
216 | +}; |
217 | + |
218 | +} |
219 | +} |
220 | + |
221 | +#endif |
222 | |
223 | === modified file 'shortcuts/CMakeLists.txt' |
224 | --- shortcuts/CMakeLists.txt 2012-07-06 10:20:29 +0000 |
225 | +++ shortcuts/CMakeLists.txt 2012-09-11 10:45:23 +0000 |
226 | @@ -30,6 +30,7 @@ |
227 | # |
228 | set (SHORTCUTS_SOURCES |
229 | AbstractShortcutHint.h |
230 | + BaseWindowRaiserImp.cpp |
231 | MockShortcutHint.h |
232 | ShortcutController.cpp |
233 | ShortcutController.h |
234 | |
235 | === modified file 'shortcuts/MockShortcutHint.h' |
236 | --- shortcuts/MockShortcutHint.h 2012-05-07 22:28:17 +0000 |
237 | +++ shortcuts/MockShortcutHint.h 2012-09-11 10:45:23 +0000 |
238 | @@ -14,7 +14,7 @@ |
239 | * You should have received a copy of the GNU General Public License |
240 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
241 | * |
242 | - * Authored by: Andrea Azzarone <azzaronea@gmail.com> |
243 | + * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> |
244 | */ |
245 | |
246 | #ifndef UNITYSHELL_MOCK_SHORTCUT_HINT_H |
247 | @@ -30,7 +30,8 @@ |
248 | class MockHint : public AbstractHint |
249 | { |
250 | public: |
251 | - // Ctor and dtor |
252 | + typedef std::shared_ptr<MockHint> Ptr; |
253 | + |
254 | MockHint(std::string const& category, |
255 | std::string const& prefix, |
256 | std::string const& postfix, |
257 | @@ -40,10 +41,7 @@ |
258 | std::string const& arg2 = "", |
259 | std::string const& arg3 = "") |
260 | : AbstractHint(category, prefix, postfix, description, type, arg1, arg2, arg3) |
261 | - { |
262 | - } |
263 | - |
264 | - ~MockHint() {}; |
265 | + {} |
266 | |
267 | // Methods... |
268 | bool Fill() |
269 | @@ -67,7 +65,7 @@ |
270 | } |
271 | }; |
272 | |
273 | -} // shortcut hint |
274 | -} // namespace unity |
275 | +} |
276 | +} |
277 | |
278 | -#endif // UNITYSHELL_MOCK_SHORTCUT_HINT_H |
279 | +#endif |
280 | |
281 | === modified file 'shortcuts/ShortcutController.cpp' |
282 | --- shortcuts/ShortcutController.cpp 2012-08-14 09:42:03 +0000 |
283 | +++ shortcuts/ShortcutController.cpp 2012-09-11 10:45:23 +0000 |
284 | @@ -13,7 +13,7 @@ |
285 | * You should have received a copy of the GNU General Public License |
286 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
287 | * |
288 | - * Authored by: Andrea Azzarone <azzaronea@gmail.com> |
289 | + * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> |
290 | */ |
291 | |
292 | #include "ShortcutController.h" |
293 | @@ -29,37 +29,37 @@ |
294 | { |
295 | const unsigned int SUPER_TAP_DURATION = 650; |
296 | const unsigned int FADE_DURATION = 100; |
297 | -} // anonymouse namespace; |
298 | +} |
299 | |
300 | -Controller::Controller(std::list<AbstractHint::Ptr>& hints) |
301 | - : visible_(false) |
302 | +Controller::Controller(std::list<AbstractHint::Ptr> const& hints, |
303 | + BaseWindowRaiser::Ptr const& base_window_raiser) |
304 | + : model_(std::make_shared<Model>(hints)) |
305 | + , base_window_raiser_(base_window_raiser) |
306 | + , visible_(false) |
307 | , enabled_(true) |
308 | + , bg_color_(0.0, 0.0, 0.0, 0.5) |
309 | , fade_in_animator_(FADE_DURATION) |
310 | , fade_out_animator_(FADE_DURATION) |
311 | { |
312 | - bg_color_ = nux::Color(0.0, 0.0, 0.0, 0.5); |
313 | + model_->Fill(); |
314 | |
315 | ubus_manager_.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED, |
316 | sigc::mem_fun(this, &Controller::OnBackgroundUpdate)); |
317 | |
318 | - ubus_manager_.RegisterInterest(UBUS_LAUNCHER_START_KEY_SWITCHER, [&] (GVariant*) { |
319 | + ubus_manager_.RegisterInterest(UBUS_LAUNCHER_START_KEY_SWITCHER, [this] (GVariant*) { |
320 | enabled_ = false; |
321 | }); |
322 | |
323 | - ubus_manager_.RegisterInterest(UBUS_LAUNCHER_END_KEY_SWITCHER, [&] (GVariant*) { |
324 | + ubus_manager_.RegisterInterest(UBUS_LAUNCHER_END_KEY_SWITCHER, [this] (GVariant*) { |
325 | enabled_ = true; |
326 | }); |
327 | |
328 | - ubus_manager_.RegisterInterest(UBUS_OVERLAY_SHOWN, [&] (GVariant*) { |
329 | + ubus_manager_.RegisterInterest(UBUS_OVERLAY_SHOWN, [this] (GVariant*) { |
330 | Hide(); |
331 | }); |
332 | |
333 | ubus_manager_.SendMessage(UBUS_BACKGROUND_REQUEST_COLOUR_EMIT); |
334 | |
335 | - model_.reset(new Model(hints)); |
336 | - |
337 | - model_->Fill(); |
338 | - |
339 | fade_in_animator_.animation_updated.connect(sigc::mem_fun(this, &Controller::OnFadeInUpdated)); |
340 | fade_in_animator_.animation_ended.connect(sigc::mem_fun(this, &Controller::OnFadeInEnded)); |
341 | fade_out_animator_.animation_updated.connect(sigc::mem_fun(this, &Controller::OnFadeOutUpdated)); |
342 | @@ -87,7 +87,6 @@ |
343 | view_window_->SetOpacity(0.0); |
344 | } |
345 | |
346 | - |
347 | void Controller::OnBackgroundUpdate(GVariant* data) |
348 | { |
349 | gdouble red, green, blue, alpha; |
350 | @@ -118,6 +117,7 @@ |
351 | return false; |
352 | |
353 | EnsureView(); |
354 | + base_window_raiser_->Raise(view_window_); |
355 | |
356 | nux::Geometry geo; |
357 | if (!view_->GetBaseGeometry(geo)) |
358 | @@ -190,12 +190,12 @@ |
359 | } |
360 | } |
361 | |
362 | -bool Controller::Visible() |
363 | +bool Controller::Visible() const |
364 | { |
365 | return visible_; |
366 | } |
367 | |
368 | -bool Controller::IsEnabled() |
369 | +bool Controller::IsEnabled() const |
370 | { |
371 | return enabled_; |
372 | } |
373 | |
374 | === modified file 'shortcuts/ShortcutController.h' |
375 | --- shortcuts/ShortcutController.h 2012-06-18 02:57:23 +0000 |
376 | +++ shortcuts/ShortcutController.h 2012-09-11 10:45:23 +0000 |
377 | @@ -13,13 +13,13 @@ |
378 | * You should have received a copy of the GNU General Public License |
379 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
380 | * |
381 | - * Authored by: Andrea Azzarone <azzaronea@gmail.com> |
382 | + * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> |
383 | */ |
384 | |
385 | -#ifndef UNITYSHELL_SHORTCUTCONTROLLER_H |
386 | -#define UNITYSHELL_SHORTCUTCONTROLLER_H |
387 | +#ifndef UNITYSHELL_SHORTCUT_CONTROLLER_H |
388 | +#define UNITYSHELL_SHORTCUT_CONTROLLER_H |
389 | |
390 | -#include <boost/shared_ptr.hpp> |
391 | +#include <memory> |
392 | |
393 | #include <Nux/Nux.h> |
394 | #include <Nux/BaseWindow.h> |
395 | @@ -28,10 +28,11 @@ |
396 | #include <UnityCore/Variant.h> |
397 | #include <UnityCore/GLibSource.h> |
398 | |
399 | +#include "BaseWindowRaiser.h" |
400 | +#include "ShortcutModel.h" |
401 | +#include "ShortcutView.h" |
402 | #include "unity-shared/Animator.h" |
403 | #include "unity-shared/Introspectable.h" |
404 | -#include "ShortcutModel.h" |
405 | -#include "ShortcutView.h" |
406 | #include "unity-shared/UBusWrapper.h" |
407 | |
408 | namespace unity |
409 | @@ -44,25 +45,24 @@ |
410 | public: |
411 | typedef std::shared_ptr<Controller> Ptr; |
412 | |
413 | - // Ctor |
414 | - Controller(std::list<AbstractHint::Ptr>& hints); |
415 | + Controller(std::list<AbstractHint::Ptr> const& hints, |
416 | + BaseWindowRaiser::Ptr const& raiser); |
417 | |
418 | - // Public Methods |
419 | bool Show(); |
420 | void Hide(); |
421 | |
422 | - bool Visible(); |
423 | - bool IsEnabled(); |
424 | + bool Visible() const; |
425 | + bool IsEnabled() const; |
426 | |
427 | void SetAdjustment(int x, int y); |
428 | void SetEnabled(bool enabled); |
429 | |
430 | protected: |
431 | + // Introspectable |
432 | std::string GetName() const; |
433 | void AddProperties(GVariantBuilder* builder); |
434 | |
435 | private: |
436 | - // Private Methods |
437 | void ConstructView(); |
438 | void EnsureView(); |
439 | void OnBackgroundUpdate(GVariant* data); |
440 | @@ -72,9 +72,9 @@ |
441 | void OnFadeOutEnded(); |
442 | bool OnShowTimer(); |
443 | |
444 | - // Private Members |
445 | View::Ptr view_; |
446 | Model::Ptr model_; |
447 | + BaseWindowRaiser::Ptr base_window_raiser_; |
448 | |
449 | nux::Geometry workarea_; |
450 | nux::ObjectPtr<nux::BaseWindow> view_window_; |
451 | @@ -91,8 +91,7 @@ |
452 | UBusManager ubus_manager_; |
453 | }; |
454 | |
455 | -} // namespace shortcut |
456 | -} // namespace unity |
457 | - |
458 | -#endif //UNITYSHELL_SHORTCUTHINTCONTROLLER_H |
459 | - |
460 | +} |
461 | +} |
462 | + |
463 | +#endif |
464 | |
465 | === modified file 'shortcuts/ShortcutModel.cpp' |
466 | --- shortcuts/ShortcutModel.cpp 2012-05-07 22:28:17 +0000 |
467 | +++ shortcuts/ShortcutModel.cpp 2012-09-11 10:45:23 +0000 |
468 | @@ -14,7 +14,7 @@ |
469 | * You should have received a copy of the GNU General Public License |
470 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
471 | * |
472 | - * Authored by: Andrea Azzarone <azzaronea@gmail.com> |
473 | + * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> |
474 | */ |
475 | |
476 | #include "ShortcutModel.h" |
477 | @@ -24,20 +24,13 @@ |
478 | namespace shortcut |
479 | { |
480 | |
481 | -// Ctor |
482 | -Model::Model(std::list<AbstractHint::Ptr>& hints) |
483 | +Model::Model(std::list<AbstractHint::Ptr> const& hints) |
484 | { |
485 | for (auto hint : hints) |
486 | AddHint(hint); |
487 | } |
488 | |
489 | -// Dtor |
490 | -Model::~Model() |
491 | -{ |
492 | -} |
493 | - |
494 | - |
495 | -void Model::AddHint(AbstractHint::Ptr hint) |
496 | +void Model::AddHint(AbstractHint::Ptr const& hint) |
497 | { |
498 | if (!hint) |
499 | return; |
500 | @@ -56,5 +49,5 @@ |
501 | item->Fill(); |
502 | } |
503 | |
504 | -} // namespace shortcut |
505 | -} // namespace unity |
506 | +} |
507 | +} |
508 | |
509 | === modified file 'shortcuts/ShortcutModel.h' |
510 | --- shortcuts/ShortcutModel.h 2012-05-07 22:28:17 +0000 |
511 | +++ shortcuts/ShortcutModel.h 2012-09-11 10:45:23 +0000 |
512 | @@ -14,11 +14,11 @@ |
513 | * You should have received a copy of the GNU General Public License |
514 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
515 | * |
516 | - * Authored by: Andrea Azzarone <azzaronea@gmail.com> |
517 | + * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> |
518 | */ |
519 | |
520 | -#ifndef UNITYSHELL_SHORTCUSMODEL_H |
521 | -#define UNITYSHELL_SHORTCUSMODEL_H |
522 | +#ifndef UNITYSHELL_SHORTCUS_MODEL_H |
523 | +#define UNITYSHELL_SHORTCUS_MODEL_H |
524 | |
525 | #include <boost/noncopyable.hpp> |
526 | #include <map> |
527 | @@ -39,26 +39,21 @@ |
528 | public: |
529 | typedef std::shared_ptr<Model> Ptr; |
530 | |
531 | - // Ctor and dtor |
532 | - Model(std::list<AbstractHint::Ptr>& hints); |
533 | - ~Model(); |
534 | + Model(std::list<AbstractHint::Ptr> const& hints); |
535 | |
536 | - // Accessors |
537 | std::vector<std::string>& categories() { return categories_; } |
538 | std::map<std::string, std::list<AbstractHint::Ptr>>& hints() { return hints_; } |
539 | |
540 | void Fill(); |
541 | |
542 | private: |
543 | - // Private functions |
544 | - void AddHint(AbstractHint::Ptr hint); |
545 | + void AddHint(AbstractHint::Ptr const& hint); |
546 | |
547 | - // Private members |
548 | std::vector<std::string> categories_; |
549 | std::map<std::string, std::list<AbstractHint::Ptr>> hints_; |
550 | }; |
551 | |
552 | -} // shortcut |
553 | -} // unity |
554 | +} |
555 | +} |
556 | |
557 | -#endif // UNITYSHELL_SHORTCUTS_H |
558 | +#endif |
559 | |
560 | === modified file 'shortcuts/StandaloneShortcuts.cpp' |
561 | --- shortcuts/StandaloneShortcuts.cpp 2012-08-28 07:07:13 +0000 |
562 | +++ shortcuts/StandaloneShortcuts.cpp 2012-09-11 10:45:23 +0000 |
563 | @@ -23,6 +23,7 @@ |
564 | #include <Nux/WindowThread.h> |
565 | |
566 | #include "unity-shared/BackgroundEffectHelper.h" |
567 | +#include "BaseWindowRaiserImp.h" |
568 | #include "MockShortcutHint.h" |
569 | #include "ShortcutController.h" |
570 | |
571 | @@ -228,7 +229,8 @@ |
572 | "resize", |
573 | "initiate_key"))); |
574 | |
575 | - controller.reset(new shortcut::Controller(hints)); |
576 | + auto base_window_raiser_ = std::make_shared<shortcut::BaseWindowRaiserImp>(); |
577 | + controller.reset(new shortcut::Controller(hints, base_window_raiser_)); |
578 | controller->Show(); |
579 | } |
580 | |
581 | |
582 | === modified file 'tests/CMakeLists.txt' |
583 | --- tests/CMakeLists.txt 2012-08-31 21:32:38 +0000 |
584 | +++ tests/CMakeLists.txt 2012-09-11 10:45:23 +0000 |
585 | @@ -223,6 +223,7 @@ |
586 | test_quicklist_menu_item.cpp |
587 | test_quicklist_view.cpp |
588 | test_resultviewgrid.cpp |
589 | + test_shortcut_controller.cpp |
590 | test_single_monitor_launcher_icon.cpp |
591 | test_switcher_controller.cpp |
592 | test_switcher_model.cpp |
593 | @@ -305,6 +306,11 @@ |
594 | ${CMAKE_SOURCE_DIR}/launcher/VolumeImp.cpp |
595 | ${CMAKE_SOURCE_DIR}/launcher/VolumeLauncherIcon.cpp |
596 | ${CMAKE_SOURCE_DIR}/launcher/VolumeMonitorWrapper.cpp |
597 | + ${CMAKE_SOURCE_DIR}/shortcuts/ShortcutController.cpp |
598 | + ${CMAKE_SOURCE_DIR}/shortcuts/ShortcutModel.cpp |
599 | + #${CMAKE_SOURCE_DIR}/shortcuts/ShortcutHintPrivate.cpp |
600 | + ${CMAKE_SOURCE_DIR}/shortcuts/ShortcutView.cpp |
601 | + ${CMAKE_SOURCE_DIR}/unity-shared/AbstractSeparator.cpp |
602 | ${CMAKE_SOURCE_DIR}/unity-shared/Animator.cpp |
603 | ${CMAKE_SOURCE_DIR}/unity-shared/BackgroundEffectHelper.cpp |
604 | ${CMAKE_SOURCE_DIR}/unity-shared/CoverArt.cpp |
605 | @@ -317,6 +323,7 @@ |
606 | ${CMAKE_SOURCE_DIR}/unity-shared/IMTextEntry.cpp |
607 | ${CMAKE_SOURCE_DIR}/unity-shared/Introspectable.cpp |
608 | ${CMAKE_SOURCE_DIR}/unity-shared/IntrospectableWrappers.cpp |
609 | + ${CMAKE_SOURCE_DIR}/unity-shared/LineSeparator.cpp |
610 | ${CMAKE_SOURCE_DIR}/unity-shared/JSONParser.cpp |
611 | ${CMAKE_SOURCE_DIR}/unity-shared/KeyboardUtil.cpp |
612 | ${CMAKE_SOURCE_DIR}/unity-shared/OverlayRenderer.cpp |
613 | |
614 | === added file 'tests/test_shortcut_controller.cpp' |
615 | --- tests/test_shortcut_controller.cpp 1970-01-01 00:00:00 +0000 |
616 | +++ tests/test_shortcut_controller.cpp 2012-09-11 10:45:23 +0000 |
617 | @@ -0,0 +1,62 @@ |
618 | +/* |
619 | + * Copyright 2012 Canonical Ltd. |
620 | + * |
621 | + * This program is free software: you can redistribute it and/or modify it |
622 | + * under the terms of the GNU General Public License version 3, as published |
623 | + * by the Free Software Foundation. |
624 | + * |
625 | + * This program is distributed in the hope that it will be useful, but |
626 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
627 | + * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR |
628 | + * PURPOSE. See the GNU General Public License for more details. |
629 | + * |
630 | + * You should have received a copy of the GNU General Public License |
631 | + * version 3 along with this program. If not, see |
632 | + * <http://www.gnu.org/licenses/> |
633 | + * |
634 | + * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> |
635 | + */ |
636 | + |
637 | +#include <gmock/gmock.h> |
638 | +using namespace testing; |
639 | + |
640 | +#include "shortcuts/BaseWindowRaiser.h" |
641 | +#include "shortcuts/ShortcutController.h" |
642 | +using namespace unity; |
643 | + |
644 | +#include "test_utils.h" |
645 | + |
646 | +namespace |
647 | +{ |
648 | + |
649 | +class MockBaseWindowRaiser : public shortcut::BaseWindowRaiser |
650 | +{ |
651 | +public: |
652 | + typedef std::shared_ptr<MockBaseWindowRaiser> Ptr; |
653 | + |
654 | + MOCK_METHOD1 (Raise, void(nux::ObjectPtr<nux::BaseWindow> window)); |
655 | +}; |
656 | + |
657 | +class TestShortcutController : public Test |
658 | +{ |
659 | +public: |
660 | + TestShortcutController() |
661 | + : base_window_raiser_(std::make_shared<MockBaseWindowRaiser>()) |
662 | + , controller_(hints_, base_window_raiser_) |
663 | + {} |
664 | + |
665 | + std::list<shortcut::AbstractHint::Ptr> hints_; |
666 | + MockBaseWindowRaiser::Ptr base_window_raiser_; |
667 | + shortcut::Controller controller_; |
668 | +}; |
669 | + |
670 | +TEST_F (TestShortcutController, WindowIsRaisedOnShow) |
671 | +{ |
672 | + EXPECT_CALL(*base_window_raiser_, Raise(_)) |
673 | + .Times(1); |
674 | + |
675 | + controller_.Show(); |
676 | + Utils::WaitForTimeout(1); |
677 | +} |
678 | + |
679 | +} |
Code looks good, manual test pass and unity test pass. :)