| 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "base/stl_util.h" | 6 #include "base/stl_util.h" |
| 7 #include "base/threading/thread.h" | 7 #include "base/threading/thread.h" |
| 8 #include "content/browser/download/download_create_info.h" | 8 #include "content/browser/download/download_create_info.h" |
| 9 #include "content/browser/download/download_item_impl.h" | 9 #include "content/browser/download/download_item_impl.h" |
| 10 #include "content/browser/download/download_request_handle.h" | 10 #include "content/browser/download/download_request_handle.h" |
| 11 #include "content/browser/download/interrupt_reasons.h" | |
| 12 #include "content/public/browser/download_id.h" | 11 #include "content/public/browser/download_id.h" |
| 12 #include "content/public/browser/download_interrupt_reasons.h" |
| 13 #include "content/test/mock_download_item.h" | 13 #include "content/test/mock_download_item.h" |
| 14 #include "content/test/test_browser_thread.h" | 14 #include "content/test/test_browser_thread.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 17 |
| 18 using content::BrowserThread; | 18 using content::BrowserThread; |
| 19 using content::DownloadId; | 19 using content::DownloadId; |
| 20 using content::DownloadItem; | 20 using content::DownloadItem; |
| 21 using content::DownloadManager; | 21 using content::DownloadManager; |
| 22 using content::MockDownloadItem; | 22 using content::MockDownloadItem; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 MockObserver observer(item); | 191 MockObserver observer(item); |
| 192 | 192 |
| 193 item->OnDownloadedFileRemoved(); | 193 item->OnDownloadedFileRemoved(); |
| 194 ASSERT_TRUE(observer.CheckUpdated()); | 194 ASSERT_TRUE(observer.CheckUpdated()); |
| 195 } | 195 } |
| 196 | 196 |
| 197 TEST_F(DownloadItemTest, NotificationAfterInterrupted) { | 197 TEST_F(DownloadItemTest, NotificationAfterInterrupted) { |
| 198 DownloadItem* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); | 198 DownloadItem* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); |
| 199 MockObserver observer(item); | 199 MockObserver observer(item); |
| 200 | 200 |
| 201 item->Interrupted(kDownloadChunkSize, "", DOWNLOAD_INTERRUPT_REASON_NONE); | 201 item->Interrupted(kDownloadChunkSize, "", |
| 202 content::DOWNLOAD_INTERRUPT_REASON_NONE); |
| 202 ASSERT_TRUE(observer.CheckUpdated()); | 203 ASSERT_TRUE(observer.CheckUpdated()); |
| 203 } | 204 } |
| 204 | 205 |
| 205 TEST_F(DownloadItemTest, NotificationAfterDelete) { | 206 TEST_F(DownloadItemTest, NotificationAfterDelete) { |
| 206 DownloadItem* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); | 207 DownloadItem* item = CreateDownloadItem(DownloadItem::IN_PROGRESS); |
| 207 MockObserver observer(item); | 208 MockObserver observer(item); |
| 208 | 209 |
| 209 item->Delete(DownloadItem::DELETE_DUE_TO_BROWSER_SHUTDOWN); | 210 item->Delete(DownloadItem::DELETE_DUE_TO_BROWSER_SHUTDOWN); |
| 210 ASSERT_TRUE(observer.CheckUpdated()); | 211 ASSERT_TRUE(observer.CheckUpdated()); |
| 211 } | 212 } |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 item->SetExternalData(&external_data_test_string, test3); | 360 item->SetExternalData(&external_data_test_string, test3); |
| 360 EXPECT_EQ(static_cast<DownloadItem::ExternalData*>(test3), | 361 EXPECT_EQ(static_cast<DownloadItem::ExternalData*>(test3), |
| 361 item->GetExternalData(&external_data_test_string)); | 362 item->GetExternalData(&external_data_test_string)); |
| 362 DestroyDownloadItem(item); | 363 DestroyDownloadItem(item); |
| 363 EXPECT_EQ(3, destructor_called); | 364 EXPECT_EQ(3, destructor_called); |
| 364 } | 365 } |
| 365 | 366 |
| 366 TEST(MockDownloadItem, Compiles) { | 367 TEST(MockDownloadItem, Compiles) { |
| 367 MockDownloadItem mock_item; | 368 MockDownloadItem mock_item; |
| 368 } | 369 } |
| OLD | NEW |