OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/strings/string_number_conversions.h" | 5 #include "base/strings/string_number_conversions.h" |
6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/extensions/api/notifications/notifications_api.h" | 9 #include "chrome/browser/extensions/api/notifications/notifications_api.h" |
10 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 } | 157 } |
158 | 158 |
159 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestPartialUpdate) { | 159 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestPartialUpdate) { |
160 ASSERT_TRUE(RunExtensionTest("notifications/api/partial_update")) << message_; | 160 ASSERT_TRUE(RunExtensionTest("notifications/api/partial_update")) << message_; |
161 const extensions::Extension* extension = GetSingleLoadedExtension(); | 161 const extensions::Extension* extension = GetSingleLoadedExtension(); |
162 ASSERT_TRUE(extension) << message_; | 162 ASSERT_TRUE(extension) << message_; |
163 | 163 |
164 const char kNewTitle[] = "Changed!"; | 164 const char kNewTitle[] = "Changed!"; |
165 const char kNewMessage[] = "Too late! The show ended yesterday"; | 165 const char kNewMessage[] = "Too late! The show ended yesterday"; |
166 int kNewPriority = 2; | 166 int kNewPriority = 2; |
| 167 const char kButtonTitle[] = "NewButton"; |
167 | 168 |
168 const message_center::NotificationList::Notifications& notifications = | 169 const message_center::NotificationList::Notifications& notifications = |
169 g_browser_process->message_center()->GetVisibleNotifications(); | 170 g_browser_process->message_center()->GetVisibleNotifications(); |
170 ASSERT_EQ(1u, notifications.size()); | 171 ASSERT_EQ(1u, notifications.size()); |
171 message_center::Notification* notification = *(notifications.begin()); | 172 message_center::Notification* notification = *(notifications.begin()); |
172 LOG(INFO) << "Notification ID: " << notification->id(); | 173 LOG(INFO) << "Notification ID: " << notification->id(); |
173 | 174 |
174 EXPECT_EQ(base::ASCIIToUTF16(kNewTitle), notification->title()); | 175 EXPECT_EQ(base::ASCIIToUTF16(kNewTitle), notification->title()); |
175 EXPECT_EQ(base::ASCIIToUTF16(kNewMessage), notification->message()); | 176 EXPECT_EQ(base::ASCIIToUTF16(kNewMessage), notification->message()); |
176 EXPECT_EQ(kNewPriority, notification->priority()); | 177 EXPECT_EQ(kNewPriority, notification->priority()); |
177 EXPECT_EQ(0u, notification->buttons().size()); | 178 EXPECT_EQ(1u, notification->buttons().size()); |
| 179 EXPECT_EQ(base::ASCIIToUTF16(kButtonTitle), notification->buttons()[0].title); |
178 } | 180 } |
179 | 181 |
180 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestGetPermissionLevel) { | 182 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestGetPermissionLevel) { |
181 scoped_refptr<Extension> empty_extension( | 183 scoped_refptr<Extension> empty_extension( |
182 extensions::test_util::CreateEmptyExtension()); | 184 extensions::test_util::CreateEmptyExtension()); |
183 | 185 |
184 // Get permission level for the extension whose notifications are enabled. | 186 // Get permission level for the extension whose notifications are enabled. |
185 { | 187 { |
186 scoped_refptr<extensions::NotificationsGetPermissionLevelFunction> | 188 scoped_refptr<extensions::NotificationsGetPermissionLevelFunction> |
187 notification_function( | 189 notification_function( |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 notification->ButtonClick(0); | 282 notification->ButtonClick(0); |
281 EXPECT_TRUE(catcher.GetNextResult()); | 283 EXPECT_TRUE(catcher.GetNextResult()); |
282 notification->Click(); | 284 notification->Click(); |
283 EXPECT_TRUE(catcher.GetNextResult()); | 285 EXPECT_TRUE(catcher.GetNextResult()); |
284 notification->Close(true); | 286 notification->Close(true); |
285 EXPECT_TRUE(catcher.GetNextResult()); | 287 EXPECT_TRUE(catcher.GetNextResult()); |
286 notification->Close(false); | 288 notification->Close(false); |
287 EXPECT_FALSE(catcher.GetNextResult()); | 289 EXPECT_FALSE(catcher.GetNextResult()); |
288 } | 290 } |
289 } | 291 } |
OLD | NEW |