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

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

Issue 12277024: Notificaitons refactor step 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more feedback from Steven Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « ui/message_center/message_center_bubble.cc ('k') | ui/message_center/message_popup_bubble.cc » ('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/utf_string_conversions.h" 7 #include "base/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/notifications/notification_types.h" 10 #include "ui/message_center/notification_types.h"
11 11
12 namespace message_center { 12 namespace message_center {
13 namespace { 13 namespace {
14 14
15 class MockDelegate : public MessageCenterTrayDelegate { 15 class MockDelegate : public MessageCenterTrayDelegate {
16 public: 16 public:
17 MockDelegate() 17 MockDelegate()
18 : show_popups_success_(true), 18 : show_popups_success_(true),
19 show_message_center_success_(true) {} 19 show_message_center_success_(true) {}
20 virtual ~MockDelegate() {} 20 virtual ~MockDelegate() {}
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 TEST_F(MessageCenterTrayTest, BasicPopup) { 95 TEST_F(MessageCenterTrayTest, BasicPopup) {
96 ASSERT_FALSE(message_center_tray_->popups_visible()); 96 ASSERT_FALSE(message_center_tray_->popups_visible());
97 ASSERT_FALSE(message_center_tray_->message_center_visible()); 97 ASSERT_FALSE(message_center_tray_->message_center_visible());
98 98
99 message_center_tray_->ShowPopupBubble(); 99 message_center_tray_->ShowPopupBubble();
100 100
101 ASSERT_FALSE(message_center_tray_->popups_visible()); 101 ASSERT_FALSE(message_center_tray_->popups_visible());
102 ASSERT_FALSE(message_center_tray_->message_center_visible()); 102 ASSERT_FALSE(message_center_tray_->message_center_visible());
103 103
104 message_center_->AddNotification( 104 message_center_->AddNotification(
105 ui::notifications::NOTIFICATION_TYPE_SIMPLE, 105 message_center::NOTIFICATION_TYPE_SIMPLE,
106 "BasicPopup", 106 "BasicPopup",
107 ASCIIToUTF16("Test Web Notification"), 107 ASCIIToUTF16("Test Web Notification"),
108 ASCIIToUTF16("Notification message body."), 108 ASCIIToUTF16("Notification message body."),
109 ASCIIToUTF16("www.test.org"), 109 ASCIIToUTF16("www.test.org"),
110 "" /* extension id */, 110 "" /* extension id */,
111 NULL /* optional_fields */); 111 NULL /* optional_fields */);
112 112
113 ASSERT_TRUE(message_center_tray_->popups_visible()); 113 ASSERT_TRUE(message_center_tray_->popups_visible());
114 ASSERT_FALSE(message_center_tray_->message_center_visible()); 114 ASSERT_FALSE(message_center_tray_->message_center_visible());
115 115
116 message_center_tray_->HidePopupBubble(); 116 message_center_tray_->HidePopupBubble();
117 117
118 ASSERT_FALSE(message_center_tray_->popups_visible()); 118 ASSERT_FALSE(message_center_tray_->popups_visible());
119 ASSERT_FALSE(message_center_tray_->message_center_visible()); 119 ASSERT_FALSE(message_center_tray_->message_center_visible());
120 } 120 }
121 121
122 TEST_F(MessageCenterTrayTest, MessageCenterClosesPopups) { 122 TEST_F(MessageCenterTrayTest, MessageCenterClosesPopups) {
123 ASSERT_FALSE(message_center_tray_->popups_visible()); 123 ASSERT_FALSE(message_center_tray_->popups_visible());
124 ASSERT_FALSE(message_center_tray_->message_center_visible()); 124 ASSERT_FALSE(message_center_tray_->message_center_visible());
125 125
126 message_center_->AddNotification( 126 message_center_->AddNotification(
127 ui::notifications::NOTIFICATION_TYPE_SIMPLE, 127 message_center::NOTIFICATION_TYPE_SIMPLE,
128 "MessageCenterClosesPopups", 128 "MessageCenterClosesPopups",
129 ASCIIToUTF16("Test Web Notification"), 129 ASCIIToUTF16("Test Web Notification"),
130 ASCIIToUTF16("Notification message body."), 130 ASCIIToUTF16("Notification message body."),
131 ASCIIToUTF16("www.test.org"), 131 ASCIIToUTF16("www.test.org"),
132 "" /* extension id */, 132 "" /* extension id */,
133 NULL /* optional_fields */); 133 NULL /* optional_fields */);
134 134
135 ASSERT_TRUE(message_center_tray_->popups_visible()); 135 ASSERT_TRUE(message_center_tray_->popups_visible());
136 ASSERT_FALSE(message_center_tray_->message_center_visible()); 136 ASSERT_FALSE(message_center_tray_->message_center_visible());
137 137
138 bool shown = message_center_tray_->ShowMessageCenterBubble(); 138 bool shown = message_center_tray_->ShowMessageCenterBubble();
139 EXPECT_TRUE(shown); 139 EXPECT_TRUE(shown);
140 140
141 ASSERT_FALSE(message_center_tray_->popups_visible()); 141 ASSERT_FALSE(message_center_tray_->popups_visible());
142 ASSERT_TRUE(message_center_tray_->message_center_visible()); 142 ASSERT_TRUE(message_center_tray_->message_center_visible());
143 143
144 message_center_->AddNotification( 144 message_center_->AddNotification(
145 ui::notifications::NOTIFICATION_TYPE_SIMPLE, 145 message_center::NOTIFICATION_TYPE_SIMPLE,
146 "MessageCenterClosesPopups2", 146 "MessageCenterClosesPopups2",
147 ASCIIToUTF16("Test Web Notification"), 147 ASCIIToUTF16("Test Web Notification"),
148 ASCIIToUTF16("Notification message body."), 148 ASCIIToUTF16("Notification message body."),
149 ASCIIToUTF16("www.test.org"), 149 ASCIIToUTF16("www.test.org"),
150 "" /* extension id */, 150 "" /* extension id */,
151 NULL /* optional_fields */); 151 NULL /* optional_fields */);
152 152
153 message_center_tray_->ShowPopupBubble(); 153 message_center_tray_->ShowPopupBubble();
154 154
155 ASSERT_FALSE(message_center_tray_->popups_visible()); 155 ASSERT_FALSE(message_center_tray_->popups_visible());
156 ASSERT_TRUE(message_center_tray_->message_center_visible()); 156 ASSERT_TRUE(message_center_tray_->message_center_visible());
157 157
158 message_center_tray_->HideMessageCenterBubble(); 158 message_center_tray_->HideMessageCenterBubble();
159 159
160 ASSERT_FALSE(message_center_tray_->popups_visible()); 160 ASSERT_FALSE(message_center_tray_->popups_visible());
161 ASSERT_FALSE(message_center_tray_->message_center_visible()); 161 ASSERT_FALSE(message_center_tray_->message_center_visible());
162 } 162 }
163 163
164 TEST_F(MessageCenterTrayTest, ShowBubbleFails) { 164 TEST_F(MessageCenterTrayTest, ShowBubbleFails) {
165 // Now the delegate will signal that it was unable to show a bubble. 165 // Now the delegate will signal that it was unable to show a bubble.
166 delegate_->show_popups_success_ = false; 166 delegate_->show_popups_success_ = false;
167 delegate_->show_message_center_success_ = false; 167 delegate_->show_message_center_success_ = false;
168 168
169 ASSERT_FALSE(message_center_tray_->popups_visible()); 169 ASSERT_FALSE(message_center_tray_->popups_visible());
170 ASSERT_FALSE(message_center_tray_->message_center_visible()); 170 ASSERT_FALSE(message_center_tray_->message_center_visible());
171 171
172 message_center_->AddNotification( 172 message_center_->AddNotification(
173 ui::notifications::NOTIFICATION_TYPE_SIMPLE, 173 message_center::NOTIFICATION_TYPE_SIMPLE,
174 "ShowBubbleFails", 174 "ShowBubbleFails",
175 ASCIIToUTF16("Test Web Notification"), 175 ASCIIToUTF16("Test Web Notification"),
176 ASCIIToUTF16("Notification message body."), 176 ASCIIToUTF16("Notification message body."),
177 ASCIIToUTF16("www.test.org"), 177 ASCIIToUTF16("www.test.org"),
178 "" /* extension id */, 178 "" /* extension id */,
179 NULL /* optional_fields */); 179 NULL /* optional_fields */);
180 180
181 message_center_tray_->ShowPopupBubble(); 181 message_center_tray_->ShowPopupBubble();
182 182
183 ASSERT_FALSE(message_center_tray_->popups_visible()); 183 ASSERT_FALSE(message_center_tray_->popups_visible());
(...skipping 15 matching lines...) Expand all
199 ASSERT_FALSE(message_center_tray_->popups_visible()); 199 ASSERT_FALSE(message_center_tray_->popups_visible());
200 ASSERT_FALSE(message_center_tray_->message_center_visible()); 200 ASSERT_FALSE(message_center_tray_->message_center_visible());
201 201
202 message_center_tray_->HidePopupBubble(); 202 message_center_tray_->HidePopupBubble();
203 203
204 ASSERT_FALSE(message_center_tray_->popups_visible()); 204 ASSERT_FALSE(message_center_tray_->popups_visible());
205 ASSERT_FALSE(message_center_tray_->message_center_visible()); 205 ASSERT_FALSE(message_center_tray_->message_center_visible());
206 } 206 }
207 207
208 } // namespace message_center 208 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/message_center_bubble.cc ('k') | ui/message_center/message_popup_bubble.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698