Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Unified Diff: net/base/network_throttle_manager_unittest.cc

Issue 1901533002: Implementation of network level throttler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Destroy transaction before session in QuicUploadWriteError. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/network_throttle_manager.cc ('k') | net/http/http_network_session.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « net/base/network_throttle_manager.cc ('k') | net/http/http_network_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698