[email protected] | 3d6d67652 | 2013-10-14 20:44:55 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_TEST_H_ |
| 6 | #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_TEST_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
[email protected] | 987858a | 2014-05-10 05:55:32 | [diff] [blame] | 10 | #include "base/files/scoped_temp_dir.h" |
avi | a2f4804a | 2015-12-24 23:11:13 | [diff] [blame] | 11 | #include "base/macros.h" |
[email protected] | 9c7b309 | 2014-06-21 01:19:03 | [diff] [blame] | 12 | #include "chrome/browser/extensions/extension_browsertest.h" |
rdevlin.cronin | 6620949 | 2015-06-10 20:44:05 | [diff] [blame] | 13 | #include "extensions/browser/extension_dialog_auto_confirm.h" |
[email protected] | 3d6d67652 | 2013-10-14 20:44:55 | [diff] [blame] | 14 | #include "url/gurl.h" |
| 15 | |
| 16 | namespace base { |
| 17 | class CommandLine; |
meacer | 92aa131 | 2015-02-17 22:36:13 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | namespace contents { |
| 21 | class WebContents; |
| 22 | } |
[email protected] | 3d6d67652 | 2013-10-14 20:44:55 | [diff] [blame] | 23 | |
robertshield | 1fc1a4a | 2017-02-01 15:18:33 | [diff] [blame] | 24 | namespace net { |
| 25 | namespace test_server { |
| 26 | struct HttpRequest; |
| 27 | } |
| 28 | } |
| 29 | |
Devlin Cronin | 836f545d | 2018-05-09 00:25:05 | [diff] [blame] | 30 | class WebstoreInstallerTest : public extensions::ExtensionBrowserTest { |
[email protected] | 3d6d67652 | 2013-10-14 20:44:55 | [diff] [blame] | 31 | public: |
| 32 | WebstoreInstallerTest(const std::string& webstore_domain, |
| 33 | const std::string& test_data_path, |
| 34 | const std::string& crx_filename, |
| 35 | const std::string& verified_domain, |
| 36 | const std::string& unverified_domain); |
dcheng | 7219181 | 2014-10-28 20:49:56 | [diff] [blame] | 37 | ~WebstoreInstallerTest() override; |
[email protected] | 3d6d67652 | 2013-10-14 20:44:55 | [diff] [blame] | 38 | |
dcheng | ae36a4a | 2014-10-21 12:36:36 | [diff] [blame] | 39 | void SetUpCommandLine(base::CommandLine* command_line) override; |
dcheng | ae36a4a | 2014-10-21 12:36:36 | [diff] [blame] | 40 | void SetUpOnMainThread() override; |
[email protected] | 3d6d67652 | 2013-10-14 20:44:55 | [diff] [blame] | 41 | |
| 42 | protected: |
| 43 | GURL GenerateTestServerUrl(const std::string& domain, |
| 44 | const std::string& page_filename); |
| 45 | |
| 46 | void RunTest(const std::string& test_function_name); |
| 47 | |
meacer | 92aa131 | 2015-02-17 22:36:13 | [diff] [blame] | 48 | void RunTest(content::WebContents* web_contents, |
| 49 | const std::string& test_function_name); |
| 50 | |
[email protected] | 3d6d67652 | 2013-10-14 20:44:55 | [diff] [blame] | 51 | // Passes |i| to |test_function_name|, and expects that function to |
| 52 | // return one of "FAILED", "KEEPGOING" or "DONE". KEEPGOING should be |
| 53 | // returned if more tests remain to be run and the current test succeeded, |
| 54 | // FAILED is returned when a test fails, and DONE is returned by the last |
| 55 | // test if it succeeds. |
| 56 | // This methods returns true iff there are more tests that need to be run. |
| 57 | bool RunIndexedTest(const std::string& test_function_name, int i); |
| 58 | |
| 59 | // Runs a test without waiting for any results from the renderer. |
| 60 | void RunTestAsync(const std::string& test_function_name); |
| 61 | |
robertshield | 1fc1a4a | 2017-02-01 15:18:33 | [diff] [blame] | 62 | // Can be overridden to inspect requests to the embedded test server. |
| 63 | virtual void ProcessServerRequest( |
| 64 | const net::test_server::HttpRequest& request); |
| 65 | |
[email protected] | 9c7b309 | 2014-06-21 01:19:03 | [diff] [blame] | 66 | // Configures command line switches to simulate a user accepting the install |
| 67 | // prompt. |
| 68 | void AutoAcceptInstall(); |
| 69 | |
| 70 | // Configures command line switches to simulate a user cancelling the install |
| 71 | // prompt. |
| 72 | void AutoCancelInstall(); |
| 73 | |
[email protected] | 3d6d67652 | 2013-10-14 20:44:55 | [diff] [blame] | 74 | std::string webstore_domain_; |
| 75 | std::string test_data_path_; |
| 76 | std::string crx_filename_; |
| 77 | std::string verified_domain_; |
| 78 | std::string unverified_domain_; |
| 79 | std::string test_gallery_url_; |
[email protected] | 987858a | 2014-05-10 05:55:32 | [diff] [blame] | 80 | |
dcheng | c963c714 | 2016-04-08 03:55:22 | [diff] [blame] | 81 | std::unique_ptr<extensions::ScopedTestDialogAutoConfirm> |
| 82 | install_auto_confirm_; |
rdevlin.cronin | 6620949 | 2015-06-10 20:44:05 | [diff] [blame] | 83 | |
| 84 | DISALLOW_COPY_AND_ASSIGN(WebstoreInstallerTest); |
[email protected] | 3d6d67652 | 2013-10-14 20:44:55 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_TEST_H_ |