OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
23 #include "content/public/test/browser_test_utils.h" | 23 #include "content/public/test/browser_test_utils.h" |
24 #include "net/base/filename_util.h" | 24 #include "net/base/filename_util.h" |
25 #include "net/test/spawned_test_server/spawned_test_server.h" | 25 #include "net/test/spawned_test_server/spawned_test_server.h" |
26 | 26 |
27 // ----------------------------------------------------------------------------- | 27 // ----------------------------------------------------------------------------- |
28 | 28 |
29 // Dimensions of the icon.png resource in the notification test data directory. | 29 // Dimensions of the icon.png resource in the notification test data directory. |
30 const int kIconWidth = 100; | 30 const int kIconWidth = 100; |
31 const int kIconHeight = 100; | 31 const int kIconHeight = 100; |
32 const int kNotificationVibrationPattern[] = { 100, 200, 300 }; | |
Peter Beverloo
2015/05/05 13:11:56
nit: blank line above this one, to distinguish it
Sanghyun Park
2015/05/05 17:54:30
Okay, I'll add blank line.
| |
32 | 33 |
33 class PlatformNotificationServiceBrowserTest : public InProcessBrowserTest { | 34 class PlatformNotificationServiceBrowserTest : public InProcessBrowserTest { |
34 public: | 35 public: |
35 PlatformNotificationServiceBrowserTest(); | 36 PlatformNotificationServiceBrowserTest(); |
36 ~PlatformNotificationServiceBrowserTest() override {} | 37 ~PlatformNotificationServiceBrowserTest() override {} |
37 | 38 |
38 // InProcessBrowserTest overrides. | 39 // InProcessBrowserTest overrides. |
39 void SetUp() override; | 40 void SetUp() override; |
40 void SetUpOnMainThread() override; | 41 void SetUpOnMainThread() override; |
41 void TearDown() override; | 42 void TearDown() override; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 EXPECT_EQ("Contents", base::UTF16ToUTF8(notification.message())); | 213 EXPECT_EQ("Contents", base::UTF16ToUTF8(notification.message())); |
213 EXPECT_EQ("replace-id", notification.tag()); | 214 EXPECT_EQ("replace-id", notification.tag()); |
214 EXPECT_FALSE(notification.icon().IsEmpty()); | 215 EXPECT_FALSE(notification.icon().IsEmpty()); |
215 EXPECT_TRUE(notification.silent()); | 216 EXPECT_TRUE(notification.silent()); |
216 | 217 |
217 EXPECT_EQ(kIconWidth, notification.icon().Width()); | 218 EXPECT_EQ(kIconWidth, notification.icon().Width()); |
218 EXPECT_EQ(kIconHeight, notification.icon().Height()); | 219 EXPECT_EQ(kIconHeight, notification.icon().Height()); |
219 } | 220 } |
220 | 221 |
221 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, | 222 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, |
223 WebNotificationOptionsVibratationPattern) { | |
224 std::string script_result; | |
225 | |
226 InfoBarResponder accepting_responder(browser(), true); | |
227 ASSERT_TRUE(RunScript("RequestPermission()", &script_result)); | |
228 EXPECT_EQ("granted", script_result); | |
229 | |
230 ASSERT_TRUE(RunScript("DisplayPersistentNotificationVibrate()", | |
231 &script_result)); | |
232 EXPECT_EQ("ok", script_result); | |
233 | |
234 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); | |
235 | |
236 const Notification& notification = ui_manager()->GetNotificationAt(0); | |
237 EXPECT_EQ("Title", base::UTF16ToUTF8(notification.title())); | |
238 EXPECT_EQ("Contents", base::UTF16ToUTF8(notification.message())); | |
239 | |
240 ASSERT_EQ(arraysize(WebNotificationOptionsVibrationPattern), | |
Sanghyun Park
2015/05/05 17:54:30
Oops.. Sorry.
I used wrong name(WebNotificationOpt
| |
241 notification.vibration_pattern().size()); | |
242 for (size_t i = 0; i < arraysize(kNotificationVibrationPattern); ++i) { | |
243 EXPECT_EQ(kNotificationVibrationPattern[i], | |
244 notification.vibration_pattern()[i]); | |
245 } | |
246 } | |
247 | |
248 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, | |
222 CloseDisplayedPersistentNotification) { | 249 CloseDisplayedPersistentNotification) { |
223 std::string script_result; | 250 std::string script_result; |
224 | 251 |
225 InfoBarResponder accepting_responder(GetInfoBarService(), true); | 252 InfoBarResponder accepting_responder(GetInfoBarService(), true); |
226 ASSERT_TRUE(RunScript("RequestPermission()", &script_result)); | 253 ASSERT_TRUE(RunScript("RequestPermission()", &script_result)); |
227 EXPECT_EQ("granted", script_result); | 254 EXPECT_EQ("granted", script_result); |
228 | 255 |
229 ASSERT_TRUE(RunScript("DisplayPersistentNotification('action_close')", | 256 ASSERT_TRUE(RunScript("DisplayPersistentNotification('action_close')", |
230 &script_result)); | 257 &script_result)); |
231 EXPECT_EQ("ok", script_result); | 258 EXPECT_EQ("ok", script_result); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 | 357 |
331 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); | 358 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); |
332 | 359 |
333 const Notification& notification = ui_manager()->GetNotificationAt(0); | 360 const Notification& notification = ui_manager()->GetNotificationAt(0); |
334 EXPECT_FALSE(notification.icon().IsEmpty()); | 361 EXPECT_FALSE(notification.icon().IsEmpty()); |
335 | 362 |
336 EXPECT_EQ("Blob Title", base::UTF16ToUTF8(notification.title())); | 363 EXPECT_EQ("Blob Title", base::UTF16ToUTF8(notification.title())); |
337 EXPECT_EQ(kIconWidth, notification.icon().Width()); | 364 EXPECT_EQ(kIconWidth, notification.icon().Width()); |
338 EXPECT_EQ(kIconHeight, notification.icon().Height()); | 365 EXPECT_EQ(kIconHeight, notification.icon().Height()); |
339 } | 366 } |
OLD | NEW |