Merge lp:~unity-team/unity-scope-mediascanner/vimeo-youtube-soundcloud-rtm into lp:unity-scope-mediascanner/rtm-14.09

Proposed by Paweł Stołowski
Status: Merged
Approved by: Marcus Tomlinson
Approved revision: 197
Merged at revision: 200
Proposed branch: lp:~unity-team/unity-scope-mediascanner/vimeo-youtube-soundcloud-rtm
Merge into: lp:unity-scope-mediascanner/rtm-14.09
Prerequisite: lp:~unity-team/unity-scope-mediascanner/click-support
Diff against target: 509 lines (+310/-6)
9 files modified
src/musicaggregator/musicaggregator-settings.ini.in (+5/-0)
src/musicaggregator/musicaggregatorquery.cpp (+129/-2)
src/musicaggregator/musicaggregatorquery.h (+3/-1)
src/musicaggregator/musicaggregatorscope.cpp (+5/-3)
src/musicaggregator/musicaggregatorscope.h (+2/-0)
src/videoaggregator/videoaggregator-settings.ini.in (+5/-0)
src/videoaggregator/videoaggregatorscope.cpp (+1/-0)
tests/CMakeLists.txt (+16/-0)
tests/test-music-aggregator.cpp (+144/-0)
To merge this branch: bzr merge lp:~unity-team/unity-scope-mediascanner/vimeo-youtube-soundcloud-rtm
Reviewer Review Type Date Requested Status
Xavi Garcia (community) Approve
Marcus Tomlinson (community) Approve
Review via email: mp+241940@code.launchpad.net

Commit message

Cherry-picked support for aggregation of results from youtube, vimeo and soundcloud n Music/Videos.

Description of the change

Cherry-picked support for aggregation of results from youtube, vimeo and soundcloud n Music/Videos.

To post a comment you must log in.
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

Looks good to me. Thanks for putting this together

review: Approve
Revision history for this message
Xavi Garcia (xavi-garcia-mena) wrote :

