~stolowski/unity-scopes-api/result-for-key

« back to all changes in this revision

Viewing changes to test/gtest/scopes/Filters/Filters_test.cpp

  • Committer: Tarmac
  • Author(s): Pawel Stolowski
  • Date: 2016-06-28 09:56:43 UTC
  • mfrom: (677.2.6 update-push-filters)
  • Revision ID: tarmac-20160628095643-1iq0wxmb41jh2ill
Marked the push(Filters const&, FilterState const&) method of SearchReply and SearchListenerBase
as deprecated and provided push methods which take Filters argument only. Fixes: https://bugs.launchpad.net/bugs/1566952.

Approved by PS Jenkins bot, Marcus Tomlinson.

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
class SearchReceiver : public SearchListenerBase, public WaitUntilFinished
67
67
{
68
68
public:
69
 
    virtual void push(CategorisedResult /* result */) override {}
70
 
 
71
 
    virtual void push(Filters const& filters, FilterState const& filter_state) override
 
69
    virtual void push(CategorisedResult result) override
 
70
    {
 
71
        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
81
        this->filters = filters;
74
 
        this->filter_state = filter_state;
75
82
    }
76
83
 
77
84
    virtual void finished(CompletionDetails const& details) override
81
88
    }
82
89
 
83
90
    Filters filters;
84
 
    FilterState filter_state;
 
91
    Filters filters2;
 
92
    std::string result_uri;
85
93
};
86
94
 
87
95
template <typename ScopeType>
135
143
    auto ctrl = scope->search("test", hints, receiver);
136
144
    receiver->wait_until_finished();
137
145
 
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);
 
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
153
        auto filters = receiver->filters;
141
154
        ASSERT_EQ(1u, filters.size());
142
155
        EXPECT_EQ("f1", filters.front()->id());
159
172
    receiver->wait_until_finished();
160
173
    {
161
174
        auto filters = receiver->filters;
162
 
        auto filter_state2 = receiver->filter_state;
 
175
        ASSERT_EQ(1u, filters.size());
163
176
        auto selector = std::dynamic_pointer_cast<const OptionSelectorFilter>(filters.front());
164
 
        ASSERT_EQ(1u, selector->active_options(filter_state2).size());
165
 
        auto option1 = *(selector->active_options(filter_state2).begin());
166
 
        EXPECT_EQ("o1", option1->id());
 
177
        EXPECT_EQ("option o1 active", receiver->result_uri);
167
178
    }
168
179
}
169
180