OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/extensions/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
6 | 6 |
7 #include "googleurl/src/gurl.h" | 7 #include "googleurl/src/gurl.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 TEST(ExtensionExtentTest, Empty) { | 10 TEST(ExtensionExtentTest, Empty) { |
11 ExtensionExtent extent; | 11 ExtensionExtent extent; |
12 EXPECT_FALSE(extent.ContainsURL(GURL("http://www.foo.com/bar"))); | 12 EXPECT_FALSE(extent.ContainsURL(GURL("http://www.foo.com/bar"))); |
13 EXPECT_FALSE(extent.ContainsURL(GURL())); | 13 EXPECT_FALSE(extent.ContainsURL(GURL())); |
14 EXPECT_FALSE(extent.ContainsURL(GURL("invalid"))); | 14 EXPECT_FALSE(extent.ContainsURL(GURL("invalid"))); |
15 } | 15 } |
16 | 16 |
17 TEST(ExtensionExtentTest, One) { | 17 TEST(ExtensionExtentTest, One) { |
18 ExtensionExtent extent; | 18 ExtensionExtent extent; |
19 extent.AddPattern(*URLPattern::CreateFromString("http://www.google.com/*")); | 19 extent.AddPattern(URLPattern("http://www.google.com/*")); |
20 | 20 |
21 EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/"))); | 21 EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/"))); |
22 EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/monkey"))); | 22 EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/monkey"))); |
23 EXPECT_FALSE(extent.ContainsURL(GURL("https://www.google.com/"))); | 23 EXPECT_FALSE(extent.ContainsURL(GURL("https://www.google.com/"))); |
24 EXPECT_FALSE(extent.ContainsURL(GURL("https://www.microsoft.com/"))); | 24 EXPECT_FALSE(extent.ContainsURL(GURL("https://www.microsoft.com/"))); |
25 } | 25 } |
26 | 26 |
27 TEST(ExtensionExtentTest, Two) { | 27 TEST(ExtensionExtentTest, Two) { |
28 ExtensionExtent extent; | 28 ExtensionExtent extent; |
29 extent.AddPattern(*URLPattern::CreateFromString("http://www.google.com/*")); | 29 extent.AddPattern(URLPattern("http://www.google.com/*")); |
30 extent.AddPattern(*URLPattern::CreateFromString("http://www.yahoo.com/*")); | 30 extent.AddPattern(URLPattern("http://www.yahoo.com/*")); |
31 | 31 |
32 EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/monkey"))); | 32 EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/monkey"))); |
33 EXPECT_TRUE(extent.ContainsURL(GURL("http://www.yahoo.com/monkey"))); | 33 EXPECT_TRUE(extent.ContainsURL(GURL("http://www.yahoo.com/monkey"))); |
34 EXPECT_FALSE(extent.ContainsURL(GURL("https://www.apple.com/monkey"))); | 34 EXPECT_FALSE(extent.ContainsURL(GURL("https://www.apple.com/monkey"))); |
35 } | 35 } |
OLD | NEW |