Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(584)

Side by Side Diff: content/common/page_state_serialization_unittest.cc

Issue 2954343005: Merge ResourceRequestBodyImpl and ResourceRequestBody. (Closed)
Patch Set: Remove comment Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/common/page_state_serialization.cc ('k') | content/common/resource_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 23 matching lines...) Expand all
34 } 34 }
35 35
36 template <typename T> 36 template <typename T>
37 void ExpectEquality(const std::vector<T>& a, const std::vector<T>& b) { 37 void ExpectEquality(const std::vector<T>& a, const std::vector<T>& b) {
38 EXPECT_EQ(a.size(), b.size()); 38 EXPECT_EQ(a.size(), b.size());
39 for (size_t i = 0; i < std::min(a.size(), b.size()); ++i) 39 for (size_t i = 0; i < std::min(a.size(), b.size()); ++i)
40 ExpectEquality(a[i], b[i]); 40 ExpectEquality(a[i], b[i]);
41 } 41 }
42 42
43 template <> 43 template <>
44 void ExpectEquality(const ResourceRequestBodyImpl::Element& a, 44 void ExpectEquality(const ResourceRequestBody::Element& a,
45 const ResourceRequestBodyImpl::Element& b) { 45 const ResourceRequestBody::Element& b) {
46 EXPECT_EQ(a.type(), b.type()); 46 EXPECT_EQ(a.type(), b.type());
47 if (a.type() == ResourceRequestBodyImpl::Element::TYPE_BYTES && 47 if (a.type() == ResourceRequestBody::Element::TYPE_BYTES &&
48 b.type() == ResourceRequestBodyImpl::Element::TYPE_BYTES) { 48 b.type() == ResourceRequestBody::Element::TYPE_BYTES) {
49 EXPECT_EQ(std::string(a.bytes(), a.length()), 49 EXPECT_EQ(std::string(a.bytes(), a.length()),
50 std::string(b.bytes(), b.length())); 50 std::string(b.bytes(), b.length()));
51 } 51 }
52 EXPECT_EQ(a.path(), b.path()); 52 EXPECT_EQ(a.path(), b.path());
53 EXPECT_EQ(a.filesystem_url(), b.filesystem_url()); 53 EXPECT_EQ(a.filesystem_url(), b.filesystem_url());
54 EXPECT_EQ(a.offset(), b.offset()); 54 EXPECT_EQ(a.offset(), b.offset());
55 EXPECT_EQ(a.length(), b.length()); 55 EXPECT_EQ(a.length(), b.length());
56 EXPECT_EQ(a.expected_modification_time(), b.expected_modification_time()); 56 EXPECT_EQ(a.expected_modification_time(), b.expected_modification_time());
57 EXPECT_EQ(a.blob_uuid(), b.blob_uuid()); 57 EXPECT_EQ(a.blob_uuid(), b.blob_uuid());
58 } 58 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 blink::kWebHistoryScrollRestorationManual; 112 blink::kWebHistoryScrollRestorationManual;
113 frame_state->visual_viewport_scroll_offset = gfx::PointF(10, 15); 113 frame_state->visual_viewport_scroll_offset = gfx::PointF(10, 15);
114 frame_state->scroll_offset = gfx::Point(0, 100); 114 frame_state->scroll_offset = gfx::Point(0, 100);
115 frame_state->item_sequence_number = 1; 115 frame_state->item_sequence_number = 1;
116 frame_state->document_sequence_number = 2; 116 frame_state->document_sequence_number = 2;
117 frame_state->page_scale_factor = 2.0; 117 frame_state->page_scale_factor = 2.0;
118 } 118 }
119 119
120 void PopulateHttpBody(ExplodedHttpBody* http_body, 120 void PopulateHttpBody(ExplodedHttpBody* http_body,
121 std::vector<base::NullableString16>* referenced_files) { 121 std::vector<base::NullableString16>* referenced_files) {
122 http_body->request_body = new ResourceRequestBodyImpl(); 122 http_body->request_body = new ResourceRequestBody();
123 http_body->request_body->set_identifier(12345); 123 http_body->request_body->set_identifier(12345);
124 http_body->contains_passwords = false; 124 http_body->contains_passwords = false;
125 http_body->http_content_type = NS16("text/foo"); 125 http_body->http_content_type = NS16("text/foo");
126 126
127 std::string test_body("foo"); 127 std::string test_body("foo");
128 http_body->request_body->AppendBytes(test_body.data(), test_body.size()); 128 http_body->request_body->AppendBytes(test_body.data(), test_body.size());
129 129
130 base::FilePath path(FILE_PATH_LITERAL("file.txt")); 130 base::FilePath path(FILE_PATH_LITERAL("file.txt"));
131 http_body->request_body->AppendFileRange(base::FilePath(path), 100, 1024, 131 http_body->request_body->AppendFileRange(base::FilePath(path), 100, 1024,
132 base::Time::FromDoubleT(9999.0)); 132 base::Time::FromDoubleT(9999.0));
(...skipping 23 matching lines...) Expand all
156 frame_state->document_state.push_back(NS16("form key")); 156 frame_state->document_state.push_back(NS16("form key"));
157 frame_state->document_state.push_back(NS16("1")); 157 frame_state->document_state.push_back(NS16("1"));
158 frame_state->document_state.push_back(NS16("foo")); 158 frame_state->document_state.push_back(NS16("foo"));
159 frame_state->document_state.push_back(NS16("file")); 159 frame_state->document_state.push_back(NS16("file"));
160 frame_state->document_state.push_back(NS16("2")); 160 frame_state->document_state.push_back(NS16("2"));
161 frame_state->document_state.push_back(NS16("file.txt")); 161 frame_state->document_state.push_back(NS16("file.txt"));
162 frame_state->document_state.push_back(NS16("displayName")); 162 frame_state->document_state.push_back(NS16("displayName"));
163 163
164 if (!is_child) { 164 if (!is_child) {
165 frame_state->http_body.http_content_type = NS16("foo/bar"); 165 frame_state->http_body.http_content_type = NS16("foo/bar");
166 frame_state->http_body.request_body = new ResourceRequestBodyImpl(); 166 frame_state->http_body.request_body = new ResourceRequestBody();
167 frame_state->http_body.request_body->set_identifier(789); 167 frame_state->http_body.request_body->set_identifier(789);
168 168
169 std::string test_body("first data block"); 169 std::string test_body("first data block");
170 frame_state->http_body.request_body->AppendBytes(test_body.data(), 170 frame_state->http_body.request_body->AppendBytes(test_body.data(),
171 test_body.size()); 171 test_body.size());
172 172
173 frame_state->http_body.request_body->AppendFileRange( 173 frame_state->http_body.request_body->AppendFileRange(
174 base::FilePath(FILE_PATH_LITERAL("file.txt")), 0, 174 base::FilePath(FILE_PATH_LITERAL("file.txt")), 0,
175 std::numeric_limits<uint64_t>::max(), base::Time::FromDoubleT(0.0)); 175 std::numeric_limits<uint64_t>::max(), base::Time::FromDoubleT(0.0));
176 176
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 TEST_F(PageStateSerializationTest, BackwardsCompat_v22) { 438 TEST_F(PageStateSerializationTest, BackwardsCompat_v22) {
439 TestBackwardsCompat(22); 439 TestBackwardsCompat(22);
440 } 440 }
441 441
442 TEST_F(PageStateSerializationTest, BackwardsCompat_v23) { 442 TEST_F(PageStateSerializationTest, BackwardsCompat_v23) {
443 TestBackwardsCompat(23); 443 TestBackwardsCompat(23);
444 } 444 }
445 445
446 } // namespace 446 } // namespace
447 } // namespace content 447 } // namespace content
OLDNEW
« no previous file with comments | « content/common/page_state_serialization.cc ('k') | content/common/resource_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698