Rewrite AndroidSyncSettings to be significantly simpler.
[chromium-blink-merge.git] / net / http / http_stream_factory_impl_request_unittest.cc
blob32900f93e789765da47f0b85ec2e88c6e1131767
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(
20 NextProto,
21 HttpStreamFactoryImplRequestTest,
22 testing::Values(kProtoSPDY31, kProtoSPDY4_14, kProtoSPDY4_15));
24 namespace {
26 class DoNothingRequestDelegate : public HttpStreamRequest::Delegate {
27 public:
28 DoNothingRequestDelegate() {}
30 ~DoNothingRequestDelegate() override {}
32 // HttpStreamRequest::Delegate
33 void OnStreamReady(const SSLConfig& used_ssl_config,
34 const ProxyInfo& used_proxy_info,
35 HttpStream* stream) override {}
36 void OnWebSocketHandshakeStreamReady(
37 const SSLConfig& used_ssl_config,
38 const ProxyInfo& used_proxy_info,
39 WebSocketHandshakeStreamBase* stream) override {}
40 void OnStreamFailed(int status, const SSLConfig& used_ssl_config) override {}
41 void OnCertificateError(int status,
42 const SSLConfig& used_ssl_config,
43 const SSLInfo& ssl_info) override {}
44 void OnNeedsProxyAuth(const HttpResponseInfo& proxy_response,
45 const SSLConfig& used_ssl_config,
46 const ProxyInfo& used_proxy_info,
47 HttpAuthController* auth_controller) override {}
48 void OnNeedsClientAuth(const SSLConfig& used_ssl_config,
49 SSLCertRequestInfo* cert_info) override {}
50 void OnHttpsProxyTunnelResponse(const HttpResponseInfo& response_info,
51 const SSLConfig& used_ssl_config,
52 const ProxyInfo& used_proxy_info,
53 HttpStream* stream) override {}
56 } // namespace
58 // Make sure that Request passes on its priority updates to its jobs.
59 TEST_P(HttpStreamFactoryImplRequestTest, SetPriority) {
60 SpdySessionDependencies session_deps(GetParam(),
61 ProxyService::CreateDirect());
63 scoped_refptr<HttpNetworkSession>
64 session(SpdySessionDependencies::SpdyCreateSession(&session_deps));
65 HttpStreamFactoryImpl* factory =
66 static_cast<HttpStreamFactoryImpl*>(session->http_stream_factory());
68 DoNothingRequestDelegate request_delegate;
69 HttpStreamFactoryImpl::Request request(
70 GURL(), factory, &request_delegate, NULL, BoundNetLog());
72 HttpStreamFactoryImpl::Job* job =
73 new HttpStreamFactoryImpl::Job(factory,
74 session.get(),
75 HttpRequestInfo(),
76 DEFAULT_PRIORITY,
77 SSLConfig(),
78 SSLConfig(),
79 NULL);
80 request.AttachJob(job);
81 EXPECT_EQ(DEFAULT_PRIORITY, job->priority());
83 request.SetPriority(MEDIUM);
84 EXPECT_EQ(MEDIUM, job->priority());
86 // Make |job| the bound job.
87 request.OnStreamFailed(job, ERR_FAILED, SSLConfig());
89 request.SetPriority(IDLE);
90 EXPECT_EQ(IDLE, job->priority());
93 } // namespace net