Index: chrome/test/base/v8_unit_test.h |
diff --git a/chrome/test/base/v8_unit_test.h b/chrome/test/base/v8_unit_test.h |
index 243b332e5efe0fe7c400e3db0690bdfa28087b8c..588362ec81b5a3d348b40bb1117d9a52b3c5a888 100644 |
--- a/chrome/test/base/v8_unit_test.h |
+++ b/chrome/test/base/v8_unit_test.h |
@@ -7,7 +7,9 @@ |
#pragma once |
#include <string> |
+#include <vector> |
+#include "base/file_path.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "v8/include/v8.h" |
@@ -26,6 +28,15 @@ class V8UnitTest : public testing::Test { |
virtual void SetUp(); |
protected: |
+ // Add a custom helper JS library for your test. |
+ // If a relative path is specified, it'll be read |
+ // as relative to the test data dir. |
+ void AddLibrary(const FilePath& library_path); |
+ |
+ // Runs a test fixture that may include calls to functions in test_api.js. |
+ bool RunJavascriptTestF(const std::string& testFixture, |
+ const std::string& testName); |
+ |
// Executes the given script source in the context. The specified script |
// name is used when reporting errors. |
virtual void ExecuteScriptInContext(const base::StringPiece& script_source, |
@@ -44,16 +55,35 @@ class V8UnitTest : public testing::Test { |
// functions implemented in JavaScript. |
virtual void TestFunction(const std::string& function_name); |
- // This method is bound to a global function "log" in the context. |
- // Scripts running in the context can call this to print out logging |
- // information to the console. |
+ // This method is bound to a global function "log" in the context, as well as |
+ // to log, warn, and info of the console object. Scripts running in the |
+ // context can call this to print out logging information to the console. |
static v8::Handle<v8::Value> Log(const v8::Arguments& args); |
+ // This method is bound to console.error in the context. Any calls to this |
+ // also signal an error condition and |RunJavascriptF| will fail. |
+ static v8::Handle<v8::Value> Error(const v8::Arguments& args); |
+ |
+ // This method is bound to a method "chrome.send" in the context. When |
+ // test_api calls testDone to report its results, this will capture and hold |
+ // the results for analysis by |RunJavascriptF|. |
+ static v8::Handle<v8::Value> ChromeSend(const v8::Arguments& args); |
+ |
+ private: |
+ // Executes all added javascript libraries. Returns true if no errors. |
+ bool ExecuteJavascriptLibraries(); |
+ |
+ // Initializes paths and libraries. |
+ void InitPathsAndLibraries(); |
+ |
// Handle scope that is used throughout the life of this class. |
v8::HandleScope handle_scope_; |
// Context for the JavaScript in the test. |
v8::Handle<v8::Context> context_; |
+ |
+ // User added libraries. |
+ std::vector<FilePath> user_libraries_; |
}; |
#endif // CHROME_TEST_BASE_V8_UNIT_TEST_H_ |