| OLD | NEW |
| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // Complete sending the request. We do this by loading a second URL in a | 105 // Complete sending the request. We do this by loading a second URL in a |
| 106 // separate tab. | 106 // separate tab. |
| 107 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 107 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 108 ASSERT_TRUE(window.get()); | 108 ASSERT_TRUE(window.get()); |
| 109 EXPECT_TRUE(window->AppendTab(GURL( | 109 EXPECT_TRUE(window->AppendTab(GURL( |
| 110 URLRequestSlowDownloadJob::kFinishDownloadUrl))); | 110 URLRequestSlowDownloadJob::kFinishDownloadUrl))); |
| 111 EXPECT_EQ(2, GetTabCount()); | 111 EXPECT_EQ(2, GetTabCount()); |
| 112 // TODO(tc): check download status text | 112 // TODO(tc): check download status text |
| 113 | 113 |
| 114 // Make sure the download shelf is showing. | 114 // Make sure the download shelf is showing. |
| 115 EXPECT_TRUE(WaitForDownloadShelfVisible(window.get())); | 115 EXPECT_TRUE(window->WaitForDownloadShelfVisibilityChange(true)); |
| 116 } | 116 } |
| 117 | 117 |
| 118 FilePath filename; | 118 FilePath filename; |
| 119 net::FileURLToFilePath(url, &filename); | 119 net::FileURLToFilePath(url, &filename); |
| 120 filename = filename.BaseName(); | 120 filename = filename.BaseName(); |
| 121 FilePath download_path = download_prefix_.Append(filename); | 121 FilePath download_path = download_prefix_.Append(filename); |
| 122 EXPECT_TRUE(file_util::PathExists(download_path)); | 122 EXPECT_TRUE(file_util::PathExists(download_path)); |
| 123 | 123 |
| 124 // Delete the file we just downloaded. | 124 // Delete the file we just downloaded. |
| 125 EXPECT_TRUE(file_util::DieFileDie(download_path, true)); | 125 EXPECT_TRUE(file_util::DieFileDie(download_path, true)); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 EXPECT_EQ(1, GetTabCount()); | 180 EXPECT_EQ(1, GetTabCount()); |
| 181 | 181 |
| 182 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file)); | 182 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file)); |
| 183 // No new tabs created, downloads appear in the current tab's download shelf. | 183 // No new tabs created, downloads appear in the current tab's download shelf. |
| 184 WaitUntilTabCount(1); | 184 WaitUntilTabCount(1); |
| 185 | 185 |
| 186 CheckDownload(file); | 186 CheckDownload(file); |
| 187 | 187 |
| 188 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 188 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 189 ASSERT_TRUE(browser.get()); | 189 ASSERT_TRUE(browser.get()); |
| 190 EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get())); | 190 EXPECT_TRUE(browser->WaitForDownloadShelfVisibilityChange(true)); |
| 191 } | 191 } |
| 192 | 192 |
| 193 // Access a file with a viewable mime-type, verify that a download | 193 // Access a file with a viewable mime-type, verify that a download |
| 194 // did not initiate. | 194 // did not initiate. |
| 195 // All download tests are flaky on all platforms, http://crbug.com/35275. | 195 // All download tests are flaky on all platforms, http://crbug.com/35275. |
| 196 // Additionally, there is Windows-specific flake, http://crbug.com/20809. | 196 // Additionally, there is Windows-specific flake, http://crbug.com/20809. |
| 197 TEST_F(DownloadTest, FLAKY_NoDownload) { | 197 TEST_F(DownloadTest, FLAKY_NoDownload) { |
| 198 FilePath file(FILE_PATH_LITERAL("download-test2.html")); | 198 FilePath file(FILE_PATH_LITERAL("download-test2.html")); |
| 199 FilePath file_path = download_prefix_.Append(file); | 199 FilePath file_path = download_prefix_.Append(file); |
| 200 | 200 |
| 201 if (file_util::PathExists(file_path)) | 201 if (file_util::PathExists(file_path)) |
| 202 ASSERT_TRUE(file_util::Delete(file_path, false)); | 202 ASSERT_TRUE(file_util::Delete(file_path, false)); |
| 203 | 203 |
| 204 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file)); | 204 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file)); |
| 205 WaitUntilTabCount(1); | 205 WaitUntilTabCount(1); |
| 206 | 206 |
| 207 // Wait to see if the file will be downloaded. | 207 // Wait to see if the file will be downloaded. |
| 208 PlatformThread::Sleep(sleep_timeout_ms()); | 208 PlatformThread::Sleep(sleep_timeout_ms()); |
| 209 | 209 |
| 210 EXPECT_FALSE(file_util::PathExists(file_path)); | 210 EXPECT_FALSE(file_util::PathExists(file_path)); |
| 211 if (file_util::PathExists(file_path)) | 211 if (file_util::PathExists(file_path)) |
| 212 ASSERT_TRUE(file_util::Delete(file_path, false)); | 212 ASSERT_TRUE(file_util::Delete(file_path, false)); |
| 213 | 213 |
| 214 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 214 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 215 ASSERT_TRUE(browser.get()); | 215 ASSERT_TRUE(browser.get()); |
| 216 EXPECT_FALSE(WaitForDownloadShelfVisible(browser.get())); | 216 EXPECT_FALSE(browser->WaitForDownloadShelfVisibilityChange(true)); |
| 217 } | 217 } |
| 218 | 218 |
| 219 // Download a 0-size file with a content-disposition header, verify that the | 219 // Download a 0-size file with a content-disposition header, verify that the |
| 220 // download tab opened and the file exists as the filename specified in the | 220 // download tab opened and the file exists as the filename specified in the |
| 221 // header. This also ensures we properly handle empty file downloads. | 221 // header. This also ensures we properly handle empty file downloads. |
| 222 // All download tests are flaky on all platforms, http://crbug.com/35275. | 222 // All download tests are flaky on all platforms, http://crbug.com/35275. |
| 223 // Additionally, there is Windows-specific flake, http://crbug.com/20809. | 223 // Additionally, there is Windows-specific flake, http://crbug.com/20809. |
| 224 TEST_F(DownloadTest, FLAKY_ContentDisposition) { | 224 TEST_F(DownloadTest, FLAKY_ContentDisposition) { |
| 225 FilePath file(FILE_PATH_LITERAL("download-test3.gif")); | 225 FilePath file(FILE_PATH_LITERAL("download-test3.gif")); |
| 226 FilePath download_file(FILE_PATH_LITERAL("download-test3-attachment.gif")); | 226 FilePath download_file(FILE_PATH_LITERAL("download-test3-attachment.gif")); |
| 227 | 227 |
| 228 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file)); | 228 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file)); |
| 229 WaitUntilTabCount(1); | 229 WaitUntilTabCount(1); |
| 230 | 230 |
| 231 CheckDownload(download_file, file); | 231 CheckDownload(download_file, file); |
| 232 | 232 |
| 233 // Ensure the download shelf is visible on the window. | 233 // Ensure the download shelf is visible on the window. |
| 234 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 234 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 235 ASSERT_TRUE(browser.get()); | 235 ASSERT_TRUE(browser.get()); |
| 236 EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get())); | 236 EXPECT_TRUE(browser->WaitForDownloadShelfVisibilityChange(true)); |
| 237 } | 237 } |
| 238 | 238 |
| 239 // Test that the download shelf is per-window by starting a download in one | 239 // Test that the download shelf is per-window by starting a download in one |
| 240 // tab, opening a second tab, closing the shelf, going back to the first tab, | 240 // tab, opening a second tab, closing the shelf, going back to the first tab, |
| 241 // and checking that the shelf is closed. | 241 // and checking that the shelf is closed. |
| 242 // See bug http://crbug.com/26325 | 242 // See bug http://crbug.com/26325 |
| 243 // All download tests are flaky on all platforms, http://crbug.com/35275. | 243 // All download tests are flaky on all platforms, http://crbug.com/35275. |
| 244 // Additionally, there is Windows-specific flake, http://crbug.com/20809. | 244 // Additionally, there is Windows-specific flake, http://crbug.com/20809. |
| 245 TEST_F(DownloadTest, FLAKY_PerWindowShelf) { | 245 TEST_F(DownloadTest, FLAKY_PerWindowShelf) { |
| 246 FilePath file(FILE_PATH_LITERAL("download-test3.gif")); | 246 FilePath file(FILE_PATH_LITERAL("download-test3.gif")); |
| 247 FilePath download_file(FILE_PATH_LITERAL("download-test3-attachment.gif")); | 247 FilePath download_file(FILE_PATH_LITERAL("download-test3-attachment.gif")); |
| 248 | 248 |
| 249 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file)); | 249 NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file)); |
| 250 WaitUntilTabCount(1); | 250 WaitUntilTabCount(1); |
| 251 | 251 |
| 252 CheckDownload(download_file, file); | 252 CheckDownload(download_file, file); |
| 253 | 253 |
| 254 // Ensure the download shelf is visible on the window. | 254 // Ensure the download shelf is visible on the window. |
| 255 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 255 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 256 ASSERT_TRUE(browser.get()); | 256 ASSERT_TRUE(browser.get()); |
| 257 EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get())); | 257 EXPECT_TRUE(browser->WaitForDownloadShelfVisibilityChange(true)); |
| 258 | 258 |
| 259 // Open a second tab | 259 // Open a second tab |
| 260 ASSERT_TRUE(browser->AppendTab(GURL())); | 260 ASSERT_TRUE(browser->AppendTab(GURL())); |
| 261 WaitUntilTabCount(2); | 261 WaitUntilTabCount(2); |
| 262 | 262 |
| 263 // Hide shelf | 263 // Hide shelf |
| 264 EXPECT_TRUE(browser->SetShelfVisible(false)); | 264 EXPECT_TRUE(browser->SetShelfVisible(false)); |
| 265 EXPECT_TRUE(WaitForDownloadShelfInvisible(browser.get())); | 265 EXPECT_TRUE(browser->WaitForDownloadShelfVisibilityChange(false)); |
| 266 | 266 |
| 267 // Go to first tab | 267 // Go to first tab |
| 268 EXPECT_TRUE(browser->ActivateTab(0)); | 268 EXPECT_TRUE(browser->ActivateTab(0)); |
| 269 int tab_count; | 269 int tab_count; |
| 270 EXPECT_TRUE(browser->GetTabCount(&tab_count)); | 270 EXPECT_TRUE(browser->GetTabCount(&tab_count)); |
| 271 ASSERT_EQ(2, tab_count); | 271 ASSERT_EQ(2, tab_count); |
| 272 | 272 |
| 273 bool shelf_visible; | 273 bool shelf_visible; |
| 274 EXPECT_TRUE(browser->IsShelfVisible(&shelf_visible)); | 274 EXPECT_TRUE(browser->IsShelfVisible(&shelf_visible)); |
| 275 ASSERT_FALSE(shelf_visible); | 275 ASSERT_FALSE(shelf_visible); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 int load_time; | 329 int load_time; |
| 330 ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time)); | 330 ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time)); |
| 331 | 331 |
| 332 // Download something. | 332 // Download something. |
| 333 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 333 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
| 334 scoped_refptr<TabProxy> tab(incognito->GetTab(0)); | 334 scoped_refptr<TabProxy> tab(incognito->GetTab(0)); |
| 335 ASSERT_TRUE(tab.get()); | 335 ASSERT_TRUE(tab.get()); |
| 336 ASSERT_TRUE(tab->NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file))); | 336 ASSERT_TRUE(tab->NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file))); |
| 337 | 337 |
| 338 // Verify that the download shelf is showing for the Incognito window. | 338 // Verify that the download shelf is showing for the Incognito window. |
| 339 EXPECT_TRUE(WaitForDownloadShelfVisible(incognito.get())); | 339 EXPECT_TRUE(incognito->WaitForDownloadShelfVisibilityChange(true)); |
| 340 | 340 |
| 341 // Close the Incognito window and don't crash. | 341 // Close the Incognito window and don't crash. |
| 342 ASSERT_TRUE(incognito->RunCommand(IDC_CLOSE_WINDOW)); | 342 ASSERT_TRUE(incognito->RunCommand(IDC_CLOSE_WINDOW)); |
| 343 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); | 343 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); |
| 344 ASSERT_EQ(1, window_count); | 344 ASSERT_EQ(1, window_count); |
| 345 | 345 |
| 346 // Verify that the regular window does not have a download shelf. | 346 // Verify that the regular window does not have a download shelf. |
| 347 EXPECT_TRUE(browser->IsShelfVisible(&is_shelf_visible)); | 347 EXPECT_TRUE(browser->IsShelfVisible(&is_shelf_visible)); |
| 348 EXPECT_FALSE(is_shelf_visible); | 348 EXPECT_FALSE(is_shelf_visible); |
| 349 | 349 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 378 ASSERT_EQ(1, window_count); | 378 ASSERT_EQ(1, window_count); |
| 379 EXPECT_EQ(1, GetTabCount()); | 379 EXPECT_EQ(1, GetTabCount()); |
| 380 | 380 |
| 381 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); | 381 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); |
| 382 ASSERT_TRUE(tab_proxy.get()); | 382 ASSERT_TRUE(tab_proxy.get()); |
| 383 | 383 |
| 384 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 384 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
| 385 ASSERT_TRUE(tab_proxy->NavigateToURLAsyncWithDisposition( | 385 ASSERT_TRUE(tab_proxy->NavigateToURLAsyncWithDisposition( |
| 386 URLRequestMockHTTPJob::GetMockUrl(file), | 386 URLRequestMockHTTPJob::GetMockUrl(file), |
| 387 NEW_BACKGROUND_TAB)); | 387 NEW_BACKGROUND_TAB)); |
| 388 |
| 388 // When the download starts, we should still have one tab. | 389 // When the download starts, we should still have one tab. |
| 389 ASSERT_TRUE(WaitForDownloadShelfVisible(browser)); | 390 ASSERT_TRUE(browser->WaitForDownloadShelfVisibilityChange(true)); |
| 390 EXPECT_EQ(1, GetTabCount()); | 391 EXPECT_EQ(1, GetTabCount()); |
| 391 | 392 |
| 392 CheckDownload(file); | 393 CheckDownload(file); |
| 393 } | 394 } |
| 394 | 395 |
| 395 // Flaky, see http://crbug.com/43066 | 396 // Flaky, see http://crbug.com/43066 |
| 396 TEST_F(DownloadTest, FLAKY_DontCloseNewTab2) { | 397 TEST_F(DownloadTest, FLAKY_DontCloseNewTab2) { |
| 397 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 398 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 398 ASSERT_TRUE(browser.get()); | 399 ASSERT_TRUE(browser.get()); |
| 399 int window_count = 0; | 400 int window_count = 0; |
| 400 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); | 401 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); |
| 401 ASSERT_EQ(1, window_count); | 402 ASSERT_EQ(1, window_count); |
| 402 EXPECT_EQ(1, GetTabCount()); | 403 EXPECT_EQ(1, GetTabCount()); |
| 403 | 404 |
| 404 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); | 405 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); |
| 405 ASSERT_TRUE(tab_proxy.get()); | 406 ASSERT_TRUE(tab_proxy.get()); |
| 406 | 407 |
| 407 ASSERT_TRUE(tab_proxy->NavigateToURL(URLRequestMockHTTPJob::GetMockUrl( | 408 ASSERT_TRUE(tab_proxy->NavigateToURL(URLRequestMockHTTPJob::GetMockUrl( |
| 408 FilePath(FILE_PATH_LITERAL("download_page1.html"))))); | 409 FilePath(FILE_PATH_LITERAL("download_page1.html"))))); |
| 409 | 410 |
| 410 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 411 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
| 411 ASSERT_TRUE(tab_proxy->NavigateToURLAsync(GURL("javascript:openNew()"))); | 412 ASSERT_TRUE(tab_proxy->NavigateToURLAsync(GURL("javascript:openNew()"))); |
| 412 | 413 |
| 413 ASSERT_TRUE(WaitForDownloadShelfVisible(browser)); | 414 ASSERT_TRUE(browser->WaitForDownloadShelfVisibilityChange(true)); |
| 414 EXPECT_EQ(2, GetTabCount()); | 415 EXPECT_EQ(2, GetTabCount()); |
| 415 | 416 |
| 416 CheckDownload(file); | 417 CheckDownload(file); |
| 417 } | 418 } |
| 418 | 419 |
| 419 // Flaky, see http://crbug.com/43066 | 420 // Flaky, see http://crbug.com/43066 |
| 420 TEST_F(DownloadTest, FLAKY_DontCloseNewTab3) { | 421 TEST_F(DownloadTest, FLAKY_DontCloseNewTab3) { |
| 421 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 422 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 422 ASSERT_TRUE(browser.get()); | 423 ASSERT_TRUE(browser.get()); |
| 423 int window_count = 0; | 424 int window_count = 0; |
| 424 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); | 425 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); |
| 425 ASSERT_EQ(1, window_count); | 426 ASSERT_EQ(1, window_count); |
| 426 EXPECT_EQ(1, GetTabCount()); | 427 EXPECT_EQ(1, GetTabCount()); |
| 427 | 428 |
| 428 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); | 429 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); |
| 429 ASSERT_TRUE(tab_proxy.get()); | 430 ASSERT_TRUE(tab_proxy.get()); |
| 430 | 431 |
| 431 ASSERT_TRUE(tab_proxy->NavigateToURL(URLRequestMockHTTPJob::GetMockUrl( | 432 ASSERT_TRUE(tab_proxy->NavigateToURL(URLRequestMockHTTPJob::GetMockUrl( |
| 432 FilePath(FILE_PATH_LITERAL("download_page2.html"))))); | 433 FilePath(FILE_PATH_LITERAL("download_page2.html"))))); |
| 433 | 434 |
| 434 ASSERT_TRUE(tab_proxy->NavigateToURLAsync(GURL("javascript:openNew()"))); | 435 ASSERT_TRUE(tab_proxy->NavigateToURLAsync(GURL("javascript:openNew()"))); |
| 435 | 436 |
| 436 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 437 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
| 437 ASSERT_TRUE(tab_proxy->NavigateToURLAsync( | 438 ASSERT_TRUE(tab_proxy->NavigateToURLAsync( |
| 438 URLRequestMockHTTPJob::GetMockUrl(file))); | 439 URLRequestMockHTTPJob::GetMockUrl(file))); |
| 439 | 440 |
| 440 ASSERT_TRUE(WaitForDownloadShelfVisible(browser)); | 441 ASSERT_TRUE(browser->WaitForDownloadShelfVisibilityChange(true)); |
| 441 EXPECT_EQ(2, GetTabCount()); | 442 EXPECT_EQ(2, GetTabCount()); |
| 442 | 443 |
| 443 CheckDownload(file); | 444 CheckDownload(file); |
| 444 } | 445 } |
| 445 | 446 |
| 446 // Flaky, see http://crbug.com/43066 | 447 // Flaky, see http://crbug.com/43066 |
| 447 TEST_F(DownloadTest, FLAKY_CloseNewTab2) { | 448 TEST_F(DownloadTest, FLAKY_CloseNewTab2) { |
| 448 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 449 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 449 ASSERT_TRUE(browser.get()); | 450 ASSERT_TRUE(browser.get()); |
| 450 int window_count = 0; | 451 int window_count = 0; |
| 451 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); | 452 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); |
| 452 ASSERT_EQ(1, window_count); | 453 ASSERT_EQ(1, window_count); |
| 453 EXPECT_EQ(1, GetTabCount()); | 454 EXPECT_EQ(1, GetTabCount()); |
| 454 | 455 |
| 455 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); | 456 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); |
| 456 ASSERT_TRUE(tab_proxy.get()); | 457 ASSERT_TRUE(tab_proxy.get()); |
| 457 | 458 |
| 458 ASSERT_TRUE(tab_proxy->NavigateToURL(URLRequestMockHTTPJob::GetMockUrl( | 459 ASSERT_TRUE(tab_proxy->NavigateToURL(URLRequestMockHTTPJob::GetMockUrl( |
| 459 FilePath(FILE_PATH_LITERAL("download_page3.html"))))); | 460 FilePath(FILE_PATH_LITERAL("download_page3.html"))))); |
| 460 | 461 |
| 461 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 462 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
| 462 ASSERT_TRUE(tab_proxy->NavigateToURLAsync(GURL("javascript:openNew()"))); | 463 ASSERT_TRUE(tab_proxy->NavigateToURLAsync(GURL("javascript:openNew()"))); |
| 463 | 464 |
| 464 ASSERT_TRUE(WaitForDownloadShelfVisible(browser)); | 465 ASSERT_TRUE(browser->WaitForDownloadShelfVisibilityChange(true)); |
| 465 EXPECT_EQ(1, GetTabCount()); | 466 EXPECT_EQ(1, GetTabCount()); |
| 466 | 467 |
| 467 CheckDownload(file); | 468 CheckDownload(file); |
| 468 } | 469 } |
| 469 | 470 |
| 470 // Flaky, see http://crbug.com/43066 | 471 // Flaky, see http://crbug.com/43066 |
| 471 TEST_F(DownloadTest, FLAKY_CloseNewTab3) { | 472 TEST_F(DownloadTest, FLAKY_CloseNewTab3) { |
| 472 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 473 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 473 ASSERT_TRUE(browser.get()); | 474 ASSERT_TRUE(browser.get()); |
| 474 int window_count = 0; | 475 int window_count = 0; |
| 475 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); | 476 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); |
| 476 ASSERT_EQ(1, window_count); | 477 ASSERT_EQ(1, window_count); |
| 477 EXPECT_EQ(1, GetTabCount()); | 478 EXPECT_EQ(1, GetTabCount()); |
| 478 | 479 |
| 479 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); | 480 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); |
| 480 ASSERT_TRUE(tab_proxy.get()); | 481 ASSERT_TRUE(tab_proxy.get()); |
| 481 | 482 |
| 482 ASSERT_TRUE(tab_proxy->NavigateToURL(URLRequestMockHTTPJob::GetMockUrl( | 483 ASSERT_TRUE(tab_proxy->NavigateToURL(URLRequestMockHTTPJob::GetMockUrl( |
| 483 FilePath(FILE_PATH_LITERAL("download_page4.html"))))); | 484 FilePath(FILE_PATH_LITERAL("download_page4.html"))))); |
| 484 | 485 |
| 485 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 486 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
| 486 ASSERT_TRUE(tab_proxy->NavigateToURLAsync( | 487 ASSERT_TRUE(tab_proxy->NavigateToURLAsync( |
| 487 GURL("javascript:document.getElementById('form').submit()"))); | 488 GURL("javascript:document.getElementById('form').submit()"))); |
| 488 | 489 |
| 489 ASSERT_TRUE(WaitForDownloadShelfVisible(browser)); | 490 ASSERT_TRUE(browser->WaitForDownloadShelfVisibilityChange(true)); |
| 490 EXPECT_EQ(1, GetTabCount()); | 491 EXPECT_EQ(1, GetTabCount()); |
| 491 | 492 |
| 492 CheckDownload(file); | 493 CheckDownload(file); |
| 493 } | 494 } |
| 494 | 495 |
| 495 // Regression test for http://crbug.com/44454 | 496 // Regression test for http://crbug.com/44454 |
| 496 TEST_F(DownloadTest, NewWindow) { | 497 TEST_F(DownloadTest, NewWindow) { |
| 497 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 498 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 498 ASSERT_TRUE(browser.get()); | 499 ASSERT_TRUE(browser.get()); |
| 499 int window_count = 0; | 500 int window_count = 0; |
| 500 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); | 501 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); |
| 501 ASSERT_EQ(1, window_count); | 502 ASSERT_EQ(1, window_count); |
| 502 EXPECT_EQ(1, GetTabCount()); | 503 EXPECT_EQ(1, GetTabCount()); |
| 503 | 504 |
| 504 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); | 505 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); |
| 505 ASSERT_TRUE(tab_proxy.get()); | 506 ASSERT_TRUE(tab_proxy.get()); |
| 506 | 507 |
| 507 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 508 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
| 508 ASSERT_TRUE(tab_proxy->NavigateToURLAsyncWithDisposition( | 509 ASSERT_TRUE(tab_proxy->NavigateToURLAsyncWithDisposition( |
| 509 URLRequestMockHTTPJob::GetMockUrl(file), NEW_WINDOW)); | 510 URLRequestMockHTTPJob::GetMockUrl(file), NEW_WINDOW)); |
| 510 | 511 |
| 511 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(1)); | 512 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(1)); |
| 512 | 513 |
| 513 CheckDownload(file); | 514 CheckDownload(file); |
| 514 } | 515 } |
| 515 | 516 |
| 516 } // namespace | 517 } // namespace |
| OLD | NEW |