OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 13 |
13 class AsyncExtensionFunction; | 14 class AsyncExtensionFunction; |
14 class Browser; | 15 class Browser; |
15 class Extension; | 16 class Extension; |
16 class UIThreadExtensionFunction; | 17 class UIThreadExtensionFunction; |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 class Value; | 20 class Value; |
20 class DictionaryValue; | 21 class DictionaryValue; |
21 class ListValue; | 22 class ListValue; |
(...skipping 17 matching lines...) Expand all Loading... |
39 // If |val| is a dictionary, return it as one, otherwise NULL. | 40 // If |val| is a dictionary, return it as one, otherwise NULL. |
40 base::DictionaryValue* ToDictionary(base::Value* val); | 41 base::DictionaryValue* ToDictionary(base::Value* val); |
41 | 42 |
42 // If |val| is a list, return it as one, otherwise NULL. | 43 // If |val| is a list, return it as one, otherwise NULL. |
43 base::ListValue* ToList(base::Value* val); | 44 base::ListValue* ToList(base::Value* val); |
44 | 45 |
45 // Creates an extension instance that can be attached to an ExtensionFunction | 46 // Creates an extension instance that can be attached to an ExtensionFunction |
46 // before running it. | 47 // before running it. |
47 scoped_refptr<Extension> CreateEmptyExtension(); | 48 scoped_refptr<Extension> CreateEmptyExtension(); |
48 | 49 |
| 50 // Creates an extension instance with a specified location that can be attached |
| 51 // to an ExtensionFunction before running. |
| 52 scoped_refptr<Extension> CreateEmptyExtensionWithLocation( |
| 53 Extension::Location location); |
| 54 |
49 enum RunFunctionFlags { | 55 enum RunFunctionFlags { |
50 NONE = 0, | 56 NONE = 0, |
51 INCLUDE_INCOGNITO = 1 << 0 | 57 INCLUDE_INCOGNITO = 1 << 0 |
52 }; | 58 }; |
53 | 59 |
54 // Run |function| with |args| and return the resulting error. Adds an error to | 60 // Run |function| with |args| and return the resulting error. Adds an error to |
55 // the current test if |function| returns a result. | 61 // the current test if |function| returns a result. |
56 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, | 62 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, |
57 const std::string& args, | 63 const std::string& args, |
58 Browser* browser, | 64 Browser* browser, |
(...skipping 24 matching lines...) Expand all Loading... |
83 // we're going to need to frob for all the different extension functions. But | 89 // we're going to need to frob for all the different extension functions. But |
84 // we can refactor when we see what is needed. | 90 // we can refactor when we see what is needed. |
85 bool RunFunction(UIThreadExtensionFunction* function, | 91 bool RunFunction(UIThreadExtensionFunction* function, |
86 const std::string& args, | 92 const std::string& args, |
87 Browser* browser, | 93 Browser* browser, |
88 RunFunctionFlags flags); | 94 RunFunctionFlags flags); |
89 | 95 |
90 } // namespace extension_function_test_utils | 96 } // namespace extension_function_test_utils |
91 | 97 |
92 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ | 98 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ |
OLD | NEW |