Chromium Code Reviews| Index: chrome/test/media_router/media_router_integration_browsertest.cc |
| diff --git a/chrome/test/media_router/media_router_integration_browsertest.cc b/chrome/test/media_router/media_router_integration_browsertest.cc |
| index 3bda71218de22f9dfc528ab10e5d69504304c148..4125f0b11af43ef7947712c8858bb98e14203d3a 100644 |
| --- a/chrome/test/media_router/media_router_integration_browsertest.cc |
| +++ b/chrome/test/media_router/media_router_integration_browsertest.cc |
| @@ -55,7 +55,8 @@ const char kCloseRouteScript[] = |
| const char kGetRouteLengthScript[] = |
| "domAutomationController.send(window.document.getElementById(" |
| " 'media-router-container').routeList.length)"; |
| - |
| +const char kClickDialog[] = |
| + "window.document.getElementById('media-router-container').click();"; |
| std::string GetStartedSessionId(content::WebContents* web_contents) { |
| std::string session_id; |
| CHECK(content::ExecuteScriptAndExtractString( |
| @@ -143,6 +144,12 @@ void MediaRouterIntegrationBrowserTest::ChooseSink( |
| ASSERT_TRUE(content::ExecuteScript(dialog_contents, script)); |
| } |
| +void MediaRouterIntegrationBrowserTest::ClickDialog() { |
| + content::WebContents* web_contents = |
| + browser()->tab_strip_model()->GetActiveWebContents(); |
| + content::WebContents* dialog_contents = GetMRDialog(web_contents); |
| + ASSERT_TRUE(content::ExecuteScript(dialog_contents, kClickDialog)); |
| +} |
| content::WebContents* MediaRouterIntegrationBrowserTest::GetMRDialog( |
| content::WebContents* web_contents) { |
| MediaRouterDialogControllerImpl* controller = |
| @@ -152,6 +159,29 @@ content::WebContents* MediaRouterIntegrationBrowserTest::GetMRDialog( |
| return dialog_contents; |
| } |
| +bool MediaRouterIntegrationBrowserTest::IsDialogClosed( |
| + content::WebContents* web_contents) { |
| + MediaRouterDialogControllerImpl* controller = |
| + MediaRouterDialogControllerImpl::GetOrCreateForWebContents(web_contents); |
| + return !controller->GetMediaRouterDialog(); |
| +} |
| + |
| +void MediaRouterIntegrationBrowserTest::CheckDialogIsClosed( |
|
imcheng
2015/10/22 18:44:14
naming suggestion: WaitUntilDialogClosed
apacible
2015/10/23 18:03:11
Done.
|
| + content::WebContents* web_contents) { |
| + ASSERT_TRUE(ConditionalWait( |
| + base::TimeDelta::FromSeconds(5), base::TimeDelta::FromSeconds(1), |
| + base::Bind(&MediaRouterIntegrationBrowserTest::IsDialogClosed, |
| + base::Unretained(this), web_contents))); |
| +} |
| + |
| +void MediaRouterIntegrationBrowserTest::CheckDialogIsOpen( |
|
imcheng
2015/10/22 18:44:14
CheckDialogRemainsOpen
apacible
2015/10/23 18:03:11
Done.
|
| + content::WebContents* web_contents) { |
| + ASSERT_FALSE(ConditionalWait( |
| + base::TimeDelta::FromSeconds(5), base::TimeDelta::FromSeconds(1), |
| + base::Bind(&MediaRouterIntegrationBrowserTest::IsDialogClosed, |
| + base::Unretained(this), web_contents))); |
| +} |
| + |
| void MediaRouterIntegrationBrowserTest::SetTestData( |
| base::FilePath::StringPieceType test_data_file) { |
| base::FilePath full_path = GetResourceFile(test_data_file); |