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

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

Issue 1572753003: QUIC - Allow cronet apps to specify how many server configs are to be (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comments in Patch set 4 Created 4 years, 11 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
« no previous file with comments | « net/http/http_server_properties_impl.cc ('k') | net/http/http_server_properties_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 const ServerNetworkStats* stats3 = impl_.GetServerNetworkStats(foo_server); 1382 const ServerNetworkStats* stats3 = impl_.GetServerNetworkStats(foo_server);
1383 EXPECT_EQ(NULL, stats3); 1383 EXPECT_EQ(NULL, stats3);
1384 } 1384 }
1385 1385
1386 typedef HttpServerPropertiesImplTest QuicServerInfoServerPropertiesTest; 1386 typedef HttpServerPropertiesImplTest QuicServerInfoServerPropertiesTest;
1387 1387
1388 TEST_F(QuicServerInfoServerPropertiesTest, Initialize) { 1388 TEST_F(QuicServerInfoServerPropertiesTest, Initialize) {
1389 HostPortPair google_server("www.google.com", 443); 1389 HostPortPair google_server("www.google.com", 443);
1390 QuicServerId google_quic_server_id(google_server, PRIVACY_MODE_ENABLED); 1390 QuicServerId google_quic_server_id(google_server, PRIVACY_MODE_ENABLED);
1391 1391
1392 EXPECT_EQ(QuicServerInfoMap::NO_AUTO_EVICT,
1393 impl_.quic_server_info_map().max_size());
1394 impl_.SetMaxServerConfigsStoredInProperties(10);
1395 EXPECT_EQ(10u, impl_.quic_server_info_map().max_size());
1396
1392 // Check empty map. 1397 // Check empty map.
1393 QuicServerInfoMap init_quic_server_info_map(QuicServerInfoMap::NO_AUTO_EVICT); 1398 QuicServerInfoMap init_quic_server_info_map(QuicServerInfoMap::NO_AUTO_EVICT);
1394 impl_.InitializeQuicServerInfoMap(&init_quic_server_info_map); 1399 impl_.InitializeQuicServerInfoMap(&init_quic_server_info_map);
1395 EXPECT_EQ(0u, impl_.quic_server_info_map().size()); 1400 EXPECT_EQ(0u, impl_.quic_server_info_map().size());
1396 1401
1397 // Check by initializing with www.google.com:443. 1402 // Check by initializing with www.google.com:443.
1398 std::string google_server_info("google_quic_server_info"); 1403 std::string google_server_info("google_quic_server_info");
1399 init_quic_server_info_map.Put(google_quic_server_id, google_server_info); 1404 init_quic_server_info_map.Put(google_quic_server_id, google_server_info);
1400 impl_.InitializeQuicServerInfoMap(&init_quic_server_info_map); 1405 impl_.InitializeQuicServerInfoMap(&init_quic_server_info_map);
1401 1406
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 ASSERT_EQ(3u, memory_map.size()); 1447 ASSERT_EQ(3u, memory_map.size());
1443 QuicServerInfoMap::const_iterator memory_map_it = memory_map.begin(); 1448 QuicServerInfoMap::const_iterator memory_map_it = memory_map.begin();
1444 EXPECT_EQ(memory_map_it->first, docs_quic_server_id); 1449 EXPECT_EQ(memory_map_it->first, docs_quic_server_id);
1445 EXPECT_EQ(new_docs_server_info, memory_map_it->second); 1450 EXPECT_EQ(new_docs_server_info, memory_map_it->second);
1446 ++memory_map_it; 1451 ++memory_map_it;
1447 EXPECT_EQ(memory_map_it->first, google_quic_server_id); 1452 EXPECT_EQ(memory_map_it->first, google_quic_server_id);
1448 EXPECT_EQ(google_server_info, memory_map_it->second); 1453 EXPECT_EQ(google_server_info, memory_map_it->second);
1449 ++memory_map_it; 1454 ++memory_map_it;
1450 EXPECT_EQ(memory_map_it->first, mail_quic_server_id); 1455 EXPECT_EQ(memory_map_it->first, mail_quic_server_id);
1451 EXPECT_EQ(mail_server_info, memory_map_it->second); 1456 EXPECT_EQ(mail_server_info, memory_map_it->second);
1457
1458 // Shrink the size of |quic_server_info_map| and verify the MRU order is
1459 // maintained.
1460 impl_.SetMaxServerConfigsStoredInProperties(2);
1461 EXPECT_EQ(2u, impl_.quic_server_info_map().max_size());
1462
1463 const QuicServerInfoMap& memory_map1 = impl_.quic_server_info_map();
1464 ASSERT_EQ(2u, memory_map1.size());
1465 QuicServerInfoMap::const_iterator memory_map1_it = memory_map1.begin();
1466 EXPECT_EQ(memory_map1_it->first, docs_quic_server_id);
1467 EXPECT_EQ(new_docs_server_info, memory_map1_it->second);
1468 ++memory_map1_it;
1469 EXPECT_EQ(memory_map1_it->first, google_quic_server_id);
1470 EXPECT_EQ(google_server_info, memory_map1_it->second);
1471 // |QuicServerInfo| for |mail_quic_server_id| shouldn't be there.
1472 EXPECT_EQ(nullptr, impl_.GetQuicServerInfo(mail_quic_server_id));
1452 } 1473 }
1453 1474
1454 TEST_F(QuicServerInfoServerPropertiesTest, SetQuicServerInfo) { 1475 TEST_F(QuicServerInfoServerPropertiesTest, SetQuicServerInfo) {
1455 HostPortPair foo_server("foo", 80); 1476 HostPortPair foo_server("foo", 80);
1456 QuicServerId quic_server_id(foo_server, PRIVACY_MODE_ENABLED); 1477 QuicServerId quic_server_id(foo_server, PRIVACY_MODE_ENABLED);
1457 EXPECT_EQ(0u, impl_.quic_server_info_map().size()); 1478 EXPECT_EQ(0u, impl_.quic_server_info_map().size());
1458 1479
1459 std::string quic_server_info1("quic_server_info1"); 1480 std::string quic_server_info1("quic_server_info1");
1460 impl_.SetQuicServerInfo(quic_server_id, quic_server_info1); 1481 impl_.SetQuicServerInfo(quic_server_id, quic_server_info1);
1461 1482
1462 EXPECT_EQ(1u, impl_.quic_server_info_map().size()); 1483 EXPECT_EQ(1u, impl_.quic_server_info_map().size());
1463 EXPECT_EQ(quic_server_info1, *(impl_.GetQuicServerInfo(quic_server_id))); 1484 EXPECT_EQ(quic_server_info1, *(impl_.GetQuicServerInfo(quic_server_id)));
1464 1485
1465 impl_.Clear(); 1486 impl_.Clear();
1466 EXPECT_EQ(0u, impl_.quic_server_info_map().size()); 1487 EXPECT_EQ(0u, impl_.quic_server_info_map().size());
1467 EXPECT_EQ(nullptr, impl_.GetQuicServerInfo(quic_server_id)); 1488 EXPECT_EQ(nullptr, impl_.GetQuicServerInfo(quic_server_id));
1468 } 1489 }
1469 1490
1470 } // namespace 1491 } // namespace
1471 1492
1472 } // namespace net 1493 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties_impl.cc ('k') | net/http/http_server_properties_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698