diff options
author | hansmuller@chromium.org <hansmuller@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-28 17:52:55 +0000 |
---|---|---|
committer | hansmuller@chromium.org <hansmuller@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-28 17:52:55 +0000 |
commit | 66bc54dd8edb69e77b20d3e61f17b24513a8d590 (patch) | |
tree | 6352924960f450604faf7b306ab08e0e0e425ddb | |
parent | c933541fdb0c2535c6ca144943788a7826a9c60b (diff) | |
download | chromium_src-66bc54dd8edb69e77b20d3e61f17b24513a8d590.zip chromium_src-66bc54dd8edb69e77b20d3e61f17b24513a8d590.tar.gz chromium_src-66bc54dd8edb69e77b20d3e61f17b24513a8d590.tar.bz2 |
Fixed gin_shell and added a smoke test.
Renamed gin_shell's local gin::ModuleRunnerDelegate subclass to since it was being overridden by the gin::ShellRunner base class.
BUG=397263
Review URL: https://codereview.chromium.org/413333002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285943 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | gin/BUILD.gn | 1 | ||||
-rw-r--r-- | gin/gin.gyp | 1 | ||||
-rw-r--r-- | gin/shell/gin_main.cc | 8 | ||||
-rw-r--r-- | gin/shell/gin_shell_unittest.cc | 34 | ||||
-rw-r--r-- | gin/shell/hello_world.js | 7 |
5 files changed, 47 insertions, 4 deletions
diff --git a/gin/BUILD.gn b/gin/BUILD.gn index 7b3f06e..d45c148 100644 --- a/gin/BUILD.gn +++ b/gin/BUILD.gn @@ -112,6 +112,7 @@ test("gin_unittests") { "modules/timer_unittest.cc", "per_context_data_unittest.cc", "shell_runner_unittest.cc", + "shell/gin_shell_unittest.cc", "test/run_all_unittests.cc", "test/run_js_tests.cc", "wrappable_unittest.cc", diff --git a/gin/gin.gyp b/gin/gin.gyp index 6ee6065..217d865 100644 --- a/gin/gin.gyp +++ b/gin/gin.gyp @@ -130,6 +130,7 @@ 'modules/timer_unittest.cc', 'per_context_data_unittest.cc', 'shell_runner_unittest.cc', + 'shell/gin_shell_unittest.cc', 'test/run_all_unittests.cc', 'test/run_js_tests.cc', 'wrappable_unittest.cc', diff --git a/gin/shell/gin_main.cc b/gin/shell/gin_main.cc index 8fc9465..d8c32ad 100644 --- a/gin/shell/gin_main.cc +++ b/gin/shell/gin_main.cc @@ -37,9 +37,9 @@ std::vector<base::FilePath> GetModuleSearchPaths() { return module_base; } -class ShellRunnerDelegate : public ModuleRunnerDelegate { +class GinShellRunnerDelegate : public ModuleRunnerDelegate { public: - ShellRunnerDelegate() : ModuleRunnerDelegate(GetModuleSearchPaths()) { + GinShellRunnerDelegate() : ModuleRunnerDelegate(GetModuleSearchPaths()) { AddBuiltinModule(Console::kModuleName, Console::GetModule); } @@ -50,7 +50,7 @@ class ShellRunnerDelegate : public ModuleRunnerDelegate { } private: - DISALLOW_COPY_AND_ASSIGN(ShellRunnerDelegate); + DISALLOW_COPY_AND_ASSIGN(GinShellRunnerDelegate); }; } // namespace @@ -65,7 +65,7 @@ int main(int argc, char** argv) { base::MessageLoop message_loop; - gin::ShellRunnerDelegate delegate; + gin::GinShellRunnerDelegate delegate; gin::ShellRunner runner(&delegate, instance.isolate()); { diff --git a/gin/shell/gin_shell_unittest.cc b/gin/shell/gin_shell_unittest.cc new file mode 100644 index 0000000..0df979d --- /dev/null +++ b/gin/shell/gin_shell_unittest.cc @@ -0,0 +1,34 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/command_line.h" +#include "base/files/file_path.h" +#include "base/path_service.h" +#include "base/process/launch.h" +#include "base/strings/string_util.h" +#include "testing/gtest/include/gtest/gtest.h" + +base::FilePath GinShellPath() { + base::FilePath dir; + PathService::Get(base::DIR_EXE, &dir); + return dir.AppendASCII("gin_shell"); +} + +base::FilePath HelloWorldPath() { + base::FilePath path; + PathService::Get(base::DIR_SOURCE_ROOT, &path); + return path + .AppendASCII("gin") + .AppendASCII("shell") + .AppendASCII("hello_world.js"); +} + +TEST(GinShellTest, HelloWorld) { + CommandLine cmd(GinShellPath()); + cmd.AppendArgPath(HelloWorldPath()); + std::string output; + ASSERT_TRUE(base::GetAppOutput(cmd, &output)); + base::TrimWhitespaceASCII(output, base::TRIM_ALL, &output); + ASSERT_EQ("Hello World", output); +} diff --git a/gin/shell/hello_world.js b/gin/shell/hello_world.js new file mode 100644 index 0000000..7216fbd1 --- /dev/null +++ b/gin/shell/hello_world.js @@ -0,0 +1,7 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +define(["console"], function(console) { + console.log("Hello World"); +}); |