| 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/test/media_router/media_router_integration_browsertest.h" | 5 #include "chrome/test/media_router/media_router_integration_browsertest.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/json/json_file_value_serializer.h" | 9 #include "base/json/json_file_value_serializer.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| 11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/browser_finder.h" | 16 #include "chrome/browser/ui/browser_finder.h" |
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "chrome/browser/ui/views/frame/browser_view.h" | 18 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 19 #include "chrome/browser/ui/webui/media_router/media_router_dialog_controller_im
pl.h" | 19 #include "chrome/browser/ui/webui/media_router/media_router_dialog_controller_im
pl.h" |
| 20 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
| 21 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
| 22 #include "content/public/browser/render_frame_host.h" |
| 22 #include "content/public/test/browser_test_utils.h" | 23 #include "content/public/test/browser_test_utils.h" |
| 23 #include "content/public/test/test_navigation_observer.h" | 24 #include "content/public/test/test_navigation_observer.h" |
| 24 #include "content/public/test/test_utils.h" | 25 #include "content/public/test/test_utils.h" |
| 25 #include "net/base/filename_util.h" | 26 #include "net/base/filename_util.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 27 | 28 |
| 28 | 29 |
| 29 namespace media_router { | 30 namespace media_router { |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 test_navigation_observer_->Wait(); | 167 test_navigation_observer_->Wait(); |
| 167 test_navigation_observer_->StopWatchingNewWebContents(); | 168 test_navigation_observer_->StopWatchingNewWebContents(); |
| 168 } | 169 } |
| 169 | 170 |
| 170 void MediaRouterIntegrationBrowserTest::ChooseSink( | 171 void MediaRouterIntegrationBrowserTest::ChooseSink( |
| 171 content::WebContents* web_contents, | 172 content::WebContents* web_contents, |
| 172 const std::string& sink_name) { | 173 const std::string& sink_name) { |
| 173 content::WebContents* dialog_contents = GetMRDialog(web_contents); | 174 content::WebContents* dialog_contents = GetMRDialog(web_contents); |
| 174 std::string script = base::StringPrintf( | 175 std::string script = base::StringPrintf( |
| 175 kChooseSinkScript, sink_name.c_str()); | 176 kChooseSinkScript, sink_name.c_str()); |
| 176 ASSERT_TRUE(content::ExecuteScript(dialog_contents, script)); | 177 // Execute javascript to choose sink, but don't wait until it finishes. |
| 178 dialog_contents->GetMainFrame()->ExecuteJavaScriptWithUserGestureForTests( |
| 179 base::UTF8ToUTF16(script)); |
| 177 } | 180 } |
| 178 | 181 |
| 179 void MediaRouterIntegrationBrowserTest::CheckStartFailed( | 182 void MediaRouterIntegrationBrowserTest::CheckStartFailed( |
| 180 content::WebContents* web_contents, | 183 content::WebContents* web_contents, |
| 181 const std::string& error_name, | 184 const std::string& error_name, |
| 182 const std::string& error_message_substring) { | 185 const std::string& error_message_substring) { |
| 183 std::string script(base::StringPrintf(kCheckStartFailedScript, | 186 std::string script(base::StringPrintf(kCheckStartFailedScript, |
| 184 error_name.c_str(), | 187 error_name.c_str(), |
| 185 error_message_substring.c_str())); | 188 error_message_substring.c_str())); |
| 186 ExecuteJavaScriptAPI(web_contents, script); | 189 ExecuteJavaScriptAPI(web_contents, script); |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 | 601 |
| 599 MediaRouterDialogControllerImpl* controller = | 602 MediaRouterDialogControllerImpl* controller = |
| 600 MediaRouterDialogControllerImpl::GetOrCreateForWebContents(web_contents); | 603 MediaRouterDialogControllerImpl::GetOrCreateForWebContents(web_contents); |
| 601 EXPECT_TRUE(controller->IsShowingMediaRouterDialog()); | 604 EXPECT_TRUE(controller->IsShowingMediaRouterDialog()); |
| 602 WaitUntilSinkDiscoveredOnUI(); | 605 WaitUntilSinkDiscoveredOnUI(); |
| 603 controller->HideMediaRouterDialog(); | 606 controller->HideMediaRouterDialog(); |
| 604 CheckStartFailed(web_contents, "NotFoundError", "No screens found."); | 607 CheckStartFailed(web_contents, "NotFoundError", "No screens found."); |
| 605 } | 608 } |
| 606 | 609 |
| 607 } // namespace media_router | 610 } // namespace media_router |
| OLD | NEW |