OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_BROWSER_API_TEST_UTILS_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_TEST_UTILS_H_ |
6 #define EXTENSIONS_BROWSER_API_TEST_UTILS_H_ | 6 #define EXTENSIONS_BROWSER_API_TEST_UTILS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 base::Value* RunFunctionAndReturnSingleResult( | 52 base::Value* RunFunctionAndReturnSingleResult( |
53 UIThreadExtensionFunction* function, | 53 UIThreadExtensionFunction* function, |
54 const std::string& args, | 54 const std::string& args, |
55 content::BrowserContext* context); | 55 content::BrowserContext* context); |
56 base::Value* RunFunctionAndReturnSingleResult( | 56 base::Value* RunFunctionAndReturnSingleResult( |
57 UIThreadExtensionFunction* function, | 57 UIThreadExtensionFunction* function, |
58 const std::string& args, | 58 const std::string& args, |
59 content::BrowserContext* context, | 59 content::BrowserContext* context, |
60 RunFunctionFlags flags); | 60 RunFunctionFlags flags); |
61 | 61 |
| 62 // Run |function| with |args| and return the resulting error. Adds an error to |
| 63 // the current test if |function| returns a result. Takes ownership of |
| 64 // |function|. |
| 65 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, |
| 66 const std::string& args, |
| 67 content::BrowserContext* context, |
| 68 RunFunctionFlags flags); |
| 69 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, |
| 70 const std::string& args, |
| 71 content::BrowserContext* context); |
| 72 |
62 // Create and run |function| with |args|. Works with both synchronous and async | 73 // Create and run |function| with |args|. Works with both synchronous and async |
63 // functions. Ownership of |function| remains with the caller. | 74 // functions. Ownership of |function| remains with the caller. |
64 // | 75 // |
65 // TODO(aa): It would be nice if |args| could be validated against the schema | 76 // TODO(aa): It would be nice if |args| could be validated against the schema |
66 // that |function| expects. That way, we know that we are testing something | 77 // that |function| expects. That way, we know that we are testing something |
67 // close to what the bindings would actually send. | 78 // close to what the bindings would actually send. |
68 // | 79 // |
69 // TODO(aa): I'm concerned that this style won't scale to all the bits and bobs | 80 // TODO(aa): I'm concerned that this style won't scale to all the bits and bobs |
70 // we're going to need to frob for all the different extension functions. But | 81 // we're going to need to frob for all the different extension functions. But |
71 // we can refactor when we see what is needed. | 82 // we can refactor when we see what is needed. |
72 bool RunFunction(UIThreadExtensionFunction* function, | 83 bool RunFunction(UIThreadExtensionFunction* function, |
73 const std::string& args, | 84 const std::string& args, |
74 content::BrowserContext* context, | 85 content::BrowserContext* context, |
75 scoped_ptr<ExtensionFunctionDispatcher> dispatcher, | 86 scoped_ptr<ExtensionFunctionDispatcher> dispatcher, |
76 RunFunctionFlags flags); | 87 RunFunctionFlags flags); |
77 bool RunFunction(UIThreadExtensionFunction* function, | 88 bool RunFunction(UIThreadExtensionFunction* function, |
78 scoped_ptr<base::ListValue> args, | 89 scoped_ptr<base::ListValue> args, |
79 content::BrowserContext* context, | 90 content::BrowserContext* context, |
80 scoped_ptr<ExtensionFunctionDispatcher> dispatcher, | 91 scoped_ptr<ExtensionFunctionDispatcher> dispatcher, |
81 RunFunctionFlags flags); | 92 RunFunctionFlags flags); |
82 | 93 |
83 } // namespace function_test_utils | 94 } // namespace function_test_utils |
84 } // namespace extensions | 95 } // namespace extensions |
85 | 96 |
86 #endif // EXTENSIONS_BROWSER_API_TEST_UTILS_H_ | 97 #endif // EXTENSIONS_BROWSER_API_TEST_UTILS_H_ |
OLD | NEW |