| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/ui/webui/web_ui_browsertest.h" | 5 #include "chrome/browser/ui/webui/web_ui_browsertest.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 private: | 509 private: |
| 510 static WebUIBrowserTest* s_test_; | 510 static WebUIBrowserTest* s_test_; |
| 511 }; | 511 }; |
| 512 | 512 |
| 513 WebUIBrowserTest* WebUIBrowserExpectFailTest::s_test_ = NULL; | 513 WebUIBrowserTest* WebUIBrowserExpectFailTest::s_test_ = NULL; |
| 514 | 514 |
| 515 // Test that bogus javascript fails fast - no timeout waiting for result. | 515 // Test that bogus javascript fails fast - no timeout waiting for result. |
| 516 IN_PROC_BROWSER_TEST_F(WebUIBrowserExpectFailTest, TestFailsFast) { | 516 IN_PROC_BROWSER_TEST_F(WebUIBrowserExpectFailTest, TestFailsFast) { |
| 517 AddLibrary(FilePath(FILE_PATH_LITERAL("sample_downloads.js"))); | 517 AddLibrary(FilePath(FILE_PATH_LITERAL("sample_downloads.js"))); |
| 518 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIDownloadsURL)); | 518 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIDownloadsURL)); |
| 519 EXPECT_FATAL_FAILURE(RunJavascriptTestNoReturn("FAILS_BogusFunctionName"), | 519 EXPECT_FATAL_FAILURE(RunJavascriptTestNoReturn("DISABLED_BogusFunctionName"), |
| 520 "WebUITestHandler::Observe"); | 520 "WebUITestHandler::Observe"); |
| 521 } | 521 } |
| 522 | 522 |
| 523 // Test that bogus javascript fails fast - no timeout waiting for result. | 523 // Test that bogus javascript fails fast - no timeout waiting for result. |
| 524 IN_PROC_BROWSER_TEST_F(WebUIBrowserExpectFailTest, TestRuntimeErrorFailsFast) { | 524 IN_PROC_BROWSER_TEST_F(WebUIBrowserExpectFailTest, TestRuntimeErrorFailsFast) { |
| 525 AddLibrary(FilePath(FILE_PATH_LITERAL("runtime_error.js"))); | 525 AddLibrary(FilePath(FILE_PATH_LITERAL("runtime_error.js"))); |
| 526 ui_test_utils::NavigateToURL(browser(), GURL(kDummyURL)); | 526 ui_test_utils::NavigateToURL(browser(), GURL(kDummyURL)); |
| 527 EXPECT_FATAL_FAILURE(RunJavascriptTestNoReturn("TestRuntimeErrorFailsFast"), | 527 EXPECT_FATAL_FAILURE(RunJavascriptTestNoReturn("TestRuntimeErrorFailsFast"), |
| 528 "WebUITestHandler::Observe"); | 528 "WebUITestHandler::Observe"); |
| 529 } | 529 } |
| 530 | 530 |
| 531 // Test that bogus javascript fails async test fast as well - no timeout waiting | 531 // Test that bogus javascript fails async test fast as well - no timeout waiting |
| 532 // for result. | 532 // for result. |
| 533 IN_PROC_BROWSER_TEST_F(WebUIBrowserExpectFailTest, TestFailsAsyncFast) { | 533 IN_PROC_BROWSER_TEST_F(WebUIBrowserExpectFailTest, TestFailsAsyncFast) { |
| 534 AddLibrary(FilePath(FILE_PATH_LITERAL("sample_downloads.js"))); | 534 AddLibrary(FilePath(FILE_PATH_LITERAL("sample_downloads.js"))); |
| 535 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIDownloadsURL)); | 535 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIDownloadsURL)); |
| 536 EXPECT_FATAL_FAILURE( | 536 EXPECT_FATAL_FAILURE( |
| 537 RunJavascriptAsyncTestNoReturn("FAILS_BogusFunctionName"), | 537 RunJavascriptAsyncTestNoReturn("DISABLED_BogusFunctionName"), |
| 538 "WebUITestHandler::Observe"); | 538 "WebUITestHandler::Observe"); |
| 539 } | 539 } |
| 540 | 540 |
| 541 // Tests that the async framework works. | 541 // Tests that the async framework works. |
| 542 class WebUIBrowserAsyncTest : public WebUIBrowserTest { | 542 class WebUIBrowserAsyncTest : public WebUIBrowserTest { |
| 543 public: | 543 public: |
| 544 // Calls the testDone() function from test_api.js | 544 // Calls the testDone() function from test_api.js |
| 545 void TestDone() { | 545 void TestDone() { |
| 546 RunJavascriptFunction("testDone"); | 546 RunJavascriptFunction("testDone"); |
| 547 } | 547 } |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 // testDone directly and expect pass result. | 698 // testDone directly and expect pass result. |
| 699 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { | 699 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { |
| 700 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); | 700 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); |
| 701 } | 701 } |
| 702 | 702 |
| 703 // Test that calling testDone during RunJavascriptTest still completes when | 703 // Test that calling testDone during RunJavascriptTest still completes when |
| 704 // waiting for async result. | 704 // waiting for async result. |
| 705 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { | 705 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { |
| 706 ASSERT_TRUE(RunJavascriptTest("testDone")); | 706 ASSERT_TRUE(RunJavascriptTest("testDone")); |
| 707 } | 707 } |
| OLD | NEW |