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

Side by Side Diff: net/base/network_stream_throttler_unittest.cc

Issue 1901533002: Implementation of network level throttler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporated latest round of comments." . Created 4 years, 7 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 unified diff | Download patch
OLDNEW
(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_stream_throttler.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 NetworkStreamThrottlerTest : public testing::Test,
19 NetworkStreamThrottler::Delegate {
20 public:
21 NetworkStreamThrottlerTest()
22 : throttler_(NetworkStreamThrottler::CreateThrottler()) {}
23
24 protected:
25 std::unique_ptr<NetworkStreamThrottler::Throttle> CreateThrottle(
26 net::RequestPriority priority,
27 bool expected_throttle_state) {
28 std::unique_ptr<NetworkStreamThrottler::Throttle> throttle(
29 throttler_->CreateThrottle(this, priority, false));
30 EXPECT_EQ(expected_throttle_state, throttle->IsThrottled());
31 return throttle;
32 }
33
34 private:
35 // NetworkStreamThrottler::Delegate
36 void OnThrottleStateChanged() override { ADD_FAILURE(); }
37
38 std::unique_ptr<NetworkStreamThrottler> throttler_;
39 };
40
41 // Check to confirm that all created throttles start unthrottled for the
42 // current null implementation.
43 TEST_F(NetworkStreamThrottlerTest, 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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698