OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <sstream> | 5 #include <sstream> |
6 | 6 |
7 #include "chrome/renderer/net/predictor_queue.h" | 7 #include "chrome/renderer/net/predictor_queue.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 // Single threaded tests of DnsQueue functionality. | 10 // Single threaded tests of DnsQueue functionality. |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 class DnsQueueTest : public testing::Test { | 14 class DnsQueueTest : public testing::Test { |
15 }; | 15 }; |
16 | 16 |
17 // Define a helper class that does Push'es and Pop's of numbers. | 17 // Define a helper class that does Push'es and Pop's of numbers. |
18 // This makes it easy to test a LOT of reads, and keep the expected Pop | 18 // This makes it easy to test a LOT of reads, and keep the expected Pop |
19 // value in sync with the Push value. | 19 // value in sync with the Push value. |
20 class DnsQueueSequentialTester { | 20 class DnsQueueSequentialTester { |
21 public: | 21 public: |
22 DnsQueueSequentialTester(DnsQueue& buffer, int32 read_counter = 0, | 22 explicit DnsQueueSequentialTester(DnsQueue& buffer, int32 read_counter = 0, |
23 int32 write_counter = 0); | 23 int32 write_counter = 0); |
24 | 24 |
25 // Return of false means buffer was full, or would not take entry. | 25 // Return of false means buffer was full, or would not take entry. |
26 bool Push(void); // Push the string value of next number. | 26 bool Push(void); // Push the string value of next number. |
27 | 27 |
28 // Return of false means buffer returned wrong value. | 28 // Return of false means buffer returned wrong value. |
29 bool Pop(void); // Validate string value of next read. | 29 bool Pop(void); // Validate string value of next read. |
30 | 30 |
31 private: | 31 private: |
32 DnsQueue* buffer_; | 32 DnsQueue* buffer_; |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 } | 253 } |
254 | 254 |
255 // Read back the accumulated 3 extra blocks. | 255 // Read back the accumulated 3 extra blocks. |
256 EXPECT_TRUE(tester.Pop()); | 256 EXPECT_TRUE(tester.Pop()); |
257 EXPECT_TRUE(tester.Pop()); | 257 EXPECT_TRUE(tester.Pop()); |
258 EXPECT_TRUE(tester.Pop()); | 258 EXPECT_TRUE(tester.Pop()); |
259 EXPECT_FALSE(tester.Pop()); | 259 EXPECT_FALSE(tester.Pop()); |
260 } | 260 } |
261 | 261 |
262 }; // namespace | 262 }; // namespace |
OLD | NEW |