Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "gin/modules/module_registry.h" | 7 #include "gin/modules/module_registry.h" |
| 8 #include "gin/test/file_runner.h" | 8 #include "gin/test/file_runner.h" |
| 9 #include "gin/test/gtest.h" | 9 #include "gin/test/gtest.h" |
| 10 #include "mojo/public/bindings/js/runner_delegate.h" | 10 #include "mojo/public/bindings/js/runner_delegate.h" |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 .AppendASCII(test); | 37 .AppendASCII(test); |
| 38 TestRunnerDelegate delegate; | 38 TestRunnerDelegate delegate; |
| 39 gin::RunTestFromFile(path, &delegate); | 39 gin::RunTestFromFile(path, &delegate); |
| 40 } | 40 } |
| 41 | 41 |
| 42 // TODO(abarth): Should we autogenerate these stubs from GYP? | 42 // TODO(abarth): Should we autogenerate these stubs from GYP? |
| 43 TEST(JSTest, core) { | 43 TEST(JSTest, core) { |
| 44 RunTest("core_unittests.js"); | 44 RunTest("core_unittests.js"); |
| 45 } | 45 } |
| 46 | 46 |
| 47 TEST(JSTest, codec) { | |
| 48 // TODO(abarth): Rather than loading all these files manually, we should | |
| 49 // teach the module loading system how to find imported modules on disk. | |
|
abarth-chromium
2013/11/17 20:07:05
This code will get much cleaner once https://coder
| |
| 50 | |
| 51 base::FilePath path; | |
| 52 PathService::Get(base::DIR_SOURCE_ROOT, &path); | |
| 53 path = path.AppendASCII("mojo") | |
| 54 .AppendASCII("public") | |
| 55 .AppendASCII("bindings") | |
| 56 .AppendASCII("js"); | |
| 57 | |
| 58 base::FilePath codec_path = path.AppendASCII("codec.js"); | |
| 59 ASSERT_TRUE(base::PathExists(codec_path)) | |
| 60 << codec_path.LossyDisplayName(); | |
| 61 | |
| 62 base::FilePath codec_unittests_path = path.AppendASCII("codec_unittests.js"); | |
| 63 ASSERT_TRUE(base::PathExists(codec_unittests_path)) | |
| 64 << codec_unittests_path.LossyDisplayName(); | |
| 65 | |
| 66 base::FilePath sample_service_path = | |
| 67 path.AppendASCII("test").AppendASCII("sample_service.js"); | |
| 68 ASSERT_TRUE(base::PathExists(sample_service_path)) | |
| 69 << sample_service_path.LossyDisplayName(); | |
| 70 | |
| 71 std::string codec; | |
| 72 ASSERT_TRUE(ReadFileToString(codec_path, &codec)); | |
| 73 | |
| 74 std::string codec_unittests; | |
| 75 ASSERT_TRUE(ReadFileToString(codec_unittests_path, &codec_unittests)); | |
| 76 | |
| 77 std::string sample_service; | |
| 78 ASSERT_TRUE(ReadFileToString(sample_service_path, &sample_service)); | |
| 79 | |
| 80 TestRunnerDelegate delegate; | |
| 81 gin::RunTestFromString(codec + codec_unittests + sample_service, &delegate); | |
| 82 } | |
| 83 | |
| 47 } // namespace | 84 } // namespace |
| 48 } // namespace js | 85 } // namespace js |
| 49 } // namespace mojo | 86 } // namespace mojo |
| OLD | NEW |