Convert browser_tests to Swarming.
[chromium-blink-merge.git] / chrome / browser / media / router / media_router_mojo_test.cc
blob75e62268164076cbc9763f116739411b5ea8b6de
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
3 // found in the LICENSE file.
5 #include "chrome/browser/media/router/media_router_mojo_test.h"
7 #include "base/run_loop.h"
9 namespace media_router {
10 namespace {
12 const char kInstanceId[] = "instance123";
14 template <typename T1, typename T2>
15 void ExpectAsyncResultEqual(T1 expected, T2 actual) {
16 EXPECT_EQ(expected, actual);
19 } // namespace
21 MockMojoMediaRouterService::MockMojoMediaRouterService() {
24 MockMojoMediaRouterService::~MockMojoMediaRouterService() {
27 MediaRouterMojoTest::MediaRouterMojoTest()
28 : message_loop_(mojo::common::MessagePumpMojo::Create()),
29 extension_id_("ext-123"),
30 router_(new MediaRouterMojoImpl(&mock_event_page_tracker_)) {
31 router_->set_instance_id_for_test(kInstanceId);
34 MediaRouterMojoTest::~MediaRouterMojoTest() {
37 void MediaRouterMojoTest::ConnectProviderManagerService() {
38 // Bind the |mojo_media_router_observer_| interface to |router_|.
39 auto request = mojo::GetProxy(&mojo_media_router_observer_);
40 router_->BindToMojoRequest(request.Pass(), extension_id_);
42 // Bind the Mojo MediaRouter interface used by |router_| to
43 // |mock_mojo_media_router_service_|.
44 interfaces::MediaRouterPtr mojo_media_router;
45 binding_.reset(new mojo::Binding<interfaces::MediaRouter>(
46 &mock_mojo_media_router_service_, mojo::GetProxy(&mojo_media_router)));
47 mojo_media_router_observer_->ProvideMediaRouter(
48 mojo_media_router.Pass(),
49 base::Bind(&ExpectAsyncResultEqual<std::string, mojo::String>,
50 kInstanceId));
53 void MediaRouterMojoTest::SetUp() {
54 ON_CALL(mock_event_page_tracker_, IsEventPageSuspended(extension_id_))
55 .WillByDefault(testing::Return(false));
57 ConnectProviderManagerService();
59 message_loop_.RunUntilIdle();
62 void MediaRouterMojoTest::ProcessEventLoop() {
63 base::RunLoop().RunUntilIdle();
66 } // namespace media_router