Merge lp:~azzar1/unity/fix-1003950 into lp:unity
- fix-1003950
- Merge into trunk
Status: | Merged | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | Martin Mrazik | ||||||||||||
Approved revision: | no longer in the source branch. | ||||||||||||
Merged at revision: | 3021 | ||||||||||||
Proposed branch: | lp:~azzar1/unity/fix-1003950 | ||||||||||||
Merge into: | lp:unity | ||||||||||||
Diff against target: |
678 lines (+443/-37) 8 files modified
tests/CMakeLists.txt (+3/-1) tests/bamf-mock-window.c (+239/-0) tests/bamf-mock-window.h (+80/-0) tests/mock-application.h (+6/-0) tests/test_bamf_application.cpp (+86/-0) unity-shared/ApplicationManager.h (+3/-0) unity-shared/BamfApplicationManager.cpp (+12/-20) unity-shared/BamfApplicationManager.h (+14/-16) |
||||||||||||
To merge this branch: | bzr merge lp:~azzar1/unity/fix-1003950 | ||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Marco Trevisan (Treviño) | Approve | ||
Review via email: mp+140781@code.launchpad.net |
Commit message
Include unmapped windows in unity::
Description of the change
== Problem ==
Launcher does not show minimized update manager while clicked.
== Fix ==
Include unmapped windows in unity::
== Test ==
Unit test added.
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Andrea Azzarone (azzar1) wrote : | # |
> 76 +bamf_mock_
> transient)
> 77 +{
> 78 + g_return_if_fail (BAMF_IS_
> 79 + self->priv-
> 80 +}
>
> Mhmh... Probably it's better not to ref it here, since the parent window can
> be also closed... Probably it's better to add a weak ref instead.
Done.
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Ops, I think you removed too much. You still need to do
self-
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Looks good, thanks!
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Andrea Azzarone (azzar1) wrote : | # |
> FAILED: Autolanding.
> More details in the following jenkins job:
> http://
> Executed test runs:
> FAILURE: http://
> autolanding/
> FAILURE: http://
> autolanding/
Are we still building with old bamf?
Martin Mrazik (mrazik) wrote : | # |
Just for the reference -- yes, it was building with old bamf package. Re-approve fixed it.
Preview Diff
1 | === modified file 'tests/CMakeLists.txt' | |||
2 | --- tests/CMakeLists.txt 2013-01-03 10:25:49 +0000 | |||
3 | +++ tests/CMakeLists.txt 2013-01-07 16:54:25 +0000 | |||
4 | @@ -191,6 +191,7 @@ | |||
5 | 191 | test_main.cpp | 191 | test_main.cpp |
6 | 192 | test_action_link.cpp | 192 | test_action_link.cpp |
7 | 193 | test_application_launcher_icon.cpp | 193 | test_application_launcher_icon.cpp |
8 | 194 | test_bamf_application.cpp | ||
9 | 194 | test_bfb_launcher_icon.cpp | 195 | test_bfb_launcher_icon.cpp |
10 | 195 | test_dashview_impl.cpp | 196 | test_dashview_impl.cpp |
11 | 196 | test_dash_controller.cpp | 197 | test_dash_controller.cpp |
12 | @@ -246,12 +247,13 @@ | |||
13 | 246 | test_xdnd_manager_imp.cpp | 247 | test_xdnd_manager_imp.cpp |
14 | 247 | test_xdnd_start_stop_notifier_imp.cpp | 248 | test_xdnd_start_stop_notifier_imp.cpp |
15 | 248 | bamf-mock-application.c | 249 | bamf-mock-application.c |
16 | 250 | bamf-mock-window.c | ||
17 | 249 | gmockmount.c | 251 | gmockmount.c |
18 | 250 | gmockvolume.c | 252 | gmockvolume.c |
19 | 251 | ${UNITY_SRC}/UnityShowdesktopHandler.cpp | 253 | ${UNITY_SRC}/UnityShowdesktopHandler.cpp |
20 | 252 | ${CMAKE_SOURCE_DIR}/plugins/unityshell/src/WindowMinimizeSpeedController.cpp | 254 | ${CMAKE_SOURCE_DIR}/plugins/unityshell/src/WindowMinimizeSpeedController.cpp |
21 | 253 | ) | 255 | ) |
23 | 254 | target_link_libraries(test-gtest gtest gmock unity-shared ${LIBS} launcher-lib unity-shared-standalone shortcuts-lib previews-lib hud-lib switcher-lib dash-lib panel-lib) | 256 | target_link_libraries(test-gtest gtest gmock unity-shared ${LIBS} launcher-lib unity-shared-bamf unity-shared-standalone shortcuts-lib previews-lib hud-lib switcher-lib dash-lib panel-lib) |
24 | 255 | add_test(UnityGTest test-gtest) | 257 | add_test(UnityGTest test-gtest) |
25 | 256 | endif (ENABLE_X_SUPPORT) | 258 | endif (ENABLE_X_SUPPORT) |
26 | 257 | endif (GTEST_SRC_DIR AND | 259 | endif (GTEST_SRC_DIR AND |
27 | 258 | 260 | ||
28 | === added file 'tests/bamf-mock-window.c' | |||
29 | --- tests/bamf-mock-window.c 1970-01-01 00:00:00 +0000 | |||
30 | +++ tests/bamf-mock-window.c 2013-01-07 16:54:25 +0000 | |||
31 | @@ -0,0 +1,239 @@ | |||
32 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
33 | 2 | /* | ||
34 | 3 | * Copyright 2012 Canonical Ltd. | ||
35 | 4 | * | ||
36 | 5 | * This program is free software: you can redistribute it and/or modify it | ||
37 | 6 | * under the terms of the GNU Lesser General Public License version 3, as | ||
38 | 7 | * published by the Free Software Foundation. | ||
39 | 8 | * | ||
40 | 9 | * This program is distributed in the hope that it will be useful, but | ||
41 | 10 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
42 | 11 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
43 | 12 | * PURPOSE. See the applicable version of the GNU Lesser General Public | ||
44 | 13 | * License for more details. | ||
45 | 14 | * | ||
46 | 15 | * You should have received a copy of both the GNU Lesser General Public | ||
47 | 16 | * License version 3 along with this program. If not, see | ||
48 | 17 | * <http://www.gnu.org/licenses/> | ||
49 | 18 | * | ||
50 | 19 | * Authored by: Andrea Azzaronea <andrea.azzarone@canonical> | ||
51 | 20 | * | ||
52 | 21 | */ | ||
53 | 22 | |||
54 | 23 | #include <glib.h> | ||
55 | 24 | |||
56 | 25 | #include "bamf-mock-window.h" | ||
57 | 26 | |||
58 | 27 | G_DEFINE_TYPE (BamfMockWindow, bamf_mock_window, BAMF_TYPE_WINDOW); | ||
59 | 28 | |||
60 | 29 | #define BAMF_MOCK_WINDOW_GET_PRIVATE(o) \ | ||
61 | 30 | (G_TYPE_INSTANCE_GET_PRIVATE ((o), BAMF_TYPE_MOCK_WINDOW, BamfMockWindowPrivate)) | ||
62 | 31 | |||
63 | 32 | struct _BamfMockWindowPrivate | ||
64 | 33 | { | ||
65 | 34 | BamfWindow* transient; | ||
66 | 35 | BamfWindowType window_type; | ||
67 | 36 | guint32 xid; | ||
68 | 37 | guint32 pid; | ||
69 | 38 | gint monitor; | ||
70 | 39 | GHashTable* props; | ||
71 | 40 | BamfWindowMaximizationType maximized; | ||
72 | 41 | time_t last_active; | ||
73 | 42 | }; | ||
74 | 43 | |||
75 | 44 | void | ||
76 | 45 | bamf_mock_window_set_transient (BamfMockWindow *self, BamfWindow* transient) | ||
77 | 46 | { | ||
78 | 47 | g_return_if_fail (BAMF_IS_MOCK_WINDOW (self)); | ||
79 | 48 | |||
80 | 49 | self->priv->transient = transient; | ||
81 | 50 | g_object_add_weak_pointer (G_OBJECT (self->priv->transient), (gpointer *) &self->priv->transient); | ||
82 | 51 | } | ||
83 | 52 | |||
84 | 53 | void | ||
85 | 54 | bamf_mock_window_set_window_type (BamfMockWindow *self, BamfWindowType window_type) | ||
86 | 55 | { | ||
87 | 56 | g_return_if_fail (BAMF_IS_MOCK_WINDOW (self)); | ||
88 | 57 | self->priv->window_type = window_type; | ||
89 | 58 | } | ||
90 | 59 | |||
91 | 60 | void | ||
92 | 61 | bamf_mock_window_set_xid (BamfMockWindow *self, guint32 xid) | ||
93 | 62 | { | ||
94 | 63 | g_return_if_fail (BAMF_IS_MOCK_WINDOW (self)); | ||
95 | 64 | self->priv->xid = xid; | ||
96 | 65 | } | ||
97 | 66 | |||
98 | 67 | void | ||
99 | 68 | bamf_mock_window_set_pid (BamfMockWindow *self, guint32 pid) | ||
100 | 69 | { | ||
101 | 70 | g_return_if_fail (BAMF_IS_MOCK_WINDOW (self)); | ||
102 | 71 | self->priv->pid = pid; | ||
103 | 72 | } | ||
104 | 73 | |||
105 | 74 | void | ||
106 | 75 | bamf_mock_window_set_monitor (BamfMockWindow *self, gint monitor) | ||
107 | 76 | { | ||
108 | 77 | g_return_if_fail (BAMF_IS_MOCK_WINDOW (self)); | ||
109 | 78 | |||
110 | 79 | if (self->priv->monitor != monitor) | ||
111 | 80 | { | ||
112 | 81 | gint old_value = self->priv->monitor; | ||
113 | 82 | self->priv->monitor = monitor; | ||
114 | 83 | g_signal_emit_by_name (G_OBJECT (self), "monitor-changed", old_value, monitor, NULL); | ||
115 | 84 | } | ||
116 | 85 | } | ||
117 | 86 | |||
118 | 87 | void | ||
119 | 88 | bamf_mock_window_set_utf8_prop (BamfMockWindow *self, const char* prop, const char* value) | ||
120 | 89 | { | ||
121 | 90 | g_return_if_fail (BAMF_IS_MOCK_WINDOW (self)); | ||
122 | 91 | |||
123 | 92 | g_hash_table_insert(self->priv->props, g_strdup(prop), g_strdup(value)); | ||
124 | 93 | } | ||
125 | 94 | |||
126 | 95 | void | ||
127 | 96 | bamf_mock_window_set_maximized (BamfMockWindow *self, BamfWindowMaximizationType maximized) | ||
128 | 97 | { | ||
129 | 98 | g_return_if_fail (BAMF_IS_MOCK_WINDOW (self)); | ||
130 | 99 | |||
131 | 100 | if (self->priv->maximized != maximized) | ||
132 | 101 | { | ||
133 | 102 | BamfWindowMaximizationType old_value = self->priv->maximized; | ||
134 | 103 | self->priv->maximized = maximized; | ||
135 | 104 | g_signal_emit_by_name (G_OBJECT (self), "maximized-changed", old_value, maximized, NULL); | ||
136 | 105 | } | ||
137 | 106 | } | ||
138 | 107 | |||
139 | 108 | void bamf_mock_window_set_last_active (BamfMockWindow *self, time_t last_active) | ||
140 | 109 | { | ||
141 | 110 | g_return_if_fail (BAMF_IS_MOCK_WINDOW (self)); | ||
142 | 111 | self->priv->last_active = last_active; | ||
143 | 112 | } | ||
144 | 113 | |||
145 | 114 | static void | ||
146 | 115 | bamf_mock_window_finalize (GObject *object) | ||
147 | 116 | { | ||
148 | 117 | BamfMockWindow *self = BAMF_MOCK_WINDOW (object); | ||
149 | 118 | |||
150 | 119 | if (self->priv->transient) | ||
151 | 120 | { | ||
152 | 121 | g_object_remove_weak_pointer(G_OBJECT (self->priv->transient), (gpointer *) &self->priv->transient); | ||
153 | 122 | self->priv->transient = NULL; | ||
154 | 123 | } | ||
155 | 124 | |||
156 | 125 | |||
157 | 126 | if (self->priv->props) | ||
158 | 127 | { | ||
159 | 128 | g_hash_table_unref (self->priv->props); | ||
160 | 129 | self->priv->props = NULL; | ||
161 | 130 | } | ||
162 | 131 | } | ||
163 | 132 | |||
164 | 133 | static BamfWindow * | ||
165 | 134 | bamf_mock_window_get_transient (BamfWindow *window) | ||
166 | 135 | { | ||
167 | 136 | g_return_val_if_fail (BAMF_IS_MOCK_WINDOW (window), NULL); | ||
168 | 137 | BamfMockWindow *self = BAMF_MOCK_WINDOW (window); | ||
169 | 138 | return self->priv->transient; | ||
170 | 139 | } | ||
171 | 140 | |||
172 | 141 | static BamfWindowType | ||
173 | 142 | bamf_mock_window_get_window_type (BamfWindow *window) | ||
174 | 143 | { | ||
175 | 144 | g_return_val_if_fail (BAMF_IS_MOCK_WINDOW (window), BAMF_WINDOW_NORMAL); | ||
176 | 145 | BamfMockWindow *self = BAMF_MOCK_WINDOW (window); | ||
177 | 146 | return self->priv->window_type; | ||
178 | 147 | } | ||
179 | 148 | |||
180 | 149 | static guint32 | ||
181 | 150 | bamf_mock_window_get_xid (BamfWindow *window) | ||
182 | 151 | { | ||
183 | 152 | g_return_val_if_fail (BAMF_IS_MOCK_WINDOW (window), 0); | ||
184 | 153 | BamfMockWindow *self = BAMF_MOCK_WINDOW (window); | ||
185 | 154 | return self->priv->xid; | ||
186 | 155 | } | ||
187 | 156 | |||
188 | 157 | static guint32 | ||
189 | 158 | bamf_mock_window_get_pid (BamfWindow *window) | ||
190 | 159 | { | ||
191 | 160 | g_return_val_if_fail (BAMF_IS_MOCK_WINDOW (window), 0); | ||
192 | 161 | BamfMockWindow *self = BAMF_MOCK_WINDOW (window); | ||
193 | 162 | return self->priv->pid; | ||
194 | 163 | } | ||
195 | 164 | |||
196 | 165 | static gint | ||
197 | 166 | bamf_mock_window_get_monitor (BamfWindow *window) | ||
198 | 167 | { | ||
199 | 168 | g_return_val_if_fail (BAMF_IS_MOCK_WINDOW (window), BAMF_WINDOW_NORMAL); | ||
200 | 169 | BamfMockWindow *self = BAMF_MOCK_WINDOW (window); | ||
201 | 170 | return self->priv->monitor; | ||
202 | 171 | } | ||
203 | 172 | |||
204 | 173 | static gchar * | ||
205 | 174 | bamf_mock_window_get_utf8_prop (BamfWindow *window, const char* prop) | ||
206 | 175 | { | ||
207 | 176 | g_return_val_if_fail (BAMF_IS_MOCK_WINDOW (window), BAMF_WINDOW_NORMAL); | ||
208 | 177 | BamfMockWindow *self = BAMF_MOCK_WINDOW (window); | ||
209 | 178 | |||
210 | 179 | if (g_hash_table_lookup(self->priv->props, prop)) | ||
211 | 180 | return g_strdup(g_hash_table_lookup(self->priv->props, prop)); | ||
212 | 181 | |||
213 | 182 | return NULL; | ||
214 | 183 | } | ||
215 | 184 | |||
216 | 185 | static BamfWindowMaximizationType | ||
217 | 186 | bamf_mock_window_maximized (BamfWindow *window) | ||
218 | 187 | { | ||
219 | 188 | g_return_val_if_fail (BAMF_IS_MOCK_WINDOW (window), BAMF_WINDOW_FLOATING); | ||
220 | 189 | BamfMockWindow *self = BAMF_MOCK_WINDOW (window); | ||
221 | 190 | return self->priv->maximized; | ||
222 | 191 | } | ||
223 | 192 | |||
224 | 193 | static time_t | ||
225 | 194 | bamf_mock_window_last_active (BamfWindow *window) | ||
226 | 195 | { | ||
227 | 196 | g_return_val_if_fail (BAMF_IS_MOCK_WINDOW (window), 0); | ||
228 | 197 | BamfMockWindow *self = BAMF_MOCK_WINDOW (window); | ||
229 | 198 | return self->priv->last_active; | ||
230 | 199 | } | ||
231 | 200 | |||
232 | 201 | static void | ||
233 | 202 | bamf_mock_window_class_init (BamfMockWindowClass *klass) | ||
234 | 203 | { | ||
235 | 204 | GObjectClass *obj_class = G_OBJECT_CLASS (klass); | ||
236 | 205 | BamfWindowClass *window_class = BAMF_WINDOW_CLASS (klass); | ||
237 | 206 | |||
238 | 207 | obj_class->finalize = bamf_mock_window_finalize; | ||
239 | 208 | window_class->get_transient = bamf_mock_window_get_transient; | ||
240 | 209 | window_class->get_window_type = bamf_mock_window_get_window_type; | ||
241 | 210 | window_class->get_xid = bamf_mock_window_get_xid; | ||
242 | 211 | window_class->get_pid = bamf_mock_window_get_pid; | ||
243 | 212 | window_class->get_monitor = bamf_mock_window_get_monitor; | ||
244 | 213 | window_class->get_utf8_prop = bamf_mock_window_get_utf8_prop; | ||
245 | 214 | window_class->maximized = bamf_mock_window_maximized; | ||
246 | 215 | window_class->last_active = bamf_mock_window_last_active; | ||
247 | 216 | |||
248 | 217 | g_type_class_add_private (obj_class, sizeof (BamfMockWindowPrivate)); | ||
249 | 218 | } | ||
250 | 219 | |||
251 | 220 | static void | ||
252 | 221 | bamf_mock_window_init (BamfMockWindow *self) | ||
253 | 222 | { | ||
254 | 223 | self->priv = BAMF_MOCK_WINDOW_GET_PRIVATE (self); | ||
255 | 224 | |||
256 | 225 | self->priv->transient = NULL; | ||
257 | 226 | self->priv->window_type = BAMF_WINDOW_NORMAL; | ||
258 | 227 | self->priv->xid = 0; | ||
259 | 228 | self->priv->pid = 0; | ||
260 | 229 | self->priv->monitor = 0; | ||
261 | 230 | self->priv->props = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | ||
262 | 231 | self->priv->maximized = BAMF_WINDOW_FLOATING; | ||
263 | 232 | self->priv->last_active = 0; | ||
264 | 233 | } | ||
265 | 234 | |||
266 | 235 | BamfMockWindow * | ||
267 | 236 | bamf_mock_window_new () | ||
268 | 237 | { | ||
269 | 238 | return g_object_new (BAMF_TYPE_MOCK_WINDOW, NULL); | ||
270 | 239 | } | ||
271 | 0 | 240 | ||
272 | === added file 'tests/bamf-mock-window.h' | |||
273 | --- tests/bamf-mock-window.h 1970-01-01 00:00:00 +0000 | |||
274 | +++ tests/bamf-mock-window.h 2013-01-07 16:54:25 +0000 | |||
275 | @@ -0,0 +1,80 @@ | |||
276 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
277 | 2 | /* | ||
278 | 3 | * Copyright 2012 Canonical Ltd. | ||
279 | 4 | * | ||
280 | 5 | * This program is free software: you can redistribute it and/or modify it | ||
281 | 6 | * under the terms of the GNU Lesser General Public License version 3, as | ||
282 | 7 | * published by the Free Software Foundation. | ||
283 | 8 | * | ||
284 | 9 | * This program is distributed in the hope that it will be useful, but | ||
285 | 10 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
286 | 11 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
287 | 12 | * PURPOSE. See the applicable version of the GNU Lesser General Public | ||
288 | 13 | * License for more details. | ||
289 | 14 | * | ||
290 | 15 | * You should have received a copy of both the GNU Lesser General Public | ||
291 | 16 | * License version 3 along with this program. If not, see | ||
292 | 17 | * <http://www.gnu.org/licenses/> | ||
293 | 18 | * | ||
294 | 19 | * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> | ||
295 | 20 | * | ||
296 | 21 | */ | ||
297 | 22 | |||
298 | 23 | #ifndef MOCK_BAMF_MOCK_WINDOW | ||
299 | 24 | #define MOCK_BAMF_MOCK_WINDOW | ||
300 | 25 | |||
301 | 26 | #include <time.h> | ||
302 | 27 | #include <glib-object.h> | ||
303 | 28 | #include <libbamf/libbamf.h> | ||
304 | 29 | |||
305 | 30 | G_BEGIN_DECLS | ||
306 | 31 | |||
307 | 32 | #define BAMF_TYPE_MOCK_WINDOW (bamf_mock_window_get_type ()) | ||
308 | 33 | |||
309 | 34 | #define BAMF_MOCK_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\ | ||
310 | 35 | BAMF_TYPE_MOCK_WINDOW, BamfMockWindow)) | ||
311 | 36 | |||
312 | 37 | #define BAMF_MOCK_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),\ | ||
313 | 38 | BAMF_TYPE_MOCK_WINDOW, BamfMockWindowClass)) | ||
314 | 39 | |||
315 | 40 | #define BAMF_IS_MOCK_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\ | ||
316 | 41 | BAMF_TYPE_MOCK_WINDOW)) | ||
317 | 42 | |||
318 | 43 | #define BAMF_IS_MOCK_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\ | ||
319 | 44 | BAMF_TYPE_MOCK_WINDOW)) | ||
320 | 45 | |||
321 | 46 | #define BAMF_MOCK_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\ | ||
322 | 47 | BAMF_TYPE_MOCK_WINDOW, BamfMockWindowClass)) | ||
323 | 48 | |||
324 | 49 | typedef struct _BamfMockWindow BamfMockWindow; | ||
325 | 50 | typedef struct _BamfMockWindowClass BamfMockWindowClass; | ||
326 | 51 | typedef struct _BamfMockWindowPrivate BamfMockWindowPrivate; | ||
327 | 52 | |||
328 | 53 | struct _BamfMockWindow | ||
329 | 54 | { | ||
330 | 55 | BamfWindow parent; | ||
331 | 56 | |||
332 | 57 | BamfMockWindowPrivate *priv; | ||
333 | 58 | }; | ||
334 | 59 | |||
335 | 60 | struct _BamfMockWindowClass | ||
336 | 61 | { | ||
337 | 62 | BamfWindowClass parent_class; | ||
338 | 63 | }; | ||
339 | 64 | |||
340 | 65 | GType bamf_mock_window_get_type (void) G_GNUC_CONST; | ||
341 | 66 | |||
342 | 67 | BamfMockWindow * bamf_mock_window_new (); | ||
343 | 68 | |||
344 | 69 | void bamf_mock_window_set_transient (BamfMockWindow *self, BamfWindow* transient); | ||
345 | 70 | void bamf_mock_window_set_window_type (BamfMockWindow *self, BamfWindowType window_type); | ||
346 | 71 | void bamf_mock_window_set_xid (BamfMockWindow *self, guint32 xid); | ||
347 | 72 | void bamf_mock_window_set_pid (BamfMockWindow *self, guint32 pid); | ||
348 | 73 | void bamf_mock_window_set_monitor (BamfMockWindow *self, gint monitor); | ||
349 | 74 | void bamf_mock_window_set_utf8_prop (BamfMockWindow *self, const char* prop, const char* value); | ||
350 | 75 | void bamf_mock_window_set_maximized (BamfMockWindow *self, BamfWindowMaximizationType maximized); | ||
351 | 76 | void bamf_mock_window_set_last_active (BamfMockWindow *self, time_t last_active); | ||
352 | 77 | |||
353 | 78 | G_END_DECLS | ||
354 | 79 | |||
355 | 80 | #endif | ||
356 | 0 | 81 | ||
357 | === modified file 'tests/mock-application.h' | |||
358 | --- tests/mock-application.h 2012-12-18 17:57:48 +0000 | |||
359 | +++ tests/mock-application.h 2013-01-07 16:54:25 +0000 | |||
360 | @@ -139,6 +139,12 @@ | |||
361 | 139 | { | 139 | { |
362 | 140 | return unity::ApplicationList(); | 140 | return unity::ApplicationList(); |
363 | 141 | } | 141 | } |
364 | 142 | |||
365 | 143 | unity::ApplicationPtr GetApplicationForWindow(Window xid) | ||
366 | 144 | { | ||
367 | 145 | return unity::ApplicationPtr(); | ||
368 | 146 | } | ||
369 | 147 | |||
370 | 142 | private: | 148 | private: |
371 | 143 | typedef std::map<std::string, unity::ApplicationPtr> AppMap; | 149 | typedef std::map<std::string, unity::ApplicationPtr> AppMap; |
372 | 144 | AppMap app_map_; | 150 | AppMap app_map_; |
373 | 145 | 151 | ||
374 | === added file 'tests/test_bamf_application.cpp' | |||
375 | --- tests/test_bamf_application.cpp 1970-01-01 00:00:00 +0000 | |||
376 | +++ tests/test_bamf_application.cpp 2013-01-07 16:54:25 +0000 | |||
377 | @@ -0,0 +1,86 @@ | |||
378 | 1 | /* | ||
379 | 2 | * Copyright 2012 Canonical Ltd. | ||
380 | 3 | * | ||
381 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
382 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
383 | 6 | * by the Free Software Foundation. | ||
384 | 7 | * | ||
385 | 8 | * This program is distributed in the hope that it will be useful, but | ||
386 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
387 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
388 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
389 | 12 | * | ||
390 | 13 | * You should have received a copy of the GNU General Public License | ||
391 | 14 | * version 3 along with this program. If not, see | ||
392 | 15 | * <http://www.gnu.org/licenses/> | ||
393 | 16 | * | ||
394 | 17 | * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> | ||
395 | 18 | */ | ||
396 | 19 | |||
397 | 20 | #include <glib.h> | ||
398 | 21 | #include <gmock/gmock.h> | ||
399 | 22 | |||
400 | 23 | #include "BamfApplicationManager.h" | ||
401 | 24 | #include "bamf-mock-application.h" | ||
402 | 25 | #include "bamf-mock-window.h" | ||
403 | 26 | #include "StandaloneWindowManager.h" | ||
404 | 27 | |||
405 | 28 | #include <UnityCore/GLibWrapper.h> | ||
406 | 29 | |||
407 | 30 | namespace { | ||
408 | 31 | |||
409 | 32 | struct MockApplicationManager : public unity::ApplicationManager | ||
410 | 33 | { | ||
411 | 34 | MOCK_METHOD0(GetActiveWindow, unity::ApplicationWindowPtr()); | ||
412 | 35 | MOCK_METHOD1(GetApplicationForDesktopFile, unity::ApplicationPtr(std::string const&)); | ||
413 | 36 | MOCK_METHOD0(GetRunningApplications, unity::ApplicationList()); | ||
414 | 37 | MOCK_METHOD1(GetApplicationForWindow, unity::ApplicationPtr(Window)); | ||
415 | 38 | }; | ||
416 | 39 | |||
417 | 40 | unity::StandaloneWindow::Ptr AddFakeWindowToWM(Window xid, bool mapped) | ||
418 | 41 | { | ||
419 | 42 | auto fake_window = std::make_shared<unity::StandaloneWindow>(xid); | ||
420 | 43 | fake_window->mapped = mapped; | ||
421 | 44 | |||
422 | 45 | unity::StandaloneWindowManager* wm = dynamic_cast<unity::StandaloneWindowManager*>(&unity::WindowManager::Default()); | ||
423 | 46 | wm->AddStandaloneWindow(fake_window); | ||
424 | 47 | |||
425 | 48 | return fake_window; | ||
426 | 49 | } | ||
427 | 50 | |||
428 | 51 | struct TestBamfApplication : public testing::Test | ||
429 | 52 | { | ||
430 | 53 | TestBamfApplication() | ||
431 | 54 | : bamf_mock_application_(bamf_mock_application_new()) | ||
432 | 55 | , application_(mock_manager_, unity::glib::object_cast<BamfApplication>(bamf_mock_application_)) | ||
433 | 56 | {} | ||
434 | 57 | |||
435 | 58 | MockApplicationManager mock_manager_; | ||
436 | 59 | unity::glib::Object<BamfMockApplication> bamf_mock_application_; | ||
437 | 60 | unity::bamf::Application application_; | ||
438 | 61 | }; | ||
439 | 62 | |||
440 | 63 | TEST_F(TestBamfApplication, GetWindows) | ||
441 | 64 | { | ||
442 | 65 | GList* children = nullptr; | ||
443 | 66 | for (int i = 0; i<5; ++i) | ||
444 | 67 | { | ||
445 | 68 | BamfMockWindow* window = bamf_mock_window_new(); | ||
446 | 69 | bamf_mock_window_set_xid(window, i); | ||
447 | 70 | children = g_list_append(children, window); | ||
448 | 71 | } | ||
449 | 72 | bamf_mock_application_set_children(bamf_mock_application_, children); | ||
450 | 73 | |||
451 | 74 | AddFakeWindowToWM(0, true); | ||
452 | 75 | AddFakeWindowToWM(1, true); | ||
453 | 76 | AddFakeWindowToWM(2, false); | ||
454 | 77 | AddFakeWindowToWM(3, true); | ||
455 | 78 | AddFakeWindowToWM(4, false); | ||
456 | 79 | |||
457 | 80 | auto windows = application_.GetWindows(); | ||
458 | 81 | ASSERT_EQ(windows.size(), 5); | ||
459 | 82 | |||
460 | 83 | g_list_free_full(children, g_object_unref); | ||
461 | 84 | } | ||
462 | 85 | |||
463 | 86 | } | ||
464 | 0 | \ No newline at end of file | 87 | \ No newline at end of file |
465 | 1 | 88 | ||
466 | === modified file 'unity-shared/ApplicationManager.h' | |||
467 | --- unity-shared/ApplicationManager.h 2012-12-18 17:57:48 +0000 | |||
468 | +++ unity-shared/ApplicationManager.h 2013-01-07 16:54:25 +0000 | |||
469 | @@ -121,6 +121,9 @@ | |||
470 | 121 | 121 | ||
471 | 122 | virtual ApplicationList GetRunningApplications() = 0; | 122 | virtual ApplicationList GetRunningApplications() = 0; |
472 | 123 | 123 | ||
473 | 124 | virtual ApplicationPtr GetApplicationForWindow(Window xid) = 0; | ||
474 | 125 | |||
475 | 126 | |||
476 | 124 | sigc::signal<void, ApplicationPtr const&> application_started; | 127 | sigc::signal<void, ApplicationPtr const&> application_started; |
477 | 125 | 128 | ||
478 | 126 | sigc::signal<void, ApplicationPtr const&> active_application_changed; | 129 | sigc::signal<void, ApplicationPtr const&> active_application_changed; |
479 | 127 | 130 | ||
480 | === modified file 'unity-shared/BamfApplicationManager.cpp' | |||
481 | --- unity-shared/BamfApplicationManager.cpp 2012-12-18 17:57:48 +0000 | |||
482 | +++ unity-shared/BamfApplicationManager.cpp 2013-01-07 16:54:25 +0000 | |||
483 | @@ -37,7 +37,7 @@ | |||
484 | 37 | 37 | ||
485 | 38 | // Due to the way glib handles object inheritance, we need to cast between pointer types. | 38 | // Due to the way glib handles object inheritance, we need to cast between pointer types. |
486 | 39 | // In order to make the up-call for the base class easy, we pass through a void* for the view. | 39 | // In order to make the up-call for the base class easy, we pass through a void* for the view. |
488 | 40 | View::View(Manager const& manager, glib::Object<BamfView> const& view) | 40 | View::View(ApplicationManager const& manager, glib::Object<BamfView> const& view) |
489 | 41 | : manager_(manager) | 41 | : manager_(manager) |
490 | 42 | , bamf_view_(view) | 42 | , bamf_view_(view) |
491 | 43 | { | 43 | { |
492 | @@ -81,7 +81,7 @@ | |||
493 | 81 | } | 81 | } |
494 | 82 | 82 | ||
495 | 83 | 83 | ||
497 | 84 | WindowBase::WindowBase(Manager const& manager, | 84 | WindowBase::WindowBase(ApplicationManager const& manager, |
498 | 85 | glib::Object<BamfView> const& window) | 85 | glib::Object<BamfView> const& window) |
499 | 86 | : View(manager, window) | 86 | : View(manager, window) |
500 | 87 | { | 87 | { |
501 | @@ -140,7 +140,7 @@ | |||
502 | 140 | } | 140 | } |
503 | 141 | 141 | ||
504 | 142 | 142 | ||
506 | 143 | AppWindow::AppWindow(Manager const& manager, glib::Object<BamfView> const& window) | 143 | AppWindow::AppWindow(ApplicationManager const& manager, glib::Object<BamfView> const& window) |
507 | 144 | : WindowBase(manager, window) | 144 | : WindowBase(manager, window) |
508 | 145 | , bamf_window_(glib::object_cast<BamfWindow>(window)) | 145 | , bamf_window_(glib::object_cast<BamfWindow>(window)) |
509 | 146 | { | 146 | { |
510 | @@ -161,8 +161,8 @@ | |||
511 | 161 | { | 161 | { |
512 | 162 | // Moderately evil, but better than changing the method to non-const. | 162 | // Moderately evil, but better than changing the method to non-const. |
513 | 163 | // We know that the manager will always be able to be non-const. | 163 | // We know that the manager will always be able to be non-const. |
516 | 164 | Manager& m = const_cast<Manager&>(manager_); | 164 | ApplicationManager& m = const_cast<ApplicationManager&>(manager_); |
517 | 165 | return m.GetApplicationForWindow(bamf_window_); | 165 | return m.GetApplicationForWindow(window_id()); |
518 | 166 | } | 166 | } |
519 | 167 | 167 | ||
520 | 168 | void AppWindow::Quit() const | 168 | void AppWindow::Quit() const |
521 | @@ -170,7 +170,7 @@ | |||
522 | 170 | WindowManager::Default().Close(window_id()); | 170 | WindowManager::Default().Close(window_id()); |
523 | 171 | } | 171 | } |
524 | 172 | 172 | ||
526 | 173 | Tab::Tab(Manager const& manager, glib::Object<BamfView> const& tab) | 173 | Tab::Tab(ApplicationManager const& manager, glib::Object<BamfView> const& tab) |
527 | 174 | : WindowBase(manager, tab) | 174 | : WindowBase(manager, tab) |
528 | 175 | , bamf_tab_(glib::object_cast<BamfTab>(tab)) | 175 | , bamf_tab_(glib::object_cast<BamfTab>(tab)) |
529 | 176 | {} | 176 | {} |
530 | @@ -206,7 +206,7 @@ | |||
531 | 206 | } | 206 | } |
532 | 207 | 207 | ||
533 | 208 | // Being brutal with this function. | 208 | // Being brutal with this function. |
535 | 209 | ApplicationWindowPtr create_window(Manager const& manager, glib::Object<BamfView> const& view) | 209 | ApplicationWindowPtr create_window(ApplicationManager const& manager, glib::Object<BamfView> const& view) |
536 | 210 | { | 210 | { |
537 | 211 | ApplicationWindowPtr result; | 211 | ApplicationWindowPtr result; |
538 | 212 | if (view.IsType(BAMF_TYPE_TAB)) | 212 | if (view.IsType(BAMF_TYPE_TAB)) |
539 | @@ -221,14 +221,14 @@ | |||
540 | 221 | return result; | 221 | return result; |
541 | 222 | } | 222 | } |
542 | 223 | 223 | ||
544 | 224 | Application::Application(Manager const& manager, glib::Object<BamfView> const& app) | 224 | Application::Application(ApplicationManager const& manager, glib::Object<BamfView> const& app) |
545 | 225 | : View(manager, app) | 225 | : View(manager, app) |
546 | 226 | , bamf_app_(glib::object_cast<BamfApplication>(app)) | 226 | , bamf_app_(glib::object_cast<BamfApplication>(app)) |
547 | 227 | { | 227 | { |
548 | 228 | HookUpEvents(); | 228 | HookUpEvents(); |
549 | 229 | } | 229 | } |
550 | 230 | 230 | ||
552 | 231 | Application::Application(Manager const& manager, glib::Object<BamfApplication> const& app) | 231 | Application::Application(ApplicationManager const& manager, glib::Object<BamfApplication> const& app) |
553 | 232 | : View(manager, glib::object_cast<BamfView>(app)) | 232 | : View(manager, glib::object_cast<BamfView>(app)) |
554 | 233 | , bamf_app_(app) | 233 | , bamf_app_(app) |
555 | 234 | { | 234 | { |
556 | @@ -347,21 +347,13 @@ | |||
557 | 347 | if (!bamf_app_) | 347 | if (!bamf_app_) |
558 | 348 | return result; | 348 | return result; |
559 | 349 | 349 | ||
560 | 350 | WindowManager& wm = WindowManager::Default(); | ||
561 | 351 | std::shared_ptr<GList> children(bamf_view_get_children(bamf_view_), g_list_free); | 350 | std::shared_ptr<GList> children(bamf_view_get_children(bamf_view_), g_list_free); |
562 | 352 | for (GList* l = children.get(); l; l = l->next) | 351 | for (GList* l = children.get(); l; l = l->next) |
563 | 353 | { | 352 | { |
564 | 354 | glib::Object<BamfView> view(BAMF_VIEW(l->data), glib::AddRef()); | 353 | glib::Object<BamfView> view(BAMF_VIEW(l->data), glib::AddRef()); |
565 | 355 | ApplicationWindowPtr window(create_window(manager_, view)); | 354 | ApplicationWindowPtr window(create_window(manager_, view)); |
573 | 356 | if (!window) | 355 | if (window) |
567 | 357 | continue; | ||
568 | 358 | |||
569 | 359 | Window window_id = window->window_id(); | ||
570 | 360 | |||
571 | 361 | if (wm.IsWindowMapped(window_id)) | ||
572 | 362 | { | ||
574 | 363 | result.push_back(window); | 356 | result.push_back(window); |
575 | 364 | } | ||
576 | 365 | } | 357 | } |
577 | 366 | return result; | 358 | return result; |
578 | 367 | } | 359 | } |
579 | @@ -592,10 +584,10 @@ | |||
580 | 592 | return result; | 584 | return result; |
581 | 593 | } | 585 | } |
582 | 594 | 586 | ||
584 | 595 | ApplicationPtr Manager::GetApplicationForWindow(glib::Object<BamfWindow> const& window) | 587 | ApplicationPtr Manager::GetApplicationForWindow(Window xid) |
585 | 596 | { | 588 | { |
586 | 597 | ApplicationPtr result; | 589 | ApplicationPtr result; |
588 | 598 | glib::Object<BamfApplication> app(bamf_matcher_get_application_for_window(matcher_, window), | 590 | glib::Object<BamfApplication> app(bamf_matcher_get_application_for_xid(matcher_, xid), |
589 | 599 | glib::AddRef()); | 591 | glib::AddRef()); |
590 | 600 | if (app) | 592 | if (app) |
591 | 601 | result.reset(new Application(*this, app)); | 593 | result.reset(new Application(*this, app)); |
592 | 602 | 594 | ||
593 | === modified file 'unity-shared/BamfApplicationManager.h' | |||
594 | --- unity-shared/BamfApplicationManager.h 2012-12-18 17:57:48 +0000 | |||
595 | +++ unity-shared/BamfApplicationManager.h 2013-01-07 16:54:25 +0000 | |||
596 | @@ -31,11 +31,10 @@ | |||
597 | 31 | { | 31 | { |
598 | 32 | namespace bamf | 32 | namespace bamf |
599 | 33 | { | 33 | { |
600 | 34 | class Manager; | ||
601 | 35 | class View | 34 | class View |
602 | 36 | { | 35 | { |
603 | 37 | public: | 36 | public: |
605 | 38 | View(Manager const& manager, | 37 | View(ApplicationManager const& manager, |
606 | 39 | glib::Object<BamfView> const& view); | 38 | glib::Object<BamfView> const& view); |
607 | 40 | 39 | ||
608 | 41 | std::string title() const; | 40 | std::string title() const; |
609 | @@ -48,7 +47,7 @@ | |||
610 | 48 | bool GetUrgent() const; | 47 | bool GetUrgent() const; |
611 | 49 | 48 | ||
612 | 50 | protected: | 49 | protected: |
614 | 51 | Manager const& manager_; | 50 | ApplicationManager const& manager_; |
615 | 52 | glib::Object<BamfView> bamf_view_; | 51 | glib::Object<BamfView> bamf_view_; |
616 | 53 | }; | 52 | }; |
617 | 54 | 53 | ||
618 | @@ -56,7 +55,7 @@ | |||
619 | 56 | class WindowBase: public ::unity::ApplicationWindow, public View | 55 | class WindowBase: public ::unity::ApplicationWindow, public View |
620 | 57 | { | 56 | { |
621 | 58 | protected: | 57 | protected: |
623 | 59 | WindowBase(Manager const& manager, | 58 | WindowBase(ApplicationManager const& manager, |
624 | 60 | glib::Object<BamfView> const& window); | 59 | glib::Object<BamfView> const& window); |
625 | 61 | 60 | ||
626 | 62 | public: | 61 | public: |
627 | @@ -74,7 +73,7 @@ | |||
628 | 74 | class AppWindow: public WindowBase | 73 | class AppWindow: public WindowBase |
629 | 75 | { | 74 | { |
630 | 76 | public: | 75 | public: |
632 | 77 | AppWindow(Manager const& manager, | 76 | AppWindow(ApplicationManager const& manager, |
633 | 78 | glib::Object<BamfView> const& window); | 77 | glib::Object<BamfView> const& window); |
634 | 79 | 78 | ||
635 | 80 | virtual Window window_id() const; | 79 | virtual Window window_id() const; |
636 | @@ -89,7 +88,7 @@ | |||
637 | 89 | class Tab: public WindowBase | 88 | class Tab: public WindowBase |
638 | 90 | { | 89 | { |
639 | 91 | public: | 90 | public: |
641 | 92 | Tab(Manager const& manager, | 91 | Tab(ApplicationManager const& manager, |
642 | 93 | glib::Object<BamfView> const& tab); | 92 | glib::Object<BamfView> const& tab); |
643 | 94 | 93 | ||
644 | 95 | virtual Window window_id() const; | 94 | virtual Window window_id() const; |
645 | @@ -106,9 +105,9 @@ | |||
646 | 106 | class Application : public ::unity::Application, public View | 105 | class Application : public ::unity::Application, public View |
647 | 107 | { | 106 | { |
648 | 108 | public: | 107 | public: |
650 | 109 | Application(Manager const& manager, | 108 | Application(ApplicationManager const& manager, |
651 | 110 | glib::Object<BamfView> const& app); | 109 | glib::Object<BamfView> const& app); |
653 | 111 | Application(Manager const& manager, | 110 | Application(ApplicationManager const& manager, |
654 | 112 | glib::Object<BamfApplication> const& app); | 111 | glib::Object<BamfApplication> const& app); |
655 | 113 | 112 | ||
656 | 114 | virtual std::string title() const; | 113 | virtual std::string title() const; |
657 | @@ -149,14 +148,13 @@ | |||
658 | 149 | Manager(); | 148 | Manager(); |
659 | 150 | ~Manager(); | 149 | ~Manager(); |
660 | 151 | 150 | ||
669 | 152 | virtual ApplicationWindowPtr GetActiveWindow(); | 151 | ApplicationWindowPtr GetActiveWindow() override; |
670 | 153 | 152 | ||
671 | 154 | virtual ApplicationPtr GetApplicationForDesktopFile(std::string const& desktop_file); | 153 | ApplicationPtr GetApplicationForDesktopFile(std::string const& desktop_file) override; |
672 | 155 | 154 | ||
673 | 156 | virtual ApplicationList GetRunningApplications(); | 155 | ApplicationList GetRunningApplications() override; |
674 | 157 | 156 | ||
675 | 158 | 157 | ApplicationPtr GetApplicationForWindow(Window xid) override; | |
668 | 159 | virtual ApplicationPtr GetApplicationForWindow(glib::Object<BamfWindow> const& window); | ||
676 | 160 | 158 | ||
677 | 161 | private: | 159 | private: |
678 | 162 | void OnViewOpened(BamfMatcher* matcher, BamfView* view); | 160 | void OnViewOpened(BamfMatcher* matcher, BamfView* view); |
76 +bamf_mock_ window_ set_transient (BamfMockWindow *self, BamfWindow* transient) MOCK_WINDOW (self)); >transient = g_object_ ref(transient) ;
77 +{
78 + g_return_if_fail (BAMF_IS_
79 + self->priv-
80 +}
Mhmh... Probably it's better not to ref it here, since the parent window can be also closed... Probably it's better to add a weak ref instead.