Merge lp:~stolowski/unity-scopes-api/update-push-filters into lp:unity-scopes-api/devel

Proposed by Paweł Stołowski
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
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: mp+297348@code.launchpad.net

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.

To post a comment you must log in.
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

Looking good. Just a few inline comments, mostly grammatical.

review: Needs Fixing
682. By Paweł Stołowski

Review comments

Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
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 ;)...

Revision history for this message
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

review: Needs Fixing
683. By Paweł Stołowski

Merged devel

Revision history for this message
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.

Revision history for this message
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

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'RELEASE_NOTES.md'
--- RELEASE_NOTES.md 2016-05-23 07:55:39 +0000
+++ RELEASE_NOTES.md 2016-06-28 08:18:23 +0000
@@ -1,6 +1,11 @@
1Release notes1Release notes
2=============2=============
33
4Changes in version 1.0.7
5========================
6 - Marked the push(Filters const&, FilterState const&) method of SearchReply and SearchListenerBase
7 as deprecated and provided push methods which take the Filters argument only.
8
4Changes in version 1.0.69Changes in version 1.0.6
5========================10========================
6 - Got rid of category header background, as per design (Bug #1446216).11 - Got rid of category header background, as per design (Bug #1446216).
712
=== modified file 'STRUCTS'
--- STRUCTS 2016-02-25 16:26:09 +0000
+++ STRUCTS 2016-06-28 08:18:23 +0000
@@ -142,10 +142,9 @@
142 'central_label' : string142 'central_label' : string
143 'filter_group' : string, optional143 'filter_group' : string, optional
144144
145Filters + FilterState145Filters
146=====================146=======
147 'filter' : array of filters (implementations of FilterBase)147 'filter' : array of filters (implementations of FilterBase)
148 'filter_state' : FilterState
149148
150PreviewResult (returned by serialize())149PreviewResult (returned by serialize())
151=======================================150=======================================
152151
=== modified file 'debian/VERSION'
--- debian/VERSION 2016-05-23 07:56:41 +0000
+++ debian/VERSION 2016-06-28 08:18:23 +0000
@@ -1,1 +1,1 @@
11.0.611.0.7
22
=== modified file 'debian/changelog'
--- debian/changelog 2016-06-17 07:27:25 +0000
+++ debian/changelog 2016-06-28 08:18:23 +0000
@@ -1,3 +1,11 @@
1unity-scopes-api (1.0.7-0ubuntu1) UNRELEASED; urgency=medium
2
3 * Marked the push(Filters const&, FilterState const&) method of SearchReply
4 and SearchListenerBase as deprecated and provided push methods which take
5 the Filters argument only.
6
7 -- Pawel Stolowski <pawel.stolowski@canonical.com> Tue, 28 Jun 2016 10:11:22 +0200
8
1unity-scopes-api (1.0.6+16.10.20160617-0ubuntu1) yakkety; urgency=medium9unity-scopes-api (1.0.6+16.10.20160617-0ubuntu1) yakkety; urgency=medium
210
3 [ Marcus Tomlinson ]11 [ Marcus Tomlinson ]
412
=== modified file 'include/unity/scopes/SearchListenerBase.h'
--- include/unity/scopes/SearchListenerBase.h 2015-09-01 22:19:45 +0000
+++ include/unity/scopes/SearchListenerBase.h 2016-06-28 08:18:23 +0000
@@ -96,10 +96,19 @@
96 /**96 /**
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.
9898
99 \deprecated Please override the push(Filters& const) method instead. This method will be removed from future releases.
100
99 The default implementation does nothing.101 The default implementation does nothing.
100 */102 */
101 virtual void push(Filters const& filters, FilterState const& filter_state);103 virtual void push(Filters const& filters, FilterState const& filter_state);
102104
105 /**
106 \brief Called once by the scope to send all filters and their states.
107
108 The default implementation does nothing.
109 */
110 virtual void push(Filters const& filters);
111
103protected:112protected:
104 /// @cond113 /// @cond
105 SearchListenerBase();114 SearchListenerBase();
106115
=== modified file 'include/unity/scopes/SearchReply.h'
--- include/unity/scopes/SearchReply.h 2015-10-29 02:35:50 +0000
+++ include/unity/scopes/SearchReply.h 2016-06-28 08:18:23 +0000
@@ -139,7 +139,8 @@
139 virtual bool push(experimental::Annotation const& annotation) = 0;139 virtual bool push(experimental::Annotation const& annotation) = 0;
140140
141 /**141 /**
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.
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.
143 \return True if the filters were accepted, false otherwise.144 \return True if the filters were accepted, false otherwise.
144 */145 */
145 virtual bool push(Filters const& filters, FilterState const& filter_state) = 0;146 virtual bool push(Filters const& filters, FilterState const& filter_state) = 0;
@@ -190,6 +191,12 @@
190 */191 */
191 virtual void push_surfacing_results_from_cache() = 0;192 virtual void push_surfacing_results_from_cache() = 0;
192193
194 /**
195 \brief Sends all filter definitions to the source of a query.
196 \return True if the filters were accepted, false otherwise.
197 */
198 virtual bool push(Filters const& filters) = 0;
199
193protected:200protected:
194 /// @cond201 /// @cond
195 SearchReply();202 SearchReply();
196203
=== modified file 'include/unity/scopes/internal/SearchReplyImpl.h'
--- include/unity/scopes/internal/SearchReplyImpl.h 2015-02-27 05:28:09 +0000
+++ include/unity/scopes/internal/SearchReplyImpl.h 2016-06-28 08:18:23 +0000
@@ -80,6 +80,8 @@
8080
81 virtual void push_surfacing_results_from_cache() noexcept override;81 virtual void push_surfacing_results_from_cache() noexcept override;
8282
83 virtual bool push(unity::scopes::Filters const& filters) override;
84
83private:85private:
84 bool push(Category::SCPtr category);86 bool push(Category::SCPtr category);
85 void write_cached_results() noexcept;87 void write_cached_results() noexcept;
@@ -94,7 +96,6 @@
9496
95 Department::SCPtr cached_departments_;97 Department::SCPtr cached_departments_;
96 unity::scopes::Filters cached_filters_;98 unity::scopes::Filters cached_filters_;
97 unity::scopes::FilterState cached_filter_state_;
98 std::vector<unity::scopes::CategorisedResult> cached_results_;99 std::vector<unity::scopes::CategorisedResult> cached_results_;
99 std::mutex mutex_;100 std::mutex mutex_;
100};101};
101102
=== modified file 'include/unity/scopes/testing/MockSearchReply.h'
--- include/unity/scopes/testing/MockSearchReply.h 2015-04-10 10:10:06 +0000
+++ include/unity/scopes/testing/MockSearchReply.h 2016-06-28 08:18:23 +0000
@@ -66,6 +66,7 @@
66 MOCK_METHOD1(lookup_category, Category::SCPtr(std::string const&));66 MOCK_METHOD1(lookup_category, Category::SCPtr(std::string const&));
67 MOCK_METHOD1(push, bool(CategorisedResult const&));67 MOCK_METHOD1(push, bool(CategorisedResult const&));
68 MOCK_METHOD2(push, bool(Filters const&, FilterState const&));68 MOCK_METHOD2(push, bool(Filters const&, FilterState const&));
69 MOCK_METHOD1(push, bool(Filters const&));
69 MOCK_METHOD1(push, bool(experimental::Annotation const& annotation));70 MOCK_METHOD1(push, bool(experimental::Annotation const& annotation));
70 MOCK_METHOD0(push_surfacing_results_from_cache, void());71 MOCK_METHOD0(push_surfacing_results_from_cache, void());
7172
7273
=== modified file 'include/unity/scopes/utility/internal/BufferedSearchReplyImpl.h'
--- include/unity/scopes/utility/internal/BufferedSearchReplyImpl.h 2015-02-27 05:28:09 +0000
+++ include/unity/scopes/utility/internal/BufferedSearchReplyImpl.h 2016-06-28 08:18:23 +0000
@@ -78,6 +78,7 @@
78 std::string to_string() override;78 std::string to_string() override;
7979
80 void flush();80 void flush();
81 bool push(unity::scopes::Filters const& filters) override;
8182
82private:83private:
83 std::mutex mutex_;84 std::mutex mutex_;
8485
=== modified file 'src/scopes/SearchListenerBase.cpp'
--- src/scopes/SearchListenerBase.cpp 2014-06-17 15:07:13 +0000
+++ src/scopes/SearchListenerBase.cpp 2016-06-28 08:18:23 +0000
@@ -44,6 +44,11 @@
44 // Intentionally empty: "do nothing" default implementation.44 // Intentionally empty: "do nothing" default implementation.
45}45}
4646
47void SearchListenerBase::push(Filters const& /* filters */)
48{
49 // Intentionally empty: "do nothing" default implementation.
50}
51
47void SearchListenerBase::push(Category::SCPtr const& /* category */)52void SearchListenerBase::push(Category::SCPtr const& /* category */)
48{53{
49 // Intentionally empty: "do nothing" default implementation.54 // Intentionally empty: "do nothing" default implementation.
5055
=== modified file 'src/scopes/internal/ResultReplyObject.cpp'
--- src/scopes/internal/ResultReplyObject.cpp 2016-02-24 16:49:34 +0000
+++ src/scopes/internal/ResultReplyObject.cpp 2016-06-28 08:18:23 +0000
@@ -74,16 +74,11 @@
74 }74 }
7575
76 Filters const filters = FilterBaseImpl::deserialize_filters(it->second.get_array(), groups);76 Filters const filters = FilterBaseImpl::deserialize_filters(it->second.get_array(), groups);
77 it = data.find("filter_state");77
78 if (it != data.end())78 // temporarily support both variants of push until the one supporting filter state gets dropped.
79 {79 FilterState filter_state;
80 auto filter_state = FilterStateImpl::deserialize(it->second.get_dict());80 receiver_->push(filters, filter_state);
81 receiver_->push(filters, filter_state);81 receiver_->push(filters);
82 }
83 else
84 {
85 throw InvalidArgumentException("ResultReplyObject::push(): filters present but missing filter_state data");
86 }
87 }82 }
8883
89 it = data.find("category");84 it = data.find("category");
9085
=== modified file 'src/scopes/internal/SearchReplyImpl.cpp'
--- src/scopes/internal/SearchReplyImpl.cpp 2016-02-25 16:08:01 +0000
+++ src/scopes/internal/SearchReplyImpl.cpp 2016-06-28 08:18:23 +0000
@@ -170,7 +170,12 @@
170 return true;170 return true;
171}171}
172172
173bool SearchReplyImpl::push(unity::scopes::Filters const& filters, unity::scopes::FilterState const& filter_state)173bool SearchReplyImpl::push(unity::scopes::Filters const& filters, unity::scopes::FilterState const&)
174{
175 return push(filters);
176}
177
178bool SearchReplyImpl::push(unity::scopes::Filters const& filters)
174{179{
175 // basic consistency check180 // basic consistency check
176 try181 try
@@ -186,7 +191,6 @@
186 {191 {
187 lock_guard<mutex> lock(mutex_);192 lock_guard<mutex> lock(mutex_);
188 cached_filters_ = filters;193 cached_filters_ = filters;
189 cached_filter_state_ = filter_state;
190 }194 }
191195
192 VariantMap var;196 VariantMap var;
@@ -196,7 +200,6 @@
196 var["filter_groups"] = filter_groups;200 var["filter_groups"] = filter_groups;
197 }201 }
198 var["filters"] = internal::FilterBaseImpl::serialize_filters(filters);202 var["filters"] = internal::FilterBaseImpl::serialize_filters(filters);
199 var["filter_state"] = filter_state.serialize();
200 return ReplyImpl::push(var);203 return ReplyImpl::push(var);
201}204}
202205
@@ -260,7 +263,6 @@
260 departments = cached_departments_->serialize();263 departments = cached_departments_->serialize();
261 }264 }
262 auto filters = internal::FilterBaseImpl::serialize_filters(cached_filters_);265 auto filters = internal::FilterBaseImpl::serialize_filters(cached_filters_);
263 auto filter_state = cached_filter_state_.serialize();
264 VariantArray categories = cat_registry_->serialize();266 VariantArray categories = cat_registry_->serialize();
265 VariantArray results;267 VariantArray results;
266 for (auto const& r : cached_results_)268 for (auto const& r : cached_results_)
@@ -279,7 +281,6 @@
279 }281 }
280282
281 vm["filters"] = move(filters);283 vm["filters"] = move(filters);
282 vm["filter_state"] = move(filter_state);
283284
284 vm["results"] = move(results);285 vm["results"] = move(results);
285 string const json = Variant(move(vm)).serialize_json();286 string const json = Variant(move(vm)).serialize_json();
@@ -371,13 +372,6 @@
371 }372 }
372 auto filter_array = it->second.get_array();373 auto filter_array = it->second.get_array();
373374
374 it = vm.find("filter_state");
375 if (it == vm.end())
376 {
377 throw unity::scopes::NotFoundException("malformed cache file", "filter_state");
378 }
379 auto filter_state_dict = it->second.get_dict();
380
381 it = vm.find("results");375 it = vm.find("results");
382 if (it == vm.end())376 if (it == vm.end())
383 {377 {
@@ -408,8 +402,7 @@
408 }402 }
409403
410 auto filters = FilterBaseImpl::deserialize_filters(move(filter_array), groups);404 auto filters = FilterBaseImpl::deserialize_filters(move(filter_array), groups);
411 auto filter_state = FilterStateImpl::deserialize(move(filter_state_dict));405 push(filters);
412 push(filters, filter_state);
413406
414 for (auto const& r : result_array)407 for (auto const& r : result_array)
415 {408 {
416409
=== modified file 'src/scopes/testing/InProcessBenchmark.cpp'
--- src/scopes/testing/InProcessBenchmark.cpp 2015-01-09 07:10:07 +0000
+++ src/scopes/testing/InProcessBenchmark.cpp 2016-06-28 08:18:23 +0000
@@ -204,6 +204,11 @@
204 return true;204 return true;
205 }205 }
206206
207 bool push(unity::scopes::Filters const&) override
208 {
209 return true;
210 }
211
207 bool push(unity::scopes::experimental::Annotation const&) override212 bool push(unity::scopes::experimental::Annotation const&) override
208 {213 {
209 return true;214 return true;
210215
=== modified file 'src/scopes/utility/internal/BufferedSearchReplyImpl.cpp'
--- src/scopes/utility/internal/BufferedSearchReplyImpl.cpp 2015-02-27 05:28:09 +0000
+++ src/scopes/utility/internal/BufferedSearchReplyImpl.cpp 2016-06-28 08:18:23 +0000
@@ -92,6 +92,11 @@
92 return upstream_->push(filters, filter_state);92 return upstream_->push(filters, filter_state);
93}93}
9494
95bool BufferedSearchReplyImpl::push(unity::scopes::Filters const& filters)
96{
97 return upstream_->push(filters);
98}
99
95void BufferedSearchReplyImpl::push_surfacing_results_from_cache() noexcept100void BufferedSearchReplyImpl::push_surfacing_results_from_cache() noexcept
96{101{
97 upstream_->push_surfacing_results_from_cache();102 upstream_->push_surfacing_results_from_cache();
98103
=== modified file 'test/gtest/scopes/Filters/Filters_test.cpp'
--- test/gtest/scopes/Filters/Filters_test.cpp 2016-03-03 11:46:25 +0000
+++ test/gtest/scopes/Filters/Filters_test.cpp 2016-06-28 08:18:23 +0000
@@ -66,12 +66,19 @@
66class SearchReceiver : public SearchListenerBase, public WaitUntilFinished66class SearchReceiver : public SearchListenerBase, public WaitUntilFinished
67{67{
68public:68public:
69 virtual void push(CategorisedResult /* result */) override {}69 virtual void push(CategorisedResult result) override
7070 {
71 virtual void push(Filters const& filters, FilterState const& filter_state) override71 result_uri = result.uri();
72 }
73
74 virtual void push(Filters const& filters, FilterState const&) override
75 {
76 this->filters2 = filters;
77 }
78
79 virtual void push(Filters const& filters) override
72 {80 {
73 this->filters = filters;81 this->filters = filters;
74 this->filter_state = filter_state;
75 }82 }
7683
77 virtual void finished(CompletionDetails const& details) override84 virtual void finished(CompletionDetails const& details) override
@@ -81,7 +88,8 @@
81 }88 }
8289
83 Filters filters;90 Filters filters;
84 FilterState filter_state;91 Filters filters2;
92 std::string result_uri;
85};93};
8694
87template <typename ScopeType>95template <typename ScopeType>
@@ -135,8 +143,13 @@
135 auto ctrl = scope->search("test", hints, receiver);143 auto ctrl = scope->search("test", hints, receiver);
136 receiver->wait_until_finished();144 receiver->wait_until_finished();
137145
138 auto filter_state = receiver->filter_state; // copy filter state, it will be sent with 2nd query146 EXPECT_EQ("no options active", receiver->result_uri);
147
148 FilterState filter_state;
139 {149 {
150 // make sure the deprecated API push method for filters still works
151 ASSERT_EQ(1u, receiver->filters2.size());
152
140 auto filters = receiver->filters;153 auto filters = receiver->filters;
141 ASSERT_EQ(1u, filters.size());154 ASSERT_EQ(1u, filters.size());
142 EXPECT_EQ("f1", filters.front()->id());155 EXPECT_EQ("f1", filters.front()->id());
@@ -159,11 +172,9 @@
159 receiver->wait_until_finished();172 receiver->wait_until_finished();
160 {173 {
161 auto filters = receiver->filters;174 auto filters = receiver->filters;
162 auto filter_state2 = receiver->filter_state;175 ASSERT_EQ(1u, filters.size());
163 auto selector = std::dynamic_pointer_cast<const OptionSelectorFilter>(filters.front());176 auto selector = std::dynamic_pointer_cast<const OptionSelectorFilter>(filters.front());
164 ASSERT_EQ(1u, selector->active_options(filter_state2).size());177 EXPECT_EQ("option o1 active", receiver->result_uri);
165 auto option1 = *(selector->active_options(filter_state2).begin());
166 EXPECT_EQ("o1", option1->id());
167 }178 }
168}179}
169180
170181
=== modified file 'test/gtest/scopes/Filters/TestScope.h'
--- test/gtest/scopes/Filters/TestScope.h 2016-02-25 16:08:01 +0000
+++ test/gtest/scopes/Filters/TestScope.h 2016-06-28 08:18:23 +0000
@@ -21,6 +21,7 @@
21#include <unity/scopes/CategorisedResult.h>21#include <unity/scopes/CategorisedResult.h>
22#include <unity/scopes/Category.h>22#include <unity/scopes/Category.h>
23#include <unity/scopes/FilterGroup.h>23#include <unity/scopes/FilterGroup.h>
24#include <unity/scopes/FilterOption.h>
24#include <unity/scopes/OptionSelectorFilter.h>25#include <unity/scopes/OptionSelectorFilter.h>
25#include <unity/scopes/ScopeBase.h>26#include <unity/scopes/ScopeBase.h>
26#include <unity/scopes/SearchReply.h>27#include <unity/scopes/SearchReply.h>
@@ -49,11 +50,27 @@
49 filter->add_option("o2", "Option 2");50 filter->add_option("o2", "Option 2");
50 filters.push_back(filter);51 filters.push_back(filter);
51 auto active_opts = filter->active_options(query().filter_state());52 auto active_opts = filter->active_options(query().filter_state());
52 reply->push(filters, query().filter_state()); // send unmodified state back53
54 if (query().query_string() == "test")
55 {
56 reply->push(filters);
57 }
58 else
59 {
60 // use the deprecated push call
61 reply->push(filters, query().filter_state());
62 }
5363
54 auto cat = reply->register_category("cat1", "Category 1", "");64 auto cat = reply->register_category("cat1", "Category 1", "");
55 CategorisedResult res(cat);65 CategorisedResult res(cat);
56 res.set_uri("uri");66 if (active_opts.size() == 1)
67 {
68 res.set_uri("option " + (*(active_opts.begin()))->id() + " active");
69 }
70 else
71 {
72 res.set_uri("no options active");
73 }
57 res.set_dnd_uri("dnd_uri");74 res.set_dnd_uri("dnd_uri");
58 reply->push(res);75 reply->push(res);
59 }76 }
6077
=== modified file 'test/gtest/scopes/ResultCache/ResultCache_test.cpp'
--- test/gtest/scopes/ResultCache/ResultCache_test.cpp 2016-02-25 17:28:22 +0000
+++ test/gtest/scopes/ResultCache/ResultCache_test.cpp 2016-06-28 08:18:23 +0000
@@ -46,11 +46,10 @@
46 dept_ = parent;46 dept_ = parent;
47 }47 }
4848
49 virtual void push(Filters const& filters, FilterState const& filter_state) override49 virtual void push(Filters const& filters) override
50 {50 {
51 lock_guard<mutex> lock(mutex_);51 lock_guard<mutex> lock(mutex_);
52 filters_ = filters;52 filters_ = filters;
53 filter_state_ = filter_state;
54 }53 }
5554
56 virtual void push(CategorisedResult result) override55 virtual void push(CategorisedResult result) override
@@ -86,12 +85,6 @@
86 return filters_;85 return filters_;
87 }86 }
8887
89 FilterState filter_state() const
90 {
91 lock_guard<mutex> lock(mutex_);
92 return filter_state_;
93 }
94
95 CategorisedResult::SCPtr result() const88 CategorisedResult::SCPtr result() const
96 {89 {
97 lock_guard<mutex> lock(mutex_);90 lock_guard<mutex> lock(mutex_);
@@ -101,7 +94,6 @@
101private:94private:
102 Department::SCPtr dept_;95 Department::SCPtr dept_;
103 Filters filters_;96 Filters filters_;
104 FilterState filter_state_;
105 CategorisedResult::SCPtr result_;97 CategorisedResult::SCPtr result_;
106 bool query_complete_;98 bool query_complete_;
107 mutable mutex mutex_;99 mutable mutex mutex_;
@@ -248,9 +240,6 @@
248 auto osf = dynamic_pointer_cast<OptionSelectorFilter const>(f);240 auto osf = dynamic_pointer_cast<OptionSelectorFilter const>(f);
249 ASSERT_TRUE(osf != nullptr);241 ASSERT_TRUE(osf != nullptr);
250 EXPECT_EQ("Choose an option", osf->label());242 EXPECT_EQ("Choose an option", osf->label());
251 auto fs = receiver->filter_state();
252 EXPECT_TRUE(fs.has_filter("f1"));
253 EXPECT_TRUE(osf->has_active_option(fs));
254243
255 // Cache file must still be there.244 // Cache file must still be there.
256 boost::system::error_code ec;245 boost::system::error_code ec;
@@ -290,9 +279,6 @@
290 auto osf = dynamic_pointer_cast<OptionSelectorFilter const>(f);279 auto osf = dynamic_pointer_cast<OptionSelectorFilter const>(f);
291 ASSERT_TRUE(osf != nullptr);280 ASSERT_TRUE(osf != nullptr);
292 EXPECT_EQ("Choose an option", osf->label());281 EXPECT_EQ("Choose an option", osf->label());
293 auto fs = receiver->filter_state();
294 EXPECT_TRUE(fs.has_filter("f1"));
295 EXPECT_TRUE(osf->has_active_option(fs));
296282
297 // Cache file must still be there.283 // Cache file must still be there.
298 boost::system::error_code ec;284 boost::system::error_code ec;
@@ -344,9 +330,6 @@
344 auto osf = dynamic_pointer_cast<OptionSelectorFilter const>(f);330 auto osf = dynamic_pointer_cast<OptionSelectorFilter const>(f);
345 ASSERT_TRUE(osf != nullptr);331 ASSERT_TRUE(osf != nullptr);
346 EXPECT_EQ("Choose an option", osf->label());332 EXPECT_EQ("Choose an option", osf->label());
347 auto fs = receiver->filter_state();
348 EXPECT_TRUE(fs.has_filter("f1"));
349 EXPECT_TRUE(osf->has_active_option(fs));
350333
351 // New cache file must have been created334 // New cache file must have been created
352 boost::system::error_code ec;335 boost::system::error_code ec;
@@ -414,20 +397,6 @@
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));
415}398}
416399
417TEST_F(CacheScopeTest, missing_filter_state)
418{
419 // Get coverage on missing filters_state entry
420 system("cp " TEST_SOURCE_PATH "/no_filter_state_cache " TEST_RUNTIME_PATH "/unconfined/CacheScope/.surfacing_cache");
421 auto receiver = make_shared<Receiver>();
422 scope()->search("", SearchMetadata("unused", "unused"), receiver);
423 receiver->wait_until_finished();
424 EXPECT_EQ(receiver->result(), nullptr);
425
426 // Cache file must still be there, but decode will have failed.
427 boost::system::error_code ec;
428 EXPECT_TRUE(boost::filesystem::exists(TEST_RUNTIME_PATH "/unconfined/CacheScope/.surfacing_cache", ec));
429}
430
431TEST_F(CacheScopeTest, missing_results)400TEST_F(CacheScopeTest, missing_results)
432{401{
433 // Get coverage on missing results entry402 // Get coverage on missing results entry
434403
=== removed file 'test/gtest/scopes/ResultCache/no_filter_state_cache'
--- test/gtest/scopes/ResultCache/no_filter_state_cache 2015-02-05 09:35:42 +0000
+++ test/gtest/scopes/ResultCache/no_filter_state_cache 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
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"}}]}

Subscribers

People subscribed via source and target branches

to all changes: