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
3 // found in the LICENSE file.
5 #include "net/spdy/write_blocked_list.h"
7 #include "testing/gtest/include/gtest/gtest.h"
14 typedef WriteBlockedList
<int> IntWriteBlockedList
;
16 TEST(WriteBlockedListTest
, GetHighestPriority
) {
17 IntWriteBlockedList list
;
18 EXPECT_FALSE(list
.HasWriteBlockedStreams());
20 EXPECT_TRUE(list
.HasWriteBlockedStreams());
21 EXPECT_EQ(1, list
.GetHighestPriorityWriteBlockedList());
23 EXPECT_TRUE(list
.HasWriteBlockedStreams());
24 EXPECT_EQ(0, list
.GetHighestPriorityWriteBlockedList());
27 TEST(WriteBlockedListTest
, HasWriteBlockedStreamsOfGreaterThanPriority
) {
28 IntWriteBlockedList list
;
30 EXPECT_TRUE(list
.HasWriteBlockedStreamsGreaterThanPriority(5));
31 EXPECT_FALSE(list
.HasWriteBlockedStreamsGreaterThanPriority(4));
33 EXPECT_TRUE(list
.HasWriteBlockedStreamsGreaterThanPriority(3));
34 EXPECT_FALSE(list
.HasWriteBlockedStreamsGreaterThanPriority(2));
37 TEST(WriteBlockedListTest
, RemoveStreamFromWriteBlockedList
) {
38 IntWriteBlockedList list
;
41 EXPECT_TRUE(list
.HasWriteBlockedStreams());
43 list
.RemoveStreamFromWriteBlockedList(1, 5);
44 EXPECT_TRUE(list
.HasWriteBlockedStreams());
48 list
.RemoveStreamFromWriteBlockedList(1, 4);
49 list
.RemoveStreamFromWriteBlockedList(2, 4);
50 EXPECT_FALSE(list
.HasWriteBlockedStreams());
53 EXPECT_TRUE(list
.HasWriteBlockedStreams());
56 TEST(WriteBlockedListTest
, PopFront
) {
57 IntWriteBlockedList list
;
60 EXPECT_EQ(1u, list
.NumBlockedStreams());
64 EXPECT_EQ(4u, list
.NumBlockedStreams());
66 EXPECT_EQ(1, list
.PopFront(4));
67 EXPECT_EQ(2, list
.PopFront(4));
68 EXPECT_EQ(1, list
.PopFront(4));
69 EXPECT_EQ(1u, list
.NumBlockedStreams());
70 EXPECT_EQ(3, list
.PopFront(4));