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

Side by Side Diff: extensions/common/url_pattern_unittest.cc

Issue 364703002: Return if a host name in an URLPattern has no non-whitespace characters. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 | « extensions/common/url_pattern.cc ('k') | no next file » | 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) 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
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
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
OLDNEW
« no previous file with comments | « extensions/common/url_pattern.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698