OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "modules/notifications/NotificationData.h" | 5 #include "modules/notifications/NotificationData.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "core/testing/NullExecutionContext.h" | 8 #include "core/testing/NullExecutionContext.h" |
9 #include "modules/notifications/Notification.h" | 9 #include "modules/notifications/Notification.h" |
10 #include "modules/notifications/NotificationOptions.h" | 10 #include "modules/notifications/NotificationOptions.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 ASSERT_FALSE(exceptionState.hadException()); | 97 ASSERT_FALSE(exceptionState.hadException()); |
98 | 98 |
99 EXPECT_EQ(kNotificationTitle, notificationData.title); | 99 EXPECT_EQ(kNotificationTitle, notificationData.title); |
100 | 100 |
101 EXPECT_EQ(WebNotificationData::DirectionRightToLeft, | 101 EXPECT_EQ(WebNotificationData::DirectionRightToLeft, |
102 notificationData.direction); | 102 notificationData.direction); |
103 EXPECT_EQ(kNotificationLang, notificationData.lang); | 103 EXPECT_EQ(kNotificationLang, notificationData.lang); |
104 EXPECT_EQ(kNotificationBody, notificationData.body); | 104 EXPECT_EQ(kNotificationBody, notificationData.body); |
105 EXPECT_EQ(kNotificationTag, notificationData.tag); | 105 EXPECT_EQ(kNotificationTag, notificationData.tag); |
106 | 106 |
107 // TODO(peter): Test the various icon properties when ExecutionContext::comple
teURL() works in this test. | 107 // TODO(peter): Test the various icon properties when |
| 108 // ExecutionContext::completeURL() works in this test. |
108 | 109 |
109 ASSERT_EQ(vibrationPattern.size(), notificationData.vibrate.size()); | 110 ASSERT_EQ(vibrationPattern.size(), notificationData.vibrate.size()); |
110 for (size_t i = 0; i < vibrationPattern.size(); ++i) | 111 for (size_t i = 0; i < vibrationPattern.size(); ++i) |
111 EXPECT_EQ(vibrationPattern[i], | 112 EXPECT_EQ(vibrationPattern[i], |
112 static_cast<unsigned>(notificationData.vibrate[i])); | 113 static_cast<unsigned>(notificationData.vibrate[i])); |
113 | 114 |
114 EXPECT_EQ(kNotificationTimestamp, notificationData.timestamp); | 115 EXPECT_EQ(kNotificationTimestamp, notificationData.timestamp); |
115 EXPECT_EQ(kNotificationRenotify, notificationData.renotify); | 116 EXPECT_EQ(kNotificationRenotify, notificationData.renotify); |
116 EXPECT_EQ(kNotificationSilent, notificationData.silent); | 117 EXPECT_EQ(kNotificationSilent, notificationData.silent); |
117 EXPECT_EQ(kNotificationRequireInteraction, | 118 EXPECT_EQ(kNotificationRequireInteraction, |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 } | 237 } |
237 | 238 |
238 TEST_F(NotificationDataTest, DefaultTimestampValue) { | 239 TEST_F(NotificationDataTest, DefaultTimestampValue) { |
239 NotificationOptions options; | 240 NotificationOptions options; |
240 | 241 |
241 TrackExceptionState exceptionState; | 242 TrackExceptionState exceptionState; |
242 WebNotificationData notificationData = createWebNotificationData( | 243 WebNotificationData notificationData = createWebNotificationData( |
243 getExecutionContext(), kNotificationTitle, options, exceptionState); | 244 getExecutionContext(), kNotificationTitle, options, exceptionState); |
244 EXPECT_FALSE(exceptionState.hadException()); | 245 EXPECT_FALSE(exceptionState.hadException()); |
245 | 246 |
246 // The timestamp should be set to the current time since the epoch if it wasn'
t supplied by the developer. | 247 // The timestamp should be set to the current time since the epoch if it |
247 // "32" has no significance, but an equal comparison of the value could lead t
o flaky failures. | 248 // wasn't supplied by the developer. "32" has no significance, but an equal |
| 249 // comparison of the value could lead to flaky failures. |
248 EXPECT_NEAR(notificationData.timestamp, WTF::currentTimeMS(), 32); | 250 EXPECT_NEAR(notificationData.timestamp, WTF::currentTimeMS(), 32); |
249 } | 251 } |
250 | 252 |
251 TEST_F(NotificationDataTest, DirectionValues) { | 253 TEST_F(NotificationDataTest, DirectionValues) { |
252 WTF::HashMap<String, WebNotificationData::Direction> mappings; | 254 WTF::HashMap<String, WebNotificationData::Direction> mappings; |
253 mappings.add("ltr", WebNotificationData::DirectionLeftToRight); | 255 mappings.add("ltr", WebNotificationData::DirectionLeftToRight); |
254 mappings.add("rtl", WebNotificationData::DirectionRightToLeft); | 256 mappings.add("rtl", WebNotificationData::DirectionRightToLeft); |
255 mappings.add("auto", WebNotificationData::DirectionAuto); | 257 mappings.add("auto", WebNotificationData::DirectionAuto); |
256 | 258 |
257 // Invalid values should default to "auto". | 259 // Invalid values should default to "auto". |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 ASSERT_EQ(Notification::maxActions(), notificationData.actions.size()); | 294 ASSERT_EQ(Notification::maxActions(), notificationData.actions.size()); |
293 | 295 |
294 for (size_t i = 0; i < Notification::maxActions(); ++i) { | 296 for (size_t i = 0; i < Notification::maxActions(); ++i) { |
295 WebString expectedAction = String::number(i); | 297 WebString expectedAction = String::number(i); |
296 EXPECT_EQ(expectedAction, notificationData.actions[i].action); | 298 EXPECT_EQ(expectedAction, notificationData.actions[i].action); |
297 } | 299 } |
298 } | 300 } |
299 | 301 |
300 } // namespace | 302 } // namespace |
301 } // namespace blink | 303 } // namespace blink |
OLD | NEW |