| 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 <map> | 5 #include <map> |
| 6 #include <memory> | 6 #include <memory> |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 const base::string16& display_source) override { | 145 const base::string16& display_source) override { |
| 146 NOTREACHED(); | 146 NOTREACHED(); |
| 147 return nullptr; | 147 return nullptr; |
| 148 } | 148 } |
| 149 bool HasClickedListener(const std::string& notification_id) override { | 149 bool HasClickedListener(const std::string& notification_id) override { |
| 150 return false; | 150 return false; |
| 151 } | 151 } |
| 152 void ClickOnNotificationButton(const std::string& notification_id, | 152 void ClickOnNotificationButton(const std::string& notification_id, |
| 153 int button_index) override {} | 153 int button_index) override {} |
| 154 void ClickOnSettingsButton(const std::string& notification_id) override {} | 154 void ClickOnSettingsButton(const std::string& notification_id) override {} |
| 155 void UpdateNotificationSize(const std::string& notification_id) override; |
| 155 | 156 |
| 156 // Widget to host a MessageListView. | 157 // Widget to host a MessageListView. |
| 157 std::unique_ptr<views::Widget> widget_; | 158 std::unique_ptr<views::Widget> widget_; |
| 158 // MessageListView to be tested. | 159 // MessageListView to be tested. |
| 159 std::unique_ptr<MessageListView> message_list_view_; | 160 std::unique_ptr<MessageListView> message_list_view_; |
| 160 | 161 |
| 161 DISALLOW_COPY_AND_ASSIGN(MessageListViewTest); | 162 DISALLOW_COPY_AND_ASSIGN(MessageListViewTest); |
| 162 }; | 163 }; |
| 163 | 164 |
| 165 void MessageListViewTest::UpdateNotificationSize( |
| 166 const std::string& notification_id) { |
| 167 // For this test, this method should not be invoked. |
| 168 NOTREACHED(); |
| 169 } |
| 170 |
| 164 /* Unit tests *****************************************************************/ | 171 /* Unit tests *****************************************************************/ |
| 165 | 172 |
| 166 TEST_F(MessageListViewTest, AddNotification) { | 173 TEST_F(MessageListViewTest, AddNotification) { |
| 167 // Create a dummy notification. | 174 // Create a dummy notification. |
| 168 auto notification_view = CreateNotificationView( | 175 auto notification_view = CreateNotificationView( |
| 169 Notification(NOTIFICATION_TYPE_SIMPLE, std::string(kNotificationId1), | 176 Notification(NOTIFICATION_TYPE_SIMPLE, std::string(kNotificationId1), |
| 170 base::UTF8ToUTF16("title"), base::UTF8ToUTF16("message1"), | 177 base::UTF8ToUTF16("title"), base::UTF8ToUTF16("message1"), |
| 171 gfx::Image(), base::UTF8ToUTF16("display source"), GURL(), | 178 gfx::Image(), base::UTF8ToUTF16("display source"), GURL(), |
| 172 NotifierId(NotifierId::APPLICATION, "extension_id"), | 179 NotifierId(NotifierId::APPLICATION, "extension_id"), |
| 173 message_center::RichNotificationData(), nullptr)); | 180 message_center::RichNotificationData(), nullptr)); |
| 174 | 181 |
| 175 EXPECT_EQ(0, message_list_view()->child_count()); | 182 EXPECT_EQ(0, message_list_view()->child_count()); |
| 176 EXPECT_FALSE(message_list_view()->Contains(notification_view)); | 183 EXPECT_FALSE(message_list_view()->Contains(notification_view)); |
| 177 | 184 |
| 178 // Add a notification. | 185 // Add a notification. |
| 179 message_list_view()->AddNotificationAt(notification_view, 0); | 186 message_list_view()->AddNotificationAt(notification_view, 0); |
| 180 | 187 |
| 181 EXPECT_EQ(1, message_list_view()->child_count()); | 188 EXPECT_EQ(1, message_list_view()->child_count()); |
| 182 EXPECT_TRUE(message_list_view()->Contains(notification_view)); | 189 EXPECT_TRUE(message_list_view()->Contains(notification_view)); |
| 183 } | 190 } |
| 184 | 191 |
| 185 } // namespace | 192 } // namespace |
| OLD | NEW |