Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 "content/public/browser/push_messaging_application_id.h" | |
| 6 #include "testing/gtest/include/gtest/gtest.h" | |
| 7 | |
| 8 namespace content { | |
| 9 | |
| 10 TEST(PushMessagingApplicationIdTest, ConstructorValidity) { | |
| 11 EXPECT_TRUE(PushMessagingApplicationId(GURL("https://www.example.com/"), 1) | |
| 12 .is_valid()); | |
| 13 EXPECT_TRUE(PushMessagingApplicationId(GURL("https://www.example.com"), 1) | |
| 14 .is_valid()); | |
| 15 EXPECT_FALSE(PushMessagingApplicationId(GURL(""), 1).is_valid()); | |
| 16 EXPECT_FALSE(PushMessagingApplicationId(GURL("foo"), 1).is_valid()); | |
| 17 EXPECT_FALSE(PushMessagingApplicationId(GURL("https://www.example.com/foo"), | |
| 18 1).is_valid()); | |
| 19 EXPECT_FALSE(PushMessagingApplicationId(GURL("https://www.example.com/#foo"), | |
| 20 1).is_valid()); | |
| 21 EXPECT_FALSE(PushMessagingApplicationId(GURL("https://www.example.com/"), -1) | |
| 22 .is_valid()); | |
| 23 EXPECT_FALSE(PushMessagingApplicationId().is_valid()); | |
| 24 } | |
| 25 | |
| 26 TEST(PushMessagingApplicationIdTest, ToString) { | |
| 27 EXPECT_EQ(PushMessagingApplicationId(GURL("https://www.example.com/"), 1) | |
| 28 .ToString(), | |
| 29 "push#https://www.example.com/#1"); | |
| 30 EXPECT_EQ( | |
| 31 PushMessagingApplicationId(GURL("https://www.example.com"), 1).ToString(), | |
| 32 "push#https://www.example.com/#1"); | |
| 33 } | |
| 34 | |
| 35 TEST(PushMessagingApplicationIdTest, ParseValidity) { | |
| 36 EXPECT_TRUE(PushMessagingApplicationId::Parse( | |
| 37 "push#https://www.example.com/#1").is_valid()); | |
| 38 EXPECT_FALSE(PushMessagingApplicationId::Parse("").is_valid()); | |
| 39 EXPECT_FALSE(PushMessagingApplicationId::Parse( | |
| 40 "sync#https://www.example.com/#1").is_valid()); | |
| 41 EXPECT_FALSE(PushMessagingApplicationId::Parse("push#foo#1").is_valid()); | |
| 42 EXPECT_FALSE(PushMessagingApplicationId::Parse( | |
| 43 "push#https://www.example.com/foo#1").is_valid()); | |
| 44 EXPECT_FALSE(PushMessagingApplicationId::Parse( | |
| 45 "push#https://www.example.com/#one").is_valid()); | |
| 46 EXPECT_FALSE(PushMessagingApplicationId::Parse( | |
| 47 "push#https://www.example.com/#foo#1").is_valid()); | |
|
johnme
2014/07/23 12:36:57
Nit: maybe change this to "push#https://www.exampl
Michael van Ouwerkerk
2014/07/23 15:05:14
Done.
| |
| 48 EXPECT_FALSE(PushMessagingApplicationId::Parse( | |
| 49 "push#https://www.example.com/#-1").is_valid()); | |
| 50 } | |
| 51 | |
| 52 } // namespace content | |
| OLD | NEW |