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

Side by Side Diff: chrome/browser/media/router/mojo/media_router_mojo_test.cc

Issue 2837363002: [Media Router] Use DialMediaSinkService in MediaRouterMojoImpl (Closed)
Patch Set: fix windows unit tests failures Created 3 years, 7 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 "chrome/browser/media/router/mojo/media_router_mojo_test.h" 5 #include "chrome/browser/media/router/mojo/media_router_mojo_test.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "extensions/common/test_util.h" 10 #include "extensions/common/test_util.h"
11 11
12 namespace media_router { 12 namespace media_router {
13 namespace { 13 namespace {
14
15 const char kInstanceId[] = "instance123"; 14 const char kInstanceId[] = "instance123";
16
17 void ExpectEqualStrings(const std::string& expected,
18 const std::string& actual) {
19 EXPECT_EQ(expected, actual);
20 }
21
22 } // namespace 15 } // namespace
23 16
24 MockMediaRouteProvider::MockMediaRouteProvider() {} 17 MockMediaRouteProvider::MockMediaRouteProvider() {}
25 18
26 MockMediaRouteProvider::~MockMediaRouteProvider() {} 19 MockMediaRouteProvider::~MockMediaRouteProvider() {}
27 20
28 MockEventPageTracker::MockEventPageTracker() {} 21 MockEventPageTracker::MockEventPageTracker() {}
29 22
30 MockEventPageTracker::~MockEventPageTracker() {} 23 MockEventPageTracker::~MockEventPageTracker() {}
31 24
32 MockMediaController::MockMediaController() : binding_(this) {} 25 MockMediaController::MockMediaController() : binding_(this) {}
33 26
34 MockMediaController::~MockMediaController() {} 27 MockMediaController::~MockMediaController() {}
35 28
29 RegisterMediaRouteProviderHandler::RegisterMediaRouteProviderHandler() {}
30
31 RegisterMediaRouteProviderHandler::~RegisterMediaRouteProviderHandler() {}
32
36 void MockMediaController::Bind(mojom::MediaControllerRequest request) { 33 void MockMediaController::Bind(mojom::MediaControllerRequest request) {
37 binding_.Bind(std::move(request)); 34 binding_.Bind(std::move(request));
38 } 35 }
39 36
40 mojom::MediaControllerPtr MockMediaController::BindInterfacePtr() { 37 mojom::MediaControllerPtr MockMediaController::BindInterfacePtr() {
41 return binding_.CreateInterfacePtrAndBind(); 38 return binding_.CreateInterfacePtrAndBind();
42 } 39 }
43 40
44 void MockMediaController::CloseBinding() { 41 void MockMediaController::CloseBinding() {
45 binding_.Close(); 42 binding_.Close();
46 } 43 }
47 44
48 MockMediaRouteController::MockMediaRouteController( 45 MockMediaRouteController::MockMediaRouteController(
49 const MediaRoute::Id& route_id, 46 const MediaRoute::Id& route_id,
50 mojom::MediaControllerPtr mojo_media_controller, 47 mojom::MediaControllerPtr mojo_media_controller,
51 MediaRouter* media_router) 48 MediaRouter* media_router)
52 : MediaRouteController(route_id, 49 : MediaRouteController(route_id,
53 std::move(mojo_media_controller), 50 std::move(mojo_media_controller),
54 media_router) {} 51 media_router) {}
55 52
56 MockMediaRouteController::~MockMediaRouteController() {} 53 MockMediaRouteController::~MockMediaRouteController() {}
57 54
58 MockMediaRouteControllerObserver::MockMediaRouteControllerObserver( 55 MockMediaRouteControllerObserver::MockMediaRouteControllerObserver(
59 scoped_refptr<MediaRouteController> controller) 56 scoped_refptr<MediaRouteController> controller)
60 : MediaRouteController::Observer(controller) {} 57 : MediaRouteController::Observer(controller) {}
61 58
62 MockMediaRouteControllerObserver::~MockMediaRouteControllerObserver() {} 59 MockMediaRouteControllerObserver::~MockMediaRouteControllerObserver() {}
63 60
64 MediaRouterMojoTest::MediaRouterMojoTest() 61 MediaRouterMojoTest::MediaRouterMojoTest()
65 : mock_media_router_(new MediaRouterMojoImpl(&mock_event_page_tracker_)) { 62 : mock_media_router_(
63 new MediaRouterMojoImpl(&mock_event_page_tracker_, &profile_)) {
66 mock_media_router_->Initialize(); 64 mock_media_router_->Initialize();
67 mock_media_router_->set_instance_id_for_test(kInstanceId); 65 mock_media_router_->set_instance_id_for_test(kInstanceId);
68 extension_ = extensions::test_util::CreateEmptyExtension(); 66 extension_ = extensions::test_util::CreateEmptyExtension();
69 } 67 }
70 68
71 MediaRouterMojoTest::~MediaRouterMojoTest() {} 69 MediaRouterMojoTest::~MediaRouterMojoTest() {}
72 70
73 void MediaRouterMojoTest::ConnectProviderManagerService() { 71 void MediaRouterMojoTest::ConnectProviderManagerService() {
74 // Bind the |media_route_provider| interface to |media_route_provider_|. 72 // Bind the |media_route_provider| interface to |media_route_provider_|.
75 auto request = mojo::MakeRequest(&media_router_proxy_); 73 auto request = mojo::MakeRequest(&media_router_proxy_);
76 mock_media_router_->BindToMojoRequest(std::move(request), *extension_); 74 mock_media_router_->BindToMojoRequest(std::move(request), *extension_);
77 75
78 // Bind the Mojo MediaRouter interface used by |mock_media_router_| to 76 // Bind the Mojo MediaRouter interface used by |mock_media_router_| to
79 // |mock_media_route_provider_service_|. 77 // |mock_media_route_provider_service_|.
80 mojom::MediaRouteProviderPtr mojo_media_router; 78 mojom::MediaRouteProviderPtr mojo_media_router;
81 binding_.reset(new mojo::Binding<mojom::MediaRouteProvider>( 79 binding_.reset(new mojo::Binding<mojom::MediaRouteProvider>(
82 &mock_media_route_provider_, mojo::MakeRequest(&mojo_media_router))); 80 &mock_media_route_provider_, mojo::MakeRequest(&mojo_media_router)));
81 EXPECT_CALL(provide_handler_, InvokeRaw(kInstanceId, testing::_));
83 media_router_proxy_->RegisterMediaRouteProvider( 82 media_router_proxy_->RegisterMediaRouteProvider(
84 std::move(mojo_media_router), 83 std::move(mojo_media_router),
85 base::Bind(&ExpectEqualStrings, kInstanceId)); 84 base::Bind(&RegisterMediaRouteProviderHandler::Invoke,
85 base::Unretained(&provide_handler_)));
86 } 86 }
87 87
88 void MediaRouterMojoTest::SetUp() { 88 void MediaRouterMojoTest::SetUp() {
89 ON_CALL(mock_event_page_tracker_, IsEventPageSuspended(extension_id())) 89 ON_CALL(mock_event_page_tracker_, IsEventPageSuspended(extension_id()))
90 .WillByDefault(testing::Return(false)); 90 .WillByDefault(testing::Return(false));
91 ConnectProviderManagerService(); 91 ConnectProviderManagerService();
92 base::RunLoop().RunUntilIdle(); 92 base::RunLoop().RunUntilIdle();
93 } 93 }
94 94
95 void MediaRouterMojoTest::TearDown() { 95 void MediaRouterMojoTest::TearDown() {
96 mock_media_router_->Shutdown(); 96 mock_media_router_->Shutdown();
97 } 97 }
98 98
99 void MediaRouterMojoTest::ProcessEventLoop() { 99 void MediaRouterMojoTest::ProcessEventLoop() {
100 base::RunLoop().RunUntilIdle(); 100 base::RunLoop().RunUntilIdle();
101 } 101 }
102 102
103 } // namespace media_router 103 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698