Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / net / http / http_stream_factory_impl_request_unittest.cc
blobc4173eaddd1ecc7d09f18cb3ca4170b361fd3893
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));
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,
42 const SSLConfig& used_ssl_config,
43 SSLFailureState ssl_failure_state) override {}
44 void OnCertificateError(int status,
45 const SSLConfig& used_ssl_config,
46 const SSLInfo& ssl_info) override {}
47 void OnNeedsProxyAuth(const HttpResponseInfo& proxy_response,
48 const SSLConfig& used_ssl_config,
49 const ProxyInfo& used_proxy_info,
50 HttpAuthController* auth_controller) override {}
51 void OnNeedsClientAuth(const SSLConfig& used_ssl_config,
52 SSLCertRequestInfo* cert_info) override {}
53 void OnHttpsProxyTunnelResponse(const HttpResponseInfo& response_info,
54 const SSLConfig& used_ssl_config,
55 const ProxyInfo& used_proxy_info,
56 HttpStream* stream) override {}
59 } // namespace
61 // Make sure that Request passes on its priority updates to its jobs.
62 TEST_P(HttpStreamFactoryImplRequestTest, SetPriority) {
63 SpdySessionDependencies session_deps(GetParam(),
64 ProxyService::CreateDirect());
66 scoped_refptr<HttpNetworkSession>
67 session(SpdySessionDependencies::SpdyCreateSession(&session_deps));
68 HttpStreamFactoryImpl* factory =
69 static_cast<HttpStreamFactoryImpl*>(session->http_stream_factory());
71 DoNothingRequestDelegate request_delegate;
72 HttpStreamFactoryImpl::Request request(
73 GURL(), factory, &request_delegate, NULL, BoundNetLog());
75 HttpStreamFactoryImpl::Job* job =
76 new HttpStreamFactoryImpl::Job(factory,
77 session.get(),
78 HttpRequestInfo(),
79 DEFAULT_PRIORITY,
80 SSLConfig(),
81 SSLConfig(),
82 NULL);
83 request.AttachJob(job);
84 EXPECT_EQ(DEFAULT_PRIORITY, job->priority());
86 request.SetPriority(MEDIUM);
87 EXPECT_EQ(MEDIUM, job->priority());
89 // Make |job| the bound job.
90 request.OnStreamFailed(job, ERR_FAILED, SSLConfig(), SSL_FAILURE_NONE);
92 request.SetPriority(IDLE);
93 EXPECT_EQ(IDLE, job->priority());
96 } // namespace net