Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: chrome/browser/extensions/webstore_installer_test.cc

Issue 1378123003: Adding SSL ETS Tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ets
Patch Set: Rebase. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 verified_domain_(verified_domain), 48 verified_domain_(verified_domain),
49 unverified_domain_(unverified_domain) { 49 unverified_domain_(unverified_domain) {
50 } 50 }
51 51
52 WebstoreInstallerTest::~WebstoreInstallerTest() {} 52 WebstoreInstallerTest::~WebstoreInstallerTest() {}
53 53
54 void WebstoreInstallerTest::SetUpCommandLine(base::CommandLine* command_line) { 54 void WebstoreInstallerTest::SetUpCommandLine(base::CommandLine* command_line) {
55 ExtensionBrowserTest::SetUpCommandLine(command_line); 55 ExtensionBrowserTest::SetUpCommandLine(command_line);
56 // We start the test server now instead of in 56 // We start the test server now instead of in
57 // SetUpInProcessBrowserTestFixture so that we can get its port number. 57 // SetUpInProcessBrowserTestFixture so that we can get its port number.
58 ASSERT_TRUE(test_server()->Start()); 58 ASSERT_TRUE(embedded_test_server()->Start());
59 59
60 net::HostPortPair host_port = test_server()->host_port_pair(); 60 net::HostPortPair host_port = embedded_test_server()->host_port_pair();
61 test_gallery_url_ = base::StringPrintf( 61 test_gallery_url_ =
62 "http://%s:%d/files/%s", 62 base::StringPrintf("http://%s:%d/%s", webstore_domain_.c_str(),
63 webstore_domain_.c_str(), host_port.port(), test_data_path_.c_str()); 63 host_port.port(), test_data_path_.c_str());
64 command_line->AppendSwitchASCII( 64 command_line->AppendSwitchASCII(
65 switches::kAppsGalleryURL, test_gallery_url_); 65 switches::kAppsGalleryURL, test_gallery_url_);
66 66
67 GURL crx_url = GenerateTestServerUrl(webstore_domain_, crx_filename_); 67 GURL crx_url = GenerateTestServerUrl(webstore_domain_, crx_filename_);
68 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 68 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
69 switches::kAppsGalleryUpdateURL, crx_url.spec()); 69 switches::kAppsGalleryUpdateURL, crx_url.spec());
70 70
71 // Allow tests to call window.gc(), so that we can check that callback 71 // Allow tests to call window.gc(), so that we can check that callback
72 // functions don't get collected prematurely. 72 // functions don't get collected prematurely.
73 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); 73 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc");
74 } 74 }
75 75
76 void WebstoreInstallerTest::SetUpInProcessBrowserTestFixture() { 76 void WebstoreInstallerTest::SetUpInProcessBrowserTestFixture() {
77 host_resolver()->AddRule(webstore_domain_, "127.0.0.1"); 77 host_resolver()->AddRule(webstore_domain_, "127.0.0.1");
78 host_resolver()->AddRule(verified_domain_, "127.0.0.1"); 78 host_resolver()->AddRule(verified_domain_, "127.0.0.1");
79 host_resolver()->AddRule(unverified_domain_, "127.0.0.1"); 79 host_resolver()->AddRule(unverified_domain_, "127.0.0.1");
80 } 80 }
81 81
82 void WebstoreInstallerTest::SetUpOnMainThread() { 82 void WebstoreInstallerTest::SetUpOnMainThread() {
83 ExtensionBrowserTest::SetUpOnMainThread(); 83 ExtensionBrowserTest::SetUpOnMainThread();
84 ASSERT_TRUE(download_directory_.CreateUniqueTempDir()); 84 ASSERT_TRUE(download_directory_.CreateUniqueTempDir());
85 DownloadPrefs* download_prefs = DownloadPrefs::FromBrowserContext( 85 DownloadPrefs* download_prefs = DownloadPrefs::FromBrowserContext(
86 browser()->profile()); 86 browser()->profile());
87 download_prefs->SetDownloadPath(download_directory_.path()); 87 download_prefs->SetDownloadPath(download_directory_.path());
88 } 88 }
89 89
90 GURL WebstoreInstallerTest::GenerateTestServerUrl( 90 GURL WebstoreInstallerTest::GenerateTestServerUrl(
91 const std::string& domain, 91 const std::string& domain,
92 const std::string& page_filename) { 92 const std::string& page_filename) {
93 GURL page_url = test_server()->GetURL( 93 GURL page_url = embedded_test_server()->GetURL(base::StringPrintf(
94 base::StringPrintf("files/%s/%s", 94 "/%s/%s", test_data_path_.c_str(), page_filename.c_str()));
95 test_data_path_.c_str(),
96 page_filename.c_str()));
97 95
98 GURL::Replacements replace_host; 96 GURL::Replacements replace_host;
99 replace_host.SetHostStr(domain); 97 replace_host.SetHostStr(domain);
100 return page_url.ReplaceComponents(replace_host); 98 return page_url.ReplaceComponents(replace_host);
101 } 99 }
102 100
103 void WebstoreInstallerTest::RunTest(WebContents* web_contents, 101 void WebstoreInstallerTest::RunTest(WebContents* web_contents,
104 const std::string& test_function_name) { 102 const std::string& test_function_name) {
105 bool result = false; 103 bool result = false;
106 std::string script = base::StringPrintf( 104 std::string script = base::StringPrintf(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 install_auto_confirm_.reset(); // Destroy any old override first. 140 install_auto_confirm_.reset(); // Destroy any old override first.
143 install_auto_confirm_.reset(new extensions::ScopedTestDialogAutoConfirm( 141 install_auto_confirm_.reset(new extensions::ScopedTestDialogAutoConfirm(
144 extensions::ScopedTestDialogAutoConfirm::ACCEPT)); 142 extensions::ScopedTestDialogAutoConfirm::ACCEPT));
145 } 143 }
146 144
147 void WebstoreInstallerTest::AutoCancelInstall() { 145 void WebstoreInstallerTest::AutoCancelInstall() {
148 install_auto_confirm_.reset(); // Destroy any old override first. 146 install_auto_confirm_.reset(); // Destroy any old override first.
149 install_auto_confirm_.reset(new extensions::ScopedTestDialogAutoConfirm( 147 install_auto_confirm_.reset(new extensions::ScopedTestDialogAutoConfirm(
150 extensions::ScopedTestDialogAutoConfirm::CANCEL)); 148 extensions::ScopedTestDialogAutoConfirm::CANCEL));
151 } 149 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/wake_event_page_apitest.cc ('k') | chrome/browser/extensions/window_open_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698