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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 } | 1004 } |
1005 | 1005 |
1006 // Test the behavior of DownloadFileManager and DownloadManager in the event | 1006 // Test the behavior of DownloadFileManager and DownloadManager in the event |
1007 // of a file error while writing the download to disk. | 1007 // of a file error while writing the download to disk. |
1008 TEST_F(DownloadManagerTest, MAYBE_DownloadFileErrorTest) { | 1008 TEST_F(DownloadManagerTest, MAYBE_DownloadFileErrorTest) { |
1009 // Create a temporary file and a mock stream. | 1009 // Create a temporary file and a mock stream. |
1010 FilePath path; | 1010 FilePath path; |
1011 ASSERT_TRUE(file_util::CreateTemporaryFile(&path)); | 1011 ASSERT_TRUE(file_util::CreateTemporaryFile(&path)); |
1012 | 1012 |
1013 // This file stream will be used, until the first rename occurs. | 1013 // This file stream will be used, until the first rename occurs. |
1014 net::FileStream* stream = new net::FileStream; | 1014 net::FileStream* stream = new net::FileStream(NULL); |
1015 ASSERT_EQ(0, stream->Open( | 1015 ASSERT_EQ(0, stream->Open( |
1016 path, | 1016 path, |
1017 base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_WRITE)); | 1017 base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_WRITE)); |
1018 | 1018 |
1019 // Normally, the download system takes ownership of info, and is | 1019 // Normally, the download system takes ownership of info, and is |
1020 // responsible for deleting it. In these unit tests, however, we | 1020 // responsible for deleting it. In these unit tests, however, we |
1021 // don't call the function that deletes it, so we do so ourselves. | 1021 // don't call the function that deletes it, so we do so ourselves. |
1022 scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo); | 1022 scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo); |
1023 static const int32 local_id = 0; | 1023 static const int32 local_id = 0; |
1024 info->download_id = DownloadId(kValidIdDomain, local_id); | 1024 info->download_id = DownloadId(kValidIdDomain, local_id); |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1303 EXPECT_FALSE(observer->hit_state(DownloadItem::INTERRUPTED)); | 1303 EXPECT_FALSE(observer->hit_state(DownloadItem::INTERRUPTED)); |
1304 EXPECT_TRUE(observer->hit_state(DownloadItem::COMPLETE)); | 1304 EXPECT_TRUE(observer->hit_state(DownloadItem::COMPLETE)); |
1305 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING)); | 1305 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING)); |
1306 EXPECT_TRUE(observer->was_updated()); | 1306 EXPECT_TRUE(observer->was_updated()); |
1307 EXPECT_FALSE(observer->was_opened()); | 1307 EXPECT_FALSE(observer->was_opened()); |
1308 EXPECT_TRUE(download->GetFileExternallyRemoved()); | 1308 EXPECT_TRUE(download->GetFileExternallyRemoved()); |
1309 EXPECT_EQ(DownloadItem::COMPLETE, download->GetState()); | 1309 EXPECT_EQ(DownloadItem::COMPLETE, download->GetState()); |
1310 | 1310 |
1311 EXPECT_FALSE(file_util::PathExists(new_path)); | 1311 EXPECT_FALSE(file_util::PathExists(new_path)); |
1312 } | 1312 } |
OLD | NEW |