OLD | NEW |
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 <math.h> | 5 #include <math.h> |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 109 } |
110 | 110 |
111 void PopulateHttpBody(ExplodedHttpBody* http_body, | 111 void PopulateHttpBody(ExplodedHttpBody* http_body, |
112 std::vector<base::NullableString16>* referenced_files) { | 112 std::vector<base::NullableString16>* referenced_files) { |
113 http_body->is_null = false; | 113 http_body->is_null = false; |
114 http_body->identifier = 12345; | 114 http_body->identifier = 12345; |
115 http_body->contains_passwords = false; | 115 http_body->contains_passwords = false; |
116 http_body->http_content_type = NS16("text/foo"); | 116 http_body->http_content_type = NS16("text/foo"); |
117 | 117 |
118 ExplodedHttpBodyElement e1; | 118 ExplodedHttpBodyElement e1; |
119 e1.type = WebKit::WebHTTPBody::Element::TypeData; | 119 e1.type = blink::WebHTTPBody::Element::TypeData; |
120 e1.data = "foo"; | 120 e1.data = "foo"; |
121 http_body->elements.push_back(e1); | 121 http_body->elements.push_back(e1); |
122 | 122 |
123 ExplodedHttpBodyElement e2; | 123 ExplodedHttpBodyElement e2; |
124 e2.type = WebKit::WebHTTPBody::Element::TypeFile; | 124 e2.type = blink::WebHTTPBody::Element::TypeFile; |
125 e2.file_path = NS16("file.txt"); | 125 e2.file_path = NS16("file.txt"); |
126 e2.file_start = 100; | 126 e2.file_start = 100; |
127 e2.file_length = 1024; | 127 e2.file_length = 1024; |
128 e2.file_modification_time = 9999.0; | 128 e2.file_modification_time = 9999.0; |
129 http_body->elements.push_back(e2); | 129 http_body->elements.push_back(e2); |
130 | 130 |
131 referenced_files->push_back(e2.file_path); | 131 referenced_files->push_back(e2.file_path); |
132 } | 132 } |
133 | 133 |
134 void PopulateFrameStateForBackwardsCompatTest( | 134 void PopulateFrameStateForBackwardsCompatTest( |
(...skipping 19 matching lines...) Expand all Loading... |
154 frame_state->document_state.push_back(NS16("2")); | 154 frame_state->document_state.push_back(NS16("2")); |
155 frame_state->document_state.push_back(NS16("file.txt")); | 155 frame_state->document_state.push_back(NS16("file.txt")); |
156 frame_state->document_state.push_back(NS16("displayName")); | 156 frame_state->document_state.push_back(NS16("displayName")); |
157 | 157 |
158 if (!is_child) { | 158 if (!is_child) { |
159 frame_state->http_body.http_content_type = NS16("foo/bar"); | 159 frame_state->http_body.http_content_type = NS16("foo/bar"); |
160 frame_state->http_body.identifier = 789; | 160 frame_state->http_body.identifier = 789; |
161 frame_state->http_body.is_null = false; | 161 frame_state->http_body.is_null = false; |
162 | 162 |
163 ExplodedHttpBodyElement e1; | 163 ExplodedHttpBodyElement e1; |
164 e1.type = WebKit::WebHTTPBody::Element::TypeData; | 164 e1.type = blink::WebHTTPBody::Element::TypeData; |
165 e1.data = "first data block"; | 165 e1.data = "first data block"; |
166 frame_state->http_body.elements.push_back(e1); | 166 frame_state->http_body.elements.push_back(e1); |
167 | 167 |
168 ExplodedHttpBodyElement e2; | 168 ExplodedHttpBodyElement e2; |
169 e2.type = WebKit::WebHTTPBody::Element::TypeFile; | 169 e2.type = blink::WebHTTPBody::Element::TypeFile; |
170 e2.file_path = NS16("file.txt"); | 170 e2.file_path = NS16("file.txt"); |
171 frame_state->http_body.elements.push_back(e2); | 171 frame_state->http_body.elements.push_back(e2); |
172 | 172 |
173 ExplodedHttpBodyElement e3; | 173 ExplodedHttpBodyElement e3; |
174 e3.type = WebKit::WebHTTPBody::Element::TypeData; | 174 e3.type = blink::WebHTTPBody::Element::TypeData; |
175 e3.data = "data the second"; | 175 e3.data = "data the second"; |
176 frame_state->http_body.elements.push_back(e3); | 176 frame_state->http_body.elements.push_back(e3); |
177 | 177 |
178 ExplodedFrameState child_state; | 178 ExplodedFrameState child_state; |
179 PopulateFrameStateForBackwardsCompatTest(&child_state, true); | 179 PopulateFrameStateForBackwardsCompatTest(&child_state, true); |
180 frame_state->children.push_back(child_state); | 180 frame_state->children.push_back(child_state); |
181 } | 181 } |
182 } | 182 } |
183 | 183 |
184 void PopulatePageStateForBackwardsCompatTest(ExplodedPageState* page_state) { | 184 void PopulatePageStateForBackwardsCompatTest(ExplodedPageState* page_state) { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 // More misc fields. | 345 // More misc fields. |
346 p.WriteData(reinterpret_cast<const char*>(&d), sizeof(d)); | 346 p.WriteData(reinterpret_cast<const char*>(&d), sizeof(d)); |
347 p.WriteInt(1); | 347 p.WriteInt(1); |
348 p.WriteInt(1); | 348 p.WriteInt(1); |
349 p.WriteInt(0); | 349 p.WriteInt(0); |
350 p.WriteInt(0); | 350 p.WriteInt(0); |
351 p.WriteInt(-1); | 351 p.WriteInt(-1); |
352 p.WriteInt(0); | 352 p.WriteInt(0); |
353 // WebForm | 353 // WebForm |
354 p.WriteInt(1); | 354 p.WriteInt(1); |
355 p.WriteInt(WebKit::WebHTTPBody::Element::TypeData); | 355 p.WriteInt(blink::WebHTTPBody::Element::TypeData); |
356 | 356 |
357 std::string s(static_cast<const char*>(p.data()), p.size()); | 357 std::string s(static_cast<const char*>(p.data()), p.size()); |
358 | 358 |
359 ExplodedPageState output; | 359 ExplodedPageState output; |
360 EXPECT_FALSE(DecodePageState(s, &output)); | 360 EXPECT_FALSE(DecodePageState(s, &output)); |
361 } | 361 } |
362 | 362 |
363 TEST_F(PageStateSerializationTest, DumpExpectedPageStateForBackwardsCompat) { | 363 TEST_F(PageStateSerializationTest, DumpExpectedPageStateForBackwardsCompat) { |
364 // Comment out this return statement to enable this code. Use this code to | 364 // Comment out this return statement to enable this code. Use this code to |
365 // generate data, based on the current serialization format, for the | 365 // generate data, based on the current serialization format, for the |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 TEST_F(PageStateSerializationTest, BackwardsCompat_v15) { | 416 TEST_F(PageStateSerializationTest, BackwardsCompat_v15) { |
417 TestBackwardsCompat(15); | 417 TestBackwardsCompat(15); |
418 } | 418 } |
419 | 419 |
420 TEST_F(PageStateSerializationTest, BackwardsCompat_v16) { | 420 TEST_F(PageStateSerializationTest, BackwardsCompat_v16) { |
421 TestBackwardsCompat(16); | 421 TestBackwardsCompat(16); |
422 } | 422 } |
423 | 423 |
424 } // namespace | 424 } // namespace |
425 } // namespace content | 425 } // namespace content |
OLD | NEW |