OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/spdy/hpack_header_table.h" | 5 #include "net/spdy/hpack_header_table.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "net/spdy/hpack_constants.h" | 14 #include "net/spdy/hpack_constants.h" |
15 #include "net/spdy/hpack_entry.h" | 15 #include "net/spdy/hpack_entry.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 | 17 |
18 namespace net { | 18 namespace net { |
19 | 19 |
20 using base::StringPiece; | 20 using base::StringPiece; |
21 using std::distance; | 21 using std::distance; |
22 using std::string; | 22 using std::string; |
23 | 23 |
24 namespace test { | 24 namespace test { |
25 | 25 |
26 class HpackHeaderTablePeer { | 26 class HpackHeaderTablePeer { |
27 public: | 27 public: |
28 explicit HpackHeaderTablePeer(HpackHeaderTable* table) | 28 explicit HpackHeaderTablePeer(HpackHeaderTable* table) : table_(table) {} |
29 : table_(table) {} | |
30 | 29 |
31 const HpackHeaderTable::EntryTable& dynamic_entries() { | 30 const HpackHeaderTable::EntryTable& dynamic_entries() { |
32 return table_->dynamic_entries_; | 31 return table_->dynamic_entries_; |
33 } | 32 } |
34 const HpackHeaderTable::EntryTable& static_entries() { | 33 const HpackHeaderTable::EntryTable& static_entries() { |
35 return table_->static_entries_; | 34 return table_->static_entries_; |
36 } | 35 } |
37 const HpackEntry::OrderedSet& index() { | 36 const HpackEntry::OrderedSet& index() { return table_->index_; } |
38 return table_->index_; | |
39 } | |
40 std::vector<HpackEntry*> EvictionSet(StringPiece name, StringPiece value) { | 37 std::vector<HpackEntry*> EvictionSet(StringPiece name, StringPiece value) { |
41 HpackHeaderTable::EntryTable::iterator begin, end; | 38 HpackHeaderTable::EntryTable::iterator begin, end; |
42 table_->EvictionSet(name, value, &begin, &end); | 39 table_->EvictionSet(name, value, &begin, &end); |
43 std::vector<HpackEntry*> result; | 40 std::vector<HpackEntry*> result; |
44 for (; begin != end; ++begin) { | 41 for (; begin != end; ++begin) { |
45 result.push_back(&(*begin)); | 42 result.push_back(&(*begin)); |
46 } | 43 } |
47 return result; | 44 return result; |
48 } | 45 } |
49 size_t total_insertions() { | 46 size_t total_insertions() { return table_->total_insertions_; } |
50 return table_->total_insertions_; | 47 size_t dynamic_entries_count() { return table_->dynamic_entries_count_; } |
51 } | |
52 size_t dynamic_entries_count() { | |
53 return table_->dynamic_entries_count_; | |
54 } | |
55 size_t EvictionCountForEntry(StringPiece name, StringPiece value) { | 48 size_t EvictionCountForEntry(StringPiece name, StringPiece value) { |
56 return table_->EvictionCountForEntry(name, value); | 49 return table_->EvictionCountForEntry(name, value); |
57 } | 50 } |
58 size_t EvictionCountToReclaim(size_t reclaim_size) { | 51 size_t EvictionCountToReclaim(size_t reclaim_size) { |
59 return table_->EvictionCountToReclaim(reclaim_size); | 52 return table_->EvictionCountToReclaim(reclaim_size); |
60 } | 53 } |
61 void Evict(size_t count) { | 54 void Evict(size_t count) { return table_->Evict(count); } |
62 return table_->Evict(count); | |
63 } | |
64 | 55 |
65 private: | 56 private: |
66 HpackHeaderTable* table_; | 57 HpackHeaderTable* table_; |
67 }; | 58 }; |
68 | 59 |
69 } // namespace test | 60 } // namespace test |
70 | 61 |
71 namespace { | 62 namespace { |
72 | 63 |
73 class HpackHeaderTableTest : public ::testing::Test { | 64 class HpackHeaderTableTest : public ::testing::Test { |
74 protected: | 65 protected: |
75 typedef std::vector<HpackEntry> HpackEntryVector; | 66 typedef std::vector<HpackEntry> HpackEntryVector; |
76 | 67 |
77 HpackHeaderTableTest() | 68 HpackHeaderTableTest() : table_(), peer_(&table_) {} |
78 : table_(), | |
79 peer_(&table_) {} | |
80 | 69 |
81 // Returns an entry whose Size() is equal to the given one. | 70 // Returns an entry whose Size() is equal to the given one. |
82 static HpackEntry MakeEntryOfSize(uint32 size) { | 71 static HpackEntry MakeEntryOfSize(uint32 size) { |
83 EXPECT_GE(size, HpackEntry::kSizeOverhead); | 72 EXPECT_GE(size, HpackEntry::kSizeOverhead); |
84 string name((size - HpackEntry::kSizeOverhead) / 2, 'n'); | 73 string name((size - HpackEntry::kSizeOverhead) / 2, 'n'); |
85 string value(size - HpackEntry::kSizeOverhead - name.size(), 'v'); | 74 string value(size - HpackEntry::kSizeOverhead - name.size(), 'v'); |
86 HpackEntry entry(name, value); | 75 HpackEntry entry(name, value); |
87 EXPECT_EQ(size, entry.Size()); | 76 EXPECT_EQ(size, entry.Size()); |
88 return entry; | 77 return entry; |
89 } | 78 } |
(...skipping 11 matching lines...) Expand all Loading... |
101 remaining_size -= entry_size; | 90 remaining_size -= entry_size; |
102 entry_size = std::min(remaining_size, entry_size + 32); | 91 entry_size = std::min(remaining_size, entry_size + 32); |
103 } | 92 } |
104 return entries; | 93 return entries; |
105 } | 94 } |
106 | 95 |
107 // Adds the given vector of entries to the given header table, | 96 // Adds the given vector of entries to the given header table, |
108 // expecting no eviction to happen. | 97 // expecting no eviction to happen. |
109 void AddEntriesExpectNoEviction(const HpackEntryVector& entries) { | 98 void AddEntriesExpectNoEviction(const HpackEntryVector& entries) { |
110 for (HpackEntryVector::const_iterator it = entries.begin(); | 99 for (HpackEntryVector::const_iterator it = entries.begin(); |
111 it != entries.end(); ++it) { | 100 it != entries.end(); |
| 101 ++it) { |
112 HpackHeaderTable::EntryTable::iterator begin, end; | 102 HpackHeaderTable::EntryTable::iterator begin, end; |
113 | 103 |
114 table_.EvictionSet(it->name(), it->value(), &begin, &end); | 104 table_.EvictionSet(it->name(), it->value(), &begin, &end); |
115 EXPECT_EQ(0, distance(begin, end)); | 105 EXPECT_EQ(0, distance(begin, end)); |
116 | 106 |
117 HpackEntry* entry = table_.TryAddEntry(it->name(), it->value()); | 107 HpackEntry* entry = table_.TryAddEntry(it->name(), it->value()); |
118 EXPECT_NE(entry, static_cast<HpackEntry*>(NULL)); | 108 EXPECT_NE(entry, static_cast<HpackEntry*>(NULL)); |
119 } | 109 } |
120 | 110 |
121 for (size_t i = 0; i != entries.size(); ++i) { | 111 for (size_t i = 0; i != entries.size(); ++i) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // Index() of |first_static_entry| reflects the eviction. | 177 // Index() of |first_static_entry| reflects the eviction. |
188 EXPECT_EQ(1u, first_static_entry->Index()); | 178 EXPECT_EQ(1u, first_static_entry->Index()); |
189 EXPECT_EQ(first_static_entry, table_.GetByIndex(1)); | 179 EXPECT_EQ(first_static_entry, table_.GetByIndex(1)); |
190 } | 180 } |
191 | 181 |
192 TEST_F(HpackHeaderTableTest, EntryIndexing) { | 182 TEST_F(HpackHeaderTableTest, EntryIndexing) { |
193 HpackEntry* first_static_entry = table_.GetByIndex(1); | 183 HpackEntry* first_static_entry = table_.GetByIndex(1); |
194 | 184 |
195 // Static entries are queryable by name & value. | 185 // Static entries are queryable by name & value. |
196 EXPECT_EQ(first_static_entry, table_.GetByName(first_static_entry->name())); | 186 EXPECT_EQ(first_static_entry, table_.GetByName(first_static_entry->name())); |
197 EXPECT_EQ(first_static_entry, table_.GetByNameAndValue( | 187 EXPECT_EQ(first_static_entry, |
198 first_static_entry->name(), first_static_entry->value())); | 188 table_.GetByNameAndValue(first_static_entry->name(), |
| 189 first_static_entry->value())); |
199 | 190 |
200 // Create a mix of entries which duplicate names, and names & values of both | 191 // Create a mix of entries which duplicate names, and names & values of both |
201 // dynamic and static entries. | 192 // dynamic and static entries. |
202 HpackEntry* entry1 = table_.TryAddEntry(first_static_entry->name(), | 193 HpackEntry* entry1 = table_.TryAddEntry(first_static_entry->name(), |
203 first_static_entry->value()); | 194 first_static_entry->value()); |
204 HpackEntry* entry2 = table_.TryAddEntry(first_static_entry->name(), | 195 HpackEntry* entry2 = |
205 "Value Four"); | 196 table_.TryAddEntry(first_static_entry->name(), "Value Four"); |
206 HpackEntry* entry3 = table_.TryAddEntry("key-1", "Value One"); | 197 HpackEntry* entry3 = table_.TryAddEntry("key-1", "Value One"); |
207 HpackEntry* entry4 = table_.TryAddEntry("key-2", "Value Three"); | 198 HpackEntry* entry4 = table_.TryAddEntry("key-2", "Value Three"); |
208 HpackEntry* entry5 = table_.TryAddEntry("key-1", "Value Two"); | 199 HpackEntry* entry5 = table_.TryAddEntry("key-1", "Value Two"); |
209 HpackEntry* entry6 = table_.TryAddEntry("key-2", "Value Three"); | 200 HpackEntry* entry6 = table_.TryAddEntry("key-2", "Value Three"); |
210 HpackEntry* entry7 = table_.TryAddEntry("key-2", "Value Four"); | 201 HpackEntry* entry7 = table_.TryAddEntry("key-2", "Value Four"); |
211 | 202 |
212 // Entries are queryable under their current index. | 203 // Entries are queryable under their current index. |
213 EXPECT_EQ(entry7, table_.GetByIndex(1)); | 204 EXPECT_EQ(entry7, table_.GetByIndex(1)); |
214 EXPECT_EQ(entry6, table_.GetByIndex(2)); | 205 EXPECT_EQ(entry6, table_.GetByIndex(2)); |
215 EXPECT_EQ(entry5, table_.GetByIndex(3)); | 206 EXPECT_EQ(entry5, table_.GetByIndex(3)); |
216 EXPECT_EQ(entry4, table_.GetByIndex(4)); | 207 EXPECT_EQ(entry4, table_.GetByIndex(4)); |
217 EXPECT_EQ(entry3, table_.GetByIndex(5)); | 208 EXPECT_EQ(entry3, table_.GetByIndex(5)); |
218 EXPECT_EQ(entry2, table_.GetByIndex(6)); | 209 EXPECT_EQ(entry2, table_.GetByIndex(6)); |
219 EXPECT_EQ(entry1, table_.GetByIndex(7)); | 210 EXPECT_EQ(entry1, table_.GetByIndex(7)); |
220 EXPECT_EQ(first_static_entry, table_.GetByIndex(8)); | 211 EXPECT_EQ(first_static_entry, table_.GetByIndex(8)); |
221 | 212 |
222 // Querying by name returns the lowest-value matching entry. | 213 // Querying by name returns the lowest-value matching entry. |
223 EXPECT_EQ(entry3, table_.GetByName("key-1")); | 214 EXPECT_EQ(entry3, table_.GetByName("key-1")); |
224 EXPECT_EQ(entry7, table_.GetByName("key-2")); | 215 EXPECT_EQ(entry7, table_.GetByName("key-2")); |
225 EXPECT_EQ(entry2->name(), | 216 EXPECT_EQ(entry2->name(), |
226 table_.GetByName(first_static_entry->name())->name()); | 217 table_.GetByName(first_static_entry->name())->name()); |
227 EXPECT_EQ(NULL, table_.GetByName("not-present")); | 218 EXPECT_EQ(NULL, table_.GetByName("not-present")); |
228 | 219 |
229 // Querying by name & value returns the lowest-index matching entry. | 220 // Querying by name & value returns the lowest-index matching entry. |
230 EXPECT_EQ(entry3, table_.GetByNameAndValue("key-1", "Value One")); | 221 EXPECT_EQ(entry3, table_.GetByNameAndValue("key-1", "Value One")); |
231 EXPECT_EQ(entry5, table_.GetByNameAndValue("key-1", "Value Two")); | 222 EXPECT_EQ(entry5, table_.GetByNameAndValue("key-1", "Value Two")); |
232 EXPECT_EQ(entry6, table_.GetByNameAndValue("key-2", "Value Three")); | 223 EXPECT_EQ(entry6, table_.GetByNameAndValue("key-2", "Value Three")); |
233 EXPECT_EQ(entry7, table_.GetByNameAndValue("key-2", "Value Four")); | 224 EXPECT_EQ(entry7, table_.GetByNameAndValue("key-2", "Value Four")); |
234 EXPECT_EQ(entry1, table_.GetByNameAndValue(first_static_entry->name(), | 225 EXPECT_EQ(entry1, |
235 first_static_entry->value())); | 226 table_.GetByNameAndValue(first_static_entry->name(), |
236 EXPECT_EQ(entry2, table_.GetByNameAndValue(first_static_entry->name(), | 227 first_static_entry->value())); |
237 "Value Four")); | 228 EXPECT_EQ(entry2, |
| 229 table_.GetByNameAndValue(first_static_entry->name(), "Value Four")); |
238 EXPECT_EQ(NULL, table_.GetByNameAndValue("key-1", "Not Present")); | 230 EXPECT_EQ(NULL, table_.GetByNameAndValue("key-1", "Not Present")); |
239 EXPECT_EQ(NULL, table_.GetByNameAndValue("not-present", "Value One")); | 231 EXPECT_EQ(NULL, table_.GetByNameAndValue("not-present", "Value One")); |
240 | 232 |
241 // Evict |entry1|. Queries for its name & value now return the static entry. | 233 // Evict |entry1|. Queries for its name & value now return the static entry. |
242 // |entry2| remains queryable. | 234 // |entry2| remains queryable. |
243 peer_.Evict(1); | 235 peer_.Evict(1); |
244 EXPECT_EQ(first_static_entry, | 236 EXPECT_EQ(first_static_entry, |
245 table_.GetByNameAndValue(first_static_entry->name(), | 237 table_.GetByNameAndValue(first_static_entry->name(), |
246 first_static_entry->value())); | 238 first_static_entry->value())); |
247 EXPECT_EQ(entry2, table_.GetByNameAndValue(first_static_entry->name(), | 239 EXPECT_EQ(entry2, |
248 "Value Four")); | 240 table_.GetByNameAndValue(first_static_entry->name(), "Value Four")); |
249 | 241 |
250 // Evict |entry2|. Queries by its name & value are not found. | 242 // Evict |entry2|. Queries by its name & value are not found. |
251 peer_.Evict(1); | 243 peer_.Evict(1); |
252 EXPECT_EQ(NULL, table_.GetByNameAndValue(first_static_entry->name(), | 244 EXPECT_EQ(NULL, |
253 "Value Four")); | 245 table_.GetByNameAndValue(first_static_entry->name(), "Value Four")); |
254 } | 246 } |
255 | 247 |
256 TEST_F(HpackHeaderTableTest, SetSizes) { | 248 TEST_F(HpackHeaderTableTest, SetSizes) { |
257 string key = "key", value = "value"; | 249 string key = "key", value = "value"; |
258 HpackEntry* entry1 = table_.TryAddEntry(key, value); | 250 HpackEntry* entry1 = table_.TryAddEntry(key, value); |
259 HpackEntry* entry2 = table_.TryAddEntry(key, value); | 251 HpackEntry* entry2 = table_.TryAddEntry(key, value); |
260 HpackEntry* entry3 = table_.TryAddEntry(key, value); | 252 HpackEntry* entry3 = table_.TryAddEntry(key, value); |
261 | 253 |
262 // Set exactly large enough. No Evictions. | 254 // Set exactly large enough. No Evictions. |
263 size_t max_size = entry1->Size() + entry2->Size() + entry3->Size(); | 255 size_t max_size = entry1->Size() + entry2->Size() + entry3->Size(); |
264 table_.SetMaxSize(max_size); | 256 table_.SetMaxSize(max_size); |
265 EXPECT_EQ(3u, peer_.dynamic_entries().size()); | 257 EXPECT_EQ(3u, peer_.dynamic_entries().size()); |
266 | 258 |
267 // Set just too small. One eviction. | 259 // Set just too small. One eviction. |
268 max_size = entry1->Size() + entry2->Size() + entry3->Size() - 1; | 260 max_size = entry1->Size() + entry2->Size() + entry3->Size() - 1; |
269 table_.SetMaxSize(max_size); | 261 table_.SetMaxSize(max_size); |
270 EXPECT_EQ(2u, peer_.dynamic_entries().size()); | 262 EXPECT_EQ(2u, peer_.dynamic_entries().size()); |
271 | 263 |
272 // Changing SETTINGS_HEADER_TABLE_SIZE doesn't affect table_.max_size(), | 264 // Changing SETTINGS_HEADER_TABLE_SIZE doesn't affect table_.max_size(), |
273 // iff SETTINGS_HEADER_TABLE_SIZE >= |max_size|. | 265 // iff SETTINGS_HEADER_TABLE_SIZE >= |max_size|. |
274 EXPECT_EQ(kDefaultHeaderTableSizeSetting, table_.settings_size_bound()); | 266 EXPECT_EQ(kDefaultHeaderTableSizeSetting, table_.settings_size_bound()); |
275 table_.SetSettingsHeaderTableSize(kDefaultHeaderTableSizeSetting*2); | 267 table_.SetSettingsHeaderTableSize(kDefaultHeaderTableSizeSetting * 2); |
276 EXPECT_EQ(max_size, table_.max_size()); | 268 EXPECT_EQ(max_size, table_.max_size()); |
277 table_.SetSettingsHeaderTableSize(max_size + 1); | 269 table_.SetSettingsHeaderTableSize(max_size + 1); |
278 EXPECT_EQ(max_size, table_.max_size()); | 270 EXPECT_EQ(max_size, table_.max_size()); |
279 EXPECT_EQ(2u, peer_.dynamic_entries().size()); | 271 EXPECT_EQ(2u, peer_.dynamic_entries().size()); |
280 | 272 |
281 // SETTINGS_HEADER_TABLE_SIZE upper-bounds |table_.max_size()|, | 273 // SETTINGS_HEADER_TABLE_SIZE upper-bounds |table_.max_size()|, |
282 // and will force evictions. | 274 // and will force evictions. |
283 max_size = entry3->Size() - 1; | 275 max_size = entry3->Size() - 1; |
284 table_.SetSettingsHeaderTableSize(max_size); | 276 table_.SetSettingsHeaderTableSize(max_size); |
285 EXPECT_EQ(max_size, table_.max_size()); | 277 EXPECT_EQ(max_size, table_.max_size()); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 // Most of the checks are in AddEntriesExpectNoEviction(). | 358 // Most of the checks are in AddEntriesExpectNoEviction(). |
367 AddEntriesExpectNoEviction(entries); | 359 AddEntriesExpectNoEviction(entries); |
368 EXPECT_EQ(table_.max_size(), table_.size()); | 360 EXPECT_EQ(table_.max_size(), table_.size()); |
369 EXPECT_EQ(table_.settings_size_bound(), table_.size()); | 361 EXPECT_EQ(table_.settings_size_bound(), table_.size()); |
370 } | 362 } |
371 | 363 |
372 // Fill a header table with entries, and then ramp the table's max | 364 // Fill a header table with entries, and then ramp the table's max |
373 // size down to evict an entry one at a time. Make sure the eviction | 365 // size down to evict an entry one at a time. Make sure the eviction |
374 // happens as expected. | 366 // happens as expected. |
375 TEST_F(HpackHeaderTableTest, SetMaxSize) { | 367 TEST_F(HpackHeaderTableTest, SetMaxSize) { |
376 HpackEntryVector entries = MakeEntriesOfTotalSize( | 368 HpackEntryVector entries = |
377 kDefaultHeaderTableSizeSetting / 2); | 369 MakeEntriesOfTotalSize(kDefaultHeaderTableSizeSetting / 2); |
378 AddEntriesExpectNoEviction(entries); | 370 AddEntriesExpectNoEviction(entries); |
379 | 371 |
380 for (HpackEntryVector::iterator it = entries.begin(); | 372 for (HpackEntryVector::iterator it = entries.begin(); it != entries.end(); |
381 it != entries.end(); ++it) { | 373 ++it) { |
382 size_t expected_count = distance(it, entries.end()); | 374 size_t expected_count = distance(it, entries.end()); |
383 EXPECT_EQ(expected_count, peer_.dynamic_entries().size()); | 375 EXPECT_EQ(expected_count, peer_.dynamic_entries().size()); |
384 | 376 |
385 table_.SetMaxSize(table_.size() + 1); | 377 table_.SetMaxSize(table_.size() + 1); |
386 EXPECT_EQ(expected_count, peer_.dynamic_entries().size()); | 378 EXPECT_EQ(expected_count, peer_.dynamic_entries().size()); |
387 | 379 |
388 table_.SetMaxSize(table_.size()); | 380 table_.SetMaxSize(table_.size()); |
389 EXPECT_EQ(expected_count, peer_.dynamic_entries().size()); | 381 EXPECT_EQ(expected_count, peer_.dynamic_entries().size()); |
390 | 382 |
391 --expected_count; | 383 --expected_count; |
392 table_.SetMaxSize(table_.size() - 1); | 384 table_.SetMaxSize(table_.size() - 1); |
393 EXPECT_EQ(expected_count, peer_.dynamic_entries().size()); | 385 EXPECT_EQ(expected_count, peer_.dynamic_entries().size()); |
394 } | 386 } |
395 EXPECT_EQ(0u, table_.size()); | 387 EXPECT_EQ(0u, table_.size()); |
396 } | 388 } |
397 | 389 |
398 // Fill a header table with entries, and then add an entry just big | 390 // Fill a header table with entries, and then add an entry just big |
399 // enough to cause eviction of all but one entry. Make sure the | 391 // enough to cause eviction of all but one entry. Make sure the |
400 // eviction happens as expected and the long entry is inserted into | 392 // eviction happens as expected and the long entry is inserted into |
401 // the table. | 393 // the table. |
402 TEST_F(HpackHeaderTableTest, TryAddEntryEviction) { | 394 TEST_F(HpackHeaderTableTest, TryAddEntryEviction) { |
403 HpackEntryVector entries = MakeEntriesOfTotalSize(table_.max_size()); | 395 HpackEntryVector entries = MakeEntriesOfTotalSize(table_.max_size()); |
404 AddEntriesExpectNoEviction(entries); | 396 AddEntriesExpectNoEviction(entries); |
405 | 397 |
406 HpackEntry* survivor_entry = table_.GetByIndex(1); | 398 HpackEntry* survivor_entry = table_.GetByIndex(1); |
407 HpackEntry long_entry = | 399 HpackEntry long_entry = |
408 MakeEntryOfSize(table_.max_size() - survivor_entry->Size()); | 400 MakeEntryOfSize(table_.max_size() - survivor_entry->Size()); |
409 | 401 |
410 // All entries but the first are to be evicted. | 402 // All entries but the first are to be evicted. |
411 EXPECT_EQ(peer_.dynamic_entries().size() - 1, peer_.EvictionSet( | 403 EXPECT_EQ(peer_.dynamic_entries().size() - 1, |
412 long_entry.name(), long_entry.value()).size()); | 404 peer_.EvictionSet(long_entry.name(), long_entry.value()).size()); |
413 | 405 |
414 HpackEntry* new_entry = table_.TryAddEntry(long_entry.name(), | 406 HpackEntry* new_entry = |
415 long_entry.value()); | 407 table_.TryAddEntry(long_entry.name(), long_entry.value()); |
416 EXPECT_EQ(1u, new_entry->Index()); | 408 EXPECT_EQ(1u, new_entry->Index()); |
417 EXPECT_EQ(2u, peer_.dynamic_entries().size()); | 409 EXPECT_EQ(2u, peer_.dynamic_entries().size()); |
418 EXPECT_EQ(table_.GetByIndex(2), survivor_entry); | 410 EXPECT_EQ(table_.GetByIndex(2), survivor_entry); |
419 EXPECT_EQ(table_.GetByIndex(1), new_entry); | 411 EXPECT_EQ(table_.GetByIndex(1), new_entry); |
420 } | 412 } |
421 | 413 |
422 // Fill a header table with entries, and then add an entry bigger than | 414 // Fill a header table with entries, and then add an entry bigger than |
423 // the entire table. Make sure no entry remains in the table. | 415 // the entire table. Make sure no entry remains in the table. |
424 TEST_F(HpackHeaderTableTest, TryAddTooLargeEntry) { | 416 TEST_F(HpackHeaderTableTest, TryAddTooLargeEntry) { |
425 HpackEntryVector entries = MakeEntriesOfTotalSize(table_.max_size()); | 417 HpackEntryVector entries = MakeEntriesOfTotalSize(table_.max_size()); |
426 AddEntriesExpectNoEviction(entries); | 418 AddEntriesExpectNoEviction(entries); |
427 | 419 |
428 HpackEntry long_entry = MakeEntryOfSize(table_.max_size() + 1); | 420 HpackEntry long_entry = MakeEntryOfSize(table_.max_size() + 1); |
429 | 421 |
430 // All entries are to be evicted. | 422 // All entries are to be evicted. |
431 EXPECT_EQ(peer_.dynamic_entries().size(), peer_.EvictionSet( | 423 EXPECT_EQ(peer_.dynamic_entries().size(), |
432 long_entry.name(), long_entry.value()).size()); | 424 peer_.EvictionSet(long_entry.name(), long_entry.value()).size()); |
433 | 425 |
434 HpackEntry* new_entry = table_.TryAddEntry(long_entry.name(), | 426 HpackEntry* new_entry = |
435 long_entry.value()); | 427 table_.TryAddEntry(long_entry.name(), long_entry.value()); |
436 EXPECT_EQ(new_entry, static_cast<HpackEntry*>(NULL)); | 428 EXPECT_EQ(new_entry, static_cast<HpackEntry*>(NULL)); |
437 EXPECT_EQ(0u, peer_.dynamic_entries().size()); | 429 EXPECT_EQ(0u, peer_.dynamic_entries().size()); |
438 } | 430 } |
439 | 431 |
440 } // namespace | 432 } // namespace |
441 | 433 |
442 } // namespace net | 434 } // namespace net |
OLD | NEW |