diff options
author | abarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-18 23:05:12 +0000 |
---|---|---|
committer | abarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-18 23:05:12 +0000 |
commit | fd5cf7fd4622292d331b9c1af77fa2335688df2f (patch) | |
tree | e78150b2b80ceac70bc38132695481d63cb0348b /gin/test | |
parent | 168a15cb1ac0f810c0372f86a02fb564e25d5424 (diff) | |
download | chromium_src-fd5cf7fd4622292d331b9c1af77fa2335688df2f.zip chromium_src-fd5cf7fd4622292d331b9c1af77fa2335688df2f.tar.gz chromium_src-fd5cf7fd4622292d331b9c1af77fa2335688df2f.tar.bz2 |
Implement Mojo message codec in JavaScript
This CL contains an encoder and decoder for the Mojo message IPC format. I've
tested the encoder and decoder against each other, but I haven't yet tested them
against the C++ implementation.
I haven't tried to tune the encoder or decoder for performance. IMHO, we should
work on that after getting correctness.
The C++ code for JSTest.codec is a bit verbose because the C++ code need to
load all the dependencies for codec_unittests.js. A better approach is to teach
the system how to load dependencies from the file system, but I've left that for
a future CL.
BUG=317398
R=aa@chromium.org
Review URL: https://codereview.chromium.org/69843003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235838 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gin/test')
-rw-r--r-- | gin/test/file_runner.cc | 13 | ||||
-rw-r--r-- | gin/test/file_runner.h | 3 | ||||
-rw-r--r-- | gin/test/gtest.cc | 6 | ||||
-rw-r--r-- | gin/test/gtest.h | 6 |
4 files changed, 12 insertions, 16 deletions
diff --git a/gin/test/file_runner.cc b/gin/test/file_runner.cc index a343d64..dd0ca66 100644 --- a/gin/test/file_runner.cc +++ b/gin/test/file_runner.cc @@ -27,28 +27,19 @@ base::FilePath GetModuleBase() { FileRunnerDelegate::FileRunnerDelegate() : ModuleRunnerDelegate(GetModuleBase()) { + AddBuiltinModule(GTest::kModuleName, GTest::GetTemplate); } FileRunnerDelegate::~FileRunnerDelegate() { } -void FileRunnerDelegate::DidCreateContext(Runner* runner) { - ModuleRunnerDelegate::DidCreateContext(runner); - - v8::Handle<v8::Context> context = runner->context(); - ModuleRegistry* registry = ModuleRegistry::From(context); - - registry->AddBuiltinModule(runner->isolate(), "gtest", - GetGTestTemplate(runner->isolate())); -} - void FileRunnerDelegate::UnhandledException(Runner* runner, TryCatch& try_catch) { ModuleRunnerDelegate::UnhandledException(runner, try_catch); EXPECT_FALSE(try_catch.HasCaught()) << try_catch.GetPrettyMessage(); } -void RunTestFromFile(const base::FilePath& path, RunnerDelegate* delegate) { +void RunTestFromFile(const base::FilePath& path, FileRunnerDelegate* delegate) { ASSERT_TRUE(base::PathExists(path)) << path.LossyDisplayName(); std::string source; ASSERT_TRUE(ReadFileToString(path, &source)); diff --git a/gin/test/file_runner.h b/gin/test/file_runner.h index b00e089..c4164f5 100644 --- a/gin/test/file_runner.h +++ b/gin/test/file_runner.h @@ -19,13 +19,12 @@ class FileRunnerDelegate : public ModuleRunnerDelegate { private: // From ModuleRunnerDelegate: - virtual void DidCreateContext(Runner* runner) OVERRIDE; virtual void UnhandledException(Runner* runner, TryCatch& try_catch) OVERRIDE; DISALLOW_COPY_AND_ASSIGN(FileRunnerDelegate); }; -void RunTestFromFile(const base::FilePath& path, RunnerDelegate* delegate); +void RunTestFromFile(const base::FilePath& path, FileRunnerDelegate* delegate); } // namespace gin diff --git a/gin/test/gtest.cc b/gin/test/gtest.cc index 2d77563..d600418 100644 --- a/gin/test/gtest.cc +++ b/gin/test/gtest.cc @@ -54,9 +54,11 @@ void ExpectEqual(const v8::FunctionCallbackInfo<v8::Value>& info) { WrapperInfo g_gtest_wrapper_info = {}; -} +} // namespace + +const char GTest::kModuleName[] = "gtest"; -v8::Local<v8::ObjectTemplate> GetGTestTemplate(v8::Isolate* isolate) { +v8::Local<v8::ObjectTemplate> GTest::GetTemplate(v8::Isolate* isolate) { PerIsolateData* data = PerIsolateData::From(isolate); v8::Local<v8::ObjectTemplate> templ = data->GetObjectTemplate( &g_gtest_wrapper_info); diff --git a/gin/test/gtest.h b/gin/test/gtest.h index e4ad534..ee19b71 100644 --- a/gin/test/gtest.h +++ b/gin/test/gtest.h @@ -9,7 +9,11 @@ namespace gin { -v8::Local<v8::ObjectTemplate> GetGTestTemplate(v8::Isolate* isolate); +class GTest { + public: + static const char kModuleName[]; + static v8::Local<v8::ObjectTemplate> GetTemplate(v8::Isolate* isolate); +}; } // namespace gin |