OLD | NEW |
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 "ios/web/public/referrer_util.h" | 5 #include "ios/web/public/referrer_util.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "ios/web/public/referrer.h" | 8 #include "ios/web/public/referrer.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 policy == ReferrerPolicyNever || | 157 policy == ReferrerPolicyNever || |
158 policy == ReferrerPolicyOrigin); | 158 policy == ReferrerPolicyOrigin); |
159 break; | 159 break; |
160 case net::URLRequest:: | 160 case net::URLRequest:: |
161 CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE: | 161 CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE: |
162 // This corresponds directly to ReferrerPolicyNoReferrerWhenDowngrade, | 162 // This corresponds directly to ReferrerPolicyNoReferrerWhenDowngrade, |
163 // which is also how Default works on iOS. | 163 // which is also how Default works on iOS. |
164 EXPECT_TRUE(policy == ReferrerPolicyDefault || | 164 EXPECT_TRUE(policy == ReferrerPolicyDefault || |
165 policy == ReferrerPolicyNoReferrerWhenDowngrade); | 165 policy == ReferrerPolicyNoReferrerWhenDowngrade); |
166 break; | 166 break; |
167 case net::URLRequest::ORIGIN: | |
168 EXPECT_TRUE(policy == ReferrerPolicyOrigin); | |
169 break; | |
170 case net::URLRequest::NO_REFERRER: | |
171 EXPECT_TRUE(policy == ReferrerPolicyNever); | |
172 break; | |
173 case net::URLRequest::MAX_REFERRER_POLICY: | |
174 FAIL(); | |
175 break; | |
176 } | 167 } |
177 } | 168 } |
178 } | 169 } |
179 | 170 |
180 // Tests that all the strings corresponding to web::ReferrerPolicy values are | 171 // Tests that all the strings corresponding to web::ReferrerPolicy values are |
181 // correctly handled. | 172 // correctly handled. |
182 TEST(ReferrerUtilTest, PolicyFromString) { | 173 TEST(ReferrerUtilTest, PolicyFromString) { |
183 // The ordering here must match web::ReferrerPolicy; this makes the test | 174 // The ordering here must match web::ReferrerPolicy; this makes the test |
184 // simpler, at the cost of needing to re-order if the enum is re-ordered. | 175 // simpler, at the cost of needing to re-order if the enum is re-ordered. |
185 const char* const kPolicyStrings[] = { | 176 const char* const kPolicyStrings[] = { |
(...skipping 23 matching lines...) Expand all Loading... |
209 EXPECT_EQ(ReferrerPolicyNoReferrerWhenDowngrade, | 200 EXPECT_EQ(ReferrerPolicyNoReferrerWhenDowngrade, |
210 ReferrerPolicyFromString("default")); | 201 ReferrerPolicyFromString("default")); |
211 EXPECT_EQ(ReferrerPolicyAlways, ReferrerPolicyFromString("always")); | 202 EXPECT_EQ(ReferrerPolicyAlways, ReferrerPolicyFromString("always")); |
212 | 203 |
213 // Test that invalid values map to Never. | 204 // Test that invalid values map to Never. |
214 EXPECT_EQ(ReferrerPolicyNever, ReferrerPolicyFromString("")); | 205 EXPECT_EQ(ReferrerPolicyNever, ReferrerPolicyFromString("")); |
215 EXPECT_EQ(ReferrerPolicyNever, ReferrerPolicyFromString("made-up")); | 206 EXPECT_EQ(ReferrerPolicyNever, ReferrerPolicyFromString("made-up")); |
216 } | 207 } |
217 | 208 |
218 } // namespace web | 209 } // namespace web |
OLD | NEW |