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

Side by Side Diff: chrome/browser/services/gcm/push_messaging_application_id_unittest.cc

Issue 404353003: Define PushMessagingApplicationId and replace ad-hoc code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments from jam and fgorski. Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 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 "chrome/browser/services/gcm/push_messaging_application_id.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 TEST(PushMessagingApplicationIdTest, ConstructorValidity) {
9 EXPECT_TRUE(gcm::PushMessagingApplicationId(GURL("https://www.example.com/"),
10 1).IsValid());
11 EXPECT_TRUE(gcm::PushMessagingApplicationId(GURL("https://www.example.com"),
12 1).IsValid());
13 EXPECT_FALSE(gcm::PushMessagingApplicationId(GURL(""), 1).IsValid());
14 EXPECT_FALSE(gcm::PushMessagingApplicationId(GURL("foo"), 1).IsValid());
15 EXPECT_FALSE(gcm::PushMessagingApplicationId(
16 GURL("https://www.example.com/foo"), 1).IsValid());
17 EXPECT_FALSE(gcm::PushMessagingApplicationId(
18 GURL("https://www.example.com/#foo"), 1).IsValid());
19 EXPECT_FALSE(gcm::PushMessagingApplicationId(GURL("https://www.example.com/"),
20 -1).IsValid());
21 EXPECT_FALSE(gcm::PushMessagingApplicationId().IsValid());
22 }
23
24 TEST(PushMessagingApplicationIdTest, ToString) {
25 EXPECT_EQ(gcm::PushMessagingApplicationId(GURL("https://www.example.com/"), 1)
26 .ToString(),
27 "push#https://www.example.com/#1");
28 EXPECT_EQ(gcm::PushMessagingApplicationId(GURL("https://www.example.com"), 1)
29 .ToString(),
30 "push#https://www.example.com/#1");
31 }
32
33 TEST(PushMessagingApplicationIdTest, ParseValidity) {
34 EXPECT_TRUE(gcm::PushMessagingApplicationId::Parse(
35 "push#https://www.example.com/#1").IsValid());
36 EXPECT_FALSE(gcm::PushMessagingApplicationId::Parse("").IsValid());
37 EXPECT_FALSE(gcm::PushMessagingApplicationId::Parse(
38 "sync#https://www.example.com/#1").IsValid());
39 EXPECT_FALSE(gcm::PushMessagingApplicationId::Parse("push#foo#1").IsValid());
40 EXPECT_FALSE(gcm::PushMessagingApplicationId::Parse(
41 "push#https://www.example.com/foo#1").IsValid());
42 EXPECT_FALSE(gcm::PushMessagingApplicationId::Parse(
43 "push#https://www.example.com/#one").IsValid());
44 EXPECT_FALSE(gcm::PushMessagingApplicationId::Parse(
45 "push#https://www.example.com/#foo#1").IsValid());
46 EXPECT_FALSE(gcm::PushMessagingApplicationId::Parse(
47 "push#https://www.example.com/#1#1").IsValid());
48 EXPECT_FALSE(gcm::PushMessagingApplicationId::Parse(
49 "push#https://www.example.com/#-1").IsValid());
50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698