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

Side by Side Diff: ui/message_center/message_center_tray_unittest.cc

Issue 101473003: Do not allow creating dummy notifier id from production, for safety. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « ui/message_center/message_center.h ('k') | ui/message_center/notifier_settings.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/message_center_tray.h" 5 #include "ui/message_center/message_center_tray.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/message_center/message_center.h" 9 #include "ui/message_center/message_center.h"
10 #include "ui/message_center/notification_types.h" 10 #include "ui/message_center/notification_types.h"
(...skipping 24 matching lines...) Expand all
35 return NULL; 35 return NULL;
36 } 36 }
37 37
38 bool show_popups_success_; 38 bool show_popups_success_;
39 bool show_message_center_success_; 39 bool show_message_center_success_;
40 40
41 private: 41 private:
42 DISALLOW_COPY_AND_ASSIGN(MockDelegate); 42 DISALLOW_COPY_AND_ASSIGN(MockDelegate);
43 }; 43 };
44 44
45 } // namespace
46
45 class MessageCenterTrayTest : public testing::Test { 47 class MessageCenterTrayTest : public testing::Test {
46 public: 48 public:
47 MessageCenterTrayTest() {} 49 MessageCenterTrayTest() {}
48 virtual ~MessageCenterTrayTest() {} 50 virtual ~MessageCenterTrayTest() {}
49 51
50 virtual void SetUp() { 52 virtual void SetUp() {
51 MessageCenter::Initialize(); 53 MessageCenter::Initialize();
52 delegate_.reset(new MockDelegate); 54 delegate_.reset(new MockDelegate);
53 message_center_ = MessageCenter::Get(); 55 message_center_ = MessageCenter::Get();
54 message_center_tray_.reset( 56 message_center_tray_.reset(
55 new MessageCenterTray(delegate_.get(), message_center_)); 57 new MessageCenterTray(delegate_.get(), message_center_));
56 } 58 }
57 59
58 virtual void TearDown() { 60 virtual void TearDown() {
59 message_center_tray_.reset(); 61 message_center_tray_.reset();
60 delegate_.reset(); 62 delegate_.reset();
61 message_center_ = NULL; 63 message_center_ = NULL;
62 MessageCenter::Shutdown(); 64 MessageCenter::Shutdown();
63 } 65 }
64 66
65 protected: 67 protected:
68 NotifierId DummyNotifierId() {
69 return NotifierId();
70 }
71
66 void AddNotification(const std::string& id) { 72 void AddNotification(const std::string& id) {
67 scoped_ptr<Notification> notification( 73 scoped_ptr<Notification> notification(
68 new Notification(message_center::NOTIFICATION_TYPE_SIMPLE, 74 new Notification(message_center::NOTIFICATION_TYPE_SIMPLE,
69 id, 75 id,
70 ASCIIToUTF16("Test Web Notification"), 76 ASCIIToUTF16("Test Web Notification"),
71 ASCIIToUTF16("Notification message body."), 77 ASCIIToUTF16("Notification message body."),
72 gfx::Image(), 78 gfx::Image(),
73 ASCIIToUTF16("www.test.org"), 79 ASCIIToUTF16("www.test.org"),
74 NotifierId(), 80 DummyNotifierId(),
75 message_center::RichNotificationData(), 81 message_center::RichNotificationData(),
76 NULL /* delegate */)); 82 NULL /* delegate */));
77 message_center_->AddNotification(notification.Pass()); 83 message_center_->AddNotification(notification.Pass());
78 } 84 }
79 scoped_ptr<MockDelegate> delegate_; 85 scoped_ptr<MockDelegate> delegate_;
80 scoped_ptr<MessageCenterTray> message_center_tray_; 86 scoped_ptr<MessageCenterTray> message_center_tray_;
81 MessageCenter* message_center_; 87 MessageCenter* message_center_;
82 88
83 private: 89 private:
84 DISALLOW_COPY_AND_ASSIGN(MessageCenterTrayTest); 90 DISALLOW_COPY_AND_ASSIGN(MessageCenterTrayTest);
85 }; 91 };
86 92
87 } // namespace
88
89 TEST_F(MessageCenterTrayTest, BasicMessageCenter) { 93 TEST_F(MessageCenterTrayTest, BasicMessageCenter) {
90 ASSERT_FALSE(message_center_tray_->popups_visible()); 94 ASSERT_FALSE(message_center_tray_->popups_visible());
91 ASSERT_FALSE(message_center_tray_->message_center_visible()); 95 ASSERT_FALSE(message_center_tray_->message_center_visible());
92 96
93 bool shown = message_center_tray_->ShowMessageCenterBubble(); 97 bool shown = message_center_tray_->ShowMessageCenterBubble();
94 EXPECT_TRUE(shown); 98 EXPECT_TRUE(shown);
95 99
96 ASSERT_FALSE(message_center_tray_->popups_visible()); 100 ASSERT_FALSE(message_center_tray_->popups_visible());
97 ASSERT_TRUE(message_center_tray_->message_center_visible()); 101 ASSERT_TRUE(message_center_tray_->message_center_visible());
98 102
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 ASSERT_FALSE(message_center_tray_->popups_visible()); 175 ASSERT_FALSE(message_center_tray_->popups_visible());
172 ASSERT_FALSE(message_center_tray_->message_center_visible()); 176 ASSERT_FALSE(message_center_tray_->message_center_visible());
173 177
174 scoped_ptr<Notification> notification( 178 scoped_ptr<Notification> notification(
175 new Notification(message_center::NOTIFICATION_TYPE_SIMPLE, 179 new Notification(message_center::NOTIFICATION_TYPE_SIMPLE,
176 "MessageCenterReopnPopupsForSystemPriority", 180 "MessageCenterReopnPopupsForSystemPriority",
177 ASCIIToUTF16("Test Web Notification"), 181 ASCIIToUTF16("Test Web Notification"),
178 ASCIIToUTF16("Notification message body."), 182 ASCIIToUTF16("Notification message body."),
179 gfx::Image(), 183 gfx::Image(),
180 ASCIIToUTF16("www.test.org"), 184 ASCIIToUTF16("www.test.org"),
181 NotifierId(), 185 DummyNotifierId(),
182 message_center::RichNotificationData(), 186 message_center::RichNotificationData(),
183 NULL /* delegate */)); 187 NULL /* delegate */));
184 notification->SetSystemPriority(); 188 notification->SetSystemPriority();
185 message_center_->AddNotification(notification.Pass()); 189 message_center_->AddNotification(notification.Pass());
186 190
187 ASSERT_TRUE(message_center_tray_->popups_visible()); 191 ASSERT_TRUE(message_center_tray_->popups_visible());
188 ASSERT_FALSE(message_center_tray_->message_center_visible()); 192 ASSERT_FALSE(message_center_tray_->message_center_visible());
189 193
190 bool shown = message_center_tray_->ShowMessageCenterBubble(); 194 bool shown = message_center_tray_->ShowMessageCenterBubble();
191 EXPECT_TRUE(shown); 195 EXPECT_TRUE(shown);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 ASSERT_FALSE(message_center_tray_->popups_visible()); 234 ASSERT_FALSE(message_center_tray_->popups_visible());
231 ASSERT_FALSE(message_center_tray_->message_center_visible()); 235 ASSERT_FALSE(message_center_tray_->message_center_visible());
232 236
233 message_center_tray_->HidePopupBubble(); 237 message_center_tray_->HidePopupBubble();
234 238
235 ASSERT_FALSE(message_center_tray_->popups_visible()); 239 ASSERT_FALSE(message_center_tray_->popups_visible());
236 ASSERT_FALSE(message_center_tray_->message_center_visible()); 240 ASSERT_FALSE(message_center_tray_->message_center_visible());
237 } 241 }
238 242
239 } // namespace message_center 243 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/message_center.h ('k') | ui/message_center/notifier_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698