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..fd7a15441e98c9e71559ce8cc250653b052acc06 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,10 @@ class V8UnitTest : public testing::Test { |
virtual void SetUp(); |
protected: |
+ void AddLibrary(const FilePath& library_path); |
+ 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 +50,47 @@ 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 passing so far. |
+ bool ExecuteJavascriptLibraries(); |
+ |
+ // Initialize 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_; |
+ |
+ // Location of test data (currently test/data/webui). |
+ FilePath test_data_directory_; |
+ |
+ // Location of generated test data (<(PROGRAM_DIR)/test_data). |
+ FilePath gen_test_data_directory_; |
+ |
+ // User added libraries. |
+ std::vector<FilePath> user_libraries_; |
+ |
+ // Whether errors were seen. |
+ static bool had_errors_; |
+ |
+ // testDone results. |
+ static bool testResult_ok_; |
}; |
#endif // CHROME_TEST_BASE_V8_UNIT_TEST_H_ |