Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: ui/message_center/views/message_center_view_unittest.cc

Issue 1845343005: Makes MaterialDesignController initialization explicit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/views/message_center_view.h" 5 #include "ui/message_center/views/message_center_view.h"
6 6
7 #include <map> 7 #include <map>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/message_center/fake_message_center.h" 15 #include "ui/message_center/fake_message_center.h"
16 #include "ui/message_center/message_center_style.h" 16 #include "ui/message_center/message_center_style.h"
17 #include "ui/message_center/notification.h" 17 #include "ui/message_center/notification.h"
18 #include "ui/message_center/notification_list.h" 18 #include "ui/message_center/notification_list.h"
19 #include "ui/message_center/notification_types.h" 19 #include "ui/message_center/notification_types.h"
20 #include "ui/message_center/views/message_center_button_bar.h" 20 #include "ui/message_center/views/message_center_button_bar.h"
21 #include "ui/message_center/views/message_center_controller.h" 21 #include "ui/message_center/views/message_center_controller.h"
22 #include "ui/message_center/views/message_list_view.h" 22 #include "ui/message_center/views/message_list_view.h"
23 #include "ui/message_center/views/notification_view.h" 23 #include "ui/message_center/views/notification_view.h"
24 #include "ui/views/controls/slide_out_view.h" 24 #include "ui/views/controls/slide_out_view.h"
25 #include "ui/views/test/views_test_base.h"
25 26
26 namespace message_center { 27 namespace message_center {
27 28
28 static const char* kNotificationId1 = "notification id 1"; 29 static const char* kNotificationId1 = "notification id 1";
29 static const char* kNotificationId2 = "notification id 2"; 30 static const char* kNotificationId2 = "notification id 2";
30 31
31 /* Types **********************************************************************/ 32 /* Types **********************************************************************/
32 33
33 enum CallType { 34 enum CallType {
34 GET_PREFERRED_SIZE, 35 GET_PREFERRED_SIZE,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 void RemoveAllNotifications(bool by_user, RemoveType type) override { 106 void RemoveAllNotifications(bool by_user, RemoveType type) override {
106 if (type == RemoveType::NON_PINNED) 107 if (type == RemoveType::NON_PINNED)
107 remove_all_closable_notification_called_ = true; 108 remove_all_closable_notification_called_ = true;
108 } 109 }
109 bool remove_all_closable_notification_called_ = false; 110 bool remove_all_closable_notification_called_ = false;
110 NotificationList::Notifications visible_notifications_; 111 NotificationList::Notifications visible_notifications_;
111 }; 112 };
112 113
113 /* Test fixture ***************************************************************/ 114 /* Test fixture ***************************************************************/
114 115
115 class MessageCenterViewTest : public testing::Test, 116 class MessageCenterViewTest : public views::ViewsTestBase,
116 public MockNotificationView::Test, 117 public MockNotificationView::Test,
117 public MessageCenterController { 118 public MessageCenterController {
118 public: 119 public:
119 MessageCenterViewTest(); 120 MessageCenterViewTest();
120 ~MessageCenterViewTest() override; 121 ~MessageCenterViewTest() override;
121 122
122 void SetUp() override; 123 void SetUp() override;
123 void TearDown() override; 124 void TearDown() override;
124 125
125 MessageCenterView* GetMessageCenterView(); 126 MessageCenterView* GetMessageCenterView();
(...skipping 25 matching lines...) Expand all
151 152
152 void FireOnMouseExitedEvent(); 153 void FireOnMouseExitedEvent();
153 154
154 void LogBounds(int depth, views::View* view); 155 void LogBounds(int depth, views::View* view);
155 156
156 MessageCenterButtonBar* GetButtonBar() const; 157 MessageCenterButtonBar* GetButtonBar() const;
157 158
158 private: 159 private:
159 views::View* MakeParent(views::View* child1, views::View* child2); 160 views::View* MakeParent(views::View* child1, views::View* child2);
160 161
161 base::MessageLoopForUI message_loop_;
162
163 NotificationList::Notifications notifications_; 162 NotificationList::Notifications notifications_;
164 scoped_ptr<MessageCenterView> message_center_view_; 163 scoped_ptr<MessageCenterView> message_center_view_;
165 scoped_ptr<FakeMessageCenterImpl> message_center_; 164 scoped_ptr<FakeMessageCenterImpl> message_center_;
166 std::map<CallType,int> callCounts_; 165 std::map<CallType,int> callCounts_;
167 166
168 DISALLOW_COPY_AND_ASSIGN(MessageCenterViewTest); 167 DISALLOW_COPY_AND_ASSIGN(MessageCenterViewTest);
169 }; 168 };
170 169
171 MessageCenterViewTest::MessageCenterViewTest() { 170 MessageCenterViewTest::MessageCenterViewTest() {
172 } 171 }
173 172
174 MessageCenterViewTest::~MessageCenterViewTest() { 173 MessageCenterViewTest::~MessageCenterViewTest() {
175 } 174 }
176 175
177 void MessageCenterViewTest::SetUp() { 176 void MessageCenterViewTest::SetUp() {
177 views::ViewsTestBase::SetUp();
178 message_center_.reset(new FakeMessageCenterImpl()); 178 message_center_.reset(new FakeMessageCenterImpl());
179 179
180 // Create a dummy notification. 180 // Create a dummy notification.
181 Notification* notification1 = new Notification( 181 Notification* notification1 = new Notification(
182 NOTIFICATION_TYPE_SIMPLE, std::string(kNotificationId1), 182 NOTIFICATION_TYPE_SIMPLE, std::string(kNotificationId1),
183 base::UTF8ToUTF16("title"), base::UTF8ToUTF16("message1"), gfx::Image(), 183 base::UTF8ToUTF16("title"), base::UTF8ToUTF16("message1"), gfx::Image(),
184 base::UTF8ToUTF16("display source"), GURL(), 184 base::UTF8ToUTF16("display source"), GURL(),
185 NotifierId(NotifierId::APPLICATION, "extension_id"), 185 NotifierId(NotifierId::APPLICATION, "extension_id"),
186 message_center::RichNotificationData(), NULL); 186 message_center::RichNotificationData(), NULL);
187 187
(...skipping 18 matching lines...) Expand all
206 message_center_view_->SetNotifications(notifications_); 206 message_center_view_->SetNotifications(notifications_);
207 207
208 // Wait until the animation finishes if available. 208 // Wait until the animation finishes if available.
209 if (GetAnimator()->IsAnimating()) 209 if (GetAnimator()->IsAnimating())
210 base::MessageLoop::current()->Run(); 210 base::MessageLoop::current()->Run();
211 } 211 }
212 212
213 void MessageCenterViewTest::TearDown() { 213 void MessageCenterViewTest::TearDown() {
214 message_center_view_.reset(); 214 message_center_view_.reset();
215 STLDeleteElements(&notifications_); 215 STLDeleteElements(&notifications_);
216 views::ViewsTestBase::TearDown();
216 } 217 }
217 218
218 MessageCenterView* MessageCenterViewTest::GetMessageCenterView() { 219 MessageCenterView* MessageCenterViewTest::GetMessageCenterView() {
219 return message_center_view_.get(); 220 return message_center_view_.get();
220 } 221 }
221 222
222 MessageListView* MessageCenterViewTest::GetMessageListView() { 223 MessageListView* MessageCenterViewTest::GetMessageListView() {
223 return message_center_view_->message_list_view_.get(); 224 return message_center_view_->message_list_view_.get();
224 } 225 }
225 226
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 AddNotification( 594 AddNotification(
594 scoped_ptr<Notification>(new Notification(pinned_notification))); 595 scoped_ptr<Notification>(new Notification(pinned_notification)));
595 596
596 // There should be 1 pinned notification. 597 // There should be 1 pinned notification.
597 EXPECT_EQ(1u, GetMessageCenter()->GetVisibleNotifications().size()); 598 EXPECT_EQ(1u, GetMessageCenter()->GetVisibleNotifications().size());
598 EXPECT_FALSE(close_button->enabled()); 599 EXPECT_FALSE(close_button->enabled());
599 #endif // defined(OS_CHROMEOS) 600 #endif // defined(OS_CHROMEOS)
600 } 601 }
601 602
602 } // namespace message_center 603 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/views/bounded_label_unittest.cc ('k') | ui/shell_dialogs/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698