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/ref_counted.h" | |
Yoyo Zhou
2014/08/08 20:12:07
These new headers don't seem necessary.
Daniel Nishi
2014/08/08 20:30:26
Whoops. You are correct.
| |
10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "extensions/common/extension.h" | |
11 | 13 |
12 class UIThreadExtensionFunction; | 14 class UIThreadExtensionFunction; |
13 | 15 |
14 namespace base { | 16 namespace base { |
15 class Value; | 17 class Value; |
16 } | 18 } |
17 | 19 |
18 namespace content { | 20 namespace content { |
19 class BrowserContext; | 21 class BrowserContext; |
20 } | 22 } |
21 | 23 |
22 namespace extensions { | 24 namespace extensions { |
23 class ExtensionFunctionDispatcher; | 25 class ExtensionFunctionDispatcher; |
24 | 26 |
25 // TODO(yoz): crbug.com/394840: Remove duplicate functionality in | 27 // TODO(yoz): crbug.com/394840: Remove duplicate functionality in |
26 // chrome/browser/extensions/extension_function_test_utils.h. | 28 // chrome/browser/extensions/extension_function_test_utils.h. |
27 namespace api_test_utils { | 29 namespace api_test_utils { |
28 | 30 |
29 enum RunFunctionFlags { NONE = 0, INCLUDE_INCOGNITO = 1 << 0 }; | 31 enum RunFunctionFlags { NONE = 0, INCLUDE_INCOGNITO = 1 << 0 }; |
30 | 32 |
31 // Run |function| with |args| and return the result. Adds an error to the | 33 // Run |function| with |args| and return the result. Adds an error to the |
32 // current test if |function| returns an error. Takes ownership of | 34 // current test if |function| returns an error. Takes ownership of |
33 // |function|. The caller takes ownership of the result. | 35 // |function|. The caller takes ownership of the result. |
34 base::Value* RunFunctionAndReturnSingleResult( | 36 base::Value* RunFunctionWithDelegateAndReturnSingleResult( |
35 UIThreadExtensionFunction* function, | 37 UIThreadExtensionFunction* function, |
36 const std::string& args, | 38 const std::string& args, |
37 content::BrowserContext* context, | 39 content::BrowserContext* context, |
38 scoped_ptr<ExtensionFunctionDispatcher> dispatcher); | 40 scoped_ptr<ExtensionFunctionDispatcher> dispatcher); |
39 base::Value* RunFunctionAndReturnSingleResult( | 41 base::Value* RunFunctionWithDelegateAndReturnSingleResult( |
40 UIThreadExtensionFunction* function, | 42 UIThreadExtensionFunction* function, |
41 const std::string& args, | 43 const std::string& args, |
42 content::BrowserContext* context, | 44 content::BrowserContext* context, |
43 scoped_ptr<ExtensionFunctionDispatcher> dispatcher, | 45 scoped_ptr<ExtensionFunctionDispatcher> dispatcher, |
44 RunFunctionFlags flags); | 46 RunFunctionFlags flags); |
45 | 47 |
48 // RunFunctionAndReturnSingleResult, except with a NULL implementation of the | |
Yoyo Zhou
2014/08/08 20:12:07
This comment needs rewriting.
Daniel Nishi
2014/08/08 20:30:26
Done.
| |
49 // Delegate. | |
50 base::Value* RunFunctionAndReturnSingleResult( | |
51 UIThreadExtensionFunction* function, | |
52 const std::string& args, | |
53 content::BrowserContext* context); | |
54 base::Value* RunFunctionAndReturnSingleResult( | |
55 UIThreadExtensionFunction* function, | |
56 const std::string& args, | |
57 content::BrowserContext* context, | |
58 RunFunctionFlags flags); | |
59 | |
46 // Create and run |function| with |args|. Works with both synchronous and async | 60 // Create and run |function| with |args|. Works with both synchronous and async |
47 // functions. Ownership of |function| remains with the caller. | 61 // functions. Ownership of |function| remains with the caller. |
48 // | 62 // |
49 // TODO(aa): It would be nice if |args| could be validated against the schema | 63 // TODO(aa): It would be nice if |args| could be validated against the schema |
50 // that |function| expects. That way, we know that we are testing something | 64 // that |function| expects. That way, we know that we are testing something |
51 // close to what the bindings would actually send. | 65 // close to what the bindings would actually send. |
52 // | 66 // |
53 // TODO(aa): I'm concerned that this style won't scale to all the bits and bobs | 67 // TODO(aa): I'm concerned that this style won't scale to all the bits and bobs |
54 // we're going to need to frob for all the different extension functions. But | 68 // we're going to need to frob for all the different extension functions. But |
55 // we can refactor when we see what is needed. | 69 // we can refactor when we see what is needed. |
56 bool RunFunction(UIThreadExtensionFunction* function, | 70 bool RunFunction(UIThreadExtensionFunction* function, |
57 const std::string& args, | 71 const std::string& args, |
58 content::BrowserContext* context, | 72 content::BrowserContext* context, |
59 scoped_ptr<ExtensionFunctionDispatcher> dispatcher, | 73 scoped_ptr<ExtensionFunctionDispatcher> dispatcher, |
60 RunFunctionFlags flags); | 74 RunFunctionFlags flags); |
61 | 75 |
62 } // namespace function_test_utils | 76 } // namespace function_test_utils |
63 } // namespace extensions | 77 } // namespace extensions |
64 | 78 |
65 #endif // EXTENSIONS_BROWSER_API_TEST_UTILS_H_ | 79 #endif // EXTENSIONS_BROWSER_API_TEST_UTILS_H_ |
OLD | NEW |