| 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "extensions/common/url_pattern.h" | 6 #include "extensions/common/url_pattern.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "url/gurl.h" | 8 #include "url/gurl.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 const struct { | 24 const struct { |
| 25 const char* pattern; | 25 const char* pattern; |
| 26 URLPattern::ParseResult expected_result; | 26 URLPattern::ParseResult expected_result; |
| 27 } kInvalidPatterns[] = { | 27 } kInvalidPatterns[] = { |
| 28 { "http", URLPattern::PARSE_ERROR_MISSING_SCHEME_SEPARATOR }, | 28 { "http", URLPattern::PARSE_ERROR_MISSING_SCHEME_SEPARATOR }, |
| 29 { "http:", URLPattern::PARSE_ERROR_WRONG_SCHEME_SEPARATOR }, | 29 { "http:", URLPattern::PARSE_ERROR_WRONG_SCHEME_SEPARATOR }, |
| 30 { "http:/", URLPattern::PARSE_ERROR_WRONG_SCHEME_SEPARATOR }, | 30 { "http:/", URLPattern::PARSE_ERROR_WRONG_SCHEME_SEPARATOR }, |
| 31 { "about://", URLPattern::PARSE_ERROR_WRONG_SCHEME_SEPARATOR }, | 31 { "about://", URLPattern::PARSE_ERROR_WRONG_SCHEME_SEPARATOR }, |
| 32 { "http://", URLPattern::PARSE_ERROR_EMPTY_HOST }, | 32 { "http://", URLPattern::PARSE_ERROR_EMPTY_HOST }, |
| 33 { "http:///", URLPattern::PARSE_ERROR_EMPTY_HOST }, | 33 { "http:///", URLPattern::PARSE_ERROR_EMPTY_HOST }, |
| 34 { "http:// /", URLPattern::PARSE_ERROR_EMPTY_HOST }, |
| 34 { "http://*foo/bar", URLPattern::PARSE_ERROR_INVALID_HOST_WILDCARD }, | 35 { "http://*foo/bar", URLPattern::PARSE_ERROR_INVALID_HOST_WILDCARD }, |
| 35 { "http://foo.*.bar/baz", URLPattern::PARSE_ERROR_INVALID_HOST_WILDCARD }, | 36 { "http://foo.*.bar/baz", URLPattern::PARSE_ERROR_INVALID_HOST_WILDCARD }, |
| 36 { "http://fo.*.ba:123/baz", URLPattern::PARSE_ERROR_INVALID_HOST_WILDCARD }, | 37 { "http://fo.*.ba:123/baz", URLPattern::PARSE_ERROR_INVALID_HOST_WILDCARD }, |
| 37 { "http:/bar", URLPattern::PARSE_ERROR_WRONG_SCHEME_SEPARATOR }, | 38 { "http:/bar", URLPattern::PARSE_ERROR_WRONG_SCHEME_SEPARATOR }, |
| 38 { "http://bar", URLPattern::PARSE_ERROR_EMPTY_PATH }, | 39 { "http://bar", URLPattern::PARSE_ERROR_EMPTY_PATH }, |
| 39 }; | 40 }; |
| 40 | 41 |
| 41 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kInvalidPatterns); ++i) { | 42 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kInvalidPatterns); ++i) { |
| 42 URLPattern pattern(URLPattern::SCHEME_ALL); | 43 URLPattern pattern(URLPattern::SCHEME_ALL); |
| 43 EXPECT_EQ(kInvalidPatterns[i].expected_result, | 44 EXPECT_EQ(kInvalidPatterns[i].expected_result, |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 EXPECT_TRUE(StrictlyContains(pattern10, pattern12)); | 795 EXPECT_TRUE(StrictlyContains(pattern10, pattern12)); |
| 795 EXPECT_TRUE(StrictlyContains(pattern10, pattern13)); | 796 EXPECT_TRUE(StrictlyContains(pattern10, pattern13)); |
| 796 | 797 |
| 797 // More... | 798 // More... |
| 798 EXPECT_TRUE(StrictlyContains(pattern12, pattern11)); | 799 EXPECT_TRUE(StrictlyContains(pattern12, pattern11)); |
| 799 EXPECT_TRUE(NeitherContains(pattern11, pattern13)); | 800 EXPECT_TRUE(NeitherContains(pattern11, pattern13)); |
| 800 EXPECT_TRUE(StrictlyContains(pattern12, pattern13)); | 801 EXPECT_TRUE(StrictlyContains(pattern12, pattern13)); |
| 801 } | 802 } |
| 802 | 803 |
| 803 } // namespace | 804 } // namespace |
| OLD | NEW |