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 |