~pete-woods/unity-scope-click/cmake-extras-compatibility

« back to all changes in this revision

Viewing changes to scope/tests/test_apps_query.cpp

  • Committer: Bileto Bot
  • Author(s): Rodney Dawes
  • Date: 2016-11-07 13:48:48 UTC
  • mfrom: (495.2.4 show-snap-scope)
  • Revision ID: ci-train-bot@canonical.com-20161107134848-f3vjj22czc0rnflb
Show the big store scope icon if it is installed.

Approved by: Marcus Tomlinson, unity-api-1-bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
    {
82
82
        return *click_iface;
83
83
    }
 
84
    MOCK_METHOD0(isStoreScopeInstalled, bool());
84
85
};
85
86
 
86
87
MATCHER_P(HasApplicationTitle, n, "") { return arg["title"].get_string() == n; }
126
127
    const unity::scopes::CannedQuery query("foo.scope", "FooBar", "");
127
128
    const unity::scopes::CannedQuery query2("foo.scope", "Metallica", "");
128
129
 
129
 
    click::apps::Query q(query, nullptr, metadata);
130
 
    click::apps::Query q2(query2, nullptr, metadata);
 
130
    auto clickif = std::make_shared<MockClickInterface>();
 
131
 
 
132
    MockAppsQuery q(query, nullptr, metadata, clickif);
 
133
    MockAppsQuery q2(query2, nullptr, metadata, clickif);
131
134
 
132
135
    scopes::testing::MockSearchReply mock_reply;
133
136
    scopes::SearchReplyProxy reply(&mock_reply, [](unity::scopes::SearchReply*){});
134
137
    scopes::CategoryRenderer renderer("{}");
135
138
    auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);
136
139
 
137
 
    const unity::scopes::CannedQuery target_query("com.canonical.scopes.clickstore", "FooBar", "");
 
140
    EXPECT_CALL(q, isStoreScopeInstalled()).WillOnce(Return(true));
 
141
    const unity::scopes::CannedQuery target_query("snappy-store", "FooBar", "");
138
142
 
139
143
    EXPECT_CALL(mock_reply, register_category("store", CategoryTitleContains("FooBar"), _, _)).WillOnce(Return(ptrCat));
140
144
    EXPECT_CALL(mock_reply, push(Matcher<const unity::scopes::CategorisedResult&>(ResultUriMatchesCannedQuery(target_query))));
142
146
    scopes::testing::MockSearchReply mock_reply2;
143
147
    scopes::SearchReplyProxy reply2(&mock_reply2, [](unity::scopes::SearchReply*){});
144
148
 
145
 
    const unity::scopes::CannedQuery target_query2("com.canonical.scopes.clickstore", "Metallica", "");
 
149
    EXPECT_CALL(q2, isStoreScopeInstalled()).WillOnce(Return(false));
146
150
 
147
 
    EXPECT_CALL(mock_reply2, register_category("store", CategoryTitleContains("Metallica"), _, _)).WillOnce(Return(ptrCat));
148
 
    EXPECT_CALL(mock_reply2, push(Matcher<const unity::scopes::CategorisedResult&>(ResultUriMatchesCannedQuery(target_query2))));
 
151
    EXPECT_CALL(mock_reply2, register_category("store", _, _, _)).Times(0);
149
152
 
150
153
    q.add_fake_store_app(reply);
151
154
    q2.add_fake_store_app(reply2);
156
159
    const scopes::SearchMetadata metadata("en_EN", "phone");
157
160
    const unity::scopes::CannedQuery query("foo.scope", "", "music-department");
158
161
 
159
 
    click::apps::Query q(query, nullptr, metadata);
 
162
    auto clickif = std::make_shared<MockClickInterface>();
 
163
 
 
164
    MockAppsQuery q(query, nullptr, metadata, clickif);
160
165
 
161
166
    scopes::CategoryRenderer renderer("{}");
162
167
    auto ptrCat = std::make_shared<FakeCategory>("id", "", "", renderer);
164
169
    scopes::testing::MockSearchReply mock_reply;
165
170
    scopes::SearchReplyProxy reply(&mock_reply, [](unity::scopes::SearchReply*){});
166
171
 
167
 
    const unity::scopes::CannedQuery target_query("com.canonical.scopes.clickstore", "", "music-department");
 
172
    const unity::scopes::CannedQuery target_query("snappy-store", "", "music-department");
168
173
 
 
174
    EXPECT_CALL(q, isStoreScopeInstalled()).WillOnce(Return(true));
169
175
    EXPECT_CALL(mock_reply, register_category("store", _, _, _)).WillOnce(Return(ptrCat));
170
176
    EXPECT_CALL(mock_reply, push(Matcher<const unity::scopes::CategorisedResult&>(ResultUriMatchesCannedQuery(target_query))));
171
177