| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 const std::string& args, | 65 const std::string& args, |
| 66 Browser* browser, | 66 Browser* browser, |
| 67 RunFunctionFlags flags); | 67 RunFunctionFlags flags); |
| 68 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, | 68 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, |
| 69 const std::string& args, | 69 const std::string& args, |
| 70 Browser* browser); | 70 Browser* browser); |
| 71 | 71 |
| 72 // Run |function| with |args| and return the result. Adds an error to the | 72 // Run |function| with |args| and return the result. Adds an error to the |
| 73 // current test if |function| returns an error. The caller takes ownership of | 73 // current test if |function| returns an error. The caller takes ownership of |
| 74 // the result. | 74 // the result. |
| 75 base::Value* RunFunctionAndReturnResult(UIThreadExtensionFunction* function, | 75 base::Value* RunFunctionAndReturnSingleResult( |
| 76 const std::string& args, | 76 UIThreadExtensionFunction* function, |
| 77 Browser* browser, | 77 const std::string& args, |
| 78 RunFunctionFlags flags); | 78 Browser* browser, |
| 79 base::Value* RunFunctionAndReturnResult(UIThreadExtensionFunction* function, | 79 RunFunctionFlags flags); |
| 80 const std::string& args, | 80 base::Value* RunFunctionAndReturnSingleResult( |
| 81 Browser* browser); | 81 UIThreadExtensionFunction* function, |
| 82 const std::string& args, |
| 83 Browser* browser); |
| 82 | 84 |
| 83 // Create and run |function| with |args|. Works with both synchronous and async | 85 // Create and run |function| with |args|. Works with both synchronous and async |
| 84 // functions. | 86 // functions. |
| 85 // | 87 // |
| 86 // TODO(aa): It would be nice if |args| could be validated against the schema | 88 // TODO(aa): It would be nice if |args| could be validated against the schema |
| 87 // that |function| expects. That way, we know that we are testing something | 89 // that |function| expects. That way, we know that we are testing something |
| 88 // close to what the bindings would actually send. | 90 // close to what the bindings would actually send. |
| 89 // | 91 // |
| 90 // TODO(aa): I'm concerned that this style won't scale to all the bits and bobs | 92 // TODO(aa): I'm concerned that this style won't scale to all the bits and bobs |
| 91 // we're going to need to frob for all the different extension functions. But | 93 // we're going to need to frob for all the different extension functions. But |
| 92 // we can refactor when we see what is needed. | 94 // we can refactor when we see what is needed. |
| 93 bool RunFunction(UIThreadExtensionFunction* function, | 95 bool RunFunction(UIThreadExtensionFunction* function, |
| 94 const std::string& args, | 96 const std::string& args, |
| 95 Browser* browser, | 97 Browser* browser, |
| 96 RunFunctionFlags flags); | 98 RunFunctionFlags flags); |
| 97 | 99 |
| 98 } // namespace extension_function_test_utils | 100 } // namespace extension_function_test_utils |
| 99 | 101 |
| 100 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ | 102 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ |
| OLD | NEW |