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