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

Side by Side Diff: chrome/browser/notifications/platform_notification_service_browsertest.cc

Issue 1054573002: Implement support for notification.vibrate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 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"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/infobars/infobar_responder.h" 12 #include "chrome/browser/infobars/infobar_responder.h"
13 #include "chrome/browser/infobars/infobar_service.h" 13 #include "chrome/browser/infobars/infobar_service.h"
14 #include "chrome/browser/notifications/desktop_notification_profile_util.h" 14 #include "chrome/browser/notifications/desktop_notification_profile_util.h"
15 #include "chrome/browser/notifications/desktop_notification_service.h" 15 #include "chrome/browser/notifications/desktop_notification_service.h"
16 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 16 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
17 #include "chrome/browser/notifications/notification_test_util.h" 17 #include "chrome/browser/notifications/notification_test_util.h"
18 #include "chrome/browser/notifications/platform_notification_service_impl.h" 18 #include "chrome/browser/notifications/platform_notification_service_impl.h"
19 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/tabs/tab_strip_model.h" 20 #include "chrome/browser/ui/tabs/tab_strip_model.h"
21 #include "chrome/test/base/in_process_browser_test.h" 21 #include "chrome/test/base/in_process_browser_test.h"
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 #include "testing/gmock/include/gmock/gmock.h"
26 27
27 // ----------------------------------------------------------------------------- 28 // -----------------------------------------------------------------------------
28 29
29 // Dimensions of the icon.png resource in the notification test data directory. 30 // Dimensions of the icon.png resource in the notification test data directory.
30 const int kIconWidth = 100; 31 const int kIconWidth = 100;
31 const int kIconHeight = 100; 32 const int kIconHeight = 100;
32 33
34 const int kNotificationVibrationPattern[] = { 100, 200, 300 };
35
33 class PlatformNotificationServiceBrowserTest : public InProcessBrowserTest { 36 class PlatformNotificationServiceBrowserTest : public InProcessBrowserTest {
34 public: 37 public:
35 PlatformNotificationServiceBrowserTest(); 38 PlatformNotificationServiceBrowserTest();
36 ~PlatformNotificationServiceBrowserTest() override {} 39 ~PlatformNotificationServiceBrowserTest() override {}
37 40
38 // InProcessBrowserTest overrides. 41 // InProcessBrowserTest overrides.
39 void SetUp() override; 42 void SetUp() override;
40 void SetUpOnMainThread() override; 43 void SetUpOnMainThread() override;
41 void TearDown() override; 44 void TearDown() override;
42 45
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 EXPECT_EQ("Contents", base::UTF16ToUTF8(notification.message())); 215 EXPECT_EQ("Contents", base::UTF16ToUTF8(notification.message()));
213 EXPECT_EQ("replace-id", notification.tag()); 216 EXPECT_EQ("replace-id", notification.tag());
214 EXPECT_FALSE(notification.icon().IsEmpty()); 217 EXPECT_FALSE(notification.icon().IsEmpty());
215 EXPECT_TRUE(notification.silent()); 218 EXPECT_TRUE(notification.silent());
216 219
217 EXPECT_EQ(kIconWidth, notification.icon().Width()); 220 EXPECT_EQ(kIconWidth, notification.icon().Width());
218 EXPECT_EQ(kIconHeight, notification.icon().Height()); 221 EXPECT_EQ(kIconHeight, notification.icon().Height());
219 } 222 }
220 223
221 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, 224 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
225 WebNotificationOptionsVibrationPattern) {
226 std::string script_result;
227
228 InfoBarResponder accepting_responder(GetInfoBarService(), true);
229 ASSERT_TRUE(RunScript("RequestPermission()", &script_result));
230 EXPECT_EQ("granted", script_result);
231
232 ASSERT_TRUE(RunScript("DisplayPersistentNotificationVibrate()",
233 &script_result));
234 EXPECT_EQ("ok", script_result);
235
236 ASSERT_EQ(1u, ui_manager()->GetNotificationCount());
237
238 const Notification& notification = ui_manager()->GetNotificationAt(0);
239 EXPECT_EQ("Title", base::UTF16ToUTF8(notification.title()));
240 EXPECT_EQ("Contents", base::UTF16ToUTF8(notification.message()));
241
242 EXPECT_THAT(notification.vibration_pattern(),
243 testing::ElementsAreArray(kNotificationVibrationPattern));
244 }
245
246 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
222 CloseDisplayedPersistentNotification) { 247 CloseDisplayedPersistentNotification) {
223 std::string script_result; 248 std::string script_result;
224 249
225 InfoBarResponder accepting_responder(GetInfoBarService(), true); 250 InfoBarResponder accepting_responder(GetInfoBarService(), true);
226 ASSERT_TRUE(RunScript("RequestPermission()", &script_result)); 251 ASSERT_TRUE(RunScript("RequestPermission()", &script_result));
227 EXPECT_EQ("granted", script_result); 252 EXPECT_EQ("granted", script_result);
228 253
229 ASSERT_TRUE(RunScript("DisplayPersistentNotification('action_close')", 254 ASSERT_TRUE(RunScript("DisplayPersistentNotification('action_close')",
230 &script_result)); 255 &script_result));
231 EXPECT_EQ("ok", script_result); 256 EXPECT_EQ("ok", script_result);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 355
331 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); 356 ASSERT_EQ(1u, ui_manager()->GetNotificationCount());
332 357
333 const Notification& notification = ui_manager()->GetNotificationAt(0); 358 const Notification& notification = ui_manager()->GetNotificationAt(0);
334 EXPECT_FALSE(notification.icon().IsEmpty()); 359 EXPECT_FALSE(notification.icon().IsEmpty());
335 360
336 EXPECT_EQ("Blob Title", base::UTF16ToUTF8(notification.title())); 361 EXPECT_EQ("Blob Title", base::UTF16ToUTF8(notification.title()));
337 EXPECT_EQ(kIconWidth, notification.icon().Width()); 362 EXPECT_EQ(kIconWidth, notification.icon().Width());
338 EXPECT_EQ(kIconHeight, notification.icon().Height()); 363 EXPECT_EQ(kIconHeight, notification.icon().Height());
339 } 364 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698