Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / net / http / http_stream_factory_impl_request_unittest.cc
blobb7afbfedfdf338d0db8e3093a197cb43da906d75
1 // Copyright (c) 2013 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.
5 #include "net/http/http_stream_factory_impl_request.h"
7 #include "net/http/http_stream_factory_impl_job.h"
8 #include "net/proxy/proxy_info.h"
9 #include "net/proxy/proxy_service.h"
10 #include "net/spdy/spdy_test_util_common.h"
11 #include "testing/gtest/include/gtest/gtest.h"
13 namespace net {
15 class HttpStreamFactoryImplRequestTest
16 : public ::testing::Test,
17 public ::testing::WithParamInterface<NextProto> {};
19 INSTANTIATE_TEST_CASE_P(NextProto,
20 HttpStreamFactoryImplRequestTest,
21 testing::Values(kProtoSPDY31,
22 kProtoSPDY4_14,
23 kProtoSPDY4));
25 namespace {
27 class DoNothingRequestDelegate : public HttpStreamRequest::Delegate {
28 public:
29 DoNothingRequestDelegate() {}
31 ~DoNothingRequestDelegate() override {}
33 // HttpStreamRequest::Delegate
34 void OnStreamReady(const SSLConfig& used_ssl_config,
35 const ProxyInfo& used_proxy_info,
36 HttpStream* stream) override {}
37 void OnWebSocketHandshakeStreamReady(
38 const SSLConfig& used_ssl_config,
39 const ProxyInfo& used_proxy_info,
40 WebSocketHandshakeStreamBase* stream) override {}
41 void OnStreamFailed(int status, const SSLConfig& used_ssl_config) override {}
42 void OnCertificateError(int status,
43 const SSLConfig& used_ssl_config,
44 const SSLInfo& ssl_info) override {}
45 void OnNeedsProxyAuth(const HttpResponseInfo& proxy_response,
46 const SSLConfig& used_ssl_config,
47 const ProxyInfo& used_proxy_info,
48 HttpAuthController* auth_controller) override {}
49 void OnNeedsClientAuth(const SSLConfig& used_ssl_config,
50 SSLCertRequestInfo* cert_info) override {}
51 void OnHttpsProxyTunnelResponse(const HttpResponseInfo& response_info,
52 const SSLConfig& used_ssl_config,
53 const ProxyInfo& used_proxy_info,
54 HttpStream* stream) override {}
57 } // namespace
59 // Make sure that Request passes on its priority updates to its jobs.
60 TEST_P(HttpStreamFactoryImplRequestTest, SetPriority) {
61 SpdySessionDependencies session_deps(GetParam(),
62 ProxyService::CreateDirect());
64 scoped_refptr<HttpNetworkSession>
65 session(SpdySessionDependencies::SpdyCreateSession(&session_deps));
66 HttpStreamFactoryImpl* factory =
67 static_cast<HttpStreamFactoryImpl*>(session->http_stream_factory());
69 DoNothingRequestDelegate request_delegate;
70 HttpStreamFactoryImpl::Request request(
71 GURL(), factory, &request_delegate, NULL, BoundNetLog());
73 HttpStreamFactoryImpl::Job* job =
74 new HttpStreamFactoryImpl::Job(factory,
75 session.get(),
76 HttpRequestInfo(),
77 DEFAULT_PRIORITY,
78 SSLConfig(),
79 SSLConfig(),
80 NULL);
81 request.AttachJob(job);
82 EXPECT_EQ(DEFAULT_PRIORITY, job->priority());
84 request.SetPriority(MEDIUM);
85 EXPECT_EQ(MEDIUM, job->priority());
87 // Make |job| the bound job.
88 request.OnStreamFailed(job, ERR_FAILED, SSLConfig());
90 request.SetPriority(IDLE);
91 EXPECT_EQ(IDLE, job->priority());
94 } // namespace net