| OLD | NEW |
| 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 bool GetBoolean(base::DictionaryValue* val, const std::string& key); | 41 bool GetBoolean(base::DictionaryValue* val, const std::string& key); |
| 42 int GetInteger(base::DictionaryValue* val, const std::string& key); | 42 int GetInteger(base::DictionaryValue* val, const std::string& key); |
| 43 std::string GetString(base::DictionaryValue* val, const std::string& key); | 43 std::string GetString(base::DictionaryValue* val, const std::string& key); |
| 44 | 44 |
| 45 // If |val| is a dictionary, return it as one, otherwise NULL. | 45 // If |val| is a dictionary, return it as one, otherwise NULL. |
| 46 base::DictionaryValue* ToDictionary(base::Value* val); | 46 base::DictionaryValue* ToDictionary(base::Value* val); |
| 47 | 47 |
| 48 // If |val| is a list, return it as one, otherwise NULL. | 48 // If |val| is a list, return it as one, otherwise NULL. |
| 49 base::ListValue* ToList(base::Value* val); | 49 base::ListValue* ToList(base::Value* val); |
| 50 | 50 |
| 51 // Creates an extension instance that can be attached to an ExtensionFunction | |
| 52 // before running it. | |
| 53 scoped_refptr<extensions::Extension> CreateEmptyExtension(); | |
| 54 | |
| 55 // Creates an extension instance with a specified location that can be attached | 51 // Creates an extension instance with a specified location that can be attached |
| 56 // to an ExtensionFunction before running. | 52 // to an ExtensionFunction before running. |
| 57 scoped_refptr<extensions::Extension> CreateEmptyExtensionWithLocation( | 53 scoped_refptr<extensions::Extension> CreateEmptyExtensionWithLocation( |
| 58 extensions::Manifest::Location location); | 54 extensions::Manifest::Location location); |
| 59 | 55 |
| 60 // Creates an empty extension with a variable ID, for tests that require | |
| 61 // multiple extensions side-by-side having distinct IDs. If not empty, then | |
| 62 // id_input is passed directly to Extension::CreateId() and thus has the same | |
| 63 // behavior as that method. If id_input is empty, then Extension::Create() | |
| 64 // receives an empty explicit ID and generates an appropriate ID for a blank | |
| 65 // extension. | |
| 66 scoped_refptr<extensions::Extension> CreateEmptyExtension( | |
| 67 const std::string& id_input); | |
| 68 | |
| 69 scoped_refptr<extensions::Extension> CreateExtension( | 56 scoped_refptr<extensions::Extension> CreateExtension( |
| 70 extensions::Manifest::Location location, | 57 extensions::Manifest::Location location, |
| 71 base::DictionaryValue* test_extension_value, | 58 base::DictionaryValue* test_extension_value, |
| 72 const std::string& id_input); | 59 const std::string& id_input); |
| 73 | 60 |
| 74 // Creates an extension instance with a specified extension value that can be | 61 // Creates an extension instance with a specified extension value that can be |
| 75 // attached to an ExtensionFunction before running. | 62 // attached to an ExtensionFunction before running. |
| 76 scoped_refptr<extensions::Extension> CreateExtension( | 63 scoped_refptr<extensions::Extension> CreateExtension( |
| 77 base::DictionaryValue* test_extension_value); | 64 base::DictionaryValue* test_extension_value); |
| 78 | 65 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 Browser* browser, | 111 Browser* browser, |
| 125 RunFunctionFlags flags); | 112 RunFunctionFlags flags); |
| 126 bool RunFunction(UIThreadExtensionFunction* function, | 113 bool RunFunction(UIThreadExtensionFunction* function, |
| 127 scoped_ptr<base::ListValue> args, | 114 scoped_ptr<base::ListValue> args, |
| 128 Browser* browser, | 115 Browser* browser, |
| 129 RunFunctionFlags flags); | 116 RunFunctionFlags flags); |
| 130 | 117 |
| 131 } // namespace extension_function_test_utils | 118 } // namespace extension_function_test_utils |
| 132 | 119 |
| 133 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ | 120 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ |
| OLD | NEW |