Index: net/base/network_stream_throttler_unittest.cc |
diff --git a/net/base/network_stream_throttler_unittest.cc b/net/base/network_stream_throttler_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e97ff4b0774d9e276b946dedb13c698c1cf87469 |
--- /dev/null |
+++ b/net/base/network_stream_throttler_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_stream_throttler.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 NetworkStreamThrottlerTest : public testing::Test, |
+ NetworkStreamThrottler::Delegate { |
+ public: |
+ NetworkStreamThrottlerTest() |
+ : throttler_(NetworkStreamThrottler::CreateThrottler()) {} |
+ |
+ protected: |
+ std::unique_ptr<NetworkStreamThrottler::Throttle> CreateThrottle( |
+ net::RequestPriority priority, |
+ bool expected_throttle_state) { |
+ std::unique_ptr<NetworkStreamThrottler::Throttle> throttle( |
+ throttler_->CreateThrottle(this, priority, false)); |
+ EXPECT_EQ(expected_throttle_state, throttle->IsThrottled()); |
+ return throttle; |
+ } |
+ |
+ private: |
+ // NetworkStreamThrottler::Delegate |
+ void OnThrottleStateChanged() override { ADD_FAILURE(); } |
+ |
+ std::unique_ptr<NetworkStreamThrottler> throttler_; |
+}; |
+ |
+// Check to confirm that all created throttles start unthrottled for the |
+// current null implementation. |
+TEST_F(NetworkStreamThrottlerTest, AllUnthrottled) { |
+ for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; ++i) { |
+ CreateThrottle(static_cast<RequestPriority>(i), false); |
+ } |
+} |
+ |
+} // namespace |
+ |
+} // namespace net |