blob: ccb8514c6abe33ca9e5af4519a0734805bfa37e6 [file] [log] [blame]
[email protected]3d6d676522013-10-14 20:44:551// 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]987858a2014-05-10 05:55:3210#include "base/files/scoped_temp_dir.h"
avia2f4804a2015-12-24 23:11:1311#include "base/macros.h"
[email protected]9c7b3092014-06-21 01:19:0312#include "chrome/browser/extensions/extension_browsertest.h"
rdevlin.cronin66209492015-06-10 20:44:0513#include "extensions/browser/extension_dialog_auto_confirm.h"
[email protected]3d6d676522013-10-14 20:44:5514#include "url/gurl.h"
15
16namespace base {
17class CommandLine;
meacer92aa1312015-02-17 22:36:1318}
19
20namespace contents {
21class WebContents;
22}
[email protected]3d6d676522013-10-14 20:44:5523
robertshield1fc1a4a2017-02-01 15:18:3324namespace net {
25namespace test_server {
26struct HttpRequest;
27}
28}
29
Devlin Cronin836f545d2018-05-09 00:25:0530class WebstoreInstallerTest : public extensions::ExtensionBrowserTest {
[email protected]3d6d676522013-10-14 20:44:5531 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);
dcheng72191812014-10-28 20:49:5637 ~WebstoreInstallerTest() override;
[email protected]3d6d676522013-10-14 20:44:5538
dchengae36a4a2014-10-21 12:36:3639 void SetUpCommandLine(base::CommandLine* command_line) override;
dchengae36a4a2014-10-21 12:36:3640 void SetUpOnMainThread() override;
[email protected]3d6d676522013-10-14 20:44:5541
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
meacer92aa1312015-02-17 22:36:1348 void RunTest(content::WebContents* web_contents,
49 const std::string& test_function_name);
50
[email protected]3d6d676522013-10-14 20:44:5551 // 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
robertshield1fc1a4a2017-02-01 15:18:3362 // 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]9c7b3092014-06-21 01:19:0366 // 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]3d6d676522013-10-14 20:44:5574 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]987858a2014-05-10 05:55:3280
dchengc963c7142016-04-08 03:55:2281 std::unique_ptr<extensions::ScopedTestDialogAutoConfirm>
82 install_auto_confirm_;
rdevlin.cronin66209492015-06-10 20:44:0583
84 DISALLOW_COPY_AND_ASSIGN(WebstoreInstallerTest);
[email protected]3d6d676522013-10-14 20:44:5585};
86
87#endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_TEST_H_