| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/download/download_prefs.h" | 8 #include "chrome/browser/download/download_prefs.h" |
| 9 #include "chrome/browser/extensions/extension_install_prompt.h" | 9 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 10 #include "chrome/browser/extensions/tab_helper.h" | 10 #include "chrome/browser/extensions/tab_helper.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "net/test/embedded_test_server/embedded_test_server.h" | 30 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 31 #include "url/gurl.h" | 31 #include "url/gurl.h" |
| 32 | 32 |
| 33 using content::WebContents; | 33 using content::WebContents; |
| 34 using extensions::Extension; | 34 using extensions::Extension; |
| 35 using extensions::TabHelper; | 35 using extensions::TabHelper; |
| 36 using extensions::WebstoreInlineInstaller; | 36 using extensions::WebstoreInlineInstaller; |
| 37 using extensions::WebstoreInlineInstallerFactory; | 37 using extensions::WebstoreInlineInstallerFactory; |
| 38 using extensions::WebstoreStandaloneInstaller; | 38 using extensions::WebstoreStandaloneInstaller; |
| 39 | 39 |
| 40 using net::test_server::HttpRequest; |
| 41 |
| 40 WebstoreInstallerTest::WebstoreInstallerTest( | 42 WebstoreInstallerTest::WebstoreInstallerTest( |
| 41 const std::string& webstore_domain, | 43 const std::string& webstore_domain, |
| 42 const std::string& test_data_path, | 44 const std::string& test_data_path, |
| 43 const std::string& crx_filename, | 45 const std::string& crx_filename, |
| 44 const std::string& verified_domain, | 46 const std::string& verified_domain, |
| 45 const std::string& unverified_domain) | 47 const std::string& unverified_domain) |
| 46 : webstore_domain_(webstore_domain), | 48 : webstore_domain_(webstore_domain), |
| 47 test_data_path_(test_data_path), | 49 test_data_path_(test_data_path), |
| 48 crx_filename_(crx_filename), | 50 crx_filename_(crx_filename), |
| 49 verified_domain_(verified_domain), | 51 verified_domain_(verified_domain), |
| 50 unverified_domain_(unverified_domain) { | 52 unverified_domain_(unverified_domain) { |
| 51 } | 53 } |
| 52 | 54 |
| 53 WebstoreInstallerTest::~WebstoreInstallerTest() {} | 55 WebstoreInstallerTest::~WebstoreInstallerTest() {} |
| 54 | 56 |
| 55 void WebstoreInstallerTest::SetUpCommandLine(base::CommandLine* command_line) { | 57 void WebstoreInstallerTest::SetUpCommandLine(base::CommandLine* command_line) { |
| 56 ExtensionBrowserTest::SetUpCommandLine(command_line); | 58 ExtensionBrowserTest::SetUpCommandLine(command_line); |
| 59 |
| 60 embedded_test_server()->RegisterRequestMonitor(base::Bind( |
| 61 &WebstoreInstallerTest::ProcessServerRequest, base::Unretained(this))); |
| 57 // We start the test server now instead of in | 62 // We start the test server now instead of in |
| 58 // SetUpInProcessBrowserTestFixture so that we can get its port number. | 63 // SetUpInProcessBrowserTestFixture so that we can get its port number. |
| 59 ASSERT_TRUE(embedded_test_server()->Start()); | 64 ASSERT_TRUE(embedded_test_server()->Start()); |
| 60 | 65 |
| 61 net::HostPortPair host_port = embedded_test_server()->host_port_pair(); | 66 net::HostPortPair host_port = embedded_test_server()->host_port_pair(); |
| 62 test_gallery_url_ = | 67 test_gallery_url_ = |
| 63 base::StringPrintf("http://%s:%d/%s", webstore_domain_.c_str(), | 68 base::StringPrintf("http://%s:%d/%s", webstore_domain_.c_str(), |
| 64 host_port.port(), test_data_path_.c_str()); | 69 host_port.port(), test_data_path_.c_str()); |
| 65 command_line->AppendSwitchASCII( | 70 command_line->AppendSwitchASCII( |
| 66 switches::kAppsGalleryURL, test_gallery_url_); | 71 switches::kAppsGalleryURL, test_gallery_url_); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 } | 135 } |
| 131 | 136 |
| 132 void WebstoreInstallerTest::RunTestAsync( | 137 void WebstoreInstallerTest::RunTestAsync( |
| 133 const std::string& test_function_name) { | 138 const std::string& test_function_name) { |
| 134 std::string script = base::StringPrintf( | 139 std::string script = base::StringPrintf( |
| 135 "%s('%s')", test_function_name.c_str(), test_gallery_url_.c_str()); | 140 "%s('%s')", test_function_name.c_str(), test_gallery_url_.c_str()); |
| 136 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame()-> | 141 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame()-> |
| 137 ExecuteJavaScriptWithUserGestureForTests(base::UTF8ToUTF16(script)); | 142 ExecuteJavaScriptWithUserGestureForTests(base::UTF8ToUTF16(script)); |
| 138 } | 143 } |
| 139 | 144 |
| 145 void WebstoreInstallerTest::ProcessServerRequest(const HttpRequest& request) {} |
| 146 |
| 140 void WebstoreInstallerTest::AutoAcceptInstall() { | 147 void WebstoreInstallerTest::AutoAcceptInstall() { |
| 141 install_auto_confirm_.reset(); // Destroy any old override first. | 148 install_auto_confirm_.reset(); // Destroy any old override first. |
| 142 install_auto_confirm_.reset(new extensions::ScopedTestDialogAutoConfirm( | 149 install_auto_confirm_.reset(new extensions::ScopedTestDialogAutoConfirm( |
| 143 extensions::ScopedTestDialogAutoConfirm::ACCEPT)); | 150 extensions::ScopedTestDialogAutoConfirm::ACCEPT)); |
| 144 } | 151 } |
| 145 | 152 |
| 146 void WebstoreInstallerTest::AutoCancelInstall() { | 153 void WebstoreInstallerTest::AutoCancelInstall() { |
| 147 install_auto_confirm_.reset(); // Destroy any old override first. | 154 install_auto_confirm_.reset(); // Destroy any old override first. |
| 148 install_auto_confirm_.reset(new extensions::ScopedTestDialogAutoConfirm( | 155 install_auto_confirm_.reset(new extensions::ScopedTestDialogAutoConfirm( |
| 149 extensions::ScopedTestDialogAutoConfirm::CANCEL)); | 156 extensions::ScopedTestDialogAutoConfirm::CANCEL)); |
| 150 } | 157 } |
| OLD | NEW |