Index: chrome/browser/ui/webui/net_internals_ui_browsertest.cc |
=================================================================== |
--- chrome/browser/ui/webui/net_internals_ui_browsertest.cc (revision 95540) |
+++ chrome/browser/ui/webui/net_internals_ui_browsertest.cc (working copy) |
@@ -31,25 +31,7 @@ |
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; |
virtual void SetUpOnMainThread() OVERRIDE; |
- // Runs the specified Javascript test function with the specified arguments |
- // and waits for the title to change to "Test Passed" or "Test Failed". |
- void RunTestAndWaitForTitle(const std::string& function_name, |
- const ListValue& function_arguments); |
- |
- // Same as above, with constant number of arguments for easy use. Will also |
- // free arguments. |
- void RunTestAndWaitForTitle(const std::string& function_name); |
- void RunTestAndWaitForTitle(const std::string& function_name, Value* arg); |
- void RunTestAndWaitForTitle(const std::string& function_name, |
- Value* arg1, Value* arg2); |
- void RunTestAndWaitForTitle(const std::string& function_name, |
- Value* arg1, Value* arg2, Value* arg3); |
- |
- void set_expected_title_(const string16& value) { expected_title_ = value; } |
- |
private: |
- // The expected title at the end of the test. Defaults to kPassTitle. |
- string16 expected_title_; |
DISALLOW_COPY_AND_ASSIGN(NetInternalsTest); |
}; |
@@ -87,92 +69,45 @@ |
GURL(chrome::kChromeUINetInternalsURL)); |
} |
-void NetInternalsTest::RunTestAndWaitForTitle( |
- const std::string& function_name, |
- const ListValue& function_arguments) { |
- ui_test_utils::TitleWatcher title_watcher(browser()->GetTabContentsAt(0), |
- kPassTitle); |
- title_watcher.AlsoWaitForTitle(kFailTitle); |
- |
- ConstValueVector arguments; |
- StringValue function_name_arg(function_name); |
- arguments.push_back(&function_name_arg); |
- arguments.push_back(&function_arguments); |
- |
- ASSERT_TRUE(RunJavascriptFunction("netInternalsTest.runTest", arguments)); |
- ASSERT_EQ(expected_title_, title_watcher.WaitAndGetTitle()); |
-} |
- |
-void NetInternalsTest::RunTestAndWaitForTitle( |
- const std::string& function_name) { |
- ListValue test_arguments; |
- RunTestAndWaitForTitle(function_name, test_arguments); |
-} |
- |
-void NetInternalsTest::RunTestAndWaitForTitle(const std::string& function_name, |
- Value* arg) { |
- ListValue test_arguments; |
- test_arguments.Append(arg); |
- RunTestAndWaitForTitle(function_name, test_arguments); |
-} |
- |
-void NetInternalsTest::RunTestAndWaitForTitle(const std::string& function_name, |
- Value* arg1, Value* arg2) { |
- ListValue test_arguments; |
- test_arguments.Append(arg1); |
- test_arguments.Append(arg2); |
- RunTestAndWaitForTitle(function_name, test_arguments); |
-} |
- |
-void NetInternalsTest::RunTestAndWaitForTitle(const std::string& function_name, |
- Value* arg1, Value* arg2, |
- Value* arg3) { |
- ListValue test_arguments; |
- test_arguments.Append(arg1); |
- test_arguments.Append(arg2); |
- test_arguments.Append(arg3); |
- RunTestAndWaitForTitle(function_name, test_arguments); |
-} |
- |
//////////////////////////////////////////////////////////////////////////////// |
-// framework.js |
+// net_internals_test.js |
//////////////////////////////////////////////////////////////////////////////// |
// Checks testDone. |
IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsDone) { |
- RunTestAndWaitForTitle("NetInternalsDone"); |
+ ASSERT_TRUE(RunJavascriptTest("NetInternalsDone")); |
+ ASSERT_TRUE(WaitForAsyncResult();); |
} |
// Checks a failed expect statement. |
IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsExpectFail) { |
- set_expected_title_(kFailTitle); |
- RunTestAndWaitForTitle("NetInternalsExpectFail"); |
+ ASSERT_FALSE(RunJavascriptTest("NetInternalsExpectFail")); |
} |
// Checks a failed assert statement. |
IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsAssertFail) { |
- set_expected_title_(kFailTitle); |
- RunTestAndWaitForTitle("NetInternalsAssertFail"); |
+ ASSERT_FALSE(RunJavascriptTest("NetInternalsAssertFail")); |
} |
// Checks that testDone works when called by an observer in response to an |
// event. |
IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsObserverDone) { |
- RunTestAndWaitForTitle("NetInternalsObserverDone"); |
+ ASSERT_TRUE(RunJavascriptTest("NetInternalsObserverDone")); |
+ ASSERT_TRUE(WaitForAsyncResult()); |
} |
// Checks that a failed expect works when called by an observer in response |
// to an event. |
IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsObserverExpectFail) { |
- set_expected_title_(kFailTitle); |
- RunTestAndWaitForTitle("NetInternalsObserverExpectFail"); |
+ ASSERT_TRUE(RunJavascriptTest("NetInternalsObserverExpectFail")); |
+ ASSERT_FALSE(WaitForAsyncResult()); |
} |
// Checks that a failed assertion works when called by an observer in response |
// to an event. |
IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsObserverAssertFail) { |
- set_expected_title_(kFailTitle); |
- RunTestAndWaitForTitle("NetInternalsObserverAssertFail"); |
+ ASSERT_TRUE(RunJavascriptTest("NetInternalsObserverAssertFail")); |
+ ASSERT_FALSE(WaitForAsyncResult()); |
} |
//////////////////////////////////////////////////////////////////////////////// |
@@ -184,7 +119,7 @@ |
// the table. |
IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsTestViewPassTwice) { |
ASSERT_TRUE(test_server()->Start()); |
- RunTestAndWaitForTitle( |
+ ASSERT_TRUE(RunJavascriptTest( |
"NetInternalsTestView", |
// URL that results in success. |
Value::CreateStringValue( |
@@ -192,14 +127,15 @@ |
// Resulting error code of the first test. |
Value::CreateIntegerValue(net::OK), |
// Number of times to run the test suite. |
- Value::CreateIntegerValue(2)); |
+ Value::CreateIntegerValue(2))); |
+ ASSERT_TRUE(WaitForAsyncResult()); |
} |
// Runs the test suite twice, expecting a failing result the first time. Checks |
// the first result, the order of events that occur, and the number of rows in |
// the table. |
IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsTestViewFailTwice) { |
- RunTestAndWaitForTitle( |
+ ASSERT_TRUE(RunJavascriptTest( |
"NetInternalsTestView", |
// URL that results in an error, due to the port. |
Value::CreateStringValue("http://127.0.0.1:7/"), |
@@ -207,6 +143,7 @@ |
Value::CreateIntegerValue(net::ERR_UNSAFE_PORT), |
// Number of times to run the test suite. |
Value::CreateIntegerValue(2)); |
+ ASSERT_TRUE(WaitForAsyncResult()); |
} |
//////////////////////////////////////////////////////////////////////////////// |
@@ -217,7 +154,7 @@ |
// to fail, the second is expected to succeed. |
IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsPrerenderView) { |
ASSERT_TRUE(test_server()->Start()); |
- RunTestAndWaitForTitle( |
+ ASSERT_TRUE(RunJavascriptTest( |
"NetInternalsPrerenderView", |
// URL that can't be prerendered, since it triggers a download. |
Value::CreateStringValue( |
@@ -225,6 +162,7 @@ |
// URL that can be prerendered. |
Value::CreateStringValue( |
test_server()->GetURL("files/title1.html").spec())); |
+ ASSERT_TRUE(WaitForAsyncResult()); |
} |
//////////////////////////////////////////////////////////////////////////////// |
@@ -234,7 +172,7 @@ |
// Check that we correctly remove cookies and login information. |
IN_PROC_BROWSER_TEST_F(NetInternalsTest, |
NetInternalsLogViewPainterStripInfo) { |
- RunTestAndWaitForTitle("NetInternalsLogViewPainterStripInfo"); |
+ ASSERT_TRUE(RunJavascriptTest("NetInternalsLogViewPainterStripInfo")); |
} |
} // namespace |