OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "modules/push_messaging/PushMessageData.h" |
| 6 |
| 7 #include "public/platform/WebString.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 |
| 10 namespace blink { |
| 11 namespace { |
| 12 |
| 13 const char kPushMessageData[] = "Push Message valid data string."; |
| 14 |
| 15 TEST(PushMessageDataTest, ValidPayload) |
| 16 { |
| 17 // Create a WebString with the test message, then create a |
| 18 // PushMessageData from that. |
| 19 WebString s(blink::WebString::fromUTF8(kPushMessageData)); |
| 20 PushMessageData* data = PushMessageData::create(s); |
| 21 |
| 22 ASSERT_NE(data, nullptr); |
| 23 EXPECT_STREQ(kPushMessageData, data->text().utf8().data()); |
| 24 } |
| 25 |
| 26 TEST(PushMessageDataTest, ValidEmptyPayload) |
| 27 { |
| 28 // Create a WebString with a valid but empty test message, then create |
| 29 // a PushMessageData from that. |
| 30 WebString s(""); |
| 31 PushMessageData* data = PushMessageData::create(s); |
| 32 |
| 33 ASSERT_NE(data, nullptr); |
| 34 EXPECT_STREQ("", data->text().utf8().data()); |
| 35 } |
| 36 |
| 37 TEST(PushMessageDataTest, NullPayload) |
| 38 { |
| 39 // Create a PushMessageData with a null payload. |
| 40 WebString s; |
| 41 PushMessageData* data = PushMessageData::create(s); |
| 42 |
| 43 EXPECT_EQ(data, nullptr); |
| 44 } |
| 45 |
| 46 } // anonymous namespace |
| 47 } // namespace blink |
OLD | NEW |