Merge lp:~marcustomlinson/unity-scopes-api/metadata_tags_attr into lp:unity-scopes-api/devel

Proposed by Marcus Tomlinson
Status: Merged
Approved by: Michi Henning
Approved revision: 543
Merged at revision: 537
Proposed branch: lp:~marcustomlinson/unity-scopes-api/metadata_tags_attr
Merge into: lp:unity-scopes-api/devel
Diff against target: 747 lines (+222/-4)
30 files modified
CONFIGFILES (+8/-0)
RELEASE_NOTES.md (+1/-0)
STRUCTS (+1/-0)
debian/changelog (+4/-1)
debian/libunity-scopes3.symbols (+5/-0)
doc/tutorial.dox (+5/-0)
include/unity/scopes/ScopeMetadata.h (+10/-0)
include/unity/scopes/internal/ScopeConfig.h (+3/-1)
include/unity/scopes/internal/ScopeMetadataImpl.h (+3/-0)
include/unity/scopes/internal/smartscopes/SmartScopesClient.h (+1/-0)
include/unity/scopes/testing/ScopeMetadataBuilder.h (+1/-0)
scoperegistry/scoperegistry.cpp (+1/-0)
src/scopes/ScopeMetadata.cpp (+5/-0)
src/scopes/internal/ScopeConfig.cpp (+22/-0)
src/scopes/internal/ScopeMetadataImpl.cpp (+31/-0)
src/scopes/internal/smartscopes/SSRegistryObject.cpp (+2/-0)
src/scopes/internal/smartscopes/SmartScopesClient.cpp (+26/-0)
src/scopes/testing/ScopeMetadataBuilder.cpp (+9/-0)
test/gtest/scopes/Registry/Registry_test.cpp (+6/-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 (+30/-0)
test/gtest/scopes/internal/ScopeConfig/bad_tags.ini.in (+5/-0)
test/gtest/scopes/internal/ScopeConfig/complete_config.ini.in (+1/-0)
test/gtest/scopes/internal/ScopeConfig/empty_tags.ini.in (+5/-0)
test/gtest/scopes/internal/ScopeConfig/single_tag.ini.in (+5/-0)
test/gtest/scopes/internal/ScopeMetadataImpl/ScopeMetadataImpl_test.cpp (+12/-1)
test/gtest/scopes/internal/smartscopes/SmartScopesClient/FakeSss.py (+1/-1)
test/gtest/scopes/internal/smartscopes/SmartScopesClient/SmartScopesClient_test.cpp (+7/-0)
test/gtest/scopes/internal/smartscopes/smartscopesproxy/smartscopesproxy_test.cpp (+5/-0)
To merge this branch: bzr merge lp:~marcustomlinson/unity-scopes-api/metadata_tags_attr
Reviewer Review Type Date Requested Status
Michi Henning (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+242882@code.launchpad.net

Commit message

Added support for 'Tags' scope .ini option.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
543. By Marcus Tomlinson

Added missing symbol

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michi Henning (michihenning) wrote :

Looks good and very thorough, thanks!

My only comment: we probably need a public list of tags that are used. It's no good if each and every scope invents its own tags (with possibly different spelling).

What would the best place for this be? The doxygen doc, I would think?

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CONFIGFILES'
2--- CONFIGFILES 2014-11-13 00:28:01 +0000
3+++ CONFIGFILES 2014-11-27 05:38:38 +0000
4@@ -403,6 +403,14 @@
5
6 If not set, the default value is false.
7
8+- Tags
9+
10+ A list of tags this scope falls under (if any). The values in this list must be separated by semicolons.
11+
12+ E.g. "Tags = music;video"
13+
14+ Note: make sure there are no trailing spaces following the tags, as they will be preserved.
15+
16
17 The following keys are recognized in the Appearance group:
18
19
20=== modified file 'RELEASE_NOTES.md'
21--- RELEASE_NOTES.md 2014-11-21 09:59:33 +0000
22+++ RELEASE_NOTES.md 2014-11-27 05:38:38 +0000
23@@ -11,6 +11,7 @@
24 not vice versa).
25 - Added missing methods for settings_definitions(), location_data_needed(),
26 and child_scope_ids() to testing::ScopeMetadataBuilder.
27+ - Added support for Tags scope .ini option.
28
29 Changes in version 0.6.8
30 ========================
31
32=== modified file 'STRUCTS'
33--- STRUCTS 2014-11-10 03:57:03 +0000
34+++ STRUCTS 2014-11-27 05:38:38 +0000
35@@ -79,6 +79,7 @@
36 'location_data_needed' : bool, optional
37 'child_scopes' : array of strings, optional
38 'version' : int, optional
39+ 'tags' : array of strings, optional
40
41 Query (returned by serialize())
42 ===============================
43
44=== modified file 'debian/changelog'
45--- debian/changelog 2014-11-21 09:59:33 +0000
46+++ debian/changelog 2014-11-27 05:38:38 +0000
47@@ -11,7 +11,10 @@
48 * Added missing methods for settings_definitions(), location_data_needed(),
49 and child_scope_ids() to testing::ScopeMetadataBuilder.
50
51- -- Pawel Stolowski <pawel.stolowski@canonical.com> Fri, 21 Nov 2014 10:56:49 +0100
52+ [ Marcus Tomlinson ]
53+ * Added support for Tags scope .ini option.
54+
55+ -- Marcus Tomlinson <marcus.tomlinson@canonical.com> Wed, 26 Nov 2014 09:36:56 +0200
56
57 unity-scopes-api (0.6.8+15.04.20141119-0ubuntu1) vivid; urgency=medium
58
59
60=== modified file 'debian/libunity-scopes3.symbols'
61--- debian/libunity-scopes3.symbols 2014-11-21 09:59:33 +0000
62+++ debian/libunity-scopes3.symbols 2014-11-27 05:38:38 +0000
63@@ -457,6 +457,7 @@
64 (c++)"unity::scopes::internal::ScopeConfig::ScopeConfig(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1
65 (c++)"unity::scopes::internal::ScopeConfig::scope_runner() const@Base" 0.4.2+14.04.20140404.2
66 (c++)"unity::scopes::internal::ScopeConfig::search_hint() const@Base" 0.4.0+14.04.20140312.1
67+ (c++)"unity::scopes::internal::ScopeConfig::tags() const@Base" 0replaceme
68 (c++)"unity::scopes::internal::ScopeConfig::version() const@Base" 0replaceme
69 (c++)"unity::scopes::internal::ScopeImpl::activate(unity::scopes::Result const&, unity::scopes::ActionMetadata const&, std::shared_ptr<unity::scopes::ActivationListenerBase> const&)@Base" 0.4.0+14.04.20140312.1
70 (c++)"unity::scopes::internal::ScopeImpl::create(std::shared_ptr<unity::scopes::internal::MWScope> const&, unity::scopes::internal::RuntimeImpl*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1
71@@ -516,8 +517,10 @@
72 (c++)"unity::scopes::internal::ScopeMetadataImpl::set_scope_id(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1
73 (c++)"unity::scopes::internal::ScopeMetadataImpl::set_search_hint(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1
74 (c++)"unity::scopes::internal::ScopeMetadataImpl::set_settings_definitions(std::vector<unity::scopes::Variant, std::allocator<unity::scopes::Variant> > const&)@Base" 0.5.2+14.10.20140709.2
75+ (c++)"unity::scopes::internal::ScopeMetadataImpl::set_tags(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
76 (c++)"unity::scopes::internal::ScopeMetadataImpl::settings_definitions() const@Base" 0.5.2+14.10.20140709.2
77 (c++)"unity::scopes::internal::ScopeMetadataImpl::set_version(int)@Base" 0replaceme
78+ (c++)"unity::scopes::internal::ScopeMetadataImpl::tags() const@Base" 0replaceme
79 (c++)"unity::scopes::internal::ScopeMetadataImpl::version() const@Base" 0replaceme
80 (c++)"unity::scopes::internal::ScopeObject::activate(unity::scopes::Result const&, unity::scopes::ActionMetadata const&, std::shared_ptr<unity::scopes::internal::MWReply> const&, unity::scopes::internal::InvokeInfo const&)@Base" 0.4.0+14.04.20140312.1
81 (c++)"unity::scopes::internal::ScopeObject::debug_mode() const@Base" 0.6.2+rtm+rtm+rtm+14.09.20140818
82@@ -787,6 +790,7 @@
83 (c++)"unity::scopes::ScopeMetadata::search_hint() const@Base" 0.4.0+14.04.20140312.1
84 (c++)"unity::scopes::ScopeMetadata::serialize() const@Base" 0.4.0+14.04.20140312.1
85 (c++)"unity::scopes::ScopeMetadata::settings_definitions() const@Base" 0.5.2+14.10.20140709.2
86+ (c++)"unity::scopes::ScopeMetadata::tags() const@Base" 0replaceme
87 (c++)"unity::scopes::ScopeMetadata::version() const@Base" 0replaceme
88 (c++)"unity::scopes::Scope::~Scope()@Base" 0.4.0+14.04.20140312.1
89 (c++)"unity::scopes::Scope::Scope()@Base" 0.4.0+14.04.20140312.1
90@@ -875,6 +879,7 @@
91 (c++)"unity::scopes::testing::ScopeMetadataBuilder::ScopeMetadataBuilder()@Base" 0.4.0+14.04.20140312.1
92 (c++)"unity::scopes::testing::ScopeMetadataBuilder::search_hint(unity::scopes::testing::ScopeMetadataBuilder::Optional<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&)@Base" 0.4.0+14.04.20140312.1
93 (c++)"unity::scopes::testing::ScopeMetadataBuilder::settings_definitions(unity::scopes::testing::ScopeMetadataBuilder::Optional<std::vector<unity::scopes::Variant, std::allocator<unity::scopes::Variant> > > const&)@Base" 0replaceme
94+ (c++)"unity::scopes::testing::ScopeMetadataBuilder::tags(unity::scopes::testing::ScopeMetadataBuilder::Optional<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
95 (c++)"unity::scopes::testing::ScopeMetadataBuilder::version(unity::scopes::testing::ScopeMetadataBuilder::Optional<int> const&)@Base" 0replaceme
96 (c++)"unity::scopes::testing::StudentsTTest::one_sample(unity::scopes::testing::Sample const&, double, double)@Base" 0.4.0+14.04.20140312.1
97 (c++)"unity::scopes::testing::StudentsTTest::Result::~Result()@Base" 0.4.2+14.04.20140404.2
98
99=== modified file 'doc/tutorial.dox'
100--- doc/tutorial.dox 2014-11-13 03:09:45 +0000
101+++ doc/tutorial.dox 2014-11-27 05:38:38 +0000
102@@ -1061,6 +1061,7 @@
103 HotKey =
104 ResultsTtlType = None, Small, Medium, or Large
105 ChildScopes =
106+ Tags =
107
108 [Appearance]
109 ForegroundColor = default text color (defaults to theme-provided foreground color)
110@@ -1108,6 +1109,10 @@
111
112 This list of scopes is translated to the names of children scopes when in the scopes overview page of the Unity Dash.
113
114+The `Tags` key is optional, but we recommend that you use it. Tags are used by aggregators to collect results from scopes of
115+similar type (E.g. The Music scope will aggregate scopes with the tag "music", and so on). The value of `Tags` should specify a
116+list of tags your scope falls under. Like `ChildScopes`, this value must be a semicolon separated list (E.g. `Tags = music;video`).
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-11-10 03:57:03 +0000
124+++ include/unity/scopes/ScopeMetadata.h 2014-11-27 05:38:38 +0000
125@@ -203,6 +203,16 @@
126 */
127 int version() const;
128
129+ /**
130+ \brief Return the list of tags specified by this scope.
131+
132+ The list returned by this method is formulated from the value specified under
133+ the "Tags" key in the scope's .ini file.
134+
135+ \return The list of scope tags specified by this scope.
136+ */
137+ std::vector<std::string> tags() const;
138+
139 private:
140 ScopeMetadata(std::unique_ptr<internal::ScopeMetadataImpl>); // Instantiable only by ScopeMetadataImpl
141 std::unique_ptr<internal::ScopeMetadataImpl> p;
142
143=== modified file 'include/unity/scopes/internal/ScopeConfig.h'
144--- include/unity/scopes/internal/ScopeConfig.h 2014-11-10 03:57:03 +0000
145+++ include/unity/scopes/internal/ScopeConfig.h 2014-11-27 05:38:38 +0000
146@@ -52,8 +52,9 @@
147 int idle_timeout() const; // Optional, returns default value if not present
148 ScopeMetadata::ResultsTtlType results_ttl_type() const; // Optional, returns none if not present
149 bool debug_mode() const; // Optional, returns false if not present
150- std::vector<std::string> child_scope_ids() const;
151+ std::vector<std::string> child_scope_ids() const; // Optional, returns an empty vector if no ids are present
152 int version() const; // Optional, returns 0 if not present
153+ std::vector<std::string> tags() const; // Optional, returns an empty vector if no tags are present
154
155 VariantMap appearance_attributes() const; // Optional, returns empty map if no attributes are present
156
157@@ -76,6 +77,7 @@
158 bool debug_mode_;
159 std::vector<std::string> child_scope_ids_;
160 int version_;
161+ std::vector<std::string> tags_;
162
163 VariantMap appearance_attributes_;
164 };
165
166=== modified file 'include/unity/scopes/internal/ScopeMetadataImpl.h'
167--- include/unity/scopes/internal/ScopeMetadataImpl.h 2014-11-10 03:57:03 +0000
168+++ include/unity/scopes/internal/ScopeMetadataImpl.h 2014-11-27 05:38:38 +0000
169@@ -59,6 +59,7 @@
170 bool location_data_needed() const; // optional (default: false)
171 std::vector<std::string> child_scope_ids() const; // optional (default: empty array)
172 int version() const; // optional (default: 0)
173+ std::vector<std::string> tags() const; // optional (default: empty array)
174
175 void set_scope_id(std::string const& scope_id);
176 void set_proxy(ScopeProxy const& proxy);
177@@ -77,6 +78,7 @@
178 void set_location_data_needed(bool location_data_needed);
179 void set_child_scope_ids(std::vector<std::string> const& ids);
180 void set_version(int v);
181+ void set_tags(std::vector<std::string> const& tags);
182
183 VariantMap serialize() const;
184 void deserialize(VariantMap const& var);
185@@ -103,6 +105,7 @@
186 std::unique_ptr<bool> location_data_needed_; // Optional, hence a pointer
187 std::vector<std::string> child_scope_ids_;
188 int version_;
189+ std::vector<std::string> tags_;
190 };
191
192 } // namespace internal
193
194=== modified file 'include/unity/scopes/internal/smartscopes/SmartScopesClient.h'
195--- include/unity/scopes/internal/smartscopes/SmartScopesClient.h 2014-11-19 13:05:49 +0000
196+++ include/unity/scopes/internal/smartscopes/SmartScopesClient.h 2014-11-27 05:38:38 +0000
197@@ -61,6 +61,7 @@
198 std::shared_ptr<bool> needs_location_data; // optional
199 bool invisible = false;
200 int version;
201+ std::vector<std::string> tags; // optional
202 };
203
204 struct SearchCategory
205
206=== modified file 'include/unity/scopes/testing/ScopeMetadataBuilder.h'
207--- include/unity/scopes/testing/ScopeMetadataBuilder.h 2014-11-12 02:15:46 +0000
208+++ include/unity/scopes/testing/ScopeMetadataBuilder.h 2014-11-27 05:38:38 +0000
209@@ -97,6 +97,7 @@
210 ScopeMetadataBuilder& location_data_needed(Optional<bool> const& value);
211 ScopeMetadataBuilder& child_scope_ids(Optional<std::vector<std::string>> const& value);
212 ScopeMetadataBuilder& version(Optional<int> const& value);
213+ ScopeMetadataBuilder& tags(Optional<std::vector<std::string>> const& value);
214
215 ScopeMetadata operator()() const;
216
217
218=== modified file 'scoperegistry/scoperegistry.cpp'
219--- scoperegistry/scoperegistry.cpp 2014-11-20 03:11:18 +0000
220+++ scoperegistry/scoperegistry.cpp 2014-11-27 05:38:38 +0000
221@@ -319,6 +319,7 @@
222 mi->set_appearance_attributes(sc.appearance_attributes());
223 mi->set_child_scope_ids(sc.child_scope_ids());
224 mi->set_version(sc.version());
225+ mi->set_tags(sc.tags());
226
227 // Prepend scope_dir to pageheader logo path if logo path is relative.
228 // TODO: Once we have type-safe parsing in the config files, remove
229
230=== modified file 'src/scopes/ScopeMetadata.cpp'
231--- src/scopes/ScopeMetadata.cpp 2014-11-10 03:57:03 +0000
232+++ src/scopes/ScopeMetadata.cpp 2014-11-27 05:38:38 +0000
233@@ -157,6 +157,11 @@
234 return p->version();
235 }
236
237+std::vector<std::string> ScopeMetadata::tags() const
238+{
239+ return p->tags();
240+}
241+
242 //! @endcond
243
244 } // namespace scopes
245
246=== modified file 'src/scopes/internal/ScopeConfig.cpp'
247--- src/scopes/internal/ScopeConfig.cpp 2014-11-10 03:57:03 +0000
248+++ src/scopes/internal/ScopeConfig.cpp 2014-11-27 05:38:38 +0000
249@@ -58,6 +58,7 @@
250 const string debug_mode_key = "DebugMode";
251 const string child_scope_ids_key = "ChildScopes";
252 const string version_key = "Version";
253+ const string tags_key = "Tags";
254
255 const string scope_appearance_group = "Appearance";
256 const string fg_color_key = "ForegroundColor";
257@@ -223,6 +224,22 @@
258
259 try
260 {
261+ tags_ = parser()->get_string_array(scope_config_group, tags_key);
262+ }
263+ catch (LogicException const&)
264+ {
265+ }
266+
267+ for (auto const& tag: tags_)
268+ {
269+ if (tag.empty())
270+ {
271+ throw_ex("Invalid empty tag string found in \"Tags\" list");
272+ }
273+ }
274+
275+ try
276+ {
277 debug_mode_ = parser()->get_boolean(scope_config_group, debug_mode_key);
278 }
279 catch (LogicException const&)
280@@ -444,6 +461,11 @@
281 return version_;
282 }
283
284+std::vector<std::string> ScopeConfig::tags() const
285+{
286+ return tags_;
287+}
288+
289 } // namespace internal
290
291 } // namespace scopes
292
293=== modified file 'src/scopes/internal/ScopeMetadataImpl.cpp'
294--- src/scopes/internal/ScopeMetadataImpl.cpp 2014-11-12 23:16:14 +0000
295+++ src/scopes/internal/ScopeMetadataImpl.cpp 2014-11-27 05:38:38 +0000
296@@ -61,6 +61,7 @@
297 , results_ttl_type_(other.results_ttl_type_)
298 , child_scope_ids_(other.child_scope_ids_)
299 , version_(other.version_)
300+ , tags_(other.tags_)
301 {
302 if (other.art_)
303 {
304@@ -118,6 +119,7 @@
305 location_data_needed_.reset(rhs.location_data_needed_ ? new bool(*rhs.location_data_needed_) : nullptr);
306 child_scope_ids_ = rhs.child_scope_ids_;
307 version_ = rhs.version_;
308+ tags_ = rhs.tags_;
309 }
310 return *this;
311 }
312@@ -239,6 +241,11 @@
313 return version_;
314 }
315
316+std::vector<std::string> ScopeMetadataImpl::tags() const
317+{
318+ return tags_;
319+}
320+
321 void ScopeMetadataImpl::set_scope_id(std::string const& scope_id)
322 {
323 scope_id_ = scope_id;
324@@ -328,6 +335,11 @@
325 version_ = v;
326 }
327
328+void ScopeMetadataImpl::set_tags(std::vector<std::string> const& tags)
329+{
330+ tags_ = tags;
331+}
332+
333 namespace
334 {
335
336@@ -413,6 +425,15 @@
337 }
338 var["child_scopes"] = Variant(va);
339 }
340+ if (tags_.size())
341+ {
342+ VariantArray va;
343+ for (auto const& tag: tags_)
344+ {
345+ va.push_back(Variant(tag));
346+ }
347+ var["tags"] = Variant(va);
348+ }
349
350 return var;
351 }
352@@ -557,6 +578,16 @@
353 child_scope_ids_.push_back(v.get_string());
354 }
355 }
356+
357+ tags_.clear();
358+ it = var.find("tags");
359+ if (it != var.end())
360+ {
361+ for (auto const& v: it->second.get_array())
362+ {
363+ tags_.push_back(v.get_string());
364+ }
365+ }
366 }
367
368 ScopeMetadata ScopeMetadataImpl::create(unique_ptr<ScopeMetadataImpl> impl)
369
370=== modified file 'src/scopes/internal/smartscopes/SSRegistryObject.cpp'
371--- src/scopes/internal/smartscopes/SSRegistryObject.cpp 2014-11-11 05:05:33 +0000
372+++ src/scopes/internal/smartscopes/SSRegistryObject.cpp 2014-11-27 05:38:38 +0000
373@@ -337,6 +337,8 @@
374
375 metadata->set_version(scope.version);
376
377+ metadata->set_tags(scope.tags);
378+
379 ScopeProxy proxy = ScopeImpl::create(middleware_->create_scope_proxy(scope.id, ss_scope_endpoint_),
380 middleware_->runtime(),
381 scope.id);
382
383=== modified file 'src/scopes/internal/smartscopes/SmartScopesClient.cpp'
384--- src/scopes/internal/smartscopes/SmartScopesClient.cpp 2014-11-19 13:05:49 +0000
385+++ src/scopes/internal/smartscopes/SmartScopesClient.cpp 2014-11-27 05:38:38 +0000
386@@ -284,6 +284,32 @@
387
388 scope.version = child_node->has_node("version") ? child_node->get_node("version")->as_int() : 0;
389
390+ if (child_node->has_node("tags"))
391+ {
392+ auto node = child_node->get_node("tags");
393+ if (node->type() == JsonNodeInterface::NodeType::Array)
394+ {
395+ auto tags = node->to_variant().get_array();
396+ for (auto const& tag : tags)
397+ {
398+ try
399+ {
400+ scope.tags.push_back(tag.get_string());
401+ }
402+ catch (unity::LogicException const& e)
403+ {
404+ std::cerr << "SmartScopesClient.get_remote_scopes(): Scope: \""
405+ << scope.id << "\" returned a non-string tag" << std::endl;
406+ }
407+ }
408+ }
409+ else
410+ {
411+ std::cerr << "SmartScopesClient.get_remote_scopes(): Scope: \""
412+ << scope.id << "\" returned an invalid value type for \"tags\"" << std::endl;
413+ }
414+ }
415+
416 remote_scopes.push_back(scope);
417 }
418 catch (std::exception const& e)
419
420=== modified file 'src/scopes/testing/ScopeMetadataBuilder.cpp'
421--- src/scopes/testing/ScopeMetadataBuilder.cpp 2014-11-12 02:15:46 +0000
422+++ src/scopes/testing/ScopeMetadataBuilder.cpp 2014-11-27 05:38:38 +0000
423@@ -48,6 +48,7 @@
424 Optional<bool> location_data_needed;
425 Optional<std::vector<std::string>> child_scope_ids;
426 Optional<int> version;
427+ Optional<std::vector<std::string>> tags;
428 };
429
430 testing::ScopeMetadataBuilder::ScopeMetadataBuilder() : p(new Private())
431@@ -160,6 +161,12 @@
432 return *this;
433 }
434
435+testing::ScopeMetadataBuilder& testing::ScopeMetadataBuilder::tags(Optional<std::vector<std::string>> const& value)
436+{
437+ p->tags = value;
438+ return *this;
439+}
440+
441 unity::scopes::ScopeMetadata testing::ScopeMetadataBuilder::operator()() const
442 {
443 auto impl = new unity::scopes::internal::ScopeMetadataImpl(Private::invalid_middleware);
444@@ -193,6 +200,8 @@
445 impl->set_child_scope_ids(*p->child_scope_ids);
446 if (p->version)
447 impl->set_version(*p->version);
448+ if (p->tags)
449+ impl->set_tags(*p->tags);
450
451 return unity::scopes::internal::ScopeMetadataImpl::create(
452 std::move(
453
454=== modified file 'test/gtest/scopes/Registry/Registry_test.cpp'
455--- test/gtest/scopes/Registry/Registry_test.cpp 2014-11-20 21:33:33 +0000
456+++ test/gtest/scopes/Registry/Registry_test.cpp 2014-11-27 05:38:38 +0000
457@@ -109,6 +109,11 @@
458 EXPECT_EQ("com.foo.bar", children[0]);
459 EXPECT_EQ("com.foo.baz", children[1]);
460 EXPECT_EQ(1, meta.version());
461+ auto tags = meta.tags();
462+ EXPECT_EQ(3u, tags.size());
463+ EXPECT_EQ("music", tags[0]);
464+ EXPECT_EQ("news", tags[1]);
465+ EXPECT_EQ("foo", tags[2]);
466
467 auto attrs = meta.appearance_attributes();
468 EXPECT_EQ("fg_color", attrs["foreground-color"].get_string());
469@@ -140,6 +145,7 @@
470 EXPECT_EQ(0, defs.size());
471 EXPECT_FALSE(meta.location_data_needed());
472 EXPECT_EQ(0, meta.child_scope_ids().size());
473+ EXPECT_EQ(0, meta.tags().size());
474 EXPECT_EQ(0, meta.version());
475 }
476
477
478=== modified file 'test/gtest/scopes/Registry/scopes/testscopeA/testscopeA.ini.in'
479--- test/gtest/scopes/Registry/scopes/testscopeA/testscopeA.ini.in 2014-11-10 03:57:03 +0000
480+++ test/gtest/scopes/Registry/scopes/testscopeA/testscopeA.ini.in 2014-11-27 05:38:38 +0000
481@@ -9,6 +9,7 @@
482 LocationDataNeeded = true
483 ChildScopes = com.foo.bar;com.foo.baz
484 Version = 1
485+Tags = music;news;foo
486
487 [Appearance]
488 ForegroundColor = fg_color
489
490=== modified file 'test/gtest/scopes/internal/ScopeConfig/CMakeLists.txt'
491--- test/gtest/scopes/internal/ScopeConfig/CMakeLists.txt 2014-11-10 03:57:03 +0000
492+++ test/gtest/scopes/internal/ScopeConfig/CMakeLists.txt 2014-11-27 05:38:38 +0000
493@@ -8,6 +8,9 @@
494 configure_file(bad_child_ids.ini.in bad_child_ids.ini copyonly)
495 configure_file(empty_child_ids.ini.in empty_child_ids.ini copyonly)
496 configure_file(single_child_id.ini.in single_child_id.ini copyonly)
497+configure_file(bad_tags.ini.in bad_tags.ini copyonly)
498+configure_file(empty_tags.ini.in empty_tags.ini copyonly)
499+configure_file(single_tag.ini.in single_tag.ini copyonly)
500
501 add_definitions(-DCOMPLETE_CONFIG="${CMAKE_CURRENT_BINARY_DIR}/complete_config.ini")
502 add_definitions(-DMANDATORY_CONFIG="${CMAKE_CURRENT_BINARY_DIR}/mandatory_config.ini")
503@@ -19,6 +22,9 @@
504 add_definitions(-DSINGLE_CHILD_ID="${CMAKE_CURRENT_BINARY_DIR}/single_child_id.ini")
505 add_definitions(-DBAD_TTL="${CMAKE_CURRENT_BINARY_DIR}/bad_ttl.ini")
506 add_definitions(-DBAD_VERSION="${CMAKE_CURRENT_BINARY_DIR}/bad_version.ini")
507+add_definitions(-DBAD_TAGS="${CMAKE_CURRENT_BINARY_DIR}/bad_tags.ini")
508+add_definitions(-DEMPTY_TAGS="${CMAKE_CURRENT_BINARY_DIR}/empty_tags.ini")
509+add_definitions(-DSINGLE_TAG="${CMAKE_CURRENT_BINARY_DIR}/single_tag.ini")
510
511 add_executable(ScopeConfig_test ScopeConfig_test.cpp)
512 target_link_libraries(ScopeConfig_test ${TESTLIBS})
513
514=== modified file 'test/gtest/scopes/internal/ScopeConfig/ScopeConfig_test.cpp'
515--- test/gtest/scopes/internal/ScopeConfig/ScopeConfig_test.cpp 2014-11-10 03:57:03 +0000
516+++ test/gtest/scopes/internal/ScopeConfig/ScopeConfig_test.cpp 2014-11-27 05:38:38 +0000
517@@ -57,6 +57,11 @@
518 EXPECT_EQ("com.foo.bar2", children[1]);
519 EXPECT_EQ("com.foo.boo", children[2]);
520
521+ auto tags = cfg.tags();
522+ EXPECT_EQ(2u, tags.size());
523+ EXPECT_EQ("foo", tags[0]);
524+ EXPECT_EQ("bar", tags[1]);
525+
526 auto attrs = cfg.appearance_attributes();
527 EXPECT_EQ(5, attrs.size());
528 EXPECT_TRUE(attrs["arbitrary_key"].get_bool());
529@@ -180,6 +185,31 @@
530 }
531 }
532
533+TEST(ScopeConfig, bad_tags)
534+{
535+ try
536+ {
537+ ScopeConfig cfg(BAD_TAGS);
538+ }
539+ catch(ConfigException const& e)
540+ {
541+ boost::regex r("unity::scopes::ConfigException: \".*\": Invalid empty tag string found in \"Tags\" list");
542+ EXPECT_TRUE(boost::regex_match(e.what(), r));
543+ }
544+}
545+
546+TEST(ScopeConfig, empty_tags)
547+{
548+ ScopeConfig cfg(EMPTY_TAGS);
549+ EXPECT_EQ(cfg.tags().size(), 0);
550+}
551+
552+TEST(ScopeConfig, single_tag)
553+{
554+ ScopeConfig cfg(SINGLE_TAG);
555+ EXPECT_EQ(cfg.tags().size(), 1);
556+}
557+
558 class ScopeConfigWithIntl: public ::testing::Test
559 {
560 public:
561
562=== added file 'test/gtest/scopes/internal/ScopeConfig/bad_tags.ini.in'
563--- test/gtest/scopes/internal/ScopeConfig/bad_tags.ini.in 1970-01-01 00:00:00 +0000
564+++ test/gtest/scopes/internal/ScopeConfig/bad_tags.ini.in 2014-11-27 05:38:38 +0000
565@@ -0,0 +1,5 @@
566+[ScopeConfig]
567+DisplayName = Scope name
568+Description = Scope description
569+Author = Canonical
570+Tags = foo;;
571
572=== modified file 'test/gtest/scopes/internal/ScopeConfig/complete_config.ini.in'
573--- test/gtest/scopes/internal/ScopeConfig/complete_config.ini.in 2014-11-10 03:57:03 +0000
574+++ test/gtest/scopes/internal/ScopeConfig/complete_config.ini.in 2014-11-27 05:38:38 +0000
575@@ -19,6 +19,7 @@
576 DebugMode = true
577 Version = 1
578 ChildScopes = com.foo.bar;com.foo.bar2;com.foo.boo
579+Tags = foo;bar
580
581 [Appearance]
582 arbitrary_key = true
583
584=== added file 'test/gtest/scopes/internal/ScopeConfig/empty_tags.ini.in'
585--- test/gtest/scopes/internal/ScopeConfig/empty_tags.ini.in 1970-01-01 00:00:00 +0000
586+++ test/gtest/scopes/internal/ScopeConfig/empty_tags.ini.in 2014-11-27 05:38:38 +0000
587@@ -0,0 +1,5 @@
588+[ScopeConfig]
589+DisplayName = Scope name
590+Description = Scope description
591+Author = Canonical
592+Tags =
593
594=== added file 'test/gtest/scopes/internal/ScopeConfig/single_tag.ini.in'
595--- test/gtest/scopes/internal/ScopeConfig/single_tag.ini.in 1970-01-01 00:00:00 +0000
596+++ test/gtest/scopes/internal/ScopeConfig/single_tag.ini.in 2014-11-27 05:38:38 +0000
597@@ -0,0 +1,5 @@
598+[ScopeConfig]
599+DisplayName = Scope name
600+Description = Scope description
601+Author = Canonical
602+Tags = foo
603
604=== modified file 'test/gtest/scopes/internal/ScopeMetadataImpl/ScopeMetadataImpl_test.cpp'
605--- test/gtest/scopes/internal/ScopeMetadataImpl/ScopeMetadataImpl_test.cpp 2014-11-10 03:57:03 +0000
606+++ test/gtest/scopes/internal/ScopeMetadataImpl/ScopeMetadataImpl_test.cpp 2014-11-27 05:38:38 +0000
607@@ -162,6 +162,7 @@
608 mi2->set_settings_definitions(va);
609 mi2->set_location_data_needed(true);
610 mi2->set_child_scope_ids(vector<string>{"abc", "def"});
611+ mi2->set_tags(vector<string>{"music", "video", "news"});
612
613 // Make another copy, so we get coverage on the entire copy constructor
614 unique_ptr<ScopeMetadataImpl> mi3(new ScopeMetadataImpl(*mi2));
615@@ -175,6 +176,7 @@
616 EXPECT_EQ(va, m.settings_definitions());
617 EXPECT_TRUE(m.location_data_needed());
618 EXPECT_EQ((vector<string>{"abc", "def"}), m.child_scope_ids());
619+ EXPECT_EQ((vector<string>{"music", "video", "news"}), m.tags());
620
621 // Make another value
622 unique_ptr<ScopeMetadataImpl> ti(new ScopeMetadataImpl(&mw));
623@@ -198,6 +200,7 @@
624 ti->set_settings_definitions(tmp_va);
625 ti->set_location_data_needed(true);
626 ti->set_child_scope_ids(vector<string>{"tmp abc", "tmp def"});
627+ ti->set_tags(vector<string>{"music", "video"});
628
629 // Check impl assignment operator
630 ScopeMetadataImpl ci(&mw);
631@@ -220,6 +223,7 @@
632 EXPECT_TRUE(ci.location_data_needed());
633 EXPECT_EQ((vector<string>{"tmp abc", "tmp def"}), ci.child_scope_ids());
634 EXPECT_EQ(99, ci.version());
635+ EXPECT_EQ((vector<string>{"music", "video"}), ci.tags());
636
637 // Check public assignment operator
638 auto tmp = ScopeMetadataImpl::create(move(ti));
639@@ -242,6 +246,7 @@
640 EXPECT_EQ(tmp_va, m.settings_definitions());
641 EXPECT_TRUE(m.location_data_needed());
642 EXPECT_EQ((vector<string>{"tmp abc", "tmp def"}), m.child_scope_ids());
643+ EXPECT_EQ((vector<string>{"music", "video"}), m.tags());
644
645 // Self-assignment
646 tmp = tmp;
647@@ -263,6 +268,7 @@
648 EXPECT_EQ(tmp_va, tmp.settings_definitions());
649 EXPECT_TRUE(tmp.location_data_needed());
650 EXPECT_EQ((vector<string>{"tmp abc", "tmp def"}), tmp.child_scope_ids());
651+ EXPECT_EQ((vector<string>{"music", "video"}), tmp.tags());
652
653 // Copy constructor
654 ScopeMetadata tmp2(tmp);
655@@ -284,6 +290,7 @@
656 EXPECT_EQ(tmp_va, tmp2.settings_definitions());
657 EXPECT_TRUE(tmp2.location_data_needed());
658 EXPECT_EQ((vector<string>{"tmp abc", "tmp def"}), tmp2.child_scope_ids());
659+ EXPECT_EQ((vector<string>{"music", "video"}), tmp2.tags());
660 }
661
662 TEST(ScopeMetadataImpl, serialize)
663@@ -315,11 +322,12 @@
664 mi->set_settings_definitions(va);
665 mi->set_location_data_needed(false);
666 mi->set_child_scope_ids({"com.foo.bar", "com.foo.baz"});
667+ mi->set_tags({"news", "games"});
668
669 // Check that serialize() sets the map values correctly
670 auto m = ScopeMetadataImpl::create(move(mi));
671 auto var = m.serialize();
672- EXPECT_EQ(17u, var.size());
673+ EXPECT_EQ(18u, var.size());
674 EXPECT_EQ("scope_id", var["scope_id"].get_string());
675 EXPECT_EQ("display_name", var["display_name"].get_string());
676 EXPECT_EQ("description", var["description"].get_string());
677@@ -340,6 +348,9 @@
678 EXPECT_EQ(2u, var["child_scopes"].get_array().size());
679 EXPECT_EQ("com.foo.bar", var["child_scopes"].get_array()[0].get_string());
680 EXPECT_EQ("com.foo.baz", var["child_scopes"].get_array()[1].get_string());
681+ EXPECT_EQ(2u, var["tags"].get_array().size());
682+ EXPECT_EQ("news", var["tags"].get_array()[0].get_string());
683+ EXPECT_EQ("games", var["tags"].get_array()[1].get_string());
684
685 // Make another instance from the VariantMap and check its fields
686 ScopeMetadataImpl c(var, &mw);
687
688=== modified file 'test/gtest/scopes/internal/smartscopes/SmartScopesClient/FakeSss.py'
689--- test/gtest/scopes/internal/smartscopes/SmartScopesClient/FakeSss.py 2014-11-11 05:05:33 +0000
690+++ test/gtest/scopes/internal/smartscopes/SmartScopesClient/FakeSss.py 2014-11-27 05:38:38 +0000
691@@ -88,7 +88,7 @@
692 \
693 {"id" : "fail.scope.3", "name": "Fail Scope 3", "description": "Fails due to no base_url.", "author": "Mr.Fake", "art": "art" },\
694 \
695-{"base_url": "http://127.0.0.1:' + str(port) + '/demo3", "id" : "dummy.scope.3", "name": "Dummy Demo Scope 3", "description": "Dummy demo scope 3.", "author": "Mr.Fake",\
696+{"base_url": "http://127.0.0.1:' + str(port) + '/demo3", "id" : "dummy.scope.3", "name": "Dummy Demo Scope 3", "description": "Dummy demo scope 3.", "author": "Mr.Fake", "tags": ["music", "video", "news", "games"],\
697 "settings":\
698 [\
699 {\
700
701=== modified file 'test/gtest/scopes/internal/smartscopes/SmartScopesClient/SmartScopesClient_test.cpp'
702--- test/gtest/scopes/internal/smartscopes/SmartScopesClient/SmartScopesClient_test.cpp 2014-11-19 13:05:49 +0000
703+++ test/gtest/scopes/internal/smartscopes/SmartScopesClient/SmartScopesClient_test.cpp 2014-11-27 05:38:38 +0000
704@@ -85,6 +85,7 @@
705 EXPECT_EQ(0, scopes[0].version);
706 EXPECT_EQ(nullptr, scopes[0].appearance);
707 EXPECT_EQ(nullptr, scopes[0].settings);
708+ EXPECT_TRUE(scopes[0].tags.empty());
709
710 EXPECT_EQ("dummy.scope.2", scopes[1].id);
711 EXPECT_EQ("Dummy Demo Scope 2", scopes[1].name);
712@@ -98,6 +99,7 @@
713 EXPECT_EQ("#00BEEF", (*scopes[1].appearance)["background"].get_string());
714 EXPECT_EQ("logo.png", (*scopes[1].appearance)["PageHeader"].get_dict()["logo"].get_string());
715 EXPECT_EQ(nullptr, scopes[1].settings);
716+ EXPECT_TRUE(scopes[1].tags.empty());
717
718 EXPECT_EQ("dummy.scope.3", scopes[2].id);
719 EXPECT_EQ("Dummy Demo Scope 3", scopes[2].name);
720@@ -115,6 +117,11 @@
721 "\"defaultValue\":23},\"type\":\"number\"},{\"displayName\":\"Enabled\",\"id\":"
722 "\"enabled\",\"parameters\":{\"defaultValue\":true},\"type\":\"boolean\"}]\n",
723 *scopes[2].settings);
724+ ASSERT_EQ(4, scopes[2].tags.size());
725+ EXPECT_EQ("music", scopes[2].tags[0]);
726+ EXPECT_EQ("video", scopes[2].tags[1]);
727+ EXPECT_EQ("news", scopes[2].tags[2]);
728+ EXPECT_EQ("games", scopes[2].tags[3]);
729 }
730
731 TEST_F(SmartScopesClientTest, search)
732
733=== modified file 'test/gtest/scopes/internal/smartscopes/smartscopesproxy/smartscopesproxy_test.cpp'
734--- test/gtest/scopes/internal/smartscopes/smartscopesproxy/smartscopesproxy_test.cpp 2014-11-20 03:11:18 +0000
735+++ test/gtest/scopes/internal/smartscopes/smartscopesproxy/smartscopesproxy_test.cpp 2014-11-27 05:38:38 +0000
736@@ -140,6 +140,11 @@
737 EXPECT_EQ(2, meta.settings_definitions()[1].get_dict()["displayValues"].get_array().size());
738 EXPECT_EQ("Celsius", meta.settings_definitions()[1].get_dict()["displayValues"].get_array()[0].get_string());
739 EXPECT_EQ("Fahrenheit", meta.settings_definitions()[1].get_dict()["displayValues"].get_array()[1].get_string());
740+ ASSERT_EQ(4, meta.tags().size());
741+ EXPECT_EQ("music", meta.tags()[0]);
742+ EXPECT_EQ("video", meta.tags()[1]);
743+ EXPECT_EQ("news", meta.tags()[2]);
744+ EXPECT_EQ("games", meta.tags()[3]);
745 }
746
747 // non-existent scope (via mw)

Subscribers

People subscribed via source and target branches

to all changes: