file_manager: Fix a bug where hosted documents could not be opened without active...
[chromium-blink-merge.git] / net / spdy / write_blocked_list_test.cc
blob3bb49df94f49771a398bea6db7633106a886fc7c
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_EQ(-1, list.GetHighestPriorityWriteBlockedList());
19 list.PushBack(1, 1);
20 EXPECT_EQ(1, list.GetHighestPriorityWriteBlockedList());
21 list.PushBack(1, 0);
22 EXPECT_EQ(0, list.GetHighestPriorityWriteBlockedList());
25 TEST(WriteBlockedListTest, HasWriteBlockedStreamsOfGreaterThanPriority) {
26 IntWriteBlockedList list;
27 list.PushBack(1, 4);
28 EXPECT_TRUE(list.HasWriteBlockedStreamsGreaterThanPriority(5));
29 EXPECT_FALSE(list.HasWriteBlockedStreamsGreaterThanPriority(4));
30 list.PushBack(1, 2);
31 EXPECT_TRUE(list.HasWriteBlockedStreamsGreaterThanPriority(3));
32 EXPECT_FALSE(list.HasWriteBlockedStreamsGreaterThanPriority(2));
35 TEST(WriteBlockedListTest, RemoveStreamFromWriteBlockedList) {
36 IntWriteBlockedList list;
38 list.PushBack(1, 4);
39 EXPECT_TRUE(list.HasWriteBlockedStreams());
41 list.RemoveStreamFromWriteBlockedList(1, 5);
42 EXPECT_TRUE(list.HasWriteBlockedStreams());
44 list.PushBack(2, 4);
45 list.PushBack(1, 4);
46 list.RemoveStreamFromWriteBlockedList(1, 4);
47 list.RemoveStreamFromWriteBlockedList(2, 4);
48 EXPECT_FALSE(list.HasWriteBlockedStreams());
50 list.PushBack(1, 7);
51 EXPECT_TRUE(list.HasWriteBlockedStreams());
54 TEST(WriteBlockedListTest, PopFront) {
55 IntWriteBlockedList list;
57 list.PushBack(1, 4);
58 EXPECT_EQ(1, list.NumBlockedStreams());
59 list.PushBack(2, 4);
60 list.PushBack(1, 4);
61 list.PushBack(3, 4);
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));
71 } // namespace
72 } // namespace test
73 } // namespace net