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

Side by Side Diff: net/quic/quic_write_blocked_list_test.cc

Issue 288313003: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src
Patch Set: implemented rch's comments Created 6 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 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/quic/quic_write_blocked_list.h" 5 #include "net/quic/quic_write_blocked_list.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace net { 9 namespace net {
10 namespace test { 10 namespace test {
11 namespace { 11 namespace {
12 12
13 TEST(QuicWriteBlockedListTest, PriorityOrder) { 13 TEST(QuicWriteBlockedListTest, PriorityOrder) {
14 QuicWriteBlockedList write_blocked_list; 14 QuicWriteBlockedList write_blocked_list;
15 15
16 // Mark streams blocked in roughly reverse priority order, and 16 // Mark streams blocked in roughly reverse priority order, and
17 // verify that streams are sorted. 17 // verify that streams are sorted.
18 write_blocked_list.PushBack(40, 18 write_blocked_list.PushBack(40,
19 QuicWriteBlockedList::kLowestPriority); 19 QuicWriteBlockedList::kLowestPriority);
20 write_blocked_list.PushBack(23, 20 write_blocked_list.PushBack(23,
21 QuicWriteBlockedList::kHighestPriority); 21 QuicWriteBlockedList::kHighestPriority);
22 write_blocked_list.PushBack(17, 22 write_blocked_list.PushBack(17,
23 QuicWriteBlockedList::kHighestPriority); 23 QuicWriteBlockedList::kHighestPriority);
24 write_blocked_list.PushBack(kHeadersStreamId, 24 write_blocked_list.PushBack(kHeadersStreamId,
25 QuicWriteBlockedList::kHighestPriority); 25 QuicWriteBlockedList::kHighestPriority);
26 write_blocked_list.PushBack(kCryptoStreamId, 26 write_blocked_list.PushBack(kCryptoStreamId,
27 QuicWriteBlockedList::kHighestPriority); 27 QuicWriteBlockedList::kHighestPriority);
28 28
29 EXPECT_EQ(5u, write_blocked_list.NumBlockedStreams()); 29 EXPECT_EQ(5u, write_blocked_list.NumBlockedStreams());
30 EXPECT_TRUE(write_blocked_list.HasWriteBlockedStreams()); 30 EXPECT_TRUE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
31 EXPECT_TRUE(write_blocked_list.HasWriteBlockedDataStreams());
31 // The Crypto stream is highest priority. 32 // The Crypto stream is highest priority.
32 EXPECT_EQ(kCryptoStreamId, write_blocked_list.PopFront()); 33 EXPECT_EQ(kCryptoStreamId, write_blocked_list.PopFront());
33 // Followed by the Headers stream. 34 // Followed by the Headers stream.
34 EXPECT_EQ(kHeadersStreamId, write_blocked_list.PopFront()); 35 EXPECT_EQ(kHeadersStreamId, write_blocked_list.PopFront());
35 // Streams with same priority are popped in the order they were inserted. 36 // Streams with same priority are popped in the order they were inserted.
36 EXPECT_EQ(23u, write_blocked_list.PopFront()); 37 EXPECT_EQ(23u, write_blocked_list.PopFront());
37 EXPECT_EQ(17u, write_blocked_list.PopFront()); 38 EXPECT_EQ(17u, write_blocked_list.PopFront());
38 // Low priority stream appears last. 39 // Low priority stream appears last.
39 EXPECT_EQ(40u, write_blocked_list.PopFront()); 40 EXPECT_EQ(40u, write_blocked_list.PopFront());
40 41
41 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams()); 42 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams());
42 EXPECT_FALSE(write_blocked_list.HasWriteBlockedStreams()); 43 EXPECT_FALSE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
44 EXPECT_FALSE(write_blocked_list.HasWriteBlockedDataStreams());
43 } 45 }
44 46
45 TEST(QuicWriteBlockedListTest, CryptoStream) { 47 TEST(QuicWriteBlockedListTest, CryptoStream) {
46 QuicWriteBlockedList write_blocked_list; 48 QuicWriteBlockedList write_blocked_list;
47 write_blocked_list.PushBack(kCryptoStreamId, 49 write_blocked_list.PushBack(kCryptoStreamId,
48 QuicWriteBlockedList::kHighestPriority); 50 QuicWriteBlockedList::kHighestPriority);
49 51
50 EXPECT_EQ(1u, write_blocked_list.NumBlockedStreams()); 52 EXPECT_EQ(1u, write_blocked_list.NumBlockedStreams());
51 EXPECT_TRUE(write_blocked_list.HasWriteBlockedStreams()); 53 EXPECT_TRUE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
52 EXPECT_EQ(kCryptoStreamId, write_blocked_list.PopFront()); 54 EXPECT_EQ(kCryptoStreamId, write_blocked_list.PopFront());
53 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams()); 55 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams());
54 EXPECT_FALSE(write_blocked_list.HasWriteBlockedStreams()); 56 EXPECT_FALSE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
55 } 57 }
56 58
57 TEST(QuicWriteBlockedListTest, HeadersStream) { 59 TEST(QuicWriteBlockedListTest, HeadersStream) {
58 QuicWriteBlockedList write_blocked_list; 60 QuicWriteBlockedList write_blocked_list;
59 write_blocked_list.PushBack(kHeadersStreamId, 61 write_blocked_list.PushBack(kHeadersStreamId,
60 QuicWriteBlockedList::kHighestPriority); 62 QuicWriteBlockedList::kHighestPriority);
61 63
62 EXPECT_EQ(1u, write_blocked_list.NumBlockedStreams()); 64 EXPECT_EQ(1u, write_blocked_list.NumBlockedStreams());
63 EXPECT_TRUE(write_blocked_list.HasWriteBlockedStreams()); 65 EXPECT_TRUE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
64 EXPECT_EQ(kHeadersStreamId, write_blocked_list.PopFront()); 66 EXPECT_EQ(kHeadersStreamId, write_blocked_list.PopFront());
65 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams()); 67 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams());
66 EXPECT_FALSE(write_blocked_list.HasWriteBlockedStreams()); 68 EXPECT_FALSE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
67 } 69 }
68 70
69 TEST(QuicWriteBlockedListTest, VerifyHeadersStream) { 71 TEST(QuicWriteBlockedListTest, VerifyHeadersStream) {
70 QuicWriteBlockedList write_blocked_list; 72 QuicWriteBlockedList write_blocked_list;
71 write_blocked_list.PushBack(5, 73 write_blocked_list.PushBack(5,
72 QuicWriteBlockedList::kHighestPriority); 74 QuicWriteBlockedList::kHighestPriority);
73 write_blocked_list.PushBack(kHeadersStreamId, 75 write_blocked_list.PushBack(kHeadersStreamId,
74 QuicWriteBlockedList::kHighestPriority); 76 QuicWriteBlockedList::kHighestPriority);
75 77
76 EXPECT_EQ(2u, write_blocked_list.NumBlockedStreams()); 78 EXPECT_EQ(2u, write_blocked_list.NumBlockedStreams());
77 EXPECT_TRUE(write_blocked_list.HasWriteBlockedStreams()); 79 EXPECT_TRUE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
80 EXPECT_TRUE(write_blocked_list.HasWriteBlockedDataStreams());
78 // In newer QUIC versions, there is a headers stream which is 81 // In newer QUIC versions, there is a headers stream which is
79 // higher priority than data streams. 82 // higher priority than data streams.
80 EXPECT_EQ(kHeadersStreamId, write_blocked_list.PopFront()); 83 EXPECT_EQ(kHeadersStreamId, write_blocked_list.PopFront());
81 EXPECT_EQ(5u, write_blocked_list.PopFront()); 84 EXPECT_EQ(5u, write_blocked_list.PopFront());
82 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams()); 85 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams());
83 EXPECT_FALSE(write_blocked_list.HasWriteBlockedStreams()); 86 EXPECT_FALSE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
87 EXPECT_FALSE(write_blocked_list.HasWriteBlockedDataStreams());
84 } 88 }
85 89
86 TEST(QuicWriteBlockedListTest, NoDuplicateEntries) { 90 TEST(QuicWriteBlockedListTest, NoDuplicateEntries) {
87 // Test that QuicWriteBlockedList doesn't allow duplicate entries. 91 // Test that QuicWriteBlockedList doesn't allow duplicate entries.
88 QuicWriteBlockedList write_blocked_list; 92 QuicWriteBlockedList write_blocked_list;
89 93
90 // Try to add a stream to the write blocked list multiple times at the same 94 // Try to add a stream to the write blocked list multiple times at the same
91 // priority. 95 // priority.
92 const QuicStreamId kBlockedId = 5; 96 const QuicStreamId kBlockedId = 5;
93 write_blocked_list.PushBack(kBlockedId, 97 write_blocked_list.PushBack(kBlockedId,
94 QuicWriteBlockedList::kHighestPriority); 98 QuicWriteBlockedList::kHighestPriority);
95 write_blocked_list.PushBack(kBlockedId, 99 write_blocked_list.PushBack(kBlockedId,
96 QuicWriteBlockedList::kHighestPriority); 100 QuicWriteBlockedList::kHighestPriority);
97 write_blocked_list.PushBack(kBlockedId, 101 write_blocked_list.PushBack(kBlockedId,
98 QuicWriteBlockedList::kHighestPriority); 102 QuicWriteBlockedList::kHighestPriority);
99 103
100 // This should only result in one blocked stream being added. 104 // This should only result in one blocked stream being added.
101 EXPECT_EQ(1u, write_blocked_list.NumBlockedStreams()); 105 EXPECT_EQ(1u, write_blocked_list.NumBlockedStreams());
102 EXPECT_TRUE(write_blocked_list.HasWriteBlockedStreams()); 106 EXPECT_TRUE(write_blocked_list.HasWriteBlockedDataStreams());
103 107
104 // There should only be one stream to pop off the front. 108 // There should only be one stream to pop off the front.
105 EXPECT_EQ(kBlockedId, write_blocked_list.PopFront()); 109 EXPECT_EQ(kBlockedId, write_blocked_list.PopFront());
106 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams()); 110 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams());
107 EXPECT_FALSE(write_blocked_list.HasWriteBlockedStreams()); 111 EXPECT_FALSE(write_blocked_list.HasWriteBlockedDataStreams());
108 } 112 }
109 113
110 } // namespace 114 } // namespace
111 } // namespace test 115 } // namespace test
112 } // namespace net 116 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698