blob: e794eb61153239311b11ade9089a86b4a503448a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// 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/modules/module_registry.h"
#include "gin/test/file_runner.h"
#include "gin/test/gtest.h"
#include "mojo/apps/js/bindings/core.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace mojo {
namespace js {
namespace {
class TestRunnerDelegate : public gin::FileRunnerDelegate {
public:
TestRunnerDelegate() {
AddBuiltinModule(Core::kModuleName, Core::GetModule);
}
private:
DISALLOW_COPY_AND_ASSIGN(TestRunnerDelegate);
};
void RunTest(std::string test) {
base::FilePath path;
PathService::Get(base::DIR_SOURCE_ROOT, &path);
path = path.AppendASCII("mojo")
.AppendASCII("apps")
.AppendASCII("js")
.AppendASCII("bindings")
.AppendASCII(test);
TestRunnerDelegate delegate;
gin::RunTestFromFile(path, &delegate);
}
// TODO(abarth): Should we autogenerate these stubs from GYP?
TEST(JSTest, core) {
RunTest("core_unittests.js");
}
TEST(JSTest, codec) {
RunTest("codec_unittests.js");
}
TEST(JSTest, sample_test) {
base::FilePath path;
PathService::Get(base::DIR_SOURCE_ROOT, &path);
path = path.AppendASCII("mojo")
.AppendASCII("public")
.AppendASCII("bindings")
.AppendASCII("sample")
.AppendASCII("sample_service_unittests.js");
TestRunnerDelegate delegate;
gin::RunTestFromFile(path, &delegate);
}
TEST(JSTest, connector) {
RunTest("connector_unittests.js");
}
} // namespace
} // namespace js
} // namespace mojo
|