OLD | NEW |
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/presentation_media_sinks_observer.h" | 5 #include "chrome/browser/media/router/presentation_media_sinks_observer.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "chrome/browser/media/router/media_source_helper.h" | 11 #include "chrome/browser/media/router/media_source_helper.h" |
12 #include "chrome/browser/media/router/mock_media_router.h" | 12 #include "chrome/browser/media/router/mock_media_router.h" |
13 #include "chrome/browser/media/router/mock_screen_availability_listener.h" | 13 #include "chrome/browser/media/router/mock_screen_availability_listener.h" |
14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
15 #include "content/public/browser/presentation_screen_availability_listener.h" | 15 #include "content/public/browser/presentation_screen_availability_listener.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
17 | 17 |
18 using testing::_; | 18 using testing::_; |
19 using testing::Mock; | 19 using testing::Mock; |
20 using testing::Return; | 20 using testing::Return; |
21 | 21 |
22 namespace media_router { | 22 namespace media_router { |
23 | 23 |
24 class PresentationMediaSinksObserverTest : public ::testing::Test { | 24 class PresentationMediaSinksObserverTest : public ::testing::Test { |
25 public: | 25 public: |
26 PresentationMediaSinksObserverTest() | 26 PresentationMediaSinksObserverTest() |
27 : listener_("http://example.com/presentation.html") {} | 27 : listener_(GURL("http://example.com/presentation.html")) {} |
28 ~PresentationMediaSinksObserverTest() override {} | 28 ~PresentationMediaSinksObserverTest() override {} |
29 | 29 |
30 void SetUp() override { | 30 void SetUp() override { |
31 EXPECT_CALL(router_, RegisterMediaSinksObserver(_)).WillOnce(Return(true)); | 31 EXPECT_CALL(router_, RegisterMediaSinksObserver(_)).WillOnce(Return(true)); |
32 observer_.reset(new PresentationMediaSinksObserver( | 32 observer_.reset(new PresentationMediaSinksObserver( |
33 &router_, &listener_, | 33 &router_, &listener_, MediaSourceForPresentationUrl( |
34 MediaSourceForPresentationUrl("http://example.com/presentation.html"), | 34 GURL("http://example.com/presentation.html")), |
35 GURL("https://google.com"))); | 35 GURL("https://google.com"))); |
36 EXPECT_TRUE(observer_->Init()); | 36 EXPECT_TRUE(observer_->Init()); |
37 } | 37 } |
38 | 38 |
39 void TearDown() override { | 39 void TearDown() override { |
40 EXPECT_CALL(router_, UnregisterMediaSinksObserver(_)); | 40 EXPECT_CALL(router_, UnregisterMediaSinksObserver(_)); |
41 observer_.reset(); | 41 observer_.reset(); |
42 } | 42 } |
43 | 43 |
44 MockMediaRouter router_; | 44 MockMediaRouter router_; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 observer_->OnSinksReceived(result); | 84 observer_->OnSinksReceived(result); |
85 EXPECT_TRUE(Mock::VerifyAndClearExpectations(&listener_)); | 85 EXPECT_TRUE(Mock::VerifyAndClearExpectations(&listener_)); |
86 | 86 |
87 // |listener_| should get result since it changed to false. | 87 // |listener_| should get result since it changed to false. |
88 EXPECT_CALL(listener_, OnScreenAvailabilityChanged(false)).Times(1); | 88 EXPECT_CALL(listener_, OnScreenAvailabilityChanged(false)).Times(1); |
89 observer_->OnSinksReceived(std::vector<MediaSink>()); | 89 observer_->OnSinksReceived(std::vector<MediaSink>()); |
90 EXPECT_TRUE(Mock::VerifyAndClearExpectations(&listener_)); | 90 EXPECT_TRUE(Mock::VerifyAndClearExpectations(&listener_)); |
91 } | 91 } |
92 | 92 |
93 } // namespace media_router | 93 } // namespace media_router |
OLD | NEW |