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

Side by Side Diff: chrome/browser/net/http_server_properties_manager_unittest.cc

Issue 9703050: SPDY - don't persist SpdySettings until we convert it to a map. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
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 "chrome/browser/net/http_server_properties_manager.h" 5 #include "chrome/browser/net/http_server_properties_manager.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 ExpectCacheUpdate(); 132 ExpectCacheUpdate();
133 133
134 // Set up the prefs for www.google.com:80 and mail.google.com:80 and then set 134 // Set up the prefs for www.google.com:80 and mail.google.com:80 and then set
135 // it twice. Only expect a single cache update. 135 // it twice. Only expect a single cache update.
136 136
137 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; 137 base::DictionaryValue* server_pref_dict = new base::DictionaryValue;
138 138
139 // Set supports_spdy for www.google.com:80. 139 // Set supports_spdy for www.google.com:80.
140 server_pref_dict->SetBoolean("supports_spdy", true); 140 server_pref_dict->SetBoolean("supports_spdy", true);
141 141
142 // Set up the SpdySettings for www.google.com:80.
143 base::ListValue* spdy_settings_list = new base::ListValue;
144 base::DictionaryValue* spdy_setting_dict = new base::DictionaryValue;
145 spdy_setting_dict->SetInteger("flags", spdy::SETTINGS_FLAG_PERSISTED);
146 spdy_setting_dict->SetInteger("id", 1234);
147 spdy_setting_dict->SetInteger("value", 31337);
148 spdy_settings_list->Append(spdy_setting_dict);
149 server_pref_dict->Set("settings", spdy_settings_list);
150
151 // Set up alternate_protocol for www.google.com:80. 142 // Set up alternate_protocol for www.google.com:80.
152 base::DictionaryValue* alternate_protocol = new base::DictionaryValue; 143 base::DictionaryValue* alternate_protocol = new base::DictionaryValue;
153 alternate_protocol->SetInteger("port", 443); 144 alternate_protocol->SetInteger("port", 443);
154 alternate_protocol->SetInteger("protocol", static_cast<int>(net::NPN_SPDY_1)); 145 alternate_protocol->SetInteger("protocol", static_cast<int>(net::NPN_SPDY_1));
155 server_pref_dict->SetWithoutPathExpansion( 146 server_pref_dict->SetWithoutPathExpansion(
156 "alternate_protocol", alternate_protocol); 147 "alternate_protocol", alternate_protocol);
157 148
158 // Set pipeline capability for www.google.com:80. 149 // Set pipeline capability for www.google.com:80.
159 server_pref_dict->SetInteger("pipeline_capability", net::PIPELINE_CAPABLE); 150 server_pref_dict->SetInteger("pipeline_capability", net::PIPELINE_CAPABLE);
160 151
161 // Set the server preference for www.google.com:80. 152 // Set the server preference for www.google.com:80.
162 base::DictionaryValue* http_server_properties_dict = 153 base::DictionaryValue* http_server_properties_dict =
163 new base::DictionaryValue; 154 new base::DictionaryValue;
164 http_server_properties_dict->SetWithoutPathExpansion( 155 http_server_properties_dict->SetWithoutPathExpansion(
165 "www.google.com:80", server_pref_dict); 156 "www.google.com:80", server_pref_dict);
166 157
167 // Set the preference for mail.google.com server. 158 // Set the preference for mail.google.com server.
168 base::DictionaryValue* server_pref_dict1 = new base::DictionaryValue; 159 base::DictionaryValue* server_pref_dict1 = new base::DictionaryValue;
169 160
170 // Set supports_spdy for mail.google.com:80 161 // Set supports_spdy for mail.google.com:80
171 server_pref_dict1->SetBoolean("supports_spdy", true); 162 server_pref_dict1->SetBoolean("supports_spdy", true);
172 163
173 // Set up the SpdySettings for mail.google.com:80
174 base::ListValue* spdy_settings_list1 = new base::ListValue;
175 base::DictionaryValue* spdy_setting_dict1 = new base::DictionaryValue;
176 spdy_setting_dict1->SetInteger("flags", spdy::SETTINGS_FLAG_PERSISTED);
177 spdy_setting_dict1->SetInteger("id", 5678);
178 spdy_setting_dict1->SetInteger("value", 62667);
179 spdy_settings_list1->Append(spdy_setting_dict1);
180 server_pref_dict1->Set("settings", spdy_settings_list1);
181
182 // Set up alternate_protocol for mail.google.com:80 164 // Set up alternate_protocol for mail.google.com:80
183 base::DictionaryValue* alternate_protocol1 = new base::DictionaryValue; 165 base::DictionaryValue* alternate_protocol1 = new base::DictionaryValue;
184 alternate_protocol1->SetInteger("port", 444); 166 alternate_protocol1->SetInteger("port", 444);
185 alternate_protocol1->SetInteger( 167 alternate_protocol1->SetInteger(
186 "protocol", static_cast<int>(net::NPN_SPDY_2)); 168 "protocol", static_cast<int>(net::NPN_SPDY_2));
187 server_pref_dict1->SetWithoutPathExpansion( 169 server_pref_dict1->SetWithoutPathExpansion(
188 "alternate_protocol", alternate_protocol1); 170 "alternate_protocol", alternate_protocol1);
189 171
190 // Set pipelining capability for mail.google.com:80 172 // Set pipelining capability for mail.google.com:80
191 server_pref_dict1->SetInteger("pipeline_capability", net::PIPELINE_INCAPABLE); 173 server_pref_dict1->SetInteger("pipeline_capability", net::PIPELINE_INCAPABLE);
(...skipping 14 matching lines...) Expand all
206 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); 188 Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
207 189
208 // Verify SupportsSpdy. 190 // Verify SupportsSpdy.
209 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy( 191 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy(
210 net::HostPortPair::FromString("www.google.com:80"))); 192 net::HostPortPair::FromString("www.google.com:80")));
211 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy( 193 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy(
212 net::HostPortPair::FromString("mail.google.com:80"))); 194 net::HostPortPair::FromString("mail.google.com:80")));
213 EXPECT_FALSE(http_server_props_manager_->SupportsSpdy( 195 EXPECT_FALSE(http_server_props_manager_->SupportsSpdy(
214 net::HostPortPair::FromString("foo.google.com:1337"))); 196 net::HostPortPair::FromString("foo.google.com:1337")));
215 197
216 // Verify SpdySettings.
217 spdy::SpdySettings spdy_settings_ret =
218 http_server_props_manager_->GetSpdySettings(
219 net::HostPortPair::FromString("www.google.com:80"));
220 ASSERT_EQ(1U, spdy_settings_ret.size());
221 spdy::SpdySetting spdy_setting1_ret = spdy_settings_ret.front();
222 spdy::SettingsFlagsAndId id1_ret(spdy_setting1_ret.first);
223 EXPECT_EQ(1234U, id1_ret.id());
224 EXPECT_EQ(spdy::SETTINGS_FLAG_PERSISTED, id1_ret.flags());
225 EXPECT_EQ(31337u, spdy_setting1_ret.second);
226 spdy_settings_ret = http_server_props_manager_->GetSpdySettings(
227 net::HostPortPair::FromString("mail.google.com:80"));
228 ASSERT_EQ(1U, spdy_settings_ret.size());
229 spdy_setting1_ret = spdy_settings_ret.front();
230 id1_ret = spdy_setting1_ret.first;
231 EXPECT_EQ(5678U, id1_ret.id());
232 EXPECT_EQ(spdy::SETTINGS_FLAG_PERSISTED, id1_ret.flags());
233 EXPECT_EQ(62667u, spdy_setting1_ret.second);
234
235 // Verify AlternateProtocol. 198 // Verify AlternateProtocol.
236 ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol( 199 ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol(
237 net::HostPortPair::FromString("www.google.com:80"))); 200 net::HostPortPair::FromString("www.google.com:80")));
238 ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol( 201 ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol(
239 net::HostPortPair::FromString("mail.google.com:80"))); 202 net::HostPortPair::FromString("mail.google.com:80")));
240 net::PortAlternateProtocolPair port_alternate_protocol = 203 net::PortAlternateProtocolPair port_alternate_protocol =
241 http_server_props_manager_->GetAlternateProtocol( 204 http_server_props_manager_->GetAlternateProtocol(
242 net::HostPortPair::FromString("www.google.com:80")); 205 net::HostPortPair::FromString("www.google.com:80"));
243 EXPECT_EQ(443, port_alternate_protocol.port); 206 EXPECT_EQ(443, port_alternate_protocol.port);
244 EXPECT_EQ(net::NPN_SPDY_1, port_alternate_protocol.protocol); 207 EXPECT_EQ(net::NPN_SPDY_1, port_alternate_protocol.protocol);
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 // Run the task after shutdown, but before deletion. 461 // Run the task after shutdown, but before deletion.
499 loop_.RunAllPending(); 462 loop_.RunAllPending();
500 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); 463 Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
501 http_server_props_manager_.reset(); 464 http_server_props_manager_.reset();
502 loop_.RunAllPending(); 465 loop_.RunAllPending();
503 } 466 }
504 467
505 } // namespace 468 } // namespace
506 469
507 } // namespace chrome_browser_net 470 } // namespace chrome_browser_net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698