| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/spdy_priority_tree.h" | 5 #include "net/spdy/spdy_priority_tree.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | |
| 8 #include "testing/gmock/include/gmock/gmock.h" | 7 #include "testing/gmock/include/gmock/gmock.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 9 |
| 11 namespace net { | 10 namespace net { |
| 12 | 11 |
| 13 using ::testing::ElementsAre; | 12 using ::testing::ElementsAre; |
| 14 using ::testing::IsEmpty; | 13 using ::testing::IsEmpty; |
| 15 using ::testing::UnorderedElementsAre; | 14 using ::testing::UnorderedElementsAre; |
| 16 | 15 |
| 17 namespace test { | 16 namespace test { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 37 bool ValidateInvariants() const { | 36 bool ValidateInvariants() const { |
| 38 return tree_->ValidateInvariantsForTests(); | 37 return tree_->ValidateInvariantsForTests(); |
| 39 } | 38 } |
| 40 | 39 |
| 41 private: | 40 private: |
| 42 SpdyPriorityTree<NodeId>* tree_; | 41 SpdyPriorityTree<NodeId>* tree_; |
| 43 }; | 42 }; |
| 44 | 43 |
| 45 class SpdyPriorityTreeTest : public ::testing::Test { | 44 class SpdyPriorityTreeTest : public ::testing::Test { |
| 46 protected: | 45 protected: |
| 47 typedef uint32 SpdyStreamId; | 46 typedef uint32_t SpdyStreamId; |
| 48 typedef std::pair<SpdyStreamId, float> PriorityNode; | 47 typedef std::pair<SpdyStreamId, float> PriorityNode; |
| 49 typedef std::vector<PriorityNode> PriorityList; | 48 typedef std::vector<PriorityNode> PriorityList; |
| 50 | 49 |
| 51 SpdyPriorityTreeTest() : peer(&tree) {} | 50 SpdyPriorityTreeTest() : peer(&tree) {} |
| 52 | 51 |
| 53 SpdyPriorityTree<SpdyStreamId> tree; | 52 SpdyPriorityTree<SpdyStreamId> tree; |
| 54 SpdyPriorityTreePeer<SpdyStreamId> peer; | 53 SpdyPriorityTreePeer<SpdyStreamId> peer; |
| 55 }; | 54 }; |
| 56 | 55 |
| 57 TEST_F(SpdyPriorityTreeTest, AddAndRemoveNodes) { | 56 TEST_F(SpdyPriorityTreeTest, AddAndRemoveNodes) { |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 EXPECT_EQ(3, tree.GetWeight(4)); | 598 EXPECT_EQ(3, tree.GetWeight(4)); |
| 600 EXPECT_EQ(3, tree.GetWeight(5)); | 599 EXPECT_EQ(3, tree.GetWeight(5)); |
| 601 // 2.5 rounded up = 3. | 600 // 2.5 rounded up = 3. |
| 602 EXPECT_EQ(3, tree.GetWeight(6)); | 601 EXPECT_EQ(3, tree.GetWeight(6)); |
| 603 EXPECT_EQ(3, tree.GetWeight(7)); | 602 EXPECT_EQ(3, tree.GetWeight(7)); |
| 604 // 0 is not a valid weight, so round up to 1. | 603 // 0 is not a valid weight, so round up to 1. |
| 605 EXPECT_EQ(1, tree.GetWeight(8)); | 604 EXPECT_EQ(1, tree.GetWeight(8)); |
| 606 } | 605 } |
| 607 } // namespace test | 606 } // namespace test |
| 608 } // namespace gfe_spdy | 607 } // namespace gfe_spdy |
| OLD | NEW |