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

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

Issue 1134603005: Remove WriteBlockedList::use_stream_to_priority. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « net/quic/quic_write_blocked_list.cc ('k') | net/spdy/write_blocked_list.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 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 "net/quic/test_tools/quic_test_utils.h" 7 #include "net/quic/test_tools/quic_test_utils.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace net { 10 namespace net {
11 namespace test { 11 namespace test {
12 namespace { 12 namespace {
13 13
14 TEST(QuicWriteBlockedListTest, PriorityOrder) { 14 TEST(QuicWriteBlockedListTest, PriorityOrder) {
15 QuicWriteBlockedList write_blocked_list(true); 15 QuicWriteBlockedList write_blocked_list;
16 16
17 // Mark streams blocked in roughly reverse priority order, and 17 // Mark streams blocked in roughly reverse priority order, and
18 // verify that streams are sorted. 18 // verify that streams are sorted.
19 write_blocked_list.PushBack(40, 19 write_blocked_list.PushBack(40,
20 QuicWriteBlockedList::kLowestPriority); 20 QuicWriteBlockedList::kLowestPriority);
21 write_blocked_list.PushBack(23, 21 write_blocked_list.PushBack(23,
22 QuicWriteBlockedList::kHighestPriority); 22 QuicWriteBlockedList::kHighestPriority);
23 write_blocked_list.PushBack(17, 23 write_blocked_list.PushBack(17,
24 QuicWriteBlockedList::kHighestPriority); 24 QuicWriteBlockedList::kHighestPriority);
25 write_blocked_list.PushBack(kHeadersStreamId, 25 write_blocked_list.PushBack(kHeadersStreamId,
(...skipping 13 matching lines...) Expand all
39 EXPECT_EQ(17u, write_blocked_list.PopFront()); 39 EXPECT_EQ(17u, write_blocked_list.PopFront());
40 // Low priority stream appears last. 40 // Low priority stream appears last.
41 EXPECT_EQ(40u, write_blocked_list.PopFront()); 41 EXPECT_EQ(40u, write_blocked_list.PopFront());
42 42
43 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams()); 43 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams());
44 EXPECT_FALSE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream()); 44 EXPECT_FALSE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
45 EXPECT_FALSE(write_blocked_list.HasWriteBlockedDataStreams()); 45 EXPECT_FALSE(write_blocked_list.HasWriteBlockedDataStreams());
46 } 46 }
47 47
48 TEST(QuicWriteBlockedListTest, CryptoStream) { 48 TEST(QuicWriteBlockedListTest, CryptoStream) {
49 QuicWriteBlockedList write_blocked_list(true); 49 QuicWriteBlockedList write_blocked_list;
50 write_blocked_list.PushBack(kCryptoStreamId, 50 write_blocked_list.PushBack(kCryptoStreamId,
51 QuicWriteBlockedList::kHighestPriority); 51 QuicWriteBlockedList::kHighestPriority);
52 52
53 EXPECT_EQ(1u, write_blocked_list.NumBlockedStreams()); 53 EXPECT_EQ(1u, write_blocked_list.NumBlockedStreams());
54 EXPECT_TRUE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream()); 54 EXPECT_TRUE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
55 EXPECT_EQ(kCryptoStreamId, write_blocked_list.PopFront()); 55 EXPECT_EQ(kCryptoStreamId, write_blocked_list.PopFront());
56 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams()); 56 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams());
57 EXPECT_FALSE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream()); 57 EXPECT_FALSE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
58 } 58 }
59 59
60 TEST(QuicWriteBlockedListTest, HeadersStream) { 60 TEST(QuicWriteBlockedListTest, HeadersStream) {
61 QuicWriteBlockedList write_blocked_list(true); 61 QuicWriteBlockedList write_blocked_list;
62 write_blocked_list.PushBack(kHeadersStreamId, 62 write_blocked_list.PushBack(kHeadersStreamId,
63 QuicWriteBlockedList::kHighestPriority); 63 QuicWriteBlockedList::kHighestPriority);
64 64
65 EXPECT_EQ(1u, write_blocked_list.NumBlockedStreams()); 65 EXPECT_EQ(1u, write_blocked_list.NumBlockedStreams());
66 EXPECT_TRUE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream()); 66 EXPECT_TRUE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
67 EXPECT_EQ(kHeadersStreamId, write_blocked_list.PopFront()); 67 EXPECT_EQ(kHeadersStreamId, write_blocked_list.PopFront());
68 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams()); 68 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams());
69 EXPECT_FALSE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream()); 69 EXPECT_FALSE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
70 } 70 }
71 71
72 TEST(QuicWriteBlockedListTest, VerifyHeadersStream) { 72 TEST(QuicWriteBlockedListTest, VerifyHeadersStream) {
73 QuicWriteBlockedList write_blocked_list(true); 73 QuicWriteBlockedList write_blocked_list;
74 write_blocked_list.PushBack(5, 74 write_blocked_list.PushBack(5,
75 QuicWriteBlockedList::kHighestPriority); 75 QuicWriteBlockedList::kHighestPriority);
76 write_blocked_list.PushBack(kHeadersStreamId, 76 write_blocked_list.PushBack(kHeadersStreamId,
77 QuicWriteBlockedList::kHighestPriority); 77 QuicWriteBlockedList::kHighestPriority);
78 78
79 EXPECT_EQ(2u, write_blocked_list.NumBlockedStreams()); 79 EXPECT_EQ(2u, write_blocked_list.NumBlockedStreams());
80 EXPECT_TRUE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream()); 80 EXPECT_TRUE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
81 EXPECT_TRUE(write_blocked_list.HasWriteBlockedDataStreams()); 81 EXPECT_TRUE(write_blocked_list.HasWriteBlockedDataStreams());
82 // In newer QUIC versions, there is a headers stream which is 82 // In newer QUIC versions, there is a headers stream which is
83 // higher priority than data streams. 83 // higher priority than data streams.
84 EXPECT_EQ(kHeadersStreamId, write_blocked_list.PopFront()); 84 EXPECT_EQ(kHeadersStreamId, write_blocked_list.PopFront());
85 EXPECT_EQ(5u, write_blocked_list.PopFront()); 85 EXPECT_EQ(5u, write_blocked_list.PopFront());
86 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams()); 86 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams());
87 EXPECT_FALSE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream()); 87 EXPECT_FALSE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream());
88 EXPECT_FALSE(write_blocked_list.HasWriteBlockedDataStreams()); 88 EXPECT_FALSE(write_blocked_list.HasWriteBlockedDataStreams());
89 } 89 }
90 90
91 TEST(QuicWriteBlockedListTest, NoDuplicateEntries) { 91 TEST(QuicWriteBlockedListTest, NoDuplicateEntries) {
92 // Test that QuicWriteBlockedList doesn't allow duplicate entries. 92 // Test that QuicWriteBlockedList doesn't allow duplicate entries.
93 QuicWriteBlockedList write_blocked_list(true); 93 QuicWriteBlockedList write_blocked_list;
94 94
95 // Try to add a stream to the write blocked list multiple times at the same 95 // Try to add a stream to the write blocked list multiple times at the same
96 // priority. 96 // priority.
97 const QuicStreamId kBlockedId = kClientDataStreamId1; 97 const QuicStreamId kBlockedId = kClientDataStreamId1;
98 write_blocked_list.PushBack(kBlockedId, 98 write_blocked_list.PushBack(kBlockedId,
99 QuicWriteBlockedList::kHighestPriority); 99 QuicWriteBlockedList::kHighestPriority);
100 write_blocked_list.PushBack(kBlockedId, 100 write_blocked_list.PushBack(kBlockedId,
101 QuicWriteBlockedList::kHighestPriority); 101 QuicWriteBlockedList::kHighestPriority);
102 write_blocked_list.PushBack(kBlockedId, 102 write_blocked_list.PushBack(kBlockedId,
103 QuicWriteBlockedList::kHighestPriority); 103 QuicWriteBlockedList::kHighestPriority);
104 104
105 // This should only result in one blocked stream being added. 105 // This should only result in one blocked stream being added.
106 EXPECT_EQ(1u, write_blocked_list.NumBlockedStreams()); 106 EXPECT_EQ(1u, write_blocked_list.NumBlockedStreams());
107 EXPECT_TRUE(write_blocked_list.HasWriteBlockedDataStreams()); 107 EXPECT_TRUE(write_blocked_list.HasWriteBlockedDataStreams());
108 108
109 // There should only be one stream to pop off the front. 109 // There should only be one stream to pop off the front.
110 EXPECT_EQ(kBlockedId, write_blocked_list.PopFront()); 110 EXPECT_EQ(kBlockedId, write_blocked_list.PopFront());
111 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams()); 111 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams());
112 EXPECT_FALSE(write_blocked_list.HasWriteBlockedDataStreams()); 112 EXPECT_FALSE(write_blocked_list.HasWriteBlockedDataStreams());
113 } 113 }
114 114
115 } // namespace 115 } // namespace
116 } // namespace test 116 } // namespace test
117 } // namespace net 117 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_write_blocked_list.cc ('k') | net/spdy/write_blocked_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698