Merge lp:~unity-api-team/unity-scopes-api/child-scopes-option into lp:unity-scopes-api/devel

Proposed by Paweł Stołowski
Status: Merged
Approved by: Michi Henning
Approved revision: 516
Merged at revision: 514
Proposed branch: lp:~unity-api-team/unity-scopes-api/child-scopes-option
Merge into: lp:unity-scopes-api/devel
Diff against target: 538 lines (+168/-3)
22 files modified
CONFIGFILES (+9/-0)
RELEASE_NOTES.md (+1/-0)
STRUCTS (+1/-0)
debian/changelog (+2/-1)
debian/libunity-scopes3.symbols (+4/-0)
doc/tutorial.dox (+8/-0)
include/unity/scopes/ScopeMetadata.h (+13/-0)
include/unity/scopes/internal/ScopeConfig.h (+2/-0)
include/unity/scopes/internal/ScopeMetadataImpl.h (+3/-0)
scoperegistry/scoperegistry.cpp (+1/-0)
src/scopes/ScopeMetadata.cpp (+5/-0)
src/scopes/internal/ScopeConfig.cpp (+24/-1)
src/scopes/internal/ScopeMetadataImpl.cpp (+31/-0)
test/gtest/scopes/Registry/Registry_test.cpp (+5/-0)
test/gtest/scopes/Registry/scopes/testscopeA/testscopeA.ini.in (+1/-0)
test/gtest/scopes/internal/ScopeConfig/CMakeLists.txt (+6/-0)
test/gtest/scopes/internal/ScopeConfig/ScopeConfig_test.cpp (+31/-0)
test/gtest/scopes/internal/ScopeConfig/bad_child_ids.ini.in (+5/-0)
test/gtest/scopes/internal/ScopeConfig/complete_config.ini.in (+1/-0)
test/gtest/scopes/internal/ScopeConfig/empty_child_ids.ini.in (+5/-0)
test/gtest/scopes/internal/ScopeConfig/single_child_id.ini.in (+5/-0)
test/gtest/scopes/internal/ScopeMetadataImpl/ScopeMetadataImpl_test.cpp (+5/-1)
To merge this branch: bzr merge lp:~unity-api-team/unity-scopes-api/child-scopes-option
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michi Henning (community) Approve
Marcus Tomlinson (community) Needs Fixing
Review via email: mp+236879@code.launchpad.net

Commit message

Added ChildScopes config option to declare ids of aggregated scopes (for aggregators).

Description of the change

Added ChildScopes config option to declare ids of aggregated scopes (for aggregators). This is exposed via ScopeMetadata and will be used by shell plugin.

To post a comment you must log in.
Marcus Tomlinson (marcustomlinson) wrote :

Looks good. Could you just add a short explanation of how to use this field in CONFIGFILES.

review: Needs Fixing
503. By Paweł Stołowski on 2014-10-03

Updated symbols.

504. By Paweł Stołowski on 2014-10-06

Added ChildScopes to CONFFILES.

Michi Henning (michihenning) wrote :

A few comments:

The tutorial needs updating for the new config attribute. It needs to mention that this is an array setting, with semicolon as the separator. It should also say what the attribute is used for. (The scope author needs be aware of the consequences of forgetting to mention a child scope in this list.)

241 + string child_str = parser()->get_string(scope_config_group, child_scope_ids_key);
...
280 +std::vector<std::string> ScopeConfig::parse_scope_ids(std::string const& val)

We don't need this. The IniParser has a method get_string_array() that splits an array attribute into its components automatically. The separator used in .ini files is semicolon (instead of comma). We should use this because it maintains the established syntax for .ini files and also makes all the code in parse_scope_ids() redundant.

It would be good to have test for a zero-element and a single-element array of child scopes too, just to be sure that the code behaves sanely if someone does something silly in their config file.

24 + should be spearated by commas.

There is a typo here: "spearated". Also it needs to say "semicolons" (see above).

Use "must" instead of "should". If we say "should", that suggests that it's OK to use something other than commas. Also, the ini parser preserves whitespace for string array elements, so it would be good to show an example. Something along the lines of:

ChildScopes = com.acme.scopeX;com.acme.scopeY

Somewhat stupidly, the ini parser strips leading whitespace, but not trailing whitespace:

ChildScopes = a;b;c

