Chromium Code Reviews| Index: content/browser/push_messaging_application_id_unittest.cc |
| diff --git a/content/browser/push_messaging_application_id_unittest.cc b/content/browser/push_messaging_application_id_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..12fd7ed94984b14f0153b8bb6c92766d60cb173e |
| --- /dev/null |
| +++ b/content/browser/push_messaging_application_id_unittest.cc |
| @@ -0,0 +1,52 @@ |
| +// Copyright 2014 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 "content/public/browser/push_messaging_application_id.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace content { |
| + |
| +TEST(PushMessagingApplicationIdTest, ConstructorValidity) { |
| + EXPECT_TRUE(PushMessagingApplicationId(GURL("https://www.example.com/"), 1) |
| + .is_valid()); |
| + EXPECT_TRUE(PushMessagingApplicationId(GURL("https://www.example.com"), 1) |
| + .is_valid()); |
| + EXPECT_FALSE(PushMessagingApplicationId(GURL(""), 1).is_valid()); |
| + EXPECT_FALSE(PushMessagingApplicationId(GURL("foo"), 1).is_valid()); |
| + EXPECT_FALSE(PushMessagingApplicationId(GURL("https://www.example.com/foo"), |
| + 1).is_valid()); |
| + EXPECT_FALSE(PushMessagingApplicationId(GURL("https://www.example.com/#foo"), |
| + 1).is_valid()); |
| + EXPECT_FALSE(PushMessagingApplicationId(GURL("https://www.example.com/"), -1) |
| + .is_valid()); |
| + EXPECT_FALSE(PushMessagingApplicationId().is_valid()); |
| +} |
| + |
| +TEST(PushMessagingApplicationIdTest, ToString) { |
| + EXPECT_EQ(PushMessagingApplicationId(GURL("https://www.example.com/"), 1) |
| + .ToString(), |
| + "push#https://www.example.com/#1"); |
| + EXPECT_EQ( |
| + PushMessagingApplicationId(GURL("https://www.example.com"), 1).ToString(), |
| + "push#https://www.example.com/#1"); |
| +} |
| + |
| +TEST(PushMessagingApplicationIdTest, ParseValidity) { |
| + EXPECT_TRUE(PushMessagingApplicationId::Parse( |
| + "push#https://www.example.com/#1").is_valid()); |
| + EXPECT_FALSE(PushMessagingApplicationId::Parse("").is_valid()); |
| + EXPECT_FALSE(PushMessagingApplicationId::Parse( |
| + "sync#https://www.example.com/#1").is_valid()); |
| + EXPECT_FALSE(PushMessagingApplicationId::Parse("push#foo#1").is_valid()); |
| + EXPECT_FALSE(PushMessagingApplicationId::Parse( |
| + "push#https://www.example.com/foo#1").is_valid()); |
| + EXPECT_FALSE(PushMessagingApplicationId::Parse( |
| + "push#https://www.example.com/#one").is_valid()); |
| + EXPECT_FALSE(PushMessagingApplicationId::Parse( |
| + "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.
|
| + EXPECT_FALSE(PushMessagingApplicationId::Parse( |
| + "push#https://www.example.com/#-1").is_valid()); |
| +} |
| + |
| +} // namespace content |