1 // Copyright 2015 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_response_info.h"
7 #include "base/pickle.h"
8 #include "net/http/http_response_headers.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 class HttpResponseInfoTest
: public testing::Test
{
13 void SetUp() override
{
14 response_info_
.headers
= new net::HttpResponseHeaders("");
17 void PickleAndRestore(const net::HttpResponseInfo
& response_info
,
18 net::HttpResponseInfo
* restored_response_info
) const {
20 response_info
.Persist(&pickle
, false, false);
21 bool truncated
= false;
22 restored_response_info
->InitFromPickle(pickle
, &truncated
);
25 net::HttpResponseInfo response_info_
;
28 TEST_F(HttpResponseInfoTest
, UnusedSincePrefetchDefault
) {
29 EXPECT_FALSE(response_info_
.unused_since_prefetch
);
32 TEST_F(HttpResponseInfoTest
, UnusedSincePrefetchCopy
) {
33 response_info_
.unused_since_prefetch
= true;
34 net::HttpResponseInfo
response_info_clone(response_info_
);
35 EXPECT_TRUE(response_info_clone
.unused_since_prefetch
);
38 TEST_F(HttpResponseInfoTest
, UnusedSincePrefetchPersistFalse
) {
39 net::HttpResponseInfo restored_response_info
;
40 PickleAndRestore(response_info_
, &restored_response_info
);
41 EXPECT_FALSE(restored_response_info
.unused_since_prefetch
);
44 TEST_F(HttpResponseInfoTest
, UnusedSincePrefetchPersistTrue
) {
45 response_info_
.unused_since_prefetch
= true;
46 net::HttpResponseInfo restored_response_info
;
47 PickleAndRestore(response_info_
, &restored_response_info
);
48 EXPECT_TRUE(restored_response_info
.unused_since_prefetch
);