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

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

Issue 1878943002: Revert of Makes MaterialDesignController initialization explicit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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"
26 25
27 namespace message_center { 26 namespace message_center {
28 27
29 static const char* kNotificationId1 = "notification id 1"; 28 static const char* kNotificationId1 = "notification id 1";
30 static const char* kNotificationId2 = "notification id 2"; 29 static const char* kNotificationId2 = "notification id 2";
31 30
32 /* Types **********************************************************************/ 31 /* Types **********************************************************************/
33 32
34 enum CallType { 33 enum CallType {
35 GET_PREFERRED_SIZE, 34 GET_PREFERRED_SIZE,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 void RemoveAllNotifications(bool by_user, RemoveType type) override { 105 void RemoveAllNotifications(bool by_user, RemoveType type) override {
107 if (type == RemoveType::NON_PINNED) 106 if (type == RemoveType::NON_PINNED)
108 remove_all_closable_notification_called_ = true; 107 remove_all_closable_notification_called_ = true;
109 } 108 }
110 bool remove_all_closable_notification_called_ = false; 109 bool remove_all_closable_notification_called_ = false;
111 NotificationList::Notifications visible_notifications_; 110 NotificationList::Notifications visible_notifications_;
112 }; 111 };
113 112
114 /* Test fixture ***************************************************************/ 113 /* Test fixture ***************************************************************/
115 114
116 class MessageCenterViewTest : public views::ViewsTestBase, 115 class MessageCenterViewTest : public testing::Test,
117 public MockNotificationView::Test, 116 public MockNotificationView::Test,
118 public MessageCenterController { 117 public MessageCenterController {
119 public: 118 public:
120 MessageCenterViewTest(); 119 MessageCenterViewTest();
121 ~MessageCenterViewTest() override; 120 ~MessageCenterViewTest() override;
122 121
123 void SetUp() override; 122 void SetUp() override;
124 void TearDown() override; 123 void TearDown() override;
125 124
126 MessageCenterView* GetMessageCenterView(); 125 MessageCenterView* GetMessageCenterView();
(...skipping 25 matching lines...) Expand all
152 151
153 void FireOnMouseExitedEvent(); 152 void FireOnMouseExitedEvent();
154 153
155 void LogBounds(int depth, views::View* view); 154 void LogBounds(int depth, views::View* view);
156 155
157 MessageCenterButtonBar* GetButtonBar() const; 156 MessageCenterButtonBar* GetButtonBar() const;
158 157
159 private: 158 private:
160 views::View* MakeParent(views::View* child1, views::View* child2); 159 views::View* MakeParent(views::View* child1, views::View* child2);
161 160
161 base::MessageLoopForUI message_loop_;
162
162 NotificationList::Notifications notifications_; 163 NotificationList::Notifications notifications_;
163 scoped_ptr<MessageCenterView> message_center_view_; 164 scoped_ptr<MessageCenterView> message_center_view_;
164 scoped_ptr<FakeMessageCenterImpl> message_center_; 165 scoped_ptr<FakeMessageCenterImpl> message_center_;
165 std::map<CallType,int> callCounts_; 166 std::map<CallType,int> callCounts_;
166 167
167 DISALLOW_COPY_AND_ASSIGN(MessageCenterViewTest); 168 DISALLOW_COPY_AND_ASSIGN(MessageCenterViewTest);
168 }; 169 };
169 170
170 MessageCenterViewTest::MessageCenterViewTest() { 171 MessageCenterViewTest::MessageCenterViewTest() {
171 } 172 }
172 173
173 MessageCenterViewTest::~MessageCenterViewTest() { 174 MessageCenterViewTest::~MessageCenterViewTest() {
174 } 175 }
175 176
176 void MessageCenterViewTest::SetUp() { 177 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();
217 } 216 }
218 217
219 MessageCenterView* MessageCenterViewTest::GetMessageCenterView() { 218 MessageCenterView* MessageCenterViewTest::GetMessageCenterView() {
220 return message_center_view_.get(); 219 return message_center_view_.get();
221 } 220 }
222 221
223 MessageListView* MessageCenterViewTest::GetMessageListView() { 222 MessageListView* MessageCenterViewTest::GetMessageListView() {
224 return message_center_view_->message_list_view_.get(); 223 return message_center_view_->message_list_view_.get();
225 } 224 }
226 225
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 AddNotification( 593 AddNotification(
595 scoped_ptr<Notification>(new Notification(pinned_notification))); 594 scoped_ptr<Notification>(new Notification(pinned_notification)));
596 595
597 // There should be 1 pinned notification. 596 // There should be 1 pinned notification.
598 EXPECT_EQ(1u, GetMessageCenter()->GetVisibleNotifications().size()); 597 EXPECT_EQ(1u, GetMessageCenter()->GetVisibleNotifications().size());
599 EXPECT_FALSE(close_button->enabled()); 598 EXPECT_FALSE(close_button->enabled());
600 #endif // defined(OS_CHROMEOS) 599 #endif // defined(OS_CHROMEOS)
601 } 600 }
602 601
603 } // namespace message_center 602 } // 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