Looks good to me, thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/musicaggregator/musicaggregator-settings.ini.in'
2--- src/musicaggregator/musicaggregator-settings.ini.in 2014-10-07 11:20:33 +0000
3+++ src/musicaggregator/musicaggregator-settings.ini.in 2014-11-17 11:41:23 +0000
4@@ -12,3 +12,8 @@
5 type=boolean
6 defaultValue=true
7 _displayName=Display results from Grooveshark
8+
9+[com.ubuntu.scopes.soundcloud_soundcloud]
10+type=boolean
11+defaultValue=true
12+_displayName=Display results from SoundCloud
13
14=== modified file 'src/musicaggregator/musicaggregatorquery.cpp'
15--- src/musicaggregator/musicaggregatorquery.cpp 2014-11-17 11:41:22 +0000
16+++ src/musicaggregator/musicaggregatorquery.cpp 2014-11-17 11:41:23 +0000
17@@ -135,6 +135,48 @@
18 }
19 )";
20
21+static const char SOUNDCLOUD_CATEGORY_DEFINITION[] = R"(
22+{
23+ "schema-version": 1,
24+ "template": {
25+ "category-layout": "grid",
26+ "card-size": "large",
27+ "overlay": true,
28+ "card-background": "color:///#000000"
29+ },
30+ "components": {
31+ "title": "title",
32+ "art" : {
33+ "field": "waveform",
34+ "aspect-ratio": 4.0
35+ },
36+ "subtitle": "username",
37+ "mascot": "art",
38+ "attributes": {
39+ "field": "attributes",
40+ "max-count": 3
41+ }
42+ }
43+}
44+)";
45+
46+static const char SOUNDCLOUD_SEARCH_CATEGORY_DEFINITION[] = R"(
47+{
48+ "schema-version": 1,
49+ "template": {
50+ "category-layout": "grid",
51+ "card-size": "large",
52+ "card-layout": "horizontal"
53+ },
54+ "components": {
55+ "title": "title",
56+ "mascot": "art",
57+ "subtitle": "address",
58+ "attributes": "attributes"
59+ }
60+}
61+)";
62+
63 static const char SONGKICK_CATEGORY_DEFINITION[] = R"(
64 {
65 "schema-version": 1,
66@@ -168,6 +210,43 @@
67 }
68 )";
69
70+static char YOUTUBE_SURFACING_CATEGORY_DEFINITION[] = R"(
71+{
72+ "schema-version": 1,
73+ "template": {
74+ "category-layout": "grid",
75+ "card-size": "medium"
76+ },
77+ "components": {
78+ "title": "title",
79+ "subtitle": "subtitle",
80+ "art": {
81+ "field": "art",
82+ "aspect-ratio": 1.5
83+ }
84+ }
85+}
86+)";
87+
88+static char YOUTUBE_SEARCH_CATEGORY_DEFINITION[] = R"(
89+{
90+ "schema-version": 1,
91+ "template": {
92+ "category-layout": "grid",
93+ "card-size": "medium",
94+ "card-layout": "horizontal"
95+ },
96+ "components": {
97+ "title": "title",
98+ "subtitle": "subtitle",
99+ "art": {
100+ "field": "art",
101+ "aspect-ratio": 1.5
102+ }
103+ }
104+}
105+)";
106+
107 const std::string MusicAggregatorQuery::grooveshark_songs_category_id = "cat_0";
108
109 MusicAggregatorQuery::MusicAggregatorQuery(CannedQuery const& query, SearchMetadata const& hints,
110@@ -175,14 +254,16 @@
111 ScopeProxy const& grooveshark_scope,
112 ScopeProxy const& soundcloud_scope,
113 ScopeProxy const& sevendigital_scope,
114- ScopeProxy const& songkick_scope
115+ ScopeProxy const& songkick_scope,
116+ ScopeProxy const& youtube_scope
117 ) :
118 SearchQueryBase(query, hints),
119 local_scope(local_scope),
120 grooveshark_scope(grooveshark_scope),
121 soundcloud_scope(soundcloud_scope),
122 sevendigital_scope(sevendigital_scope),
123- songkick_scope(songkick_scope)
124+ songkick_scope(songkick_scope),
125+ youtube_scope(youtube_scope)
126 {
127 }
128
129@@ -196,11 +277,14 @@
130 {
131 std::vector<std::shared_ptr<ResultForwarder>> replies;
132 std::vector<unity::scopes::ScopeProxy> scopes({local_scope});
133+ const std::string department_id = "aggregated:musicaggregator";
134
135 const CannedQuery mymusic_query(MusicAggregatorScope::LOCALSCOPE, query().query_string(), "");
136 const CannedQuery sevendigital_query(MusicAggregatorScope::SEVENDIGITAL, query().query_string(), "newreleases");
137+ const CannedQuery soundcloud_query(MusicAggregatorScope::SOUNDCLOUD, query().query_string(), "");
138 const CannedQuery songkick_query(MusicAggregatorScope::SONGKICK, query().query_string(), "");
139 const CannedQuery grooveshark_query(MusicAggregatorScope::GROOVESHARKSCOPE, query().query_string(), "");
140+ const CannedQuery youtube_query(MusicAggregatorScope::YOUTUBE, query().query_string(), department_id);
141
142 const bool empty_search = query().query_string().empty();
143
144@@ -212,12 +296,19 @@
145 auto sevendigital_cat = empty_search ? parent_reply->register_category("7digital", _("New albums from 7digital"), "",
146 sevendigital_query, CategoryRenderer(SEVENDIGITAL_CATEGORY_DEFINITION))
147 : parent_reply->register_category("7digital", _("7digital"), "", CategoryRenderer(SEVENDIGITAL_SEARCH_CATEGORY_DEFINITION));
148+ auto soundcloud_cat = empty_search ? parent_reply->register_category("soundcloud", _("Popular tracks on SoundCloud"), "",
149+ soundcloud_query, CategoryRenderer(SOUNDCLOUD_CATEGORY_DEFINITION))
150+ : parent_reply->register_category("soundcloud", _("SoundCloud"), "", CategoryRenderer(SOUNDCLOUD_SEARCH_CATEGORY_DEFINITION));
151 auto songkick_cat = empty_search ? parent_reply->register_category("songkick", _("Nearby Events on Songkick"), "",
152 songkick_query, CategoryRenderer(SONGKICK_CATEGORY_DEFINITION))
153 : parent_reply->register_category("songkick", _("Songkick"), "", CategoryRenderer(SONGKICK_SEARCH_CATEGORY_DEFINITION));
154 auto grooveshark_cat = empty_search ? parent_reply->register_category("grooveshark", _("Popular tracks on Grooveshark"), "",
155 grooveshark_query, CategoryRenderer(GROOVESHARK_CATEGORY_DEFINITION))
156 : parent_reply->register_category("grooveshark", _("Grooveshark"), "", CategoryRenderer(GROOVESHARK_SEARCH_CATEGORY_DEFINITION));
157+ auto youtube_cat = empty_search ? parent_reply->register_category("youtube", _("Popular tracks on Youtube"), "",
158+ youtube_query, CategoryRenderer(YOUTUBE_SURFACING_CATEGORY_DEFINITION))
159+ : parent_reply->register_category("youtube", _("Youtube"), "", youtube_query, CategoryRenderer(YOUTUBE_SEARCH_CATEGORY_DEFINITION));
160+
161
162 {
163 auto local_reply = std::make_shared<ResultForwarder>(parent_reply, [this, mymusic_cat](CategorisedResult& res) -> bool {
164@@ -236,6 +327,18 @@
165 });
166 replies.push_back(reply);
167 }
168+ if (soundcloud_scope)
169+ {
170+ scopes.push_back(soundcloud_scope);
171+ auto reply = std::make_shared<OnlineMusicResultForwarder>(parent_reply, [this, soundcloud_cat](CategorisedResult& res) -> bool {
172+ if (res.category()->id() == "soundcloud_login_nag") {
173+ return false;
174+ }
175+ res.set_category(soundcloud_cat);
176+ return true;
177+ });
178+ replies.push_back(reply);
179+ }
180 if (songkick_scope)
181 {
182 scopes.push_back(songkick_scope);
183@@ -267,6 +370,15 @@
184 {
185 // TODO when available
186 }
187+ if (youtube_scope)
188+ {
189+ scopes.push_back(youtube_scope);
190+ auto reply = std::make_shared<OnlineMusicResultForwarder>(parent_reply, [this, youtube_cat](CategorisedResult& res) -> bool {
191+ res.set_category(youtube_cat);
192+ return !res["musicaggregation"].is_null();
193+ });
194+ replies.push_back(reply);
195+ }
196
197 // create and chain result forwarders to enforce proper order of categories
198 for (unsigned int i = 1; i < scopes.size(); ++i)
199@@ -301,6 +413,13 @@
200 metadata.set_cardinality(3);
201 }
202 }
203+ else if (scopes[i] == soundcloud_scope)
204+ {
205+ if (empty_search)
206+ {
207+ metadata.set_cardinality(3);
208+ }
209+ }
210 else if (scopes[i] == songkick_scope)
211 {
212 if (empty_search)
213@@ -308,6 +427,14 @@
214 metadata.set_cardinality(2);
215 }
216 }
217+ else if (scopes[i] == youtube_scope)
218+ {
219+ if (empty_search)
220+ {
221+ metadata.set_cardinality(2);
222+ }
223+ dept = department_id;
224+ }
225
226 // Don't send location data to scopes that don't need it.
227 if (scopes[i] != songkick_scope)
228
229=== modified file 'src/musicaggregator/musicaggregatorquery.h'
230--- src/musicaggregator/musicaggregatorquery.h 2014-09-15 07:26:58 +0000
231+++ src/musicaggregator/musicaggregatorquery.h 2014-11-17 11:41:23 +0000
232@@ -35,7 +35,8 @@
233 unity::scopes::ScopeProxy const& grooveshark_scope,
234 unity::scopes::ScopeProxy const& soundcloud_scope,
235 unity::scopes::ScopeProxy const& sevendigital_scope,
236- unity::scopes::ScopeProxy const& songkick_scope);
237+ unity::scopes::ScopeProxy const& songkick_scope,
238+ unity::scopes::ScopeProxy const& youtube_scope);
239 ~MusicAggregatorQuery();
240 virtual void cancelled() override;
241
242@@ -47,6 +48,7 @@
243 unity::scopes::ScopeProxy soundcloud_scope;
244 unity::scopes::ScopeProxy sevendigital_scope;
245 unity::scopes::ScopeProxy songkick_scope;
246+ unity::scopes::ScopeProxy youtube_scope;
247 static const std::string grooveshark_songs_category_id;
248 };
249
250
251=== modified file 'src/musicaggregator/musicaggregatorscope.cpp'
252--- src/musicaggregator/musicaggregatorscope.cpp 2014-11-17 11:41:22 +0000
253+++ src/musicaggregator/musicaggregatorscope.cpp 2014-11-17 11:41:23 +0000
254@@ -36,8 +36,9 @@
255 #endif
256 const std::string MusicAggregatorScope::GROOVESHARKSCOPE = "com.canonical.scopes.grooveshark";
257 const std::string MusicAggregatorScope::SEVENDIGITAL = "com.canonical.scopes.sevendigital";
258-const std::string MusicAggregatorScope::SOUNDCLOUD = "com.canonical.scopes.soundcloud";
259+const std::string MusicAggregatorScope::SOUNDCLOUD = "com.ubuntu.scopes.soundcloud_soundcloud";
260 const std::string MusicAggregatorScope::SONGKICK = "com.canonical.scopes.songkick_songkick";
261+const std::string MusicAggregatorScope::YOUTUBE = "com.ubuntu.scopes.youtube_youtube";
262
263 void MusicAggregatorScope::start(std::string const&) {
264 init_gettext(*this);
265@@ -53,7 +54,7 @@
266 // FIXME: workaround for problem with no remote scopes on first run
267 // until network becomes available
268 init_scope_proxies();
269- SearchQueryBase::UPtr query(new MusicAggregatorQuery(q, hints, local_scope, grooveshark_scope, soundcloud_scope, sevendigital_scope, songkick_scope));
270+ SearchQueryBase::UPtr query(new MusicAggregatorQuery(q, hints, local_scope, grooveshark_scope, soundcloud_scope, sevendigital_scope, songkick_scope, youtube_scope));
271 return query;
272 }
273
274@@ -89,8 +90,9 @@
275 const auto config = settings();
276 init_scope_proxy(GROOVESHARKSCOPE, grooveshark_scope, config);
277 init_scope_proxy(SEVENDIGITAL, sevendigital_scope, config);
278- //init_scope_proxy(SOUNDCLOUD, soundcloud_scope, config);
279+ init_scope_proxy(SOUNDCLOUD, soundcloud_scope, config);
280 init_scope_proxy(SONGKICK, songkick_scope, config);
281+ init_scope_proxy(YOUTUBE, youtube_scope, config);
282 }
283
284 PreviewQueryBase::UPtr MusicAggregatorScope::preview(Result const& /*result*/, ActionMetadata const& /*hints*/) {
285
286=== modified file 'src/musicaggregator/musicaggregatorscope.h'
287--- src/musicaggregator/musicaggregatorscope.h 2014-09-15 07:26:58 +0000
288+++ src/musicaggregator/musicaggregatorscope.h 2014-11-17 11:41:23 +0000
289@@ -34,6 +34,7 @@
290 static const std::string SEVENDIGITAL;
291 static const std::string SOUNDCLOUD;
292 static const std::string SONGKICK;
293+ static const std::string YOUTUBE;
294
295 virtual void start(std::string const&) override;
296
297@@ -53,6 +54,7 @@
298 unity::scopes::ScopeProxy soundcloud_scope;
299 unity::scopes::ScopeProxy sevendigital_scope;
300 unity::scopes::ScopeProxy songkick_scope;
301+ unity::scopes::ScopeProxy youtube_scope;
302 };
303
304 #endif
305
306=== modified file 'src/videoaggregator/videoaggregator-settings.ini.in'
307--- src/videoaggregator/videoaggregator-settings.ini.in 2014-07-31 09:37:39 +0000
308+++ src/videoaggregator/videoaggregator-settings.ini.in 2014-11-17 11:41:23 +0000
309@@ -2,3 +2,8 @@
310 type=boolean
311 defaultValue=true
312 _displayName=Display results from YouTube
313+
314+[com.ubuntu.scopes.vimeo_vimeo]
315+type=boolean
316+defaultValue=true
317+_displayName=Display results from Vimeo
318
319=== modified file 'src/videoaggregator/videoaggregatorscope.cpp'
320--- src/videoaggregator/videoaggregatorscope.cpp 2014-11-17 11:41:22 +0000
321+++ src/videoaggregator/videoaggregatorscope.cpp 2014-11-17 11:41:23 +0000
322@@ -35,6 +35,7 @@
323 "mediascanner-video",
324 #endif
325 "com.ubuntu.scopes.youtube_youtube",
326+ "com.ubuntu.scopes.vimeo_vimeo",
327 };
328
329 void VideoAggregatorScope::start(std::string const&) {
330
331=== modified file 'tests/CMakeLists.txt'
332--- tests/CMakeLists.txt 2014-11-17 11:41:22 +0000
333+++ tests/CMakeLists.txt 2014-11-17 11:41:23 +0000
334@@ -15,10 +15,26 @@
335 test-music-scope.cpp
336 ../src/mymusic/music-scope.cpp
337 )
338+
339+add_executable(test-music-aggregator
340+ test-music-aggregator.cpp
341+ ../src/musicaggregator/musicaggregatorquery.cpp
342+ ../src/musicaggregator/onlinemusicresultforwarder.cpp
343+ ../src/musicaggregator/musicaggregatorscope.cpp
344+)
345+
346+add_definitions(
347+ -DTEST_SCOPE_DIRECTORY="${CMAKE_BINARY_DIR}/src"
348+)
349+
350 target_link_libraries(test-music-scope
351 scope-utils ${UNITY_LDFLAGS} ${gtest_libs} ${GIO_DEPS_LDFLAGS})
352 add_test(test-music-scope test-music-scope)
353
354+target_link_libraries(test-music-aggregator
355+ scope-utils ${UNITY_LDFLAGS} ${gtest_libs} ${GIO_DEPS_LDFLAGS})
356+add_test(test-music-aggregator test-music-aggregator)
357+
358 add_executable(test-video-scope
359 test-video-scope.cpp
360 ../src/myvideos/video-scope.cpp
361
362=== added file 'tests/test-music-aggregator.cpp'
363--- tests/test-music-aggregator.cpp 1970-01-01 00:00:00 +0000
364+++ tests/test-music-aggregator.cpp 2014-11-17 11:41:23 +0000
365@@ -0,0 +1,144 @@
366+#include <cerrno>
367+#include <cstring>
368+#include <memory>
369+#include <string>
370+
371+#include <gmock/gmock.h>
372+#include <gtest/gtest.h>
373+#include <unity/scopes/testing/Category.h>
374+#include <unity/scopes/testing/MockSearchReply.h>
375+#include <unity/scopes/testing/MockScope.h>
376+#include <unity/scopes/testing/MockQueryCtrl.h>
377+
378+
379+#include "../src/musicaggregator/musicaggregatorscope.h"
380+#include "../src/musicaggregator/musicaggregatorquery.h"
381+
382+using namespace unity::scopes;
383+using ::testing::_;
384+using ::testing::Return;
385+
386+TEST(TestMusicAgregator, TestSurfacingSearch) {
387+
388+ CannedQuery q("mediascanner-music", "", "");
389+ SearchMetadata hints("en_AU", "phone");
390+
391+ std::shared_ptr<unity::scopes::testing::MockScope> grooveshark_scope(new unity::scopes::testing::MockScope());
392+ std::shared_ptr<unity::scopes::testing::MockScope> soundcloud_scope(new unity::scopes::testing::MockScope());
393+ std::shared_ptr<unity::scopes::testing::MockScope> sevendigital_scope(new unity::scopes::testing::MockScope());
394+ std::shared_ptr<unity::scopes::testing::MockScope> songkick_scope(new unity::scopes::testing::MockScope());
395+ std::shared_ptr<unity::scopes::testing::MockScope> youtube_scope(new unity::scopes::testing::MockScope());
396+ std::shared_ptr<unity::scopes::testing::MockScope> local_scope(new unity::scopes::testing::MockScope());
397+
398+ MusicAggregatorQuery query( q, hints, unity::scopes::ScopeProxy(local_scope), unity::scopes::ScopeProxy(grooveshark_scope),
399+ unity::scopes::ScopeProxy(soundcloud_scope), unity::scopes::ScopeProxy(sevendigital_scope),
400+ unity::scopes::ScopeProxy(songkick_scope), unity::scopes::ScopeProxy(youtube_scope) );
401+
402+
403+ unity::scopes::testing::MockSearchReply reply;
404+
405+ Category::SCPtr mymusic_category = std::make_shared<unity::scopes::testing::Category>(
406+ "mymusic", "Tracks", "icon", CategoryRenderer());
407+ Category::SCPtr sevendigital_category = std::make_shared<unity::scopes::testing::Category>(
408+ "7digital", "Tracks", "icon", CategoryRenderer());
409+ Category::SCPtr songkick_category = std::make_shared<unity::scopes::testing::Category>(
410+ "songkick", "Tracks", "icon", CategoryRenderer());
411+ Category::SCPtr grooveshark_category = std::make_shared<unity::scopes::testing::Category>(
412+ "grooveshark", "Tracks", "icon", CategoryRenderer());
413+ Category::SCPtr youtube_category = std::make_shared<unity::scopes::testing::Category>(
414+ "youtube", "Tracks", "icon", CategoryRenderer());
415+ Category::SCPtr soundcloud_category = std::make_shared<unity::scopes::testing::Category>(
416+ "soundcloud", "Tracks", "icon", CategoryRenderer());
417+
418+
419+ std::shared_ptr<unity::scopes::testing::MockQueryCtrl> queryctrl(new unity::scopes::testing::MockQueryCtrl());
420+
421+ EXPECT_CALL(reply, register_category("mymusic", _, _, _,_))
422+ .WillOnce(Return(mymusic_category));
423+ EXPECT_CALL(reply, register_category("7digital", _, _, _,_))
424+ .WillOnce(Return(sevendigital_category));
425+ EXPECT_CALL(reply, register_category("songkick", _, _, _,_))
426+ .WillOnce(Return(songkick_category));
427+ EXPECT_CALL(reply, register_category("grooveshark", _, _, _,_))
428+ .WillOnce(Return(grooveshark_category));
429+ EXPECT_CALL(reply, register_category("youtube", _, _, _,_))
430+ .WillOnce(Return(youtube_category));
431+ EXPECT_CALL(reply, register_category("soundcloud", _, _, _,_))
432+ .WillOnce(Return(soundcloud_category));
433+
434+ // check that each scope calls search with the correct parameters...
435+ EXPECT_CALL(*sevendigital_scope.get(), search("","newreleases", _, _, _)).WillOnce(Return(queryctrl));
436+ EXPECT_CALL(*local_scope.get(), search("","", _, _, _)).WillOnce(Return(queryctrl));
437+ EXPECT_CALL(*songkick_scope.get(), search("","", _, _, _)).WillOnce(Return(queryctrl));
438+ EXPECT_CALL(*grooveshark_scope.get(), search("","", _, _, _)).WillOnce(Return(queryctrl));
439+ EXPECT_CALL(*youtube_scope.get(), search("","aggregated:musicaggregator", _, _, _)).WillOnce(Return(queryctrl));
440+ EXPECT_CALL(*soundcloud_scope.get(), search("","", _, _, _)).WillOnce(Return(queryctrl));
441+
442+ SearchReplyProxy proxy(&reply, [](SearchReply*){});
443+ query.run(proxy);
444+}
445+
446+TEST(TestMusicAgregator, TestSpecificSearch) {
447+
448+ CannedQuery q("mediascanner-music", "test", "");
449+ SearchMetadata hints("en_AU", "phone");
450+
451+ std::shared_ptr<unity::scopes::testing::MockScope> grooveshark_scope(new unity::scopes::testing::MockScope());
452+ std::shared_ptr<unity::scopes::testing::MockScope> soundcloud_scope(new unity::scopes::testing::MockScope());
453+ std::shared_ptr<unity::scopes::testing::MockScope> sevendigital_scope(new unity::scopes::testing::MockScope());
454+ std::shared_ptr<unity::scopes::testing::MockScope> songkick_scope(new unity::scopes::testing::MockScope());
455+ std::shared_ptr<unity::scopes::testing::MockScope> youtube_scope(new unity::scopes::testing::MockScope());
456+ std::shared_ptr<unity::scopes::testing::MockScope> local_scope(new unity::scopes::testing::MockScope());
457+
458+ MusicAggregatorQuery query( q, hints, unity::scopes::ScopeProxy(local_scope), unity::scopes::ScopeProxy(grooveshark_scope),
459+ unity::scopes::ScopeProxy(soundcloud_scope), unity::scopes::ScopeProxy(sevendigital_scope),
460+ unity::scopes::ScopeProxy(songkick_scope), unity::scopes::ScopeProxy(youtube_scope) );
461+
462+
463+ unity::scopes::testing::MockSearchReply reply;
464+
465+ Category::SCPtr mymusic_category = std::make_shared<unity::scopes::testing::Category>(
466+ "mymusic", "Tracks", "icon", CategoryRenderer());
467+ Category::SCPtr sevendigital_category = std::make_shared<unity::scopes::testing::Category>(
468+ "7digital", "Tracks", "icon", CategoryRenderer());
469+ Category::SCPtr songkick_category = std::make_shared<unity::scopes::testing::Category>(
470+ "songkick", "Tracks", "icon", CategoryRenderer());
471+ Category::SCPtr grooveshark_category = std::make_shared<unity::scopes::testing::Category>(
472+ "grooveshark", "Tracks", "icon", CategoryRenderer());
473+ Category::SCPtr youtube_category = std::make_shared<unity::scopes::testing::Category>(
474+ "youtube", "Tracks", "icon", CategoryRenderer());
475+ Category::SCPtr soundcloud_category = std::make_shared<unity::scopes::testing::Category>(
476+ "soundcloud", "Tracks", "icon", CategoryRenderer());
477+
478+
479+ std::shared_ptr<unity::scopes::testing::MockQueryCtrl> queryctrl(new unity::scopes::testing::MockQueryCtrl());
480+
481+ EXPECT_CALL(reply, register_category("mymusic", _, _, _))
482+ .WillOnce(Return(mymusic_category));
483+ EXPECT_CALL(reply, register_category("7digital", _, _,_))
484+ .WillOnce(Return(sevendigital_category));
485+ EXPECT_CALL(reply, register_category("songkick", _, _,_))
486+ .WillOnce(Return(songkick_category));
487+ EXPECT_CALL(reply, register_category("grooveshark", _, _,_))
488+ .WillOnce(Return(grooveshark_category));
489+ EXPECT_CALL(reply, register_category("youtube", _, _, _,_))
490+ .WillOnce(Return(youtube_category));
491+ EXPECT_CALL(reply, register_category("soundcloud", _, _,_))
492+ .WillOnce(Return(soundcloud_category));
493+
494+ // check that each scope calls search with the correct parameters...
495+ EXPECT_CALL(*sevendigital_scope.get(), search("test","", _, _, _)).WillOnce(Return(queryctrl));
496+ EXPECT_CALL(*local_scope.get(), search("test","", _, _, _)).WillOnce(Return(queryctrl));
497+ EXPECT_CALL(*songkick_scope.get(), search("test","", _, _, _)).WillOnce(Return(queryctrl));
498+ EXPECT_CALL(*grooveshark_scope.get(), search("test","", _, _, _)).WillOnce(Return(queryctrl));
499+ EXPECT_CALL(*youtube_scope.get(), search("test","aggregated:musicaggregator", _, _, _)).WillOnce(Return(queryctrl));
500+ EXPECT_CALL(*soundcloud_scope.get(), search("test","", _, _, _)).WillOnce(Return(queryctrl));
501+
502+ SearchReplyProxy proxy(&reply, [](SearchReply*){});
503+ query.run(proxy);
504+}
505+
506+int main(int argc, char **argv) {
507+ ::testing::InitGoogleTest(&argc, argv);
508+ return RUN_ALL_TESTS();
509+}

Subscribers

People subscribed via source and target branches

to all changes: