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

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

Issue 6804032: Add TLS-SRP (RFC 5054) support Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: use system srp and mpi libs, not local copies Created 9 years, 8 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 | Annotate | Revision Log
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 static const int kAllSchemes = 10 static const int kAllSchemes =
(...skipping 11 matching lines...) Expand all
22 } 22 }
23 23
24 TEST(ExtensionExtentTest, One) { 24 TEST(ExtensionExtentTest, One) {
25 ExtensionExtent extent; 25 ExtensionExtent extent;
26 extent.AddPattern(URLPattern(kAllSchemes, "http://www.google.com/*")); 26 extent.AddPattern(URLPattern(kAllSchemes, "http://www.google.com/*"));
27 27
28 EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/"))); 28 EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/")));
29 EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/monkey"))); 29 EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/monkey")));
30 EXPECT_FALSE(extent.ContainsURL(GURL("https://www.google.com/"))); 30 EXPECT_FALSE(extent.ContainsURL(GURL("https://www.google.com/")));
31 EXPECT_FALSE(extent.ContainsURL(GURL("https://www.microsoft.com/"))); 31 EXPECT_FALSE(extent.ContainsURL(GURL("https://www.microsoft.com/")));
32 EXPECT_FALSE(extent.ContainsURL(GURL("httpsv://www.microsoft.com/")));
32 } 33 }
33 34
34 TEST(ExtensionExtentTest, Two) { 35 TEST(ExtensionExtentTest, Two) {
35 ExtensionExtent extent; 36 ExtensionExtent extent;
36 extent.AddPattern(URLPattern(kAllSchemes, "http://www.google.com/*")); 37 extent.AddPattern(URLPattern(kAllSchemes, "http://www.google.com/*"));
37 extent.AddPattern(URLPattern(kAllSchemes, "http://www.yahoo.com/*")); 38 extent.AddPattern(URLPattern(kAllSchemes, "http://www.yahoo.com/*"));
38 39
39 EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/monkey"))); 40 EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/monkey")));
40 EXPECT_TRUE(extent.ContainsURL(GURL("http://www.yahoo.com/monkey"))); 41 EXPECT_TRUE(extent.ContainsURL(GURL("http://www.yahoo.com/monkey")));
41 EXPECT_FALSE(extent.ContainsURL(GURL("https://www.apple.com/monkey"))); 42 EXPECT_FALSE(extent.ContainsURL(GURL("https://www.apple.com/monkey")));
43 EXPECT_FALSE(extent.ContainsURL(GURL("httpsv://www.apple.com/monkey")));
44 }
45
46 TEST(ExtensionExtentTest, SeparateHTTPSAndHTTPSV) {
47 ExtensionExtent extent;
48 extent.AddPattern(URLPattern(kAllSchemes, "https://www.google.com/*"));
49
50 EXPECT_FALSE(extent.ContainsURL(GURL("httpsv://www.google.com/")));
42 } 51 }
43 52
44 TEST(ExtensionExtentTest, OverlapsWith) { 53 TEST(ExtensionExtentTest, OverlapsWith) {
45 ExtensionExtent extent1; 54 ExtensionExtent extent1;
46 extent1.AddPattern(URLPattern(kAllSchemes, "http://www.google.com/f*")); 55 extent1.AddPattern(URLPattern(kAllSchemes, "http://www.google.com/f*"));
47 extent1.AddPattern(URLPattern(kAllSchemes, "http://www.yahoo.com/b*")); 56 extent1.AddPattern(URLPattern(kAllSchemes, "http://www.yahoo.com/b*"));
48 57
49 ExtensionExtent extent2; 58 ExtensionExtent extent2;
50 extent2.AddPattern(URLPattern(kAllSchemes, "http://www.reddit.com/f*")); 59 extent2.AddPattern(URLPattern(kAllSchemes, "http://www.reddit.com/f*"));
51 extent2.AddPattern(URLPattern(kAllSchemes, "http://www.yahoo.com/z*")); 60 extent2.AddPattern(URLPattern(kAllSchemes, "http://www.yahoo.com/z*"));
52 61
53 ExtensionExtent extent3; 62 ExtensionExtent extent3;
54 extent3.AddPattern(URLPattern(kAllSchemes, "http://www.google.com/q/*")); 63 extent3.AddPattern(URLPattern(kAllSchemes, "http://www.google.com/q/*"));
55 extent3.AddPattern(URLPattern(kAllSchemes, "http://www.yahoo.com/b/*")); 64 extent3.AddPattern(URLPattern(kAllSchemes, "http://www.yahoo.com/b/*"));
56 65
57 EXPECT_FALSE(extent1.OverlapsWith(extent2)); 66 EXPECT_FALSE(extent1.OverlapsWith(extent2));
58 EXPECT_FALSE(extent2.OverlapsWith(extent1)); 67 EXPECT_FALSE(extent2.OverlapsWith(extent1));
59 68
60 EXPECT_TRUE(extent1.OverlapsWith(extent3)); 69 EXPECT_TRUE(extent1.OverlapsWith(extent3));
61 EXPECT_TRUE(extent3.OverlapsWith(extent1)); 70 EXPECT_TRUE(extent3.OverlapsWith(extent1));
62 } 71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698