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

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

Issue 342056: Mark all tests in the DownloadTest suite as flaky under Windows (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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>
11 #endif 11 #endif
12 12
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/path_service.h" 15 #include "base/path_service.h"
16 #include "base/platform_thread.h" 16 #include "base/platform_thread.h"
17 #include "base/string_util.h" 17 #include "base/string_util.h"
18 #include "chrome/app/chrome_dll_resource.h" 18 #include "chrome/app/chrome_dll_resource.h"
19 #include "chrome/browser/net/url_request_mock_http_job.h" 19 #include "chrome/browser/net/url_request_mock_http_job.h"
20 #include "chrome/browser/net/url_request_slow_download_job.h" 20 #include "chrome/browser/net/url_request_slow_download_job.h"
21 #include "chrome/common/chrome_constants.h" 21 #include "chrome/common/chrome_constants.h"
22 #include "chrome/common/chrome_paths.h" 22 #include "chrome/common/chrome_paths.h"
23 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
24 #include "chrome/test/ui/ui_test.h" 24 #include "chrome/test/ui/ui_test.h"
25 #include "chrome/test/automation/tab_proxy.h" 25 #include "chrome/test/automation/tab_proxy.h"
26 #include "chrome/test/automation/browser_proxy.h" 26 #include "chrome/test/automation/browser_proxy.h"
27 #include "net/base/net_util.h" 27 #include "net/base/net_util.h"
28 #include "net/url_request/url_request_unittest.h" 28 #include "net/url_request/url_request_unittest.h"
29 29
30 #if defined(OS_WIN)
31 #define FLAKYONWIN(Test) FLAKY_ ## Test
32 #else
33 #define FLAKYONWIN(Test) Test
34 #endif
35
30 namespace { 36 namespace {
31 37
32 const wchar_t kDocRoot[] = L"chrome/test/data"; 38 const wchar_t kDocRoot[] = L"chrome/test/data";
33 39
34 #if defined(OS_WIN) 40 #if defined(OS_WIN)
35 // Checks if the volume supports Alternate Data Streams. This is required for 41 // Checks if the volume supports Alternate Data Streams. This is required for
36 // the Zone Identifier implementation. 42 // the Zone Identifier implementation.
37 bool VolumeSupportsADS(const std::wstring path) { 43 bool VolumeSupportsADS(const std::wstring path) {
38 wchar_t drive[MAX_PATH] = {0}; 44 wchar_t drive[MAX_PATH] = {0};
39 wcscpy_s(drive, MAX_PATH, path.c_str()); 45 wcscpy_s(drive, MAX_PATH, path.c_str());
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 175
170 FAIL() << "Could not detect Internet ZoneIndentifier"; 176 FAIL() << "Could not detect Internet ZoneIndentifier";
171 } 177 }
172 #endif // defined(OS_WIN) 178 #endif // defined(OS_WIN)
173 179
174 FilePath download_prefix_; 180 FilePath download_prefix_;
175 }; 181 };
176 182
177 // Download a file with non-viewable content, verify that the 183 // Download a file with non-viewable content, verify that the
178 // download tab opened and the file exists. 184 // download tab opened and the file exists.
179 TEST_F(DownloadTest, DownloadMimeType) { 185 TEST_F(DownloadTest, FLAKYONWIN(DownloadMimeType)) {
180 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); 186 FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
181 187
182 EXPECT_EQ(1, GetTabCount()); 188 EXPECT_EQ(1, GetTabCount());
183 189
184 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file)); 190 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file));
185 // No new tabs created, downloads appear in the current tab's download shelf. 191 // No new tabs created, downloads appear in the current tab's download shelf.
186 WaitUntilTabCount(1); 192 WaitUntilTabCount(1);
187 193
188 // Wait until the file is downloaded. 194 // Wait until the file is downloaded.
189 PlatformThread::Sleep(action_timeout_ms()); 195 PlatformThread::Sleep(action_timeout_ms());
190 196
191 CleanUpDownload(file); 197 CleanUpDownload(file);
192 198
193 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); 199 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
194 ASSERT_TRUE(browser.get()); 200 ASSERT_TRUE(browser.get());
195 EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get())); 201 EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get()));
196 } 202 }
197 203
198 // Access a file with a viewable mime-type, verify that a download 204 // Access a file with a viewable mime-type, verify that a download
199 // did not initiate. 205 // did not initiate.
200 TEST_F(DownloadTest, NoDownload) { 206 TEST_F(DownloadTest, FLAKYONWIN(NoDownload)) {
201 FilePath file(FILE_PATH_LITERAL("download-test2.html")); 207 FilePath file(FILE_PATH_LITERAL("download-test2.html"));
202 FilePath file_path = download_prefix_.Append(file); 208 FilePath file_path = download_prefix_.Append(file);
203 209
204 if (file_util::PathExists(file_path)) 210 if (file_util::PathExists(file_path))
205 ASSERT_TRUE(file_util::Delete(file_path, false)); 211 ASSERT_TRUE(file_util::Delete(file_path, false));
206 212
207 EXPECT_EQ(1, GetTabCount()); 213 EXPECT_EQ(1, GetTabCount());
208 214
209 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file)); 215 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file));
210 WaitUntilTabCount(1); 216 WaitUntilTabCount(1);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 // Ensure the download shelf is visible on the window. 248 // Ensure the download shelf is visible on the window.
243 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); 249 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
244 ASSERT_TRUE(browser.get()); 250 ASSERT_TRUE(browser.get());
245 EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get())); 251 EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get()));
246 } 252 }
247 253
248 // Test that the download shelf is per-window by starting a download in one 254 // Test that the download shelf is per-window by starting a download in one
249 // tab, opening a second tab, closing the shelf, going back to the first tab, 255 // tab, opening a second tab, closing the shelf, going back to the first tab,
250 // and checking that the shelf is closed. 256 // and checking that the shelf is closed.
251 // See bug http://crbug.com/26325 257 // See bug http://crbug.com/26325
252 TEST_F(DownloadTest, FLAKY_PerWindowShelf) { 258 TEST_F(DownloadTest, FLAKYONWIN(PerWindowShelf)) {
253 FilePath file(FILE_PATH_LITERAL("download-test3.gif")); 259 FilePath file(FILE_PATH_LITERAL("download-test3.gif"));
254 FilePath download_file(FILE_PATH_LITERAL("download-test3-attachment.gif")); 260 FilePath download_file(FILE_PATH_LITERAL("download-test3-attachment.gif"));
255 261
256 EXPECT_EQ(1, GetTabCount()); 262 EXPECT_EQ(1, GetTabCount());
257 263
258 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file)); 264 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file));
259 WaitUntilTabCount(1); 265 WaitUntilTabCount(1);
260 266
261 // Wait until the file is downloaded. 267 // Wait until the file is downloaded.
262 PlatformThread::Sleep(action_timeout_ms()); 268 PlatformThread::Sleep(action_timeout_ms());
(...skipping 24 matching lines...) Expand all
287 ASSERT_FALSE(shelf_visible); 293 ASSERT_FALSE(shelf_visible);
288 } 294 }
289 295
290 // UnknownSize and KnownSize are tests which depend on 296 // UnknownSize and KnownSize are tests which depend on
291 // URLRequestSlowDownloadJob to serve content in a certain way. Data will be 297 // URLRequestSlowDownloadJob to serve content in a certain way. Data will be
292 // sent in two chunks where the first chunk is 35K and the second chunk is 10K. 298 // sent in two chunks where the first chunk is 35K and the second chunk is 10K.
293 // The test will first attempt to download a file; but the server will "pause" 299 // The test will first attempt to download a file; but the server will "pause"
294 // in the middle until the server receives a second request for 300 // in the middle until the server receives a second request for
295 // "download-finish. At that time, the download will finish. 301 // "download-finish. At that time, the download will finish.
296 // Flaky on Linux: http://code.google.com/p/chromium/issues/detail?id=14746 302 // Flaky on Linux: http://code.google.com/p/chromium/issues/detail?id=14746
297 TEST_F(DownloadTest, UnknownSize) { 303 TEST_F(DownloadTest, FLAKYONWIN(UnknownSize)) {
298 GURL url(URLRequestSlowDownloadJob::kUnknownSizeUrl); 304 GURL url(URLRequestSlowDownloadJob::kUnknownSizeUrl);
299 FilePath filename; 305 FilePath filename;
300 net::FileURLToFilePath(url, &filename); 306 net::FileURLToFilePath(url, &filename);
301 filename = filename.BaseName(); 307 filename = filename.BaseName();
302 RunSizeTest(url, L"32.0 KB - " + filename.ToWStringHack(), 308 RunSizeTest(url, L"32.0 KB - " + filename.ToWStringHack(),
303 L"100% - " + filename.ToWStringHack()); 309 L"100% - " + filename.ToWStringHack());
304 } 310 }
305 311
306 // http://b/1158253 312 // http://b/1158253
307 TEST_F(DownloadTest, DISABLED_KnownSize) { 313 TEST_F(DownloadTest, DISABLED_KnownSize) {
308 GURL url(URLRequestSlowDownloadJob::kKnownSizeUrl); 314 GURL url(URLRequestSlowDownloadJob::kKnownSizeUrl);
309 FilePath filename; 315 FilePath filename;
310 net::FileURLToFilePath(url, &filename); 316 net::FileURLToFilePath(url, &filename);
311 filename = filename.BaseName(); 317 filename = filename.BaseName();
312 RunSizeTest(url, L"71% - " + filename.ToWStringHack(), 318 RunSizeTest(url, L"71% - " + filename.ToWStringHack(),
313 L"100% - " + filename.ToWStringHack()); 319 L"100% - " + filename.ToWStringHack());
314 } 320 }
315 321
316 // Test that when downloading an item in Incognito mode, we don't crash when 322 // Test that when downloading an item in Incognito mode, we don't crash when
317 // closing the last Incognito window (http://crbug.com/13983). 323 // closing the last Incognito window (http://crbug.com/13983).
318 TEST_F(DownloadTest, IncognitoDownload) { 324 TEST_F(DownloadTest, FLAKYONWIN(IncognitoDownload)) {
319 // Open a regular window and sanity check default values for window / tab 325 // Open a regular window and sanity check default values for window / tab
320 // count and shelf visibility. 326 // count and shelf visibility.
321 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); 327 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
322 int window_count = 0; 328 int window_count = 0;
323 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); 329 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
324 ASSERT_EQ(1, window_count); 330 ASSERT_EQ(1, window_count);
325 EXPECT_EQ(1, GetTabCount()); 331 EXPECT_EQ(1, GetTabCount());
326 bool is_shelf_visible; 332 bool is_shelf_visible;
327 browser->IsShelfVisible(&is_shelf_visible); 333 browser->IsShelfVisible(&is_shelf_visible);
328 EXPECT_FALSE(is_shelf_visible); 334 EXPECT_FALSE(is_shelf_visible);
(...skipping 20 matching lines...) Expand all
349 ASSERT_EQ(1, window_count); 355 ASSERT_EQ(1, window_count);
350 356
351 // Verify that the regular window does not have a download shelf. 357 // Verify that the regular window does not have a download shelf.
352 browser->IsShelfVisible(&is_shelf_visible); 358 browser->IsShelfVisible(&is_shelf_visible);
353 EXPECT_FALSE(is_shelf_visible); 359 EXPECT_FALSE(is_shelf_visible);
354 360
355 CleanUpDownload(file); 361 CleanUpDownload(file);
356 } 362 }
357 363
358 } // namespace 364 } // namespace
365
366 #undef FLAKYONWIN
367
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698