Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: third_party/WebKit/Source/modules/push_messaging/PushMessageDataTest.cpp

Issue 1636483002: Update the PushEvent to have a nullable PushMessageData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and integrate OWNERS code review comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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"
Peter Beverloo 2016/01/27 17:30:49 Ugh. This should read: #include "public/platform
harkness 2016/01/27 17:49:07 oops.
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698