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

Side by Side Diff: net/http/http_server_properties_impl_unittest.cc

Issue 1860343002: SHP 1: Change SupportsSpdy dict to use SchemeHostPort as the key. No change to Pref data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/http/http_server_properties_impl.h" 5 #include "net/http/http_server_properties_impl.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 EXPECT_EQ(data.value, flags_and_value_memory.second); 96 EXPECT_EQ(data.value, flags_and_value_memory.second);
97 } 97 }
98 } 98 }
99 99
100 HttpServerPropertiesImpl impl_; 100 HttpServerPropertiesImpl impl_;
101 }; 101 };
102 102
103 typedef HttpServerPropertiesImplTest SpdyServerPropertiesTest; 103 typedef HttpServerPropertiesImplTest SpdyServerPropertiesTest;
104 104
105 TEST_F(SpdyServerPropertiesTest, Initialize) { 105 TEST_F(SpdyServerPropertiesTest, Initialize) {
106 HostPortPair spdy_server_google("www.google.com", 443); 106 url::SchemeHostPort spdy_server_google("https", "www.google.com", 443);
107 std::string spdy_server_g = spdy_server_google.ToString(); 107 std::string spdy_server_g = spdy_server_google.ToString();
108 108
109 HostPortPair spdy_server_photos("photos.google.com", 443); 109 url::SchemeHostPort spdy_server_photos("https", "photos.google.com", 443);
110 std::string spdy_server_p = spdy_server_photos.ToString(); 110 std::string spdy_server_p = spdy_server_photos.ToString();
111 111
112 HostPortPair spdy_server_docs("docs.google.com", 443); 112 url::SchemeHostPort spdy_server_docs("https", "docs.google.com", 443);
113 std::string spdy_server_d = spdy_server_docs.ToString(); 113 std::string spdy_server_d = spdy_server_docs.ToString();
114 114
115 HostPortPair spdy_server_mail("mail.google.com", 443); 115 url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
Ryan Hamilton 2016/04/06 19:16:08 We should have tests which verify that the same ho
Zhongyi Shi 2016/04/07 00:31:18 Done.
116 std::string spdy_server_m = spdy_server_mail.ToString(); 116 std::string spdy_server_m = spdy_server_mail.ToString();
117 117
118 // Check by initializing NULL spdy servers. 118 // Check by initializing NULL spdy servers.
119 impl_.InitializeSpdyServers(NULL, true); 119 impl_.InitializeSpdyServers(NULL, true);
120 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google)); 120 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google));
121 121
122 // Check by initializing empty spdy servers. 122 // Check by initializing empty spdy servers.
123 std::vector<std::string> spdy_servers; 123 std::vector<std::string> spdy_servers;
124 impl_.InitializeSpdyServers(&spdy_servers, true); 124 impl_.InitializeSpdyServers(&spdy_servers, true);
125 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google)); 125 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google));
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 194
195 // Verify photos and mail servers don't support SPDY and other servers support 195 // Verify photos and mail servers don't support SPDY and other servers support
196 // SPDY. 196 // SPDY.
197 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs)); 197 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs));
198 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail)); 198 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail));
199 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_photos)); 199 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_photos));
200 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google)); 200 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google));
201 } 201 }
202 202
203 TEST_F(SpdyServerPropertiesTest, SupportsRequestPriorityTest) { 203 TEST_F(SpdyServerPropertiesTest, SupportsRequestPriorityTest) {
204 HostPortPair spdy_server_empty(std::string(), 443); 204 url::SchemeHostPort spdy_server_empty("https", std::string(), 443);
205 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_empty)); 205 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_empty));
206 206
207 // Add www.google.com:443 as supporting SPDY. 207 // Add www.google.com:443 as supporting SPDY.
208 HostPortPair spdy_server_google("www.google.com", 443); 208 url::SchemeHostPort spdy_server_google("https", "www.google.com", 443);
209 impl_.SetSupportsSpdy(spdy_server_google, true); 209 impl_.SetSupportsSpdy(spdy_server_google, true);
210 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google)); 210 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google));
211 211
212 // Add mail.google.com:443 as not supporting SPDY. 212 // Add mail.google.com:443 as not supporting SPDY.
213 HostPortPair spdy_server_mail("mail.google.com", 443); 213 url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
214 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail)); 214 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail));
215 215
216 // Add docs.google.com:443 as supporting SPDY. 216 // Add docs.google.com:443 as supporting SPDY.
217 HostPortPair spdy_server_docs("docs.google.com", 443); 217 url::SchemeHostPort spdy_server_docs("https", "docs.google.com", 443);
218 impl_.SetSupportsSpdy(spdy_server_docs, true); 218 impl_.SetSupportsSpdy(spdy_server_docs, true);
219 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs)); 219 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs));
220 220
221 // Add www.youtube.com:443 as supporting QUIC. 221 // Add www.youtube.com:443 as supporting QUIC.
222 HostPortPair quic_server_youtube("www.youtube.com", 443); 222 HostPortPair quic_server_youtube("www.youtube.com", 443);
223 url::SchemeHostPort youtube_server("https", "www.youtube.com", 443);
223 const AlternativeService alternative_service1(QUIC, "www.youtube.com", 443); 224 const AlternativeService alternative_service1(QUIC, "www.youtube.com", 443);
224 SetAlternativeService(quic_server_youtube, alternative_service1); 225 SetAlternativeService(quic_server_youtube, alternative_service1);
225 EXPECT_TRUE(impl_.SupportsRequestPriority(quic_server_youtube)); 226 EXPECT_TRUE(impl_.SupportsRequestPriority(youtube_server));
226 227
227 // Add www.example.com:443 with two alternative services, one supporting QUIC. 228 // Add www.example.com:443 with two alternative services, one supporting QUIC.
228 HostPortPair quic_server_example("www.example.com", 443); 229 HostPortPair quic_server_example("www.example.com", 443);
230 url::SchemeHostPort example_server("https", "www.example.com", 443);
229 const AlternativeService alternative_service2(NPN_HTTP_2, "", 443); 231 const AlternativeService alternative_service2(NPN_HTTP_2, "", 443);
230 SetAlternativeService(quic_server_example, alternative_service2); 232 SetAlternativeService(quic_server_example, alternative_service2);
231 SetAlternativeService(quic_server_example, alternative_service1); 233 SetAlternativeService(quic_server_example, alternative_service1);
232 EXPECT_TRUE(impl_.SupportsRequestPriority(quic_server_example)); 234 EXPECT_TRUE(impl_.SupportsRequestPriority(example_server));
233 235
234 // Verify all the entries are the same after additions. 236 // Verify all the entries are the same after additions.
235 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google)); 237 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google));
236 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail)); 238 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail));
237 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs)); 239 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs));
238 EXPECT_TRUE(impl_.SupportsRequestPriority(quic_server_youtube)); 240 EXPECT_TRUE(impl_.SupportsRequestPriority(youtube_server));
239 EXPECT_TRUE(impl_.SupportsRequestPriority(quic_server_example)); 241 EXPECT_TRUE(impl_.SupportsRequestPriority(example_server));
240 } 242 }
241 243
242 TEST_F(SpdyServerPropertiesTest, Clear) { 244 TEST_F(SpdyServerPropertiesTest, Clear) {
243 // Add www.google.com:443 and mail.google.com:443 as supporting SPDY. 245 // Add www.google.com:443 and mail.google.com:443 as supporting SPDY.
244 HostPortPair spdy_server_google("www.google.com", 443); 246 url::SchemeHostPort spdy_server_google("https", "www.google.com", 443);
245 impl_.SetSupportsSpdy(spdy_server_google, true); 247 impl_.SetSupportsSpdy(spdy_server_google, true);
246 HostPortPair spdy_server_mail("mail.google.com", 443); 248 url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
247 impl_.SetSupportsSpdy(spdy_server_mail, true); 249 impl_.SetSupportsSpdy(spdy_server_mail, true);
248 250
249 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google)); 251 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google));
250 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_mail)); 252 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_mail));
251 253
252 impl_.Clear(); 254 impl_.Clear();
253 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google)); 255 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google));
254 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail)); 256 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail));
255 } 257 }
256 258
257 TEST_F(SpdyServerPropertiesTest, GetSpdyServerList) { 259 TEST_F(SpdyServerPropertiesTest, GetSpdyServerList) {
258 base::ListValue spdy_server_list; 260 base::ListValue spdy_server_list;
259 261
260 // Check there are no spdy_servers. 262 // Check there are no spdy_servers.
261 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); 263 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts);
262 EXPECT_EQ(0U, spdy_server_list.GetSize()); 264 EXPECT_EQ(0U, spdy_server_list.GetSize());
263 265
264 // Check empty server is not added. 266 // Check empty server is not added.
265 HostPortPair spdy_server_empty(std::string(), 443); 267 url::SchemeHostPort spdy_server_empty("https", std::string(), 443);
266 impl_.SetSupportsSpdy(spdy_server_empty, true); 268 impl_.SetSupportsSpdy(spdy_server_empty, true);
267 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); 269 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts);
268 EXPECT_EQ(0U, spdy_server_list.GetSize()); 270 EXPECT_EQ(0U, spdy_server_list.GetSize());
269 271
270 std::string string_value_g; 272 std::string string_value_g;
271 std::string string_value_m; 273 std::string string_value_m;
272 HostPortPair spdy_server_google("www.google.com", 443); 274 url::SchemeHostPort spdy_server_google("https", "www.google.com", 443);
273 std::string spdy_server_g = spdy_server_google.ToString(); 275 std::string spdy_server_g = spdy_server_google.ToString();
274 HostPortPair spdy_server_mail("mail.google.com", 443); 276 url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
275 std::string spdy_server_m = spdy_server_mail.ToString(); 277 std::string spdy_server_m = spdy_server_mail.ToString();
276 278
277 // Add www.google.com:443 as not supporting SPDY. 279 // Add www.google.com:443 as not supporting SPDY.
278 impl_.SetSupportsSpdy(spdy_server_google, false); 280 impl_.SetSupportsSpdy(spdy_server_google, false);
279 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); 281 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts);
280 EXPECT_EQ(0U, spdy_server_list.GetSize()); 282 EXPECT_EQ(0U, spdy_server_list.GetSize());
281 283
282 // Add www.google.com:443 as supporting SPDY. 284 // Add www.google.com:443 as supporting SPDY.
283 impl_.SetSupportsSpdy(spdy_server_google, true); 285 impl_.SetSupportsSpdy(spdy_server_google, true);
284 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); 286 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts);
(...skipping 24 matching lines...) Expand all
309 ASSERT_EQ(1U, spdy_server_list.GetSize()); 311 ASSERT_EQ(1U, spdy_server_list.GetSize());
310 ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_m)); 312 ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_m));
311 ASSERT_EQ(spdy_server_m, string_value_m); 313 ASSERT_EQ(spdy_server_m, string_value_m);
312 } 314 }
313 315
314 TEST_F(SpdyServerPropertiesTest, MRUOfGetSpdyServerList) { 316 TEST_F(SpdyServerPropertiesTest, MRUOfGetSpdyServerList) {
315 base::ListValue spdy_server_list; 317 base::ListValue spdy_server_list;
316 318
317 std::string string_value_g; 319 std::string string_value_g;
318 std::string string_value_m; 320 std::string string_value_m;
319 HostPortPair spdy_server_google("www.google.com", 443); 321 url::SchemeHostPort spdy_server_google("https", "www.google.com", 443);
320 std::string spdy_server_g = spdy_server_google.ToString(); 322 std::string spdy_server_g = spdy_server_google.ToString();
321 HostPortPair spdy_server_mail("mail.google.com", 443); 323 url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
322 std::string spdy_server_m = spdy_server_mail.ToString(); 324 std::string spdy_server_m = spdy_server_mail.ToString();
323 325
324 // Add www.google.com:443 as supporting SPDY. 326 // Add www.google.com:443 as supporting SPDY.
325 impl_.SetSupportsSpdy(spdy_server_google, true); 327 impl_.SetSupportsSpdy(spdy_server_google, true);
326 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); 328 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts);
327 ASSERT_EQ(1U, spdy_server_list.GetSize()); 329 ASSERT_EQ(1U, spdy_server_list.GetSize());
328 ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_g)); 330 ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_g));
329 ASSERT_EQ(spdy_server_g, string_value_g); 331 ASSERT_EQ(spdy_server_g, string_value_g);
330 332
331 // Add mail.google.com:443 as supporting SPDY. Verify mail.google.com:443 and 333 // Add mail.google.com:443 as supporting SPDY. Verify mail.google.com:443 and
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 EXPECT_EQ(quic_server_info1, *(impl_.GetQuicServerInfo(quic_server_id))); 1395 EXPECT_EQ(quic_server_info1, *(impl_.GetQuicServerInfo(quic_server_id)));
1394 1396
1395 impl_.Clear(); 1397 impl_.Clear();
1396 EXPECT_EQ(0u, impl_.quic_server_info_map().size()); 1398 EXPECT_EQ(0u, impl_.quic_server_info_map().size());
1397 EXPECT_EQ(nullptr, impl_.GetQuicServerInfo(quic_server_id)); 1399 EXPECT_EQ(nullptr, impl_.GetQuicServerInfo(quic_server_id));
1398 } 1400 }
1399 1401
1400 } // namespace 1402 } // namespace
1401 1403
1402 } // namespace net 1404 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698