| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 5 #include <string> |
| 6 #include <set> | 6 #include <set> |
| 7 | 7 |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/i18n/number_formatting.h" | 9 #include "base/i18n/number_formatting.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "chrome/browser/download/mock_download_manager.h" | 26 #include "chrome/browser/download/mock_download_manager.h" |
| 27 #include "chrome/browser/prefs/pref_service.h" | 27 #include "chrome/browser/prefs/pref_service.h" |
| 28 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/test/testing_profile.h" | 29 #include "chrome/test/testing_profile.h" |
| 30 #include "content/browser/browser_thread.h" | 30 #include "content/browser/browser_thread.h" |
| 31 #include "grit/generated_resources.h" | 31 #include "grit/generated_resources.h" |
| 32 #include "testing/gmock/include/gmock/gmock.h" | 32 #include "testing/gmock/include/gmock/gmock.h" |
| 33 #include "testing/gmock_mutant.h" | 33 #include "testing/gmock_mutant.h" |
| 34 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
| 35 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
| 36 #include "ui/base/text/bytes_formatting.h" |
| 36 | 37 |
| 37 class DownloadManagerTest : public testing::Test { | 38 class DownloadManagerTest : public testing::Test { |
| 38 public: | 39 public: |
| 39 static const char* kTestData; | 40 static const char* kTestData; |
| 40 static const size_t kTestDataLen; | 41 static const size_t kTestDataLen; |
| 41 | 42 |
| 42 DownloadManagerTest() | 43 DownloadManagerTest() |
| 43 : profile_(new TestingProfile()), | 44 : profile_(new TestingProfile()), |
| 44 download_manager_(new MockDownloadManager(&download_status_updater_)), | 45 download_manager_(new MockDownloadManager(&download_status_updater_)), |
| 45 ui_thread_(BrowserThread::UI, &message_loop_), | 46 ui_thread_(BrowserThread::UI, &message_loop_), |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 EXPECT_TRUE(GetActiveDownloadItem(0) == NULL); | 441 EXPECT_TRUE(GetActiveDownloadItem(0) == NULL); |
| 441 EXPECT_TRUE(observer->hit_state(DownloadItem::IN_PROGRESS)); | 442 EXPECT_TRUE(observer->hit_state(DownloadItem::IN_PROGRESS)); |
| 442 EXPECT_TRUE(observer->hit_state(DownloadItem::INTERRUPTED)); | 443 EXPECT_TRUE(observer->hit_state(DownloadItem::INTERRUPTED)); |
| 443 EXPECT_FALSE(observer->hit_state(DownloadItem::COMPLETE)); | 444 EXPECT_FALSE(observer->hit_state(DownloadItem::COMPLETE)); |
| 444 EXPECT_FALSE(observer->hit_state(DownloadItem::CANCELLED)); | 445 EXPECT_FALSE(observer->hit_state(DownloadItem::CANCELLED)); |
| 445 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING)); | 446 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING)); |
| 446 EXPECT_TRUE(observer->was_updated()); | 447 EXPECT_TRUE(observer->was_updated()); |
| 447 EXPECT_FALSE(observer->was_opened()); | 448 EXPECT_FALSE(observer->was_opened()); |
| 448 EXPECT_FALSE(download->file_externally_removed()); | 449 EXPECT_FALSE(download->file_externally_removed()); |
| 449 EXPECT_EQ(DownloadItem::INTERRUPTED, download->state()); | 450 EXPECT_EQ(DownloadItem::INTERRUPTED, download->state()); |
| 450 DataUnits amount_units = GetByteDisplayUnits(kTestDataLen); | 451 ui::DataUnits amount_units = ui::GetByteDisplayUnits(kTestDataLen); |
| 451 const string16 simple_size = FormatBytes(error_size, amount_units, false); | 452 const string16 simple_size = ui::FormatBytes(error_size, amount_units, false); |
| 452 string16 simple_total = base::i18n::GetDisplayStringInLTRDirectionality( | 453 string16 simple_total = base::i18n::GetDisplayStringInLTRDirectionality( |
| 453 FormatBytes(kTestDataLen, amount_units, true)); | 454 ui::FormatBytes(kTestDataLen, amount_units, true)); |
| 454 EXPECT_EQ(download_item_model->GetStatusText(), | 455 EXPECT_EQ(download_item_model->GetStatusText(), |
| 455 l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_INTERRUPTED, | 456 l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_INTERRUPTED, |
| 456 simple_size, | 457 simple_size, |
| 457 simple_total)); | 458 simple_total)); |
| 458 | 459 |
| 459 download->Cancel(true); | 460 download->Cancel(true); |
| 460 | 461 |
| 461 EXPECT_TRUE(observer->hit_state(DownloadItem::IN_PROGRESS)); | 462 EXPECT_TRUE(observer->hit_state(DownloadItem::IN_PROGRESS)); |
| 462 EXPECT_TRUE(observer->hit_state(DownloadItem::INTERRUPTED)); | 463 EXPECT_TRUE(observer->hit_state(DownloadItem::INTERRUPTED)); |
| 463 EXPECT_FALSE(observer->hit_state(DownloadItem::COMPLETE)); | 464 EXPECT_FALSE(observer->hit_state(DownloadItem::COMPLETE)); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING)); | 707 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING)); |
| 707 EXPECT_TRUE(observer->was_updated()); | 708 EXPECT_TRUE(observer->was_updated()); |
| 708 EXPECT_FALSE(observer->was_opened()); | 709 EXPECT_FALSE(observer->was_opened()); |
| 709 EXPECT_TRUE(download->file_externally_removed()); | 710 EXPECT_TRUE(download->file_externally_removed()); |
| 710 EXPECT_EQ(DownloadItem::COMPLETE, download->state()); | 711 EXPECT_EQ(DownloadItem::COMPLETE, download->state()); |
| 711 EXPECT_EQ(download_item_model->GetStatusText(), | 712 EXPECT_EQ(download_item_model->GetStatusText(), |
| 712 l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_REMOVED)); | 713 l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_REMOVED)); |
| 713 | 714 |
| 714 EXPECT_FALSE(file_util::PathExists(new_path)); | 715 EXPECT_FALSE(file_util::PathExists(new_path)); |
| 715 } | 716 } |
| OLD | NEW |