Chromium Code Reviews| 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..bcda69ca6c30872b9594cc1fe7b80cd73040d4d7 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/modules/push_messaging/PushMessageDataTest.cpp |
| @@ -0,0 +1,53 @@ |
| +// 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/25 17:39:07
micro nit: namespaces are not indented in either o
harkness
2016/01/26 12:07:20
Done.
|
| + |
| + class PushMessageDataTest : public ::testing::Test { |
|
Peter Beverloo
2016/01/25 17:39:07
Since you don't need anything special from the fix
harkness
2016/01/26 12:07:20
Done.
|
| + }; |
| + |
| + TEST_F(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); |
| + |
| + EXPECT_NE(data, nullptr); |
| + if (data) { |
|
Peter Beverloo
2016/01/25 17:39:07
GTest supports most comparisons using two directiv
harkness
2016/01/26 12:07:20
Done.
|
| + EXPECT_TRUE(s.equals(data->text())); |
| + } |
| + } |
| + |
| + TEST_F(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); |
| + |
| + EXPECT_NE(data, nullptr); |
| + if (data) { |
| + EXPECT_TRUE(s.equals(data->text())); |
| + } |
| + } |
| + |
| + TEST_F(PushMessageDataTest, NullPayload) |
| + { |
| + // Create a PushMessageData with a null payload. |
| + WebString s; |
| + PushMessageData* data = PushMessageData::create(s); |
| + |
| + EXPECT_EQ(data, nullptr); |
| + } |
| +} |
| +} // namespace blink |