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

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

Issue 2901093004: Add and persist a new field in AlternativeServiceInfo to list QUIC verisons advertised (Closed)
Patch Set: self review Created 3 years, 7 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 <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "net/base/host_port_pair.h" 13 #include "net/base/host_port_pair.h"
14 #include "net/base/ip_address.h" 14 #include "net/base/ip_address.h"
15 #include "net/http/http_network_session.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 #include "url/gurl.h" 17 #include "url/gurl.h"
17 18
18 namespace base { 19 namespace base {
19 class ListValue; 20 class ListValue;
20 } 21 }
21 22
22 namespace net { 23 namespace net {
23 24
24 class HttpServerPropertiesImplPeer { 25 class HttpServerPropertiesImplPeer {
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 alternative_service_info_vector[0].alternative_service); 358 alternative_service_info_vector[0].alternative_service);
358 359
359 impl_.Clear(); 360 impl_.Clear();
360 EXPECT_FALSE(HasAlternativeService(test_server)); 361 EXPECT_FALSE(HasAlternativeService(test_server));
361 } 362 }
362 363
363 TEST_F(AlternateProtocolServerPropertiesTest, ExcludeOrigin) { 364 TEST_F(AlternateProtocolServerPropertiesTest, ExcludeOrigin) {
364 AlternativeServiceInfoVector alternative_service_info_vector; 365 AlternativeServiceInfoVector alternative_service_info_vector;
365 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 366 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
366 // Same hostname, same port, TCP: should be ignored. 367 // Same hostname, same port, TCP: should be ignored.
367 AlternativeServiceInfo alternative_service_info1(kProtoHTTP2, "foo", 443, 368 AlternativeServiceInfo alternative_service_info1(
368 expiration); 369 AlternativeService(kProtoHTTP2, "foo", 443), expiration);
369 alternative_service_info_vector.push_back(alternative_service_info1); 370 alternative_service_info_vector.push_back(alternative_service_info1);
370 // Different hostname: GetAlternativeServiceInfos should return this one. 371 // Different hostname: GetAlternativeServiceInfos should return this one.
371 AlternativeServiceInfo alternative_service_info2(kProtoHTTP2, "bar", 443, 372 AlternativeServiceInfo alternative_service_info2(
372 expiration); 373 AlternativeService(kProtoHTTP2, "bar", 443), expiration);
373 alternative_service_info_vector.push_back(alternative_service_info2); 374 alternative_service_info_vector.push_back(alternative_service_info2);
374 // Different port: GetAlternativeServiceInfos should return this one too. 375 // Different port: GetAlternativeServiceInfos should return this one too.
375 AlternativeServiceInfo alternative_service_info3(kProtoHTTP2, "foo", 80, 376 AlternativeServiceInfo alternative_service_info3(
376 expiration); 377 AlternativeService(kProtoHTTP2, "foo", 80), expiration);
377 alternative_service_info_vector.push_back(alternative_service_info3); 378 alternative_service_info_vector.push_back(alternative_service_info3);
378 // QUIC: GetAlternativeServices should return this one too. 379 // QUIC: GetAlternativeServices should return this one too.
379 AlternativeServiceInfo alternative_service_info4(kProtoQUIC, "foo", 443, 380 AlternativeServiceInfo alternative_service_info4(
380 expiration); 381 AlternativeService(kProtoQUIC, "foo", 443), expiration);
381 alternative_service_info_vector.push_back(alternative_service_info4); 382 alternative_service_info_vector.push_back(alternative_service_info4);
382 383
383 url::SchemeHostPort test_server("https", "foo", 443); 384 url::SchemeHostPort test_server("https", "foo", 443);
384 impl_.SetAlternativeServices(test_server, alternative_service_info_vector); 385 impl_.SetAlternativeServices(test_server, alternative_service_info_vector);
385 386
386 const AlternativeServiceInfoVector alternative_service_info_vector2 = 387 const AlternativeServiceInfoVector alternative_service_info_vector2 =
387 impl_.GetAlternativeServiceInfos(test_server); 388 impl_.GetAlternativeServiceInfos(test_server);
388 ASSERT_EQ(3u, alternative_service_info_vector2.size()); 389 ASSERT_EQ(3u, alternative_service_info_vector2.size());
389 EXPECT_EQ(alternative_service_info2, alternative_service_info_vector2[0]); 390 EXPECT_EQ(alternative_service_info2, alternative_service_info_vector2[0]);
390 EXPECT_EQ(alternative_service_info3, alternative_service_info_vector2[1]); 391 EXPECT_EQ(alternative_service_info3, alternative_service_info_vector2[1]);
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 alternative_service_info_vector = 631 alternative_service_info_vector =
631 impl_.GetAlternativeServiceInfos(test_server); 632 impl_.GetAlternativeServiceInfos(test_server);
632 ASSERT_EQ(1u, alternative_service_info_vector.size()); 633 ASSERT_EQ(1u, alternative_service_info_vector.size());
633 EXPECT_EQ(alternative_service1, 634 EXPECT_EQ(alternative_service1,
634 alternative_service_info_vector[0].alternative_service); 635 alternative_service_info_vector[0].alternative_service);
635 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service1)); 636 EXPECT_TRUE(impl_.IsAlternativeServiceBroken(alternative_service1));
636 637
637 // SetAlternativeServices should add a broken alternative service to the map. 638 // SetAlternativeServices should add a broken alternative service to the map.
638 AlternativeServiceInfoVector alternative_service_info_vector2; 639 AlternativeServiceInfoVector alternative_service_info_vector2;
639 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 640 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
641
Ryan Hamilton 2017/05/25 22:01:45 nit: remove
Zhongyi Shi 2017/06/06 22:04:52 Done.
640 alternative_service_info_vector2.push_back( 642 alternative_service_info_vector2.push_back(
641 AlternativeServiceInfo(alternative_service1, expiration)); 643 AlternativeServiceInfo(alternative_service1, expiration));
642 const AlternativeService alternative_service2(kProtoHTTP2, "foo", 1234); 644 const AlternativeService alternative_service2(kProtoHTTP2, "foo", 1234);
643 alternative_service_info_vector2.push_back( 645 alternative_service_info_vector2.push_back(
644 AlternativeServiceInfo(alternative_service2, expiration)); 646 AlternativeServiceInfo(alternative_service2, expiration));
645 impl_.SetAlternativeServices(test_server, alternative_service_info_vector2); 647 impl_.SetAlternativeServices(test_server, alternative_service_info_vector2);
646 alternative_service_info_vector = 648 alternative_service_info_vector =
647 impl_.GetAlternativeServiceInfos(test_server); 649 impl_.GetAlternativeServiceInfos(test_server);
648 ASSERT_EQ(2u, alternative_service_info_vector.size()); 650 ASSERT_EQ(2u, alternative_service_info_vector.size());
649 EXPECT_EQ(alternative_service1, 651 EXPECT_EQ(alternative_service1,
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 EXPECT_EQ(quic_server_info1, *(impl_.GetQuicServerInfo(quic_server_id))); 1241 EXPECT_EQ(quic_server_info1, *(impl_.GetQuicServerInfo(quic_server_id)));
1240 1242
1241 impl_.Clear(); 1243 impl_.Clear();
1242 EXPECT_EQ(0u, impl_.quic_server_info_map().size()); 1244 EXPECT_EQ(0u, impl_.quic_server_info_map().size());
1243 EXPECT_EQ(nullptr, impl_.GetQuicServerInfo(quic_server_id)); 1245 EXPECT_EQ(nullptr, impl_.GetQuicServerInfo(quic_server_id));
1244 } 1246 }
1245 1247
1246 } // namespace 1248 } // namespace
1247 1249
1248 } // namespace net 1250 } // namespace net
OLDNEW
« net/http/http_server_properties.cc ('K') | « net/http/http_server_properties.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698