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

Side by Side Diff: url/origin_unittest.cc

Issue 2387143003: Fix SchemeHostPort::GetURL() and add more tests (Closed)
Patch Set: Created 4 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
« no previous file with comments | « no previous file | url/scheme_host_port.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "url/gurl.h" 11 #include "url/gurl.h"
12 #include "url/origin.h" 12 #include "url/origin.h"
13 13
14 namespace { 14 namespace {
15 15
16 void ExpectParsedComponentEqual(const url::Component& a,
17 const url::Component& b) {
18 EXPECT_EQ(a.begin, b.begin);
19 EXPECT_EQ(a.len, b.len);
20 }
21
22 void ExpectParsedUrlsEqual(const GURL& a, const GURL& b) { 16 void ExpectParsedUrlsEqual(const GURL& a, const GURL& b) {
23 EXPECT_EQ(a, b); 17 EXPECT_EQ(a, b);
24 const url::Parsed& a_parsed = a.parsed_for_possibly_invalid_spec(); 18 const url::Parsed& a_parsed = a.parsed_for_possibly_invalid_spec();
25 const url::Parsed& b_parsed = b.parsed_for_possibly_invalid_spec(); 19 const url::Parsed& b_parsed = b.parsed_for_possibly_invalid_spec();
26 ExpectParsedComponentEqual(a_parsed.scheme, b_parsed.scheme); 20 EXPECT_EQ(a_parsed.scheme.begin, b_parsed.scheme.begin);
27 ExpectParsedComponentEqual(a_parsed.username, b_parsed.username); 21 EXPECT_EQ(a_parsed.scheme.len, b_parsed.scheme.len);
28 ExpectParsedComponentEqual(a_parsed.password, b_parsed.password); 22 EXPECT_EQ(a_parsed.username.begin, b_parsed.username.begin);
29 ExpectParsedComponentEqual(a_parsed.host, b_parsed.host); 23 EXPECT_EQ(a_parsed.username.len, b_parsed.username.len);
30 ExpectParsedComponentEqual(a_parsed.port, b_parsed.port); 24 EXPECT_EQ(a_parsed.password.begin, b_parsed.password.begin);
31 ExpectParsedComponentEqual(a_parsed.path, b_parsed.path); 25 EXPECT_EQ(a_parsed.password.len, b_parsed.password.len);
32 ExpectParsedComponentEqual(a_parsed.query, b_parsed.query); 26 EXPECT_EQ(a_parsed.host.begin, b_parsed.host.begin);
33 ExpectParsedComponentEqual(a_parsed.ref, b_parsed.ref); 27 EXPECT_EQ(a_parsed.host.len, b_parsed.host.len);
28 EXPECT_EQ(a_parsed.port.begin, b_parsed.port.begin);
29 EXPECT_EQ(a_parsed.port.len, b_parsed.port.len);
30 EXPECT_EQ(a_parsed.path.begin, b_parsed.path.begin);
31 EXPECT_EQ(a_parsed.path.len, b_parsed.path.len);
32 EXPECT_EQ(a_parsed.query.begin, b_parsed.query.begin);
33 EXPECT_EQ(a_parsed.query.len, b_parsed.query.len);
34 EXPECT_EQ(a_parsed.ref.begin, b_parsed.ref.begin);
35 EXPECT_EQ(a_parsed.ref.len, b_parsed.ref.len);
34 } 36 }
35 37
36 TEST(OriginTest, UniqueOriginComparison) { 38 TEST(OriginTest, UniqueOriginComparison) {
37 url::Origin unique_origin; 39 url::Origin unique_origin;
38 EXPECT_EQ("", unique_origin.scheme()); 40 EXPECT_EQ("", unique_origin.scheme());
39 EXPECT_EQ("", unique_origin.host()); 41 EXPECT_EQ("", unique_origin.host());
40 EXPECT_EQ(0, unique_origin.port()); 42 EXPECT_EQ(0, unique_origin.port());
41 EXPECT_TRUE(unique_origin.unique()); 43 EXPECT_TRUE(unique_origin.unique());
42 EXPECT_FALSE(unique_origin.IsSameOriginWith(unique_origin)); 44 EXPECT_FALSE(unique_origin.IsSameOriginWith(unique_origin));
43 45
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 GURL invalid_url("google.com"); 338 GURL invalid_url("google.com");
337 ASSERT_FALSE(invalid_url.is_valid()); 339 ASSERT_FALSE(invalid_url.is_valid());
338 EXPECT_FALSE(url::Origin(invalid_url).DomainIs("google.com")); 340 EXPECT_FALSE(url::Origin(invalid_url).DomainIs("google.com"));
339 341
340 // Unique origins. 342 // Unique origins.
341 EXPECT_FALSE(url::Origin().DomainIs("")); 343 EXPECT_FALSE(url::Origin().DomainIs(""));
342 EXPECT_FALSE(url::Origin().DomainIs("com")); 344 EXPECT_FALSE(url::Origin().DomainIs("com"));
343 } 345 }
344 346
345 } // namespace url 347 } // namespace url
OLDNEW
« no previous file with comments | « no previous file | url/scheme_host_port.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698