Roll src/third_party/WebKit eac3800:0237a66 (svn 202606:202607)
[chromium-blink-merge.git] / net / http / http_response_info_unittest.cc
blobd27fb1c8ff7cd7bc84cc5d4c6ada44a181e1771f
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 namespace net {
13 namespace {
15 class HttpResponseInfoTest : public testing::Test {
16 protected:
17 void SetUp() override {
18 response_info_.headers = new HttpResponseHeaders("");
21 void PickleAndRestore(const HttpResponseInfo& response_info,
22 HttpResponseInfo* restored_response_info) const {
23 base::Pickle pickle;
24 response_info.Persist(&pickle, false, false);
25 bool truncated = false;
26 restored_response_info->InitFromPickle(pickle, &truncated);
29 HttpResponseInfo response_info_;
32 TEST_F(HttpResponseInfoTest, UnusedSincePrefetchDefault) {
33 EXPECT_FALSE(response_info_.unused_since_prefetch);
36 TEST_F(HttpResponseInfoTest, UnusedSincePrefetchCopy) {
37 response_info_.unused_since_prefetch = true;
38 HttpResponseInfo response_info_clone(response_info_);
39 EXPECT_TRUE(response_info_clone.unused_since_prefetch);
42 TEST_F(HttpResponseInfoTest, UnusedSincePrefetchPersistFalse) {
43 HttpResponseInfo restored_response_info;
44 PickleAndRestore(response_info_, &restored_response_info);
45 EXPECT_FALSE(restored_response_info.unused_since_prefetch);
48 TEST_F(HttpResponseInfoTest, UnusedSincePrefetchPersistTrue) {
49 response_info_.unused_since_prefetch = true;
50 HttpResponseInfo restored_response_info;
51 PickleAndRestore(response_info_, &restored_response_info);
52 EXPECT_TRUE(restored_response_info.unused_since_prefetch);
55 TEST_F(HttpResponseInfoTest, AsyncRevalidationRequiredDefault) {
56 EXPECT_FALSE(response_info_.async_revalidation_required);
59 TEST_F(HttpResponseInfoTest, AsyncRevalidationRequiredCopy) {
60 response_info_.async_revalidation_required = true;
61 net::HttpResponseInfo response_info_clone(response_info_);
62 EXPECT_TRUE(response_info_clone.async_revalidation_required);
65 TEST_F(HttpResponseInfoTest, AsyncRevalidationRequiredAssign) {
66 response_info_.async_revalidation_required = true;
67 net::HttpResponseInfo response_info_clone;
68 response_info_clone = response_info_;
69 EXPECT_TRUE(response_info_clone.async_revalidation_required);
72 TEST_F(HttpResponseInfoTest, AsyncRevalidationRequiredNotPersisted) {
73 response_info_.async_revalidation_required = true;
74 net::HttpResponseInfo restored_response_info;
75 PickleAndRestore(response_info_, &restored_response_info);
76 EXPECT_FALSE(restored_response_info.async_revalidation_required);
79 } // namespace
81 } // namespace net