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

Side by Side Diff: net/spdy/write_blocked_list_test.cc

Issue 822713002: Update from https://crrev.com/309415 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 12 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/write_blocked_list.h" 5 #include "net/spdy/write_blocked_list.h"
6 6
7 #include <deque>
8
7 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
8 10
11 namespace {
12
13 class WriteBlockedListPeer {
14 public:
15 static std::deque<int>* GetWriteBlockedList(
16 int i,
17 net::WriteBlockedList<int>* list) {
18 return &list->write_blocked_lists_[i];
19 }
20 };
21
22 } // namespace
9 23
10 namespace net { 24 namespace net {
11 namespace test { 25 namespace test {
12 namespace { 26 namespace {
13
14 typedef WriteBlockedList<int> IntWriteBlockedList; 27 typedef WriteBlockedList<int> IntWriteBlockedList;
15 28
16 TEST(WriteBlockedListTest, GetHighestPriority) { 29 TEST(WriteBlockedListTest, GetHighestPriority) {
17 IntWriteBlockedList list; 30 IntWriteBlockedList list;
18 EXPECT_FALSE(list.HasWriteBlockedStreams()); 31 EXPECT_FALSE(list.HasWriteBlockedStreams());
19 list.PushBack(1, 1); 32 list.PushBack(1, 1);
20 EXPECT_TRUE(list.HasWriteBlockedStreams()); 33 EXPECT_TRUE(list.HasWriteBlockedStreams());
21 EXPECT_EQ(1, list.GetHighestPriorityWriteBlockedList()); 34 EXPECT_EQ(1, list.GetHighestPriorityWriteBlockedList());
22 list.PushBack(1, 0); 35 list.PushBack(1, 0);
23 EXPECT_TRUE(list.HasWriteBlockedStreams()); 36 EXPECT_TRUE(list.HasWriteBlockedStreams());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 list.PushBack(3, 4); 76 list.PushBack(3, 4);
64 EXPECT_EQ(4u, list.NumBlockedStreams()); 77 EXPECT_EQ(4u, list.NumBlockedStreams());
65 78
66 EXPECT_EQ(1, list.PopFront(4)); 79 EXPECT_EQ(1, list.PopFront(4));
67 EXPECT_EQ(2, list.PopFront(4)); 80 EXPECT_EQ(2, list.PopFront(4));
68 EXPECT_EQ(1, list.PopFront(4)); 81 EXPECT_EQ(1, list.PopFront(4));
69 EXPECT_EQ(1u, list.NumBlockedStreams()); 82 EXPECT_EQ(1u, list.NumBlockedStreams());
70 EXPECT_EQ(3, list.PopFront(4)); 83 EXPECT_EQ(3, list.PopFront(4));
71 } 84 }
72 85
86 TEST(WriteBlockedListTest, UpdateStreamPriorityInWriteBlockedList) {
87 IntWriteBlockedList list;
88
89 list.PushBack(1, 1);
90 list.PushBack(2, 2);
91 list.PushBack(3, 3);
92 list.PushBack(1, 3);
93 list.PushBack(1, 3);
94 EXPECT_EQ(5u, list.NumBlockedStreams());
95 EXPECT_EQ(1u, WriteBlockedListPeer::GetWriteBlockedList(1, &list)->size());
96 EXPECT_EQ(1u, WriteBlockedListPeer::GetWriteBlockedList(2, &list)->size());
97 EXPECT_EQ(3u, WriteBlockedListPeer::GetWriteBlockedList(3, &list)->size());
98
99 list.UpdateStreamPriorityInWriteBlockedList(1, 1, 2);
100 EXPECT_EQ(0u, WriteBlockedListPeer::GetWriteBlockedList(1, &list)->size());
101 EXPECT_EQ(2u, WriteBlockedListPeer::GetWriteBlockedList(2, &list)->size());
102 list.UpdateStreamPriorityInWriteBlockedList(3, 3, 1);
103 EXPECT_EQ(1u, WriteBlockedListPeer::GetWriteBlockedList(1, &list)->size());
104 EXPECT_EQ(2u, WriteBlockedListPeer::GetWriteBlockedList(3, &list)->size());
105
106 // Redundant update.
107 list.UpdateStreamPriorityInWriteBlockedList(1, 3, 3);
108 EXPECT_EQ(2u, WriteBlockedListPeer::GetWriteBlockedList(3, &list)->size());
109
110 // No entries for given stream_id / old_priority pair.
111 list.UpdateStreamPriorityInWriteBlockedList(4, 4, 1);
112 EXPECT_EQ(1u, WriteBlockedListPeer::GetWriteBlockedList(1, &list)->size());
113 EXPECT_EQ(2u, WriteBlockedListPeer::GetWriteBlockedList(2, &list)->size());
114 EXPECT_EQ(0u, WriteBlockedListPeer::GetWriteBlockedList(4, &list)->size());
115
116 // Update multiple entries.
117 list.UpdateStreamPriorityInWriteBlockedList(1, 3, 4);
118 EXPECT_EQ(0u, WriteBlockedListPeer::GetWriteBlockedList(3, &list)->size());
119 EXPECT_EQ(1u, WriteBlockedListPeer::GetWriteBlockedList(4, &list)->size());
120
121 EXPECT_EQ(3, list.PopFront(1));
122 EXPECT_EQ(2, list.PopFront(2));
123 EXPECT_EQ(1, list.PopFront(2));
124 EXPECT_EQ(1, list.PopFront(4));
125 EXPECT_EQ(0u, list.NumBlockedStreams());
126 }
127
73 } // namespace 128 } // namespace
74 } // namespace test 129 } // namespace test
75 } // namespace net 130 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698