| 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> |
| 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/automation/url_request_mock_http_job.h" | 19 #include "chrome/browser/automation/url_request_mock_http_job.h" |
| 20 #include "chrome/browser/automation/url_request_slow_download_job.h" | 20 #include "chrome/browser/automation/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_LINUX) |
| 31 #define MAYBE_UnknownSize DISABLED_UnknownSize |
| 32 #define MAYBE_IncognitoDownload DISABLED_IncognitoDownload |
| 33 #else |
| 34 #define MAYBE_UnknownSize UnknownSize |
| 35 #define MAYBE_IncognitoDownload IncognitoDownload |
| 36 #endif |
| 37 |
| 30 namespace { | 38 namespace { |
| 31 | 39 |
| 32 const wchar_t kDocRoot[] = L"chrome/test/data"; | 40 const wchar_t kDocRoot[] = L"chrome/test/data"; |
| 33 | 41 |
| 34 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
| 35 // Checks if the volume supports Alternate Data Streams. This is required for | 43 // Checks if the volume supports Alternate Data Streams. This is required for |
| 36 // the Zone Identifier implementation. | 44 // the Zone Identifier implementation. |
| 37 bool VolumeSupportsADS(const std::wstring path) { | 45 bool VolumeSupportsADS(const std::wstring path) { |
| 38 wchar_t drive[MAX_PATH] = {0}; | 46 wchar_t drive[MAX_PATH] = {0}; |
| 39 wcscpy_s(drive, MAX_PATH, path.c_str()); | 47 wcscpy_s(drive, MAX_PATH, path.c_str()); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 EXPECT_TRUE(browser->IsShelfVisible(&shelf_visible)); | 271 EXPECT_TRUE(browser->IsShelfVisible(&shelf_visible)); |
| 264 ASSERT_FALSE(shelf_visible); | 272 ASSERT_FALSE(shelf_visible); |
| 265 } | 273 } |
| 266 | 274 |
| 267 // UnknownSize and KnownSize are tests which depend on | 275 // UnknownSize and KnownSize are tests which depend on |
| 268 // URLRequestSlowDownloadJob to serve content in a certain way. Data will be | 276 // URLRequestSlowDownloadJob to serve content in a certain way. Data will be |
| 269 // sent in two chunks where the first chunk is 35K and the second chunk is 10K. | 277 // sent in two chunks where the first chunk is 35K and the second chunk is 10K. |
| 270 // The test will first attempt to download a file; but the server will "pause" | 278 // The test will first attempt to download a file; but the server will "pause" |
| 271 // in the middle until the server receives a second request for | 279 // in the middle until the server receives a second request for |
| 272 // "download-finish. At that time, the download will finish. | 280 // "download-finish. At that time, the download will finish. |
| 273 TEST_F(DownloadTest, UnknownSize) { | 281 // Flaky on Linux: http://code.google.com/p/chromium/issues/detail?id=14746 |
| 282 TEST_F(DownloadTest, MAYBE_UnknownSize) { |
| 274 GURL url(URLRequestSlowDownloadJob::kUnknownSizeUrl); | 283 GURL url(URLRequestSlowDownloadJob::kUnknownSizeUrl); |
| 275 FilePath filename; | 284 FilePath filename; |
| 276 net::FileURLToFilePath(url, &filename); | 285 net::FileURLToFilePath(url, &filename); |
| 277 filename = filename.BaseName(); | 286 filename = filename.BaseName(); |
| 278 RunSizeTest(url, L"32.0 KB - " + filename.ToWStringHack(), | 287 RunSizeTest(url, L"32.0 KB - " + filename.ToWStringHack(), |
| 279 L"100% - " + filename.ToWStringHack()); | 288 L"100% - " + filename.ToWStringHack()); |
| 280 } | 289 } |
| 281 | 290 |
| 282 // http://b/1158253 | 291 // http://b/1158253 |
| 283 TEST_F(DownloadTest, DISABLED_KnownSize) { | 292 TEST_F(DownloadTest, DISABLED_KnownSize) { |
| 284 GURL url(URLRequestSlowDownloadJob::kKnownSizeUrl); | 293 GURL url(URLRequestSlowDownloadJob::kKnownSizeUrl); |
| 285 FilePath filename; | 294 FilePath filename; |
| 286 net::FileURLToFilePath(url, &filename); | 295 net::FileURLToFilePath(url, &filename); |
| 287 filename = filename.BaseName(); | 296 filename = filename.BaseName(); |
| 288 RunSizeTest(url, L"71% - " + filename.ToWStringHack(), | 297 RunSizeTest(url, L"71% - " + filename.ToWStringHack(), |
| 289 L"100% - " + filename.ToWStringHack()); | 298 L"100% - " + filename.ToWStringHack()); |
| 290 } | 299 } |
| 291 | 300 |
| 292 // Test that when downloading an item in Incognito mode, we don't crash when | 301 // Test that when downloading an item in Incognito mode, we don't crash when |
| 293 // closing the last Incognito window (http://crbug.com/13983). | 302 // closing the last Incognito window (http://crbug.com/13983). |
| 294 TEST_F(DownloadTest, IncognitoDownload) { | 303 TEST_F(DownloadTest, MAYBE_IncognitoDownload) { |
| 295 // Open a regular window and sanity check default values for window / tab | 304 // Open a regular window and sanity check default values for window / tab |
| 296 // count and shelf visibility. | 305 // count and shelf visibility. |
| 297 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 306 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 298 int window_count = 0; | 307 int window_count = 0; |
| 299 automation()->GetBrowserWindowCount(&window_count); | 308 automation()->GetBrowserWindowCount(&window_count); |
| 300 ASSERT_EQ(1, window_count); | 309 ASSERT_EQ(1, window_count); |
| 301 EXPECT_EQ(1, GetTabCount()); | 310 EXPECT_EQ(1, GetTabCount()); |
| 302 bool is_shelf_visible; | 311 bool is_shelf_visible; |
| 303 browser->IsShelfVisible(&is_shelf_visible); | 312 browser->IsShelfVisible(&is_shelf_visible); |
| 304 EXPECT_FALSE(is_shelf_visible); | 313 EXPECT_FALSE(is_shelf_visible); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 325 ASSERT_EQ(1, window_count); | 334 ASSERT_EQ(1, window_count); |
| 326 | 335 |
| 327 // Verify that the regular window does not have a download shelf. | 336 // Verify that the regular window does not have a download shelf. |
| 328 browser->IsShelfVisible(&is_shelf_visible); | 337 browser->IsShelfVisible(&is_shelf_visible); |
| 329 EXPECT_FALSE(is_shelf_visible); | 338 EXPECT_FALSE(is_shelf_visible); |
| 330 | 339 |
| 331 CleanUpDownload(file); | 340 CleanUpDownload(file); |
| 332 } | 341 } |
| 333 | 342 |
| 334 } // namespace | 343 } // namespace |
| OLD | NEW |