Merge lp:~3v1n0/unity/app-icon-ensure-on-running-6.0 into lp:unity/6.0
- app-icon-ensure-on-running-6.0
- Merge into 6.0
Proposed by
Marco Trevisan (Treviño)
Status: | Merged |
---|---|
Approved by: | Brandon Schaefer |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2777 |
Proposed branch: | lp:~3v1n0/unity/app-icon-ensure-on-running-6.0 |
Merge into: | lp:unity/6.0 |
Diff against target: |
508 lines (+347/-18) 6 files modified
launcher/BamfLauncherIcon.cpp (+22/-8) tests/CMakeLists.txt (+1/-0) tests/bamf-mock-application.c (+201/-0) tests/bamf-mock-application.h (+77/-0) tests/test_bamf_launcher_icon.cpp (+43/-8) tests/test_launcher_controller.cpp (+3/-2) |
To merge this branch: | bzr merge lp:~3v1n0/unity/app-icon-ensure-on-running-6.0 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Brandon Schaefer (community) | Approve | ||
Review via email: mp+129470@code.launchpad.net |
Commit message
BamfLauncherIcon: ensure the icon and name values when the running state changes
This avoids to get "?" icons
Description of the change
Backported branch lp:~3v1n0/unity/app-icon-ensure-on-running/+merge/129469 to 6.0
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 'launcher/BamfLauncherIcon.cpp' | |||
2 | --- launcher/BamfLauncherIcon.cpp 2012-09-28 22:33:55 +0000 | |||
3 | +++ launcher/BamfLauncherIcon.cpp 2012-10-12 18:26:21 +0000 | |||
4 | @@ -81,7 +81,7 @@ | |||
5 | 81 | glib::SignalBase* sig; | 81 | glib::SignalBase* sig; |
6 | 82 | 82 | ||
7 | 83 | sig = new glib::Signal<void, BamfView*, BamfView*>(bamf_view, "child-added", | 83 | sig = new glib::Signal<void, BamfView*, BamfView*>(bamf_view, "child-added", |
9 | 84 | [&] (BamfView*, BamfView*) { | 84 | [this] (BamfView*, BamfView*) { |
10 | 85 | EnsureWindowState(); | 85 | EnsureWindowState(); |
11 | 86 | UpdateMenus(); | 86 | UpdateMenus(); |
12 | 87 | UpdateIconGeometries(GetCenters()); | 87 | UpdateIconGeometries(GetCenters()); |
13 | @@ -89,7 +89,7 @@ | |||
14 | 89 | _gsignals.Add(sig); | 89 | _gsignals.Add(sig); |
15 | 90 | 90 | ||
16 | 91 | sig = new glib::Signal<void, BamfView*, BamfView*>(bamf_view, "child-removed", | 91 | sig = new glib::Signal<void, BamfView*, BamfView*>(bamf_view, "child-removed", |
18 | 92 | [&] (BamfView*, BamfView*) { EnsureWindowState(); }); | 92 | [this] (BamfView*, BamfView*) { EnsureWindowState(); }); |
19 | 93 | _gsignals.Add(sig); | 93 | _gsignals.Add(sig); |
20 | 94 | 94 | ||
21 | 95 | sig = new glib::Signal<void, BamfView*, BamfView*>(bamf_view, "child-moved", | 95 | sig = new glib::Signal<void, BamfView*, BamfView*>(bamf_view, "child-moved", |
22 | @@ -99,39 +99,53 @@ | |||
23 | 99 | _gsignals.Add(sig); | 99 | _gsignals.Add(sig); |
24 | 100 | 100 | ||
25 | 101 | sig = new glib::Signal<void, BamfView*, gboolean>(bamf_view, "urgent-changed", | 101 | sig = new glib::Signal<void, BamfView*, gboolean>(bamf_view, "urgent-changed", |
27 | 102 | [&] (BamfView*, gboolean urgent) { | 102 | [this] (BamfView*, gboolean urgent) { |
28 | 103 | SetQuirk(Quirk::URGENT, urgent); | 103 | SetQuirk(Quirk::URGENT, urgent); |
29 | 104 | }); | 104 | }); |
30 | 105 | _gsignals.Add(sig); | 105 | _gsignals.Add(sig); |
31 | 106 | 106 | ||
32 | 107 | sig = new glib::Signal<void, BamfView*, gboolean>(bamf_view, "active-changed", | 107 | sig = new glib::Signal<void, BamfView*, gboolean>(bamf_view, "active-changed", |
34 | 108 | [&] (BamfView*, gboolean active) { | 108 | [this] (BamfView*, gboolean active) { |
35 | 109 | SetQuirk(Quirk::ACTIVE, active); | 109 | SetQuirk(Quirk::ACTIVE, active); |
36 | 110 | }); | 110 | }); |
37 | 111 | _gsignals.Add(sig); | 111 | _gsignals.Add(sig); |
38 | 112 | 112 | ||
39 | 113 | sig = new glib::Signal<void, BamfView*, gboolean>(bamf_view, "running-changed", | 113 | sig = new glib::Signal<void, BamfView*, gboolean>(bamf_view, "running-changed", |
41 | 114 | [&] (BamfView*, gboolean running) { | 114 | [this] (BamfView* view, gboolean running) { |
42 | 115 | SetQuirk(Quirk::RUNNING, running); | 115 | SetQuirk(Quirk::RUNNING, running); |
43 | 116 | 116 | ||
44 | 117 | if (running) | 117 | if (running) |
45 | 118 | { | 118 | { |
46 | 119 | _source_manager.Remove(ICON_REMOVE_TIMEOUT); | ||
47 | 120 | |||
48 | 121 | /* It can happen that these values are not set | ||
49 | 122 | * during initialization if the view is closed | ||
50 | 123 | * very early, so we need to make sure that they | ||
51 | 124 | * are updated as soon as the view is re-opened. */ | ||
52 | 125 | if (tooltip_text().empty()) | ||
53 | 126 | tooltip_text = BamfName(); | ||
54 | 127 | |||
55 | 128 | if (icon_name == DEFAULT_ICON) | ||
56 | 129 | { | ||
57 | 130 | glib::String icon(bamf_view_get_icon(view)); | ||
58 | 131 | icon_name = (icon ? icon.Str() : DEFAULT_ICON); | ||
59 | 132 | } | ||
60 | 133 | |||
61 | 119 | EnsureWindowState(); | 134 | EnsureWindowState(); |
62 | 120 | UpdateIconGeometries(GetCenters()); | 135 | UpdateIconGeometries(GetCenters()); |
63 | 121 | _source_manager.Remove(ICON_REMOVE_TIMEOUT); | ||
64 | 122 | } | 136 | } |
65 | 123 | }); | 137 | }); |
66 | 124 | _gsignals.Add(sig); | 138 | _gsignals.Add(sig); |
67 | 125 | 139 | ||
68 | 126 | sig = new glib::Signal<void, BamfView*, gboolean>(bamf_view, "user-visible-changed", | 140 | sig = new glib::Signal<void, BamfView*, gboolean>(bamf_view, "user-visible-changed", |
70 | 127 | [&] (BamfView*, gboolean visible) { | 141 | [this] (BamfView*, gboolean visible) { |
71 | 128 | if (!IsSticky()) | 142 | if (!IsSticky()) |
72 | 129 | SetQuirk(Quirk::VISIBLE, visible); | 143 | SetQuirk(Quirk::VISIBLE, visible); |
73 | 130 | }); | 144 | }); |
74 | 131 | _gsignals.Add(sig); | 145 | _gsignals.Add(sig); |
75 | 132 | 146 | ||
76 | 133 | sig = new glib::Signal<void, BamfView*>(bamf_view, "closed", | 147 | sig = new glib::Signal<void, BamfView*>(bamf_view, "closed", |
78 | 134 | [&] (BamfView*) { | 148 | [this] (BamfView*) { |
79 | 135 | if (!IsSticky()) | 149 | if (!IsSticky()) |
80 | 136 | { | 150 | { |
81 | 137 | SetQuirk(Quirk::VISIBLE, false); | 151 | SetQuirk(Quirk::VISIBLE, false); |
82 | 138 | 152 | ||
83 | === modified file 'tests/CMakeLists.txt' | |||
84 | --- tests/CMakeLists.txt 2012-10-09 10:48:30 +0000 | |||
85 | +++ tests/CMakeLists.txt 2012-10-12 18:26:21 +0000 | |||
86 | @@ -244,6 +244,7 @@ | |||
87 | 244 | test_unity_settings.cpp | 244 | test_unity_settings.cpp |
88 | 245 | test_volume_imp.cpp | 245 | test_volume_imp.cpp |
89 | 246 | test_volume_launcher_icon.cpp | 246 | test_volume_launcher_icon.cpp |
90 | 247 | bamf-mock-application.c | ||
91 | 247 | gmockmount.c | 248 | gmockmount.c |
92 | 248 | gmockvolume.c | 249 | gmockvolume.c |
93 | 249 | ${CMAKE_SOURCE_DIR}/dash/AbstractPlacesGroup.cpp | 250 | ${CMAKE_SOURCE_DIR}/dash/AbstractPlacesGroup.cpp |
94 | 250 | 251 | ||
95 | === added file 'tests/bamf-mock-application.c' | |||
96 | --- tests/bamf-mock-application.c 1970-01-01 00:00:00 +0000 | |||
97 | +++ tests/bamf-mock-application.c 2012-10-12 18:26:21 +0000 | |||
98 | @@ -0,0 +1,201 @@ | |||
99 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
100 | 2 | /* | ||
101 | 3 | * Copyright 2012 Canonical Ltd. | ||
102 | 4 | * | ||
103 | 5 | * This program is free software: you can redistribute it and/or modify it | ||
104 | 6 | * under the terms of the GNU Lesser General Public License version 3, as | ||
105 | 7 | * published by the Free Software Foundation. | ||
106 | 8 | * | ||
107 | 9 | * This program is distributed in the hope that it will be useful, but | ||
108 | 10 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
109 | 11 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
110 | 12 | * PURPOSE. See the applicable version of the GNU Lesser General Public | ||
111 | 13 | * License for more details. | ||
112 | 14 | * | ||
113 | 15 | * You should have received a copy of both the GNU Lesser General Public | ||
114 | 16 | * License version 3 along with this program. If not, see | ||
115 | 17 | * <http://www.gnu.org/licenses/> | ||
116 | 18 | * | ||
117 | 19 | * Authored by: Marco Trevisan <marco.trevisan@canonical.com> | ||
118 | 20 | * | ||
119 | 21 | */ | ||
120 | 22 | |||
121 | 23 | #include "bamf-mock-application.h" | ||
122 | 24 | |||
123 | 25 | G_DEFINE_TYPE (BamfMockApplication, bamf_mock_application, BAMF_TYPE_APPLICATION); | ||
124 | 26 | |||
125 | 27 | #define BAMF_MOCK_APPLICATION_GET_PRIVATE(o) \ | ||
126 | 28 | (G_TYPE_INSTANCE_GET_PRIVATE ((o), BAMF_TYPE_MOCK_APPLICATION, BamfMockApplicationPrivate)) | ||
127 | 29 | |||
128 | 30 | struct _BamfMockApplicationPrivate | ||
129 | 31 | { | ||
130 | 32 | gboolean active; | ||
131 | 33 | gboolean running; | ||
132 | 34 | gboolean urgent; | ||
133 | 35 | gchar * name; | ||
134 | 36 | gchar * icon; | ||
135 | 37 | GList * children; | ||
136 | 38 | }; | ||
137 | 39 | |||
138 | 40 | void | ||
139 | 41 | bamf_mock_application_set_active (BamfMockApplication * self, gboolean active) | ||
140 | 42 | { | ||
141 | 43 | g_return_if_fail (BAMF_IS_MOCK_APPLICATION (self)); | ||
142 | 44 | |||
143 | 45 | if (self->priv->active != active) | ||
144 | 46 | { | ||
145 | 47 | self->priv->active = active; | ||
146 | 48 | g_signal_emit_by_name (G_OBJECT (self), "active-changed", active, NULL); | ||
147 | 49 | } | ||
148 | 50 | } | ||
149 | 51 | |||
150 | 52 | void | ||
151 | 53 | bamf_mock_application_set_running (BamfMockApplication * self, gboolean running) | ||
152 | 54 | { | ||
153 | 55 | g_return_if_fail (BAMF_IS_MOCK_APPLICATION (self)); | ||
154 | 56 | |||
155 | 57 | if (self->priv->running != running) | ||
156 | 58 | { | ||
157 | 59 | self->priv->running = running; | ||
158 | 60 | g_signal_emit_by_name (G_OBJECT (self), "running-changed", running, NULL); | ||
159 | 61 | } | ||
160 | 62 | } | ||
161 | 63 | |||
162 | 64 | void | ||
163 | 65 | bamf_mock_application_set_urgent (BamfMockApplication * self, gboolean urgent) | ||
164 | 66 | { | ||
165 | 67 | g_return_if_fail (BAMF_IS_MOCK_APPLICATION (self)); | ||
166 | 68 | |||
167 | 69 | if (self->priv->urgent != urgent) | ||
168 | 70 | { | ||
169 | 71 | self->priv->urgent = urgent; | ||
170 | 72 | g_signal_emit_by_name (G_OBJECT (self), "urgent-changed", urgent, NULL); | ||
171 | 73 | } | ||
172 | 74 | } | ||
173 | 75 | |||
174 | 76 | void | ||
175 | 77 | bamf_mock_application_set_name (BamfMockApplication * self, const gchar * name) | ||
176 | 78 | { | ||
177 | 79 | g_return_if_fail (BAMF_IS_MOCK_APPLICATION (self)); | ||
178 | 80 | |||
179 | 81 | if (g_strcmp0 (self->priv->name, name) != 0) | ||
180 | 82 | { | ||
181 | 83 | char *old = self->priv->name; | ||
182 | 84 | self->priv->name = g_strdup (name); | ||
183 | 85 | g_signal_emit_by_name (G_OBJECT (self), "name-changed", old, self->priv->name, NULL); | ||
184 | 86 | g_free (old); | ||
185 | 87 | } | ||
186 | 88 | } | ||
187 | 89 | |||
188 | 90 | void | ||
189 | 91 | bamf_mock_application_set_icon (BamfMockApplication * self, const gchar * icon) | ||
190 | 92 | { | ||
191 | 93 | g_return_if_fail (BAMF_IS_MOCK_APPLICATION (self)); | ||
192 | 94 | |||
193 | 95 | g_free (self->priv->icon); | ||
194 | 96 | self->priv->icon = g_strdup (icon); | ||
195 | 97 | } | ||
196 | 98 | |||
197 | 99 | void | ||
198 | 100 | bamf_mock_application_set_children (BamfMockApplication * self, GList * children) | ||
199 | 101 | { | ||
200 | 102 | g_return_if_fail (BAMF_IS_MOCK_APPLICATION (self)); | ||
201 | 103 | |||
202 | 104 | g_list_free (self->priv->children); | ||
203 | 105 | self->priv->children = g_list_copy (children); | ||
204 | 106 | } | ||
205 | 107 | |||
206 | 108 | static void | ||
207 | 109 | bamf_mock_application_finalize (GObject *object) | ||
208 | 110 | { | ||
209 | 111 | BamfMockApplication *self = BAMF_MOCK_APPLICATION (object); | ||
210 | 112 | |||
211 | 113 | g_free (self->priv->name); | ||
212 | 114 | g_free (self->priv->icon); | ||
213 | 115 | g_list_free (self->priv->children); | ||
214 | 116 | } | ||
215 | 117 | |||
216 | 118 | static GList * | ||
217 | 119 | bamf_mock_application_get_children (BamfView *view) | ||
218 | 120 | { | ||
219 | 121 | g_return_val_if_fail (BAMF_IS_MOCK_APPLICATION (view), NULL); | ||
220 | 122 | BamfMockApplication *self = BAMF_MOCK_APPLICATION (view); | ||
221 | 123 | return g_list_copy (self->priv->children); | ||
222 | 124 | } | ||
223 | 125 | |||
224 | 126 | static gboolean | ||
225 | 127 | bamf_mock_application_is_active (BamfView *view) | ||
226 | 128 | { | ||
227 | 129 | g_return_val_if_fail (BAMF_IS_MOCK_APPLICATION (view), FALSE); | ||
228 | 130 | BamfMockApplication *self = BAMF_MOCK_APPLICATION (view); | ||
229 | 131 | return self->priv->active; | ||
230 | 132 | } | ||
231 | 133 | |||
232 | 134 | static gboolean | ||
233 | 135 | bamf_mock_application_is_running (BamfView *view) | ||
234 | 136 | { | ||
235 | 137 | g_return_val_if_fail (BAMF_IS_MOCK_APPLICATION (view), FALSE); | ||
236 | 138 | BamfMockApplication *self = BAMF_MOCK_APPLICATION (view); | ||
237 | 139 | return self->priv->running; | ||
238 | 140 | } | ||
239 | 141 | |||
240 | 142 | static gboolean | ||
241 | 143 | bamf_mock_application_is_urgent (BamfView *view) | ||
242 | 144 | { | ||
243 | 145 | g_return_val_if_fail (BAMF_IS_MOCK_APPLICATION (view), FALSE); | ||
244 | 146 | BamfMockApplication *self = BAMF_MOCK_APPLICATION (view); | ||
245 | 147 | return self->priv->urgent; | ||
246 | 148 | } | ||
247 | 149 | |||
248 | 150 | static char * | ||
249 | 151 | bamf_mock_application_get_name (BamfView *view) | ||
250 | 152 | { | ||
251 | 153 | g_return_val_if_fail (BAMF_IS_MOCK_APPLICATION (view), NULL); | ||
252 | 154 | BamfMockApplication *self = BAMF_MOCK_APPLICATION (view); | ||
253 | 155 | return g_strdup (self->priv->name); | ||
254 | 156 | } | ||
255 | 157 | |||
256 | 158 | static char * | ||
257 | 159 | bamf_mock_application_get_icon (BamfView *view) | ||
258 | 160 | { | ||
259 | 161 | g_return_val_if_fail (BAMF_IS_MOCK_APPLICATION (view), NULL); | ||
260 | 162 | BamfMockApplication *self = BAMF_MOCK_APPLICATION (view); | ||
261 | 163 | return g_strdup (self->priv->icon); | ||
262 | 164 | } | ||
263 | 165 | |||
264 | 166 | static const char * | ||
265 | 167 | bamf_mock_application_view_type (BamfView *view) | ||
266 | 168 | { | ||
267 | 169 | g_return_val_if_fail (BAMF_IS_MOCK_APPLICATION (view), NULL); | ||
268 | 170 | return "mock-application"; | ||
269 | 171 | } | ||
270 | 172 | |||
271 | 173 | static void | ||
272 | 174 | bamf_mock_application_class_init (BamfMockApplicationClass *klass) | ||
273 | 175 | { | ||
274 | 176 | GObjectClass *obj_class = G_OBJECT_CLASS (klass); | ||
275 | 177 | BamfViewClass *view_class = BAMF_VIEW_CLASS (klass); | ||
276 | 178 | |||
277 | 179 | obj_class->finalize = bamf_mock_application_finalize; | ||
278 | 180 | view_class->get_children = bamf_mock_application_get_children; | ||
279 | 181 | view_class->is_active = bamf_mock_application_is_active; | ||
280 | 182 | view_class->is_running = bamf_mock_application_is_running; | ||
281 | 183 | view_class->is_urgent = bamf_mock_application_is_urgent; | ||
282 | 184 | view_class->get_name = bamf_mock_application_get_name; | ||
283 | 185 | view_class->get_icon = bamf_mock_application_get_icon; | ||
284 | 186 | view_class->view_type = bamf_mock_application_view_type; | ||
285 | 187 | |||
286 | 188 | g_type_class_add_private (obj_class, sizeof (BamfMockApplicationPrivate)); | ||
287 | 189 | } | ||
288 | 190 | |||
289 | 191 | static void | ||
290 | 192 | bamf_mock_application_init (BamfMockApplication *self) | ||
291 | 193 | { | ||
292 | 194 | self->priv = BAMF_MOCK_APPLICATION_GET_PRIVATE (self); | ||
293 | 195 | } | ||
294 | 196 | |||
295 | 197 | BamfMockApplication * | ||
296 | 198 | bamf_mock_application_new () | ||
297 | 199 | { | ||
298 | 200 | return g_object_new (BAMF_TYPE_MOCK_APPLICATION, NULL); | ||
299 | 201 | } | ||
300 | 0 | \ No newline at end of file | 202 | \ No newline at end of file |
301 | 1 | 203 | ||
302 | === added file 'tests/bamf-mock-application.h' | |||
303 | --- tests/bamf-mock-application.h 1970-01-01 00:00:00 +0000 | |||
304 | +++ tests/bamf-mock-application.h 2012-10-12 18:26:21 +0000 | |||
305 | @@ -0,0 +1,77 @@ | |||
306 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
307 | 2 | /* | ||
308 | 3 | * Copyright 2012 Canonical Ltd. | ||
309 | 4 | * | ||
310 | 5 | * This program is free software: you can redistribute it and/or modify it | ||
311 | 6 | * under the terms of the GNU Lesser General Public License version 3, as | ||
312 | 7 | * published by the Free Software Foundation. | ||
313 | 8 | * | ||
314 | 9 | * This program is distributed in the hope that it will be useful, but | ||
315 | 10 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
316 | 11 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
317 | 12 | * PURPOSE. See the applicable version of the GNU Lesser General Public | ||
318 | 13 | * License for more details. | ||
319 | 14 | * | ||
320 | 15 | * You should have received a copy of both the GNU Lesser General Public | ||
321 | 16 | * License version 3 along with this program. If not, see | ||
322 | 17 | * <http://www.gnu.org/licenses/> | ||
323 | 18 | * | ||
324 | 19 | * Authored by: Marco Trevisan <marco.trevisan@canonical.com> | ||
325 | 20 | * | ||
326 | 21 | */ | ||
327 | 22 | |||
328 | 23 | #ifndef MOCK_BAMF_MOCK_APPLICATION | ||
329 | 24 | #define MOCK_BAMF_MOCK_APPLICATION | ||
330 | 25 | |||
331 | 26 | #include <libbamf/libbamf.h> | ||
332 | 27 | |||
333 | 28 | G_BEGIN_DECLS | ||
334 | 29 | |||
335 | 30 | #define BAMF_TYPE_MOCK_APPLICATION (bamf_mock_application_get_type ()) | ||
336 | 31 | |||
337 | 32 | #define BAMF_MOCK_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\ | ||
338 | 33 | BAMF_TYPE_MOCK_APPLICATION, BamfMockApplication)) | ||
339 | 34 | |||
340 | 35 | #define BAMF_MOCK_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),\ | ||
341 | 36 | BAMF_TYPE_MOCK_APPLICATION, BamfMockApplicationClass)) | ||
342 | 37 | |||
343 | 38 | #define BAMF_IS_MOCK_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\ | ||
344 | 39 | BAMF_TYPE_MOCK_APPLICATION)) | ||
345 | 40 | |||
346 | 41 | #define BAMF_IS_MOCK_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\ | ||
347 | 42 | BAMF_TYPE_MOCK_APPLICATION)) | ||
348 | 43 | |||
349 | 44 | #define BAMF_MOCK_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\ | ||
350 | 45 | BAMF_TYPE_MOCK_APPLICATION, BamfMockApplicationClass)) | ||
351 | 46 | |||
352 | 47 | typedef struct _BamfMockApplication BamfMockApplication; | ||
353 | 48 | typedef struct _BamfMockApplicationClass BamfMockApplicationClass; | ||
354 | 49 | typedef struct _BamfMockApplicationPrivate BamfMockApplicationPrivate; | ||
355 | 50 | |||
356 | 51 | struct _BamfMockApplication | ||
357 | 52 | { | ||
358 | 53 | BamfApplication parent; | ||
359 | 54 | |||
360 | 55 | BamfMockApplicationPrivate *priv; | ||
361 | 56 | }; | ||
362 | 57 | |||
363 | 58 | struct _BamfMockApplicationClass | ||
364 | 59 | { | ||
365 | 60 | BamfApplicationClass parent_class; | ||
366 | 61 | }; | ||
367 | 62 | |||
368 | 63 | GType bamf_mock_application_get_type (void) G_GNUC_CONST; | ||
369 | 64 | |||
370 | 65 | BamfMockApplication * bamf_mock_application_new (); | ||
371 | 66 | |||
372 | 67 | void bamf_mock_application_set_active (BamfMockApplication * self, gboolean active); | ||
373 | 68 | void bamf_mock_application_set_running (BamfMockApplication * self, gboolean running); | ||
374 | 69 | void bamf_mock_application_set_urgent (BamfMockApplication * self, gboolean urgent); | ||
375 | 70 | void bamf_mock_application_set_name (BamfMockApplication * self, const gchar * name); | ||
376 | 71 | void bamf_mock_application_set_icon (BamfMockApplication * self, const gchar * icon); | ||
377 | 72 | void bamf_mock_application_set_children (BamfMockApplication * self, GList * children); | ||
378 | 73 | |||
379 | 74 | G_END_DECLS | ||
380 | 75 | |||
381 | 76 | #endif | ||
382 | 77 | |||
383 | 0 | 78 | ||
384 | === modified file 'tests/test_bamf_launcher_icon.cpp' | |||
385 | --- tests/test_bamf_launcher_icon.cpp 2012-09-18 15:47:49 +0000 | |||
386 | +++ tests/test_bamf_launcher_icon.cpp 2012-10-12 18:26:21 +0000 | |||
387 | @@ -27,6 +27,7 @@ | |||
388 | 27 | 27 | ||
389 | 28 | #include "BamfLauncherIcon.h" | 28 | #include "BamfLauncherIcon.h" |
390 | 29 | #include "FavoriteStore.h" | 29 | #include "FavoriteStore.h" |
391 | 30 | #include "bamf-mock-application.h" | ||
392 | 30 | 31 | ||
393 | 31 | using namespace unity; | 32 | using namespace unity; |
394 | 32 | using namespace unity::launcher; | 33 | using namespace unity::launcher; |
395 | @@ -34,6 +35,7 @@ | |||
396 | 34 | namespace | 35 | namespace |
397 | 35 | { | 36 | { |
398 | 36 | 37 | ||
399 | 38 | const std::string DEFAULT_EMPTY_ICON = "application-default-icon"; | ||
400 | 37 | const std::string USC_DESKTOP = BUILDDIR"/tests/data/applications/ubuntu-software-center.desktop"; | 39 | const std::string USC_DESKTOP = BUILDDIR"/tests/data/applications/ubuntu-software-center.desktop"; |
401 | 38 | const std::string NO_ICON_DESKTOP = BUILDDIR"/tests/data/applications/no-icon.desktop"; | 40 | const std::string NO_ICON_DESKTOP = BUILDDIR"/tests/data/applications/no-icon.desktop"; |
402 | 39 | 41 | ||
403 | @@ -53,15 +55,16 @@ | |||
404 | 53 | empty_icon = new launcher::BamfLauncherIcon(bamf_app); | 55 | empty_icon = new launcher::BamfLauncherIcon(bamf_app); |
405 | 54 | ASSERT_EQ(empty_icon->DesktopFile(), NO_ICON_DESKTOP); | 56 | ASSERT_EQ(empty_icon->DesktopFile(), NO_ICON_DESKTOP); |
406 | 55 | 57 | ||
410 | 56 | bamf_app = static_cast<BamfApplication*>(g_object_new(BAMF_TYPE_APPLICATION, nullptr)); | 58 | mock_app = bamf_mock_application_new(); |
411 | 57 | empty_app = new launcher::BamfLauncherIcon(bamf_app); | 59 | mock_icon = new launcher::BamfLauncherIcon(glib::object_cast<BamfApplication>(mock_app)); |
412 | 58 | ASSERT_TRUE(empty_app->DesktopFile().empty()); | 60 | ASSERT_TRUE(mock_icon->DesktopFile().empty()); |
413 | 59 | } | 61 | } |
414 | 60 | 62 | ||
415 | 61 | glib::Object<BamfMatcher> bamf_matcher; | 63 | glib::Object<BamfMatcher> bamf_matcher; |
416 | 64 | glib::Object<BamfMockApplication> mock_app; | ||
417 | 62 | nux::ObjectPtr<launcher::BamfLauncherIcon> usc_icon; | 65 | nux::ObjectPtr<launcher::BamfLauncherIcon> usc_icon; |
418 | 63 | nux::ObjectPtr<launcher::BamfLauncherIcon> empty_icon; | 66 | nux::ObjectPtr<launcher::BamfLauncherIcon> empty_icon; |
420 | 64 | nux::ObjectPtr<launcher::BamfLauncherIcon> empty_app; | 67 | nux::ObjectPtr<launcher::BamfLauncherIcon> mock_icon; |
421 | 65 | }; | 68 | }; |
422 | 66 | 69 | ||
423 | 67 | TEST_F(TestBamfLauncherIcon, Position) | 70 | TEST_F(TestBamfLauncherIcon, Position) |
424 | @@ -81,9 +84,9 @@ | |||
425 | 81 | 84 | ||
426 | 82 | TEST_F(TestBamfLauncherIcon, TestDefaultIcon) | 85 | TEST_F(TestBamfLauncherIcon, TestDefaultIcon) |
427 | 83 | { | 86 | { |
431 | 84 | EXPECT_EQ(usc_icon->icon_name.Get(), "softwarecenter"); | 87 | EXPECT_EQ(usc_icon->icon_name(), "softwarecenter"); |
432 | 85 | EXPECT_EQ(empty_icon->icon_name.Get(), "application-default-icon"); | 88 | EXPECT_EQ(empty_icon->icon_name(), DEFAULT_EMPTY_ICON); |
433 | 86 | EXPECT_EQ(empty_app->icon_name.Get(), "application-default-icon"); | 89 | EXPECT_EQ(mock_icon->icon_name(), DEFAULT_EMPTY_ICON); |
434 | 87 | } | 90 | } |
435 | 88 | 91 | ||
436 | 89 | TEST_F(TestBamfLauncherIcon, Stick) | 92 | TEST_F(TestBamfLauncherIcon, Stick) |
437 | @@ -143,7 +146,39 @@ | |||
438 | 143 | TEST_F(TestBamfLauncherIcon, RemoteUri) | 146 | TEST_F(TestBamfLauncherIcon, RemoteUri) |
439 | 144 | { | 147 | { |
440 | 145 | EXPECT_EQ(usc_icon->RemoteUri(), FavoriteStore::URI_PREFIX_APP + DesktopUtilities::GetDesktopID(USC_DESKTOP)); | 148 | EXPECT_EQ(usc_icon->RemoteUri(), FavoriteStore::URI_PREFIX_APP + DesktopUtilities::GetDesktopID(USC_DESKTOP)); |
442 | 146 | EXPECT_TRUE(empty_app->RemoteUri().empty()); | 149 | EXPECT_TRUE(mock_icon->RemoteUri().empty()); |
443 | 150 | } | ||
444 | 151 | |||
445 | 152 | TEST_F(TestBamfLauncherIcon, EmptyTooltipUpdatesOnRunning) | ||
446 | 153 | { | ||
447 | 154 | ASSERT_TRUE(mock_icon->tooltip_text().empty()); | ||
448 | 155 | bamf_mock_application_set_name (mock_app, "Got Name"); | ||
449 | 156 | |||
450 | 157 | ASSERT_TRUE(mock_icon->tooltip_text().empty()); | ||
451 | 158 | |||
452 | 159 | bamf_mock_application_set_running(mock_app, TRUE); | ||
453 | 160 | EXPECT_EQ(mock_icon->tooltip_text(), "Got Name"); | ||
454 | 161 | |||
455 | 162 | bamf_mock_application_set_running(mock_app, FALSE); | ||
456 | 163 | bamf_mock_application_set_name (mock_app, "New Name"); | ||
457 | 164 | bamf_mock_application_set_running(mock_app, TRUE); | ||
458 | 165 | EXPECT_EQ(mock_icon->tooltip_text(), "Got Name"); | ||
459 | 166 | } | ||
460 | 167 | |||
461 | 168 | TEST_F(TestBamfLauncherIcon, InvalidIconUpdatesOnRunning) | ||
462 | 169 | { | ||
463 | 170 | ASSERT_EQ(mock_icon->icon_name(), DEFAULT_EMPTY_ICON); | ||
464 | 171 | bamf_mock_application_set_icon (mock_app, "icon-name"); | ||
465 | 172 | |||
466 | 173 | ASSERT_EQ(mock_icon->icon_name(), DEFAULT_EMPTY_ICON); | ||
467 | 174 | |||
468 | 175 | bamf_mock_application_set_running(mock_app, TRUE); | ||
469 | 176 | EXPECT_EQ(mock_icon->icon_name(), "icon-name"); | ||
470 | 177 | |||
471 | 178 | bamf_mock_application_set_running(mock_app, FALSE); | ||
472 | 179 | bamf_mock_application_set_icon (mock_app, "new-icon-name"); | ||
473 | 180 | bamf_mock_application_set_running(mock_app, TRUE); | ||
474 | 181 | EXPECT_EQ(mock_icon->icon_name(), "icon-name"); | ||
475 | 147 | } | 182 | } |
476 | 148 | 183 | ||
477 | 149 | } | 184 | } |
478 | 150 | 185 | ||
479 | === modified file 'tests/test_launcher_controller.cpp' | |||
480 | --- tests/test_launcher_controller.cpp 2012-09-28 11:32:04 +0000 | |||
481 | +++ tests/test_launcher_controller.cpp 2012-10-12 18:26:21 +0000 | |||
482 | @@ -18,7 +18,6 @@ | |||
483 | 18 | */ | 18 | */ |
484 | 19 | 19 | ||
485 | 20 | #include <gmock/gmock.h> | 20 | #include <gmock/gmock.h> |
486 | 21 | #include "test_uscreen_mock.h" | ||
487 | 22 | 21 | ||
488 | 23 | #include "FavoriteStore.h" | 22 | #include "FavoriteStore.h" |
489 | 24 | #include "LauncherController.h" | 23 | #include "LauncherController.h" |
490 | @@ -34,7 +33,9 @@ | |||
491 | 34 | #include "PanelStyle.h" | 33 | #include "PanelStyle.h" |
492 | 35 | #include "UnitySettings.h" | 34 | #include "UnitySettings.h" |
493 | 36 | #include "test_utils.h" | 35 | #include "test_utils.h" |
494 | 36 | #include "test_uscreen_mock.h" | ||
495 | 37 | #include "test_mock_devices.h" | 37 | #include "test_mock_devices.h" |
496 | 38 | #include "bamf-mock-application.h" | ||
497 | 38 | 39 | ||
498 | 39 | using namespace unity::launcher; | 40 | using namespace unity::launcher; |
499 | 40 | using namespace testing; | 41 | using namespace testing; |
500 | @@ -131,7 +132,7 @@ | |||
501 | 131 | typedef bool Fake; | 132 | typedef bool Fake; |
502 | 132 | 133 | ||
503 | 133 | MockBamfLauncherIcon(Fake = true, std::string const& remote_uri = "") | 134 | MockBamfLauncherIcon(Fake = true, std::string const& remote_uri = "") |
505 | 134 | : BamfLauncherIcon(static_cast<BamfApplication*>(g_object_new(BAMF_TYPE_APPLICATION, nullptr))) | 135 | : BamfLauncherIcon(BAMF_APPLICATION(bamf_mock_application_new())) |
506 | 135 | , remote_uri_(remote_uri) | 136 | , remote_uri_(remote_uri) |
507 | 136 | { | 137 | { |
508 | 137 | InitMock(); | 138 | InitMock(); |
Looks good.