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

Unified Diff: third_party/WebKit/Source/modules/push_messaging/PushMessageDataTest.cpp

Issue 1636483002: Update the PushEvent to have a nullable PushMessageData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/push_messaging/PushMessageDataTest.cpp
diff --git a/third_party/WebKit/Source/modules/push_messaging/PushMessageDataTest.cpp b/third_party/WebKit/Source/modules/push_messaging/PushMessageDataTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b39c3a189709e24a88b6674d787a3148b869185f
--- /dev/null
+++ b/third_party/WebKit/Source/modules/push_messaging/PushMessageDataTest.cpp
@@ -0,0 +1,46 @@
+// 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 "modules/push_messaging/PushMessageData.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/WebKit/public/platform/WebString.h"
+
+namespace blink {
+namespace {
+
+ const char kPushMessageData[] = "Push Message valid data string.";
Peter Beverloo 2016/01/26 12:35:18 No indentation in the namespace please.
harkness 2016/01/26 14:49:20 I had to double check this one, because I knew I h
+
+ TEST(PushMessageDataTest, ValidPayload)
+ {
+ // Create a WebString with the test message, then create a
+ // PushMessageData from that.
+ WebString s(blink::WebString::fromUTF8(kPushMessageData));
+ PushMessageData* data = PushMessageData::create(s);
+
+ ASSERT_NE(data, nullptr);
+ EXPECT_TRUE(s.equals(data->text()));
+ }
+
+ TEST(PushMessageDataTest, ValidEmptyPayload)
+ {
+ // Create a WebString with a valid but empty test message, then create
+ // a PushMessageData from that.
+ WebString s("");
+ PushMessageData* data = PushMessageData::create(s);
+
+ ASSERT_NE(data, nullptr);
+ EXPECT_TRUE(s.equals(data->text()));
+ }
+
+ TEST(PushMessageDataTest, NullPayload)
+ {
+ // Create a PushMessageData with a null payload.
+ WebString s;
+ PushMessageData* data = PushMessageData::create(s);
+
+ EXPECT_EQ(data, nullptr);
+ }
+}
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698