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

Side by Side Diff: chrome/browser/extensions/extension_function_test_utils.h

Issue 10375021: Move Extension into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Take 6 Created 8 years, 7 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "chrome/common/extensions/extension.h" 12 #include "chrome/common/extensions/extension.h"
13 13
14 class AsyncExtensionFunction; 14 class AsyncExtensionFunction;
15 class Browser; 15 class Browser;
16 class Extension;
17 class UIThreadExtensionFunction; 16 class UIThreadExtensionFunction;
18 17
19 namespace base { 18 namespace base {
20 class Value; 19 class Value;
21 class DictionaryValue; 20 class DictionaryValue;
22 class ListValue; 21 class ListValue;
23 } 22 }
24 23
24 namespace extensions {
25 class Extension;
26 }
27
25 namespace extension_function_test_utils { 28 namespace extension_function_test_utils {
26 29
27 // Parse JSON and return as the specified type, or NULL if the JSON is invalid 30 // Parse JSON and return as the specified type, or NULL if the JSON is invalid
28 // or not the specified type. 31 // or not the specified type.
29 base::Value* ParseJSON(const std::string& data); 32 base::Value* ParseJSON(const std::string& data);
30 base::ListValue* ParseList(const std::string& data); 33 base::ListValue* ParseList(const std::string& data);
31 base::DictionaryValue* ParseDictionary(const std::string& data); 34 base::DictionaryValue* ParseDictionary(const std::string& data);
32 35
33 // Get |key| from |val| as the specified type. If |key| does not exist, or is 36 // Get |key| from |val| as the specified type. If |key| does not exist, or is
34 // not of the specified type, adds a failure to the current test and returns 37 // not of the specified type, adds a failure to the current test and returns
35 // false, 0, empty string, etc. 38 // false, 0, empty string, etc.
36 bool GetBoolean(base::DictionaryValue* val, const std::string& key); 39 bool GetBoolean(base::DictionaryValue* val, const std::string& key);
37 int GetInteger(base::DictionaryValue* val, const std::string& key); 40 int GetInteger(base::DictionaryValue* val, const std::string& key);
38 std::string GetString(base::DictionaryValue* val, const std::string& key); 41 std::string GetString(base::DictionaryValue* val, const std::string& key);
39 42
40 // If |val| is a dictionary, return it as one, otherwise NULL. 43 // If |val| is a dictionary, return it as one, otherwise NULL.
41 base::DictionaryValue* ToDictionary(base::Value* val); 44 base::DictionaryValue* ToDictionary(base::Value* val);
42 45
43 // If |val| is a list, return it as one, otherwise NULL. 46 // If |val| is a list, return it as one, otherwise NULL.
44 base::ListValue* ToList(base::Value* val); 47 base::ListValue* ToList(base::Value* val);
45 48
46 // Creates an extension instance that can be attached to an ExtensionFunction 49 // Creates an extension instance that can be attached to an ExtensionFunction
47 // before running it. 50 // before running it.
48 scoped_refptr<Extension> CreateEmptyExtension(); 51 scoped_refptr<extensions::Extension> CreateEmptyExtension();
49 52
50 // Creates an extension instance with a specified location that can be attached 53 // Creates an extension instance with a specified location that can be attached
51 // to an ExtensionFunction before running. 54 // to an ExtensionFunction before running.
52 scoped_refptr<Extension> CreateEmptyExtensionWithLocation( 55 scoped_refptr<extensions::Extension> CreateEmptyExtensionWithLocation(
53 Extension::Location location); 56 extensions::Extension::Location location);
54 57
55 enum RunFunctionFlags { 58 enum RunFunctionFlags {
56 NONE = 0, 59 NONE = 0,
57 INCLUDE_INCOGNITO = 1 << 0 60 INCLUDE_INCOGNITO = 1 << 0
58 }; 61 };
59 62
60 // Run |function| with |args| and return the resulting error. Adds an error to 63 // Run |function| with |args| and return the resulting error. Adds an error to
61 // the current test if |function| returns a result. 64 // the current test if |function| returns a result.
62 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, 65 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function,
63 const std::string& args, 66 const std::string& args,
(...skipping 25 matching lines...) Expand all
89 // we're going to need to frob for all the different extension functions. But 92 // we're going to need to frob for all the different extension functions. But
90 // we can refactor when we see what is needed. 93 // we can refactor when we see what is needed.
91 bool RunFunction(UIThreadExtensionFunction* function, 94 bool RunFunction(UIThreadExtensionFunction* function,
92 const std::string& args, 95 const std::string& args,
93 Browser* browser, 96 Browser* browser,
94 RunFunctionFlags flags); 97 RunFunctionFlags flags);
95 98
96 } // namespace extension_function_test_utils 99 } // namespace extension_function_test_utils
97 100
98 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ 101 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_function_dispatcher.cc ('k') | chrome/browser/extensions/extension_function_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698