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