OLD | NEW |
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" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 std::stringstream out; | 255 std::stringstream out; |
256 out << origin; | 256 out << origin; |
257 EXPECT_EQ(test_case.expected, out.str()); | 257 EXPECT_EQ(test_case.expected, out.str()); |
258 } | 258 } |
259 | 259 |
260 const char* const failure_cases[] = { | 260 const char* const failure_cases[] = { |
261 "http-so://.", "http-so://foo", "http-so://.foo", "http-so://foo.", | 261 "http-so://.", "http-so://foo", "http-so://.foo", "http-so://foo.", |
262 "https-so://.", "https-so://foo", "https-so://.foo", "https-so://foo.", | 262 "https-so://.", "https-so://foo", "https-so://.foo", "https-so://foo.", |
263 }; | 263 }; |
264 | 264 |
265 for (const auto& test_case : failure_cases) { | 265 for (auto* test_case : failure_cases) { |
266 SCOPED_TRACE(test_case); | 266 SCOPED_TRACE(test_case); |
267 GURL url(test_case); | 267 GURL url(test_case); |
268 EXPECT_TRUE(url.is_valid()); | 268 EXPECT_TRUE(url.is_valid()); |
269 url::Origin origin(url); | 269 url::Origin origin(url); |
270 std::string serialized = origin.Serialize(); | 270 std::string serialized = origin.Serialize(); |
271 std::string serialized_physical_origin = | 271 std::string serialized_physical_origin = |
272 origin.GetPhysicalOrigin().Serialize(); | 272 origin.GetPhysicalOrigin().Serialize(); |
273 EXPECT_TRUE(origin.unique()); | 273 EXPECT_TRUE(origin.unique()); |
274 EXPECT_EQ("", origin.suborigin()); | 274 EXPECT_EQ("", origin.suborigin()); |
275 ExpectParsedUrlsEqual(GURL(serialized), origin.GetURL()); | 275 ExpectParsedUrlsEqual(GURL(serialized), origin.GetURL()); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 GURL invalid_url("google.com"); | 492 GURL invalid_url("google.com"); |
493 ASSERT_FALSE(invalid_url.is_valid()); | 493 ASSERT_FALSE(invalid_url.is_valid()); |
494 EXPECT_FALSE(url::Origin(invalid_url).DomainIs("google.com")); | 494 EXPECT_FALSE(url::Origin(invalid_url).DomainIs("google.com")); |
495 | 495 |
496 // Unique origins. | 496 // Unique origins. |
497 EXPECT_FALSE(url::Origin().DomainIs("")); | 497 EXPECT_FALSE(url::Origin().DomainIs("")); |
498 EXPECT_FALSE(url::Origin().DomainIs("com")); | 498 EXPECT_FALSE(url::Origin().DomainIs("com")); |
499 } | 499 } |
500 | 500 |
501 } // namespace url | 501 } // namespace url |
OLD | NEW |