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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 for (const auto& test_case : cases) { | 83 for (const auto& test_case : cases) { |
84 testing::Message scope_message; | 84 testing::Message scope_message; |
85 if (test_case.suborigin != std::string()) { | 85 if (test_case.suborigin != std::string()) { |
86 scope_message << test_case.scheme << "-so://" << test_case.suborigin | 86 scope_message << test_case.scheme << "-so://" << test_case.suborigin |
87 << "." << test_case.host << ":" << test_case.port; | 87 << "." << test_case.host << ":" << test_case.port; |
88 } else { | 88 } else { |
89 scope_message << test_case.scheme << "://" << test_case.host << ":" | 89 scope_message << test_case.scheme << "://" << test_case.host << ":" |
90 << test_case.port; | 90 << test_case.port; |
91 } | 91 } |
92 SCOPED_TRACE(scope_message); | 92 SCOPED_TRACE(scope_message); |
93 | |
94 url::Origin origin_without_suborigin = | |
95 url::Origin::CreateFromNormalizedTuple(test_case.scheme, test_case.host, | |
96 test_case.port); | |
97 | |
98 url::Origin origin_with_suborigin = | 93 url::Origin origin_with_suborigin = |
99 url::Origin::CreateFromNormalizedTupleWithSuborigin( | 94 url::Origin::CreateFromNormalizedTupleWithSuborigin( |
100 test_case.scheme, test_case.host, test_case.port, | 95 test_case.scheme, test_case.host, test_case.port, |
101 test_case.suborigin); | 96 test_case.suborigin); |
102 | 97 |
103 EXPECT_EQ(test_case.scheme, origin_without_suborigin.scheme()); | |
104 EXPECT_EQ(test_case.host, origin_without_suborigin.host()); | |
105 EXPECT_EQ(test_case.port, origin_without_suborigin.port()); | |
106 | |
107 EXPECT_EQ(test_case.scheme, origin_with_suborigin.scheme()); | 98 EXPECT_EQ(test_case.scheme, origin_with_suborigin.scheme()); |
108 EXPECT_EQ(test_case.host, origin_with_suborigin.host()); | 99 EXPECT_EQ(test_case.host, origin_with_suborigin.host()); |
109 EXPECT_EQ(test_case.port, origin_with_suborigin.port()); | 100 EXPECT_EQ(test_case.port, origin_with_suborigin.port()); |
110 EXPECT_EQ(test_case.suborigin, origin_with_suborigin.suborigin()); | 101 EXPECT_EQ(test_case.suborigin, origin_with_suborigin.suborigin()); |
111 } | 102 } |
112 } | 103 } |
113 | 104 |
114 TEST(OriginTest, ConstructFromGURL) { | 105 TEST(OriginTest, ConstructFromGURL) { |
115 url::Origin different_origin(GURL("https://not-in-the-list.test/")); | 106 url::Origin different_origin(GURL("https://not-in-the-list.test/")); |
116 | 107 |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 GURL invalid_url("google.com"); | 492 GURL invalid_url("google.com"); |
502 ASSERT_FALSE(invalid_url.is_valid()); | 493 ASSERT_FALSE(invalid_url.is_valid()); |
503 EXPECT_FALSE(url::Origin(invalid_url).DomainIs("google.com")); | 494 EXPECT_FALSE(url::Origin(invalid_url).DomainIs("google.com")); |
504 | 495 |
505 // Unique origins. | 496 // Unique origins. |
506 EXPECT_FALSE(url::Origin().DomainIs("")); | 497 EXPECT_FALSE(url::Origin().DomainIs("")); |
507 EXPECT_FALSE(url::Origin().DomainIs("com")); | 498 EXPECT_FALSE(url::Origin().DomainIs("com")); |
508 } | 499 } |
509 | 500 |
510 } // namespace url | 501 } // namespace url |
OLD | NEW |