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

Side by Side Diff: extensions/renderer/api/mojo_private/mojo_private_unittest.cc

Issue 649003003: Add a mojoPrivate API that exposes mojo to component apps/extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@serial-service
Patch Set: Created 5 years, 11 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
OLDNEW
(Empty)
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.
4
5 #include "extensions/renderer/api_test_base.h"
6
7 #include "gin/modules/module_registry.h"
8
9 // A test launcher for tests for the mojoPrivate API defined in
10 // extensions/test/data/mojo_private_unittest.js.
11
12 namespace extensions {
13
14 class MojoPrivateApiTest : public ApiTestBase {
15 public:
16 MojoPrivateApiTest() = default;
17
18 gin::ModuleRegistry* module_registry() {
19 return gin::ModuleRegistry::From(env()->context()->v8_context());
20 }
21
22 private:
23 DISALLOW_COPY_AND_ASSIGN(MojoPrivateApiTest);
24 };
25
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"));
29 }
30
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"));
36 }
37
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!"));
46 }
47
48 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698