Chromium Code Reviews| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 | 156 |
| 157 // Extract the fields. | 157 // Extract the fields. |
| 158 bool passed = false; | 158 bool passed = false; |
| 159 ASSERT_TRUE(dict_value->GetBoolean("passed", &passed)); | 159 ASSERT_TRUE(dict_value->GetBoolean("passed", &passed)); |
| 160 std::string error_message; | 160 std::string error_message; |
| 161 ASSERT_TRUE(dict_value->GetString("errorMessage", &error_message)); | 161 ASSERT_TRUE(dict_value->GetString("errorMessage", &error_message)); |
| 162 | 162 |
| 163 ASSERT_TRUE(passed) << error_message; | 163 ASSERT_TRUE(passed) << error_message; |
| 164 } | 164 } |
| 165 | 165 |
| 166 WebContents* MediaRouterIntegrationBrowserTest::StartSessionWithTestPageNow() { | 166 void MediaRouterIntegrationBrowserTest::StartSessionAndAssertNotFoundError() { |
| 167 OpenTestPage(FILE_PATH_LITERAL("basic_test.html")); | 167 OpenTestPage(FILE_PATH_LITERAL("basic_test.html")); |
| 168 WebContents* web_contents = GetActiveWebContents(); | 168 WebContents* web_contents = GetActiveWebContents(); |
| 169 CHECK(web_contents); | 169 CHECK(web_contents); |
| 170 StartSession(web_contents); | 170 StartSession(web_contents); |
| 171 return web_contents; | 171 |
| 172 // Wait a bit for the UI to settle. | |
|
mark a. foltz
2017/05/31 22:54:20
Maybe update this to "Wait for any sinks to be dis
imcheng
2017/05/31 23:12:27
Done.
| |
| 173 Wait(base::TimeDelta::FromSeconds(1)); | |
| 174 GetControllerForShownDialog(web_contents)->HideMediaRouterDialog(); | |
| 175 CheckStartFailed(web_contents, "NotFoundError", "No screens found."); | |
| 172 } | 176 } |
| 173 | 177 |
| 174 WebContents* | 178 WebContents* |
| 175 MediaRouterIntegrationBrowserTest::StartSessionWithTestPageAndSink() { | 179 MediaRouterIntegrationBrowserTest::StartSessionWithTestPageAndSink() { |
| 176 OpenTestPage(FILE_PATH_LITERAL("basic_test.html")); | 180 OpenTestPage(FILE_PATH_LITERAL("basic_test.html")); |
| 177 WebContents* web_contents = GetActiveWebContents(); | 181 WebContents* web_contents = GetActiveWebContents(); |
| 178 CHECK(web_contents); | 182 CHECK(web_contents); |
| 179 ExecuteJavaScriptAPI(web_contents, kWaitSinkScript); | 183 ExecuteJavaScriptAPI(web_contents, kWaitSinkScript); |
| 180 StartSession(web_contents); | 184 StartSession(web_contents); |
| 181 return web_contents; | 185 return web_contents; |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 621 IN_PROC_BROWSER_TEST_F(MediaRouterIntegrationBrowserTest, | 625 IN_PROC_BROWSER_TEST_F(MediaRouterIntegrationBrowserTest, |
| 622 MANUAL_Fail_StartCancelled) { | 626 MANUAL_Fail_StartCancelled) { |
| 623 WebContents* web_contents = StartSessionWithTestPageAndSink(); | 627 WebContents* web_contents = StartSessionWithTestPageAndSink(); |
| 624 GetControllerForShownDialog(web_contents)->HideMediaRouterDialog(); | 628 GetControllerForShownDialog(web_contents)->HideMediaRouterDialog(); |
| 625 CheckStartFailed(web_contents, "NotAllowedError", "Dialog closed."); | 629 CheckStartFailed(web_contents, "NotAllowedError", "Dialog closed."); |
| 626 } | 630 } |
| 627 | 631 |
| 628 IN_PROC_BROWSER_TEST_F(MediaRouterIntegrationBrowserTest, | 632 IN_PROC_BROWSER_TEST_F(MediaRouterIntegrationBrowserTest, |
| 629 MANUAL_Fail_StartCancelledNoSinks) { | 633 MANUAL_Fail_StartCancelledNoSinks) { |
| 630 SetTestData(FILE_PATH_LITERAL("no_sinks.json")); | 634 SetTestData(FILE_PATH_LITERAL("no_sinks.json")); |
| 631 WebContents* web_contents = StartSessionWithTestPageNow(); | 635 StartSessionAndAssertNotFoundError(); |
| 632 GetControllerForShownDialog(web_contents)->HideMediaRouterDialog(); | |
| 633 CheckStartFailed(web_contents, "NotFoundError", "No screens found."); | |
| 634 } | 636 } |
| 635 | 637 |
| 636 IN_PROC_BROWSER_TEST_F(MediaRouterIntegrationBrowserTest, | 638 IN_PROC_BROWSER_TEST_F(MediaRouterIntegrationBrowserTest, |
| 637 MANUAL_Fail_StartCancelledNoSupportedSinks) { | 639 MANUAL_Fail_StartCancelledNoSupportedSinks) { |
| 638 SetTestData(FILE_PATH_LITERAL("no_supported_sinks.json")); | 640 SetTestData(FILE_PATH_LITERAL("no_supported_sinks.json")); |
| 639 WebContents* web_contents = StartSessionWithTestPageNow(); | 641 StartSessionAndAssertNotFoundError(); |
| 640 WaitUntilSinkDiscoveredOnUI(); | |
| 641 GetControllerForShownDialog(web_contents)->HideMediaRouterDialog(); | |
| 642 CheckStartFailed(web_contents, "NotFoundError", "No screens found."); | |
| 643 } | 642 } |
| 644 | 643 |
| 645 void MediaRouterIntegrationIncognitoBrowserTest::InstallAndEnableMRExtension() { | 644 void MediaRouterIntegrationIncognitoBrowserTest::InstallAndEnableMRExtension() { |
| 646 const extensions::Extension* extension = | 645 const extensions::Extension* extension = |
| 647 LoadExtensionIncognito(extension_unpacked_); | 646 LoadExtensionIncognito(extension_unpacked_); |
| 648 incognito_extension_id_ = extension->id(); | 647 incognito_extension_id_ = extension->id(); |
| 649 } | 648 } |
| 650 | 649 |
| 651 void MediaRouterIntegrationIncognitoBrowserTest::UninstallMRExtension() { | 650 void MediaRouterIntegrationIncognitoBrowserTest::UninstallMRExtension() { |
| 652 if (!incognito_extension_id_.empty()) { | 651 if (!incognito_extension_id_.empty()) { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 664 MANUAL_Basic) { | 663 MANUAL_Basic) { |
| 665 RunBasicTest(); | 664 RunBasicTest(); |
| 666 } | 665 } |
| 667 | 666 |
| 668 IN_PROC_BROWSER_TEST_F(MediaRouterIntegrationIncognitoBrowserTest, | 667 IN_PROC_BROWSER_TEST_F(MediaRouterIntegrationIncognitoBrowserTest, |
| 669 MANUAL_ReconnectSession) { | 668 MANUAL_ReconnectSession) { |
| 670 RunReconnectSessionTest(); | 669 RunReconnectSessionTest(); |
| 671 } | 670 } |
| 672 | 671 |
| 673 } // namespace media_router | 672 } // namespace media_router |
| OLD | NEW |