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..8785eab38fa861241f7563e7f02f50433b3f73c2 |
--- /dev/null |
+++ b/content/browser/push_messaging_application_id_unittest.cc |
@@ -0,0 +1,54 @@ |
+// 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) |
+ .IsValid()); |
+ EXPECT_TRUE( |
+ PushMessagingApplicationId(GURL("https://www.example.com"), 1).IsValid()); |
+ EXPECT_FALSE(PushMessagingApplicationId(GURL(""), 1).IsValid()); |
+ EXPECT_FALSE(PushMessagingApplicationId(GURL("foo"), 1).IsValid()); |
+ EXPECT_FALSE(PushMessagingApplicationId(GURL("https://www.example.com/foo"), |
+ 1).IsValid()); |
+ EXPECT_FALSE(PushMessagingApplicationId(GURL("https://www.example.com/#foo"), |
+ 1).IsValid()); |
+ EXPECT_FALSE(PushMessagingApplicationId(GURL("https://www.example.com/"), -1) |
+ .IsValid()); |
+ EXPECT_FALSE(PushMessagingApplicationId().IsValid()); |
+} |
+ |
+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").IsValid()); |
+ EXPECT_FALSE(PushMessagingApplicationId::Parse("").IsValid()); |
+ EXPECT_FALSE(PushMessagingApplicationId::Parse( |
+ "sync#https://www.example.com/#1").IsValid()); |
+ EXPECT_FALSE(PushMessagingApplicationId::Parse("push#foo#1").IsValid()); |
+ EXPECT_FALSE(PushMessagingApplicationId::Parse( |
+ "push#https://www.example.com/foo#1").IsValid()); |
+ EXPECT_FALSE(PushMessagingApplicationId::Parse( |
+ "push#https://www.example.com/#one").IsValid()); |
+ EXPECT_FALSE(PushMessagingApplicationId::Parse( |
+ "push#https://www.example.com/#foo#1").IsValid()); |
+ EXPECT_FALSE(PushMessagingApplicationId::Parse( |
+ "push#https://www.example.com/#1#1").IsValid()); |
+ EXPECT_FALSE(PushMessagingApplicationId::Parse( |
+ "push#https://www.example.com/#-1").IsValid()); |
+} |
+ |
+} // namespace content |