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_EQ(-1, list
.GetHighestPriorityWriteBlockedList());
20 EXPECT_EQ(1, list
.GetHighestPriorityWriteBlockedList());
22 EXPECT_EQ(0, list
.GetHighestPriorityWriteBlockedList());
25 TEST(WriteBlockedListTest
, HasWriteBlockedStreamsOfGreaterThanPriority
) {
26 IntWriteBlockedList list
;
28 EXPECT_TRUE(list
.HasWriteBlockedStreamsGreaterThanPriority(5));
29 EXPECT_FALSE(list
.HasWriteBlockedStreamsGreaterThanPriority(4));
31 EXPECT_TRUE(list
.HasWriteBlockedStreamsGreaterThanPriority(3));
32 EXPECT_FALSE(list
.HasWriteBlockedStreamsGreaterThanPriority(2));
35 TEST(WriteBlockedListTest
, RemoveStreamFromWriteBlockedList
) {
36 IntWriteBlockedList list
;
39 EXPECT_TRUE(list
.HasWriteBlockedStreams());
41 list
.RemoveStreamFromWriteBlockedList(1, 5);
42 EXPECT_TRUE(list
.HasWriteBlockedStreams());
46 list
.RemoveStreamFromWriteBlockedList(1, 4);
47 list
.RemoveStreamFromWriteBlockedList(2, 4);
48 EXPECT_FALSE(list
.HasWriteBlockedStreams());
51 EXPECT_TRUE(list
.HasWriteBlockedStreams());
54 TEST(WriteBlockedListTest
, PopFront
) {
55 IntWriteBlockedList list
;
58 EXPECT_EQ(1, list
.NumBlockedStreams());
62 EXPECT_EQ(4, list
.NumBlockedStreams());
64 EXPECT_EQ(1, list
.PopFront(4));
65 EXPECT_EQ(2, list
.PopFront(4));
66 EXPECT_EQ(1, list
.PopFront(4));
67 EXPECT_EQ(1, list
.NumBlockedStreams());
68 EXPECT_EQ(3, list
.PopFront(4));