| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 2995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3006 base::PlatformFile fd = base::CreatePlatformFile( | 3006 base::PlatformFile fd = base::CreatePlatformFile( |
| 3007 file_path, flags, &created, &error); | 3007 file_path, flags, &created, &error); |
| 3008 int64 size = 1 << 29; | 3008 int64 size = 1 << 29; |
| 3009 EXPECT_EQ(size, base::SeekPlatformFile( | 3009 EXPECT_EQ(size, base::SeekPlatformFile( |
| 3010 fd, base::PLATFORM_FILE_FROM_BEGIN, size)); | 3010 fd, base::PLATFORM_FILE_FROM_BEGIN, size)); |
| 3011 EXPECT_EQ(1, base::WritePlatformFileAtCurrentPos(fd, "a", 1)); | 3011 EXPECT_EQ(1, base::WritePlatformFileAtCurrentPos(fd, "a", 1)); |
| 3012 EXPECT_TRUE(base::ClosePlatformFile(fd)); | 3012 EXPECT_TRUE(base::ClosePlatformFile(fd)); |
| 3013 fd = base::kInvalidPlatformFileValue; | 3013 fd = base::kInvalidPlatformFileValue; |
| 3014 #if defined(OS_POSIX) | 3014 #if defined(OS_POSIX) |
| 3015 // Make it readable by chronos on chromeos | 3015 // Make it readable by chronos on chromeos |
| 3016 file_util::SetPosixFilePermissions(file_path, 0755); | 3016 base::SetPosixFilePermissions(file_path, 0755); |
| 3017 #endif | 3017 #endif |
| 3018 | 3018 |
| 3019 // Ensure that we have enough disk space. | 3019 // Ensure that we have enough disk space. |
| 3020 int64 free_space = base::SysInfo::AmountOfFreeDiskSpace( | 3020 int64 free_space = base::SysInfo::AmountOfFreeDiskSpace( |
| 3021 GetDownloadDirectory(browser())); | 3021 GetDownloadDirectory(browser())); |
| 3022 ASSERT_LE(size, free_space) << "Not enough disk space to download. Got " | 3022 ASSERT_LE(size, free_space) << "Not enough disk space to download. Got " |
| 3023 << free_space; | 3023 << free_space; |
| 3024 GURL file_url(net::FilePathToFileURL(file_path)); | 3024 GURL file_url(net::FilePathToFileURL(file_path)); |
| 3025 scoped_ptr<content::DownloadTestObserver> progress_waiter( | 3025 scoped_ptr<content::DownloadTestObserver> progress_waiter( |
| 3026 CreateInProgressWaiter(browser(), 1)); | 3026 CreateInProgressWaiter(browser(), 1)); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3250 | 3250 |
| 3251 // No errors this time. The download should complete successfully. | 3251 // No errors this time. The download should complete successfully. |
| 3252 EXPECT_FALSE(completion_observer->IsFinished()); | 3252 EXPECT_FALSE(completion_observer->IsFinished()); |
| 3253 completion_observer->StartObserving(); | 3253 completion_observer->StartObserving(); |
| 3254 download->Resume(); | 3254 download->Resume(); |
| 3255 completion_observer->WaitForFinished(); | 3255 completion_observer->WaitForFinished(); |
| 3256 EXPECT_EQ(DownloadItem::COMPLETE, download->GetState()); | 3256 EXPECT_EQ(DownloadItem::COMPLETE, download->GetState()); |
| 3257 | 3257 |
| 3258 EXPECT_FALSE(DidShowFileChooser()); | 3258 EXPECT_FALSE(DidShowFileChooser()); |
| 3259 } | 3259 } |
| OLD | NEW |