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

Unified Diff: mojo/public/bindings/js/test/harness.cc

Issue 62333018: Implement Asynchronous Module Definition API for Mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Aaron's comments Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/bindings/js/runner_delegate.cc ('k') | mojo/public/bindings/js/test/run_js_tests.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/bindings/js/test/harness.cc
diff --git a/mojo/public/bindings/js/test/harness.cc b/mojo/public/bindings/js/test/harness.cc
deleted file mode 100644
index 5b7319d718a08739f18f25316679d86cfc885508..0000000000000000000000000000000000000000
--- a/mojo/public/bindings/js/test/harness.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright 2013 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/file_util.h"
-#include "base/path_service.h"
-#include "gin/converter.h"
-#include "gin/runner.h"
-#include "gin/test/gtest.h"
-#include "mojo/public/bindings/js/runner_delegate.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-using v8::Isolate;
-using v8::Object;
-using v8::Script;
-using v8::Value;
-
-namespace mojo {
-namespace js {
-namespace {
-
-class TestRunnerDelegate : public RunnerDelegate {
- public:
- virtual ~TestRunnerDelegate() {}
-
- virtual v8::Handle<Object> CreateRootObject(
- gin::Runner* runner) MOJO_OVERRIDE {
- v8::Handle<Object> root = RunnerDelegate::CreateRootObject(runner);
- root->Set(gin::StringToSymbol(runner->isolate(), "gtest"),
- gin::GetGTestTemplate(runner->isolate())->NewInstance());
- return root;
- }
-};
-
-std::string GetExceptionInfo(const v8::TryCatch& try_catch) {
- std::string info;
- gin::ConvertFromV8(try_catch.Message()->Get(), &info);
- return info;
-}
-
-void RunTestFromFile(const base::FilePath& path) {
- EXPECT_TRUE(base::PathExists(path)) << path.LossyDisplayName();
- std::string source;
- EXPECT_TRUE(ReadFileToString(path, &source));
- Isolate* isolate = Isolate::GetCurrent();
-
- TestRunnerDelegate delegate;
- gin::Runner runner(&delegate, isolate);
- gin::Runner::Scope scope(&runner);
-
- v8::TryCatch try_catch;
- runner.Run(Script::New(gin::StringToV8(isolate, source)));
-
- EXPECT_FALSE(try_catch.HasCaught()) << GetExceptionInfo(try_catch);
-}
-
-void RunTest(std::string test) {
- base::FilePath path;
- PathService::Get(base::DIR_SOURCE_ROOT, &path);
- path = path.AppendASCII("mojo")
- .AppendASCII("public")
- .AppendASCII("bindings")
- .AppendASCII("js")
- .AppendASCII(test);
- RunTestFromFile(path);
-}
-
-// TODO(abarth): Should we autogenerate these stubs from GYP?
-TEST(Harness, mojo_unittests_js) {
- RunTest("mojo_unittests.js");
-}
-
-TEST(Harness, core_unittests_js) {
- RunTest("core_unittests.js");
-}
-
-} // namespace
-} // namespace js
-} // namespace mojo
« no previous file with comments | « mojo/public/bindings/js/runner_delegate.cc ('k') | mojo/public/bindings/js/test/run_js_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698