OLD | NEW |
| (Empty) |
1 // Copyright 2016 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. | |
4 | |
5 #include "net/base/network_throttle_manager.h" | |
6 | |
7 #include <memory> | |
8 | |
9 #include "net/base/request_priority.h" | |
10 #include "testing/gtest/include/gtest/gtest.h" | |
11 | |
12 namespace net { | |
13 | |
14 namespace { | |
15 | |
16 #include "testing/gtest/include/gtest/gtest.h" | |
17 | |
18 class NetworkThrottleManagerTest : public testing::Test, | |
19 NetworkThrottleManager::ThrottleDelegate { | |
20 public: | |
21 NetworkThrottleManagerTest() | |
22 : throttler_(NetworkThrottleManager::CreateThrottler()) {} | |
23 | |
24 protected: | |
25 std::unique_ptr<NetworkThrottleManager::Throttle> CreateThrottle( | |
26 net::RequestPriority priority, | |
27 bool expected_throttle_state) { | |
28 std::unique_ptr<NetworkThrottleManager::Throttle> throttle( | |
29 throttler_->CreateThrottle(this, priority, false)); | |
30 EXPECT_EQ(expected_throttle_state, throttle->IsThrottled()); | |
31 return throttle; | |
32 } | |
33 | |
34 private: | |
35 // NetworkThrottleManager::Delegate | |
36 void OnThrottleStateChanged() override { ADD_FAILURE(); } | |
37 | |
38 std::unique_ptr<NetworkThrottleManager> throttler_; | |
39 }; | |
40 | |
41 // Check to confirm that all created throttles start unthrottled for the | |
42 // current null implementation. | |
43 TEST_F(NetworkThrottleManagerTest, AllUnthrottled) { | |
44 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; ++i) { | |
45 CreateThrottle(static_cast<RequestPriority>(i), false); | |
46 } | |
47 } | |
48 | |
49 } // namespace | |
50 | |
51 } // namespace net | |
OLD | NEW |