| 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 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 // Get |key| from |val| as the specified type. If |key| does not exist, or is | 32 // Get |key| from |val| as the specified type. If |key| does not exist, or is |
| 33 // not of the specified type, adds a failure to the current test and returns | 33 // not of the specified type, adds a failure to the current test and returns |
| 34 // false, 0, empty string, etc. | 34 // false, 0, empty string, etc. |
| 35 bool GetBoolean(base::DictionaryValue* val, const std::string& key); | 35 bool GetBoolean(base::DictionaryValue* val, const std::string& key); |
| 36 int GetInteger(base::DictionaryValue* val, const std::string& key); | 36 int GetInteger(base::DictionaryValue* val, const std::string& key); |
| 37 std::string GetString(base::DictionaryValue* val, const std::string& key); | 37 std::string GetString(base::DictionaryValue* val, const std::string& key); |
| 38 | 38 |
| 39 // If |val| is a dictionary, return it as one, otherwise NULL. | 39 // If |val| is a dictionary, return it as one, otherwise NULL. |
| 40 base::DictionaryValue* ToDictionary(base::Value* val); | 40 base::DictionaryValue* ToDictionary(base::Value* val); |
| 41 | 41 |
| 42 // If |val| is a list, return it as one, otherwise NULL. |
| 43 base::ListValue* ToList(base::Value* val); |
| 44 |
| 42 // Creates an extension instance that can be attached to an ExtensionFunction | 45 // Creates an extension instance that can be attached to an ExtensionFunction |
| 43 // before running it. | 46 // before running it. |
| 44 scoped_refptr<Extension> CreateEmptyExtension(); | 47 scoped_refptr<Extension> CreateEmptyExtension(); |
| 45 | 48 |
| 46 enum RunFunctionFlags { | 49 enum RunFunctionFlags { |
| 47 NONE = 0, | 50 NONE = 0, |
| 48 INCLUDE_INCOGNITO = 1 << 0 | 51 INCLUDE_INCOGNITO = 1 << 0 |
| 49 }; | 52 }; |
| 50 | 53 |
| 51 // Run |function| with |args| and return the resulting error. Adds an error to | 54 // Run |function| with |args| and return the resulting error. Adds an error to |
| (...skipping 28 matching lines...) Expand all Loading... |
| 80 // we're going to need to frob for all the different extension functions. But | 83 // we're going to need to frob for all the different extension functions. But |
| 81 // we can refactor when we see what is needed. | 84 // we can refactor when we see what is needed. |
| 82 bool RunFunction(UIThreadExtensionFunction* function, | 85 bool RunFunction(UIThreadExtensionFunction* function, |
| 83 const std::string& args, | 86 const std::string& args, |
| 84 Browser* browser, | 87 Browser* browser, |
| 85 RunFunctionFlags flags); | 88 RunFunctionFlags flags); |
| 86 | 89 |
| 87 } // namespace extension_function_test_utils | 90 } // namespace extension_function_test_utils |
| 88 | 91 |
| 89 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ | 92 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ |
| OLD | NEW |