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