Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / net / spdy / write_blocked_list_test.cc
blob908f0a9e6edaa430b79de2e6ea6749f74e2000fa
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"
10 namespace net {
11 namespace test {
12 namespace {
14 typedef WriteBlockedList<int> IntWriteBlockedList;
16 TEST(WriteBlockedListTest, GetHighestPriority) {
17 IntWriteBlockedList list;
18 EXPECT_FALSE(list.HasWriteBlockedStreams());
19 list.PushBack(1, 1);
20 EXPECT_TRUE(list.HasWriteBlockedStreams());
21 EXPECT_EQ(1, list.GetHighestPriorityWriteBlockedList());
22 list.PushBack(1, 0);
23 EXPECT_TRUE(list.HasWriteBlockedStreams());
24 EXPECT_EQ(0, list.GetHighestPriorityWriteBlockedList());
27 TEST(WriteBlockedListTest, HasWriteBlockedStreamsOfGreaterThanPriority) {
28 IntWriteBlockedList list;
29 list.PushBack(1, 4);
30 EXPECT_TRUE(list.HasWriteBlockedStreamsGreaterThanPriority(5));
31 EXPECT_FALSE(list.HasWriteBlockedStreamsGreaterThanPriority(4));
32 list.PushBack(1, 2);
33 EXPECT_TRUE(list.HasWriteBlockedStreamsGreaterThanPriority(3));
34 EXPECT_FALSE(list.HasWriteBlockedStreamsGreaterThanPriority(2));
37 TEST(WriteBlockedListTest, RemoveStreamFromWriteBlockedList) {
38 IntWriteBlockedList list;
40 list.PushBack(1, 4);
41 EXPECT_TRUE(list.HasWriteBlockedStreams());
43 list.RemoveStreamFromWriteBlockedList(1, 5);
44 EXPECT_TRUE(list.HasWriteBlockedStreams());
46 list.PushBack(2, 4);
47 list.PushBack(1, 4);
48 list.RemoveStreamFromWriteBlockedList(1, 4);
49 list.RemoveStreamFromWriteBlockedList(2, 4);
50 EXPECT_FALSE(list.HasWriteBlockedStreams());
52 list.PushBack(1, 7);
53 EXPECT_TRUE(list.HasWriteBlockedStreams());
56 TEST(WriteBlockedListTest, PopFront) {
57 IntWriteBlockedList list;
59 list.PushBack(1, 4);
60 EXPECT_EQ(1u, list.NumBlockedStreams());
61 list.PushBack(2, 4);
62 list.PushBack(1, 4);
63 list.PushBack(3, 4);
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));
73 } // namespace
74 } // namespace test
75 } // namespace net