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) { |
(...skipping 15 matching lines...) Expand all Loading... |
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::CreateFromString("http://www.google.com/*")); |
30 extent.AddPattern(*URLPattern::CreateFromString("http://www.yahoo.com/*")); | 30 extent.AddPattern(*URLPattern::CreateFromString("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 } |
| 36 |
| 37 TEST(ExtensionExtentTest, OverlapsWith) { |
| 38 ExtensionExtent extent1; |
| 39 extent1.AddPattern(*URLPattern::CreateFromString("http://www.google.com/f*")); |
| 40 extent1.AddPattern(*URLPattern::CreateFromString("http://www.yahoo.com/b*")); |
| 41 |
| 42 ExtensionExtent extent2; |
| 43 extent2.AddPattern(*URLPattern::CreateFromString("http://www.reddit.com/f*")); |
| 44 extent2.AddPattern(*URLPattern::CreateFromString("http://www.yahoo.com/z*")); |
| 45 |
| 46 ExtensionExtent extent3; |
| 47 extent3.AddPattern(*URLPattern::CreateFromString( |
| 48 "http://www.google.com/q/*")); |
| 49 extent3.AddPattern(*URLPattern::CreateFromString("http://www.yahoo.com/b/*")); |
| 50 |
| 51 EXPECT_FALSE(extent1.OverlapsWith(extent2)); |
| 52 EXPECT_FALSE(extent2.OverlapsWith(extent1)); |
| 53 |
| 54 EXPECT_TRUE(extent1.OverlapsWith(extent3)); |
| 55 EXPECT_TRUE(extent3.OverlapsWith(extent1)); |
| 56 } |
OLD | NEW |