Chromium Code Reviews| 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 "testing/gtest/include/gtest/gtest.h" | |
| 8 #include "third_party/WebKit/public/platform/WebString.h" | |
| 9 | |
| 10 namespace blink { | |
| 11 namespace { | |
| 12 | |
| 13 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.
| |
| 14 | |
| 15 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.
| |
| 16 }; | |
| 17 | |
| 18 TEST_F(PushMessageDataTest, ValidPayload) | |
| 19 { | |
| 20 // Create a WebString with the test message, then create a | |
| 21 // PushMessageData from that. | |
| 22 WebString s(blink::WebString::fromUTF8(kPushMessageData)); | |
| 23 PushMessageData* data = PushMessageData::create(s); | |
| 24 | |
| 25 EXPECT_NE(data, nullptr); | |
| 26 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.
| |
| 27 EXPECT_TRUE(s.equals(data->text())); | |
| 28 } | |
| 29 } | |
| 30 | |
| 31 TEST_F(PushMessageDataTest, ValidEmptyPayload) | |
| 32 { | |
| 33 // Create a WebString with a valid but empty test message, then create | |
| 34 // a PushMessageData from that. | |
| 35 WebString s(""); | |
| 36 PushMessageData* data = PushMessageData::create(s); | |
| 37 | |
| 38 EXPECT_NE(data, nullptr); | |
| 39 if (data) { | |
| 40 EXPECT_TRUE(s.equals(data->text())); | |
| 41 } | |
| 42 } | |
| 43 | |
| 44 TEST_F(PushMessageDataTest, NullPayload) | |
| 45 { | |
| 46 // Create a PushMessageData with a null payload. | |
| 47 WebString s; | |
| 48 PushMessageData* data = PushMessageData::create(s); | |
| 49 | |
| 50 EXPECT_EQ(data, nullptr); | |
| 51 } | |
| 52 } | |
| 53 } // namespace blink | |
| OLD | NEW |