Merge lp:~3v1n0/unity/spread-launcher-desaturate into lp:unity
- spread-launcher-desaturate
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Brandon Schaefer |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3577 |
Proposed branch: | lp:~3v1n0/unity/spread-launcher-desaturate |
Merge into: | lp:unity |
Diff against target: |
764 lines (+378/-74) 10 files modified
dash/DashController.h (+1/-1) hud/HudController.h (+1/-1) launcher/Launcher.cpp (+50/-9) launcher/Launcher.h (+1/-0) tests/autopilot/unity/tests/test_spread.py (+72/-2) tests/mock-base-window.h (+8/-6) tests/test_dash_controller.cpp (+21/-22) tests/test_hud_controller.cpp (+29/-19) tests/test_launcher.cpp (+194/-8) tests/test_switcher_controller_class.cpp (+1/-6) |
To merge this branch: | bzr merge lp:~3v1n0/unity/spread-launcher-desaturate |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Brandon Schaefer (community) | Approve | ||
Review via email: mp+192066@code.launchpad.net |
This proposal supersedes a proposal from 2013-10-11.
Commit message
Launcher: desaturate the inactive icons when in Spread mode
Description of the change
Desaturate the Launcher and hide tooltips when spread is initiated as designed.
Added unit and autopilot tests.
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:3578
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Christopher Townsend (townsend) wrote : Posted in a previous version of this proposal | # |
Seems Jenkins CI is segfaulting:
[ RUN ] TestLauncher.
Segmentation fault
I don't see that locally:(
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:3578
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:3582
http://
Executed test runs:
FAILURE: http://
None: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
PASSED: Continuous integration, rev:3584
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Brandon Schaefer (brandontschaefer) wrote : Posted in a previous version of this proposal | # |
LGTM
Brandon Schaefer (brandontschaefer) wrote : | # |
Still looks good!
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'dash/DashController.h' | |||
2 | --- dash/DashController.h 2013-10-03 13:18:57 +0000 | |||
3 | +++ dash/DashController.h 2013-10-21 23:51:09 +0000 | |||
4 | @@ -41,7 +41,7 @@ | |||
5 | 41 | namespace dash | 41 | namespace dash |
6 | 42 | { | 42 | { |
7 | 43 | 43 | ||
9 | 44 | class Controller : public unity::debug::Introspectable | 44 | class Controller : public unity::debug::Introspectable, public sigc::trackable |
10 | 45 | { | 45 | { |
11 | 46 | public: | 46 | public: |
12 | 47 | typedef std::shared_ptr<Controller> Ptr; | 47 | typedef std::shared_ptr<Controller> Ptr; |
13 | 48 | 48 | ||
14 | === modified file 'hud/HudController.h' | |||
15 | --- hud/HudController.h 2013-10-16 03:42:03 +0000 | |||
16 | +++ hud/HudController.h 2013-10-21 23:51:09 +0000 | |||
17 | @@ -40,7 +40,7 @@ | |||
18 | 40 | namespace hud | 40 | namespace hud |
19 | 41 | { | 41 | { |
20 | 42 | 42 | ||
22 | 43 | class Controller : public unity::debug::Introspectable | 43 | class Controller : public unity::debug::Introspectable, public sigc::trackable |
23 | 44 | { | 44 | { |
24 | 45 | public: | 45 | public: |
25 | 46 | typedef std::shared_ptr<Controller> Ptr; | 46 | typedef std::shared_ptr<Controller> Ptr; |
26 | 47 | 47 | ||
27 | === modified file 'launcher/Launcher.cpp' | |||
28 | --- launcher/Launcher.cpp 2013-10-04 03:55:52 +0000 | |||
29 | +++ launcher/Launcher.cpp 2013-10-21 23:51:09 +0000 | |||
30 | @@ -94,6 +94,7 @@ | |||
31 | 94 | const std::string START_DRAGICON_TIMEOUT = "start-dragicon-timeout"; | 94 | const std::string START_DRAGICON_TIMEOUT = "start-dragicon-timeout"; |
32 | 95 | const std::string SCROLL_TIMEOUT = "scroll-timeout"; | 95 | const std::string SCROLL_TIMEOUT = "scroll-timeout"; |
33 | 96 | const std::string ANIMATION_IDLE = "animation-idle"; | 96 | const std::string ANIMATION_IDLE = "animation-idle"; |
34 | 97 | const std::string SCALE_DESATURATE_IDLE = "scale-desaturate-idle"; | ||
35 | 97 | const std::string URGENT_TIMEOUT = "urgent-timeout"; | 98 | const std::string URGENT_TIMEOUT = "urgent-timeout"; |
36 | 98 | } | 99 | } |
37 | 99 | 100 | ||
38 | @@ -173,9 +174,9 @@ | |||
39 | 173 | ql_manager.quicklist_closed.connect(sigc::mem_fun(this, &Launcher::RecvQuicklistClosed)); | 174 | ql_manager.quicklist_closed.connect(sigc::mem_fun(this, &Launcher::RecvQuicklistClosed)); |
40 | 174 | 175 | ||
41 | 175 | WindowManager& wm = WindowManager::Default(); | 176 | WindowManager& wm = WindowManager::Default(); |
43 | 176 | wm.initiate_spread.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged)); | 177 | wm.initiate_spread.connect(sigc::mem_fun(this, &Launcher::OnSpreadChanged)); |
44 | 178 | wm.terminate_spread.connect(sigc::mem_fun(this, &Launcher::OnSpreadChanged)); | ||
45 | 177 | wm.initiate_expo.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged)); | 179 | wm.initiate_expo.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged)); |
46 | 178 | wm.terminate_spread.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged)); | ||
47 | 179 | wm.terminate_expo.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged)); | 180 | wm.terminate_expo.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged)); |
48 | 180 | wm.screen_viewport_switch_ended.connect(sigc::mem_fun(this, &Launcher::QueueDraw)); | 181 | wm.screen_viewport_switch_ended.connect(sigc::mem_fun(this, &Launcher::QueueDraw)); |
49 | 181 | 182 | ||
50 | @@ -1125,23 +1126,30 @@ | |||
51 | 1125 | } | 1126 | } |
52 | 1126 | } | 1127 | } |
53 | 1127 | 1128 | ||
54 | 1129 | // FIXME: add monitor-aware quirks! | ||
55 | 1128 | void Launcher::DesaturateIcons() | 1130 | void Launcher::DesaturateIcons() |
56 | 1129 | { | 1131 | { |
58 | 1130 | for (auto icon : *model_) | 1132 | bool inactive_only = WindowManager::Default().IsScaleActiveForGroup(); |
59 | 1133 | |||
60 | 1134 | for (auto const& icon : *model_) | ||
61 | 1131 | { | 1135 | { |
62 | 1136 | bool desaturate = false; | ||
63 | 1137 | |||
64 | 1132 | if (icon->GetIconType () != AbstractLauncherIcon::IconType::HOME && | 1138 | if (icon->GetIconType () != AbstractLauncherIcon::IconType::HOME && |
66 | 1133 | icon->GetIconType () != AbstractLauncherIcon::IconType::HUD) | 1139 | icon->GetIconType () != AbstractLauncherIcon::IconType::HUD && |
67 | 1140 | (!inactive_only || !icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE))) | ||
68 | 1134 | { | 1141 | { |
70 | 1135 | icon->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, true); | 1142 | desaturate = true; |
71 | 1136 | } | 1143 | } |
72 | 1137 | 1144 | ||
73 | 1145 | icon->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, desaturate); | ||
74 | 1138 | icon->HideTooltip(); | 1146 | icon->HideTooltip(); |
75 | 1139 | } | 1147 | } |
76 | 1140 | } | 1148 | } |
77 | 1141 | 1149 | ||
78 | 1142 | void Launcher::SaturateIcons() | 1150 | void Launcher::SaturateIcons() |
79 | 1143 | { | 1151 | { |
81 | 1144 | for (auto icon : *model_) | 1152 | for (auto const& icon : *model_) |
82 | 1145 | { | 1153 | { |
83 | 1146 | icon->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, false); | 1154 | icon->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, false); |
84 | 1147 | } | 1155 | } |
85 | @@ -1243,7 +1251,7 @@ | |||
86 | 1243 | 1251 | ||
87 | 1244 | bool Launcher::IsOverlayOpen() const | 1252 | bool Launcher::IsOverlayOpen() const |
88 | 1245 | { | 1253 | { |
90 | 1246 | return dash_is_open_ || hud_is_open_; | 1254 | return dash_is_open_ || hud_is_open_ || WindowManager::Default().IsScaleActive(); |
91 | 1247 | } | 1255 | } |
92 | 1248 | 1256 | ||
93 | 1249 | void Launcher::SetHidden(bool hide_launcher) | 1257 | void Launcher::SetHidden(bool hide_launcher) |
94 | @@ -1303,8 +1311,34 @@ | |||
95 | 1303 | void Launcher::OnPluginStateChanged() | 1311 | void Launcher::OnPluginStateChanged() |
96 | 1304 | { | 1312 | { |
97 | 1305 | WindowManager& wm = WindowManager::Default(); | 1313 | WindowManager& wm = WindowManager::Default(); |
100 | 1306 | hide_machine_.SetQuirk(LauncherHideMachine::EXPO_ACTIVE, wm.IsExpoActive()); | 1314 | bool expo_active = wm.IsExpoActive(); |
101 | 1307 | hide_machine_.SetQuirk(LauncherHideMachine::SCALE_ACTIVE, wm.IsScaleActive()); | 1315 | hide_machine_.SetQuirk(LauncherHideMachine::EXPO_ACTIVE, expo_active); |
102 | 1316 | |||
103 | 1317 | if (expo_active && icon_under_mouse_) | ||
104 | 1318 | icon_under_mouse_->HideTooltip(); | ||
105 | 1319 | } | ||
106 | 1320 | |||
107 | 1321 | void Launcher::OnSpreadChanged() | ||
108 | 1322 | { | ||
109 | 1323 | WindowManager& wm = WindowManager::Default(); | ||
110 | 1324 | bool active = wm.IsScaleActive(); | ||
111 | 1325 | hide_machine_.SetQuirk(LauncherHideMachine::SCALE_ACTIVE, active); | ||
112 | 1326 | |||
113 | 1327 | bg_effect_helper_.enabled = active; | ||
114 | 1328 | |||
115 | 1329 | if (active && icon_under_mouse_) | ||
116 | 1330 | icon_under_mouse_->HideTooltip(); | ||
117 | 1331 | |||
118 | 1332 | if (active && (!hovered_ || wm.IsScaleActiveForGroup())) | ||
119 | 1333 | { | ||
120 | 1334 | // The icons can take some ms to update their active state, this can protect us. | ||
121 | 1335 | sources_.AddIdle([this] { DesaturateIcons(); return false; }, SCALE_DESATURATE_IDLE); | ||
122 | 1336 | } | ||
123 | 1337 | else | ||
124 | 1338 | { | ||
125 | 1339 | sources_.Remove(SCALE_DESATURATE_IDLE); | ||
126 | 1340 | SaturateIcons(); | ||
127 | 1341 | } | ||
128 | 1308 | } | 1342 | } |
129 | 1309 | 1343 | ||
130 | 1310 | LauncherHideMode Launcher::GetHideMode() const | 1344 | LauncherHideMode Launcher::GetHideMode() const |
131 | @@ -2231,6 +2265,13 @@ | |||
132 | 2231 | if (!hidden_) | 2265 | if (!hidden_) |
133 | 2232 | UpdateChangeInMousePosition(dx, dy); | 2266 | UpdateChangeInMousePosition(dx, dy); |
134 | 2233 | 2267 | ||
135 | 2268 | if (WindowManager::Default().IsScaleActiveForGroup()) | ||
136 | 2269 | { | ||
137 | 2270 | auto icon = MouseIconIntersection(x, y); | ||
138 | 2271 | if (icon && !icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE)) | ||
139 | 2272 | SaturateIcons(); | ||
140 | 2273 | } | ||
141 | 2274 | |||
142 | 2234 | // Every time the mouse moves, we check if it is inside an icon... | 2275 | // Every time the mouse moves, we check if it is inside an icon... |
143 | 2235 | EventLogic(); | 2276 | EventLogic(); |
144 | 2236 | 2277 | ||
145 | 2237 | 2278 | ||
146 | === modified file 'launcher/Launcher.h' | |||
147 | --- launcher/Launcher.h 2013-09-30 15:08:09 +0000 | |||
148 | +++ launcher/Launcher.h 2013-10-21 23:51:09 +0000 | |||
149 | @@ -200,6 +200,7 @@ | |||
150 | 200 | #endif | 200 | #endif |
151 | 201 | 201 | ||
152 | 202 | void OnPluginStateChanged(); | 202 | void OnPluginStateChanged(); |
153 | 203 | void OnSpreadChanged(); | ||
154 | 203 | 204 | ||
155 | 204 | void OnSelectionChanged(AbstractLauncherIcon::Ptr const& selection); | 205 | void OnSelectionChanged(AbstractLauncherIcon::Ptr const& selection); |
156 | 205 | 206 | ||
157 | 206 | 207 | ||
158 | === modified file 'tests/autopilot/unity/tests/test_spread.py' | |||
159 | --- tests/autopilot/unity/tests/test_spread.py 2013-10-08 14:08:52 +0000 | |||
160 | +++ tests/autopilot/unity/tests/test_spread.py 2013-10-21 23:51:09 +0000 | |||
161 | @@ -8,9 +8,11 @@ | |||
162 | 8 | 8 | ||
163 | 9 | from __future__ import absolute_import | 9 | from __future__ import absolute_import |
164 | 10 | 10 | ||
165 | 11 | from autopilot.display import Display | ||
166 | 11 | from autopilot.matchers import Eventually | 12 | from autopilot.matchers import Eventually |
167 | 12 | from testtools.matchers import Equals, NotEquals | 13 | from testtools.matchers import Equals, NotEquals |
168 | 13 | from time import sleep | 14 | from time import sleep |
169 | 15 | from unity.emulators.icons import BFBLauncherIcon | ||
170 | 14 | 16 | ||
171 | 15 | from unity.tests import UnityTestCase | 17 | from unity.tests import UnityTestCase |
172 | 16 | 18 | ||
173 | @@ -18,6 +20,10 @@ | |||
174 | 18 | class SpreadTests(UnityTestCase): | 20 | class SpreadTests(UnityTestCase): |
175 | 19 | """Spread tests""" | 21 | """Spread tests""" |
176 | 20 | 22 | ||
177 | 23 | def setUp(self): | ||
178 | 24 | super(SpreadTests, self).setUp() | ||
179 | 25 | self.launcher = self.unity.launcher.get_launcher_for_monitor(self.display.get_primary_screen()) | ||
180 | 26 | |||
181 | 21 | def start_test_application_windows(self, app_name, num_windows=2): | 27 | def start_test_application_windows(self, app_name, num_windows=2): |
182 | 22 | """Start a given number of windows of the requested application""" | 28 | """Start a given number of windows of the requested application""" |
183 | 23 | self.process_manager.close_all_app(app_name) | 29 | self.process_manager.close_all_app(app_name) |
184 | @@ -44,10 +50,9 @@ | |||
185 | 44 | """Initiate the Spread for windows of the given app""" | 50 | """Initiate the Spread for windows of the given app""" |
186 | 45 | icon = self.unity.launcher.model.get_icon(desktop_id=desktop_id) | 51 | icon = self.unity.launcher.model.get_icon(desktop_id=desktop_id) |
187 | 46 | self.assertThat(icon, NotEquals(None)) | 52 | self.assertThat(icon, NotEquals(None)) |
188 | 47 | launcher = self.unity.launcher.get_launcher_for_monitor(self.display.get_primary_screen()) | ||
189 | 48 | 53 | ||
190 | 49 | self.addCleanup(self.unity.window_manager.terminate_spread) | 54 | self.addCleanup(self.unity.window_manager.terminate_spread) |
192 | 50 | launcher.click_launcher_icon(icon) | 55 | self.launcher.click_launcher_icon(icon, move_mouse_after=False) |
193 | 51 | self.assertThat(self.unity.window_manager.scale_active_for_group, Eventually(Equals(True))) | 56 | self.assertThat(self.unity.window_manager.scale_active_for_group, Eventually(Equals(True))) |
194 | 52 | 57 | ||
195 | 53 | def assertWindowIsNotScaled(self, window): | 58 | def assertWindowIsNotScaled(self, window): |
196 | @@ -60,6 +65,17 @@ | |||
197 | 60 | refresh_fn = lambda: xid in [w.x_id for w in self.process_manager.get_open_windows()] | 65 | refresh_fn = lambda: xid in [w.x_id for w in self.process_manager.get_open_windows()] |
198 | 61 | self.assertThat(refresh_fn, Eventually(Equals(False))) | 66 | self.assertThat(refresh_fn, Eventually(Equals(False))) |
199 | 62 | 67 | ||
200 | 68 | def assertLauncherIconsSaturated(self): | ||
201 | 69 | for icon in self.unity.launcher.model.get_launcher_icons(): | ||
202 | 70 | self.assertThat(icon.desaturated, Eventually(Equals(False))) | ||
203 | 71 | |||
204 | 72 | def assertLauncherIconsDesaturated(self, also_active=True): | ||
205 | 73 | for icon in self.unity.launcher.model.get_launcher_icons(): | ||
206 | 74 | if isinstance(icon, BFBLauncherIcon) or (not also_active and icon.active): | ||
207 | 75 | self.assertThat(icon.desaturated, Eventually(Equals(False))) | ||
208 | 76 | else: | ||
209 | 77 | self.assertThat(icon.desaturated, Eventually(Equals(True))) | ||
210 | 78 | |||
211 | 63 | def test_scale_application_windows(self): | 79 | def test_scale_application_windows(self): |
212 | 64 | """All the windows of an application must be scaled when application | 80 | """All the windows of an application must be scaled when application |
213 | 65 | spread is initiated | 81 | spread is initiated |
214 | @@ -120,3 +136,57 @@ | |||
215 | 120 | 136 | ||
216 | 121 | self.assertWindowIsNotScaled(target_win) | 137 | self.assertWindowIsNotScaled(target_win) |
217 | 122 | self.assertWindowIsClosed(target_xid) | 138 | self.assertWindowIsClosed(target_xid) |
218 | 139 | |||
219 | 140 | def test_spread_desaturate_launcher_icons(self): | ||
220 | 141 | """Test that the screen spread desaturates the launcher icons""" | ||
221 | 142 | self.start_test_application_windows("Calculator", 1) | ||
222 | 143 | self.initiate_spread_for_screen() | ||
223 | 144 | self.launcher.move_mouse_to_right_of_launcher() | ||
224 | 145 | self.assertLauncherIconsDesaturated() | ||
225 | 146 | |||
226 | 147 | def test_spread_saturate_launcher_icons_on_mouse_over(self): | ||
227 | 148 | """Test that the screen spread re-saturates the launcher icons on mouse over""" | ||
228 | 149 | win = self.start_test_application_windows("Calculator", 2)[0] | ||
229 | 150 | self.initiate_spread_for_application(win.application.desktop_file) | ||
230 | 151 | self.launcher.move_mouse_over_launcher() | ||
231 | 152 | self.assertLauncherIconsSaturated() | ||
232 | 153 | |||
233 | 154 | def test_app_spread_desaturate_inactive_launcher_icons(self): | ||
234 | 155 | """Test that the app spread desaturates the inactive launcher icons""" | ||
235 | 156 | win = self.start_test_application_windows("Calculator", 2)[0] | ||
236 | 157 | self.initiate_spread_for_application(win.application.desktop_file) | ||
237 | 158 | self.assertLauncherIconsDesaturated(also_active=False) | ||
238 | 159 | |||
239 | 160 | def test_app_spread_saturate_launcher_icons_on_mouse_move(self): | ||
240 | 161 | """Test that the app spread re-saturates the launcher icons on mouse move""" | ||
241 | 162 | win = self.start_test_application_windows("Calculator", 2)[0] | ||
242 | 163 | self.initiate_spread_for_application(win.application.desktop_file) | ||
243 | 164 | self.launcher.move_mouse_to_icon(self.unity.launcher.model.get_bfb_icon()) | ||
244 | 165 | self.assertLauncherIconsSaturated() | ||
245 | 166 | |||
246 | 167 | def test_app_spread_saturate_launcher_icons_on_mouse_over(self): | ||
247 | 168 | """Test that the app spread re-saturates the launcher icons on mouse over""" | ||
248 | 169 | win = self.start_test_application_windows("Calculator", 2)[0] | ||
249 | 170 | self.initiate_spread_for_application(win.application.desktop_file) | ||
250 | 171 | self.launcher.move_mouse_over_launcher() | ||
251 | 172 | self.assertLauncherIconsSaturated() | ||
252 | 173 | |||
253 | 174 | def test_app_spread_desaturate_launcher_icons_switching_application(self): | ||
254 | 175 | """Test that the app spread desaturates the launcher icons on mouse over""" | ||
255 | 176 | cal_win = self.start_test_application_windows("Calculator", 2)[0] | ||
256 | 177 | char_win = self.start_test_application_windows("Character Map", 2)[0] | ||
257 | 178 | self.initiate_spread_for_application(char_win.application.desktop_file) | ||
258 | 179 | self.initiate_spread_for_application(cal_win.application.desktop_file) | ||
259 | 180 | self.assertLauncherIconsDesaturated(also_active=False) | ||
260 | 181 | |||
261 | 182 | def test_spread_hides_icon_tooltip(self): | ||
262 | 183 | """Tests that the screen spread hides the active tooltip.""" | ||
263 | 184 | [win] = self.start_test_application_windows("Calculator", 1) | ||
264 | 185 | icon = self.unity.launcher.model.get_icon(desktop_id=win.application.desktop_file) | ||
265 | 186 | self.mouse.move(icon.center_x, icon.center_y) | ||
266 | 187 | |||
267 | 188 | self.assertThat(lambda: icon.get_tooltip(), Eventually(NotEquals(None))) | ||
268 | 189 | self.assertThat(icon.get_tooltip().active, Eventually(Equals(True))) | ||
269 | 190 | |||
270 | 191 | self.initiate_spread_for_screen() | ||
271 | 192 | self.assertThat(icon.get_tooltip().active, Eventually(Equals(False))) | ||
272 | 123 | \ No newline at end of file | 193 | \ No newline at end of file |
273 | 124 | 194 | ||
274 | === modified file 'tests/mock-base-window.h' | |||
275 | --- tests/mock-base-window.h 2013-02-07 16:55:11 +0000 | |||
276 | +++ tests/mock-base-window.h 2013-10-21 23:51:09 +0000 | |||
277 | @@ -16,6 +16,7 @@ | |||
278 | 16 | #ifndef TESTS_MOCK_BASEWINDOW_H | 16 | #ifndef TESTS_MOCK_BASEWINDOW_H |
279 | 17 | #define TESTS_MOCK_BASEWINDOW_H | 17 | #define TESTS_MOCK_BASEWINDOW_H |
280 | 18 | 18 | ||
281 | 19 | #include <gmock/gmock.h> | ||
282 | 19 | #include "ResizingBaseWindow.h" | 20 | #include "ResizingBaseWindow.h" |
283 | 20 | 21 | ||
284 | 21 | namespace unity | 22 | namespace unity |
285 | @@ -23,25 +24,26 @@ | |||
286 | 23 | namespace testmocks | 24 | namespace testmocks |
287 | 24 | { | 25 | { |
288 | 25 | 26 | ||
289 | 27 | using namespace testing; | ||
290 | 28 | |||
291 | 26 | class MockBaseWindow : public ResizingBaseWindow | 29 | class MockBaseWindow : public ResizingBaseWindow |
292 | 27 | { | 30 | { |
293 | 28 | public: | 31 | public: |
294 | 29 | typedef nux::ObjectPtr<MockBaseWindow> Ptr; | 32 | typedef nux::ObjectPtr<MockBaseWindow> Ptr; |
295 | 33 | typedef NiceMock<MockBaseWindow> Nice; | ||
296 | 30 | 34 | ||
297 | 31 | MockBaseWindow(ResizingBaseWindow::GeometryAdjuster const& input_adjustment, const char *name = "Mock") | 35 | MockBaseWindow(ResizingBaseWindow::GeometryAdjuster const& input_adjustment, const char *name = "Mock") |
298 | 32 | : ResizingBaseWindow(name, input_adjustment) | 36 | : ResizingBaseWindow(name, input_adjustment) |
300 | 33 | {} | 37 | { |
301 | 38 | ON_CALL(*this, SetOpacity(_)).WillByDefault(Invoke([this] (float o) { ResizingBaseWindow::SetOpacity(o); })); | ||
302 | 39 | } | ||
303 | 34 | 40 | ||
304 | 35 | MockBaseWindow(const char *name = "Mock") | 41 | MockBaseWindow(const char *name = "Mock") |
306 | 36 | : ResizingBaseWindow(name, [](nux::Geometry const& geo) { return geo; }) | 42 | : MockBaseWindow([](nux::Geometry const& geo) { return geo; }, name) |
307 | 37 | {} | 43 | {} |
308 | 38 | 44 | ||
309 | 39 | MOCK_METHOD2(ShowWindow, void(bool, bool)); | 45 | MOCK_METHOD2(ShowWindow, void(bool, bool)); |
310 | 40 | MOCK_METHOD1(SetOpacity, void(float)); | 46 | MOCK_METHOD1(SetOpacity, void(float)); |
311 | 41 | |||
312 | 42 | // Really invoke the SetOpacity member function, a callthrough for use with | ||
313 | 43 | // ::testing::Invoke(). | ||
314 | 44 | void RealSetOpacity(float opacity) { ResizingBaseWindow::SetOpacity(opacity); } | ||
315 | 45 | }; | 47 | }; |
316 | 46 | 48 | ||
317 | 47 | } // namespace testmocks | 49 | } // namespace testmocks |
318 | 48 | 50 | ||
319 | === modified file 'tests/test_dash_controller.cpp' | |||
320 | --- tests/test_dash_controller.cpp 2013-02-07 16:56:07 +0000 | |||
321 | +++ tests/test_dash_controller.cpp 2013-10-21 23:51:09 +0000 | |||
322 | @@ -21,6 +21,7 @@ | |||
323 | 21 | #include "unity-shared/DashStyle.h" | 21 | #include "unity-shared/DashStyle.h" |
324 | 22 | #include "unity-shared/PanelStyle.h" | 22 | #include "unity-shared/PanelStyle.h" |
325 | 23 | #include "unity-shared/UnitySettings.h" | 23 | #include "unity-shared/UnitySettings.h" |
326 | 24 | #include "unity-shared/WindowManager.h" | ||
327 | 24 | #include "test_utils.h" | 25 | #include "test_utils.h" |
328 | 25 | 26 | ||
329 | 26 | #include <NuxCore/AnimationController.h> | 27 | #include <NuxCore/AnimationController.h> |
330 | @@ -32,42 +33,32 @@ | |||
331 | 32 | namespace | 33 | namespace |
332 | 33 | { | 34 | { |
333 | 34 | 35 | ||
335 | 35 | class TestDashController : public Test | 36 | struct TestDashController : Test |
336 | 36 | { | 37 | { |
337 | 37 | public: | ||
338 | 38 | TestDashController() | 38 | TestDashController() |
339 | 39 | : animation_controller(tick_source) | 39 | : animation_controller(tick_source) |
357 | 40 | , base_window_(new NiceMock<testmocks::MockBaseWindow>()) | 40 | , base_window_(new testmocks::MockBaseWindow::Nice()) |
358 | 41 | { } | 41 | , controller_(std::make_shared<dash::Controller>([this] { return base_window_.GetPointer(); })) |
359 | 42 | 42 | {} | |
343 | 43 | virtual void SetUp() | ||
344 | 44 | { | ||
345 | 45 | ON_CALL(*base_window_, SetOpacity(_)) | ||
346 | 46 | .WillByDefault(Invoke(base_window_.GetPointer(), | ||
347 | 47 | &testmocks::MockBaseWindow::RealSetOpacity)); | ||
348 | 48 | |||
349 | 49 | // Set expectations for creating the controller | ||
350 | 50 | EXPECT_CALL(*base_window_, SetOpacity(0.0f)) | ||
351 | 51 | .WillOnce(Invoke(base_window_.GetPointer(), | ||
352 | 52 | &testmocks::MockBaseWindow::RealSetOpacity)); | ||
353 | 53 | |||
354 | 54 | controller_.reset(new dash::Controller([&](){ return base_window_.GetPointer();})); | ||
355 | 55 | Mock::VerifyAndClearExpectations(base_window_.GetPointer()); | ||
356 | 56 | } | ||
360 | 57 | 43 | ||
361 | 58 | protected: | 44 | protected: |
362 | 59 | nux::animation::TickSource tick_source; | 45 | nux::animation::TickSource tick_source; |
363 | 60 | nux::animation::AnimationController animation_controller; | 46 | nux::animation::AnimationController animation_controller; |
364 | 61 | 47 | ||
365 | 62 | dash::Controller::Ptr controller_; | ||
366 | 63 | testmocks::MockBaseWindow::Ptr base_window_; | ||
367 | 64 | |||
368 | 65 | // required to create hidden secret global variables | 48 | // required to create hidden secret global variables |
369 | 66 | Settings unity_settings_; | 49 | Settings unity_settings_; |
370 | 67 | dash::Style dash_style_; | 50 | dash::Style dash_style_; |
371 | 68 | panel::Style panel_style_; | 51 | panel::Style panel_style_; |
372 | 52 | |||
373 | 53 | testmocks::MockBaseWindow::Ptr base_window_; | ||
374 | 54 | dash::Controller::Ptr controller_; | ||
375 | 69 | }; | 55 | }; |
376 | 70 | 56 | ||
377 | 57 | TEST_F(TestDashController, Construction) | ||
378 | 58 | { | ||
379 | 59 | EXPECT_CALL(*base_window_, SetOpacity(0.0f)); | ||
380 | 60 | controller_ = std::make_shared<dash::Controller>([this] { return base_window_.GetPointer(); }); | ||
381 | 61 | } | ||
382 | 71 | 62 | ||
383 | 72 | TEST_F(TestDashController, TestShowAndHideDash) | 63 | TEST_F(TestDashController, TestShowAndHideDash) |
384 | 73 | { | 64 | { |
385 | @@ -100,5 +91,13 @@ | |||
386 | 100 | EXPECT_EQ(base_window_->GetOpacity(), 0.0); | 91 | EXPECT_EQ(base_window_->GetOpacity(), 0.0); |
387 | 101 | } | 92 | } |
388 | 102 | 93 | ||
389 | 94 | TEST_F(TestDashController, DisconnectWMSignalsOnDestruction) | ||
390 | 95 | { | ||
391 | 96 | auto& signal = WindowManager::Default().initiate_spread; | ||
392 | 97 | size_t before = signal.size(); | ||
393 | 98 | { auto controller = std::make_shared<dash::Controller>([this] { return base_window_.GetPointer(); }); } | ||
394 | 99 | ASSERT_EQ(before, signal.size()); | ||
395 | 100 | signal.emit(); | ||
396 | 103 | } | 101 | } |
397 | 104 | 102 | ||
398 | 103 | } | ||
399 | 105 | 104 | ||
400 | === modified file 'tests/test_hud_controller.cpp' | |||
401 | --- tests/test_hud_controller.cpp 2013-02-19 15:07:36 +0000 | |||
402 | +++ tests/test_hud_controller.cpp 2013-10-21 23:51:09 +0000 | |||
403 | @@ -28,6 +28,7 @@ | |||
404 | 28 | #include "unity-shared/DashStyle.h" | 28 | #include "unity-shared/DashStyle.h" |
405 | 29 | #include "unity-shared/PanelStyle.h" | 29 | #include "unity-shared/PanelStyle.h" |
406 | 30 | #include "unity-shared/UnitySettings.h" | 30 | #include "unity-shared/UnitySettings.h" |
407 | 31 | #include "unity-shared/WindowManager.h" | ||
408 | 31 | #include "test_utils.h" | 32 | #include "test_utils.h" |
409 | 32 | using namespace unity; | 33 | using namespace unity; |
410 | 33 | 34 | ||
411 | @@ -62,35 +63,32 @@ | |||
412 | 62 | }; | 63 | }; |
413 | 63 | 64 | ||
414 | 64 | 65 | ||
416 | 65 | class TestHudController : public Test | 66 | struct TestHudController : Test |
417 | 66 | { | 67 | { |
418 | 67 | public: | ||
419 | 68 | TestHudController() | 68 | TestHudController() |
433 | 69 | : view_(new NiceMock<MockHudView>) | 69 | : view_(new NiceMock<MockHudView>) |
434 | 70 | , base_window_(new NiceMock<testmocks::MockBaseWindow>()) | 70 | , base_window_(new testmocks::MockBaseWindow::Nice()) |
435 | 71 | { | 71 | , controller_(std::make_shared<hud::Controller>([this] { return view_.GetPointer(); }, |
436 | 72 | ON_CALL(*base_window_, SetOpacity(_)) | 72 | [this] { return base_window_.GetPointer(); })) |
437 | 73 | .WillByDefault(Invoke(base_window_.GetPointer(), | 73 | {} |
425 | 74 | &testmocks::MockBaseWindow::RealSetOpacity)); | ||
426 | 75 | |||
427 | 76 | // Set expectations for creating the controller | ||
428 | 77 | EXPECT_CALL(*base_window_, SetOpacity(0.0f)); | ||
429 | 78 | |||
430 | 79 | controller_.reset(new hud::Controller([&](){ return view_.GetPointer(); }, | ||
431 | 80 | [&](){ return base_window_.GetPointer();})); | ||
432 | 81 | } | ||
438 | 82 | 74 | ||
439 | 83 | protected: | 75 | protected: |
440 | 84 | hud::Controller::Ptr controller_; | ||
441 | 85 | MockHudView::Ptr view_; | ||
442 | 86 | testmocks::MockBaseWindow::Ptr base_window_; | ||
443 | 87 | |||
444 | 88 | // required to create hidden secret global variables | 76 | // required to create hidden secret global variables |
445 | 89 | Settings unity_settings_; | 77 | Settings unity_settings_; |
446 | 90 | dash::Style dash_style_; | 78 | dash::Style dash_style_; |
447 | 91 | panel::Style panel_style_; | 79 | panel::Style panel_style_; |
448 | 80 | |||
449 | 81 | MockHudView::Ptr view_; | ||
450 | 82 | testmocks::MockBaseWindow::Ptr base_window_; | ||
451 | 83 | hud::Controller::Ptr controller_; | ||
452 | 92 | }; | 84 | }; |
453 | 93 | 85 | ||
454 | 86 | TEST_F(TestHudController, Construction) | ||
455 | 87 | { | ||
456 | 88 | EXPECT_CALL(*base_window_, SetOpacity(0.0f)); | ||
457 | 89 | controller_ = std::make_shared<hud::Controller>([this] { return view_.GetPointer(); }, | ||
458 | 90 | [this] { return base_window_.GetPointer(); }); | ||
459 | 91 | } | ||
460 | 94 | 92 | ||
461 | 95 | TEST_F(TestHudController, TestShowAndHideHud) | 93 | TEST_F(TestHudController, TestShowAndHideHud) |
462 | 96 | { | 94 | { |
463 | @@ -141,4 +139,16 @@ | |||
464 | 141 | EXPECT_EQ(base_window_->GetOpacity(), 0.0); | 139 | EXPECT_EQ(base_window_->GetOpacity(), 0.0); |
465 | 142 | } | 140 | } |
466 | 143 | 141 | ||
467 | 142 | TEST_F(TestHudController, DisconnectWMSignalsOnDestruction) | ||
468 | 143 | { | ||
469 | 144 | auto& signal = WindowManager::Default().initiate_spread; | ||
470 | 145 | size_t before = signal.size(); | ||
471 | 146 | { | ||
472 | 147 | auto controller = std::make_shared<hud::Controller>([this] { return view_.GetPointer(); }, | ||
473 | 148 | [this] { return base_window_.GetPointer(); }); | ||
474 | 149 | } | ||
475 | 150 | ASSERT_EQ(before, signal.size()); | ||
476 | 151 | signal.emit(); | ||
477 | 152 | } | ||
478 | 153 | |||
479 | 144 | } | 154 | } |
480 | 145 | 155 | ||
481 | === modified file 'tests/test_launcher.cpp' | |||
482 | --- tests/test_launcher.cpp 2013-10-04 00:19:56 +0000 | |||
483 | +++ tests/test_launcher.cpp 2013-10-21 23:51:09 +0000 | |||
484 | @@ -31,6 +31,7 @@ | |||
485 | 31 | #include "unity-shared/PanelStyle.h" | 31 | #include "unity-shared/PanelStyle.h" |
486 | 32 | #include "unity-shared/UnitySettings.h" | 32 | #include "unity-shared/UnitySettings.h" |
487 | 33 | #include "unity-shared/IconRenderer.h" | 33 | #include "unity-shared/IconRenderer.h" |
488 | 34 | #include "StandaloneWindowManager.h" | ||
489 | 34 | #include "test_utils.h" | 35 | #include "test_utils.h" |
490 | 35 | 36 | ||
491 | 36 | namespace unity | 37 | namespace unity |
492 | @@ -46,6 +47,7 @@ | |||
493 | 46 | { | 47 | { |
494 | 47 | public: | 48 | public: |
495 | 48 | typedef nux::ObjectPtr<MockMockLauncherIcon> Ptr; | 49 | typedef nux::ObjectPtr<MockMockLauncherIcon> Ptr; |
496 | 50 | typedef testing::NiceMock<MockMockLauncherIcon> Nice; | ||
497 | 49 | MockMockLauncherIcon(IconType type = IconType::APPLICATION) | 51 | MockMockLauncherIcon(IconType type = IconType::APPLICATION) |
498 | 50 | : MockLauncherIcon(type) | 52 | : MockLauncherIcon(type) |
499 | 51 | {} | 53 | {} |
500 | @@ -53,6 +55,7 @@ | |||
501 | 53 | MOCK_METHOD1(ShouldHighlightOnDrag, bool(DndData const&)); | 55 | MOCK_METHOD1(ShouldHighlightOnDrag, bool(DndData const&)); |
502 | 54 | MOCK_METHOD1(Stick, void(bool)); | 56 | MOCK_METHOD1(Stick, void(bool)); |
503 | 55 | MOCK_METHOD2(PerformScroll, void(ScrollDirection, Time)); | 57 | MOCK_METHOD2(PerformScroll, void(ScrollDirection, Time)); |
504 | 58 | MOCK_METHOD0(HideTooltip, void()); | ||
505 | 56 | }; | 59 | }; |
506 | 57 | 60 | ||
507 | 58 | } | 61 | } |
508 | @@ -115,6 +118,7 @@ | |||
509 | 115 | using Launcher::SetHidden; | 118 | using Launcher::SetHidden; |
510 | 116 | using Launcher::HandleUrgentIcon; | 119 | using Launcher::HandleUrgentIcon; |
511 | 117 | using Launcher::SetUrgentTimer; | 120 | using Launcher::SetUrgentTimer; |
512 | 121 | using Launcher::SetIconUnderMouse; | ||
513 | 118 | using Launcher::urgent_timer_running_; | 122 | using Launcher::urgent_timer_running_; |
514 | 119 | using Launcher::urgent_finished_time_; | 123 | using Launcher::urgent_finished_time_; |
515 | 120 | using Launcher::urgent_wiggle_time_; | 124 | using Launcher::urgent_wiggle_time_; |
516 | @@ -140,7 +144,8 @@ | |||
517 | 140 | }; | 144 | }; |
518 | 141 | 145 | ||
519 | 142 | TestLauncher() | 146 | TestLauncher() |
521 | 143 | : parent_window_(new MockableBaseWindow("TestLauncherWindow")) | 147 | : WM(dynamic_cast<StandaloneWindowManager*>(&WindowManager::Default())) |
522 | 148 | , parent_window_(new MockableBaseWindow("TestLauncherWindow")) | ||
523 | 144 | , model_(new LauncherModel) | 149 | , model_(new LauncherModel) |
524 | 145 | , options_(new Options) | 150 | , options_(new Options) |
525 | 146 | , launcher_(new MockLauncher(parent_window_.GetPointer())) | 151 | , launcher_(new MockLauncher(parent_window_.GetPointer())) |
526 | @@ -149,6 +154,15 @@ | |||
527 | 149 | launcher_->SetModel(model_); | 154 | launcher_->SetModel(model_); |
528 | 150 | } | 155 | } |
529 | 151 | 156 | ||
530 | 157 | ~TestLauncher() | ||
531 | 158 | { | ||
532 | 159 | WM->SetScaleActiveForGroup(false); | ||
533 | 160 | WM->SetScaleActive(false); | ||
534 | 161 | |||
535 | 162 | if (WM->IsExpoActive()) | ||
536 | 163 | WM->TerminateExpo(); | ||
537 | 164 | } | ||
538 | 165 | |||
539 | 152 | std::vector<MockMockLauncherIcon::Ptr> AddMockIcons(unsigned number) | 166 | std::vector<MockMockLauncherIcon::Ptr> AddMockIcons(unsigned number) |
540 | 153 | { | 167 | { |
541 | 154 | std::vector<MockMockLauncherIcon::Ptr> icons; | 168 | std::vector<MockMockLauncherIcon::Ptr> icons; |
542 | @@ -159,7 +173,7 @@ | |||
543 | 159 | 173 | ||
544 | 160 | for (unsigned i = 0; i < number; ++i) | 174 | for (unsigned i = 0; i < number; ++i) |
545 | 161 | { | 175 | { |
547 | 162 | MockMockLauncherIcon::Ptr icon(new MockMockLauncherIcon); | 176 | MockMockLauncherIcon::Ptr icon(new MockMockLauncherIcon::Nice); |
548 | 163 | icon->SetCenter(nux::Point3(launcher_geo.x + icon_size/2.0f, launcher_geo.y + icon_size/2.0f * (i+1) + 1, 0), monitor); | 177 | icon->SetCenter(nux::Point3(launcher_geo.x + icon_size/2.0f, launcher_geo.y + icon_size/2.0f * (i+1) + 1, 0), monitor); |
549 | 164 | 178 | ||
550 | 165 | icons.push_back(icon); | 179 | icons.push_back(icon); |
551 | @@ -173,6 +187,7 @@ | |||
552 | 173 | } | 187 | } |
553 | 174 | 188 | ||
554 | 175 | MockUScreen uscreen; | 189 | MockUScreen uscreen; |
555 | 190 | StandaloneWindowManager* WM; | ||
556 | 176 | nux::ObjectPtr<MockableBaseWindow> parent_window_; | 191 | nux::ObjectPtr<MockableBaseWindow> parent_window_; |
557 | 177 | Settings settings; | 192 | Settings settings; |
558 | 178 | panel::Style panel_style; | 193 | panel::Style panel_style; |
559 | @@ -688,9 +703,180 @@ | |||
560 | 688 | launcher_->HandleUrgentIcon(icon, current); | 703 | launcher_->HandleUrgentIcon(icon, current); |
561 | 689 | 704 | ||
562 | 690 | EXPECT_THAT(launcher_->urgent_finished_time_.tv_sec, Gt(0)); | 705 | EXPECT_THAT(launcher_->urgent_finished_time_.tv_sec, Gt(0)); |
569 | 691 | EXPECT_THAT(launcher_->urgent_finished_time_.tv_nsec, Gt(0)); | 706 | EXPECT_THAT(launcher_->urgent_finished_time_.tv_nsec, Gt(0)); |
570 | 692 | } | 707 | } |
571 | 693 | 708 | ||
572 | 694 | } | 709 | TEST_F(TestLauncher, DesaturateAllIconsOnSpread) |
573 | 695 | } | 710 | { |
574 | 696 | 711 | auto const& icons = AddMockIcons(5); | |
575 | 712 | icons[g_random_int()%icons.size()]->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, true); | ||
576 | 713 | |||
577 | 714 | WM->SetScaleActiveForGroup(false); | ||
578 | 715 | WM->SetScaleActive(true); | ||
579 | 716 | WM->initiate_spread.emit(); | ||
580 | 717 | |||
581 | 718 | Utils::WaitUntilMSec([&icons] { | ||
582 | 719 | for (auto const& icon : icons) | ||
583 | 720 | { | ||
584 | 721 | if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT)) | ||
585 | 722 | return false; | ||
586 | 723 | } | ||
587 | 724 | return true; | ||
588 | 725 | }); | ||
589 | 726 | |||
590 | 727 | for (auto const& icon : icons) | ||
591 | 728 | ASSERT_TRUE(icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT)); | ||
592 | 729 | } | ||
593 | 730 | |||
594 | 731 | TEST_F(TestLauncher, SaturateAllIconsOnSpreadTerminated) | ||
595 | 732 | { | ||
596 | 733 | auto const& icons = AddMockIcons(5); | ||
597 | 734 | icons[g_random_int()%icons.size()]->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, true); | ||
598 | 735 | |||
599 | 736 | for (auto const& icon : icons) | ||
600 | 737 | icon->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, true); | ||
601 | 738 | |||
602 | 739 | WM->SetScaleActiveForGroup(false); | ||
603 | 740 | WM->SetScaleActive(false); | ||
604 | 741 | WM->terminate_spread.emit(); | ||
605 | 742 | |||
606 | 743 | for (auto const& icon : icons) | ||
607 | 744 | ASSERT_FALSE(icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT)); | ||
608 | 745 | } | ||
609 | 746 | |||
610 | 747 | TEST_F(TestLauncher, SaturatesAllIconsOnSpreadWithMouseOver) | ||
611 | 748 | { | ||
612 | 749 | auto const& icons = AddMockIcons(5); | ||
613 | 750 | icons[g_random_int()%icons.size()]->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, true); | ||
614 | 751 | |||
615 | 752 | for (auto const& icon : icons) | ||
616 | 753 | icon->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, true); | ||
617 | 754 | |||
618 | 755 | launcher_->SetHover(true); | ||
619 | 756 | WM->SetScaleActiveForGroup(false); | ||
620 | 757 | WM->SetScaleActive(true); | ||
621 | 758 | WM->initiate_spread.emit(); | ||
622 | 759 | |||
623 | 760 | Utils::WaitPendingEvents(); | ||
624 | 761 | |||
625 | 762 | for (auto const& icon : icons) | ||
626 | 763 | ASSERT_FALSE(icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT)); | ||
627 | 764 | } | ||
628 | 765 | |||
629 | 766 | TEST_F(TestLauncher, DesaturateInactiveIconsOnAppSpread) | ||
630 | 767 | { | ||
631 | 768 | auto const& icons = AddMockIcons(5); | ||
632 | 769 | icons[g_random_int()%icons.size()]->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, true); | ||
633 | 770 | |||
634 | 771 | WM->SetScaleActiveForGroup(true); | ||
635 | 772 | WM->SetScaleActive(true); | ||
636 | 773 | WM->initiate_spread.emit(); | ||
637 | 774 | |||
638 | 775 | Utils::WaitUntilMSec([&icons] { | ||
639 | 776 | for (auto const& icon : icons) | ||
640 | 777 | { | ||
641 | 778 | if (icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE) == icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT)) | ||
642 | 779 | return false; | ||
643 | 780 | } | ||
644 | 781 | return true; | ||
645 | 782 | }); | ||
646 | 783 | |||
647 | 784 | for (auto const& icon : icons) | ||
648 | 785 | ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT)); | ||
649 | 786 | } | ||
650 | 787 | |||
651 | 788 | TEST_F(TestLauncher, SaturatesAllIconsOnAppSpreadMouseMove) | ||
652 | 789 | { | ||
653 | 790 | auto const& icons = AddMockIcons(5); | ||
654 | 791 | unsigned active_idx = g_random_int()%icons.size(); | ||
655 | 792 | icons[active_idx]->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, true); | ||
656 | 793 | |||
657 | 794 | launcher_->SetHover(true); | ||
658 | 795 | WM->SetScaleActiveForGroup(true); | ||
659 | 796 | WM->SetScaleActive(true); | ||
660 | 797 | WM->initiate_spread.emit(); | ||
661 | 798 | |||
662 | 799 | Utils::WaitUntilMSec([&icons] { | ||
663 | 800 | for (auto const& icon : icons) | ||
664 | 801 | { | ||
665 | 802 | if (icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE) == icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT)) | ||
666 | 803 | return false; | ||
667 | 804 | } | ||
668 | 805 | return true; | ||
669 | 806 | }); | ||
670 | 807 | |||
671 | 808 | for (auto const& icon : icons) | ||
672 | 809 | ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT)); | ||
673 | 810 | |||
674 | 811 | auto const& active_center = icons[active_idx]->GetCenter(launcher_->monitor()); | ||
675 | 812 | launcher_->mouse_move.emit(active_center.x, active_center.y, 0, 0, 0, 0); | ||
676 | 813 | |||
677 | 814 | for (auto const& icon : icons) | ||
678 | 815 | ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT)); | ||
679 | 816 | |||
680 | 817 | auto const& other_center = icons[(active_idx+1)%icons.size()]->GetCenter(launcher_->monitor()); | ||
681 | 818 | launcher_->mouse_move.emit(other_center.x, other_center.y, 0, 0, 0, 0); | ||
682 | 819 | |||
683 | 820 | for (auto const& icon : icons) | ||
684 | 821 | ASSERT_FALSE(icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT)); | ||
685 | 822 | |||
686 | 823 | launcher_->SetHover(false); | ||
687 | 824 | for (auto const& icon : icons) | ||
688 | 825 | ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT)); | ||
689 | 826 | |||
690 | 827 | launcher_->SetHover(true); | ||
691 | 828 | for (auto const& icon : icons) | ||
692 | 829 | ASSERT_FALSE(icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT)); | ||
693 | 830 | } | ||
694 | 831 | |||
695 | 832 | TEST_F(TestLauncher, DesaturateActiveIconOnAppSpreadIconUpdate) | ||
696 | 833 | { | ||
697 | 834 | auto const& icons = AddMockIcons(5); | ||
698 | 835 | unsigned active_idx = g_random_int()%icons.size(); | ||
699 | 836 | icons[active_idx]->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, true); | ||
700 | 837 | |||
701 | 838 | launcher_->SetHover(true); | ||
702 | 839 | WM->SetScaleActiveForGroup(true); | ||
703 | 840 | WM->SetScaleActive(true); | ||
704 | 841 | WM->initiate_spread.emit(); | ||
705 | 842 | |||
706 | 843 | Utils::WaitPendingEvents(); | ||
707 | 844 | for (auto const& icon : icons) | ||
708 | 845 | ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT)); | ||
709 | 846 | |||
710 | 847 | unsigned new_active_idx = (active_idx+1)%icons.size(); | ||
711 | 848 | icons[active_idx]->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, false); | ||
712 | 849 | icons[new_active_idx]->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, true); | ||
713 | 850 | |||
714 | 851 | WM->terminate_spread.emit(); | ||
715 | 852 | WM->initiate_spread.emit(); | ||
716 | 853 | |||
717 | 854 | Utils::WaitPendingEvents(); | ||
718 | 855 | for (auto const& icon : icons) | ||
719 | 856 | ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT)); | ||
720 | 857 | } | ||
721 | 858 | |||
722 | 859 | TEST_F(TestLauncher, HideTooltipOnSpread) | ||
723 | 860 | { | ||
724 | 861 | auto icon = AddMockIcons(1).front(); | ||
725 | 862 | EXPECT_CALL(*icon, HideTooltip()); | ||
726 | 863 | |||
727 | 864 | launcher_->SetIconUnderMouse(icon); | ||
728 | 865 | WM->SetScaleActive(true); | ||
729 | 866 | WM->initiate_spread.emit(); | ||
730 | 867 | } | ||
731 | 868 | |||
732 | 869 | TEST_F(TestLauncher, HideTooltipOnExpo) | ||
733 | 870 | { | ||
734 | 871 | auto icon = AddMockIcons(1).front(); | ||
735 | 872 | EXPECT_CALL(*icon, HideTooltip()); | ||
736 | 873 | |||
737 | 874 | if (!WM->IsExpoActive()) | ||
738 | 875 | WM->InitiateExpo(); | ||
739 | 876 | |||
740 | 877 | launcher_->SetIconUnderMouse(icon); | ||
741 | 878 | WM->initiate_expo.emit(); | ||
742 | 879 | } | ||
743 | 880 | |||
744 | 881 | } // namespace launcher | ||
745 | 882 | } // namespace unity | ||
746 | 697 | 883 | ||
747 | === modified file 'tests/test_switcher_controller_class.cpp' | |||
748 | --- tests/test_switcher_controller_class.cpp 2013-06-26 17:10:45 +0000 | |||
749 | +++ tests/test_switcher_controller_class.cpp 2013-10-21 23:51:09 +0000 | |||
750 | @@ -78,13 +78,8 @@ | |||
751 | 78 | : WM(dynamic_cast<StandaloneWindowManager*>(&WindowManager::Default())) | 78 | : WM(dynamic_cast<StandaloneWindowManager*>(&WindowManager::Default())) |
752 | 79 | , animation_controller_(tick_source_) | 79 | , animation_controller_(tick_source_) |
753 | 80 | , mock_window_(new NiceMock<testmocks::MockBaseWindow>()) | 80 | , mock_window_(new NiceMock<testmocks::MockBaseWindow>()) |
754 | 81 | , controller_(std::make_shared<Controller>([this] { return mock_window_; })) | ||
755 | 81 | { | 82 | { |
756 | 82 | ON_CALL(*mock_window_, SetOpacity(_)) | ||
757 | 83 | .WillByDefault(Invoke(mock_window_.GetPointer(), | ||
758 | 84 | &testmocks::MockBaseWindow::RealSetOpacity)); | ||
759 | 85 | |||
760 | 86 | auto create_window = [this] { return mock_window_; }; | ||
761 | 87 | controller_.reset(new Controller(create_window)); | ||
762 | 88 | controller_->timeout_length = 0; | 83 | controller_->timeout_length = 0; |
763 | 89 | 84 | ||
764 | 90 | icons_.push_back(launcher::AbstractLauncherIcon::Ptr(new launcher::DesktopLauncherIcon())); | 85 | icons_.push_back(launcher::AbstractLauncherIcon::Ptr(new launcher::DesktopLauncherIcon())); |
FAILED: Continuous integration, rev:3577 jenkins. qa.ubuntu. com/job/ unity-ci/ 438/ jenkins. qa.ubuntu. com/job/ unity-saucy- amd64-ci/ 327/console jenkins. qa.ubuntu. com/job/ unity-saucy- armhf-ci/ 325/console jenkins. qa.ubuntu. com/job/ unity-saucy- i386-ci/ 326/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: 10.97.0. 26:8080/ job/unity- ci/438/ rebuild
http://