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

Proposed by Marcus Tomlinson
Status: Merged
Approved by: Michi Henning
Approved revision: 190
Merged at revision: 191
Proposed branch: lp:~marcustomlinson/unity-scopes-api/metadata_invisible_attr
Merge into: lp:unity-scopes-api/devel
Diff against target: 307 lines (+62/-13)
7 files modified
include/unity/scopes/ScopeMetadata.h (+1/-0)
include/unity/scopes/internal/ScopeMetadataImpl.h (+4/-1)
src/scopes/ScopeMetadata.cpp (+5/-0)
src/scopes/internal/ScopeMetadataImpl.cpp (+29/-0)
src/scopes/internal/smartscopes/SSRegistryObject.cpp (+1/-5)
test/gtest/scopes/internal/ScopeMetadataImpl/ScopeMetadataImpl_test.cpp (+14/-1)
test/gtest/scopes/internal/smartscopes/smartscopesproxy/smartscopesproxy_test.cpp (+8/-6)
To merge this branch: bzr merge lp:~marcustomlinson/unity-scopes-api/metadata_invisible_attr
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michi Henning (community) Needs Fixing
Review via email: mp+205528@code.launchpad.net

Commit message

Added "invisible" attribute to ScopeMetadata.

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

Looks good to me, but we need to sort out the test failure.

review: Needs Fixing
190. By Marcus Tomlinson

Fixed smartscopesproxytest error

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

