Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <stack> | |
| 6 | |
| 5 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 6 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 7 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 8 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
| 9 #include "base/test/test_file_util.h" | 11 #include "base/test/test_file_util.h" |
| 10 #include "chrome/browser/ui/browser.h" | 12 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/browser_window.h" | 13 #include "chrome/browser/browser_window.h" |
| 12 #include "chrome/browser/download/download_item.h" | 14 #include "chrome/browser/download/download_item.h" |
| 13 #include "chrome/browser/download/download_manager.h" | 15 #include "chrome/browser/download/download_manager.h" |
| 14 #include "chrome/browser/download/download_prefs.h" | 16 #include "chrome/browser/download/download_prefs.h" |
| 17 #include "chrome/browser/download/download_shelf.h" | |
| 15 #include "chrome/browser/net/url_request_mock_http_job.h" | 18 #include "chrome/browser/net/url_request_mock_http_job.h" |
| 19 #include "chrome/browser/net/url_request_slow_download_job.h" | |
| 16 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/tab_contents/tab_contents.h" | 22 #include "chrome/browser/tab_contents/tab_contents.h" |
| 23 #include "chrome/browser/ui/browser.h" | |
| 24 #include "chrome/browser/ui/browser_list.h" | |
| 19 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 20 #include "chrome/common/chrome_paths.h" | 26 #include "chrome/common/chrome_paths.h" |
| 21 #include "chrome/common/notification_service.h" | 27 #include "chrome/common/notification_service.h" |
| 28 #include "chrome/common/page_transition_types.h" | |
| 22 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
| 23 #include "chrome/test/in_process_browser_test.h" | 30 #include "chrome/test/in_process_browser_test.h" |
| 24 #include "chrome/test/ui_test_utils.h" | 31 #include "chrome/test/ui_test_utils.h" |
| 32 #include "net/base/net_util.h" | |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 34 |
| 27 namespace { | 35 namespace { |
| 28 | 36 |
| 29 // Variation of DownloadsCompleteObserver from ui_test_utils.cc; the | 37 // Variation of DownloadsCompleteObserver from ui_test_utils.cc; the |
| 30 // specifically targeted download tests need finer granularity on waiting. | 38 // specifically targeted download tests need finer granularity on waiting. |
| 31 // Construction of this class defines a system state, based on some number | 39 // Construction of this class defines a system state, based on some number |
| 32 // of downloads being seen in a particular state + other events that | 40 // of downloads being seen in a particular state + other events that |
| 33 // may occur in the download system. That state will be recorded if it | 41 // may occur in the download system. That state will be recorded if it |
| 34 // occurs at any point after construction. When that state occurs, the class | 42 // occurs at any point after construction. When that state occurs, the class |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 // the select file dialog comes up. | 216 // the select file dialog comes up. |
| 209 bool finish_on_select_file_; | 217 bool finish_on_select_file_; |
| 210 | 218 |
| 211 // True if we've seen the select file dialog. | 219 // True if we've seen the select file dialog. |
| 212 bool select_file_dialog_seen_; | 220 bool select_file_dialog_seen_; |
| 213 | 221 |
| 214 DISALLOW_COPY_AND_ASSIGN(DownloadsObserver); | 222 DISALLOW_COPY_AND_ASSIGN(DownloadsObserver); |
| 215 }; | 223 }; |
| 216 | 224 |
| 217 class DownloadTest : public InProcessBrowserTest { | 225 class DownloadTest : public InProcessBrowserTest { |
| 226 public: | |
| 227 enum SelectExpectation { | |
| 228 EXPECT_NO_SELECT_DIALOG = -1, | |
| 229 EXPECT_NOTHING, | |
| 230 EXPECT_SELECT_DIALOG | |
| 231 }; | |
| 232 | |
| 233 virtual void InitialSetup(bool force_no_prompt) { | |
| 234 // Sanity check default values for window / tab count and shelf visibility. | |
| 235 PushBrowser(InProcessBrowserTest::browser()); // Set the initial browser. | |
| 236 int window_count = BrowserList::size(); | |
| 237 ASSERT_EQ(1, window_count); | |
| 238 EXPECT_EQ(1, browser()->tab_count()); | |
| 239 | |
| 240 bool is_shelf_visible = browser()->window()->IsDownloadShelfVisible(); | |
| 241 EXPECT_FALSE(is_shelf_visible); | |
| 242 | |
| 243 // Set up the temporary download folder. | |
| 244 ASSERT_TRUE(CreateAndSetDownloadsDirectory()); | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
My understanding is that we can't use ASSERT_* ins
ahendrickson
2010/12/16 19:26:41
I removed most of the ASSERT's, including all that
| |
| 245 | |
| 246 if (force_no_prompt) { | |
| 247 browser()->profile()->GetPrefs()->SetBoolean(prefs::kPromptForDownload, | |
| 248 false); | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
Is there ever a case where we *don't* want to spec
ahendrickson
2010/12/16 19:26:41
There is still one instance where it has to occur
| |
| 249 } | |
| 250 } | |
| 251 | |
| 218 protected: | 252 protected: |
| 253 | |
| 254 // We now use a browser stack. | |
| 255 void PushBrowser(Browser* browser) { browsers_.push(browser); } | |
| 256 void PopBrowser() { browsers_.pop(); } | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
If you take my suggestion below about giving Creat
ahendrickson
2010/12/16 19:26:41
It's also needed for |CreateWaiter()|, which is ca
| |
| 257 | |
| 258 virtual Browser* browser() const { return browsers_.top(); } | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
I'd suggest browsers_.empty() -> return NULL;
ahendrickson
2010/12/16 19:26:41
Done.
| |
| 259 | |
| 219 void SetUpInProcessBrowserTestFixture() { | 260 void SetUpInProcessBrowserTestFixture() { |
| 220 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir_)); | 261 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir_)); |
| 221 } | 262 } |
| 222 | 263 |
| 223 // Must be called after browser creation. Creates a temporary | 264 // Must be called after browser creation. Creates a temporary |
| 224 // directory for downloads that is auto-deleted on destruction. | 265 // directory for downloads that is auto-deleted on destruction. |
| 225 bool CreateAndSetDownloadsDirectory() { | 266 bool CreateAndSetDownloadsDirectory() { |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
The two usages of this function are in InitialSetu
ahendrickson
2010/12/16 19:26:41
I'd have to make other functions take a browser ar
| |
| 226 if (downloads_directory_.CreateUniqueTempDir()) { | 267 if (downloads_directory_.CreateUniqueTempDir()) |
| 227 browser()->profile()->GetPrefs()->SetFilePath( | 268 return SetDownloadsDirectoryForBrowser(browser()); |
| 269 return false; | |
| 270 } | |
| 271 | |
| 272 bool SetDownloadsDirectoryForBrowser(Browser* browser) { | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
The only use I can find of SetDownloadsDirectoryFo
ahendrickson
2010/12/16 19:26:41
Done.
| |
| 273 if (browser) { | |
| 274 browser->profile()->GetPrefs()->SetFilePath( | |
| 228 prefs::kDownloadDefaultDirectory, | 275 prefs::kDownloadDefaultDirectory, |
| 229 downloads_directory_.path()); | 276 downloads_directory_.path()); |
| 230 return true; | 277 return true; |
| 231 } | 278 } |
| 232 return false; | 279 return false; |
| 233 } | 280 } |
| 234 | 281 |
| 235 // May only be called inside of an individual test; browser() is NULL | 282 // May only be called inside of an individual test; browser() is NULL |
| 236 // outside of that context. | 283 // outside of that context. |
| 237 FilePath GetDownloadDirectory() { | 284 FilePath GetDownloadDirectory() { |
| 238 DownloadManager* download_mananger = | 285 DownloadManager* download_mananger = |
| 239 browser()->profile()->GetDownloadManager(); | 286 browser()->profile()->GetDownloadManager(); |
| 240 return download_mananger->download_prefs()->download_path(); | 287 return download_mananger->download_prefs()->download_path(); |
| 241 } | 288 } |
| 242 | 289 |
| 243 DownloadsObserver* CreateWaiter(int num_downloads) { | 290 DownloadsObserver* CreateWaiter(int num_downloads) { |
| 244 DownloadManager* download_manager = | 291 DownloadManager* download_manager = |
| 245 browser()->profile()->GetDownloadManager(); | 292 browser()->profile()->GetDownloadManager(); |
| 246 return new DownloadsObserver( | 293 return new DownloadsObserver( |
| 247 download_manager, num_downloads, | 294 download_manager, num_downloads, |
| 248 DownloadsObserver::FILE_RENAME, // Really done | 295 DownloadsObserver::FILE_RENAME, // Really done |
| 249 true); // Bail on select file | 296 true); // Bail on select file |
| 297 } | |
| 298 | |
| 299 // Download a file, then wait for the download to finish. | |
| 300 // |disposition| indicates where the naiation occurs (current tab, new | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
Nit: "navigation"
ahendrickson
2010/12/16 19:26:41
Done.
| |
| 301 // foreground tab, etc). | |
| 302 // |browser_test_flags| indicate what to wait for, and is an OR of 0 or more | |
| 303 // values in the BrowserTestFlags enum. | |
| 304 void DownloadAndWaitWithDisposition(Browser* browser, | |
| 305 const GURL& url, | |
| 306 WindowOpenDisposition disposition, | |
| 307 SelectExpectation expectation, | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
|expectation| isn't mentioned in the comments for
ahendrickson
2010/12/16 19:26:41
Done.
| |
| 308 int browser_test_flags) { | |
| 309 // Setup notification, navigate, and block. | |
| 310 scoped_ptr<DownloadsObserver> observer(CreateWaiter(1)); | |
| 311 ui_test_utils::NavigateToURLWithDisposition(browser, | |
| 312 url, | |
| 313 disposition, | |
| 314 browser_test_flags); | |
| 315 observer->WaitForFinished(); | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
I'd make clear in comments that we're blocking for
ahendrickson
2010/12/16 19:26:41
Done.
| |
| 316 | |
| 317 // If specified, check the state of the select file dialog. | |
| 318 if (expectation != EXPECT_NOTHING) { | |
| 319 EXPECT_EQ(expectation == EXPECT_SELECT_DIALOG, | |
| 320 observer->select_file_dialog_seen()); | |
| 321 } | |
| 322 } | |
| 323 | |
| 324 // Download a file in the current tab, then wait for the download to finish. | |
| 325 void DownloadAndWait(Browser* browser, | |
| 326 const GURL& url, | |
| 327 SelectExpectation expectation) { | |
| 328 DownloadAndWaitWithDisposition( | |
| 329 browser, | |
| 330 url, | |
| 331 CURRENT_TAB, | |
| 332 expectation, | |
| 333 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
| 250 } | 334 } |
| 251 | 335 |
| 252 // Should only be called when the download is known to have finished | 336 // Should only be called when the download is known to have finished |
| 253 // (in error or not). | 337 // (in error or not). |
| 254 void CheckDownload(const FilePath& downloaded_filename, | 338 void CheckDownload(const FilePath& downloaded_filename, |
| 255 const FilePath& origin_filename) { | 339 const FilePath& origin_filename) { |
| 256 // Find the path to which the data will be downloaded. | 340 // Find the path to which the data will be downloaded. |
| 257 FilePath downloaded_file = | 341 FilePath downloaded_file = |
| 258 GetDownloadDirectory().Append(downloaded_filename); | 342 GetDownloadDirectory().Append(downloaded_filename); |
| 259 | 343 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 273 #if defined(OS_WIN) | 357 #if defined(OS_WIN) |
| 274 // Check if the Zone Identifier is correctly set. | 358 // Check if the Zone Identifier is correctly set. |
| 275 if (file_util::VolumeSupportsADS(downloaded_file)) | 359 if (file_util::VolumeSupportsADS(downloaded_file)) |
| 276 EXPECT_TRUE(file_util::HasInternetZoneIdentifier(downloaded_file)); | 360 EXPECT_TRUE(file_util::HasInternetZoneIdentifier(downloaded_file)); |
| 277 #endif | 361 #endif |
| 278 | 362 |
| 279 // Delete the downloaded copy of the file. | 363 // Delete the downloaded copy of the file. |
| 280 EXPECT_TRUE(file_util::DieFileDie(downloaded_file, false)); | 364 EXPECT_TRUE(file_util::DieFileDie(downloaded_file, false)); |
| 281 } | 365 } |
| 282 | 366 |
| 367 // Note: |expected_title_in_progress| and |expected_title_in_finished| need | |
| 368 // to be checked. | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
I think the usual format for this is "TODO(<your l
| |
| 369 void RunSizeTest(const GURL& url, | |
| 370 const std::wstring& expected_title_in_progress, | |
| 371 const std::wstring& expected_title_finished) { | |
| 372 InitialSetup(true); | |
| 373 | |
| 374 // Download a partial web page in a background tab and wait. | |
| 375 // The mock system will not complete until it gets a special URL. | |
| 376 scoped_ptr<DownloadsObserver> observer(CreateWaiter(1)); | |
| 377 ui_test_utils::NavigateToURL(browser(), url); | |
| 378 | |
| 379 // TODO(tc): check download status text before downloading. | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
I think since the text is primarily yours (?), the
ahendrickson
2010/12/16 19:26:41
Done.
| |
| 380 // Need to: | |
| 381 // - Add a member function to the |DownloadShelf| interface class, that | |
| 382 // indicates how many members it has. | |
| 383 // - Add a member function to |DownloadShelf| to get the status text | |
| 384 // of a given member (for example, via |DownloadItemView|'s | |
| 385 // GetAccessibleName() member function), by index. | |
| 386 // - Iterate over browser()->window()->GetDownloadShelf()'s members | |
| 387 // to see if any match the status text we want. Start with the last one. | |
| 388 | |
| 389 // Complete sending the request. We do this by loading a second URL in a | |
| 390 // separate tab. | |
| 391 GURL finish_url(URLRequestSlowDownloadJob::kFinishDownloadUrl); | |
| 392 ui_test_utils::NavigateToURLWithDisposition( | |
| 393 browser(), | |
| 394 finish_url, | |
| 395 NEW_FOREGROUND_TAB, | |
| 396 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
| 397 observer->WaitForFinished(); | |
| 398 | |
| 399 EXPECT_EQ(2, browser()->tab_count()); | |
| 400 | |
| 401 // TODO(tc): check download status text after downloading. | |
| 402 | |
| 403 // Make sure the download shelf is showing. | |
| 404 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); | |
| 405 | |
| 406 FilePath filename; | |
| 407 net::FileURLToFilePath(url, &filename); | |
| 408 filename = filename.BaseName(); | |
| 409 FilePath download_path = downloads_directory_.path().Append(filename); | |
| 410 EXPECT_TRUE(file_util::PathExists(download_path)); | |
| 411 | |
| 412 // Delete the file we just downloaded. | |
| 413 EXPECT_TRUE(file_util::DieFileDie(download_path, true)); | |
| 414 EXPECT_FALSE(file_util::PathExists(download_path)); | |
| 415 } | |
| 416 | |
| 283 private: | 417 private: |
| 284 // Location of the test data. | 418 // Location of the test data. |
| 285 FilePath test_dir_; | 419 FilePath test_dir_; |
| 286 | 420 |
| 287 // Location of the downloads directory for these tests | 421 // Location of the downloads directory for these tests |
| 288 ScopedTempDir downloads_directory_; | 422 ScopedTempDir downloads_directory_; |
| 423 | |
| 424 std::stack<Browser *> browsers_; | |
| 289 }; | 425 }; |
| 290 | 426 |
| 427 // NOTES: | |
| 428 // | |
| 429 // Files for these tests are found in chrome\test\data\. | |
| 430 // Mock responses have extension .mock-http-headers appended to the file name. | |
| 431 | |
| 432 // Download a file due to the associated MIME type. | |
| 433 // | |
| 291 // Test is believed good (non-flaky) in itself, but it | 434 // Test is believed good (non-flaky) in itself, but it |
| 292 // sometimes trips over underlying flakiness in the downloads | 435 // sometimes trips over underlying flakiness in the downloads |
| 293 // subsystem in in http://crbug.com/63237. Until that bug is | 436 // subsystem in in http://crbug.com/63237. Until that bug is |
| 294 // fixed, this test should be considered flaky. It's entered as | 437 // fixed, this test should be considered flaky. It's entered as |
| 295 // DISABLED since if 63237 does cause a failure, it'll be a timeout. | 438 // DISABLED since if 63237 does cause a failure, it'll be a timeout. |
| 296 IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_DownloadMimeType) { | 439 IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_DownloadMimeType) { |
| 297 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 440 InitialSetup(false); |
| 298 ASSERT_TRUE(CreateAndSetDownloadsDirectory()); | 441 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
| 299 | 442 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
| 443 | |
| 444 // Download the file and wait. We do not expect the Select File dialog. | |
| 445 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); | |
| 446 | |
| 447 // Check state. | |
| 300 EXPECT_EQ(1, browser()->tab_count()); | 448 EXPECT_EQ(1, browser()->tab_count()); |
| 301 | |
| 302 // Setup notification, navigate, and block. | |
| 303 scoped_ptr<DownloadsObserver> observer(CreateWaiter(1)); | |
| 304 ui_test_utils::NavigateToURL( | |
| 305 browser(), URLRequestMockHTTPJob::GetMockUrl(file)); | |
| 306 observer->WaitForFinished(); | |
| 307 | |
| 308 // Download should be finished; check state. | |
| 309 EXPECT_FALSE(observer->select_file_dialog_seen()); | |
| 310 EXPECT_EQ(1, browser()->tab_count()); | |
| 311 CheckDownload(file, file); | 449 CheckDownload(file, file); |
| 312 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); | 450 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); |
| 313 } | 451 } |
| 314 | 452 |
| 453 // Put up a Select File dialog when the file is downloaded, due to its MIME | |
| 454 // type. | |
| 455 // | |
| 315 // This test runs correctly, but leaves behind turds in the test user's | 456 // This test runs correctly, but leaves behind turds in the test user's |
| 316 // download directory because of http://crbug.com/62099. No big loss; it | 457 // download directory because of http://crbug.com/62099. No big loss; it |
| 317 // was primarily confirming DownloadsObserver wait on select file dialog | 458 // was primarily confirming DownloadsObserver wait on select file dialog |
| 318 // functionality anyway. | 459 // functionality anyway. |
| 460 // Additionally, there is Windows-specific flake, http://crbug.com/20809. | |
| 319 IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_DownloadMimeTypeSelect) { | 461 IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_DownloadMimeTypeSelect) { |
| 320 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 462 InitialSetup(false); |
| 321 ASSERT_TRUE(CreateAndSetDownloadsDirectory()); | |
| 322 browser()->profile()->GetPrefs()->SetBoolean(prefs::kPromptForDownload, true); | 463 browser()->profile()->GetPrefs()->SetBoolean(prefs::kPromptForDownload, true); |
| 323 | 464 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
| 465 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | |
| 466 | |
| 467 // Download the file and wait. We expect the Select File dialog to appear | |
| 468 // due to the MIME type. | |
| 469 DownloadAndWait(browser(), url, EXPECT_SELECT_DIALOG); | |
| 470 | |
| 471 // Check state. | |
| 324 EXPECT_EQ(1, browser()->tab_count()); | 472 EXPECT_EQ(1, browser()->tab_count()); |
| 325 | 473 // Since we exited while the Select File dialog was visible, there should not |
| 326 // Setup notification, navigate, and block. | 474 // be anything in the download shelf and so it should not be visible. |
| 327 scoped_ptr<DownloadsObserver> observer(CreateWaiter(1)); | 475 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
| 328 ui_test_utils::NavigateToURL( | 476 } |
| 329 browser(), URLRequestMockHTTPJob::GetMockUrl(file)); | 477 |
| 330 observer->WaitForFinished(); | 478 // Access a file with a viewable mime-type, verify that a download |
| 331 | 479 // did not initiate. |
| 332 // Download should not be finished; check state. | 480 IN_PROC_BROWSER_TEST_F(DownloadTest, NoDownload) { |
| 333 EXPECT_TRUE(observer->select_file_dialog_seen()); | 481 InitialSetup(true); |
| 482 FilePath file(FILE_PATH_LITERAL("download-test2.html")); | |
| 483 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | |
| 484 FilePath file_path = GetDownloadDirectory().Append(file); | |
| 485 | |
| 486 // Open a web page and wait. | |
| 487 ui_test_utils::NavigateToURL(browser(), url); | |
| 488 | |
| 489 // Check that we did not download the web page. | |
| 490 EXPECT_FALSE(file_util::PathExists(file_path)); | |
| 491 if (file_util::PathExists(file_path)) | |
| 492 ASSERT_TRUE(file_util::DieFileDie(file_path, false)); | |
| 493 | |
| 494 // Check state. | |
| 334 EXPECT_EQ(1, browser()->tab_count()); | 495 EXPECT_EQ(1, browser()->tab_count()); |
| 335 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 496 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
| 336 } | 497 } |
| 337 | 498 |
| 499 // Download a 0-size file with a content-disposition header, verify that the | |
| 500 // download tab opened and the file exists as the filename specified in the | |
| 501 // header. This also ensures we properly handle empty file downloads. | |
| 502 // The download shelf should be visible in the current tab. | |
| 503 // | |
| 504 // Test is believed mostly good (non-flaky) in itself, but it | |
| 505 // sometimes trips over underlying flakiness in the downloads | |
| 506 // subsystem in in http://crbug.com/63237. Until that bug is | |
| 507 // fixed, this test should be considered flaky. It's entered as | |
| 508 // DISABLED since if 63237 does cause a failure, it'll be a timeout. | |
| 509 // Additionally, there is Windows-specific flake, http://crbug.com/20809. | |
| 510 IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_ContentDisposition) { | |
| 511 InitialSetup(true); | |
| 512 FilePath file(FILE_PATH_LITERAL("download-test3.gif")); | |
| 513 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | |
| 514 FilePath download_file(FILE_PATH_LITERAL("download-test3-attachment.gif")); | |
| 515 | |
| 516 // Download a file and wait. | |
| 517 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); | |
| 518 | |
| 519 CheckDownload(download_file, file); | |
| 520 | |
| 521 // Check state. | |
| 522 EXPECT_EQ(1, browser()->tab_count()); | |
| 523 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); | |
| 524 } | |
| 525 | |
| 526 // Test that the download shelf is per-window by starting a download in one | |
| 527 // tab, opening a second tab, closing the shelf, going back to the first tab, | |
| 528 // and checking that the shelf is closed. | |
| 529 // | |
| 530 // The test is considered flaky due to bug http://crbug.com/26325. | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
Obviously, remove references to 26325.
ahendrickson
2010/12/16 19:26:41
Done.
| |
| 531 // The test sometimes trips over underlying flakiness in the downloads | |
| 532 // subsystem in in http://crbug.com/63237. It's entered as | |
| 533 // DISABLED since if 63237 does cause a failure, it'll be a timeout. | |
| 534 // Additionally, there is Windows-specific flake, http://crbug.com/20809. | |
| 535 IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_PerWindowShelf) { | |
| 536 InitialSetup(true); | |
| 537 FilePath file(FILE_PATH_LITERAL("download-test3.gif")); | |
| 538 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | |
| 539 FilePath download_file(FILE_PATH_LITERAL("download-test3-attachment.gif")); | |
| 540 | |
| 541 // Download a file and wait. | |
| 542 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); | |
| 543 | |
| 544 CheckDownload(download_file, file); | |
| 545 | |
| 546 // Check state. | |
| 547 EXPECT_EQ(1, browser()->tab_count()); | |
| 548 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); | |
| 549 | |
| 550 // Open a second tab and wait. | |
| 551 ASSERT_NE(static_cast<TabContentsWrapper *>(NULL), | |
| 552 browser()->AddSelectedTabWithURL(GURL(), PageTransition::TYPED)); | |
| 553 EXPECT_EQ(2, browser()->tab_count()); | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
It would seem natural to this test to check that t
ahendrickson
2010/12/16 19:26:41
Done.
| |
| 554 | |
| 555 // Hide the download shelf. | |
| 556 browser()->window()->GetDownloadShelf()->Close(); | |
| 557 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | |
| 558 | |
| 559 // Go to the first tab. | |
| 560 browser()->SelectTabContentsAt(0, true); | |
| 561 ASSERT_EQ(2, browser()->tab_count()); | |
| 562 | |
| 563 // The download shelf should not be visible. | |
| 564 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | |
| 565 } | |
| 566 | |
| 567 // UnknownSize and KnownSize are tests which depend on | |
| 568 // URLRequestSlowDownloadJob to serve content in a certain way. Data will be | |
| 569 // sent in two chunks where the first chunk is 35K and the second chunk is 10K. | |
| 570 // The test will first attempt to download a file; but the server will "pause" | |
| 571 // in the middle until the server receives a second request for | |
| 572 // "download-finish". At that time, the download will finish. | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
I'd add "These tests don't currently test much due
ahendrickson
2010/12/16 19:26:41
Done.
| |
| 573 | |
| 574 // Test is believed mostly good (non-flaky) in itself, but it | |
| 575 // sometimes trips over underlying flakiness in the downloads | |
| 576 // subsystem in in http://crbug.com/63237. Until that bug is | |
| 577 // fixed, this test should be considered flaky. | |
| 578 // Additionally, there is Windows-specific flake, http://crbug.com/20809. | |
| 579 IN_PROC_BROWSER_TEST_F(DownloadTest, FLAKY_UnknownSize) { | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
For what it's worth, I believe these tests won't n
ahendrickson
2010/12/16 19:26:41
I'm going to enable them, then.
| |
| 580 GURL url(URLRequestSlowDownloadJob::kUnknownSizeUrl); | |
| 581 FilePath filename; | |
| 582 net::FileURLToFilePath(url, &filename); | |
| 583 filename = filename.BaseName(); | |
| 584 RunSizeTest(url, L"32.0 KB - " + filename.ToWStringHack(), | |
| 585 L"100% - " + filename.ToWStringHack()); | |
| 586 } | |
| 587 | |
| 588 // Test is believed mostly good (non-flaky) in itself, but it | |
| 589 // sometimes trips over underlying flakiness in the downloads | |
| 590 // subsystem in in http://crbug.com/63237. Until that bug is | |
| 591 // fixed, this test should be considered flaky. | |
| 592 // Additionally, there is Windows-specific flake, http://crbug.com/20809. | |
| 593 IN_PROC_BROWSER_TEST_F(DownloadTest, FLAKY_KnownSize) { | |
| 594 GURL url(URLRequestSlowDownloadJob::kKnownSizeUrl); | |
| 595 FilePath filename; | |
| 596 net::FileURLToFilePath(url, &filename); | |
| 597 filename = filename.BaseName(); | |
| 598 RunSizeTest(url, L"71% - " + filename.ToWStringHack(), | |
| 599 L"100% - " + filename.ToWStringHack()); | |
| 600 } | |
| 601 | |
| 602 // Test that when downloading an item in Incognito mode, we don't crash when | |
| 603 // closing the last Incognito window (http://crbug.com/13983). | |
| 604 // Also check that the download shelf is not visible after closing the | |
| 605 // Incognito window. | |
| 606 // | |
| 607 // Test is believed mostly good (non-flaky) in itself, but it | |
| 608 // sometimes trips over underlying flakiness in the downloads | |
| 609 // subsystem in in http://crbug.com/63237. Until that bug is | |
| 610 // fixed, this test should be considered flaky. | |
| 611 // Additionally, there is Windows-specific flake, http://crbug.com/20809. | |
| 612 IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_IncognitoDownload) { | |
| 613 InitialSetup(false); | |
| 614 | |
| 615 // Open an Incognito window. | |
| 616 Browser* incognito = CreateIncognitoBrowser(); // Waits. | |
| 617 ASSERT_TRUE(incognito); | |
| 618 int window_count = BrowserList::size(); | |
| 619 ASSERT_EQ(2, window_count); | |
| 620 | |
| 621 // Download a file in the Incognito window and wait. | |
| 622 PushBrowser(incognito); | |
| 623 CreateAndSetDownloadsDirectory(); // Must be called after PushBrowser(). | |
| 624 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | |
| 625 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | |
| 626 incognito->profile()->GetPrefs()->SetBoolean(prefs::kPromptForDownload, | |
| 627 false); | |
| 628 DownloadAndWait(incognito, url, EXPECT_NO_SELECT_DIALOG); | |
| 629 PopBrowser(); | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
I'd call this below, near CloseWindow(), just to k
ahendrickson
2010/12/16 19:26:41
Done.
| |
| 630 | |
| 631 // We should still have 2 windows. | |
| 632 window_count = BrowserList::size(); | |
| 633 ASSERT_EQ(2, window_count); | |
| 634 | |
| 635 // Verify that the download shelf is showing for the Incognito window. | |
| 636 bool is_shelf_visible = incognito->window()->IsDownloadShelfVisible(); | |
| 637 EXPECT_TRUE(is_shelf_visible); | |
| 638 | |
| 639 // Close the Incognito window and don't crash. | |
| 640 incognito->CloseWindow(); | |
| 641 ui_test_utils::WaitForWindowClosed(incognito); | |
| 642 window_count = BrowserList::size(); | |
| 643 ASSERT_EQ(1, window_count); | |
| 644 | |
| 645 // Verify that the regular window does not have a download shelf. | |
| 646 is_shelf_visible = browser()->window()->IsDownloadShelfVisible(); | |
| 647 EXPECT_FALSE(is_shelf_visible); | |
| 648 | |
| 649 CheckDownload(file, file); | |
| 650 } | |
| 651 | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
Not a requirement for this CL, but I invite you to
| |
| 652 // Navigate to a new background page, but don't download. Confirm that the | |
| 653 // download shelf is not visible and that we have two tabs. | |
| 654 // | |
| 655 // Test is believed mostly good (non-flaky) in itself, but it | |
| 656 // sometimes trips over underlying flakiness in the downloads | |
| 657 // subsystem in in http://crbug.com/63237. Until that bug is | |
| 658 // fixed, this test should be considered flaky. | |
| 659 // Additionally, there is Windows-specific flake, http://crbug.com/20809. | |
| 660 IN_PROC_BROWSER_TEST_F(DownloadTest, FLAKY_DontCloseNewTab1) { | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
I can't seen any reason why this test should be fl
ahendrickson
2010/12/16 19:26:41
Done.
| |
| 661 InitialSetup(false); | |
| 662 // Because it's an HTML link, it should open a tab rather than downloading. | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
This comment reads weirdly in combination with the
ahendrickson
2010/12/16 19:26:41
Changed the comments, here and elsewhere.
| |
| 663 FilePath file1(FILE_PATH_LITERAL("download-test2.html")); | |
| 664 GURL url(URLRequestMockHTTPJob::GetMockUrl(file1)); | |
| 665 | |
| 666 // Open a web page and wait. | |
| 667 ui_test_utils::NavigateToURLWithDisposition( | |
| 668 browser(), | |
| 669 url, | |
| 670 NEW_BACKGROUND_TAB, | |
| 671 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
| 672 | |
| 673 // We should have two tabs now. | |
| 674 ASSERT_EQ(2, browser()->tab_count()); | |
| 675 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | |
| 676 } | |
| 677 | |
| 678 // Download a file in a background tab. Verify that the tab is closed | |
| 679 // automatically, and that the download shelf is visible in the current tab. | |
| 680 // | |
| 681 // The test sometimes trips over underlying flakiness in the downloads | |
| 682 // subsystem in in http://crbug.com/63237. | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
nit: "in in"
ahendrickson
2010/12/16 19:26:41
I don't understand.
| |
| 683 // Additionally, there is Windows-specific flake, http://crbug.com/20809. | |
| 684 IN_PROC_BROWSER_TEST_F(DownloadTest, FLAKY_CloseNewTab1) { | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
Can't imagine why this wouldn't timeout via 62637.
| |
| 685 InitialSetup(true); | |
| 686 | |
| 687 // Download a file in a new background tab and wait. The tab is automatically | |
| 688 // closed when the download is done. | |
| 689 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | |
| 690 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | |
| 691 DownloadAndWaitWithDisposition( | |
| 692 browser(), | |
| 693 url, | |
| 694 NEW_BACKGROUND_TAB, | |
| 695 EXPECT_NO_SELECT_DIALOG, | |
| 696 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
| 697 | |
| 698 // When the download finishes, we should still have one tab. | |
| 699 ASSERT_TRUE(browser()->window()->IsDownloadShelfVisible()); | |
| 700 ASSERT_EQ(1, browser()->tab_count()); | |
| 701 | |
| 702 CheckDownload(file, file); | |
| 703 } | |
| 704 | |
| 705 // Open a web page, then download a file in another tab via a Javascript call. | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
Elsewhere current tab, foreground tab, background
ahendrickson
2010/12/16 19:26:41
Added "current tab", but no temporary tab is creat
| |
| 706 // Verify that we have 2 tabs, and the download shelf is visible in the current | |
| 707 // tab. | |
| 708 // | |
| 709 // The test sometimes trips over underlying flakiness in the downloads | |
| 710 // subsystem in in http://crbug.com/63237. | |
| 711 // Additionally, there is Windows-specific flake, http://crbug.com/20809. | |
| 712 IN_PROC_BROWSER_TEST_F(DownloadTest, FLAKY_DontCloseNewTab2) { | |
| 713 InitialSetup(true); | |
| 714 // Because it's an HTML link, it should open a tab rather than downloading. | |
| 715 FilePath file1(FILE_PATH_LITERAL("download_page1.html")); | |
| 716 GURL url(URLRequestMockHTTPJob::GetMockUrl(file1)); | |
| 717 | |
| 718 // Open a web page and wait. | |
| 719 ui_test_utils::NavigateToURL(browser(), url); | |
| 720 | |
| 721 // Download a file in a new tab and wait (via Javascript). | |
| 722 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | |
| 723 DownloadAndWaitWithDisposition(browser(), | |
| 724 GURL("javascript:openNew()"), | |
| 725 CURRENT_TAB, | |
| 726 EXPECT_NO_SELECT_DIALOG, | |
| 727 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | |
| 728 | |
| 729 // When the download finishes, we should have two tabs. | |
| 730 ASSERT_TRUE(browser()->window()->IsDownloadShelfVisible()); | |
| 731 ASSERT_EQ(2, browser()->tab_count()); | |
| 732 | |
| 733 CheckDownload(file, file); | |
| 734 } | |
| 735 | |
| 736 // Open a web page in the current tab, open another tab via a Javascript call, | |
| 737 // then download a file in the new tab. | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
I'd suggest that in general, when the test relies
ahendrickson
2010/12/16 19:26:41
The |openNew()| function is embedded in the web pa
| |
| 738 // Verify that we have 2 tabs, and the download shelf is visible in the current | |
| 739 // tab. | |
| 740 // | |
| 741 // The test sometimes trips over underlying flakiness in the downloads | |
| 742 // subsystem in in http://crbug.com/63237. | |
| 743 // Additionally, there is Windows-specific flake, http://crbug.com/20809. | |
| 744 IN_PROC_BROWSER_TEST_F(DownloadTest, FLAKY_DontCloseNewTab3) { | |
| 745 InitialSetup(true); | |
| 746 // Because it's an HTML link, it should open a tab rather than downloading. | |
| 747 FilePath file1(FILE_PATH_LITERAL("download_page2.html")); | |
| 748 GURL url1(URLRequestMockHTTPJob::GetMockUrl(file1)); | |
| 749 | |
| 750 // Open a web page and wait. | |
| 751 ui_test_utils::NavigateToURL(browser(), url1); | |
| 752 | |
| 753 // Open a new tab and wait. | |
| 754 ui_test_utils::NavigateToURLWithDisposition( | |
| 755 browser(), | |
| 756 GURL("javascript:openNew()"), | |
| 757 CURRENT_TAB, | |
| 758 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | |
| 759 | |
| 760 ASSERT_EQ(2, browser()->tab_count()); | |
| 761 | |
| 762 // Download a file and wait. | |
| 763 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | |
| 764 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | |
| 765 DownloadAndWaitWithDisposition(browser(), | |
| 766 url, | |
| 767 CURRENT_TAB, | |
| 768 EXPECT_NO_SELECT_DIALOG, | |
| 769 ui_test_utils::BROWSER_TEST_NONE); | |
| 770 | |
| 771 // When the download finishes, we should have two tabs. | |
| 772 ASSERT_TRUE(browser()->window()->IsDownloadShelfVisible()); | |
| 773 ASSERT_EQ(2, browser()->tab_count()); | |
| 774 | |
| 775 CheckDownload(file, file); | |
| 776 } | |
| 777 | |
| 778 // Open a web page in the current tab, then download a file via Javascript, | |
| 779 // which will do so in a temporary tab. | |
| 780 // Verify that we have 1 tab, and the download shelf is visible. | |
| 781 // | |
| 782 // The test sometimes trips over underlying flakiness in the downloads | |
| 783 // subsystem in in http://crbug.com/63237. | |
| 784 // Additionally, there is Windows-specific flake, http://crbug.com/20809. | |
| 785 IN_PROC_BROWSER_TEST_F(DownloadTest, FLAKY_CloseNewTab2) { | |
| 786 InitialSetup(true); | |
| 787 // Because it's an HTML link, it should open a tab rather than downloading. | |
| 788 FilePath file1(FILE_PATH_LITERAL("download_page3.html")); | |
| 789 GURL url(URLRequestMockHTTPJob::GetMockUrl(file1)); | |
| 790 | |
| 791 // Open a web page and wait. | |
| 792 ui_test_utils::NavigateToURL(browser(), url); | |
| 793 | |
| 794 // Download a file and wait. | |
| 795 // The file to download is "download-test1.lib". | |
| 796 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | |
| 797 DownloadAndWaitWithDisposition(browser(), | |
| 798 GURL("javascript:openNew()"), | |
| 799 CURRENT_TAB, | |
| 800 EXPECT_NO_SELECT_DIALOG, | |
| 801 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | |
| 802 | |
| 803 // When the download finishes, we should still have one tab. | |
| 804 ASSERT_TRUE(browser()->window()->IsDownloadShelfVisible()); | |
| 805 ASSERT_EQ(1, browser()->tab_count()); | |
| 806 | |
| 807 CheckDownload(file, file); | |
| 808 } | |
| 809 | |
| 810 // Open a web page in the current tab, then call Javascript via a button to | |
| 811 // download a file in a new tab. Close the new tab when the download is done. | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
Is the new tab closed by the test? I don't see th
ahendrickson
2010/12/16 19:26:41
Done.
| |
| 812 // Verify that we have 1 tab, and the download shelf is visible. | |
| 813 // | |
| 814 // The test sometimes trips over underlying flakiness in the downloads | |
| 815 // subsystem in in http://crbug.com/63237. | |
| 816 // Additionally, there is Windows-specific flake, http://crbug.com/20809. | |
| 817 IN_PROC_BROWSER_TEST_F(DownloadTest, FLAKY_CloseNewTab3) { | |
| 818 InitialSetup(true); | |
| 819 // Because it's an HTML link, it should open a tab rather than downloading. | |
| 820 FilePath file1(FILE_PATH_LITERAL("download_page4.html")); | |
| 821 GURL url(URLRequestMockHTTPJob::GetMockUrl(file1)); | |
| 822 | |
| 823 // Open a web page and wait. | |
| 824 ui_test_utils::NavigateToURL(browser(), url); | |
| 825 | |
| 826 // Download a file in a new tab and wait. The tab will automatically close | |
| 827 // when the download is done. | |
| 828 // The file to download is "download-test1.lib". | |
| 829 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | |
| 830 DownloadAndWaitWithDisposition( | |
| 831 browser(), | |
| 832 GURL("javascript:document.getElementById('form').submit()"), | |
| 833 CURRENT_TAB, | |
| 834 EXPECT_NO_SELECT_DIALOG, | |
| 835 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | |
| 836 | |
| 837 // When the download finishes, we should still have one tab. | |
| 838 ASSERT_TRUE(browser()->window()->IsDownloadShelfVisible()); | |
| 839 ASSERT_EQ(1, browser()->tab_count()); | |
| 840 | |
| 841 CheckDownload(file, file); | |
| 842 } | |
| 843 | |
| 844 // Download a file in a new browser window, leaving it open. | |
| 845 // Verify that we have 2 windows, and the download shelf is not visible in the | |
| 846 // first window, but is visible in the second window. | |
| 847 // | |
| 848 // Test is believed mostly good (non-flaky) in itself, but it | |
| 849 // sometimes trips over underlying flakiness in the downloads | |
| 850 // subsystem in in http://crbug.com/63237. Until that bug is | |
| 851 // fixed, this test should be considered flaky. | |
| 852 // Additionally, there is Windows-specific flake, http://crbug.com/20809. | |
| 853 IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_DontCloseNewWindow) { | |
| 854 InitialSetup(true); | |
| 855 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | |
| 856 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | |
| 857 | |
| 858 // Download a file in a new window and wait. | |
| 859 DownloadAndWaitWithDisposition( | |
| 860 browser(), | |
| 861 url, | |
| 862 NEW_WINDOW, | |
| 863 EXPECT_NO_SELECT_DIALOG, | |
| 864 ui_test_utils::BROWSER_TEST_NONE); | |
| 865 | |
| 866 // When the download finishes, the download shelf SHOULD NOT be visible in | |
| 867 // the first window. | |
| 868 int window_count = BrowserList::size(); | |
| 869 ASSERT_EQ(2, window_count); | |
| 870 ASSERT_EQ(1, browser()->tab_count()); | |
| 871 ASSERT_FALSE(browser()->window()->IsDownloadShelfVisible()); | |
| 872 | |
| 873 // The download shelf SHOULD be visible in the second window. | |
| 874 Browser* download_browser = ui_test_utils::GetBrowser(1); | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
Does GetBrowser() give a guarantee that we get the
ahendrickson
2010/12/16 19:26:41
In this particular case, it's guaranteed. If you
| |
| 875 ASSERT_NE(download_browser, browser()); | |
| 876 ASSERT_EQ(1, download_browser->tab_count()); | |
| 877 ASSERT_TRUE(download_browser->window()->IsDownloadShelfVisible()); | |
| 878 | |
| 879 CheckDownload(file, file); | |
| 880 } | |
| 881 | |
| 882 // Download a file in a new window. | |
| 883 // Verify that we have 2 windows, and the download shelf is not visible in the | |
| 884 // first window, but is visible in the second window. | |
| 885 // Close the new window. | |
| 886 // Verify that we have 1 window, and the download shelf is not visible. | |
| 887 // | |
| 888 // Regression test for http://crbug.com/44454 | |
| 889 // | |
| 890 // Test is believed mostly good (non-flaky) in itself, but it | |
| 891 // sometimes trips over underlying flakiness in the downloads | |
| 892 // subsystem in in http://crbug.com/63237. Until that bug is | |
| 893 // fixed, this test should be considered flaky. | |
| 894 // Additionally, there is Windows-specific flake, http://crbug.com/20809. | |
| 895 IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_NewWindow) { | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
This test looks like a strict superset of DontClos
| |
| 896 InitialSetup(true); | |
| 897 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | |
| 898 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | |
| 899 | |
| 900 // Download a file in a new window and wait. | |
| 901 DownloadAndWaitWithDisposition(browser(), | |
| 902 url, | |
| 903 NEW_WINDOW, | |
| 904 EXPECT_NO_SELECT_DIALOG, | |
| 905 ui_test_utils::BROWSER_TEST_NONE); | |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
Micro-nit: Consistency is a win, so in the absence
ahendrickson
2010/12/16 19:26:41
I personally prefer this method of lining up varia
| |
| 906 | |
| 907 // When the download finishes, the download shelf SHOULD NOT be visible in | |
| 908 // the first window. | |
| 909 int window_count = BrowserList::size(); | |
| 910 ASSERT_EQ(2, window_count); | |
| 911 ASSERT_EQ(1, browser()->tab_count()); | |
| 912 ASSERT_FALSE(browser()->window()->IsDownloadShelfVisible()); | |
| 913 | |
| 914 // The download shelf SHOULD be visible in the second window. | |
| 915 Browser* download_browser = ui_test_utils::GetBrowser(1); | |
| 916 ASSERT_NE(download_browser, browser()); | |
| 917 ASSERT_EQ(1, download_browser->tab_count()); | |
| 918 ASSERT_TRUE(download_browser->window()->IsDownloadShelfVisible()); | |
| 919 | |
| 920 // Close the new window. | |
| 921 download_browser->CloseWindow(); | |
| 922 ui_test_utils::WaitForWindowClosed(download_browser); | |
| 923 window_count = BrowserList::size(); | |
| 924 ASSERT_EQ(1, window_count); | |
| 925 ASSERT_EQ(1, browser()->tab_count()); | |
| 926 // The download shelf should not be visible in the remaining window. | |
| 927 ASSERT_FALSE(browser()->window()->IsDownloadShelfVisible()); | |
| 928 | |
| 929 CheckDownload(file, file); | |
| 930 } | |
| 931 | |
| 338 } // namespace | 932 } // namespace |
| OLD | NEW |