| 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/thread_task_runner_handle.h" | 14 #include "base/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/grit/generated_resources.h" |
| 21 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.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" |
| 28 #include "ui/base/l10n/l10n_util.h" |
| 27 | 29 |
| 28 | 30 |
| 29 namespace media_router { | 31 namespace media_router { |
| 30 | 32 |
| 31 namespace { | 33 namespace { |
| 32 // The path relative to <chromium src>/out/<build config> for media router | 34 // The path relative to <chromium src>/out/<build config> for media router |
| 33 // browser test resources. | 35 // browser test resources. |
| 34 const base::FilePath::StringPieceType kResourcePath = FILE_PATH_LITERAL( | 36 const base::FilePath::StringPieceType kResourcePath = FILE_PATH_LITERAL( |
| 35 "media_router/browser_test_resources/"); | 37 "media_router/browser_test_resources/"); |
| 36 const char kTestSinkName[] = "test-sink-1"; | 38 const char kTestSinkName[] = "test-sink-1"; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 content::WebContents* web_contents = | 239 content::WebContents* web_contents = |
| 238 browser()->tab_strip_model()->GetActiveWebContents(); | 240 browser()->tab_strip_model()->GetActiveWebContents(); |
| 239 content::WebContents* dialog_contents = GetMRDialog(web_contents); | 241 content::WebContents* dialog_contents = GetMRDialog(web_contents); |
| 240 ASSERT_TRUE(content::ExecuteScript(dialog_contents, kCloseRouteScript)); | 242 ASSERT_TRUE(content::ExecuteScript(dialog_contents, kCloseRouteScript)); |
| 241 ASSERT_TRUE(ConditionalWait( | 243 ASSERT_TRUE(ConditionalWait( |
| 242 base::TimeDelta::FromSeconds(10), base::TimeDelta::FromSeconds(1), | 244 base::TimeDelta::FromSeconds(10), base::TimeDelta::FromSeconds(1), |
| 243 base::Bind(&MediaRouterIntegrationBrowserTest::AreRoutesClosedOnUI, | 245 base::Bind(&MediaRouterIntegrationBrowserTest::AreRoutesClosedOnUI, |
| 244 base::Unretained(this)))); | 246 base::Unretained(this)))); |
| 245 } | 247 } |
| 246 | 248 |
| 249 void MediaRouterIntegrationBrowserTest::WaitUntilRouteCreationTimeout() { |
| 250 ASSERT_FALSE(ConditionalWait( |
| 251 base::TimeDelta::FromSeconds(30), base::TimeDelta::FromSeconds(1), |
| 252 base::Bind(&MediaRouterIntegrationBrowserTest::IsRouteCreatedOnUI, |
| 253 base::Unretained(this)))); |
| 254 } |
| 255 |
| 247 IN_PROC_BROWSER_TEST_F(MediaRouterIntegrationBrowserTest, MANUAL_Basic) { | 256 IN_PROC_BROWSER_TEST_F(MediaRouterIntegrationBrowserTest, MANUAL_Basic) { |
| 248 OpenTestPage(FILE_PATH_LITERAL("basic_test.html")); | 257 OpenTestPage(FILE_PATH_LITERAL("basic_test.html")); |
| 249 content::WebContents* web_contents = | 258 content::WebContents* web_contents = |
| 250 browser()->tab_strip_model()->GetActiveWebContents(); | 259 browser()->tab_strip_model()->GetActiveWebContents(); |
| 251 ASSERT_TRUE(web_contents); | 260 ASSERT_TRUE(web_contents); |
| 252 ExecuteJavaScriptAPI(web_contents, kWaitDeviceScript); | 261 ExecuteJavaScriptAPI(web_contents, kWaitDeviceScript); |
| 253 StartSession(web_contents); | 262 StartSession(web_contents); |
| 254 ChooseSink(web_contents, kTestSinkName); | 263 ChooseSink(web_contents, kTestSinkName); |
| 255 ExecuteJavaScriptAPI(web_contents, kCheckSessionScript); | 264 ExecuteJavaScriptAPI(web_contents, kCheckSessionScript); |
| 256 Wait(base::TimeDelta::FromSeconds(5)); | 265 Wait(base::TimeDelta::FromSeconds(5)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 268 IN_PROC_BROWSER_TEST_F(MediaRouterIntegrationBrowserTest, | 277 IN_PROC_BROWSER_TEST_F(MediaRouterIntegrationBrowserTest, |
| 269 MANUAL_Fail_No_Provider) { | 278 MANUAL_Fail_No_Provider) { |
| 270 SetTestData(FILE_PATH_LITERAL("no_provider.json")); | 279 SetTestData(FILE_PATH_LITERAL("no_provider.json")); |
| 271 OpenTestPage(FILE_PATH_LITERAL("no_provider.html")); | 280 OpenTestPage(FILE_PATH_LITERAL("no_provider.html")); |
| 272 content::WebContents* web_contents = | 281 content::WebContents* web_contents = |
| 273 browser()->tab_strip_model()->GetActiveWebContents(); | 282 browser()->tab_strip_model()->GetActiveWebContents(); |
| 274 ASSERT_TRUE(web_contents); | 283 ASSERT_TRUE(web_contents); |
| 275 ExecuteJavaScriptAPI(web_contents, kWaitDeviceScript); | 284 ExecuteJavaScriptAPI(web_contents, kWaitDeviceScript); |
| 276 StartSession(web_contents); | 285 StartSession(web_contents); |
| 277 ChooseSink(web_contents, kTestSinkName); | 286 ChooseSink(web_contents, kTestSinkName); |
| 287 WaitUntilRouteCreationTimeout(); |
| 278 ExecuteJavaScriptAPI(web_contents, kCheckSessionFailedScript); | 288 ExecuteJavaScriptAPI(web_contents, kCheckSessionFailedScript); |
| 289 |
| 290 content::WebContents* dialog_contents = GetMRDialog(web_contents); |
| 291 std::string script = base::StringPrintf( |
| 292 "domAutomationController.send(window.document.getElementById(" |
| 293 "'media-router-container').issue.title)"); |
| 294 std::string issue_title = ExecuteScriptAndExtractString( |
| 295 dialog_contents, script); |
| 296 ASSERT_EQ(l10n_util::GetStringUTF8( |
| 297 IDS_MEDIA_ROUTER_ISSUE_CREATE_ROUTE_TIMEOUT), |
| 298 issue_title); |
| 279 } | 299 } |
| 280 | 300 |
| 281 IN_PROC_BROWSER_TEST_F(MediaRouterIntegrationBrowserTest, | 301 IN_PROC_BROWSER_TEST_F(MediaRouterIntegrationBrowserTest, |
| 282 MANUAL_Fail_Create_Route) { | 302 MANUAL_Fail_Create_Route) { |
| 283 SetTestData(FILE_PATH_LITERAL("fail_create_route.json")); | 303 SetTestData(FILE_PATH_LITERAL("fail_create_route.json")); |
| 284 OpenTestPage(FILE_PATH_LITERAL("fail_create_route.html")); | 304 OpenTestPage(FILE_PATH_LITERAL("fail_create_route.html")); |
| 285 content::WebContents* web_contents = | 305 content::WebContents* web_contents = |
| 286 browser()->tab_strip_model()->GetActiveWebContents(); | 306 browser()->tab_strip_model()->GetActiveWebContents(); |
| 287 ASSERT_TRUE(web_contents); | 307 ASSERT_TRUE(web_contents); |
| 288 ExecuteJavaScriptAPI(web_contents, kWaitDeviceScript); | 308 ExecuteJavaScriptAPI(web_contents, kWaitDeviceScript); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 content::WebContents* new_web_contents = | 357 content::WebContents* new_web_contents = |
| 338 browser()->tab_strip_model()->GetActiveWebContents(); | 358 browser()->tab_strip_model()->GetActiveWebContents(); |
| 339 ASSERT_TRUE(new_web_contents); | 359 ASSERT_TRUE(new_web_contents); |
| 340 ExecuteJavaScriptAPI( | 360 ExecuteJavaScriptAPI( |
| 341 new_web_contents, | 361 new_web_contents, |
| 342 base::StringPrintf("checkReconnectSessionFails('%s');", | 362 base::StringPrintf("checkReconnectSessionFails('%s');", |
| 343 session_id.c_str())); | 363 session_id.c_str())); |
| 344 } | 364 } |
| 345 | 365 |
| 346 } // namespace media_router | 366 } // namespace media_router |
| OLD | NEW |