Sorry, don't know how I missed that

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/unity/scopes/ScopeMetadata.h'
2--- include/unity/scopes/ScopeMetadata.h 2014-01-27 21:33:11 +0000
3+++ include/unity/scopes/ScopeMetadata.h 2014-02-10 09:03:48 +0000
4@@ -52,6 +52,7 @@
5 std::string icon() const; // optional
6 std::string search_hint() const; // localized, optional
7 std::string hot_key() const; // localized, optional
8+ bool invisible() const; // optional (default = false)
9
10 /**
11 \brief Returns a dictionary of all attributes of this ScopeMetadata instance.
12
13=== modified file 'include/unity/scopes/internal/ScopeMetadataImpl.h'
14--- include/unity/scopes/internal/ScopeMetadataImpl.h 2014-01-07 12:22:29 +0000
15+++ include/unity/scopes/internal/ScopeMetadataImpl.h 2014-02-10 09:03:48 +0000
16@@ -45,12 +45,13 @@
17
18 std::string scope_name() const;
19 ScopeProxy proxy() const;
20- std::string display_name() const; // localized
21+ std::string display_name() const; // localized
22 std::string description() const; // localized
23 std::string art() const; // optional
24 std::string icon() const; // optional
25 std::string search_hint() const; // localized, optional
26 std::string hot_key() const; // localized, optional
27+ bool invisible() const; // optional (default = false)
28
29 void set_scope_name(std::string const& scope_name);
30 void set_proxy(ScopeProxy const& proxy);
31@@ -60,6 +61,7 @@
32 void set_icon(std::string const& icon);
33 void set_search_hint(std::string const& search_hint);
34 void set_hot_key(std::string const& hot_key);
35+ void set_invisible(bool invisible);
36
37 VariantMap serialize() const;
38 void deserialize(VariantMap const& var);
39@@ -77,6 +79,7 @@
40 std::unique_ptr<std::string> icon_; // Optional, hence a pointer
41 std::unique_ptr<std::string> search_hint_; // Optional, hence a pointer
42 std::unique_ptr<std::string> hot_key_; // Optional, hence a pointer
43+ std::unique_ptr<bool> invisible_; // Optional, hence a pointer
44 };
45
46 } // namespace internal
47
48=== modified file 'src/scopes/ScopeMetadata.cpp'
49--- src/scopes/ScopeMetadata.cpp 2014-01-09 09:09:52 +0000
50+++ src/scopes/ScopeMetadata.cpp 2014-02-10 09:03:48 +0000
51@@ -106,6 +106,11 @@
52 return p->hot_key();
53 }
54
55+bool ScopeMetadata::invisible() const
56+{
57+ return p->invisible();
58+}
59+
60 VariantMap ScopeMetadata::serialize() const
61 {
62 return p->serialize();
63
64=== modified file 'src/scopes/internal/ScopeMetadataImpl.cpp'
65--- src/scopes/internal/ScopeMetadataImpl.cpp 2014-01-15 22:52:19 +0000
66+++ src/scopes/internal/ScopeMetadataImpl.cpp 2014-02-10 09:03:48 +0000
67@@ -68,6 +68,10 @@
68 {
69 hot_key_.reset(new string(*other.hot_key_));
70 }
71+ if (other.invisible_)
72+ {
73+ invisible_.reset(new bool(*other.invisible_));
74+ }
75 }
76
77 ScopeMetadataImpl& ScopeMetadataImpl::operator=(ScopeMetadataImpl const& rhs)
78@@ -82,6 +86,7 @@
79 icon_.reset(rhs.icon_ ? new string(*rhs.icon_) : nullptr);
80 search_hint_.reset(rhs.search_hint_ ? new string(*rhs.search_hint_) : nullptr);
81 hot_key_.reset(rhs.hot_key_ ? new string(*rhs.hot_key_) : nullptr);
82+ invisible_.reset(rhs.invisible_ ? new bool(*rhs.invisible_) : nullptr);
83 }
84 return *this;
85 }
86@@ -142,6 +147,15 @@
87 throw NotFoundException("attribute not set", "hot_key");
88 }
89
90+bool ScopeMetadataImpl::invisible() const
91+{
92+ if (invisible_)
93+ {
94+ return *invisible_;
95+ }
96+ return false;
97+}
98+
99 void ScopeMetadataImpl::set_scope_name(std::string const& scope_name)
100 {
101 scope_name_ = scope_name;
102@@ -182,6 +196,11 @@
103 hot_key_.reset(new string(hot_key));
104 }
105
106+void ScopeMetadataImpl::set_invisible(bool invisible)
107+{
108+ invisible_.reset(new bool(invisible));
109+}
110+
111 namespace
112 {
113
114@@ -231,6 +250,10 @@
115 {
116 var["hot_key"] = *hot_key_;
117 }
118+ if (invisible_)
119+ {
120+ var["invisible"] = *invisible_;
121+ }
122
123 return var;
124 }
125@@ -306,6 +329,12 @@
126 {
127 hot_key_.reset(new string(it->second.get_string()));
128 }
129+
130+ it = var.find("invisible");
131+ if (it != var.end())
132+ {
133+ invisible_.reset(new bool(it->second.get_bool()));
134+ }
135 }
136
137 ScopeMetadata ScopeMetadataImpl::create(unique_ptr<ScopeMetadataImpl> impl)
138
139=== modified file 'src/scopes/internal/smartscopes/SSRegistryObject.cpp'
140--- src/scopes/internal/smartscopes/SSRegistryObject.cpp 2014-02-03 11:29:47 +0000
141+++ src/scopes/internal/smartscopes/SSRegistryObject.cpp 2014-02-10 09:03:48 +0000
142@@ -173,11 +173,6 @@
143 // loop through all available scopes and add() each visible scope
144 for (RemoteScope const& scope : remote_scopes)
145 {
146- if (scope.invisible)
147- {
148- continue;
149- }
150-
151 // construct a ScopeMetadata with remote scope info
152 std::unique_ptr<ScopeMetadataImpl> metadata(new ScopeMetadataImpl(nullptr));
153
154@@ -190,6 +185,7 @@
155 scope.name);
156
157 metadata->set_proxy(proxy);
158+ metadata->set_invisible(scope.invisible);
159
160 auto meta = ScopeMetadataImpl::create(move(metadata));
161
162
163=== modified file 'test/gtest/scopes/internal/ScopeMetadataImpl/ScopeMetadataImpl_test.cpp'
164--- test/gtest/scopes/internal/ScopeMetadataImpl/ScopeMetadataImpl_test.cpp 2014-01-24 03:18:25 +0000
165+++ test/gtest/scopes/internal/ScopeMetadataImpl/ScopeMetadataImpl_test.cpp 2014-02-10 09:03:48 +0000
166@@ -97,6 +97,9 @@
167 EXPECT_STREQ("unity::scopes::NotFoundException: attribute not set (name = hot_key)", e.what());
168 }
169
170+ // when "invisible" is not set, false is returned
171+ EXPECT_FALSE(m.invisible());
172+
173 // Check that the copy has the same values as the original
174 EXPECT_EQ("scope_name", mi2->scope_name());
175 EXPECT_EQ("identity", mi2->proxy()->identity());
176@@ -109,6 +112,7 @@
177 mi2->set_icon("icon");
178 mi2->set_search_hint("search_hint");
179 mi2->set_hot_key("hot_key");
180+ mi2->set_invisible(true);
181
182 // Make another copy, so we get coverage on the entire copy constructor
183 unique_ptr<ScopeMetadataImpl> mi3(new ScopeMetadataImpl(*mi2));
184@@ -117,6 +121,7 @@
185 m = ScopeMetadataImpl::create(move(mi2));
186 EXPECT_EQ("search_hint", m.search_hint());
187 EXPECT_EQ("hot_key", m.hot_key());
188+ EXPECT_TRUE(m.invisible());
189
190 // Make another value
191 unique_ptr<ScopeMetadataImpl> ti(new ScopeMetadataImpl(&mw));
192@@ -129,6 +134,7 @@
193 ti->set_icon("tmp icon");
194 ti->set_search_hint("tmp search_hint");
195 ti->set_hot_key("tmp hot_key");
196+ ti->set_invisible(true);
197
198 // Check impl assignment operator
199 ScopeMetadataImpl ci(&mw);
200@@ -142,6 +148,7 @@
201 EXPECT_EQ("tmp icon", ci.icon());
202 EXPECT_EQ("tmp search_hint", ci.search_hint());
203 EXPECT_EQ("tmp hot_key", ci.hot_key());
204+ EXPECT_TRUE(ci.invisible());
205
206 // Check public assignment operator
207 auto tmp = ScopeMetadataImpl::create(move(ti));
208@@ -155,6 +162,7 @@
209 EXPECT_EQ("tmp icon", m.icon());
210 EXPECT_EQ("tmp search_hint", m.search_hint());
211 EXPECT_EQ("tmp hot_key", m.hot_key());
212+ EXPECT_TRUE(m.invisible());
213
214 // Self-assignment
215 tmp = tmp;
216@@ -167,6 +175,7 @@
217 EXPECT_EQ("tmp icon", tmp.icon());
218 EXPECT_EQ("tmp search_hint", tmp.search_hint());
219 EXPECT_EQ("tmp hot_key", tmp.hot_key());
220+ EXPECT_TRUE(tmp.invisible());
221
222 // Copy constructor
223 ScopeMetadata tmp2(tmp);
224@@ -179,6 +188,7 @@
225 EXPECT_EQ("tmp icon", tmp2.icon());
226 EXPECT_EQ("tmp search_hint", tmp2.search_hint());
227 EXPECT_EQ("tmp hot_key", tmp2.hot_key());
228+ EXPECT_TRUE(tmp2.invisible());
229 }
230
231 TEST(ScopeMetadataImpl, serialize)
232@@ -196,11 +206,12 @@
233 mi->set_icon("icon");
234 mi->set_search_hint("search_hint");
235 mi->set_hot_key("hot_key");
236+ mi->set_invisible(false);
237
238 // Check that serialize() sets the map values correctly
239 auto m = ScopeMetadataImpl::create(move(mi));
240 auto var = m.serialize();
241- EXPECT_EQ(8, var.size());
242+ EXPECT_EQ(9, var.size());
243 EXPECT_EQ("scope_name", var["scope_name"].get_string());
244 EXPECT_EQ("display_name", var["display_name"].get_string());
245 EXPECT_EQ("description", var["description"].get_string());
246@@ -208,6 +219,7 @@
247 EXPECT_EQ("icon", var["icon"].get_string());
248 EXPECT_EQ("search_hint", var["search_hint"].get_string());
249 EXPECT_EQ("hot_key", var["hot_key"].get_string());
250+ EXPECT_FALSE(var["invisible"].get_bool());
251
252 // Make another instance from the VariantMap and check its fields
253 ScopeMetadataImpl c(var, &mw);
254@@ -220,6 +232,7 @@
255 EXPECT_EQ("icon", c.icon());
256 EXPECT_EQ("search_hint", c.search_hint());
257 EXPECT_EQ("hot_key", c.hot_key());
258+ EXPECT_FALSE(c.invisible());
259 }
260
261 TEST(ScopeMetadataImpl, serialize_exceptions)
262
263=== modified file 'test/gtest/scopes/internal/smartscopes/smartscopesproxy/smartscopesproxy_test.cpp'
264--- test/gtest/scopes/internal/smartscopes/smartscopesproxy/smartscopesproxy_test.cpp 2014-02-04 12:31:29 +0000
265+++ test/gtest/scopes/internal/smartscopes/smartscopesproxy/smartscopesproxy_test.cpp 2014-02-10 09:03:48 +0000
266@@ -107,16 +107,17 @@
267
268 // list scopes (direct)
269 MetadataMap scopes = reg_->list();
270- EXPECT_EQ(scopes.size(), 1);
271+ EXPECT_EQ(scopes.size(), 2);
272
273 // visible scope (direct)
274 ScopeMetadata meta = reg_->get_metadata("Dummy Demo Scope");
275 EXPECT_EQ("Dummy Demo Scope", meta.scope_name());
276 EXPECT_EQ("Dummy Demo Scope", meta.display_name());
277 EXPECT_EQ("Dummy demo scope.", meta.description());
278+ EXPECT_FALSE(meta.invisible());
279
280- // invisible scope (direct)
281- EXPECT_THROW(reg_->get_metadata("Dummy Demo Scope 2"), NotFoundException);
282+ // non-existant scope (direct)
283+ EXPECT_THROW(reg_->get_metadata("Dummy Demo Scope 3"), NotFoundException);
284
285 // locate should throw (via mw)
286 MWRegistryProxy mw_reg = reg_mw_->create_registry_proxy(reg_id_, reg_mw_->get_scope_endpoint());
287@@ -124,16 +125,17 @@
288
289 // list scopes (via mw)
290 scopes = mw_reg->list();
291- EXPECT_EQ(scopes.size(), 1);
292+ EXPECT_EQ(scopes.size(), 2);
293
294 // visible scope (via mw)
295 meta = mw_reg->get_metadata("Dummy Demo Scope");
296 EXPECT_EQ("Dummy Demo Scope", meta.scope_name());
297 EXPECT_EQ("Dummy Demo Scope", meta.display_name());
298 EXPECT_EQ("Dummy demo scope.", meta.description());
299+ EXPECT_FALSE(meta.invisible());
300
301- // invisible scope (via mw)
302- EXPECT_THROW(mw_reg->get_metadata("Dummy Demo Scope 2"), NotFoundException);
303+ // non-existant scope (via mw)
304+ EXPECT_THROW(mw_reg->get_metadata("Dummy Demo Scope 3"), NotFoundException);
305 }
306
307 class Receiver : public SearchListener

Subscribers

People subscribed via source and target branches

to all changes: