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

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

Issue 1523543002: SPDY Servers - Servers that are restored from preferences maintain MRU order (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mru_cache_swap
Patch Set: rebase Created 5 years 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') | no next file » | 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/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 HttpServerPropertiesImpl impl_; 67 HttpServerPropertiesImpl impl_;
68 }; 68 };
69 69
70 typedef HttpServerPropertiesImplTest SpdyServerPropertiesTest; 70 typedef HttpServerPropertiesImplTest SpdyServerPropertiesTest;
71 71
72 TEST_F(SpdyServerPropertiesTest, Initialize) { 72 TEST_F(SpdyServerPropertiesTest, Initialize) {
73 HostPortPair spdy_server_google("www.google.com", 443); 73 HostPortPair spdy_server_google("www.google.com", 443);
74 std::string spdy_server_g = spdy_server_google.ToString(); 74 std::string spdy_server_g = spdy_server_google.ToString();
75 75
76 HostPortPair spdy_server_photos("photos.google.com", 443);
77 std::string spdy_server_p = spdy_server_photos.ToString();
78
76 HostPortPair spdy_server_docs("docs.google.com", 443); 79 HostPortPair spdy_server_docs("docs.google.com", 443);
77 std::string spdy_server_d = spdy_server_docs.ToString(); 80 std::string spdy_server_d = spdy_server_docs.ToString();
78 81
82 HostPortPair spdy_server_mail("mail.google.com", 443);
83 std::string spdy_server_m = spdy_server_mail.ToString();
84
79 // Check by initializing NULL spdy servers. 85 // Check by initializing NULL spdy servers.
80 impl_.InitializeSpdyServers(NULL, true); 86 impl_.InitializeSpdyServers(NULL, true);
81 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google)); 87 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google));
82 88
83 // Check by initializing empty spdy servers. 89 // Check by initializing empty spdy servers.
84 std::vector<std::string> spdy_servers; 90 std::vector<std::string> spdy_servers;
85 impl_.InitializeSpdyServers(&spdy_servers, true); 91 impl_.InitializeSpdyServers(&spdy_servers, true);
86 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google)); 92 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_google));
87 93
88 // Check by initializing with www.google.com:443 spdy server. 94 // Check by initializing www.google.com:443 and photos.google.com:443 as spdy
95 // servers.
89 std::vector<std::string> spdy_servers1; 96 std::vector<std::string> spdy_servers1;
90 spdy_servers1.push_back(spdy_server_g); 97 spdy_servers1.push_back(spdy_server_g); // Will be 0th index.
98 spdy_servers1.push_back(spdy_server_p); // Will be 1st index.
91 impl_.InitializeSpdyServers(&spdy_servers1, true); 99 impl_.InitializeSpdyServers(&spdy_servers1, true);
100 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_photos));
92 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google)); 101 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google));
93 102
94 // Check by initializing with www.google.com:443 and docs.google.com:443 spdy
95 // servers.
96 std::vector<std::string> spdy_servers2;
97 spdy_servers2.push_back(spdy_server_g);
98 spdy_servers2.push_back(spdy_server_d);
99 impl_.InitializeSpdyServers(&spdy_servers2, true);
100
101 // Verify spdy_server_g and spdy_server_d are in the list in the same order. 103 // Verify spdy_server_g and spdy_server_d are in the list in the same order.
102 base::ListValue spdy_server_list; 104 base::ListValue spdy_server_list;
103 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts); 105 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts);
104 EXPECT_EQ(2U, spdy_server_list.GetSize()); 106 EXPECT_EQ(2U, spdy_server_list.GetSize());
105 std::string string_value_g; 107 std::string string_value_g;
108 ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_g)); // 0th index.
109 ASSERT_EQ(spdy_server_g, string_value_g);
110 std::string string_value_p;
111 ASSERT_TRUE(spdy_server_list.GetString(1, &string_value_p)); // 1st index.
112 ASSERT_EQ(spdy_server_p, string_value_p);
113
114 // Check by initializing mail.google.com:443 and docs.google.com:443 as spdy
115 // servers.
116 std::vector<std::string> spdy_servers2;
117 spdy_servers2.push_back(spdy_server_m); // Will be 2nd index.
118 spdy_servers2.push_back(spdy_server_d); // Will be 3rd index.
119 impl_.InitializeSpdyServers(&spdy_servers2, true);
120
121 // Verify all the servers are in the list in the same order.
122 spdy_server_list.Clear();
123 impl_.GetSpdyServerList(&spdy_server_list, kMaxSupportsSpdyServerHosts);
124 EXPECT_EQ(4U, spdy_server_list.GetSize());
125
106 ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_g)); 126 ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_g));
107 ASSERT_EQ(spdy_server_g, string_value_g); 127 ASSERT_EQ(spdy_server_g, string_value_g);
128 ASSERT_TRUE(spdy_server_list.GetString(1, &string_value_p));
129 ASSERT_EQ(spdy_server_p, string_value_p);
130 std::string string_value_m;
131 ASSERT_TRUE(spdy_server_list.GetString(2, &string_value_m));
132 ASSERT_EQ(spdy_server_m, string_value_m);
108 std::string string_value_d; 133 std::string string_value_d;
109 ASSERT_TRUE(spdy_server_list.GetString(1, &string_value_d)); 134 ASSERT_TRUE(spdy_server_list.GetString(3, &string_value_d));
110 ASSERT_EQ(spdy_server_d, string_value_d); 135 ASSERT_EQ(spdy_server_d, string_value_d);
136
137 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs));
138 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_mail));
139 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_photos));
111 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google)); 140 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google));
141
142 // Verify new data that is being initialized overwrites what is already in the
143 // memory and also verify the recency list order.
144 //
145 // Change supports SPDY value for photos and mails servers and order of
146 // initalization shouldn't matter.
147 std::vector<std::string> spdy_servers3;
148 spdy_servers3.push_back(spdy_server_m);
149 spdy_servers3.push_back(spdy_server_p);
150 impl_.InitializeSpdyServers(&spdy_servers3, false);
151
152 // Verify the entries are in the same order.
153 ASSERT_TRUE(spdy_server_list.GetString(0, &string_value_g));
154 ASSERT_EQ(spdy_server_g, string_value_g);
155 ASSERT_TRUE(spdy_server_list.GetString(1, &string_value_p));
156 ASSERT_EQ(spdy_server_p, string_value_p);
157 ASSERT_TRUE(spdy_server_list.GetString(2, &string_value_m));
158 ASSERT_EQ(spdy_server_m, string_value_m);
159 ASSERT_TRUE(spdy_server_list.GetString(3, &string_value_d));
160 ASSERT_EQ(spdy_server_d, string_value_d);
161
162 // Verify photos and mail servers don't support SPDY and other servers support
163 // SPDY.
112 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs)); 164 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_docs));
165 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_mail));
166 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_photos));
167 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google));
113 } 168 }
114 169
115 TEST_F(SpdyServerPropertiesTest, SupportsRequestPriorityTest) { 170 TEST_F(SpdyServerPropertiesTest, SupportsRequestPriorityTest) {
116 HostPortPair spdy_server_empty(std::string(), 443); 171 HostPortPair spdy_server_empty(std::string(), 443);
117 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_empty)); 172 EXPECT_FALSE(impl_.SupportsRequestPriority(spdy_server_empty));
118 173
119 // Add www.google.com:443 as supporting SPDY. 174 // Add www.google.com:443 as supporting SPDY.
120 HostPortPair spdy_server_google("www.google.com", 443); 175 HostPortPair spdy_server_google("www.google.com", 443);
121 impl_.SetSupportsSpdy(spdy_server_google, true); 176 impl_.SetSupportsSpdy(spdy_server_google, true);
122 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google)); 177 EXPECT_TRUE(impl_.SupportsRequestPriority(spdy_server_google));
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 EXPECT_EQ(quic_server_info1, *(impl_.GetQuicServerInfo(quic_server_id))); 1289 EXPECT_EQ(quic_server_info1, *(impl_.GetQuicServerInfo(quic_server_id)));
1235 1290
1236 impl_.Clear(); 1291 impl_.Clear();
1237 EXPECT_EQ(0u, impl_.quic_server_info_map().size()); 1292 EXPECT_EQ(0u, impl_.quic_server_info_map().size());
1238 EXPECT_EQ(nullptr, impl_.GetQuicServerInfo(quic_server_id)); 1293 EXPECT_EQ(nullptr, impl_.GetQuicServerInfo(quic_server_id));
1239 } 1294 }
1240 1295
1241 } // namespace 1296 } // namespace
1242 1297
1243 } // namespace net 1298 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698