Merge lp:~mhr3/libunity/define-subscopes into lp:libunity
- define-subscopes
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Paweł Stołowski |
Approved revision: | 274 |
Merged at revision: | 271 |
Proposed branch: | lp:~mhr3/libunity/define-subscopes |
Merge into: | lp:libunity |
Diff against target: |
634 lines (+294/-122) 5 files modified
protocol/Makefile.am (+6/-2) protocol/protocol-scope-discovery.vala (+204/-105) test/data/unity/scopes/masterscope_c.scope (+20/-0) test/vala/test-scope-discovery.vala (+10/-0) test/vala/test-scope.vala (+54/-15) |
To merge this branch: | bzr merge lp:~mhr3/libunity/define-subscopes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Paweł Stołowski (community) | Approve | ||
Review via email: mp+177633@code.launchpad.net |
Commit message
Allow definition of subscope ids in master scopes.
Description of the change
Allow definition of subscope ids in master scopes.
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:270
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:271
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Paweł Stołowski (stolowski) wrote : | # |
340 - yield reg.process_scope (filename, master_prefix);
341 + yield reg.process_scope (filename);
Since you removed master_prefix, can you also remove it from find_scopes_
Paweł Stołowski (stolowski) wrote : | # |
9 + private static string extract_scope_id (string path)
This is a good candidate for some nice tests; can you add a test with cases covering absolute/relative paths?
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:273
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
- 274. By Michal Hruby
-
Merge trunk
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'protocol/Makefile.am' |
2 | --- protocol/Makefile.am 2013-04-01 21:10:41 +0000 |
3 | +++ protocol/Makefile.am 2013-08-05 10:03:28 +0000 |
4 | @@ -35,13 +35,17 @@ |
5 | -DDATADIR=\"$(DATADIR)\" \ |
6 | -I$(srcdir) \ |
7 | $(EXTRA_FLAGS) \ |
8 | - $(LIBUNITY_CFLAGS) |
9 | + $(LIBUNITY_CFLAGS) \ |
10 | + $(COVERAGE_CFLAGS) \ |
11 | + $(NULL) |
12 | |
13 | libunity_protocol_private_la_LIBADD = \ |
14 | $(LIBUNITY_LIBS) |
15 | |
16 | libunity_protocol_private_la_LDFLAGS = \ |
17 | - $(LIBPROTOCOL_LT_LDFLAGS) |
18 | + $(LIBPROTOCOL_LT_LDFLAGS) \ |
19 | + $(COVERAGE_LDFLAGS) \ |
20 | + $(NULL) |
21 | |
22 | libunity_protocol_private_la_VALAFLAGS = \ |
23 | -C \ |
24 | |
25 | === modified file 'protocol/protocol-scope-discovery.vala' |
26 | --- protocol/protocol-scope-discovery.vala 2013-07-02 18:42:23 +0000 |
27 | +++ protocol/protocol-scope-discovery.vala 2013-08-05 10:03:28 +0000 |
28 | @@ -189,6 +189,48 @@ |
29 | private static const string SCOPE_GROUP = "Scope"; |
30 | private static const string DESKTOP_GROUP = "Desktop Entry"; |
31 | |
32 | + private static string[] scope_file_prefixes = null; |
33 | + private static string extract_scope_id (string path) |
34 | + { |
35 | + string? real_path = null; |
36 | + if (!Path.is_absolute (path)) |
37 | + { |
38 | + var f = File.new_for_path (path); |
39 | + real_path = f.get_path (); |
40 | + path = real_path; |
41 | + } |
42 | + |
43 | + if (scope_file_prefixes == null) |
44 | + { |
45 | + foreach (unowned string data_dir in Environment.get_system_data_dirs ()) |
46 | + { |
47 | + var sys_path = Path.build_path (Path.DIR_SEPARATOR_S, |
48 | + data_dir, SCOPES_DIR, null); |
49 | + var f = File.new_for_path (sys_path); |
50 | + // this will resolve relative paths |
51 | + scope_file_prefixes += "%s/".printf (f.get_path ()); |
52 | + } |
53 | + } |
54 | + |
55 | + string normalized_path = path.replace ("//", "/"); |
56 | + |
57 | + foreach (unowned string prefix in scope_file_prefixes) |
58 | + { |
59 | + if (normalized_path.has_prefix (prefix)) |
60 | + { |
61 | + string without_prefix = normalized_path.substring (prefix.length); |
62 | + |
63 | + if (Path.DIR_SEPARATOR_S in without_prefix) |
64 | + return without_prefix.replace (Path.DIR_SEPARATOR_S, "-"); |
65 | + |
66 | + return without_prefix; |
67 | + } |
68 | + } |
69 | + |
70 | + return Path.get_basename (path); |
71 | + } |
72 | + |
73 | + |
74 | public class ScopeMetadata |
75 | { |
76 | /* careful here, although it's a private lib, keeping it |
77 | @@ -221,6 +263,7 @@ |
78 | |
79 | private CategoryDefinition[] categories; |
80 | private FilterDefinition[] filters; |
81 | + private string[] subscope_ids; |
82 | |
83 | public unowned CategoryDefinition[] get_categories () |
84 | { |
85 | @@ -231,6 +274,11 @@ |
86 | return filters; |
87 | } |
88 | |
89 | + public unowned string[] get_subscope_ids () |
90 | + { |
91 | + return subscope_ids; |
92 | + } |
93 | + |
94 | public void load_from_key_file (KeyFile file) throws Error |
95 | { |
96 | this.domain = null; |
97 | @@ -346,6 +394,11 @@ |
98 | this.no_content_hint = dgettext (this.domain, file.get_string (SCOPE_GROUP, "NoContentHint")); |
99 | } |
100 | |
101 | + if (file.has_key (SCOPE_GROUP, "Subscopes")) |
102 | + { |
103 | + this.subscope_ids = file.get_string_list (SCOPE_GROUP, "Subscopes"); |
104 | + } |
105 | + |
106 | const string FILTER_PREFIX = "Filter "; |
107 | const string CATEGORY_PREFIX = "Category "; |
108 | |
109 | @@ -433,6 +486,15 @@ |
110 | } |
111 | } |
112 | |
113 | + /* Private method cause ScopeMetadata.full_path and .id are null */ |
114 | + private static ScopeMetadata for_keyfile (KeyFile file) throws Error |
115 | + { |
116 | + ScopeMetadata data = new ScopeMetadata (); |
117 | + data.load_from_key_file (file); |
118 | + |
119 | + return data; |
120 | + } |
121 | + |
122 | public static ScopeMetadata for_id (string scope_id) throws Error |
123 | { |
124 | debug ("for_id: %s", scope_id); |
125 | @@ -444,13 +506,39 @@ |
126 | KeyFileFlags.NONE); |
127 | |
128 | if (!loaded) |
129 | - throw new ParseError.FILE_NOT_FOUND ("Scope not found: %s", scope_id); |
130 | + throw new ParseError.FILE_NOT_FOUND ("Scope not found: %s", scope_id); |
131 | |
132 | - ScopeMetadata data = new ScopeMetadata (); |
133 | + var data = ScopeMetadata.for_keyfile (file); |
134 | data.id = scope_id; |
135 | data.full_path = full_path; |
136 | |
137 | - data.load_from_key_file (file); |
138 | + return data; |
139 | + } |
140 | + |
141 | + public static ScopeMetadata for_path (string path) throws Error |
142 | + { |
143 | + debug ("for_path: %s", path); |
144 | + |
145 | + bool loaded = true; |
146 | + string full_path; |
147 | + |
148 | + var keyfile = new KeyFile (); |
149 | + if (GLib.Path.is_absolute (path)) |
150 | + { |
151 | + loaded = keyfile.load_from_file (path, KeyFileFlags.NONE); |
152 | + full_path = path; |
153 | + } |
154 | + else |
155 | + { |
156 | + loaded = keyfile.load_from_data_dirs (path, out full_path, KeyFileFlags.NONE); |
157 | + } |
158 | + |
159 | + if (!loaded) |
160 | + throw new ParseError.FILE_NOT_FOUND ("File not found: %s", path); |
161 | + |
162 | + ScopeMetadata data = ScopeMetadata.for_keyfile (keyfile); |
163 | + data.full_path = full_path; |
164 | + data.id = extract_scope_id (full_path); |
165 | |
166 | return data; |
167 | } |
168 | @@ -474,111 +562,94 @@ |
169 | { |
170 | } |
171 | |
172 | - internal static async ScopeMetadata? parse_scope_file (string path, string? master_prefix) throws Error |
173 | - { |
174 | - debug ("parse_scope_file: %s, master_prefix = %s", path, master_prefix); |
175 | - |
176 | - bool loaded = true; |
177 | - ScopeMetadata data = new ScopeMetadata (); |
178 | - |
179 | - var file = new KeyFile (); |
180 | - if (GLib.Path.is_absolute (path)) |
181 | - { |
182 | - loaded = file.load_from_file (path, KeyFileFlags.NONE); |
183 | - data.full_path = path; |
184 | - } |
185 | - else |
186 | - { |
187 | - loaded = file.load_from_data_dirs (path, out data.full_path, KeyFileFlags.NONE); |
188 | - } |
189 | - |
190 | - if (!loaded) |
191 | - throw new ParseError.FILE_NOT_FOUND ("File not found: %s", path); |
192 | - |
193 | - data.load_from_key_file (file); |
194 | - |
195 | - var basename = GLib.Path.get_basename (path); |
196 | - data.id = basename; |
197 | - if (master_prefix != null && master_prefix.length > 0) |
198 | - data.id = "%s-%s".printf (master_prefix, basename); |
199 | - |
200 | - debug ("parse_scope_file: %s finished", path); |
201 | - return data; |
202 | - } |
203 | - |
204 | /** |
205 | * Process .scope file and scopes in a subdirectory if it's master scope. |
206 | * |
207 | * @param filename path of a .scope file |
208 | */ |
209 | - private async void process_scope (string filename, string? master_scope_prefix = null) throws Error |
210 | + private async void process_scope (string filename) throws Error |
211 | { |
212 | debug ("process_scope: %s", filename); |
213 | |
214 | - ScopeMetadata? scope_data = null; |
215 | - scope_data = yield parse_scope_file (filename, master_scope_prefix); // this may throw, in such case don't process this scope (and possibly its subscopes if it was master scope) |
216 | - |
217 | - if (scope_data != null) |
218 | - { |
219 | - var scope_node = new ScopeRegistryNode () |
220 | - { |
221 | - scope_info = scope_data, |
222 | - sub_scopes = null |
223 | - }; |
224 | - |
225 | - if (scope_data.is_master) |
226 | - { |
227 | - // check if there is a subdirectory with the name of master scope. |
228 | - // note that failure on single sub-scope shouldn't disable master & valid sub-scopes. |
229 | - var scopefile = GLib.File.new_for_path (scope_data.full_path); |
230 | - string scope_name = remove_scope_extension (scope_data.id); |
231 | - var parent = scopefile.get_parent (); |
232 | - if (parent != null) |
233 | - { |
234 | - string check_path = Path.build_filename (parent.get_path (), scope_name); |
235 | - |
236 | - if (FileUtils.test (check_path, FileTest.IS_DIR)) |
237 | - { |
238 | - GLib.Dir? scope_subdir = null; |
239 | - try |
240 | - { |
241 | - scope_subdir = GLib.Dir.open (check_path); |
242 | - } |
243 | - catch (FileError e) |
244 | - { |
245 | - warning ("Error accessing directory %s", check_path); |
246 | - } |
247 | - |
248 | - if (scope_subdir != null) |
249 | - { |
250 | - // iterate over all files, find .*scope |
251 | - string slave_scope_filename; |
252 | - while ((slave_scope_filename = scope_subdir.read_name ()) != null) |
253 | - { |
254 | - slave_scope_filename = Path.build_filename (check_path, slave_scope_filename); |
255 | - ScopeMetadata? slave_scope_data = null; |
256 | - try |
257 | - { |
258 | - slave_scope_data = yield parse_scope_file (slave_scope_filename, scope_name); |
259 | - } |
260 | - catch (Error e) |
261 | - { |
262 | - warning ("Failed to process '%s': %s", slave_scope_filename, e.message); |
263 | - } |
264 | - if (slave_scope_data != null) |
265 | - { |
266 | - if (scope_node.sub_scopes == null) |
267 | - scope_node.sub_scopes = new GLib.SList<ScopeMetadata?> (); |
268 | - |
269 | - scope_node.sub_scopes.append (slave_scope_data); |
270 | - } |
271 | - } |
272 | - } |
273 | - } |
274 | - } |
275 | - } |
276 | - |
277 | - scopes_.append (scope_node); |
278 | + ScopeMetadata scope_data = ScopeMetadata.for_path (filename); // this may throw, in such case don't process this scope (and possibly its subscopes if it was master scope) |
279 | + if (scope_data == null) return; |
280 | + |
281 | + var scope_node = new ScopeRegistryNode () |
282 | + { |
283 | + scope_info = scope_data, |
284 | + sub_scopes = null |
285 | + }; |
286 | + |
287 | + // adding the scope_node now, but we'll update its fields if it's a master |
288 | + scopes_.append (scope_node); |
289 | + |
290 | + if (!scope_data.is_master) return; |
291 | + |
292 | + /* This is a master scope, find its children */ |
293 | + |
294 | + // does the master scope hardcode its children? |
295 | + unowned string[] subscopes = scope_data.get_subscope_ids (); |
296 | + if (subscopes.length > 0) |
297 | + { |
298 | + foreach (unowned string subscope_id in subscopes) |
299 | + { |
300 | + try |
301 | + { |
302 | + ScopeMetadata subscope_data = ScopeMetadata.for_id (subscope_id); |
303 | + if (scope_node.sub_scopes == null) |
304 | + scope_node.sub_scopes = new GLib.SList<ScopeMetadata?> (); |
305 | + |
306 | + scope_node.sub_scopes.append (subscope_data); |
307 | + } |
308 | + catch (Error e) |
309 | + { |
310 | + warning ("Failed to process '%s': %s", subscope_id, e.message); |
311 | + } |
312 | + } |
313 | + } |
314 | + else |
315 | + { |
316 | + // check if there is a subdirectory with the name of master scope. |
317 | + // note that failure on single sub-scope shouldn't disable master & valid sub-scopes. |
318 | + var scopefile = GLib.File.new_for_path (scope_data.full_path); |
319 | + string scope_name = remove_scope_extension (scope_data.id); |
320 | + var parent = scopefile.get_parent (); |
321 | + if (parent == null) return; |
322 | + |
323 | + string check_path = Path.build_filename (parent.get_path (), scope_name); |
324 | + |
325 | + if (!FileUtils.test (check_path, FileTest.IS_DIR)) return; |
326 | + |
327 | + GLib.Dir? scope_subdir = null; |
328 | + try |
329 | + { |
330 | + scope_subdir = GLib.Dir.open (check_path); |
331 | + } |
332 | + catch (FileError e) |
333 | + { |
334 | + warning ("Error accessing directory %s", check_path); |
335 | + } |
336 | + |
337 | + if (scope_subdir == null) return; |
338 | + |
339 | + // iterate over all files, find .*scope |
340 | + string slave_scope_filename; |
341 | + while ((slave_scope_filename = scope_subdir.read_name ()) != null) |
342 | + { |
343 | + slave_scope_filename = Path.build_filename (check_path, slave_scope_filename); |
344 | + try |
345 | + { |
346 | + ScopeMetadata slave_scope_data = ScopeMetadata.for_path (slave_scope_filename); |
347 | + if (scope_node.sub_scopes == null) |
348 | + scope_node.sub_scopes = new GLib.SList<ScopeMetadata?> (); |
349 | + |
350 | + scope_node.sub_scopes.append (slave_scope_data); |
351 | + } |
352 | + catch (Error e) |
353 | + { |
354 | + warning ("Failed to process '%s': %s", slave_scope_filename, e.message); |
355 | + } |
356 | + } |
357 | } |
358 | } |
359 | |
360 | @@ -591,7 +662,7 @@ |
361 | */ |
362 | public static async ScopeRegistry find_scopes (string start_path) throws Error |
363 | { |
364 | - var reg = yield find_scopes_for_master (start_path, null); |
365 | + var reg = yield find_scopes_for_master (start_path); |
366 | return reg; |
367 | } |
368 | |
369 | @@ -602,7 +673,7 @@ |
370 | * @param start_path starting directory or specific .scope file |
371 | * @return registry of all scopes (if start_path is a dir) or just one scope and its subscopes. |
372 | */ |
373 | - private static async ScopeRegistry find_scopes_for_master (string start_path, string? master_prefix) throws Error |
374 | + private static async ScopeRegistry find_scopes_for_master (string start_path) throws Error |
375 | { |
376 | debug ("find_scopes_for_master: %s\n", start_path); |
377 | |
378 | @@ -621,7 +692,7 @@ |
379 | debug ("Found scope file: %s", filename); |
380 | try // failure of single scope shouldn't break processing of others scopes |
381 | { |
382 | - yield reg.process_scope (filename, master_prefix); |
383 | + yield reg.process_scope (filename); |
384 | } |
385 | catch (Error e) |
386 | { |
387 | @@ -655,7 +726,7 @@ |
388 | /** |
389 | * Find sub-scopes for given master scope id in unity/scopes subdirectory |
390 | * of XDG_DATA_DIRS dirs or in root_path. |
391 | - * @param scope_id id of a master scope (with or without .scope suffix) |
392 | + * @param scope_id id of a master scope (with .scope suffix) |
393 | * @param root_path base directory of scopes, defaults to XDG_DATA_DIRS paths + "/unity/scopes" |
394 | * @return scope registry with scopes property populated with all sub-scopes of the master scope. |
395 | */ |
396 | @@ -678,13 +749,41 @@ |
397 | throw new ParseError.INVALID_PATH ("Invalid scopes path"); |
398 | } |
399 | |
400 | + // try to find the master scope file |
401 | + try |
402 | + { |
403 | + var master_scope_metadata = ScopeMetadata.for_id (scope_id); |
404 | + unowned string[] subscopes = master_scope_metadata.get_subscope_ids (); |
405 | + if (subscopes.length > 0) |
406 | + { |
407 | + var reg = new ScopeRegistry (); |
408 | + foreach (unowned string subscope_id in subscopes) |
409 | + { |
410 | + var node = new ScopeRegistryNode (); |
411 | + try |
412 | + { |
413 | + node.scope_info = ScopeMetadata.for_id (subscope_id); |
414 | + reg.scopes_.append (node); |
415 | + } |
416 | + catch (Error err) |
417 | + { |
418 | + } |
419 | + } |
420 | + return reg; |
421 | + } |
422 | + } |
423 | + catch (Error err) |
424 | + { |
425 | + // silently ignore |
426 | + } |
427 | + |
428 | var sc = remove_scope_extension (scope_id); |
429 | foreach (var path in dirs) |
430 | { |
431 | var check_path = root_path == null ? Path.build_path (Path.DIR_SEPARATOR_S, path, SCOPES_DIR, sc) : Path.build_path (Path.DIR_SEPARATOR_S, root_path, sc); |
432 | if (FileUtils.test (check_path, FileTest.IS_DIR)) |
433 | { |
434 | - var reg = yield find_scopes_for_master (check_path, sc); |
435 | + var reg = yield find_scopes_for_master (check_path); |
436 | return reg; |
437 | } |
438 | } |
439 | |
440 | === added file 'test/data/unity/scopes/masterscope_c.scope' |
441 | --- test/data/unity/scopes/masterscope_c.scope 1970-01-01 00:00:00 +0000 |
442 | +++ test/data/unity/scopes/masterscope_c.scope 2013-08-05 10:03:28 +0000 |
443 | @@ -0,0 +1,20 @@ |
444 | +[Scope] |
445 | +GroupName=com.canonical.Unity.Scope.MasterC |
446 | +UniqueName=/com/canonical/unity/scope/masterc |
447 | +Icon=/usr/share/unity/6/icon2.svg |
448 | +IsMaster=true |
449 | +# Keywords is localized |
450 | +Type=booze |
451 | +Name=Sample Master Scope 3 |
452 | +Description=Finds almost everything |
453 | +SearchHint=Search things |
454 | +NoContentHint=Sorry to make you a sad panda, but there's nothing here. |
455 | +Subscopes=test_masterscope.scope; |
456 | + |
457 | +[Desktop Entry] |
458 | +X-Ubuntu-Gettext-Domain=fakedomain |
459 | + |
460 | +[Category cat1] |
461 | +Name=Category #1 |
462 | +Icon=/usr/share/unity/category1_icon.svg |
463 | +DedupField=uri |
464 | |
465 | === modified file 'test/vala/test-scope-discovery.vala' |
466 | --- test/vala/test-scope-discovery.vala 2013-07-11 10:34:15 +0000 |
467 | +++ test/vala/test-scope-discovery.vala 2013-08-05 10:03:28 +0000 |
468 | @@ -109,6 +109,7 @@ |
469 | |
470 | bool got_masterscope_1 = false; |
471 | bool got_masterscope_2 = false; |
472 | + bool got_masterscope_3 = false; |
473 | |
474 | foreach (var node in reg.scopes) |
475 | { |
476 | @@ -164,10 +165,19 @@ |
477 | |
478 | got_masterscope_2 = true; |
479 | } |
480 | + else if (inf.name == "Sample Master Scope 3") |
481 | + { |
482 | + assert (inf.id == "masterscope_c.scope"); |
483 | + |
484 | + assert (node.sub_scopes.length () == 1); |
485 | + assert (node.sub_scopes.nth_data (0).id == "test_masterscope.scope"); |
486 | + got_masterscope_3 = true; |
487 | + } |
488 | } |
489 | |
490 | assert (got_masterscope_1 == true); |
491 | assert (got_masterscope_2 == true); |
492 | + assert (got_masterscope_3 == true); |
493 | } |
494 | |
495 | internal static void test_find_specific_scope () |
496 | |
497 | === modified file 'test/vala/test-scope.vala' |
498 | --- test/vala/test-scope.vala 2013-08-01 13:09:05 +0000 |
499 | +++ test/vala/test-scope.vala 2013-08-05 10:03:28 +0000 |
500 | @@ -136,6 +136,8 @@ |
501 | Fixture.create<MasterScopeTester> (MasterScopeTester.test_push_results_and_search)); |
502 | Test.add_data_func ("/Unit/MasterScope/SubscopesSearch", |
503 | Fixture.create<MasterScopeTester> (MasterScopeTester.test_subscopes_search)); |
504 | + Test.add_data_func ("/Unit/MasterScope/OverriddenSubscopes", |
505 | + Fixture.create<MasterScopeTester> (MasterScopeTester.test_overridden_subscopes)); |
506 | Test.add_data_func ("/Unit/MasterScope/ProgressSourceProperty", |
507 | Fixture.create<MasterScopeTester> (MasterScopeTester.test_progress_source_property)); |
508 | Test.add_data_func ("/Unit/AggregatorScope/CategoryOrderSignal", |
509 | @@ -1413,22 +1415,24 @@ |
510 | } |
511 | } |
512 | |
513 | - public static bool own_bus_name (out uint owning_id) |
514 | + public static uint own_bus_name (string name = DBUS_NAME) |
515 | { |
516 | - bool name_owned = false; |
517 | + bool dbus_name_owned = false; |
518 | + uint owning_id; |
519 | var ml = new MainLoop (); |
520 | // register us a name on the bus |
521 | - owning_id = Bus.own_name (BusType.SESSION, DBUS_NAME, 0, |
522 | + owning_id = Bus.own_name (BusType.SESSION, name, 0, |
523 | () => {}, |
524 | - () => { name_owned = true; ml.quit (); }, |
525 | + () => { dbus_name_owned = true; ml.quit (); }, |
526 | () => { ml.quit (); }); |
527 | ml.run (); |
528 | - return name_owned; |
529 | + assert (dbus_name_owned == true); |
530 | + return owning_id; |
531 | } |
532 | |
533 | private void setup () |
534 | { |
535 | - assert (own_bus_name (out owning_id)); |
536 | + owning_id = own_bus_name (); |
537 | master_scope = new Unity.MasterScope (MASTER_SCOPE_DBUS_PATH, |
538 | "test_masterscope.scope"); |
539 | master_scope.search_hint = "Master search hint"; |
540 | @@ -1975,8 +1979,6 @@ |
541 | |
542 | public void test_subscopes_filter_hint () |
543 | { |
544 | - assert (proxy != null); |
545 | - |
546 | Dee.SerializableModel model; |
547 | var channel_id = ScopeTester.open_channel (proxy, ChannelType.DEFAULT, out model); |
548 | assert (channel_id != null); |
549 | @@ -1994,8 +1996,6 @@ |
550 | |
551 | public void test_push_results () |
552 | { |
553 | - assert (proxy != null); |
554 | - |
555 | Dee.SerializableModel model; |
556 | var channel_id = ScopeTester.open_channel (proxy, ChannelType.DEFAULT, out model); |
557 | assert (channel_id != null); |
558 | @@ -2019,8 +2019,6 @@ |
559 | |
560 | public void test_push_results_and_search () |
561 | { |
562 | - assert (proxy != null); |
563 | - |
564 | Dee.SerializableModel model; |
565 | var channel_id = ScopeTester.open_channel (proxy, ChannelType.DEFAULT, out model); |
566 | assert (channel_id != null); |
567 | @@ -2065,8 +2063,6 @@ |
568 | |
569 | public void test_subscopes_search () |
570 | { |
571 | - assert (proxy != null); |
572 | - |
573 | Dee.SerializableModel model; |
574 | var channel_id = ScopeTester.open_channel (proxy, ChannelType.DEFAULT, out model); |
575 | assert (channel_id != null); |
576 | @@ -2092,6 +2088,49 @@ |
577 | assert (model.get_n_rows () == 1); |
578 | } |
579 | |
580 | + public void test_overridden_subscopes () |
581 | + { |
582 | + const string MASTER_C_DBUS_NAME = "com.canonical.Unity.Scope.MasterC"; |
583 | + const string MASTER_C_DBUS_PATH = "/com/canonical/unity/scope/masterc"; |
584 | + // this master scope will query the one that was prepared in this.setup() |
585 | + // which in turn just queries the ChildScopes, so it's one level up from |
586 | + // all the other master scope tests |
587 | + uint master_own_id = own_bus_name (MASTER_C_DBUS_NAME); |
588 | + var master_c = new Unity.MasterScope (MASTER_C_DBUS_PATH, |
589 | + "masterscope_c.scope"); |
590 | + master_c.search_hint = "Master search hint"; |
591 | + |
592 | + var cats = new Unity.CategorySet (); |
593 | + cats.add (new Unity.Category ("1991", "Unused category", new GLib.ThemedIcon ("text"))); |
594 | + cats.add (new Unity.Category ("1211", "A Category", new GLib.ThemedIcon ("text"))); |
595 | + master_c.categories = cats; |
596 | + |
597 | + try |
598 | + { |
599 | + master_c.export (); |
600 | + } |
601 | + catch (Error err) { assert_not_reached (); } |
602 | + |
603 | + var proxy_c = ScopeInitTester.acquire_test_proxy (MASTER_C_DBUS_PATH, MASTER_C_DBUS_NAME); |
604 | + |
605 | + // setup finished |
606 | + Dee.SerializableModel model; |
607 | + var channel_id = ScopeTester.open_channel (proxy_c, ChannelType.DEFAULT, out model); |
608 | + assert (channel_id != null); |
609 | + |
610 | + var hints = new HashTable<string, Variant> (str_hash, str_equal); |
611 | + var reply_dict = ScopeTester.perform_search (proxy_c, channel_id, "foo", |
612 | + hints, model); |
613 | + |
614 | + assert (reply_dict != null); |
615 | + // standard search, should invoke all subscopes |
616 | + assert (search_handler_invocations == child_scopes.length); |
617 | + assert (model.get_n_rows () == child_scopes.length); |
618 | + |
619 | + master_c.unexport (); |
620 | + if (master_own_id != 0) Bus.unown_name (master_own_id); |
621 | + } |
622 | + |
623 | public void test_progress_source_property () |
624 | { |
625 | Dee.SerializableModel model; |
626 | @@ -2176,7 +2215,7 @@ |
627 | |
628 | private void setup () |
629 | { |
630 | - assert (MasterScopeTester.own_bus_name (out owning_id)); |
631 | + owning_id = MasterScopeTester.own_bus_name (); |
632 | // setup Home Scope |
633 | agg_scope = new AggScope (HOME_SCOPE_DBUS_PATH, "test_homescope.scope"); |
634 | try |
PASSED: Continuous integration, rev:269 jenkins. qa.ubuntu. com/job/ libunity- ci/82/ jenkins. qa.ubuntu. com/job/ libunity- saucy-amd64- ci/67 jenkins. qa.ubuntu. com/job/ libunity- saucy-armhf- ci/67 jenkins. qa.ubuntu. com/job/ libunity- saucy-i386- ci/67
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ libunity- ci/82/rebuild
http://