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/extensions/extension_install_prompt.h" | 9 #include "chrome/browser/extensions/extension_install_prompt.h" |
9 #include "chrome/browser/extensions/tab_helper.h" | 10 #include "chrome/browser/extensions/tab_helper.h" |
10 #include "chrome/browser/extensions/webstore_inline_installer.h" | 11 #include "chrome/browser/extensions/webstore_inline_installer.h" |
11 #include "chrome/browser/extensions/webstore_inline_installer_factory.h" | 12 #include "chrome/browser/extensions/webstore_inline_installer_factory.h" |
12 #include "chrome/browser/extensions/webstore_installer_test.h" | 13 #include "chrome/browser/extensions/webstore_installer_test.h" |
13 #include "chrome/browser/extensions/webstore_standalone_installer.h" | 14 #include "chrome/browser/extensions/webstore_standalone_installer.h" |
14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
17 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // functions don't get collected prematurely. | 71 // functions don't get collected prematurely. |
71 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); | 72 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); |
72 } | 73 } |
73 | 74 |
74 void WebstoreInstallerTest::SetUpInProcessBrowserTestFixture() { | 75 void WebstoreInstallerTest::SetUpInProcessBrowserTestFixture() { |
75 host_resolver()->AddRule(webstore_domain_, "127.0.0.1"); | 76 host_resolver()->AddRule(webstore_domain_, "127.0.0.1"); |
76 host_resolver()->AddRule(verified_domain_, "127.0.0.1"); | 77 host_resolver()->AddRule(verified_domain_, "127.0.0.1"); |
77 host_resolver()->AddRule(unverified_domain_, "127.0.0.1"); | 78 host_resolver()->AddRule(unverified_domain_, "127.0.0.1"); |
78 } | 79 } |
79 | 80 |
| 81 void WebstoreInstallerTest::SetUpOnMainThread() { |
| 82 InProcessBrowserTest::SetUpOnMainThread(); |
| 83 ASSERT_TRUE(download_directory_.CreateUniqueTempDir()); |
| 84 DownloadPrefs* download_prefs = DownloadPrefs::FromBrowserContext( |
| 85 browser()->profile()); |
| 86 download_prefs->SetDownloadPath(download_directory_.path()); |
| 87 } |
| 88 |
80 GURL WebstoreInstallerTest::GenerateTestServerUrl( | 89 GURL WebstoreInstallerTest::GenerateTestServerUrl( |
81 const std::string& domain, | 90 const std::string& domain, |
82 const std::string& page_filename) { | 91 const std::string& page_filename) { |
83 GURL page_url = test_server()->GetURL( | 92 GURL page_url = test_server()->GetURL( |
84 base::StringPrintf("files/%s/%s", | 93 base::StringPrintf("files/%s/%s", |
85 test_data_path_.c_str(), | 94 test_data_path_.c_str(), |
86 page_filename.c_str())); | 95 page_filename.c_str())); |
87 | 96 |
88 GURL::Replacements replace_host; | 97 GURL::Replacements replace_host; |
89 replace_host.SetHostStr(domain); | 98 replace_host.SetHostStr(domain); |
(...skipping 26 matching lines...) Expand all Loading... |
116 return result == "KEEPGOING"; | 125 return result == "KEEPGOING"; |
117 } | 126 } |
118 | 127 |
119 void WebstoreInstallerTest::RunTestAsync( | 128 void WebstoreInstallerTest::RunTestAsync( |
120 const std::string& test_function_name) { | 129 const std::string& test_function_name) { |
121 std::string script = base::StringPrintf( | 130 std::string script = base::StringPrintf( |
122 "%s('%s')", test_function_name.c_str(), test_gallery_url_.c_str()); | 131 "%s('%s')", test_function_name.c_str(), test_gallery_url_.c_str()); |
123 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame()-> | 132 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame()-> |
124 ExecuteJavaScript(base::UTF8ToUTF16(script)); | 133 ExecuteJavaScript(base::UTF8ToUTF16(script)); |
125 } | 134 } |
OLD | NEW |