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

Side by Side Diff: url/gurl_unittest.cc

Issue 185133005: Move referrer stripping into GURL::GetAsReferrer(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switch over the Android ContextMenuHelper. Created 6 years, 9 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
« net/url_request/url_request.cc ('K') | « url/gurl.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "url/gurl.h" 6 #include "url/gurl.h"
7 #include "url/url_canon.h" 7 #include "url/url_canon.h"
8 #include "url/url_test_utils.h" 8 #include "url/url_test_utils.h"
9 9
10 // Some implementations of base/basictypes.h may define ARRAYSIZE. 10 // Some implementations of base/basictypes.h may define ARRAYSIZE.
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 {"filesystem:http://www.google.com/temp/foo?q#b", "http://www.google.com/"}, 280 {"filesystem:http://www.google.com/temp/foo?q#b", "http://www.google.com/"},
281 {"filesystem:http://user:pass@google.com:21/blah#baz", "http://google.com:21 /"}, 281 {"filesystem:http://user:pass@google.com:21/blah#baz", "http://google.com:21 /"},
282 }; 282 };
283 for (size_t i = 0; i < ARRAYSIZE(cases); i++) { 283 for (size_t i = 0; i < ARRAYSIZE(cases); i++) {
284 GURL url(cases[i].input); 284 GURL url(cases[i].input);
285 GURL origin = url.GetOrigin(); 285 GURL origin = url.GetOrigin();
286 EXPECT_EQ(cases[i].expected, origin.spec()); 286 EXPECT_EQ(cases[i].expected, origin.spec());
287 } 287 }
288 } 288 }
289 289
290 TEST(GURLTest, GetAsReferrer) {
291 struct TestCase {
292 const char* input;
293 const char* expected;
294 } cases[] = {
295 {"http://www.google.com", "http://www.google.com/"},
296 {"http://user:pass@www.google.com:21/blah#baz", "http://www.google.com:21/bl ah"},
297 {"http://user@www.google.com", "http://www.google.com/"},
298 {"http://:pass@www.google.com", "http://www.google.com/"},
299 {"http://:@www.google.com", "http://www.google.com/"},
300 {"http://www.google.com/temp/foo?q#b", "http://www.google.com/temp/foo?q"},
301 };
302 for (size_t i = 0; i < ARRAYSIZE(cases); i++) {
303 GURL url(cases[i].input);
304 GURL origin = url.GetAsReferrer();
305 EXPECT_EQ(cases[i].expected, origin.spec());
306 }
307 }
308
290 TEST(GURLTest, GetWithEmptyPath) { 309 TEST(GURLTest, GetWithEmptyPath) {
291 struct TestCase { 310 struct TestCase {
292 const char* input; 311 const char* input;
293 const char* expected; 312 const char* expected;
294 } cases[] = { 313 } cases[] = {
295 {"http://www.google.com", "http://www.google.com/"}, 314 {"http://www.google.com", "http://www.google.com/"},
296 {"javascript:window.alert(\"hello, world\");", ""}, 315 {"javascript:window.alert(\"hello, world\");", ""},
297 {"http://www.google.com/foo/bar.html?baz=22", "http://www.google.com/"}, 316 {"http://www.google.com/foo/bar.html?baz=22", "http://www.google.com/"},
298 {"filesystem:http://www.google.com/temporary/bar.html?baz=22", "filesystem:h ttp://www.google.com/temporary/"}, 317 {"filesystem:http://www.google.com/temporary/bar.html?baz=22", "filesystem:h ttp://www.google.com/temporary/"},
299 {"filesystem:file:///temporary/bar.html?baz=22", "filesystem:file:///tempora ry/"}, 318 {"filesystem:file:///temporary/bar.html?baz=22", "filesystem:file:///tempora ry/"},
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 EXPECT_TRUE(GURL("http://bar/").SchemeIsHTTPOrHTTPS()); 576 EXPECT_TRUE(GURL("http://bar/").SchemeIsHTTPOrHTTPS());
558 EXPECT_TRUE(GURL("HTTPS://BAR").SchemeIsHTTPOrHTTPS()); 577 EXPECT_TRUE(GURL("HTTPS://BAR").SchemeIsHTTPOrHTTPS());
559 EXPECT_FALSE(GURL("ftp://bar/").SchemeIsHTTPOrHTTPS()); 578 EXPECT_FALSE(GURL("ftp://bar/").SchemeIsHTTPOrHTTPS());
560 } 579 }
561 580
562 TEST(GURLTest, SchemeIsWSOrWSS) { 581 TEST(GURLTest, SchemeIsWSOrWSS) {
563 EXPECT_TRUE(GURL("WS://BAR/").SchemeIsWSOrWSS()); 582 EXPECT_TRUE(GURL("WS://BAR/").SchemeIsWSOrWSS());
564 EXPECT_TRUE(GURL("wss://bar/").SchemeIsWSOrWSS()); 583 EXPECT_TRUE(GURL("wss://bar/").SchemeIsWSOrWSS());
565 EXPECT_FALSE(GURL("http://bar/").SchemeIsWSOrWSS()); 584 EXPECT_FALSE(GURL("http://bar/").SchemeIsWSOrWSS());
566 } 585 }
OLDNEW
« net/url_request/url_request.cc ('K') | « url/gurl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698