OLD | NEW |
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/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 ASSERT_EQ(spdy_server_g, string_value_g); | 236 ASSERT_EQ(spdy_server_g, string_value_g); |
237 ASSERT_TRUE(spdy_server_list.GetString(1, &string_value_m)); | 237 ASSERT_TRUE(spdy_server_list.GetString(1, &string_value_m)); |
238 ASSERT_EQ(spdy_server_m, string_value_m); | 238 ASSERT_EQ(spdy_server_m, string_value_m); |
239 } | 239 } |
240 | 240 |
241 typedef HttpServerPropertiesImplTest AlternateProtocolServerPropertiesTest; | 241 typedef HttpServerPropertiesImplTest AlternateProtocolServerPropertiesTest; |
242 | 242 |
243 TEST_F(AlternateProtocolServerPropertiesTest, Basic) { | 243 TEST_F(AlternateProtocolServerPropertiesTest, Basic) { |
244 HostPortPair test_host_port_pair("foo", 80); | 244 HostPortPair test_host_port_pair("foo", 80); |
245 EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair)); | 245 EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair)); |
246 impl_.SetAlternateProtocol(test_host_port_pair, 443, NPN_SPDY_3, 1); | 246 impl_.SetAlternateProtocol(test_host_port_pair, 443, NPN_SPDY_3); |
247 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair)); | 247 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair)); |
248 const AlternateProtocolInfo alternate = | 248 const PortAlternateProtocolPair alternate = |
249 impl_.GetAlternateProtocol(test_host_port_pair); | 249 impl_.GetAlternateProtocol(test_host_port_pair); |
250 EXPECT_EQ(443, alternate.port); | 250 EXPECT_EQ(443, alternate.port); |
251 EXPECT_EQ(NPN_SPDY_3, alternate.protocol); | 251 EXPECT_EQ(NPN_SPDY_3, alternate.protocol); |
252 | 252 |
253 impl_.Clear(); | 253 impl_.Clear(); |
254 EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair)); | 254 EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair)); |
255 } | 255 } |
256 | 256 |
257 TEST_F(AlternateProtocolServerPropertiesTest, Probability) { | |
258 impl_.SetAlternateProtocolProbabilityThreshold(.25); | |
259 | |
260 HostPortPair test_host_port_pair("foo", 80); | |
261 impl_.SetAlternateProtocol(test_host_port_pair, 443, NPN_SPDY_3, .5); | |
262 | |
263 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair)); | |
264 const AlternateProtocolInfo alternate = | |
265 impl_.GetAlternateProtocol(test_host_port_pair); | |
266 EXPECT_EQ(443, alternate.port); | |
267 EXPECT_EQ(NPN_SPDY_3, alternate.protocol); | |
268 EXPECT_EQ(.5, alternate.probability); | |
269 } | |
270 | |
271 TEST_F(AlternateProtocolServerPropertiesTest, ProbabilityExcluded) { | |
272 impl_.SetAlternateProtocolProbabilityThreshold(.75); | |
273 | |
274 HostPortPair test_host_port_pair("foo", 80); | |
275 | |
276 impl_.SetAlternateProtocol(test_host_port_pair, 443, NPN_SPDY_3, .5); | |
277 EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair)); | |
278 } | |
279 | |
280 TEST_F(AlternateProtocolServerPropertiesTest, Initialize) { | 257 TEST_F(AlternateProtocolServerPropertiesTest, Initialize) { |
281 HostPortPair test_host_port_pair1("foo1", 80); | 258 HostPortPair test_host_port_pair1("foo1", 80); |
282 impl_.SetBrokenAlternateProtocol(test_host_port_pair1); | 259 impl_.SetBrokenAlternateProtocol(test_host_port_pair1); |
283 HostPortPair test_host_port_pair2("foo2", 80); | 260 HostPortPair test_host_port_pair2("foo2", 80); |
284 impl_.SetAlternateProtocol(test_host_port_pair2, 443, NPN_SPDY_3, 1); | 261 impl_.SetAlternateProtocol(test_host_port_pair2, 443, NPN_SPDY_3); |
285 | 262 |
286 AlternateProtocolMap alternate_protocol_map( | 263 AlternateProtocolMap alternate_protocol_map( |
287 AlternateProtocolMap::NO_AUTO_EVICT); | 264 AlternateProtocolMap::NO_AUTO_EVICT); |
288 AlternateProtocolInfo port_alternate_protocol_pair(123, NPN_SPDY_3, 1); | 265 PortAlternateProtocolPair port_alternate_protocol_pair; |
| 266 port_alternate_protocol_pair.port = 123; |
| 267 port_alternate_protocol_pair.protocol = NPN_SPDY_3; |
289 alternate_protocol_map.Put(test_host_port_pair2, | 268 alternate_protocol_map.Put(test_host_port_pair2, |
290 port_alternate_protocol_pair); | 269 port_alternate_protocol_pair); |
291 HostPortPair test_host_port_pair3("foo3", 80); | 270 HostPortPair test_host_port_pair3("foo3", 80); |
292 port_alternate_protocol_pair.port = 1234; | 271 port_alternate_protocol_pair.port = 1234; |
293 alternate_protocol_map.Put(test_host_port_pair3, | 272 alternate_protocol_map.Put(test_host_port_pair3, |
294 port_alternate_protocol_pair); | 273 port_alternate_protocol_pair); |
295 impl_.InitializeAlternateProtocolServers(&alternate_protocol_map); | 274 impl_.InitializeAlternateProtocolServers(&alternate_protocol_map); |
296 | 275 |
297 // Verify test_host_port_pair3 is the MRU server. | 276 // Verify test_host_port_pair3 is the MRU server. |
298 const net::AlternateProtocolMap& map = impl_.alternate_protocol_map(); | 277 const net::AlternateProtocolMap& map = impl_.alternate_protocol_map(); |
299 net::AlternateProtocolMap::const_iterator it = map.begin(); | 278 net::AlternateProtocolMap::const_iterator it = map.begin(); |
300 it = map.begin(); | 279 it = map.begin(); |
301 EXPECT_TRUE(it->first.Equals(test_host_port_pair3)); | 280 EXPECT_TRUE(it->first.Equals(test_host_port_pair3)); |
302 EXPECT_EQ(1234, it->second.port); | 281 EXPECT_EQ(1234, it->second.port); |
303 EXPECT_EQ(NPN_SPDY_3, it->second.protocol); | 282 EXPECT_EQ(NPN_SPDY_3, it->second.protocol); |
304 | 283 |
305 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair1)); | 284 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair1)); |
306 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair2)); | 285 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair2)); |
307 port_alternate_protocol_pair = | 286 port_alternate_protocol_pair = |
308 impl_.GetAlternateProtocol(test_host_port_pair1); | 287 impl_.GetAlternateProtocol(test_host_port_pair1); |
309 EXPECT_EQ(ALTERNATE_PROTOCOL_BROKEN, port_alternate_protocol_pair.protocol); | 288 EXPECT_EQ(ALTERNATE_PROTOCOL_BROKEN, port_alternate_protocol_pair.protocol); |
310 port_alternate_protocol_pair = | 289 port_alternate_protocol_pair = |
311 impl_.GetAlternateProtocol(test_host_port_pair2); | 290 impl_.GetAlternateProtocol(test_host_port_pair2); |
312 EXPECT_EQ(123, port_alternate_protocol_pair.port); | 291 EXPECT_EQ(123, port_alternate_protocol_pair.port); |
313 EXPECT_EQ(NPN_SPDY_3, port_alternate_protocol_pair.protocol); | 292 EXPECT_EQ(NPN_SPDY_3, port_alternate_protocol_pair.protocol); |
314 } | 293 } |
315 | 294 |
316 TEST_F(AlternateProtocolServerPropertiesTest, MRUOfHasAlternateProtocol) { | 295 TEST_F(AlternateProtocolServerPropertiesTest, MRUOfHasAlternateProtocol) { |
317 HostPortPair test_host_port_pair1("foo1", 80); | 296 HostPortPair test_host_port_pair1("foo1", 80); |
318 impl_.SetAlternateProtocol(test_host_port_pair1, 443, NPN_SPDY_3, 1); | 297 impl_.SetAlternateProtocol(test_host_port_pair1, 443, NPN_SPDY_3); |
319 HostPortPair test_host_port_pair2("foo2", 80); | 298 HostPortPair test_host_port_pair2("foo2", 80); |
320 impl_.SetAlternateProtocol(test_host_port_pair2, 1234, NPN_SPDY_3, 1); | 299 impl_.SetAlternateProtocol(test_host_port_pair2, 1234, NPN_SPDY_3); |
321 | 300 |
322 const net::AlternateProtocolMap& map = impl_.alternate_protocol_map(); | 301 const net::AlternateProtocolMap& map = impl_.alternate_protocol_map(); |
323 net::AlternateProtocolMap::const_iterator it = map.begin(); | 302 net::AlternateProtocolMap::const_iterator it = map.begin(); |
324 EXPECT_TRUE(it->first.Equals(test_host_port_pair2)); | 303 EXPECT_TRUE(it->first.Equals(test_host_port_pair2)); |
325 EXPECT_EQ(1234, it->second.port); | 304 EXPECT_EQ(1234, it->second.port); |
326 EXPECT_EQ(NPN_SPDY_3, it->second.protocol); | 305 EXPECT_EQ(NPN_SPDY_3, it->second.protocol); |
327 | 306 |
328 // HasAlternateProtocol should reoder the AlternateProtocol map. | 307 // HasAlternateProtocol should reoder the AlternateProtocol map. |
329 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair1)); | 308 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair1)); |
330 it = map.begin(); | 309 it = map.begin(); |
331 EXPECT_TRUE(it->first.Equals(test_host_port_pair1)); | 310 EXPECT_TRUE(it->first.Equals(test_host_port_pair1)); |
332 EXPECT_EQ(443, it->second.port); | 311 EXPECT_EQ(443, it->second.port); |
333 EXPECT_EQ(NPN_SPDY_3, it->second.protocol); | 312 EXPECT_EQ(NPN_SPDY_3, it->second.protocol); |
334 } | 313 } |
335 | 314 |
336 TEST_F(AlternateProtocolServerPropertiesTest, MRUOfGetAlternateProtocol) { | 315 TEST_F(AlternateProtocolServerPropertiesTest, MRUOfGetAlternateProtocol) { |
337 HostPortPair test_host_port_pair1("foo1", 80); | 316 HostPortPair test_host_port_pair1("foo1", 80); |
338 impl_.SetAlternateProtocol(test_host_port_pair1, 443, NPN_SPDY_3, 1); | 317 impl_.SetAlternateProtocol(test_host_port_pair1, 443, NPN_SPDY_3); |
339 HostPortPair test_host_port_pair2("foo2", 80); | 318 HostPortPair test_host_port_pair2("foo2", 80); |
340 impl_.SetAlternateProtocol(test_host_port_pair2, 1234, NPN_SPDY_3, 1); | 319 impl_.SetAlternateProtocol(test_host_port_pair2, 1234, NPN_SPDY_3); |
341 | 320 |
342 const net::AlternateProtocolMap& map = impl_.alternate_protocol_map(); | 321 const net::AlternateProtocolMap& map = impl_.alternate_protocol_map(); |
343 net::AlternateProtocolMap::const_iterator it = map.begin(); | 322 net::AlternateProtocolMap::const_iterator it = map.begin(); |
344 EXPECT_TRUE(it->first.Equals(test_host_port_pair2)); | 323 EXPECT_TRUE(it->first.Equals(test_host_port_pair2)); |
345 EXPECT_EQ(1234, it->second.port); | 324 EXPECT_EQ(1234, it->second.port); |
346 EXPECT_EQ(NPN_SPDY_3, it->second.protocol); | 325 EXPECT_EQ(NPN_SPDY_3, it->second.protocol); |
347 | 326 |
348 // GetAlternateProtocol should reoder the AlternateProtocol map. | 327 // GetAlternateProtocol should reoder the AlternateProtocol map. |
349 AlternateProtocolInfo alternate = | 328 PortAlternateProtocolPair alternate = |
350 impl_.GetAlternateProtocol(test_host_port_pair1); | 329 impl_.GetAlternateProtocol(test_host_port_pair1); |
351 EXPECT_EQ(443, alternate.port); | 330 EXPECT_EQ(443, alternate.port); |
352 EXPECT_EQ(NPN_SPDY_3, alternate.protocol); | 331 EXPECT_EQ(NPN_SPDY_3, alternate.protocol); |
353 it = map.begin(); | 332 it = map.begin(); |
354 EXPECT_TRUE(it->first.Equals(test_host_port_pair1)); | 333 EXPECT_TRUE(it->first.Equals(test_host_port_pair1)); |
355 EXPECT_EQ(443, it->second.port); | 334 EXPECT_EQ(443, it->second.port); |
356 EXPECT_EQ(NPN_SPDY_3, it->second.protocol); | 335 EXPECT_EQ(NPN_SPDY_3, it->second.protocol); |
357 } | 336 } |
358 | 337 |
359 TEST_F(AlternateProtocolServerPropertiesTest, SetBroken) { | 338 TEST_F(AlternateProtocolServerPropertiesTest, SetBroken) { |
360 HostPortPair test_host_port_pair("foo", 80); | 339 HostPortPair test_host_port_pair("foo", 80); |
361 impl_.SetBrokenAlternateProtocol(test_host_port_pair); | 340 impl_.SetBrokenAlternateProtocol(test_host_port_pair); |
362 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair)); | 341 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair)); |
363 AlternateProtocolInfo alternate = | 342 PortAlternateProtocolPair alternate = |
364 impl_.GetAlternateProtocol(test_host_port_pair); | 343 impl_.GetAlternateProtocol(test_host_port_pair); |
365 EXPECT_EQ(ALTERNATE_PROTOCOL_BROKEN, alternate.protocol); | 344 EXPECT_EQ(ALTERNATE_PROTOCOL_BROKEN, alternate.protocol); |
366 | 345 |
367 impl_.SetAlternateProtocol( | 346 impl_.SetAlternateProtocol( |
368 test_host_port_pair, | 347 test_host_port_pair, |
369 1234, | 348 1234, |
370 NPN_SPDY_3, | 349 NPN_SPDY_3); |
371 1); | |
372 alternate = impl_.GetAlternateProtocol(test_host_port_pair); | 350 alternate = impl_.GetAlternateProtocol(test_host_port_pair); |
373 EXPECT_EQ(ALTERNATE_PROTOCOL_BROKEN, alternate.protocol) | 351 EXPECT_EQ(ALTERNATE_PROTOCOL_BROKEN, alternate.protocol) |
374 << "Second attempt should be ignored."; | 352 << "Second attempt should be ignored."; |
375 } | 353 } |
376 | 354 |
377 TEST_F(AlternateProtocolServerPropertiesTest, ClearBroken) { | 355 TEST_F(AlternateProtocolServerPropertiesTest, ClearBroken) { |
378 HostPortPair test_host_port_pair("foo", 80); | 356 HostPortPair test_host_port_pair("foo", 80); |
379 impl_.SetBrokenAlternateProtocol(test_host_port_pair); | 357 impl_.SetBrokenAlternateProtocol(test_host_port_pair); |
380 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair)); | 358 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair)); |
381 AlternateProtocolInfo alternate = | 359 PortAlternateProtocolPair alternate = |
382 impl_.GetAlternateProtocol(test_host_port_pair); | 360 impl_.GetAlternateProtocol(test_host_port_pair); |
383 EXPECT_EQ(ALTERNATE_PROTOCOL_BROKEN, alternate.protocol); | 361 EXPECT_EQ(ALTERNATE_PROTOCOL_BROKEN, alternate.protocol); |
384 impl_.ClearAlternateProtocol(test_host_port_pair); | 362 impl_.ClearAlternateProtocol(test_host_port_pair); |
385 EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair)); | 363 EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair)); |
386 } | 364 } |
387 | 365 |
388 TEST_F(AlternateProtocolServerPropertiesTest, Forced) { | 366 TEST_F(AlternateProtocolServerPropertiesTest, Forced) { |
389 // Test forced alternate protocols. | 367 // Test forced alternate protocols. |
390 | 368 |
391 AlternateProtocolInfo default_protocol(1234, NPN_SPDY_3, 1); | 369 PortAlternateProtocolPair default_protocol; |
| 370 default_protocol.port = 1234; |
| 371 default_protocol.protocol = NPN_SPDY_3; |
392 HttpServerPropertiesImpl::ForceAlternateProtocol(default_protocol); | 372 HttpServerPropertiesImpl::ForceAlternateProtocol(default_protocol); |
393 | 373 |
394 // Verify the forced protocol. | 374 // Verify the forced protocol. |
395 HostPortPair test_host_port_pair("foo", 80); | 375 HostPortPair test_host_port_pair("foo", 80); |
396 EXPECT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair)); | 376 EXPECT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair)); |
397 AlternateProtocolInfo alternate = | 377 PortAlternateProtocolPair alternate = |
398 impl_.GetAlternateProtocol(test_host_port_pair); | 378 impl_.GetAlternateProtocol(test_host_port_pair); |
399 EXPECT_EQ(default_protocol.port, alternate.port); | 379 EXPECT_EQ(default_protocol.port, alternate.port); |
400 EXPECT_EQ(default_protocol.protocol, alternate.protocol); | 380 EXPECT_EQ(default_protocol.protocol, alternate.protocol); |
401 | 381 |
402 // Verify the real protocol overrides the forced protocol. | 382 // Verify the real protocol overrides the forced protocol. |
403 impl_.SetAlternateProtocol(test_host_port_pair, 443, NPN_SPDY_3, 1); | 383 impl_.SetAlternateProtocol(test_host_port_pair, 443, NPN_SPDY_3); |
404 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair)); | 384 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair)); |
405 alternate = impl_.GetAlternateProtocol(test_host_port_pair); | 385 alternate = impl_.GetAlternateProtocol(test_host_port_pair); |
406 EXPECT_EQ(443, alternate.port); | 386 EXPECT_EQ(443, alternate.port); |
407 EXPECT_EQ(NPN_SPDY_3, alternate.protocol); | 387 EXPECT_EQ(NPN_SPDY_3, alternate.protocol); |
408 | 388 |
409 // Turn off the static, forced alternate protocol so that tests don't | 389 // Turn off the static, forced alternate protocol so that tests don't |
410 // have this state. | 390 // have this state. |
411 HttpServerPropertiesImpl::DisableForcedAlternateProtocol(); | 391 HttpServerPropertiesImpl::DisableForcedAlternateProtocol(); |
412 | 392 |
413 // Verify the forced protocol is off. | 393 // Verify the forced protocol is off. |
414 HostPortPair test_host_port_pair2("bar", 80); | 394 HostPortPair test_host_port_pair2("bar", 80); |
415 EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair2)); | 395 EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair2)); |
416 } | 396 } |
417 | 397 |
418 TEST_F(AlternateProtocolServerPropertiesTest, Canonical) { | 398 TEST_F(AlternateProtocolServerPropertiesTest, Canonical) { |
419 HostPortPair test_host_port_pair("foo.c.youtube.com", 80); | 399 HostPortPair test_host_port_pair("foo.c.youtube.com", 80); |
420 EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair)); | 400 EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair)); |
421 | 401 |
422 HostPortPair canonical_port_pair("bar.c.youtube.com", 80); | 402 HostPortPair canonical_port_pair("bar.c.youtube.com", 80); |
423 EXPECT_FALSE(impl_.HasAlternateProtocol(canonical_port_pair)); | 403 EXPECT_FALSE(impl_.HasAlternateProtocol(canonical_port_pair)); |
424 | 404 |
425 AlternateProtocolInfo canonical_protocol(1234, QUIC, 1); | 405 PortAlternateProtocolPair canonical_protocol; |
| 406 canonical_protocol.port = 1234; |
| 407 canonical_protocol.protocol = QUIC; |
426 | 408 |
427 impl_.SetAlternateProtocol(canonical_port_pair, | 409 impl_.SetAlternateProtocol(canonical_port_pair, |
428 canonical_protocol.port, | 410 canonical_protocol.port, |
429 canonical_protocol.protocol, | 411 canonical_protocol.protocol); |
430 1); | |
431 // Verify the forced protocol. | 412 // Verify the forced protocol. |
432 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair)); | 413 ASSERT_TRUE(impl_.HasAlternateProtocol(test_host_port_pair)); |
433 AlternateProtocolInfo alternate = | 414 PortAlternateProtocolPair alternate = |
434 impl_.GetAlternateProtocol(test_host_port_pair); | 415 impl_.GetAlternateProtocol(test_host_port_pair); |
435 EXPECT_EQ(canonical_protocol.port, alternate.port); | 416 EXPECT_EQ(canonical_protocol.port, alternate.port); |
436 EXPECT_EQ(canonical_protocol.protocol, alternate.protocol); | 417 EXPECT_EQ(canonical_protocol.protocol, alternate.protocol); |
437 | 418 |
438 // Verify the canonical suffix. | 419 // Verify the canonical suffix. |
439 EXPECT_EQ(".c.youtube.com", impl_.GetCanonicalSuffix(test_host_port_pair)); | 420 EXPECT_EQ(".c.youtube.com", impl_.GetCanonicalSuffix(test_host_port_pair)); |
440 EXPECT_EQ(".c.youtube.com", impl_.GetCanonicalSuffix(canonical_port_pair)); | 421 EXPECT_EQ(".c.youtube.com", impl_.GetCanonicalSuffix(canonical_port_pair)); |
441 } | 422 } |
442 | 423 |
443 TEST_F(AlternateProtocolServerPropertiesTest, ClearCanonical) { | 424 TEST_F(AlternateProtocolServerPropertiesTest, ClearCanonical) { |
444 HostPortPair test_host_port_pair("foo.c.youtube.com", 80); | 425 HostPortPair test_host_port_pair("foo.c.youtube.com", 80); |
445 HostPortPair canonical_port_pair("bar.c.youtube.com", 80); | 426 HostPortPair canonical_port_pair("bar.c.youtube.com", 80); |
446 | 427 |
447 AlternateProtocolInfo canonical_protocol(1234, QUIC, 1); | 428 PortAlternateProtocolPair canonical_protocol; |
| 429 canonical_protocol.port = 1234; |
| 430 canonical_protocol.protocol = QUIC; |
448 | 431 |
449 impl_.SetAlternateProtocol(canonical_port_pair, | 432 impl_.SetAlternateProtocol(canonical_port_pair, |
450 canonical_protocol.port, | 433 canonical_protocol.port, |
451 canonical_protocol.protocol, | 434 canonical_protocol.protocol); |
452 canonical_protocol.probability); | |
453 | 435 |
454 impl_.ClearAlternateProtocol(canonical_port_pair); | 436 impl_.ClearAlternateProtocol(canonical_port_pair); |
455 EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair)); | 437 EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair)); |
456 } | 438 } |
457 | 439 |
458 TEST_F(AlternateProtocolServerPropertiesTest, CanonicalBroken) { | 440 TEST_F(AlternateProtocolServerPropertiesTest, CanonicalBroken) { |
459 HostPortPair test_host_port_pair("foo.c.youtube.com", 80); | 441 HostPortPair test_host_port_pair("foo.c.youtube.com", 80); |
460 HostPortPair canonical_port_pair("bar.c.youtube.com", 80); | 442 HostPortPair canonical_port_pair("bar.c.youtube.com", 80); |
461 | 443 |
462 AlternateProtocolInfo canonical_protocol(1234, QUIC, 1); | 444 PortAlternateProtocolPair canonical_protocol; |
| 445 canonical_protocol.port = 1234; |
| 446 canonical_protocol.protocol = QUIC; |
463 | 447 |
464 impl_.SetAlternateProtocol(canonical_port_pair, | 448 impl_.SetAlternateProtocol(canonical_port_pair, |
465 canonical_protocol.port, | 449 canonical_protocol.port, |
466 canonical_protocol.protocol, | 450 canonical_protocol.protocol); |
467 canonical_protocol.probability); | |
468 | 451 |
469 impl_.SetBrokenAlternateProtocol(canonical_port_pair); | 452 impl_.SetBrokenAlternateProtocol(canonical_port_pair); |
470 EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair)); | 453 EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair)); |
471 } | 454 } |
472 | 455 |
473 TEST_F(AlternateProtocolServerPropertiesTest, ClearWithCanonical) { | 456 TEST_F(AlternateProtocolServerPropertiesTest, ClearWithCanonical) { |
474 HostPortPair test_host_port_pair("foo.c.youtube.com", 80); | 457 HostPortPair test_host_port_pair("foo.c.youtube.com", 80); |
475 HostPortPair canonical_port_pair("bar.c.youtube.com", 80); | 458 HostPortPair canonical_port_pair("bar.c.youtube.com", 80); |
476 | 459 |
477 AlternateProtocolInfo canonical_protocol(1234, QUIC, 1); | 460 PortAlternateProtocolPair canonical_protocol; |
| 461 canonical_protocol.port = 1234; |
| 462 canonical_protocol.protocol = QUIC; |
478 | 463 |
479 impl_.SetAlternateProtocol(canonical_port_pair, | 464 impl_.SetAlternateProtocol(canonical_port_pair, |
480 canonical_protocol.port, | 465 canonical_protocol.port, |
481 canonical_protocol.protocol, | 466 canonical_protocol.protocol); |
482 canonical_protocol.probability); | |
483 | 467 |
484 impl_.Clear(); | 468 impl_.Clear(); |
485 EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair)); | 469 EXPECT_FALSE(impl_.HasAlternateProtocol(test_host_port_pair)); |
486 } | 470 } |
487 | 471 |
488 typedef HttpServerPropertiesImplTest SpdySettingsServerPropertiesTest; | 472 typedef HttpServerPropertiesImplTest SpdySettingsServerPropertiesTest; |
489 | 473 |
490 TEST_F(SpdySettingsServerPropertiesTest, Initialize) { | 474 TEST_F(SpdySettingsServerPropertiesTest, Initialize) { |
491 HostPortPair spdy_server_google("www.google.com", 443); | 475 HostPortPair spdy_server_google("www.google.com", 443); |
492 | 476 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 it1_ret = settings_map1_it_ret.find(id1); | 652 it1_ret = settings_map1_it_ret.find(id1); |
669 EXPECT_TRUE(it1_ret != settings_map1_it_ret.end()); | 653 EXPECT_TRUE(it1_ret != settings_map1_it_ret.end()); |
670 flags_and_value1_ret = it1_ret->second; | 654 flags_and_value1_ret = it1_ret->second; |
671 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1_ret.first); | 655 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1_ret.first); |
672 EXPECT_EQ(value1, flags_and_value1_ret.second); | 656 EXPECT_EQ(value1, flags_and_value1_ret.second); |
673 } | 657 } |
674 | 658 |
675 } // namespace | 659 } // namespace |
676 | 660 |
677 } // namespace net | 661 } // namespace net |
OLD | NEW |