| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <limits> | 5 #include <limits> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 } | 308 } |
| 309 | 309 |
| 310 TestWebUIControllerFactory* factory() { return &factory_; } | 310 TestWebUIControllerFactory* factory() { return &factory_; } |
| 311 | 311 |
| 312 private: | 312 private: |
| 313 TestWebUIControllerFactory factory_; | 313 TestWebUIControllerFactory factory_; |
| 314 | 314 |
| 315 DISALLOW_COPY_AND_ASSIGN(WebUIMojoTest); | 315 DISALLOW_COPY_AND_ASSIGN(WebUIMojoTest); |
| 316 }; | 316 }; |
| 317 | 317 |
| 318 // Temporarily disabled due to flakiness on Windows. http://crbug.com/366644 | |
| 319 #if defined(OS_WIN) | |
| 320 #define MAYBE_EndToEndPing DISABLED_EndToEndPing | |
| 321 #define MAYBE_EndToEndEcho DISABLED_EndToEndEcho | |
| 322 #else | |
| 323 #define MAYBE_EndToEndPing EndToEndPing | |
| 324 #define MAYBE_EndToEndEcho EndToEndEcho | |
| 325 #endif | |
| 326 | |
| 327 // Loads a webui page that contains mojo bindings and verifies a message makes | 318 // Loads a webui page that contains mojo bindings and verifies a message makes |
| 328 // it from the browser to the page and back. | 319 // it from the browser to the page and back. |
| 329 IN_PROC_BROWSER_TEST_F(WebUIMojoTest, MAYBE_EndToEndPing) { | 320 IN_PROC_BROWSER_TEST_F(WebUIMojoTest, EndToEndPing) { |
| 330 // Currently there is no way to have a generated file included in the isolate | 321 // Currently there is no way to have a generated file included in the isolate |
| 331 // files. If the bindings file doesn't exist assume we're on such a bot and | 322 // files. If the bindings file doesn't exist assume we're on such a bot and |
| 332 // pass. | 323 // pass. |
| 333 // TODO(sky): remove this conditional when isolates support copying from gen. | 324 // TODO(sky): remove this conditional when isolates support copying from gen. |
| 334 const base::FilePath test_file_path( | 325 const base::FilePath test_file_path( |
| 335 mojo::test::GetFilePathForJSResource( | 326 mojo::test::GetFilePathForJSResource( |
| 336 "content/test/data/web_ui_test_mojo_bindings.mojom")); | 327 "content/test/data/web_ui_test_mojo_bindings.mojom")); |
| 337 if (!base::PathExists(test_file_path)) { | 328 if (!base::PathExists(test_file_path)) { |
| 338 LOG(WARNING) << " mojom binding file doesn't exist, assuming on isolate"; | 329 LOG(WARNING) << " mojom binding file doesn't exist, assuming on isolate"; |
| 339 return; | 330 return; |
| 340 } | 331 } |
| 341 | 332 |
| 342 got_message = false; | 333 got_message = false; |
| 343 ASSERT_TRUE(test_server()->Start()); | 334 ASSERT_TRUE(test_server()->Start()); |
| 344 base::RunLoop run_loop; | 335 base::RunLoop run_loop; |
| 345 factory()->set_run_loop(&run_loop); | 336 factory()->set_run_loop(&run_loop); |
| 346 GURL test_url(test_server()->GetURL("files/web_ui_mojo.html?ping")); | 337 GURL test_url(test_server()->GetURL("files/web_ui_mojo.html?ping")); |
| 347 NavigateToURL(shell(), test_url); | 338 NavigateToURL(shell(), test_url); |
| 348 // RunLoop is quit when message received from page. | 339 // RunLoop is quit when message received from page. |
| 349 run_loop.Run(); | 340 run_loop.Run(); |
| 350 EXPECT_TRUE(got_message); | 341 EXPECT_TRUE(got_message); |
| 351 } | 342 } |
| 352 | 343 |
| 353 // Loads a webui page that contains mojo bindings and verifies that | 344 // Loads a webui page that contains mojo bindings and verifies that |
| 354 // parameters are passed back correctly from JavaScript. | 345 // parameters are passed back correctly from JavaScript. |
| 355 IN_PROC_BROWSER_TEST_F(WebUIMojoTest, MAYBE_EndToEndEcho) { | 346 IN_PROC_BROWSER_TEST_F(WebUIMojoTest, EndToEndEcho) { |
| 356 // Currently there is no way to have a generated file included in the isolate | 347 // Currently there is no way to have a generated file included in the isolate |
| 357 // files. If the bindings file doesn't exist assume we're on such a bot and | 348 // files. If the bindings file doesn't exist assume we're on such a bot and |
| 358 // pass. | 349 // pass. |
| 359 // TODO(sky): remove this conditional when isolates support copying from gen. | 350 // TODO(sky): remove this conditional when isolates support copying from gen. |
| 360 const base::FilePath test_file_path( | 351 const base::FilePath test_file_path( |
| 361 mojo::test::GetFilePathForJSResource( | 352 mojo::test::GetFilePathForJSResource( |
| 362 "content/test/data/web_ui_test_mojo_bindings.mojom")); | 353 "content/test/data/web_ui_test_mojo_bindings.mojom")); |
| 363 if (!base::PathExists(test_file_path)) { | 354 if (!base::PathExists(test_file_path)) { |
| 364 LOG(WARNING) << " mojom binding file doesn't exist, assuming on isolate"; | 355 LOG(WARNING) << " mojom binding file doesn't exist, assuming on isolate"; |
| 365 return; | 356 return; |
| 366 } | 357 } |
| 367 | 358 |
| 368 message_count = 0; | 359 message_count = 0; |
| 369 ASSERT_TRUE(test_server()->Start()); | 360 ASSERT_TRUE(test_server()->Start()); |
| 370 base::RunLoop run_loop; | 361 base::RunLoop run_loop; |
| 371 factory()->set_run_loop(&run_loop); | 362 factory()->set_run_loop(&run_loop); |
| 372 GURL test_url(test_server()->GetURL("files/web_ui_mojo.html?echo")); | 363 GURL test_url(test_server()->GetURL("files/web_ui_mojo.html?echo")); |
| 373 NavigateToURL(shell(), test_url); | 364 NavigateToURL(shell(), test_url); |
| 374 // RunLoop is quit when response received from page. | 365 // RunLoop is quit when response received from page. |
| 375 run_loop.Run(); | 366 run_loop.Run(); |
| 376 EXPECT_EQ(kExpectedMessageCount, message_count); | 367 EXPECT_EQ(kExpectedMessageCount, message_count); |
| 377 } | 368 } |
| 378 | 369 |
| 379 } // namespace | 370 } // namespace |
| 380 } // namespace content | 371 } // namespace content |
| OLD | NEW |