Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: chrome/browser/ui/webui/web_ui_browsertest.cc

Issue 7645007: WebUI Testing: async support - global mocking, deferred runs, continued run. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added ability to defer RunTest. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698