Chromium Code Reviews| Index: extensions/browser/api_test_utils.h |
| diff --git a/extensions/browser/api_test_utils.h b/extensions/browser/api_test_utils.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6424d24e9f8a1318b9e32f7eb4b9a8e138afd4fd |
| --- /dev/null |
| +++ b/extensions/browser/api_test_utils.h |
| @@ -0,0 +1,65 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef EXTENSIONS_BROWSER_API_TEST_UTILS_H_ |
| +#define EXTENSIONS_BROWSER_API_TEST_UTILS_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/memory/scoped_ptr.h" |
| + |
| +class UIThreadExtensionFunction; |
| + |
| +namespace base { |
| +class Value; |
| +} |
| + |
| +namespace content { |
| +class BrowserContext; |
| +} |
| + |
| +namespace extensions { |
| +class ExtensionFunctionDispatcher; |
| + |
| +// TODO(yoz): Remove duplicate functionality in |
| +// chrome/browser/extensions/extension_function_test_utils.h. |
|
James Cook
2014/07/16 17:15:31
Could you file a tracking bug for this?
Yoyo Zhou
2014/07/18 02:45:31
crbug.com/394840
|
| +namespace api_test_utils { |
| + |
| +enum RunFunctionFlags { NONE = 0, INCLUDE_INCOGNITO = 1 << 0 }; |
| + |
| +// Run |function| with |args| and return the result. Adds an error to the |
| +// current test if |function| returns an error. Takes ownership of |
| +// |function|. The caller takes ownership of the result. |
| +base::Value* RunFunctionAndReturnSingleResult( |
| + UIThreadExtensionFunction* function, |
| + const std::string& args, |
| + content::BrowserContext* context, |
| + scoped_ptr<ExtensionFunctionDispatcher> dispatcher); |
| +base::Value* RunFunctionAndReturnSingleResult( |
| + UIThreadExtensionFunction* function, |
| + const std::string& args, |
| + content::BrowserContext* context, |
| + scoped_ptr<ExtensionFunctionDispatcher> dispatcher, |
| + RunFunctionFlags flags); |
| + |
| +// Create and run |function| with |args|. Works with both synchronous and async |
| +// functions. Ownership of |function| remains with the caller. |
| +// |
| +// TODO(aa): It would be nice if |args| could be validated against the schema |
| +// that |function| expects. That way, we know that we are testing something |
| +// close to what the bindings would actually send. |
| +// |
| +// TODO(aa): I'm concerned that this style won't scale to all the bits and bobs |
| +// we're going to need to frob for all the different extension functions. But |
| +// we can refactor when we see what is needed. |
| +bool RunFunction(UIThreadExtensionFunction* function, |
| + const std::string& args, |
| + content::BrowserContext* context, |
| + scoped_ptr<ExtensionFunctionDispatcher> dispatcher, |
|
James Cook
2014/07/16 17:15:31
Why do these need a dispatcher explicitly passed i
Yoyo Zhou
2014/07/18 02:45:31
The old code uses a default TestFunctionDispatcher
|
| + RunFunctionFlags flags); |
| + |
| +} // namespace function_test_utils |
| +} // namespace extensions |
| + |
| +#endif // EXTENSIONS_BROWSER_API_TEST_UTILS_H_ |