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

Side by Side Diff: mojo/public/js/bindings/tests/run_js_tests.cc

Issue 411553003: Validate incoming JS Message Headers: test message parser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Factored common Buffer class, moved JS binding tests Created 6 years, 5 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
yzshen1 2014/07/23 19:53:38 nit: this is still needed.
hansmuller 2014/07/23 21:43:44 OK. I've restored it in run_apps_js_tests.cc as w
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "gin/modules/console.h" 8 #include "gin/modules/console.h"
9 #include "gin/modules/module_registry.h" 9 #include "gin/modules/module_registry.h"
10 #include "gin/modules/timer.h" 10 #include "gin/modules/timer.h"
11 #include "gin/test/file_runner.h" 11 #include "gin/test/file_runner.h"
12 #include "gin/test/gtest.h" 12 #include "gin/test/gtest.h"
13 #include "mojo/bindings/js/core.h" 13 #include "mojo/bindings/js/core.h"
14 #include "mojo/common/test/test_utils.h" 14 #include "mojo/common/test/test_utils.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 namespace mojo { 17 namespace mojo {
18 namespace js { 18 namespace js {
19 namespace { 19 namespace {
20 20
21 class TestRunnerDelegate : public gin::FileRunnerDelegate { 21 class TestRunnerDelegate : public gin::FileRunnerDelegate {
22 public: 22 public:
23 TestRunnerDelegate() { 23 TestRunnerDelegate() {
24 AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetModule); 24 AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetModule);
25 AddBuiltinModule(Core::kModuleName, Core::GetModule); 25 AddBuiltinModule(Core::kModuleName, Core::GetModule);
26 } 26 }
27 27
28 private: 28 private:
29 DISALLOW_COPY_AND_ASSIGN(TestRunnerDelegate); 29 DISALLOW_COPY_AND_ASSIGN(TestRunnerDelegate);
30 }; 30 };
31 31
32 void RunTest(std::string test, bool run_until_idle) { 32 void RunTest(std::string test, bool run_until_idle) {
33 base::FilePath path; 33 base::FilePath path;
34 PathService::Get(base::DIR_SOURCE_ROOT, &path); 34 PathService::Get(base::DIR_SOURCE_ROOT, &path);
35 path = path.AppendASCII("mojo") 35 path = path.AppendASCII("mojo")
36 .AppendASCII("public")
37 .AppendASCII("js")
36 .AppendASCII("bindings") 38 .AppendASCII("bindings")
37 .AppendASCII("js") 39 .AppendASCII("tests")
38 .AppendASCII(test); 40 .AppendASCII(test);
39 TestRunnerDelegate delegate; 41 TestRunnerDelegate delegate;
40 gin::RunTestFromFile(path, &delegate, run_until_idle); 42 gin::RunTestFromFile(path, &delegate, run_until_idle);
41 } 43 }
42 44
43 // TODO(abarth): Should we autogenerate these stubs from GYP? 45 // TODO(abarth): Should we autogenerate these stubs from GYP?
44 TEST(JSTest, core) { 46 TEST(JSTest, core) {
45 RunTest("core_unittests.js", true); 47 RunTest("core_unittests.js", true);
46 } 48 }
47 49
48 TEST(JSTest, codec) { 50 static bool MojoBindingFilesExist() {
yzshen1 2014/07/23 07:26:55 I think this whole check is not necessary anymore.
hansmuller 2014/07/23 18:06:36 OK. I've removed it from here and from /mojo/apps/
yzshen1 2014/07/23 19:53:38 Thanks! :)
49 // TODO(yzshen): Remove this check once isolated tests are supported on the 51 // TODO(yzshen): Remove this check once isolated tests are supported on the
50 // Chromium waterfall. (http://crbug.com/351214) 52 // Chromium waterfall. (http://crbug.com/351214)
51 const base::FilePath test_file_path( 53 const base::FilePath test_file_path(
52 test::GetFilePathForJSResource( 54 test::GetFilePathForJSResource(
53 "mojo/public/interfaces/bindings/tests/sample_service.mojom")); 55 "mojo/public/interfaces/bindings/tests/sample_service.mojom"));
54 if (!base::PathExists(test_file_path)) { 56 if (!base::PathExists(test_file_path)) {
55 LOG(WARNING) << "Mojom binding files don't exist. Skipping the test."; 57 LOG(WARNING) << "Mojom binding files don't exist. Skipping the test.";
58 return false;
59 }
60 return true;
61 }
62
63 TEST(JSTest, codec) {
64 if (!MojoBindingFilesExist())
56 return; 65 return;
57 } 66 RunTest("codec_unittests.js", true);
67 }
58 68
59 RunTest("codec_unittests.js", true); 69 TEST(JSTest, validation) {
70 if (!MojoBindingFilesExist())
71 return;
72 RunTest("validation_unittests.js", true);
60 } 73 }
61 74
62 } // namespace 75 } // namespace
63 } // namespace js 76 } // namespace js
64 } // namespace mojo 77 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698