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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 279 |
280 std::vector<std::string> patterns; | 280 std::vector<std::string> patterns; |
281 patterns.push_back("http://www.google.com/*"); | 281 patterns.push_back("http://www.google.com/*"); |
282 patterns.push_back("http://www.yahoo.com/*"); | 282 patterns.push_back("http://www.yahoo.com/*"); |
283 | 283 |
284 for (size_t i = 0; i < patterns.size(); ++i) | 284 for (size_t i = 0; i < patterns.size(); ++i) |
285 AddPattern(&set1, patterns[i]); | 285 AddPattern(&set1, patterns[i]); |
286 | 286 |
287 std::string error; | 287 std::string error; |
288 bool allow_file_access = false; | 288 bool allow_file_access = false; |
289 scoped_ptr<base::ListValue> value(set1.ToValue()); | 289 std::unique_ptr<base::ListValue> value(set1.ToValue()); |
290 set2.Populate(*value, URLPattern::SCHEME_ALL, allow_file_access, &error); | 290 set2.Populate(*value, URLPattern::SCHEME_ALL, allow_file_access, &error); |
291 EXPECT_EQ(set1, set2); | 291 EXPECT_EQ(set1, set2); |
292 | 292 |
293 set2.ClearPatterns(); | 293 set2.ClearPatterns(); |
294 set2.Populate(patterns, URLPattern::SCHEME_ALL, allow_file_access, &error); | 294 set2.Populate(patterns, URLPattern::SCHEME_ALL, allow_file_access, &error); |
295 EXPECT_EQ(set1, set2); | 295 EXPECT_EQ(set1, set2); |
296 } | 296 } |
297 | 297 |
298 TEST(URLPatternSetTest, NwayUnion) { | 298 TEST(URLPatternSetTest, NwayUnion) { |
299 std::string google_a = "http://www.google.com/a*"; | 299 std::string google_a = "http://www.google.com/a*"; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 EXPECT_FALSE(set.AddOrigin( | 456 EXPECT_FALSE(set.AddOrigin( |
457 URLPattern::SCHEME_HTTP, GURL("https://google.com/"))); | 457 URLPattern::SCHEME_HTTP, GURL("https://google.com/"))); |
458 } | 458 } |
459 | 459 |
460 TEST(URLPatternSetTest, ToStringVector) { | 460 TEST(URLPatternSetTest, ToStringVector) { |
461 URLPatternSet set; | 461 URLPatternSet set; |
462 AddPattern(&set, "https://google.com/"); | 462 AddPattern(&set, "https://google.com/"); |
463 AddPattern(&set, "https://google.com/"); | 463 AddPattern(&set, "https://google.com/"); |
464 AddPattern(&set, "https://yahoo.com/"); | 464 AddPattern(&set, "https://yahoo.com/"); |
465 | 465 |
466 scoped_ptr<std::vector<std::string>> string_vector(set.ToStringVector()); | 466 std::unique_ptr<std::vector<std::string>> string_vector(set.ToStringVector()); |
467 | 467 |
468 EXPECT_EQ(2UL, string_vector->size()); | 468 EXPECT_EQ(2UL, string_vector->size()); |
469 | 469 |
470 const auto begin = string_vector->begin(); | 470 const auto begin = string_vector->begin(); |
471 const auto end = string_vector->end(); | 471 const auto end = string_vector->end(); |
472 | 472 |
473 auto it = std::find(begin, end, "https://google.com/"); | 473 auto it = std::find(begin, end, "https://google.com/"); |
474 EXPECT_NE(it, end); | 474 EXPECT_NE(it, end); |
475 it = std::find(begin, end, "https://yahoo.com/"); | 475 it = std::find(begin, end, "https://yahoo.com/"); |
476 EXPECT_NE(it, end); | 476 EXPECT_NE(it, end); |
477 } | 477 } |
478 | 478 |
479 } // namespace extensions | 479 } // namespace extensions |
OLD | NEW |