Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / extensions / renderer / api / mojo_private / mojo_private_unittest.cc
blobaf1801ecdd862e81cce0097a0d85737fd806800c
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "extensions/renderer/api_test_base.h"
7 #include "gin/modules/module_registry.h"
9 // A test launcher for tests for the mojoPrivate API defined in
10 // extensions/test/data/mojo_private_unittest.js.
12 namespace extensions {
14 class MojoPrivateApiTest : public ApiTestBase {
15 public:
16 MojoPrivateApiTest() = default;
18 gin::ModuleRegistry* module_registry() {
19 return gin::ModuleRegistry::From(env()->context()->v8_context());
22 private:
23 DISALLOW_COPY_AND_ASSIGN(MojoPrivateApiTest);
26 TEST_F(MojoPrivateApiTest, Define) {
27 ASSERT_NO_FATAL_FAILURE(RunTest("mojo_private_unittest.js", "testDefine"));
28 EXPECT_EQ(1u, module_registry()->available_modules().count("testModule"));
31 TEST_F(MojoPrivateApiTest, DefineRegistersModule) {
32 ASSERT_NO_FATAL_FAILURE(
33 RunTest("mojo_private_unittest.js", "testDefineRegistersModule"));
34 EXPECT_EQ(1u, module_registry()->available_modules().count("testModule"));
35 EXPECT_EQ(1u, module_registry()->available_modules().count("dependency"));
38 TEST_F(MojoPrivateApiTest, DefineModuleDoesNotExist) {
39 ASSERT_NO_FATAL_FAILURE(
40 RunTest("mojo_private_unittest.js", "testDefineModuleDoesNotExist"));
41 EXPECT_EQ(0u, module_registry()->available_modules().count("testModule"));
42 EXPECT_EQ(0u,
43 module_registry()->available_modules().count("does not exist!"));
44 EXPECT_EQ(1u, module_registry()->unsatisfied_dependencies().count(
45 "does not exist!"));
48 TEST_F(MojoPrivateApiTest, RequireAsync) {
49 ASSERT_NO_FATAL_FAILURE(
50 RunTest("mojo_private_unittest.js", "testRequireAsync"));
53 TEST_F(MojoPrivateApiTest, DefineAndRequire) {
54 ASSERT_NO_FATAL_FAILURE(
55 RunTest("mojo_private_unittest.js", "testDefineAndRequire"));
58 } // namespace extensions