Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Side by Side Diff: chrome/browser/media/router/media_router_mojo_impl_unittest.cc

Issue 1259333004: [MediaRouter]Wires up issue manager in MediaRouterMojoImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
12 #include "chrome/browser/media/router/issue.h"
12 #include "chrome/browser/media/router/media_route.h" 13 #include "chrome/browser/media/router/media_route.h"
13 #include "chrome/browser/media/router/media_router_mojo_test.h" 14 #include "chrome/browser/media/router/media_router_mojo_test.h"
15 #include "chrome/browser/media/router/media_router_type_converters.h"
14 #include "chrome/browser/media/router/mock_media_router.h" 16 #include "chrome/browser/media/router/mock_media_router.h"
15 #include "chrome/browser/media/router/test_helper.h" 17 #include "chrome/browser/media/router/test_helper.h"
16 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 18 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
17 #include "chrome/test/base/testing_profile.h" 19 #include "chrome/test/base/testing_profile.h"
18 #include "extensions/browser/extension_registry.h" 20 #include "extensions/browser/extension_registry.h"
19 #include "extensions/browser/process_manager.h" 21 #include "extensions/browser/process_manager.h"
20 #include "extensions/browser/process_manager_factory.h" 22 #include "extensions/browser/process_manager_factory.h"
21 #include "media/base/gmock_callback_support.h" 23 #include "media/base/gmock_callback_support.h"
22 #include "testing/gmock/include/gmock/gmock.h" 24 #include "testing/gmock/include/gmock/gmock.h"
23 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
24 26
25 using testing::_; 27 using testing::_;
26 using testing::Eq; 28 using testing::Eq;
27 using testing::Invoke; 29 using testing::Invoke;
30 using testing::Mock;
28 using testing::Pointee; 31 using testing::Pointee;
29 using testing::Return; 32 using testing::Return;
30 using testing::ReturnRef; 33 using testing::ReturnRef;
31 using testing::SaveArg; 34 using testing::SaveArg;
32 35
33 namespace media_router { 36 namespace media_router {
34 37
35 namespace { 38 namespace {
36 39
37 const char kDescription[] = "description"; 40 const char kDescription[] = "description";
(...skipping 16 matching lines...) Expand all
54 const content::PresentationSessionMessage* actual) { 57 const content::PresentationSessionMessage* actual) {
55 if (expected->presentation_url != actual->presentation_url || 58 if (expected->presentation_url != actual->presentation_url ||
56 expected->presentation_id != actual->presentation_id || 59 expected->presentation_id != actual->presentation_id ||
57 expected->type != actual->type) { 60 expected->type != actual->type) {
58 return false; 61 return false;
59 } 62 }
60 return expected->is_binary() ? *(expected->data) == *(actual->data) 63 return expected->is_binary() ? *(expected->data) == *(actual->data)
61 : *(expected->message) == *(actual->message); 64 : *(expected->message) == *(actual->message);
62 } 65 }
63 66
67 interfaces::IssuePtr CreateMojoIssue() {
68 interfaces::IssuePtr mojoIssue = interfaces::Issue::New();
69 mojoIssue->title = "title";
70 mojoIssue->message = "msg";
71 mojoIssue->route_id = "";
72 mojoIssue->default_action = interfaces::Issue::ActionType::ACTION_TYPE_OK;
73 mojoIssue->secondary_actions =
74 mojo::Array<interfaces::Issue::ActionType>::New(0);
75 mojoIssue->severity = interfaces::Issue::Severity::SEVERITY_WARNING;
76 mojoIssue->is_blocking = false;
77 mojoIssue->help_url = "";
78 return mojoIssue.Pass();
79 }
80
64 } // namespace 81 } // namespace
65 82
66 class RouteResponseCallbackHandler { 83 class RouteResponseCallbackHandler {
67 public: 84 public:
68 MOCK_METHOD2(Invoke, 85 MOCK_METHOD2(Invoke,
69 void(const MediaRoute* route, const std::string& error_text)); 86 void(const MediaRoute* route, const std::string& error_text));
70 }; 87 };
71 88
72 class SendMessageCallbackHandler { 89 class SendMessageCallbackHandler {
73 public: 90 public:
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 route_response_callbacks); 268 route_response_callbacks);
252 ProcessEventLoop(); 269 ProcessEventLoop();
253 } 270 }
254 271
255 TEST_F(MediaRouterMojoImplTest, CloseRoute) { 272 TEST_F(MediaRouterMojoImplTest, CloseRoute) {
256 EXPECT_CALL(mock_media_route_provider_, CloseRoute(mojo::String(kRouteId))); 273 EXPECT_CALL(mock_media_route_provider_, CloseRoute(mojo::String(kRouteId)));
257 router()->CloseRoute(kRouteId); 274 router()->CloseRoute(kRouteId);
258 ProcessEventLoop(); 275 ProcessEventLoop();
259 } 276 }
260 277
278 TEST_F(MediaRouterMojoImplTest, RegisterAndUnregisterIssuesObserver) {
Kevin M 2015/07/29 17:41:49 This is testing more than just registration/unregi
haibinlu 2015/07/29 18:46:07 Changed name to 'HandleIssue'
279 MockIssuesObserver issue_observer1(router());
Kevin M 2015/07/29 17:41:49 Add an IssueManager mock
haibinlu 2015/07/29 18:46:07 In order to make the mock, we need to mark IssueMa
280 MockIssuesObserver issue_observer2(router());
281 const Issue* issue;
282 EXPECT_CALL(issue_observer1, OnIssueUpdated(_))
283 .WillRepeatedly(SaveArg<0>(&issue));
Kevin M 2015/07/29 17:41:49 Be explicit with the # of Times()
haibinlu 2015/07/29 18:46:07 Done.
284 EXPECT_CALL(issue_observer2, OnIssueUpdated(_));
285 media_router_proxy_->OnIssue(CreateMojoIssue().Pass());
286 ProcessEventLoop();
287
288 EXPECT_TRUE(Mock::VerifyAndClearExpectations(&issue_observer1));
289 EXPECT_TRUE(Mock::VerifyAndClearExpectations(&issue_observer2));
290
291 router()->ClearIssue(issue->id());
292 router()->UnregisterIssuesObserver(&issue_observer1);
293 EXPECT_CALL(issue_observer2, OnIssueUpdated(_));
294 media_router_proxy_->OnIssue(CreateMojoIssue().Pass());
295 ProcessEventLoop();
296 }
297
261 TEST_F(MediaRouterMojoImplTest, RegisterAndUnregisterMediaSinksObserver) { 298 TEST_F(MediaRouterMojoImplTest, RegisterAndUnregisterMediaSinksObserver) {
262 MediaSource media_source(kSource); 299 MediaSource media_source(kSource);
263 300
264 MockMediaRouter mock_router; 301 MockMediaRouter mock_router;
265 EXPECT_CALL(mock_media_route_provider_, 302 EXPECT_CALL(mock_media_route_provider_,
266 StartObservingMediaSinks(mojo::String(kSource))).Times(2); 303 StartObservingMediaSinks(mojo::String(kSource))).Times(2);
267 EXPECT_CALL(mock_media_route_provider_, 304 EXPECT_CALL(mock_media_route_provider_,
268 StartObservingMediaSinks(mojo::String(kSource2))); 305 StartObservingMediaSinks(mojo::String(kSource2)));
269 306
270 MediaSinksObserver* captured_observer; 307 MediaSinksObserver* captured_observer;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 binding.reset(new mojo::Binding<interfaces::MediaRouteProvider>( 554 binding.reset(new mojo::Binding<interfaces::MediaRouteProvider>(
518 &mock_media_route_provider, mojo::GetProxy(&media_route_provider_proxy))); 555 &mock_media_route_provider, mojo::GetProxy(&media_route_provider_proxy)));
519 media_router_proxy->RegisterMediaRouteProvider( 556 media_router_proxy->RegisterMediaRouteProvider(
520 media_route_provider_proxy.Pass(), 557 media_route_provider_proxy.Pass(),
521 base::Bind(&RegisterMediaRouteProviderHandler::Invoke, 558 base::Bind(&RegisterMediaRouteProviderHandler::Invoke,
522 base::Unretained(&provide_handler))); 559 base::Unretained(&provide_handler)));
523 message_loop.RunUntilIdle(); 560 message_loop.RunUntilIdle();
524 } 561 }
525 562
526 } // namespace media_router 563 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698