Remove keyboard_ui.css and manifest_keyboard.json
[chromium-blink-merge.git] / chrome / browser / extensions / extension_api_unittest.cc
blob814a98473c8a922a5e24096aeaad122e52fa3568
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 "chrome/browser/extensions/extension_api_unittest.h"
7 #include "base/values.h"
8 #include "chrome/browser/extensions/extension_function_test_utils.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "extensions/browser/api_test_utils.h"
11 #include "extensions/browser/extension_function.h"
12 #include "extensions/common/extension.h"
13 #include "extensions/common/manifest.h"
14 #include "extensions/common/manifest_handlers/background_info.h"
16 namespace utils = extension_function_test_utils;
18 namespace extensions {
20 ExtensionApiUnittest::ExtensionApiUnittest() {
23 ExtensionApiUnittest::~ExtensionApiUnittest() {
26 void ExtensionApiUnittest::SetUp() {
27 BrowserWithTestWindowTest::SetUp();
28 extension_ = api_test_utils::CreateEmptyExtensionWithLocation(
29 Manifest::UNPACKED);
32 scoped_ptr<base::Value> ExtensionApiUnittest::RunFunctionAndReturnValue(
33 UIThreadExtensionFunction* function, const std::string& args) {
34 function->set_extension(extension());
35 return scoped_ptr<base::Value>(
36 utils::RunFunctionAndReturnSingleResult(function, args, browser()));
39 scoped_ptr<base::DictionaryValue>
40 ExtensionApiUnittest::RunFunctionAndReturnDictionary(
41 UIThreadExtensionFunction* function, const std::string& args) {
42 base::Value* value = RunFunctionAndReturnValue(function, args).release();
43 base::DictionaryValue* dict = NULL;
45 if (value && !value->GetAsDictionary(&dict))
46 delete value;
48 // We expect to either have successfuly retrieved a dictionary from the value,
49 // or the value to have been NULL.
50 EXPECT_TRUE(dict || !value);
51 return scoped_ptr<base::DictionaryValue>(dict);
54 scoped_ptr<base::ListValue> ExtensionApiUnittest::RunFunctionAndReturnList(
55 UIThreadExtensionFunction* function, const std::string& args) {
56 base::Value* value = RunFunctionAndReturnValue(function, args).release();
57 base::ListValue* list = NULL;
59 if (value && !value->GetAsList(&list))
60 delete value;
62 // We expect to either have successfuly retrieved a list from the value,
63 // or the value to have been NULL.
64 EXPECT_TRUE(list);
65 return scoped_ptr<base::ListValue>(list);
68 std::string ExtensionApiUnittest::RunFunctionAndReturnError(
69 UIThreadExtensionFunction* function, const std::string& args) {
70 function->set_extension(extension());
71 return utils::RunFunctionAndReturnError(function, args, browser());
74 void ExtensionApiUnittest::RunFunction(
75 UIThreadExtensionFunction* function, const std::string& args) {
76 RunFunctionAndReturnValue(function, args);
79 } // namespace extensions