Merge lp:~stolowski/unity-scopes-api/child-scopes-rtm into lp:unity-scopes-api/rtm-14.09

Proposed by Paweł Stołowski
Status: Merged
Approved by: Michał Sawicz
Approved revision: 252
Merged at revision: 251
Proposed branch: lp:~stolowski/unity-scopes-api/child-scopes-rtm
Merge into: lp:unity-scopes-api/rtm-14.09
Diff against target: 553 lines (+176/-3)
23 files modified
CMakeLists.txt (+1/-1)
CONFIGFILES (+9/-0)
RELEASE_NOTES.md (+4/-0)
STRUCTS (+1/-0)
debian/changelog (+6/-0)
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:~stolowski/unity-scopes-api/child-scopes-rtm
Reviewer Review Type Date Requested Status
Michał Sawicz Approve
Review via email: mp+244575@code.launchpad.net

Commit message

Added support for ChildScopes scope .ini option (cherry picked trunk rev. 163.337.2)
and bumped API and package version.

Description of the change

Added support for ChildScopes scope .ini option (cherry picked trunk rev. 163.337.2)
and bumped API and package version.

To post a comment you must log in.
252. By Paweł Stołowski on 2014-12-12

Fixed RELEASE NOTES version

Michał Sawicz (saviq) wrote :

As per upstream change.

review: Approve

Preview Diff

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

Subscribers

People subscribed via source and target branches

to all changes: