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

Side by Side Diff: chrome/browser/download/download_uitest.cc

Issue 113722: Make automation proxy objects to ref_counted. That allows to process async no... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/crash_recovery_uitest.cc ('k') | chrome/browser/download/save_page_uitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <sstream> 5 #include <sstream>
6 #include <string> 6 #include <string>
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <shlwapi.h> 10 #include <shlwapi.h>
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 { 117 {
118 EXPECT_EQ(1, GetTabCount()); 118 EXPECT_EQ(1, GetTabCount());
119 119
120 NavigateToURL(url); 120 NavigateToURL(url);
121 // Downloads appear in the shelf 121 // Downloads appear in the shelf
122 WaitUntilTabCount(1); 122 WaitUntilTabCount(1);
123 // TODO(tc): check download status text 123 // TODO(tc): check download status text
124 124
125 // Complete sending the request. We do this by loading a second URL in a 125 // Complete sending the request. We do this by loading a second URL in a
126 // separate tab. 126 // separate tab.
127 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); 127 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
128 EXPECT_TRUE(window->AppendTab(GURL( 128 EXPECT_TRUE(window->AppendTab(GURL(
129 URLRequestSlowDownloadJob::kFinishDownloadUrl))); 129 URLRequestSlowDownloadJob::kFinishDownloadUrl)));
130 EXPECT_EQ(2, GetTabCount()); 130 EXPECT_EQ(2, GetTabCount());
131 // TODO(tc): check download status text 131 // TODO(tc): check download status text
132 132
133 // Make sure the download shelf is showing. 133 // Make sure the download shelf is showing.
134 scoped_ptr<TabProxy> dl_tab(window->GetTab(0)); 134 scoped_refptr<TabProxy> dl_tab(window->GetTab(0));
135 ASSERT_TRUE(dl_tab.get()); 135 ASSERT_TRUE(dl_tab.get());
136 EXPECT_TRUE(WaitForDownloadShelfVisible(dl_tab.get())); 136 EXPECT_TRUE(WaitForDownloadShelfVisible(dl_tab.get()));
137 } 137 }
138 138
139 FilePath filename; 139 FilePath filename;
140 net::FileURLToFilePath(url, &filename); 140 net::FileURLToFilePath(url, &filename);
141 filename = filename.BaseName(); 141 filename = filename.BaseName();
142 FilePath download_path = download_prefix_.Append(filename); 142 FilePath download_path = download_prefix_.Append(filename);
143 EXPECT_TRUE(file_util::PathExists(download_path)); 143 EXPECT_TRUE(file_util::PathExists(download_path));
144 144
(...skipping 18 matching lines...) Expand all
163 163
164 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file.ToWStringHack())); 164 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file.ToWStringHack()));
165 // No new tabs created, downloads appear in the current tab's download shelf. 165 // No new tabs created, downloads appear in the current tab's download shelf.
166 WaitUntilTabCount(1); 166 WaitUntilTabCount(1);
167 167
168 // Wait until the file is downloaded. 168 // Wait until the file is downloaded.
169 PlatformThread::Sleep(action_timeout_ms()); 169 PlatformThread::Sleep(action_timeout_ms());
170 170
171 CleanUpDownload(file); 171 CleanUpDownload(file);
172 172
173 scoped_ptr<TabProxy> tab_proxy(GetActiveTab()); 173 scoped_refptr<TabProxy> tab_proxy(GetActiveTab());
174 ASSERT_TRUE(tab_proxy.get()); 174 ASSERT_TRUE(tab_proxy.get());
175 EXPECT_TRUE(WaitForDownloadShelfVisible(tab_proxy.get())); 175 EXPECT_TRUE(WaitForDownloadShelfVisible(tab_proxy.get()));
176 } 176 }
177 177
178 // Access a file with a viewable mime-type, verify that a download 178 // Access a file with a viewable mime-type, verify that a download
179 // did not initiate. 179 // did not initiate.
180 TEST_F(DownloadTest, NoDownload) { 180 TEST_F(DownloadTest, NoDownload) {
181 FilePath file(FILE_PATH_LITERAL("download-test2.html")); 181 FilePath file(FILE_PATH_LITERAL("download-test2.html"));
182 FilePath file_path = download_prefix_.Append(file); 182 FilePath file_path = download_prefix_.Append(file);
183 183
184 if (file_util::PathExists(file_path)) 184 if (file_util::PathExists(file_path))
185 ASSERT_TRUE(file_util::Delete(file_path, false)); 185 ASSERT_TRUE(file_util::Delete(file_path, false));
186 186
187 EXPECT_EQ(1, GetTabCount()); 187 EXPECT_EQ(1, GetTabCount());
188 188
189 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file.ToWStringHack())); 189 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file.ToWStringHack()));
190 WaitUntilTabCount(1); 190 WaitUntilTabCount(1);
191 191
192 // Wait to see if the file will be downloaded. 192 // Wait to see if the file will be downloaded.
193 PlatformThread::Sleep(action_timeout_ms()); 193 PlatformThread::Sleep(action_timeout_ms());
194 194
195 EXPECT_FALSE(file_util::PathExists(file_path)); 195 EXPECT_FALSE(file_util::PathExists(file_path));
196 if (file_util::PathExists(file_path)) 196 if (file_util::PathExists(file_path))
197 ASSERT_TRUE(file_util::Delete(file_path, false)); 197 ASSERT_TRUE(file_util::Delete(file_path, false));
198 198
199 scoped_ptr<TabProxy> tab_proxy(GetActiveTab()); 199 scoped_refptr<TabProxy> tab_proxy(GetActiveTab());
200 ASSERT_TRUE(tab_proxy.get()); 200 ASSERT_TRUE(tab_proxy.get());
201 EXPECT_FALSE(WaitForDownloadShelfVisible(tab_proxy.get())); 201 EXPECT_FALSE(WaitForDownloadShelfVisible(tab_proxy.get()));
202 } 202 }
203 203
204 // Download a 0-size file with a content-disposition header, verify that the 204 // Download a 0-size file with a content-disposition header, verify that the
205 // download tab opened and the file exists as the filename specified in the 205 // download tab opened and the file exists as the filename specified in the
206 // header. This also ensures we properly handle empty file downloads. 206 // header. This also ensures we properly handle empty file downloads.
207 TEST_F(DownloadTest, ContentDisposition) { 207 TEST_F(DownloadTest, ContentDisposition) {
208 FilePath file(FILE_PATH_LITERAL("download-test3.gif")); 208 FilePath file(FILE_PATH_LITERAL("download-test3.gif"));
209 FilePath download_file(FILE_PATH_LITERAL("download-test3-attachment.gif")); 209 FilePath download_file(FILE_PATH_LITERAL("download-test3-attachment.gif"));
210 210
211 EXPECT_EQ(1, GetTabCount()); 211 EXPECT_EQ(1, GetTabCount());
212 212
213 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file.ToWStringHack())); 213 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file.ToWStringHack()));
214 WaitUntilTabCount(1); 214 WaitUntilTabCount(1);
215 215
216 // Wait until the file is downloaded. 216 // Wait until the file is downloaded.
217 PlatformThread::Sleep(action_timeout_ms()); 217 PlatformThread::Sleep(action_timeout_ms());
218 218
219 CleanUpDownload(download_file, file); 219 CleanUpDownload(download_file, file);
220 220
221 // Ensure the download shelf is visible on the current tab. 221 // Ensure the download shelf is visible on the current tab.
222 scoped_ptr<TabProxy> tab_proxy(GetActiveTab()); 222 scoped_refptr<TabProxy> tab_proxy(GetActiveTab());
223 ASSERT_TRUE(tab_proxy.get()); 223 ASSERT_TRUE(tab_proxy.get());
224 EXPECT_TRUE(WaitForDownloadShelfVisible(tab_proxy.get())); 224 EXPECT_TRUE(WaitForDownloadShelfVisible(tab_proxy.get()));
225 } 225 }
226 226
227 // UnknownSize and KnownSize are tests which depend on 227 // UnknownSize and KnownSize are tests which depend on
228 // URLRequestSlowDownloadJob to serve content in a certain way. Data will be 228 // URLRequestSlowDownloadJob to serve content in a certain way. Data will be
229 // sent in two chunks where the first chunk is 35K and the second chunk is 10K. 229 // sent in two chunks where the first chunk is 35K and the second chunk is 10K.
230 // The test will first attempt to download a file; but the server will "pause" 230 // The test will first attempt to download a file; but the server will "pause"
231 // in the middle until the server receives a second request for 231 // in the middle until the server receives a second request for
232 // "download-finish. At that time, the download will finish. 232 // "download-finish. At that time, the download will finish.
(...skipping 10 matching lines...) Expand all
243 TEST_F(DownloadTest, DISABLED_KnownSize) { 243 TEST_F(DownloadTest, DISABLED_KnownSize) {
244 GURL url(URLRequestSlowDownloadJob::kKnownSizeUrl); 244 GURL url(URLRequestSlowDownloadJob::kKnownSizeUrl);
245 FilePath filename; 245 FilePath filename;
246 net::FileURLToFilePath(url, &filename); 246 net::FileURLToFilePath(url, &filename);
247 filename = filename.BaseName(); 247 filename = filename.BaseName();
248 RunSizeTest(url, L"71% - " + filename.ToWStringHack(), 248 RunSizeTest(url, L"71% - " + filename.ToWStringHack(),
249 L"100% - " + filename.ToWStringHack()); 249 L"100% - " + filename.ToWStringHack());
250 } 250 }
251 251
252 } // namespace 252 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/crash_recovery_uitest.cc ('k') | chrome/browser/download/save_page_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698