| Index: third_party/WebKit/Source/platform/PlatformNotificationConvertersTest.cpp
|
| diff --git a/third_party/WebKit/Source/platform/PlatformNotificationConvertersTest.cpp b/third_party/WebKit/Source/platform/PlatformNotificationConvertersTest.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..64276ec1e5a18d738b9d2ca97e8ac63c9aa2a03c
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/platform/PlatformNotificationConvertersTest.cpp
|
| @@ -0,0 +1,66 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "platform/PlatformNotificationConverters.h"
|
| +
|
| +#include "platform/weborigin/KURL.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +#include "wtf/CurrentTime.h"
|
| +
|
| +namespace blink {
|
| +
|
| +TEST(PlatformNotificationConvertersTest, TestConversion)
|
| +{
|
| + const int kVibrationPattern[] = { 50, 100, 150 };
|
| + const unsigned char kData[] = { 0x00, 0x10, 0x20, 0x30, 0x40 };
|
| + const size_t kActionButtonCount = 3;
|
| +
|
| + PlatformNotification notification;
|
| + notification.title = "title";
|
| + notification.direction = PlatformNotification::Direction::RIGHT_TO_LEFT;
|
| + notification.body = "body";
|
| + notification.tag = "tag";
|
| + notification.icon = KURL(ParsedURLString, "https://example.com/icon.png");
|
| + notification.vibrationPattern.append(kVibrationPattern, sizeof(kVibrationPattern));
|
| + notification.timestamp = currentTimeMS();
|
| + notification.renotify = true;
|
| + notification.silent = true;
|
| + notification.requireInteraction = true;
|
| + notification.data.append(kData, sizeof(kData));
|
| +
|
| + for (size_t i = 0; i < kActionButtonCount; ++i) {
|
| + PlatformNotificationAction action;
|
| + action.action = "action" + String::number(i);
|
| + action.title = "title" + String::number(i);
|
| + action.icon = KURL(ParsedURLString, "https://example.com/action-icon.png");
|
| +
|
| + notification.actions.append(action);
|
| + }
|
| +
|
| + mojom::wtf::NotificationPtr mojoNotification = mojom::wtf::Notification::From(notification);
|
| + PlatformNotification copiedNotification = mojoNotification.To<PlatformNotification>();
|
| +
|
| + EXPECT_EQ(notification.title, copiedNotification.title);
|
| + EXPECT_EQ(notification.direction, copiedNotification.direction);
|
| + EXPECT_EQ(notification.body, copiedNotification.body);
|
| + EXPECT_EQ(notification.tag, copiedNotification.tag);
|
| + EXPECT_EQ(notification.icon, copiedNotification.icon);
|
| + EXPECT_EQ(notification.vibrationPattern, copiedNotification.vibrationPattern);
|
| + EXPECT_EQ(notification.timestamp, copiedNotification.timestamp);
|
| + EXPECT_EQ(notification.renotify, copiedNotification.renotify);
|
| + EXPECT_EQ(notification.silent, copiedNotification.silent);
|
| + EXPECT_EQ(notification.requireInteraction, copiedNotification.requireInteraction);
|
| + EXPECT_EQ(notification.data, copiedNotification.data);
|
| +
|
| + ASSERT_EQ(kActionButtonCount, copiedNotification.actions.size());
|
| + for (size_t i = 0; i < kActionButtonCount; ++i) {
|
| + SCOPED_TRACE(i);
|
| +
|
| + EXPECT_EQ(notification.actions[i].action, copiedNotification.actions[i].action);
|
| + EXPECT_EQ(notification.actions[i].title, copiedNotification.actions[i].title);
|
| + EXPECT_EQ(notification.actions[i].icon, copiedNotification.actions[i].icon);
|
| + }
|
| +}
|
| +
|
| +} // namespace blink
|
|
|