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 "ui/message_center/notification_list.h" | 5 #include "ui/message_center/notification_list.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/i18n/time_formatting.h" | 8 #include "base/i18n/time_formatting.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "ui/message_center/notification_types.h" | 13 #include "ui/message_center/notification_types.h" |
14 | 14 |
15 namespace message_center { | 15 namespace message_center { |
16 namespace { | 16 namespace { |
17 | 17 |
18 class MockNotificationListDelegate : public NotificationList::Delegate { | 18 class MockNotificationListDelegate : public NotificationList::Delegate { |
19 public: | 19 public: |
20 MockNotificationListDelegate() : send_remove_count_(0) {} | 20 MockNotificationListDelegate() : send_remove_count_(0) {} |
21 virtual ~MockNotificationListDelegate() {} | 21 virtual ~MockNotificationListDelegate() {} |
22 | 22 |
23 size_t GetSendRemoveCountAndReset() { | 23 size_t GetSendRemoveCountAndReset() { |
24 size_t result = send_remove_count_; | 24 size_t result = send_remove_count_; |
25 send_remove_count_ = 0; | 25 send_remove_count_ = 0; |
26 return result; | 26 return result; |
27 } | 27 } |
28 | 28 |
29 private: | 29 private: |
30 // NotificationList::Delegate overrides: | 30 // Overridden from NotificationList::Delegate: |
31 virtual void SendRemoveNotification(const std::string& id, | 31 virtual void SendRemoveNotification(const std::string& id, |
32 bool by_user) OVERRIDE { | 32 bool by_user) OVERRIDE { |
33 send_remove_count_++; | 33 send_remove_count_++; |
34 } | 34 } |
35 | 35 |
36 virtual void SendRemoveAllNotifications(bool by_user) OVERRIDE { | |
37 } | |
38 | |
39 virtual void DisableNotificationByExtension(const std::string& id) OVERRIDE { | |
40 } | |
41 | |
42 virtual void DisableNotificationByUrl(const std::string& id) OVERRIDE { | |
43 } | |
44 | |
45 virtual void ShowNotificationSettings(const std::string& id) OVERRIDE { | |
46 } | |
47 | |
48 virtual void ShowNotificationSettingsDialog( | |
49 gfx::NativeView context) OVERRIDE { | |
50 } | |
51 | |
52 virtual void OnNotificationClicked(const std::string& id) OVERRIDE { | |
53 } | |
54 | |
55 virtual void OnQuietModeChanged(bool quiet_mode) OVERRIDE { | 36 virtual void OnQuietModeChanged(bool quiet_mode) OVERRIDE { |
56 } | 37 } |
57 | 38 |
58 virtual void OnButtonClicked(const std::string& id, | |
59 int button_index) OVERRIDE { | |
60 } | |
61 | |
62 virtual NotificationList* GetNotificationList() OVERRIDE { | |
63 return NULL; | |
64 } | |
65 | |
66 size_t send_remove_count_; | 39 size_t send_remove_count_; |
67 DISALLOW_COPY_AND_ASSIGN(MockNotificationListDelegate); | 40 DISALLOW_COPY_AND_ASSIGN(MockNotificationListDelegate); |
68 }; | 41 }; |
69 | 42 |
70 class NotificationListTest : public testing::Test { | 43 class NotificationListTest : public testing::Test { |
71 public: | 44 public: |
72 NotificationListTest() {} | 45 NotificationListTest() {} |
73 virtual ~NotificationListTest() {} | 46 virtual ~NotificationListTest() {} |
74 | 47 |
75 virtual void SetUp() { | 48 virtual void SetUp() { |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 | 399 |
427 notification_list()->SetQuietMode(false); | 400 notification_list()->SetQuietMode(false); |
428 AddNotification(NULL); | 401 AddNotification(NULL); |
429 EXPECT_EQ(4u, notification_list()->NotificationCount()); | 402 EXPECT_EQ(4u, notification_list()->NotificationCount()); |
430 EXPECT_EQ(1u, GetPopupCounts()); | 403 EXPECT_EQ(1u, GetPopupCounts()); |
431 | 404 |
432 // TODO(mukai): Add test of quiet mode with expiration. | 405 // TODO(mukai): Add test of quiet mode with expiration. |
433 } | 406 } |
434 | 407 |
435 } // namespace message_center | 408 } // namespace message_center |
OLD | NEW |