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

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

Issue 8138004: Fix issues related to <all_urls> in extensions. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: make the plugin.dll empty so it loads everywhere Created 9 years, 2 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/common/extensions/url_pattern.h" 6 #include "chrome/common/extensions/url_pattern.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "googleurl/src/gurl.h" 8 #include "googleurl/src/gurl.h"
9 9
10 // See url_pattern.h for examples of valid and invalid patterns. 10 // See url_pattern.h for examples of valid and invalid patterns.
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 EXPECT_TRUE(pattern.MatchesScheme("http")); 288 EXPECT_TRUE(pattern.MatchesScheme("http"));
289 EXPECT_TRUE(pattern.MatchesScheme("https")); 289 EXPECT_TRUE(pattern.MatchesScheme("https"));
290 EXPECT_TRUE(pattern.MatchesScheme("file")); 290 EXPECT_TRUE(pattern.MatchesScheme("file"));
291 EXPECT_TRUE(pattern.match_subdomains()); 291 EXPECT_TRUE(pattern.match_subdomains());
292 EXPECT_TRUE(pattern.match_all_urls()); 292 EXPECT_TRUE(pattern.match_all_urls());
293 EXPECT_EQ("/*", pattern.path()); 293 EXPECT_EQ("/*", pattern.path());
294 EXPECT_TRUE(pattern.MatchesURL(GURL("chrome://favicon/http://google.com"))); 294 EXPECT_TRUE(pattern.MatchesURL(GURL("chrome://favicon/http://google.com")));
295 EXPECT_TRUE(pattern.MatchesURL(GURL("http://127.0.0.1"))); 295 EXPECT_TRUE(pattern.MatchesURL(GURL("http://127.0.0.1")));
296 EXPECT_TRUE(pattern.MatchesURL(GURL("file:///foo/bar"))); 296 EXPECT_TRUE(pattern.MatchesURL(GURL("file:///foo/bar")));
297 EXPECT_TRUE(pattern.MatchesURL(GURL("file://localhost/foo/bar"))); 297 EXPECT_TRUE(pattern.MatchesURL(GURL("file://localhost/foo/bar")));
298
299 // Make sure the properties are the same when creating an <all_urls> pattern
300 // via SetMatchAllURLs and by parsing <all_urls>.
301 URLPattern pattern2(kAllSchemes);
302 pattern2.SetMatchAllURLs(true);
303
304 EXPECT_EQ(pattern.valid_schemes(), pattern2.valid_schemes());
305 EXPECT_EQ(pattern.match_subdomains(), pattern2.match_subdomains());
306 EXPECT_EQ(pattern.path(), pattern2.path());
307 EXPECT_EQ(pattern.match_all_urls(), pattern2.match_all_urls());
308 EXPECT_EQ(pattern.scheme(), pattern2.scheme());
309 EXPECT_EQ(pattern.port(), pattern2.port());
310 EXPECT_EQ(pattern.GetAsString(), pattern2.GetAsString());
298 }; 311 };
299 312
300 // SCHEME_ALL matches all schemes. 313 // SCHEME_ALL matches all schemes.
301 TEST(ExtensionURLPatternTest, Match12) { 314 TEST(ExtensionURLPatternTest, Match12) {
302 URLPattern pattern(URLPattern::SCHEME_ALL); 315 URLPattern pattern(URLPattern::SCHEME_ALL);
303 EXPECT_EQ(URLPattern::PARSE_SUCCESS, 316 EXPECT_EQ(URLPattern::PARSE_SUCCESS,
304 pattern.Parse("<all_urls>", URLPattern::ERROR_ON_PORTS)); 317 pattern.Parse("<all_urls>", URLPattern::ERROR_ON_PORTS));
305 EXPECT_TRUE(pattern.MatchesScheme("chrome")); 318 EXPECT_TRUE(pattern.MatchesScheme("chrome"));
306 EXPECT_TRUE(pattern.MatchesScheme("http")); 319 EXPECT_TRUE(pattern.MatchesScheme("http"));
307 EXPECT_TRUE(pattern.MatchesScheme("https")); 320 EXPECT_TRUE(pattern.MatchesScheme("https"));
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 680
668 URLPattern pattern1(URLPattern::SCHEME_ALL); 681 URLPattern pattern1(URLPattern::SCHEME_ALL);
669 URLPattern pattern2(URLPattern::SCHEME_ALL); 682 URLPattern pattern2(URLPattern::SCHEME_ALL);
670 683
671 pattern1.Parse(kEqualsTestCases[i].pattern1, URLPattern::USE_PORTS); 684 pattern1.Parse(kEqualsTestCases[i].pattern1, URLPattern::USE_PORTS);
672 pattern2.Parse(kEqualsTestCases[i].pattern2, URLPattern::USE_PORTS); 685 pattern2.Parse(kEqualsTestCases[i].pattern2, URLPattern::USE_PORTS);
673 EXPECT_EQ(kEqualsTestCases[i].expected_equal, pattern1 == pattern2) 686 EXPECT_EQ(kEqualsTestCases[i].expected_equal, pattern1 == pattern2)
674 << message; 687 << message;
675 } 688 }
676 } 689 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698