OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/base/test_completion_callback.h" | 5 #include "net/base/test_completion_callback.h" |
| 6 #include "net/flip/flip_io_buffer.h" |
| 7 #include "net/flip/flip_session.h" |
6 #include "net/socket/socket_test_util.h" | 8 #include "net/socket/socket_test_util.h" |
7 #include "testing/platform_test.h" | 9 #include "testing/platform_test.h" |
8 | 10 |
9 #include "net/flip/flip_session.h" | |
10 | |
11 namespace net { | 11 namespace net { |
12 | 12 |
13 class FlipSessionTest : public PlatformTest { | 13 class FlipSessionTest : public PlatformTest { |
14 public: | 14 public: |
15 }; | 15 }; |
16 | 16 |
17 // Test the PrioritizedIOBuffer class. | 17 // Test the FlipIOBuffer class. |
18 TEST_F(FlipSessionTest, PrioritizedIOBuffer) { | 18 TEST_F(FlipSessionTest, FlipIOBuffer) { |
19 std::priority_queue<PrioritizedIOBuffer> queue_; | 19 std::priority_queue<FlipIOBuffer> queue_; |
20 const size_t kQueueSize = 100; | 20 const size_t kQueueSize = 100; |
21 | 21 |
22 // Insert 100 items; pri 100 to 1. | 22 // Insert 100 items; pri 100 to 1. |
23 for (size_t index = 0; index < kQueueSize; ++index) { | 23 for (size_t index = 0; index < kQueueSize; ++index) { |
24 PrioritizedIOBuffer buffer(NULL, kQueueSize - index); | 24 FlipIOBuffer buffer(NULL, kQueueSize - index, NULL); |
25 queue_.push(buffer); | 25 queue_.push(buffer); |
26 } | 26 } |
27 | 27 |
28 // Insert several priority 0 items last. | 28 // Insert several priority 0 items last. |
29 const size_t kNumDuplicates = 12; | 29 const size_t kNumDuplicates = 12; |
30 IOBufferWithSize* buffers[kNumDuplicates]; | 30 IOBufferWithSize* buffers[kNumDuplicates]; |
31 for (size_t index = 0; index < kNumDuplicates; ++index) { | 31 for (size_t index = 0; index < kNumDuplicates; ++index) { |
32 buffers[index] = new IOBufferWithSize(index+1); | 32 buffers[index] = new IOBufferWithSize(index+1); |
33 queue_.push(PrioritizedIOBuffer(buffers[index], 0)); | 33 queue_.push(FlipIOBuffer(buffers[index], 0, NULL)); |
34 } | 34 } |
35 | 35 |
36 EXPECT_EQ(kQueueSize + kNumDuplicates, queue_.size()); | 36 EXPECT_EQ(kQueueSize + kNumDuplicates, queue_.size()); |
37 | 37 |
38 // Verify the P0 items come out in FIFO order. | 38 // Verify the P0 items come out in FIFO order. |
39 for (size_t index = 0; index < kNumDuplicates; ++index) { | 39 for (size_t index = 0; index < kNumDuplicates; ++index) { |
40 PrioritizedIOBuffer buffer = queue_.top(); | 40 FlipIOBuffer buffer = queue_.top(); |
41 EXPECT_EQ(0, buffer.priority()); | 41 EXPECT_EQ(0, buffer.priority()); |
42 EXPECT_EQ(index + 1, buffer.size()); | 42 EXPECT_EQ(index + 1, buffer.size()); |
43 queue_.pop(); | 43 queue_.pop(); |
44 } | 44 } |
45 | 45 |
46 int priority = 1; | 46 int priority = 1; |
47 while (queue_.size()) { | 47 while (queue_.size()) { |
48 PrioritizedIOBuffer buffer = queue_.top(); | 48 FlipIOBuffer buffer = queue_.top(); |
49 EXPECT_EQ(priority++, buffer.priority()); | 49 EXPECT_EQ(priority++, buffer.priority()); |
50 queue_.pop(); | 50 queue_.pop(); |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 } // namespace net | 54 } // namespace net |
55 | 55 |
OLD | NEW |