OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/chromeos/ui/low_disk_notification.h" | 5 #include "chrome/browser/chromeos/ui/low_disk_notification.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/threading/platform_thread.h" | 9 #include "base/threading/platform_thread.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 namespace chromeos { | 29 namespace chromeos { |
30 | 30 |
31 class LowDiskNotificationTest : public testing::Test, | 31 class LowDiskNotificationTest : public testing::Test, |
32 public message_center::FakeMessageCenter { | 32 public message_center::FakeMessageCenter { |
33 public: | 33 public: |
34 LowDiskNotificationTest() {} | 34 LowDiskNotificationTest() {} |
35 | 35 |
36 void SetUp() override { | 36 void SetUp() override { |
37 DBusThreadManager::GetSetterForTesting()->SetCryptohomeClient( | 37 DBusThreadManager::GetSetterForTesting()->SetCryptohomeClient( |
38 std::unique_ptr<CryptohomeClient>(new FakeCryptohomeClient)); | 38 std::unique_ptr<CryptohomeClient>(new FakeCryptohomeClient)); |
39 message_center::MessageCenter::Initialize(); | |
40 low_disk_notification_.reset(new LowDiskNotification()); | 39 low_disk_notification_.reset(new LowDiskNotification()); |
41 low_disk_notification_->SetMessageCenterForTest(this); | 40 low_disk_notification_->SetMessageCenterForTest(this); |
42 low_disk_notification_->SetNotificationIntervalForTest( | 41 low_disk_notification_->SetNotificationIntervalForTest( |
43 base::TimeDelta::FromMilliseconds(10)); | 42 base::TimeDelta::FromMilliseconds(10)); |
44 notification_count_ = 0; | 43 notification_count_ = 0; |
45 } | 44 } |
46 | 45 |
47 void TearDown() override { | 46 void TearDown() override { |
48 low_disk_notification_.reset(); | 47 low_disk_notification_.reset(); |
49 last_notification_.reset(); | 48 last_notification_.reset(); |
50 message_center::MessageCenter::Shutdown(); | |
51 DBusThreadManager::Shutdown(); | 49 DBusThreadManager::Shutdown(); |
52 } | 50 } |
53 | 51 |
54 void AddNotification( | 52 void AddNotification( |
55 std::unique_ptr<message_center::Notification> notification) override { | 53 std::unique_ptr<message_center::Notification> notification) override { |
56 last_notification_ = std::move(notification); | 54 last_notification_ = std::move(notification); |
57 notification_count_++; | 55 notification_count_++; |
58 } | 56 } |
59 | 57 |
60 protected: | 58 protected: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 95 } |
98 | 96 |
99 TEST_F(LowDiskNotificationTest, MediumNotificationsAreNotShownAfterThrottling) { | 97 TEST_F(LowDiskNotificationTest, MediumNotificationsAreNotShownAfterThrottling) { |
100 low_disk_notification_->OnLowDiskSpace(kMediumNotification); | 98 low_disk_notification_->OnLowDiskSpace(kMediumNotification); |
101 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(15)); | 99 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(15)); |
102 low_disk_notification_->OnLowDiskSpace(kMediumNotification); | 100 low_disk_notification_->OnLowDiskSpace(kMediumNotification); |
103 EXPECT_EQ(1, notification_count_); | 101 EXPECT_EQ(1, notification_count_); |
104 } | 102 } |
105 | 103 |
106 } // namespace chromeos | 104 } // namespace chromeos |
OLD | NEW |