| 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" |
| 11 #include "extensions/common/manifest.h" | 11 #include "extensions/common/manifest.h" |
| 12 | 12 |
| 13 class Browser; | 13 class Browser; |
| 14 class UIThreadExtensionFunction; | 14 class UIThreadExtensionFunction; |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class Value; | 17 class Value; |
| 18 class DictionaryValue; | 18 class DictionaryValue; |
| 19 class ListValue; | 19 class ListValue; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace extensions { | 22 namespace extensions { |
| 23 class Extension; | 23 class Extension; |
| 24 } | 24 } |
| 25 | 25 |
| 26 // TODO(ckehoe): Accept args as scoped_ptr<base::Value>, |
| 27 // and migrate existing users to the new API. |
| 26 namespace extension_function_test_utils { | 28 namespace extension_function_test_utils { |
| 27 | 29 |
| 28 // 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 |
| 29 // or not the specified type. | 31 // or not the specified type. |
| 30 base::Value* ParseJSON(const std::string& data); | 32 base::Value* ParseJSON(const std::string& data); |
| 31 base::ListValue* ParseList(const std::string& data); | 33 base::ListValue* ParseList(const std::string& data); |
| 32 base::DictionaryValue* ParseDictionary(const std::string& data); | 34 base::DictionaryValue* ParseDictionary(const std::string& data); |
| 33 | 35 |
| 34 // 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 |
| 35 // 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 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // that |function| expects. That way, we know that we are testing something | 114 // that |function| expects. That way, we know that we are testing something |
| 113 // close to what the bindings would actually send. | 115 // close to what the bindings would actually send. |
| 114 // | 116 // |
| 115 // TODO(aa): I'm concerned that this style won't scale to all the bits and bobs | 117 // TODO(aa): I'm concerned that this style won't scale to all the bits and bobs |
| 116 // we're going to need to frob for all the different extension functions. But | 118 // we're going to need to frob for all the different extension functions. But |
| 117 // we can refactor when we see what is needed. | 119 // we can refactor when we see what is needed. |
| 118 bool RunFunction(UIThreadExtensionFunction* function, | 120 bool RunFunction(UIThreadExtensionFunction* function, |
| 119 const std::string& args, | 121 const std::string& args, |
| 120 Browser* browser, | 122 Browser* browser, |
| 121 RunFunctionFlags flags); | 123 RunFunctionFlags flags); |
| 124 bool RunFunction(UIThreadExtensionFunction* function, |
| 125 scoped_ptr<base::ListValue> args, |
| 126 Browser* browser, |
| 127 RunFunctionFlags flags); |
| 122 | 128 |
| 123 } // namespace extension_function_test_utils | 129 } // namespace extension_function_test_utils |
| 124 | 130 |
| 125 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ | 131 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ |
| OLD | NEW |