OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "extensions/common/url_pattern_set.h" | 5 #include "extensions/common/url_pattern_set.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 AddPattern(&set2, "http://www.yahoo.com/*"); | 191 AddPattern(&set2, "http://www.yahoo.com/*"); |
192 | 192 |
193 EXPECT_FALSE(set1.Contains(set2)); | 193 EXPECT_FALSE(set1.Contains(set2)); |
194 EXPECT_FALSE(set2.Contains(set1)); | 194 EXPECT_FALSE(set2.Contains(set1)); |
195 | 195 |
196 AddPattern(&set2, "http://www.google.com/*"); | 196 AddPattern(&set2, "http://www.google.com/*"); |
197 | 197 |
198 EXPECT_FALSE(set1.Contains(set2)); | 198 EXPECT_FALSE(set1.Contains(set2)); |
199 EXPECT_TRUE(set2.Contains(set1)); | 199 EXPECT_TRUE(set2.Contains(set1)); |
200 | 200 |
201 // Note that this just checks pattern equality, and not if individual patterns | 201 // Note that this checks if individual patterns contain other patterns, not |
202 // contain other patterns. For example: | 202 // just equality. For example: |
203 AddPattern(&set1, "http://*.reddit.com/*"); | 203 AddPattern(&set1, "http://*.reddit.com/*"); |
204 EXPECT_FALSE(set1.Contains(set2)); | 204 EXPECT_TRUE(set1.Contains(set2)); |
205 EXPECT_FALSE(set2.Contains(set1)); | 205 EXPECT_FALSE(set2.Contains(set1)); |
206 } | 206 } |
207 | 207 |
208 TEST(URLPatternSetTest, Duplicates) { | 208 TEST(URLPatternSetTest, Duplicates) { |
209 URLPatternSet set1; | 209 URLPatternSet set1; |
210 URLPatternSet set2; | 210 URLPatternSet set2; |
211 | 211 |
212 AddPattern(&set1, "http://www.google.com/*"); | 212 AddPattern(&set1, "http://www.google.com/*"); |
213 AddPattern(&set2, "http://www.google.com/*"); | 213 AddPattern(&set2, "http://www.google.com/*"); |
214 | 214 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 AddPattern(&expected, yahoo_b); | 387 AddPattern(&expected, yahoo_b); |
388 AddPattern(&expected, yahoo_c); | 388 AddPattern(&expected, yahoo_c); |
389 AddPattern(&expected, reddit_a); | 389 AddPattern(&expected, reddit_a); |
390 AddPattern(&expected, reddit_b); | 390 AddPattern(&expected, reddit_b); |
391 AddPattern(&expected, reddit_c); | 391 AddPattern(&expected, reddit_c); |
392 EXPECT_EQ(expected, result); | 392 EXPECT_EQ(expected, result); |
393 } | 393 } |
394 } | 394 } |
395 | 395 |
396 } // namespace extensions | 396 } // namespace extensions |
OLD | NEW |