If there is a single trailing space on that line, the values of the array elements are "a", "b", and "c " :-(

It might be a nice touch to warn about trailing whitespace in the doc.

131 + \brief Return the list of scope identifiers aggregated by this scope.
132 + The list returned by this method comes from the .ini file and it's up

We need a newline after the first sentence, otherwise the entire para becomes part of the summary.

I recommend to avoid contractions ("it's") in the documentation. Contractions are usually shunned in formal documentation. Even better, make it two sentences:

"The list returned by this method is taken from the scope's `.ini` file. The scope author must ensure that it contains all scopes that an aggregator might collect results from."

134 + scopes which are not currently installed and are optional for proper functioning

This should be "scopes *that* are not currently installed" (because this is a defining relative clause.)

review: Needs Fixing
505. By Paweł Stołowski on 2014-10-22

Merged trunk.

506. By Paweł Stołowski on 2014-10-22

Use built-in array support from ini parser.

507. By Paweł Stołowski on 2014-10-22

Updated docs.

508. By Paweł Stołowski on 2014-10-22

Added test for empty ChildScopes value.

509. By Paweł Stołowski on 2014-10-22

Added test for single child.

510. By Paweł Stołowski on 2014-10-22

Minor doc update.y

511. By Paweł Stołowski on 2014-10-22

Removed empty lines.

512. By Paweł Stołowski on 2014-10-22

Merged devel.

513. By Paweł Stołowski on 2014-10-22

Fix test.

514. By Paweł Stołowski on 2014-10-22

Updated symbols.

515. By Paweł Stołowski on 2014-10-23

Merged devel.

516. By Paweł Stołowski on 2014-10-24

Fixed typo in tutorial.

Michi Henning (michihenning) wrote :

LGTM, thanks!

review: Approve
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CONFIGFILES'
2--- CONFIGFILES 2014-10-10 07:01:36 +0000
3+++ CONFIGFILES 2014-10-24 15:41:48 +0000
4@@ -327,6 +327,15 @@
5
6 The hot key for the scope. The default value is the empty string.
7
8+- ChildScopes
9+
10+ The list of ids of scopes aggregated by this scope (if any). The values in this list
11+ must be separated by semicolons. This list is translated to the names of
12+ children scopes when in the scopes overview page of the Unity Dash.
13+
14+ Note: make sure there are no trailing spaces following
15+ the ids, as they will be preserved.
16+
17 - Invisible
18
19 Whether the scope is hidden in the UI. The default value is false.
20
21=== modified file 'RELEASE_NOTES.md'
22--- RELEASE_NOTES.md 2014-10-22 15:46:36 +0000
23+++ RELEASE_NOTES.md 2014-10-24 15:41:48 +0000
24@@ -3,6 +3,7 @@
25
26 Changes in version 0.6.8
27 ========================
28+ - Added support for ChildScopes scope .ini option to list scopes ids of aggregated scopes.
29 - Replaced dbus-send with "list updated" pub/sub to invalidate smart scopes.
30
31 Changes in version 0.6.7
32
33=== modified file 'STRUCTS'
34--- STRUCTS 2014-09-25 08:33:58 +0000
35+++ STRUCTS 2014-10-24 15:41:48 +0000
36@@ -77,6 +77,7 @@
37 'results_ttl_type' : int, optional
38 'settings_definitions' : dictionary, optional
39 'location_data_needed' : bool, optional
40+ 'child_scopes' : array of strings, optional
41
42 Query (returned by serialize())
43 ===============================
44
45=== modified file 'debian/changelog'
46--- debian/changelog 2014-10-22 23:06:48 +0000
47+++ debian/changelog 2014-10-24 15:41:48 +0000
48@@ -1,8 +1,9 @@
49 unity-scopes-api (0.6.8-0ubuntu1) UNRELEASED; urgency=medium
50
51+ * Added support for ChildScopes scope .ini option.
52 * Replaced dbus-send with "list updated" pub/sub to invalidate smart scopes.
53
54- -- Marcus Tomlinson <marcus.tomlinson@canonical.com> Wed, 22 Oct 2014 17:44:46 +0200
55+ -- Pawel Stolowski <pawel.stolowski@ubuntu.com> Wed, 22 Oct 2014 12:00:44 -0400
56
57 unity-scopes-api (0.6.7+14.10.20141014-0ubuntu1) 14.09; urgency=low
58
59
60=== modified file 'debian/libunity-scopes3.symbols'
61--- debian/libunity-scopes3.symbols 2014-10-22 19:42:17 +0000
62+++ debian/libunity-scopes3.symbols 2014-10-24 15:41:48 +0000
63@@ -437,6 +437,7 @@
64 (c++)"unity::scopes::internal::ScopeConfig::appearance_attributes() const@Base" 0.4.2+14.04.20140404.2
65 (c++)"unity::scopes::internal::ScopeConfig::art() const@Base" 0.4.0+14.04.20140312.1
66 (c++)"unity::scopes::internal::ScopeConfig::author() const@Base" 0.4.0+14.04.20140312.1
67+ (c++)"unity::scopes::internal::ScopeConfig::child_scope_ids() const@Base" 0replaceme
68 (c++)"unity::scopes::internal::ScopeConfig::debug_mode() const@Base" 0.6.2+rtm+rtm+rtm+14.09.20140818
69 (c++)"unity::scopes::internal::ScopeConfig::description() const@Base" 0.4.0+14.04.20140312.1
70 (c++)"unity::scopes::internal::ScopeConfig::display_name() const@Base" 0.4.0+14.04.20140312.1
71@@ -475,6 +476,7 @@
72 (c++)"unity::scopes::internal::ScopeMetadataImpl::appearance_attributes() const@Base" 0.4.2+14.04.20140404.2
73 (c++)"unity::scopes::internal::ScopeMetadataImpl::art() const@Base" 0.4.0+14.04.20140312.1
74 (c++)"unity::scopes::internal::ScopeMetadataImpl::author() const@Base" 0.4.0+14.04.20140312.1
75+ (c++)"unity::scopes::internal::ScopeMetadataImpl::child_scope_ids() const@Base" 0replaceme
76 (c++)"unity::scopes::internal::ScopeMetadataImpl::create(std::unique_ptr<unity::scopes::internal::ScopeMetadataImpl, std::default_delete<unity::scopes::internal::ScopeMetadataImpl> >)@Base" 0.4.0+14.04.20140312.1
77 (c++)"unity::scopes::internal::ScopeMetadataImpl::description() const@Base" 0.4.0+14.04.20140312.1
78 (c++)"unity::scopes::internal::ScopeMetadataImpl::deserialize(std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unity::scopes::Variant, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, unity::scopes::Variant> > > const&)@Base" 0.4.0+14.04.20140312.1
79@@ -496,6 +498,7 @@
80 (c++)"unity::scopes::internal::ScopeMetadataImpl::set_appearance_attributes(std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unity::scopes::Variant, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, unity::scopes::Variant> > > const&)@Base" 0.4.2+14.04.20140404.2
81 (c++)"unity::scopes::internal::ScopeMetadataImpl::set_art(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1
82 (c++)"unity::scopes::internal::ScopeMetadataImpl::set_author(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1
83+ (c++)"unity::scopes::internal::ScopeMetadataImpl::set_child_scope_ids(std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)@Base" 0replaceme
84 (c++)"unity::scopes::internal::ScopeMetadataImpl::set_description(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1
85 (c++)"unity::scopes::internal::ScopeMetadataImpl::set_display_name(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1
86 (c++)"unity::scopes::internal::ScopeMetadataImpl::set_hot_key(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1
87@@ -756,6 +759,7 @@
88 (c++)"unity::scopes::ScopeMetadata::appearance_attributes() const@Base" 0.4.2+14.04.20140404.2
89 (c++)"unity::scopes::ScopeMetadata::art() const@Base" 0.4.0+14.04.20140312.1
90 (c++)"unity::scopes::ScopeMetadata::author() const@Base" 0.4.0+14.04.20140312.1
91+ (c++)"unity::scopes::ScopeMetadata::child_scope_ids() const@Base" 0replaceme
92 (c++)"unity::scopes::ScopeMetadata::description() const@Base" 0.4.0+14.04.20140312.1
93 (c++)"unity::scopes::ScopeMetadata::display_name() const@Base" 0.4.0+14.04.20140312.1
94 (c++)"unity::scopes::ScopeMetadata::hot_key() const@Base" 0.4.0+14.04.20140312.1
95
96=== modified file 'doc/tutorial.dox'
97--- doc/tutorial.dox 2014-09-15 12:43:47 +0000
98+++ doc/tutorial.dox 2014-10-24 15:41:48 +0000
99@@ -1032,6 +1032,7 @@
100 SearchHint = hint text displayed to user when viewing scope
101 HotKey =
102 ResultsTtlType = None, Small, Medium, or Large
103+ ChildScopes =
104
105 [Appearance]
106 ForegroundColor = default text color (defaults to theme-provided foreground color)
107@@ -1065,6 +1066,13 @@
108 <li>http://remote-server.com/path/to/image</li>
109 </ul>
110
111+The value of `ChildScopes` key is to be used by aggregator scopes. It must be a semicolon separated list of scope identifiers that
112+might be aggregated by this scope, for example:
113+
114+`ChildScopes = com.foo.bar;com.foo.bar2`
115+
116+This list of scopes is translated to the names of children scopes when in the scopes overview page of the Unity Dash.
117+
118 \subsection scopetool The scope tool
119
120 The Unity Scope Tool is a stand-alone redering tool that allows you
121
122=== modified file 'include/unity/scopes/ScopeMetadata.h'
123--- include/unity/scopes/ScopeMetadata.h 2014-08-12 09:38:31 +0000
124+++ include/unity/scopes/ScopeMetadata.h 2014-10-24 15:41:48 +0000
125@@ -20,6 +20,7 @@
126 #define UNITY_SCOPES_SCOPEMETADATA_H
127
128 #include <unity/scopes/Scope.h>
129+#include <vector>
130
131 namespace unity
132 {
133@@ -183,6 +184,18 @@
134 */
135 bool location_data_needed() const; // optional (default = false)
136
137+ /**
138+ \brief Return the list of scope identifiers aggregated by this scope.
139+
140+ The list returned by this method comes from the .ini file.
141+ The scope author must ensure that it contains all scopes that an aggregator
142+ might collect results from. This list may contain scopes that are not currently
143+ installed and are optional for proper functioning of the aggregator scope.
144+
145+ \return The list of scopes ids aggregated by this scope.
146+ */
147+ std::vector<std::string> child_scope_ids() const;
148+
149 private:
150 ScopeMetadata(std::unique_ptr<internal::ScopeMetadataImpl>); // Instantiable only by ScopeMetadataImpl
151 std::unique_ptr<internal::ScopeMetadataImpl> p;
152
153=== modified file 'include/unity/scopes/internal/ScopeConfig.h'
154--- include/unity/scopes/internal/ScopeConfig.h 2014-08-11 12:08:44 +0000
155+++ include/unity/scopes/internal/ScopeConfig.h 2014-10-24 15:41:48 +0000
156@@ -53,6 +53,7 @@
157 int idle_timeout() const; // Optional, returns default value if not present
158 ScopeMetadata::ResultsTtlType results_ttl_type() const; // Optional, returns none if not present
159 bool debug_mode() const; // Optional, returns false if not present
160+ std::vector<std::string> child_scope_ids() const;
161
162 VariantMap appearance_attributes() const; // Optional, returns empty map if no attributes are present
163
164@@ -73,6 +74,7 @@
165 int idle_timeout_;
166 ScopeMetadata::ResultsTtlType results_ttl_type_;
167 bool debug_mode_;
168+ std::vector<std::string> child_scope_ids_;
169
170 VariantMap appearance_attributes_;
171 };
172
173=== modified file 'include/unity/scopes/internal/ScopeMetadataImpl.h'
174--- include/unity/scopes/internal/ScopeMetadataImpl.h 2014-08-12 09:38:31 +0000
175+++ include/unity/scopes/internal/ScopeMetadataImpl.h 2014-10-24 15:41:48 +0000
176@@ -58,6 +58,7 @@
177 ScopeMetadata::ResultsTtlType results_ttl_type() const; // optional (default: none)
178 VariantArray settings_definitions() const; // optional (default: empty array)
179 bool location_data_needed() const; // optional (default: false)
180+ std::vector<std::string> child_scope_ids() const; // optional (default: empty array)
181
182 void set_scope_id(std::string const& scope_id);
183 void set_proxy(ScopeProxy const& proxy);
184@@ -74,6 +75,7 @@
185 void set_results_ttl_type(ScopeMetadata::ResultsTtlType results_ttl);
186 void set_settings_definitions(VariantArray const& settings_definitions);
187 void set_location_data_needed(bool location_data_needed);
188+ void set_child_scope_ids(std::vector<std::string> const& ids);
189
190 VariantMap serialize() const;
191 void deserialize(VariantMap const& var);
192@@ -98,6 +100,7 @@
193 ScopeMetadata::ResultsTtlType results_ttl_type_;
194 std::unique_ptr<VariantArray> settings_definitions_; // Optional, hence a pointer
195 std::unique_ptr<bool> location_data_needed_; // Optional, hence a pointer
196+ std::vector<std::string> child_scope_ids_;
197 };
198
199 } // namespace internal
200
201=== modified file 'scoperegistry/scoperegistry.cpp'
202--- scoperegistry/scoperegistry.cpp 2014-10-16 13:31:25 +0000
203+++ scoperegistry/scoperegistry.cpp 2014-10-24 15:41:48 +0000
204@@ -315,6 +315,7 @@
205 mi->set_author(sc.author());
206 mi->set_invisible(sc.invisible());
207 mi->set_appearance_attributes(sc.appearance_attributes());
208+ mi->set_child_scope_ids(sc.child_scope_ids());
209
210 // Prepend scope_dir to pageheader logo path if logo path is relative.
211 // TODO: Once we have type-safe parsing in the config files, remove
212
213=== modified file 'src/scopes/ScopeMetadata.cpp'
214--- src/scopes/ScopeMetadata.cpp 2014-08-12 09:38:31 +0000
215+++ src/scopes/ScopeMetadata.cpp 2014-10-24 15:41:48 +0000
216@@ -147,6 +147,11 @@
217 return p->location_data_needed();
218 }
219
220+std::vector<std::string> ScopeMetadata::child_scope_ids() const
221+{
222+ return p->child_scope_ids();
223+}
224+
225 //! @endcond
226
227 } // namespace scopes
228
229=== modified file 'src/scopes/internal/ScopeConfig.cpp'
230--- src/scopes/internal/ScopeConfig.cpp 2014-08-11 12:08:44 +0000
231+++ src/scopes/internal/ScopeConfig.cpp 2014-10-24 15:41:48 +0000
232@@ -56,6 +56,7 @@
233 const string idle_timeout_key = "IdleTimeout";
234 const string results_ttl_key = "ResultsTtlType";
235 const string debug_mode_key = "DebugMode";
236+ const string child_scope_ids_key = "ChildScopes";
237
238 const string scope_appearance_group = "Appearance";
239 const string fg_color_key = "ForegroundColor";
240@@ -192,6 +193,22 @@
241
242 try
243 {
244+ child_scope_ids_ = parser()->get_string_array(scope_config_group, child_scope_ids_key);
245+ }
246+ catch (LogicException const&)
247+ {
248+ }
249+
250+ for (auto const& id: child_scope_ids_)
251+ {
252+ if (id.size() == 0)
253+ {
254+ throw_ex("Invalid empty scope id for ChildScopes");
255+ }
256+ }
257+
258+ try
259+ {
260 debug_mode_ = parser()->get_boolean(scope_config_group, debug_mode_key);
261 }
262 catch (LogicException const&)
263@@ -227,7 +244,8 @@
264 scoperunner_key,
265 idle_timeout_key,
266 results_ttl_key,
267- debug_mode_key
268+ debug_mode_key,
269+ child_scope_ids_key
270 }
271 },
272 { scope_appearance_group,
273@@ -401,6 +419,11 @@
274 return appearance_attributes_;
275 }
276
277+std::vector<std::string> ScopeConfig::child_scope_ids() const
278+{
279+ return child_scope_ids_;
280+}
281+
282 } // namespace internal
283
284 } // namespace scopes
285
286=== modified file 'src/scopes/internal/ScopeMetadataImpl.cpp'
287--- src/scopes/internal/ScopeMetadataImpl.cpp 2014-08-18 08:12:22 +0000
288+++ src/scopes/internal/ScopeMetadataImpl.cpp 2014-10-24 15:41:48 +0000
289@@ -57,6 +57,7 @@
290 , author_(other.author_)
291 , appearance_attributes_(other.appearance_attributes_)
292 , results_ttl_type_(other.results_ttl_type_)
293+ , child_scope_ids_(other.child_scope_ids_)
294 {
295 if (other.art_)
296 {
297@@ -112,6 +113,7 @@
298 results_ttl_type_ = rhs.results_ttl_type_;
299 settings_definitions_.reset(rhs.settings_definitions_ ? new VariantArray(*rhs.settings_definitions_) : nullptr);
300 location_data_needed_.reset(rhs.location_data_needed_ ? new bool(*rhs.location_data_needed_) : nullptr);
301+ child_scope_ids_ = rhs.child_scope_ids_;
302 }
303 return *this;
304 }
305@@ -223,6 +225,11 @@
306 return false;
307 }
308
309+std::vector<std::string> ScopeMetadataImpl::child_scope_ids() const
310+{
311+ return child_scope_ids_;
312+}
313+
314 void ScopeMetadataImpl::set_scope_id(std::string const& scope_id)
315 {
316 scope_id_ = scope_id;
317@@ -298,6 +305,11 @@
318 location_data_needed_.reset(new bool(location_data_needed));
319 }
320
321+void ScopeMetadataImpl::set_child_scope_ids(std::vector<std::string> const& ids)
322+{
323+ child_scope_ids_ = ids;
324+}
325+
326 namespace
327 {
328
329@@ -373,6 +385,15 @@
330 {
331 var["location_data_needed"] = *location_data_needed_;
332 }
333+ if (child_scope_ids_.size())
334+ {
335+ VariantArray va;
336+ for (auto const& sid: child_scope_ids_)
337+ {
338+ va.push_back(Variant(sid));
339+ }
340+ var["child_scopes"] = Variant(va);
341+ }
342
343 return var;
344 }
345@@ -494,6 +515,16 @@
346 {
347 location_data_needed_.reset(new bool(it->second.get_bool()));
348 }
349+
350+ child_scope_ids_.clear();
351+ it = var.find("child_scopes");
352+ if (it != var.end())
353+ {
354+ for (auto const& v: it->second.get_array())
355+ {
356+ child_scope_ids_.push_back(v.get_string());
357+ }
358+ }
359 }
360
361 ScopeMetadata ScopeMetadataImpl::create(unique_ptr<ScopeMetadataImpl> impl)
362
363=== modified file 'test/gtest/scopes/Registry/Registry_test.cpp'
364--- test/gtest/scopes/Registry/Registry_test.cpp 2014-09-23 08:33:51 +0000
365+++ test/gtest/scopes/Registry/Registry_test.cpp 2014-10-24 15:41:48 +0000
366@@ -104,6 +104,10 @@
367 EXPECT_EQ("boolean", defs[1].get_dict()["type"].get_string());
368 EXPECT_EQ(true, defs[1].get_dict()["defaultValue"].get_bool());
369 EXPECT_TRUE(meta.location_data_needed());
370+ auto children = meta.child_scope_ids();
371+ EXPECT_EQ(2u, children.size());
372+ EXPECT_EQ("com.foo.bar", children[0]);
373+ EXPECT_EQ("com.foo.baz", children[1]);
374
375 auto attrs = meta.appearance_attributes();
376 EXPECT_EQ("fg_color", attrs["foreground-color"].get_string());
377@@ -134,6 +138,7 @@
378 defs = meta.settings_definitions();
379 EXPECT_EQ(0, defs.size());
380 EXPECT_FALSE(meta.location_data_needed());
381+ EXPECT_EQ(0, meta.child_scope_ids().size());
382 }
383
384 auto const wait_time = std::chrono::milliseconds(1000);
385
386=== modified file 'test/gtest/scopes/Registry/scopes/testscopeA/testscopeA.ini.in'
387--- test/gtest/scopes/Registry/scopes/testscopeA/testscopeA.ini.in 2014-07-24 13:08:48 +0000
388+++ test/gtest/scopes/Registry/scopes/testscopeA/testscopeA.ini.in 2014-10-24 15:41:48 +0000
389@@ -7,6 +7,7 @@
390 SearchHint = scope-A.SearchHint
391 HotKey = scope-A.HotKey
392 LocationDataNeeded = true
393+ChildScopes = com.foo.bar;com.foo.baz
394
395 [Appearance]
396 ForegroundColor = fg_color
397
398=== modified file 'test/gtest/scopes/internal/ScopeConfig/CMakeLists.txt'
399--- test/gtest/scopes/internal/ScopeConfig/CMakeLists.txt 2014-07-22 08:02:32 +0000
400+++ test/gtest/scopes/internal/ScopeConfig/CMakeLists.txt 2014-10-24 15:41:48 +0000
401@@ -4,12 +4,18 @@
402 configure_file(ttl_medium.ini.in ttl_medium.ini copyonly)
403 configure_file(bad_timeout.ini.in bad_timeout.ini copyonly)
404 configure_file(bad_ttl.ini.in bad_ttl.ini copyonly)
405+configure_file(bad_child_ids.ini.in bad_child_ids.ini copyonly)
406+configure_file(empty_child_ids.ini.in empty_child_ids.ini copyonly)
407+configure_file(single_child_id.ini.in single_child_id.ini copyonly)
408
409 add_definitions(-DCOMPLETE_CONFIG="${CMAKE_CURRENT_BINARY_DIR}/complete_config.ini")
410 add_definitions(-DMANDATORY_CONFIG="${CMAKE_CURRENT_BINARY_DIR}/mandatory_config.ini")
411 add_definitions(-DTTL_SMALL="${CMAKE_CURRENT_BINARY_DIR}/ttl_small.ini")
412 add_definitions(-DTTL_MEDIUM="${CMAKE_CURRENT_BINARY_DIR}/ttl_medium.ini")
413 add_definitions(-DBAD_TIMEOUT="${CMAKE_CURRENT_BINARY_DIR}/bad_timeout.ini")
414+add_definitions(-DBAD_CHILD_IDS="${CMAKE_CURRENT_BINARY_DIR}/bad_child_ids.ini")
415+add_definitions(-DEMPTY_CHILD_IDS="${CMAKE_CURRENT_BINARY_DIR}/empty_child_ids.ini")
416+add_definitions(-DSINGLE_CHILD_ID="${CMAKE_CURRENT_BINARY_DIR}/single_child_id.ini")
417 add_definitions(-DBAD_TTL="${CMAKE_CURRENT_BINARY_DIR}/bad_ttl.ini")
418
419 add_executable(ScopeConfig_test ScopeConfig_test.cpp)
420
421=== modified file 'test/gtest/scopes/internal/ScopeConfig/ScopeConfig_test.cpp'
422--- test/gtest/scopes/internal/ScopeConfig/ScopeConfig_test.cpp 2014-08-28 00:20:56 +0000
423+++ test/gtest/scopes/internal/ScopeConfig/ScopeConfig_test.cpp 2014-10-24 15:41:48 +0000
424@@ -61,6 +61,12 @@
425 EXPECT_EQ("second", attrs["logo"].get_dict()["two"].get_string());
426 EXPECT_EQ("abc", attrs["page"].get_dict()["page-header"].get_dict()["logo"].get_string());
427 EXPECT_EQ("def", attrs["page"].get_dict()["page-header"].get_dict()["logo2"].get_string());
428+
429+ auto children = cfg.child_scope_ids();
430+ EXPECT_EQ(3u, children.size());
431+ EXPECT_EQ("com.foo.bar", children[0]);
432+ EXPECT_EQ("com.foo.bar2", children[1]);
433+ EXPECT_EQ("com.foo.boo", children[2]);
434 }
435
436 {
437@@ -103,6 +109,31 @@
438 }
439 }
440
441+TEST(ScopeConfig, bad_child_scope_ids)
442+{
443+ try
444+ {
445+ ScopeConfig cfg(BAD_CHILD_IDS);
446+ }
447+ catch(ConfigException const& e)
448+ {
449+ boost::regex r("unity::scopes::ConfigException: \".*\": Invalid empty scope id for ChildScopes");
450+ EXPECT_TRUE(boost::regex_match(e.what(), r));
451+ }
452+}
453+
454+TEST(ScopeConfig, empty_scope_ids)
455+{
456+ ScopeConfig cfg(EMPTY_CHILD_IDS);
457+ EXPECT_EQ(cfg.child_scope_ids().size(), 0);
458+}
459+
460+TEST(ScopeConfig, single_scope_id)
461+{
462+ ScopeConfig cfg(SINGLE_CHILD_ID);
463+ EXPECT_EQ(cfg.child_scope_ids().size(), 1);
464+}
465+
466 TEST(ScopeConfig, bad_timeout)
467 {
468 try
469
470=== added file 'test/gtest/scopes/internal/ScopeConfig/bad_child_ids.ini.in'
471--- test/gtest/scopes/internal/ScopeConfig/bad_child_ids.ini.in 1970-01-01 00:00:00 +0000
472+++ test/gtest/scopes/internal/ScopeConfig/bad_child_ids.ini.in 2014-10-24 15:41:48 +0000
473@@ -0,0 +1,5 @@
474+[ScopeConfig]
475+DisplayName = Scope name
476+Description = Scope description
477+Author = Canonical
478+ChildScopes = com.foo.bar;;
479
480=== modified file 'test/gtest/scopes/internal/ScopeConfig/complete_config.ini.in'
481--- test/gtest/scopes/internal/ScopeConfig/complete_config.ini.in 2014-08-11 13:12:59 +0000
482+++ test/gtest/scopes/internal/ScopeConfig/complete_config.ini.in 2014-10-24 15:41:48 +0000
483@@ -17,6 +17,7 @@
484 LocationDataNeeded = true
485 ConfinementType = unconfined
486 DebugMode = true
487+ChildScopes = com.foo.bar;com.foo.bar2;com.foo.boo
488
489 [Appearance]
490 arbitrary_key = true
491
492=== added file 'test/gtest/scopes/internal/ScopeConfig/empty_child_ids.ini.in'
493--- test/gtest/scopes/internal/ScopeConfig/empty_child_ids.ini.in 1970-01-01 00:00:00 +0000
494+++ test/gtest/scopes/internal/ScopeConfig/empty_child_ids.ini.in 2014-10-24 15:41:48 +0000
495@@ -0,0 +1,5 @@
496+[ScopeConfig]
497+DisplayName = Scope name
498+Description = Scope description
499+Author = Canonical
500+ChildScopes =
501
502=== added file 'test/gtest/scopes/internal/ScopeConfig/single_child_id.ini.in'
503--- test/gtest/scopes/internal/ScopeConfig/single_child_id.ini.in 1970-01-01 00:00:00 +0000
504+++ test/gtest/scopes/internal/ScopeConfig/single_child_id.ini.in 2014-10-24 15:41:48 +0000
505@@ -0,0 +1,5 @@
506+[ScopeConfig]
507+DisplayName = Scope name
508+Description = Scope description
509+Author = Canonical
510+ChildScopes = com.foo.bar
511
512=== modified file 'test/gtest/scopes/internal/ScopeMetadataImpl/ScopeMetadataImpl_test.cpp'
513--- test/gtest/scopes/internal/ScopeMetadataImpl/ScopeMetadataImpl_test.cpp 2014-08-28 00:20:56 +0000
514+++ test/gtest/scopes/internal/ScopeMetadataImpl/ScopeMetadataImpl_test.cpp 2014-10-24 15:41:48 +0000
515@@ -294,11 +294,12 @@
516 va.push_back(Variant("world"));
517 mi->set_settings_definitions(va);
518 mi->set_location_data_needed(false);
519+ mi->set_child_scope_ids({"com.foo.bar", "com.foo.baz"});
520
521 // Check that serialize() sets the map values correctly
522 auto m = ScopeMetadataImpl::create(move(mi));
523 auto var = m.serialize();
524- EXPECT_EQ(14u, var.size());
525+ EXPECT_EQ(15u, var.size());
526 EXPECT_EQ("scope_id", var["scope_id"].get_string());
527 EXPECT_EQ("display_name", var["display_name"].get_string());
528 EXPECT_EQ("description", var["description"].get_string());
529@@ -314,6 +315,9 @@
530 EXPECT_FALSE(var["invisible"].get_bool());
531 EXPECT_EQ(va, var["settings_definitions"].get_array());
532 EXPECT_FALSE(var["location_data_needed"].get_bool());
533+ EXPECT_EQ(2u, var["child_scopes"].get_array().size());
534+ EXPECT_EQ("com.foo.bar", var["child_scopes"].get_array()[0].get_string());
535+ EXPECT_EQ("com.foo.baz", var["child_scopes"].get_array()[1].get_string());
536
537 // Make another instance from the VariantMap and check its fields
538 ScopeMetadataImpl c(var, &mw);

Subscribers

People subscribed via source and target branches

to all changes: