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..420098638817c5fe28ab1658395e40db5323665d |
--- /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 { |
Mike West
2016/01/27 06:32:14
Why do you need the extra namespace?
harkness
2016/01/27 11:52:18
I was trying to take the approach of other tests,
|
+ |
+const char kPushMessageData[] = "Push Message valid data string."; |
+ |
+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())); |
Mike West
2016/01/27 06:32:14
Nit: Why not EXPECT_STREQ?
harkness
2016/01/27 11:52:18
Done.
|
+} |
+ |
+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 |
Mike West
2016/01/27 06:32:14
Nit: If you keep the extra namespace, label the cl
harkness
2016/01/27 11:52:18
Done.
|