Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: chrome/common/extensions/extension_extent_unittest.cc

Issue 2876009: Re-implement app overlap detection with new extent syntax. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: donk Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/common/extensions/extension_extent.cc ('k') | chrome/common/extensions/url_pattern.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_extent.cc ('k') | chrome/common/extensions/url_pattern.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698