Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / net / http / http_stream_factory_impl_request_unittest.cc
blob0e31c1ec05cf4484143bdda5fe8a7822d3b0e956
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 "net/ssl/ssl_failure_state.h"
12 #include "testing/gtest/include/gtest/gtest.h"
14 namespace net {
16 class HttpStreamFactoryImplRequestTest
17 : public ::testing::Test,
18 public ::testing::WithParamInterface<NextProto> {};
20 INSTANTIATE_TEST_CASE_P(NextProto,
21 HttpStreamFactoryImplRequestTest,
22 testing::Values(kProtoSPDY31,
23 kProtoHTTP2_14,
24 kProtoHTTP2));
26 namespace {
28 class DoNothingRequestDelegate : public HttpStreamRequest::Delegate {
29 public:
30 DoNothingRequestDelegate() {}
32 ~DoNothingRequestDelegate() override {}
34 // HttpStreamRequest::Delegate
35 void OnStreamReady(const SSLConfig& used_ssl_config,
36 const ProxyInfo& used_proxy_info,
37 HttpStream* stream) override {}
38 void OnWebSocketHandshakeStreamReady(
39 const SSLConfig& used_ssl_config,
40 const ProxyInfo& used_proxy_info,
41 WebSocketHandshakeStreamBase* stream) override {}
42 void OnStreamFailed(int status,
43 const SSLConfig& used_ssl_config,
44 SSLFailureState ssl_failure_state) override {}
45 void OnCertificateError(int status,
46 const SSLConfig& used_ssl_config,
47 const SSLInfo& ssl_info) override {}
48 void OnNeedsProxyAuth(const HttpResponseInfo& proxy_response,
49 const SSLConfig& used_ssl_config,
50 const ProxyInfo& used_proxy_info,
51 HttpAuthController* auth_controller) override {}
52 void OnNeedsClientAuth(const SSLConfig& used_ssl_config,
53 SSLCertRequestInfo* cert_info) override {}
54 void OnHttpsProxyTunnelResponse(const HttpResponseInfo& response_info,
55 const SSLConfig& used_ssl_config,
56 const ProxyInfo& used_proxy_info,
57 HttpStream* stream) override {}
60 } // namespace
62 // Make sure that Request passes on its priority updates to its jobs.
63 TEST_P(HttpStreamFactoryImplRequestTest, SetPriority) {
64 SpdySessionDependencies session_deps(GetParam(),
65 ProxyService::CreateDirect());
67 scoped_refptr<HttpNetworkSession>
68 session(SpdySessionDependencies::SpdyCreateSession(&session_deps));
69 HttpStreamFactoryImpl* factory =
70 static_cast<HttpStreamFactoryImpl*>(session->http_stream_factory());
72 DoNothingRequestDelegate request_delegate;
73 HttpStreamFactoryImpl::Request request(
74 GURL(), factory, &request_delegate, NULL, BoundNetLog());
76 HttpStreamFactoryImpl::Job* job =
77 new HttpStreamFactoryImpl::Job(factory,
78 session.get(),
79 HttpRequestInfo(),
80 DEFAULT_PRIORITY,
81 SSLConfig(),
82 SSLConfig(),
83 NULL);
84 request.AttachJob(job);
85 EXPECT_EQ(DEFAULT_PRIORITY, job->priority());
87 request.SetPriority(MEDIUM);
88 EXPECT_EQ(MEDIUM, job->priority());
90 // Make |job| the bound job.
91 request.OnStreamFailed(job, ERR_FAILED, SSLConfig(), SSL_FAILURE_NONE);
93 request.SetPriority(IDLE);
94 EXPECT_EQ(IDLE, job->priority());
97 } // namespace net