| Index: net/base/network_throttle_manager_unittest.cc
|
| diff --git a/net/base/network_throttle_manager_unittest.cc b/net/base/network_throttle_manager_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c39a7a894fd4a97a904e3fa70b624b44364555f5
|
| --- /dev/null
|
| +++ b/net/base/network_throttle_manager_unittest.cc
|
| @@ -0,0 +1,51 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "net/base/network_throttle_manager.h"
|
| +
|
| +#include <memory>
|
| +
|
| +#include "net/base/request_priority.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace net {
|
| +
|
| +namespace {
|
| +
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +class NetworkThrottleManagerTest : public testing::Test,
|
| + NetworkThrottleManager::ThrottleDelegate {
|
| + public:
|
| + NetworkThrottleManagerTest()
|
| + : throttler_(NetworkThrottleManager::CreateThrottler()) {}
|
| +
|
| + protected:
|
| + std::unique_ptr<NetworkThrottleManager::Throttle> CreateThrottle(
|
| + net::RequestPriority priority,
|
| + bool expected_throttle_state) {
|
| + std::unique_ptr<NetworkThrottleManager::Throttle> throttle(
|
| + throttler_->CreateThrottle(this, priority, false));
|
| + EXPECT_EQ(expected_throttle_state, throttle->IsThrottled());
|
| + return throttle;
|
| + }
|
| +
|
| + private:
|
| + // NetworkThrottleManager::Delegate
|
| + void OnThrottleStateChanged() override { ADD_FAILURE(); }
|
| +
|
| + std::unique_ptr<NetworkThrottleManager> throttler_;
|
| +};
|
| +
|
| +// Check to confirm that all created throttles start unthrottled for the
|
| +// current null implementation.
|
| +TEST_F(NetworkThrottleManagerTest, AllUnthrottled) {
|
| + for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; ++i) {
|
| + CreateThrottle(static_cast<RequestPriority>(i), false);
|
| + }
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +} // namespace net
|
|
|