| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/ui/webui/web_ui_browsertest.h" | 4 #include "chrome/browser/ui/webui/web_ui_browsertest.h" |
| 5 | 5 |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 return RunJavascriptFunction(function_name, args); | 72 return RunJavascriptFunction(function_name, args); |
| 73 } | 73 } |
| 74 | 74 |
| 75 bool WebUIBrowserTest::RunJavascriptFunction( | 75 bool WebUIBrowserTest::RunJavascriptFunction( |
| 76 const std::string& function_name, | 76 const std::string& function_name, |
| 77 const ConstValueVector& function_arguments) { | 77 const ConstValueVector& function_arguments) { |
| 78 return RunJavascriptUsingHandler( | 78 return RunJavascriptUsingHandler( |
| 79 function_name, function_arguments, false, false, NULL); | 79 function_name, function_arguments, false, false, NULL); |
| 80 } | 80 } |
| 81 | 81 |
| 82 bool WebUIBrowserTest::RunJavascriptTestF(const std::string& test_fixture, | 82 bool WebUIBrowserTest::RunJavascriptTestF(bool is_async, |
| 83 const std::string& test_fixture, |
| 83 const std::string& test_name) { | 84 const std::string& test_name) { |
| 84 ConstValueVector args; | 85 ConstValueVector args; |
| 85 args.push_back(Value::CreateStringValue(test_fixture)); | 86 args.push_back(Value::CreateStringValue(test_fixture)); |
| 86 args.push_back(Value::CreateStringValue(test_name)); | 87 args.push_back(Value::CreateStringValue(test_name)); |
| 87 return RunJavascriptTest("RUN_TEST_F", args); | 88 |
| 89 if (is_async) |
| 90 return RunJavascriptAsyncTest("RUN_TEST_F", args); |
| 91 else |
| 92 return RunJavascriptTest("RUN_TEST_F", args); |
| 88 } | 93 } |
| 89 | 94 |
| 90 bool WebUIBrowserTest::RunJavascriptTest(const std::string& test_name) { | 95 bool WebUIBrowserTest::RunJavascriptTest(const std::string& test_name) { |
| 91 return RunJavascriptTest(test_name, ConstValueVector()); | 96 return RunJavascriptTest(test_name, ConstValueVector()); |
| 92 } | 97 } |
| 93 | 98 |
| 94 bool WebUIBrowserTest::RunJavascriptTest(const std::string& test_name, | 99 bool WebUIBrowserTest::RunJavascriptTest(const std::string& test_name, |
| 95 const Value& arg) { | 100 const Value& arg) { |
| 96 ConstValueVector args; | 101 ConstValueVector args; |
| 97 args.push_back(&arg); | 102 args.push_back(&arg); |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 // testDone directly and expect pass result. | 571 // testDone directly and expect pass result. |
| 567 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { | 572 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { |
| 568 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); | 573 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); |
| 569 } | 574 } |
| 570 | 575 |
| 571 // Test that calling testDone during RunJavascriptTest still completes when | 576 // Test that calling testDone during RunJavascriptTest still completes when |
| 572 // waiting for async result. | 577 // waiting for async result. |
| 573 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { | 578 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { |
| 574 ASSERT_TRUE(RunJavascriptTest("testDone")); | 579 ASSERT_TRUE(RunJavascriptTest("testDone")); |
| 575 } | 580 } |
| OLD | NEW |