| 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 CHROME_BROWSER_EXTENSIONS_EXTENSION_API_UNITTEST_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_API_UNITTEST_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_API_UNITTEST_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_API_UNITTEST_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 17 matching lines...) Expand all Loading... |
| 28 // Use this class to enable calling API functions in a unittest. | 28 // Use this class to enable calling API functions in a unittest. |
| 29 // By default, this class will create and load an empty unpacked |extension_|, | 29 // By default, this class will create and load an empty unpacked |extension_|, |
| 30 // which will be used in all API function calls. This extension can be | 30 // which will be used in all API function calls. This extension can be |
| 31 // overridden using set_extension(). | 31 // overridden using set_extension(). |
| 32 // By default, this class does not create a WebContents for the API functions. | 32 // By default, this class does not create a WebContents for the API functions. |
| 33 // If a WebContents is needed, calling CreateBackgroundPage() will create a | 33 // If a WebContents is needed, calling CreateBackgroundPage() will create a |
| 34 // background page for the extension and use it in API function calls. (If | 34 // background page for the extension and use it in API function calls. (If |
| 35 // needed, this could be expanded to allow for alternate WebContents). | 35 // needed, this could be expanded to allow for alternate WebContents). |
| 36 // When calling RunFunction[AndReturn*], |args| should be in JSON format, | 36 // When calling RunFunction[AndReturn*], |args| should be in JSON format, |
| 37 // wrapped in a list. See also RunFunction* in extension_function_test_utils.h. | 37 // wrapped in a list. See also RunFunction* in extension_function_test_utils.h. |
| 38 // TODO(yoz): Move users of this base class to use the equivalent base class |
| 39 // in extensions/browser/api_unittest.h. |
| 38 class ExtensionApiUnittest : public BrowserWithTestWindowTest { | 40 class ExtensionApiUnittest : public BrowserWithTestWindowTest { |
| 39 public: | 41 public: |
| 40 ExtensionApiUnittest(); | 42 ExtensionApiUnittest(); |
| 41 virtual ~ExtensionApiUnittest(); | 43 virtual ~ExtensionApiUnittest(); |
| 42 | 44 |
| 43 content::WebContents* contents() { return contents_; } | 45 content::WebContents* contents() { return contents_; } |
| 44 | 46 |
| 45 const Extension* extension() const { return extension_.get(); } | 47 const Extension* extension() const { return extension_.get(); } |
| 46 scoped_refptr<Extension> extension_ref() { return extension_; } | 48 scoped_refptr<Extension> extension_ref() { return extension_; } |
| 47 void set_extension(scoped_refptr<Extension> extension) { | 49 void set_extension(scoped_refptr<Extension> extension) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // or NULL. | 91 // or NULL. |
| 90 content::WebContents* contents_; | 92 content::WebContents* contents_; |
| 91 | 93 |
| 92 // The Extension used when running API function calls. | 94 // The Extension used when running API function calls. |
| 93 scoped_refptr<Extension> extension_; | 95 scoped_refptr<Extension> extension_; |
| 94 }; | 96 }; |
| 95 | 97 |
| 96 } // namespace extensions | 98 } // namespace extensions |
| 97 | 99 |
| 98 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_API_UNITTEST_H_ | 100 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_API_UNITTEST_H_ |
| OLD | NEW |