Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / extensions / renderer / utils_unittest.cc
blob06e20f66c7ce0cd7f953e272c02820448529d43e
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
3 // found in the LICENSE file.
5 #include "base/strings/stringprintf.h"
6 #include "extensions/renderer/module_system_test.h"
7 #include "gin/dictionary.h"
8 #include "grit/extensions_renderer_resources.h"
10 namespace extensions {
11 namespace {
13 class UtilsUnittest : public ModuleSystemTest {
14 private:
15 void SetUp() override {
16 ModuleSystemTest::SetUp();
18 env()->RegisterModule("utils", IDR_UTILS_JS);
19 env()->RegisterTestFile("utils_unittest", "utils_unittest.js");
20 env()->OverrideNativeHandler("schema_registry",
21 "exports.GetSchema = function() {};");
22 env()->OverrideNativeHandler("logging",
23 "exports.CHECK = function() {};\n"
24 "exports.DCHECK = function() {};\n"
25 "exports.WARNING = function() {};");
26 env()->OverrideNativeHandler("v8_context", "");
27 gin::Dictionary chrome(env()->isolate(), env()->CreateGlobal("chrome"));
28 gin::Dictionary chrome_runtime(
29 gin::Dictionary::CreateEmpty(env()->isolate()));
30 chrome.Set("runtime", chrome_runtime);
34 TEST_F(UtilsUnittest, TestNothing) {
35 ExpectNoAssertionsMade();
38 TEST_F(UtilsUnittest, SuperClass) {
39 ModuleSystem::NativesEnabledScope natives_enabled_scope(
40 env()->module_system());
41 env()->module_system()->CallModuleMethod("utils_unittest", "testSuperClass");
44 TEST_F(UtilsUnittest, PromiseNoResult) {
45 ModuleSystem::NativesEnabledScope natives_enabled_scope(
46 env()->module_system());
47 env()->module_system()->CallModuleMethod("utils_unittest",
48 "testPromiseNoResult");
49 RunResolvedPromises();
52 TEST_F(UtilsUnittest, PromiseOneResult) {
53 ModuleSystem::NativesEnabledScope natives_enabled_scope(
54 env()->module_system());
55 env()->module_system()->CallModuleMethod("utils_unittest",
56 "testPromiseOneResult");
57 RunResolvedPromises();
60 TEST_F(UtilsUnittest, PromiseTwoResults) {
61 ModuleSystem::NativesEnabledScope natives_enabled_scope(
62 env()->module_system());
63 env()->module_system()->CallModuleMethod("utils_unittest",
64 "testPromiseTwoResults");
65 RunResolvedPromises();
68 TEST_F(UtilsUnittest, PromiseError) {
69 ModuleSystem::NativesEnabledScope natives_enabled_scope(
70 env()->module_system());
71 env()->module_system()->CallModuleMethod("utils_unittest",
72 "testPromiseError");
73 RunResolvedPromises();
76 } // namespace
77 } // namespace extensions