Merge lp:~stolowski/unity-scopes-api/update-push-filters into lp:unity-scopes-api/devel
- update-push-filters
- Merge into devel
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Marcus Tomlinson | ||||
Approved revision: | 683 | ||||
Merged at revision: | 682 | ||||
Proposed branch: | lp:~stolowski/unity-scopes-api/update-push-filters | ||||
Merge into: | lp:unity-scopes-api/devel | ||||
Diff against target: |
503 lines (+105/-75) 18 files modified
RELEASE_NOTES.md (+5/-0) STRUCTS (+2/-3) debian/VERSION (+1/-1) debian/changelog (+8/-0) include/unity/scopes/SearchListenerBase.h (+9/-0) include/unity/scopes/SearchReply.h (+8/-1) include/unity/scopes/internal/SearchReplyImpl.h (+2/-1) include/unity/scopes/testing/MockSearchReply.h (+1/-0) include/unity/scopes/utility/internal/BufferedSearchReplyImpl.h (+1/-0) src/scopes/SearchListenerBase.cpp (+5/-0) src/scopes/internal/ResultReplyObject.cpp (+5/-10) src/scopes/internal/SearchReplyImpl.cpp (+7/-14) src/scopes/testing/InProcessBenchmark.cpp (+5/-0) src/scopes/utility/internal/BufferedSearchReplyImpl.cpp (+5/-0) test/gtest/scopes/Filters/Filters_test.cpp (+21/-10) test/gtest/scopes/Filters/TestScope.h (+19/-2) test/gtest/scopes/ResultCache/ResultCache_test.cpp (+1/-32) test/gtest/scopes/ResultCache/no_filter_state_cache (+0/-1) |
||||
To merge this branch: | bzr merge lp:~stolowski/unity-scopes-api/update-push-filters | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Marcus Tomlinson (community) | Approve | ||
unity-api-1-bot | continuous-integration | Needs Fixing | |
Review via email:
|
Commit message
Marked the push(Filters const&, FilterState const&) method of SearchReply and SearchListenerBase
as deprecated and provided push methods which take Filters argument only.
Description of the change
Marked the push(Filters const&, FilterState const&) method of SearchReply and SearchListenerBase
as deprecated and provided push methods which take Filters argument only.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
unity-api-1-bot (unity-api-1-bot) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Marcus Tomlinson (marcustomlinson) wrote : | # |
Looking good. Just a few inline comments, mostly grammatical.
- 682. By Paweł Stołowski
-
Review comments
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:682
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Paweł Stołowski (stolowski) wrote : | # |
> Looking good. Just a few inline comments, mostly grammatical.
Ok, done. Thanks for the corrections... will I ever get this stuff right ;)...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Marcus Tomlinson (marcustomlinson) wrote : | # |
> > Looking good. Just a few inline comments, mostly grammatical.
>
> Ok, done. Thanks for the corrections... will I ever get this stuff right ;)...
;) It's really not that bad! Thanks Pawel. Although, now I see there are 2 conflicts with devel
- 683. By Paweł Stołowski
-
Merged devel
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Paweł Stołowski (stolowski) wrote : | # |
> > > Looking good. Just a few inline comments, mostly grammatical.
> >
> > Ok, done. Thanks for the corrections... will I ever get this stuff right
> ;)...
>
> ;) It's really not that bad! Thanks Pawel. Although, now I see there are 2
> conflicts with devel
Ok, fixed + bumped to 1.0.7.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Marcus Tomlinson (marcustomlinson) wrote : | # |
> > > > Looking good. Just a few inline comments, mostly grammatical.
> > >
> > > Ok, done. Thanks for the corrections... will I ever get this stuff right
> > ;)...
> >
> > ;) It's really not that bad! Thanks Pawel. Although, now I see there are 2
> > conflicts with devel
>
> Ok, fixed + bumped to 1.0.7.
Thanks +1
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'RELEASE_NOTES.md' | |||
2 | --- RELEASE_NOTES.md 2016-05-23 07:55:39 +0000 | |||
3 | +++ RELEASE_NOTES.md 2016-06-28 08:18:23 +0000 | |||
4 | @@ -1,6 +1,11 @@ | |||
5 | 1 | Release notes | 1 | Release notes |
6 | 2 | ============= | 2 | ============= |
7 | 3 | 3 | ||
8 | 4 | Changes in version 1.0.7 | ||
9 | 5 | ======================== | ||
10 | 6 | - Marked the push(Filters const&, FilterState const&) method of SearchReply and SearchListenerBase | ||
11 | 7 | as deprecated and provided push methods which take the Filters argument only. | ||
12 | 8 | |||
13 | 4 | Changes in version 1.0.6 | 9 | Changes in version 1.0.6 |
14 | 5 | ======================== | 10 | ======================== |
15 | 6 | - Got rid of category header background, as per design (Bug #1446216). | 11 | - Got rid of category header background, as per design (Bug #1446216). |
16 | 7 | 12 | ||
17 | === modified file 'STRUCTS' | |||
18 | --- STRUCTS 2016-02-25 16:26:09 +0000 | |||
19 | +++ STRUCTS 2016-06-28 08:18:23 +0000 | |||
20 | @@ -142,10 +142,9 @@ | |||
21 | 142 | 'central_label' : string | 142 | 'central_label' : string |
22 | 143 | 'filter_group' : string, optional | 143 | 'filter_group' : string, optional |
23 | 144 | 144 | ||
26 | 145 | Filters + FilterState | 145 | Filters |
27 | 146 | ===================== | 146 | ======= |
28 | 147 | 'filter' : array of filters (implementations of FilterBase) | 147 | 'filter' : array of filters (implementations of FilterBase) |
29 | 148 | 'filter_state' : FilterState | ||
30 | 149 | 148 | ||
31 | 150 | PreviewResult (returned by serialize()) | 149 | PreviewResult (returned by serialize()) |
32 | 151 | ======================================= | 150 | ======================================= |
33 | 152 | 151 | ||
34 | === modified file 'debian/VERSION' | |||
35 | --- debian/VERSION 2016-05-23 07:56:41 +0000 | |||
36 | +++ debian/VERSION 2016-06-28 08:18:23 +0000 | |||
37 | @@ -1,1 +1,1 @@ | |||
39 | 1 | 1.0.6 | 1 | 1.0.7 |
40 | 2 | 2 | ||
41 | === modified file 'debian/changelog' | |||
42 | --- debian/changelog 2016-06-17 07:27:25 +0000 | |||
43 | +++ debian/changelog 2016-06-28 08:18:23 +0000 | |||
44 | @@ -1,3 +1,11 @@ | |||
45 | 1 | unity-scopes-api (1.0.7-0ubuntu1) UNRELEASED; urgency=medium | ||
46 | 2 | |||
47 | 3 | * Marked the push(Filters const&, FilterState const&) method of SearchReply | ||
48 | 4 | and SearchListenerBase as deprecated and provided push methods which take | ||
49 | 5 | the Filters argument only. | ||
50 | 6 | |||
51 | 7 | -- Pawel Stolowski <pawel.stolowski@canonical.com> Tue, 28 Jun 2016 10:11:22 +0200 | ||
52 | 8 | |||
53 | 1 | unity-scopes-api (1.0.6+16.10.20160617-0ubuntu1) yakkety; urgency=medium | 9 | unity-scopes-api (1.0.6+16.10.20160617-0ubuntu1) yakkety; urgency=medium |
54 | 2 | 10 | ||
55 | 3 | [ Marcus Tomlinson ] | 11 | [ Marcus Tomlinson ] |
56 | 4 | 12 | ||
57 | === modified file 'include/unity/scopes/SearchListenerBase.h' | |||
58 | --- include/unity/scopes/SearchListenerBase.h 2015-09-01 22:19:45 +0000 | |||
59 | +++ include/unity/scopes/SearchListenerBase.h 2016-06-28 08:18:23 +0000 | |||
60 | @@ -96,10 +96,19 @@ | |||
61 | 96 | /** | 96 | /** |
62 | 97 | \brief Called once by the scopes to send all the filters and their state. | 97 | \brief Called once by the scopes to send all the filters and their state. |
63 | 98 | 98 | ||
64 | 99 | \deprecated Please override the push(Filters& const) method instead. This method will be removed from future releases. | ||
65 | 100 | |||
66 | 99 | The default implementation does nothing. | 101 | The default implementation does nothing. |
67 | 100 | */ | 102 | */ |
68 | 101 | virtual void push(Filters const& filters, FilterState const& filter_state); | 103 | virtual void push(Filters const& filters, FilterState const& filter_state); |
69 | 102 | 104 | ||
70 | 105 | /** | ||
71 | 106 | \brief Called once by the scope to send all filters and their states. | ||
72 | 107 | |||
73 | 108 | The default implementation does nothing. | ||
74 | 109 | */ | ||
75 | 110 | virtual void push(Filters const& filters); | ||
76 | 111 | |||
77 | 103 | protected: | 112 | protected: |
78 | 104 | /// @cond | 113 | /// @cond |
79 | 105 | SearchListenerBase(); | 114 | SearchListenerBase(); |
80 | 106 | 115 | ||
81 | === modified file 'include/unity/scopes/SearchReply.h' | |||
82 | --- include/unity/scopes/SearchReply.h 2015-10-29 02:35:50 +0000 | |||
83 | +++ include/unity/scopes/SearchReply.h 2016-06-28 08:18:23 +0000 | |||
84 | @@ -139,7 +139,8 @@ | |||
85 | 139 | virtual bool push(experimental::Annotation const& annotation) = 0; | 139 | virtual bool push(experimental::Annotation const& annotation) = 0; |
86 | 140 | 140 | ||
87 | 141 | /** | 141 | /** |
89 | 142 | \brief Sends all filters and their state to the source of a query. | 142 | \brief Sends all filters and their states to the source of a query. |
90 | 143 | \deprecated Sending filter state back to the UI is deprecated and will be removed from future releases. Please use the push(Filters const&) method instead. | ||
91 | 143 | \return True if the filters were accepted, false otherwise. | 144 | \return True if the filters were accepted, false otherwise. |
92 | 144 | */ | 145 | */ |
93 | 145 | virtual bool push(Filters const& filters, FilterState const& filter_state) = 0; | 146 | virtual bool push(Filters const& filters, FilterState const& filter_state) = 0; |
94 | @@ -190,6 +191,12 @@ | |||
95 | 190 | */ | 191 | */ |
96 | 191 | virtual void push_surfacing_results_from_cache() = 0; | 192 | virtual void push_surfacing_results_from_cache() = 0; |
97 | 192 | 193 | ||
98 | 194 | /** | ||
99 | 195 | \brief Sends all filter definitions to the source of a query. | ||
100 | 196 | \return True if the filters were accepted, false otherwise. | ||
101 | 197 | */ | ||
102 | 198 | virtual bool push(Filters const& filters) = 0; | ||
103 | 199 | |||
104 | 193 | protected: | 200 | protected: |
105 | 194 | /// @cond | 201 | /// @cond |
106 | 195 | SearchReply(); | 202 | SearchReply(); |
107 | 196 | 203 | ||
108 | === modified file 'include/unity/scopes/internal/SearchReplyImpl.h' | |||
109 | --- include/unity/scopes/internal/SearchReplyImpl.h 2015-02-27 05:28:09 +0000 | |||
110 | +++ include/unity/scopes/internal/SearchReplyImpl.h 2016-06-28 08:18:23 +0000 | |||
111 | @@ -80,6 +80,8 @@ | |||
112 | 80 | 80 | ||
113 | 81 | virtual void push_surfacing_results_from_cache() noexcept override; | 81 | virtual void push_surfacing_results_from_cache() noexcept override; |
114 | 82 | 82 | ||
115 | 83 | virtual bool push(unity::scopes::Filters const& filters) override; | ||
116 | 84 | |||
117 | 83 | private: | 85 | private: |
118 | 84 | bool push(Category::SCPtr category); | 86 | bool push(Category::SCPtr category); |
119 | 85 | void write_cached_results() noexcept; | 87 | void write_cached_results() noexcept; |
120 | @@ -94,7 +96,6 @@ | |||
121 | 94 | 96 | ||
122 | 95 | Department::SCPtr cached_departments_; | 97 | Department::SCPtr cached_departments_; |
123 | 96 | unity::scopes::Filters cached_filters_; | 98 | unity::scopes::Filters cached_filters_; |
124 | 97 | unity::scopes::FilterState cached_filter_state_; | ||
125 | 98 | std::vector<unity::scopes::CategorisedResult> cached_results_; | 99 | std::vector<unity::scopes::CategorisedResult> cached_results_; |
126 | 99 | std::mutex mutex_; | 100 | std::mutex mutex_; |
127 | 100 | }; | 101 | }; |
128 | 101 | 102 | ||
129 | === modified file 'include/unity/scopes/testing/MockSearchReply.h' | |||
130 | --- include/unity/scopes/testing/MockSearchReply.h 2015-04-10 10:10:06 +0000 | |||
131 | +++ include/unity/scopes/testing/MockSearchReply.h 2016-06-28 08:18:23 +0000 | |||
132 | @@ -66,6 +66,7 @@ | |||
133 | 66 | MOCK_METHOD1(lookup_category, Category::SCPtr(std::string const&)); | 66 | MOCK_METHOD1(lookup_category, Category::SCPtr(std::string const&)); |
134 | 67 | MOCK_METHOD1(push, bool(CategorisedResult const&)); | 67 | MOCK_METHOD1(push, bool(CategorisedResult const&)); |
135 | 68 | MOCK_METHOD2(push, bool(Filters const&, FilterState const&)); | 68 | MOCK_METHOD2(push, bool(Filters const&, FilterState const&)); |
136 | 69 | MOCK_METHOD1(push, bool(Filters const&)); | ||
137 | 69 | MOCK_METHOD1(push, bool(experimental::Annotation const& annotation)); | 70 | MOCK_METHOD1(push, bool(experimental::Annotation const& annotation)); |
138 | 70 | MOCK_METHOD0(push_surfacing_results_from_cache, void()); | 71 | MOCK_METHOD0(push_surfacing_results_from_cache, void()); |
139 | 71 | 72 | ||
140 | 72 | 73 | ||
141 | === modified file 'include/unity/scopes/utility/internal/BufferedSearchReplyImpl.h' | |||
142 | --- include/unity/scopes/utility/internal/BufferedSearchReplyImpl.h 2015-02-27 05:28:09 +0000 | |||
143 | +++ include/unity/scopes/utility/internal/BufferedSearchReplyImpl.h 2016-06-28 08:18:23 +0000 | |||
144 | @@ -78,6 +78,7 @@ | |||
145 | 78 | std::string to_string() override; | 78 | std::string to_string() override; |
146 | 79 | 79 | ||
147 | 80 | void flush(); | 80 | void flush(); |
148 | 81 | bool push(unity::scopes::Filters const& filters) override; | ||
149 | 81 | 82 | ||
150 | 82 | private: | 83 | private: |
151 | 83 | std::mutex mutex_; | 84 | std::mutex mutex_; |
152 | 84 | 85 | ||
153 | === modified file 'src/scopes/SearchListenerBase.cpp' | |||
154 | --- src/scopes/SearchListenerBase.cpp 2014-06-17 15:07:13 +0000 | |||
155 | +++ src/scopes/SearchListenerBase.cpp 2016-06-28 08:18:23 +0000 | |||
156 | @@ -44,6 +44,11 @@ | |||
157 | 44 | // Intentionally empty: "do nothing" default implementation. | 44 | // Intentionally empty: "do nothing" default implementation. |
158 | 45 | } | 45 | } |
159 | 46 | 46 | ||
160 | 47 | void SearchListenerBase::push(Filters const& /* filters */) | ||
161 | 48 | { | ||
162 | 49 | // Intentionally empty: "do nothing" default implementation. | ||
163 | 50 | } | ||
164 | 51 | |||
165 | 47 | void SearchListenerBase::push(Category::SCPtr const& /* category */) | 52 | void SearchListenerBase::push(Category::SCPtr const& /* category */) |
166 | 48 | { | 53 | { |
167 | 49 | // Intentionally empty: "do nothing" default implementation. | 54 | // Intentionally empty: "do nothing" default implementation. |
168 | 50 | 55 | ||
169 | === modified file 'src/scopes/internal/ResultReplyObject.cpp' | |||
170 | --- src/scopes/internal/ResultReplyObject.cpp 2016-02-24 16:49:34 +0000 | |||
171 | +++ src/scopes/internal/ResultReplyObject.cpp 2016-06-28 08:18:23 +0000 | |||
172 | @@ -74,16 +74,11 @@ | |||
173 | 74 | } | 74 | } |
174 | 75 | 75 | ||
175 | 76 | Filters const filters = FilterBaseImpl::deserialize_filters(it->second.get_array(), groups); | 76 | Filters const filters = FilterBaseImpl::deserialize_filters(it->second.get_array(), groups); |
186 | 77 | it = data.find("filter_state"); | 77 | |
187 | 78 | if (it != data.end()) | 78 | // temporarily support both variants of push until the one supporting filter state gets dropped. |
188 | 79 | { | 79 | FilterState filter_state; |
189 | 80 | auto filter_state = FilterStateImpl::deserialize(it->second.get_dict()); | 80 | receiver_->push(filters, filter_state); |
190 | 81 | receiver_->push(filters, filter_state); | 81 | receiver_->push(filters); |
181 | 82 | } | ||
182 | 83 | else | ||
183 | 84 | { | ||
184 | 85 | throw InvalidArgumentException("ResultReplyObject::push(): filters present but missing filter_state data"); | ||
185 | 86 | } | ||
191 | 87 | } | 82 | } |
192 | 88 | 83 | ||
193 | 89 | it = data.find("category"); | 84 | it = data.find("category"); |
194 | 90 | 85 | ||
195 | === modified file 'src/scopes/internal/SearchReplyImpl.cpp' | |||
196 | --- src/scopes/internal/SearchReplyImpl.cpp 2016-02-25 16:08:01 +0000 | |||
197 | +++ src/scopes/internal/SearchReplyImpl.cpp 2016-06-28 08:18:23 +0000 | |||
198 | @@ -170,7 +170,12 @@ | |||
199 | 170 | return true; | 170 | return true; |
200 | 171 | } | 171 | } |
201 | 172 | 172 | ||
203 | 173 | bool SearchReplyImpl::push(unity::scopes::Filters const& filters, unity::scopes::FilterState const& filter_state) | 173 | bool SearchReplyImpl::push(unity::scopes::Filters const& filters, unity::scopes::FilterState const&) |
204 | 174 | { | ||
205 | 175 | return push(filters); | ||
206 | 176 | } | ||
207 | 177 | |||
208 | 178 | bool SearchReplyImpl::push(unity::scopes::Filters const& filters) | ||
209 | 174 | { | 179 | { |
210 | 175 | // basic consistency check | 180 | // basic consistency check |
211 | 176 | try | 181 | try |
212 | @@ -186,7 +191,6 @@ | |||
213 | 186 | { | 191 | { |
214 | 187 | lock_guard<mutex> lock(mutex_); | 192 | lock_guard<mutex> lock(mutex_); |
215 | 188 | cached_filters_ = filters; | 193 | cached_filters_ = filters; |
216 | 189 | cached_filter_state_ = filter_state; | ||
217 | 190 | } | 194 | } |
218 | 191 | 195 | ||
219 | 192 | VariantMap var; | 196 | VariantMap var; |
220 | @@ -196,7 +200,6 @@ | |||
221 | 196 | var["filter_groups"] = filter_groups; | 200 | var["filter_groups"] = filter_groups; |
222 | 197 | } | 201 | } |
223 | 198 | var["filters"] = internal::FilterBaseImpl::serialize_filters(filters); | 202 | var["filters"] = internal::FilterBaseImpl::serialize_filters(filters); |
224 | 199 | var["filter_state"] = filter_state.serialize(); | ||
225 | 200 | return ReplyImpl::push(var); | 203 | return ReplyImpl::push(var); |
226 | 201 | } | 204 | } |
227 | 202 | 205 | ||
228 | @@ -260,7 +263,6 @@ | |||
229 | 260 | departments = cached_departments_->serialize(); | 263 | departments = cached_departments_->serialize(); |
230 | 261 | } | 264 | } |
231 | 262 | auto filters = internal::FilterBaseImpl::serialize_filters(cached_filters_); | 265 | auto filters = internal::FilterBaseImpl::serialize_filters(cached_filters_); |
232 | 263 | auto filter_state = cached_filter_state_.serialize(); | ||
233 | 264 | VariantArray categories = cat_registry_->serialize(); | 266 | VariantArray categories = cat_registry_->serialize(); |
234 | 265 | VariantArray results; | 267 | VariantArray results; |
235 | 266 | for (auto const& r : cached_results_) | 268 | for (auto const& r : cached_results_) |
236 | @@ -279,7 +281,6 @@ | |||
237 | 279 | } | 281 | } |
238 | 280 | 282 | ||
239 | 281 | vm["filters"] = move(filters); | 283 | vm["filters"] = move(filters); |
240 | 282 | vm["filter_state"] = move(filter_state); | ||
241 | 283 | 284 | ||
242 | 284 | vm["results"] = move(results); | 285 | vm["results"] = move(results); |
243 | 285 | string const json = Variant(move(vm)).serialize_json(); | 286 | string const json = Variant(move(vm)).serialize_json(); |
244 | @@ -371,13 +372,6 @@ | |||
245 | 371 | } | 372 | } |
246 | 372 | auto filter_array = it->second.get_array(); | 373 | auto filter_array = it->second.get_array(); |
247 | 373 | 374 | ||
248 | 374 | it = vm.find("filter_state"); | ||
249 | 375 | if (it == vm.end()) | ||
250 | 376 | { | ||
251 | 377 | throw unity::scopes::NotFoundException("malformed cache file", "filter_state"); | ||
252 | 378 | } | ||
253 | 379 | auto filter_state_dict = it->second.get_dict(); | ||
254 | 380 | |||
255 | 381 | it = vm.find("results"); | 375 | it = vm.find("results"); |
256 | 382 | if (it == vm.end()) | 376 | if (it == vm.end()) |
257 | 383 | { | 377 | { |
258 | @@ -408,8 +402,7 @@ | |||
259 | 408 | } | 402 | } |
260 | 409 | 403 | ||
261 | 410 | auto filters = FilterBaseImpl::deserialize_filters(move(filter_array), groups); | 404 | auto filters = FilterBaseImpl::deserialize_filters(move(filter_array), groups); |
264 | 411 | auto filter_state = FilterStateImpl::deserialize(move(filter_state_dict)); | 405 | push(filters); |
263 | 412 | push(filters, filter_state); | ||
265 | 413 | 406 | ||
266 | 414 | for (auto const& r : result_array) | 407 | for (auto const& r : result_array) |
267 | 415 | { | 408 | { |
268 | 416 | 409 | ||
269 | === modified file 'src/scopes/testing/InProcessBenchmark.cpp' | |||
270 | --- src/scopes/testing/InProcessBenchmark.cpp 2015-01-09 07:10:07 +0000 | |||
271 | +++ src/scopes/testing/InProcessBenchmark.cpp 2016-06-28 08:18:23 +0000 | |||
272 | @@ -204,6 +204,11 @@ | |||
273 | 204 | return true; | 204 | return true; |
274 | 205 | } | 205 | } |
275 | 206 | 206 | ||
276 | 207 | bool push(unity::scopes::Filters const&) override | ||
277 | 208 | { | ||
278 | 209 | return true; | ||
279 | 210 | } | ||
280 | 211 | |||
281 | 207 | bool push(unity::scopes::experimental::Annotation const&) override | 212 | bool push(unity::scopes::experimental::Annotation const&) override |
282 | 208 | { | 213 | { |
283 | 209 | return true; | 214 | return true; |
284 | 210 | 215 | ||
285 | === modified file 'src/scopes/utility/internal/BufferedSearchReplyImpl.cpp' | |||
286 | --- src/scopes/utility/internal/BufferedSearchReplyImpl.cpp 2015-02-27 05:28:09 +0000 | |||
287 | +++ src/scopes/utility/internal/BufferedSearchReplyImpl.cpp 2016-06-28 08:18:23 +0000 | |||
288 | @@ -92,6 +92,11 @@ | |||
289 | 92 | return upstream_->push(filters, filter_state); | 92 | return upstream_->push(filters, filter_state); |
290 | 93 | } | 93 | } |
291 | 94 | 94 | ||
292 | 95 | bool BufferedSearchReplyImpl::push(unity::scopes::Filters const& filters) | ||
293 | 96 | { | ||
294 | 97 | return upstream_->push(filters); | ||
295 | 98 | } | ||
296 | 99 | |||
297 | 95 | void BufferedSearchReplyImpl::push_surfacing_results_from_cache() noexcept | 100 | void BufferedSearchReplyImpl::push_surfacing_results_from_cache() noexcept |
298 | 96 | { | 101 | { |
299 | 97 | upstream_->push_surfacing_results_from_cache(); | 102 | upstream_->push_surfacing_results_from_cache(); |
300 | 98 | 103 | ||
301 | === modified file 'test/gtest/scopes/Filters/Filters_test.cpp' | |||
302 | --- test/gtest/scopes/Filters/Filters_test.cpp 2016-03-03 11:46:25 +0000 | |||
303 | +++ test/gtest/scopes/Filters/Filters_test.cpp 2016-06-28 08:18:23 +0000 | |||
304 | @@ -66,12 +66,19 @@ | |||
305 | 66 | class SearchReceiver : public SearchListenerBase, public WaitUntilFinished | 66 | class SearchReceiver : public SearchListenerBase, public WaitUntilFinished |
306 | 67 | { | 67 | { |
307 | 68 | public: | 68 | public: |
311 | 69 | virtual void push(CategorisedResult /* result */) override {} | 69 | virtual void push(CategorisedResult result) override |
312 | 70 | 70 | { | |
313 | 71 | virtual void push(Filters const& filters, FilterState const& filter_state) override | 71 | result_uri = result.uri(); |
314 | 72 | } | ||
315 | 73 | |||
316 | 74 | virtual void push(Filters const& filters, FilterState const&) override | ||
317 | 75 | { | ||
318 | 76 | this->filters2 = filters; | ||
319 | 77 | } | ||
320 | 78 | |||
321 | 79 | virtual void push(Filters const& filters) override | ||
322 | 72 | { | 80 | { |
323 | 73 | this->filters = filters; | 81 | this->filters = filters; |
324 | 74 | this->filter_state = filter_state; | ||
325 | 75 | } | 82 | } |
326 | 76 | 83 | ||
327 | 77 | virtual void finished(CompletionDetails const& details) override | 84 | virtual void finished(CompletionDetails const& details) override |
328 | @@ -81,7 +88,8 @@ | |||
329 | 81 | } | 88 | } |
330 | 82 | 89 | ||
331 | 83 | Filters filters; | 90 | Filters filters; |
333 | 84 | FilterState filter_state; | 91 | Filters filters2; |
334 | 92 | std::string result_uri; | ||
335 | 85 | }; | 93 | }; |
336 | 86 | 94 | ||
337 | 87 | template <typename ScopeType> | 95 | template <typename ScopeType> |
338 | @@ -135,8 +143,13 @@ | |||
339 | 135 | auto ctrl = scope->search("test", hints, receiver); | 143 | auto ctrl = scope->search("test", hints, receiver); |
340 | 136 | receiver->wait_until_finished(); | 144 | receiver->wait_until_finished(); |
341 | 137 | 145 | ||
343 | 138 | auto filter_state = receiver->filter_state; // copy filter state, it will be sent with 2nd query | 146 | EXPECT_EQ("no options active", receiver->result_uri); |
344 | 147 | |||
345 | 148 | FilterState filter_state; | ||
346 | 139 | { | 149 | { |
347 | 150 | // make sure the deprecated API push method for filters still works | ||
348 | 151 | ASSERT_EQ(1u, receiver->filters2.size()); | ||
349 | 152 | |||
350 | 140 | auto filters = receiver->filters; | 153 | auto filters = receiver->filters; |
351 | 141 | ASSERT_EQ(1u, filters.size()); | 154 | ASSERT_EQ(1u, filters.size()); |
352 | 142 | EXPECT_EQ("f1", filters.front()->id()); | 155 | EXPECT_EQ("f1", filters.front()->id()); |
353 | @@ -159,11 +172,9 @@ | |||
354 | 159 | receiver->wait_until_finished(); | 172 | receiver->wait_until_finished(); |
355 | 160 | { | 173 | { |
356 | 161 | auto filters = receiver->filters; | 174 | auto filters = receiver->filters; |
358 | 162 | auto filter_state2 = receiver->filter_state; | 175 | ASSERT_EQ(1u, filters.size()); |
359 | 163 | auto selector = std::dynamic_pointer_cast<const OptionSelectorFilter>(filters.front()); | 176 | auto selector = std::dynamic_pointer_cast<const OptionSelectorFilter>(filters.front()); |
363 | 164 | ASSERT_EQ(1u, selector->active_options(filter_state2).size()); | 177 | EXPECT_EQ("option o1 active", receiver->result_uri); |
361 | 165 | auto option1 = *(selector->active_options(filter_state2).begin()); | ||
362 | 166 | EXPECT_EQ("o1", option1->id()); | ||
364 | 167 | } | 178 | } |
365 | 168 | } | 179 | } |
366 | 169 | 180 | ||
367 | 170 | 181 | ||
368 | === modified file 'test/gtest/scopes/Filters/TestScope.h' | |||
369 | --- test/gtest/scopes/Filters/TestScope.h 2016-02-25 16:08:01 +0000 | |||
370 | +++ test/gtest/scopes/Filters/TestScope.h 2016-06-28 08:18:23 +0000 | |||
371 | @@ -21,6 +21,7 @@ | |||
372 | 21 | #include <unity/scopes/CategorisedResult.h> | 21 | #include <unity/scopes/CategorisedResult.h> |
373 | 22 | #include <unity/scopes/Category.h> | 22 | #include <unity/scopes/Category.h> |
374 | 23 | #include <unity/scopes/FilterGroup.h> | 23 | #include <unity/scopes/FilterGroup.h> |
375 | 24 | #include <unity/scopes/FilterOption.h> | ||
376 | 24 | #include <unity/scopes/OptionSelectorFilter.h> | 25 | #include <unity/scopes/OptionSelectorFilter.h> |
377 | 25 | #include <unity/scopes/ScopeBase.h> | 26 | #include <unity/scopes/ScopeBase.h> |
378 | 26 | #include <unity/scopes/SearchReply.h> | 27 | #include <unity/scopes/SearchReply.h> |
379 | @@ -49,11 +50,27 @@ | |||
380 | 49 | filter->add_option("o2", "Option 2"); | 50 | filter->add_option("o2", "Option 2"); |
381 | 50 | filters.push_back(filter); | 51 | filters.push_back(filter); |
382 | 51 | auto active_opts = filter->active_options(query().filter_state()); | 52 | auto active_opts = filter->active_options(query().filter_state()); |
384 | 52 | reply->push(filters, query().filter_state()); // send unmodified state back | 53 | |
385 | 54 | if (query().query_string() == "test") | ||
386 | 55 | { | ||
387 | 56 | reply->push(filters); | ||
388 | 57 | } | ||
389 | 58 | else | ||
390 | 59 | { | ||
391 | 60 | // use the deprecated push call | ||
392 | 61 | reply->push(filters, query().filter_state()); | ||
393 | 62 | } | ||
394 | 53 | 63 | ||
395 | 54 | auto cat = reply->register_category("cat1", "Category 1", ""); | 64 | auto cat = reply->register_category("cat1", "Category 1", ""); |
396 | 55 | CategorisedResult res(cat); | 65 | CategorisedResult res(cat); |
398 | 56 | res.set_uri("uri"); | 66 | if (active_opts.size() == 1) |
399 | 67 | { | ||
400 | 68 | res.set_uri("option " + (*(active_opts.begin()))->id() + " active"); | ||
401 | 69 | } | ||
402 | 70 | else | ||
403 | 71 | { | ||
404 | 72 | res.set_uri("no options active"); | ||
405 | 73 | } | ||
406 | 57 | res.set_dnd_uri("dnd_uri"); | 74 | res.set_dnd_uri("dnd_uri"); |
407 | 58 | reply->push(res); | 75 | reply->push(res); |
408 | 59 | } | 76 | } |
409 | 60 | 77 | ||
410 | === modified file 'test/gtest/scopes/ResultCache/ResultCache_test.cpp' | |||
411 | --- test/gtest/scopes/ResultCache/ResultCache_test.cpp 2016-02-25 17:28:22 +0000 | |||
412 | +++ test/gtest/scopes/ResultCache/ResultCache_test.cpp 2016-06-28 08:18:23 +0000 | |||
413 | @@ -46,11 +46,10 @@ | |||
414 | 46 | dept_ = parent; | 46 | dept_ = parent; |
415 | 47 | } | 47 | } |
416 | 48 | 48 | ||
418 | 49 | virtual void push(Filters const& filters, FilterState const& filter_state) override | 49 | virtual void push(Filters const& filters) override |
419 | 50 | { | 50 | { |
420 | 51 | lock_guard<mutex> lock(mutex_); | 51 | lock_guard<mutex> lock(mutex_); |
421 | 52 | filters_ = filters; | 52 | filters_ = filters; |
422 | 53 | filter_state_ = filter_state; | ||
423 | 54 | } | 53 | } |
424 | 55 | 54 | ||
425 | 56 | virtual void push(CategorisedResult result) override | 55 | virtual void push(CategorisedResult result) override |
426 | @@ -86,12 +85,6 @@ | |||
427 | 86 | return filters_; | 85 | return filters_; |
428 | 87 | } | 86 | } |
429 | 88 | 87 | ||
430 | 89 | FilterState filter_state() const | ||
431 | 90 | { | ||
432 | 91 | lock_guard<mutex> lock(mutex_); | ||
433 | 92 | return filter_state_; | ||
434 | 93 | } | ||
435 | 94 | |||
436 | 95 | CategorisedResult::SCPtr result() const | 88 | CategorisedResult::SCPtr result() const |
437 | 96 | { | 89 | { |
438 | 97 | lock_guard<mutex> lock(mutex_); | 90 | lock_guard<mutex> lock(mutex_); |
439 | @@ -101,7 +94,6 @@ | |||
440 | 101 | private: | 94 | private: |
441 | 102 | Department::SCPtr dept_; | 95 | Department::SCPtr dept_; |
442 | 103 | Filters filters_; | 96 | Filters filters_; |
443 | 104 | FilterState filter_state_; | ||
444 | 105 | CategorisedResult::SCPtr result_; | 97 | CategorisedResult::SCPtr result_; |
445 | 106 | bool query_complete_; | 98 | bool query_complete_; |
446 | 107 | mutable mutex mutex_; | 99 | mutable mutex mutex_; |
447 | @@ -248,9 +240,6 @@ | |||
448 | 248 | auto osf = dynamic_pointer_cast<OptionSelectorFilter const>(f); | 240 | auto osf = dynamic_pointer_cast<OptionSelectorFilter const>(f); |
449 | 249 | ASSERT_TRUE(osf != nullptr); | 241 | ASSERT_TRUE(osf != nullptr); |
450 | 250 | EXPECT_EQ("Choose an option", osf->label()); | 242 | EXPECT_EQ("Choose an option", osf->label()); |
451 | 251 | auto fs = receiver->filter_state(); | ||
452 | 252 | EXPECT_TRUE(fs.has_filter("f1")); | ||
453 | 253 | EXPECT_TRUE(osf->has_active_option(fs)); | ||
454 | 254 | 243 | ||
455 | 255 | // Cache file must still be there. | 244 | // Cache file must still be there. |
456 | 256 | boost::system::error_code ec; | 245 | boost::system::error_code ec; |
457 | @@ -290,9 +279,6 @@ | |||
458 | 290 | auto osf = dynamic_pointer_cast<OptionSelectorFilter const>(f); | 279 | auto osf = dynamic_pointer_cast<OptionSelectorFilter const>(f); |
459 | 291 | ASSERT_TRUE(osf != nullptr); | 280 | ASSERT_TRUE(osf != nullptr); |
460 | 292 | EXPECT_EQ("Choose an option", osf->label()); | 281 | EXPECT_EQ("Choose an option", osf->label()); |
461 | 293 | auto fs = receiver->filter_state(); | ||
462 | 294 | EXPECT_TRUE(fs.has_filter("f1")); | ||
463 | 295 | EXPECT_TRUE(osf->has_active_option(fs)); | ||
464 | 296 | 282 | ||
465 | 297 | // Cache file must still be there. | 283 | // Cache file must still be there. |
466 | 298 | boost::system::error_code ec; | 284 | boost::system::error_code ec; |
467 | @@ -344,9 +330,6 @@ | |||
468 | 344 | auto osf = dynamic_pointer_cast<OptionSelectorFilter const>(f); | 330 | auto osf = dynamic_pointer_cast<OptionSelectorFilter const>(f); |
469 | 345 | ASSERT_TRUE(osf != nullptr); | 331 | ASSERT_TRUE(osf != nullptr); |
470 | 346 | EXPECT_EQ("Choose an option", osf->label()); | 332 | EXPECT_EQ("Choose an option", osf->label()); |
471 | 347 | auto fs = receiver->filter_state(); | ||
472 | 348 | EXPECT_TRUE(fs.has_filter("f1")); | ||
473 | 349 | EXPECT_TRUE(osf->has_active_option(fs)); | ||
474 | 350 | 333 | ||
475 | 351 | // New cache file must have been created | 334 | // New cache file must have been created |
476 | 352 | boost::system::error_code ec; | 335 | boost::system::error_code ec; |
477 | @@ -414,20 +397,6 @@ | |||
478 | 414 | EXPECT_TRUE(boost::filesystem::exists(TEST_RUNTIME_PATH "/unconfined/CacheScope/.surfacing_cache", ec)); | 397 | EXPECT_TRUE(boost::filesystem::exists(TEST_RUNTIME_PATH "/unconfined/CacheScope/.surfacing_cache", ec)); |
479 | 415 | } | 398 | } |
480 | 416 | 399 | ||
481 | 417 | TEST_F(CacheScopeTest, missing_filter_state) | ||
482 | 418 | { | ||
483 | 419 | // Get coverage on missing filters_state entry | ||
484 | 420 | system("cp " TEST_SOURCE_PATH "/no_filter_state_cache " TEST_RUNTIME_PATH "/unconfined/CacheScope/.surfacing_cache"); | ||
485 | 421 | auto receiver = make_shared<Receiver>(); | ||
486 | 422 | scope()->search("", SearchMetadata("unused", "unused"), receiver); | ||
487 | 423 | receiver->wait_until_finished(); | ||
488 | 424 | EXPECT_EQ(receiver->result(), nullptr); | ||
489 | 425 | |||
490 | 426 | // Cache file must still be there, but decode will have failed. | ||
491 | 427 | boost::system::error_code ec; | ||
492 | 428 | EXPECT_TRUE(boost::filesystem::exists(TEST_RUNTIME_PATH "/unconfined/CacheScope/.surfacing_cache", ec)); | ||
493 | 429 | } | ||
494 | 430 | |||
495 | 431 | TEST_F(CacheScopeTest, missing_results) | 400 | TEST_F(CacheScopeTest, missing_results) |
496 | 432 | { | 401 | { |
497 | 433 | // Get coverage on missing results entry | 402 | // Get coverage on missing results entry |
498 | 434 | 403 | ||
499 | === removed file 'test/gtest/scopes/ResultCache/no_filter_state_cache' | |||
500 | --- test/gtest/scopes/ResultCache/no_filter_state_cache 2015-02-05 09:35:42 +0000 | |||
501 | +++ test/gtest/scopes/ResultCache/no_filter_state_cache 1970-01-01 00:00:00 +0000 | |||
502 | @@ -1,1 +0,0 @@ | |||
503 | 1 | {"categories":[{"icon":"","id":"CacheScope","renderer_template":"\n {\n \"schema-version\":1,\n \"template\":\n {\n \"category-layout\":\"grid\"\n },\n \"components\":\n {\n \"title\":\"title\",\n \"art\":\"art\"\n }\n }\n ","title":""}],"departments":{"departments":[{"label":"Sub","query":{"department_id":"sub","filter_state":{},"query_string":"","scope":"CacheScope"}}],"label":"Top","query":{"department_id":"","filter_state":{},"query_string":"","scope":"CacheScope"}},"filters":[{"filter_type":"option_selector","id":"f1","label":"Choose an option","multi_select":false,"options":[{"id":"o1","label":"Option 1"},{"id":"o2","label":"Option 2"}]}],"results":[{"attrs":{"title":"","uri":"uri"},"internal":{"cat_id":"CacheScope"}}]} |
FAILED: Continuous integration, rev:681 /jenkins. canonical. com/unity- api-1/job/ lp-unity- scopes- api-ci/ 27/ /jenkins. canonical. com/unity- api-1/job/ build/78/ console /jenkins. canonical. com/unity- api-1/job/ build-0- fetch/85/ console
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/unity- api-1/job/ lp-unity- scopes- api-ci/ 27/rebuild
https:/