| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "chrome/browser/media/router/create_presentation_connection_request.h" | 7 #include "chrome/browser/media/router/create_presentation_connection_request.h" |
| 8 #include "chrome/browser/media/router/media_router_dialog_controller.h" | 8 #include "chrome/browser/media/router/media_router_dialog_controller.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/features.h" |
| 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 11 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 11 #include "content/public/browser/render_process_host.h" | 12 #include "content/public/browser/render_process_host.h" |
| 12 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 13 #include "content/public/browser/web_contents_delegate.h" | 14 #include "content/public/browser/web_contents_delegate.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 17 |
| 17 using ::testing::Return; | 18 using ::testing::Return; |
| 18 | 19 |
| 19 namespace media_router { | 20 namespace media_router { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 base::Bind(&MediaRouterDialogControllerTest::RequestSuccess, | 72 base::Bind(&MediaRouterDialogControllerTest::RequestSuccess, |
| 72 base::Unretained(this)), | 73 base::Unretained(this)), |
| 73 base::Bind(&MediaRouterDialogControllerTest::RequestError, | 74 base::Bind(&MediaRouterDialogControllerTest::RequestError, |
| 74 base::Unretained(this))); | 75 base::Unretained(this))); |
| 75 } | 76 } |
| 76 | 77 |
| 77 std::unique_ptr<TestMediaRouterDialogController> dialog_controller_; | 78 std::unique_ptr<TestMediaRouterDialogController> dialog_controller_; |
| 78 std::unique_ptr<MockWebContentsDelegate> web_contents_delegate_; | 79 std::unique_ptr<MockWebContentsDelegate> web_contents_delegate_; |
| 79 }; | 80 }; |
| 80 | 81 |
| 82 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 83 // The non-Android implementation is tested in |
| 84 // MediaRouterDialogControllerImplTest. |
| 81 TEST_F(MediaRouterDialogControllerTest, CreateForWebContents) { | 85 TEST_F(MediaRouterDialogControllerTest, CreateForWebContents) { |
| 82 MediaRouterDialogController* dialog_controller = | 86 MediaRouterDialogController* dialog_controller = |
| 83 MediaRouterDialogController::GetOrCreateForWebContents(web_contents()); | 87 MediaRouterDialogController::GetOrCreateForWebContents(web_contents()); |
| 84 ASSERT_NE(dialog_controller, nullptr); | 88 ASSERT_NE(dialog_controller, nullptr); |
| 85 } | 89 } |
| 90 #endif |
| 86 | 91 |
| 87 TEST_F(MediaRouterDialogControllerTest, ShowAndHideDialog) { | 92 TEST_F(MediaRouterDialogControllerTest, ShowAndHideDialog) { |
| 88 EXPECT_CALL(*web_contents_delegate_, ActivateContents(web_contents())); | 93 EXPECT_CALL(*web_contents_delegate_, ActivateContents(web_contents())); |
| 89 EXPECT_TRUE(dialog_controller_->ShowMediaRouterDialog()); | 94 EXPECT_TRUE(dialog_controller_->ShowMediaRouterDialog()); |
| 90 EXPECT_TRUE(dialog_controller_->IsShowingMediaRouterDialog()); | 95 EXPECT_TRUE(dialog_controller_->IsShowingMediaRouterDialog()); |
| 91 | 96 |
| 92 // If a dialog is already shown, ShowMediaRouterDialog() should return false. | 97 // If a dialog is already shown, ShowMediaRouterDialog() should return false. |
| 93 EXPECT_CALL(*web_contents_delegate_, ActivateContents(web_contents())); | 98 EXPECT_CALL(*web_contents_delegate_, ActivateContents(web_contents())); |
| 94 EXPECT_FALSE(dialog_controller_->ShowMediaRouterDialog()); | 99 EXPECT_FALSE(dialog_controller_->ShowMediaRouterDialog()); |
| 95 | 100 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 109 EXPECT_TRUE(dialog_controller_->IsShowingMediaRouterDialog()); | 114 EXPECT_TRUE(dialog_controller_->IsShowingMediaRouterDialog()); |
| 110 | 115 |
| 111 // If a dialog is already shown, ShowMediaRouterDialogForPresentation() should | 116 // If a dialog is already shown, ShowMediaRouterDialogForPresentation() should |
| 112 // return false. | 117 // return false. |
| 113 EXPECT_CALL(*web_contents_delegate_, ActivateContents(web_contents())); | 118 EXPECT_CALL(*web_contents_delegate_, ActivateContents(web_contents())); |
| 114 EXPECT_FALSE( | 119 EXPECT_FALSE( |
| 115 dialog_controller_->ShowMediaRouterDialogForPresentation(GetRequest())); | 120 dialog_controller_->ShowMediaRouterDialogForPresentation(GetRequest())); |
| 116 } | 121 } |
| 117 | 122 |
| 118 } // namespace media_router | 123 } // namespace media_router |
| OLD | NEW |