| 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 <cmath> | 5 #include <cmath> |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 std::string encoded; | 315 std::string encoded; |
| 316 EncodePageState(input, &encoded); | 316 EncodePageState(input, &encoded); |
| 317 | 317 |
| 318 ExplodedPageState output; | 318 ExplodedPageState output; |
| 319 DecodePageState(encoded, &output); | 319 DecodePageState(encoded, &output); |
| 320 | 320 |
| 321 ExpectEquality(input, output); | 321 ExpectEquality(input, output); |
| 322 } | 322 } |
| 323 | 323 |
| 324 TEST_F(PageStateSerializationTest, BadMessagesTest1) { | 324 TEST_F(PageStateSerializationTest, BadMessagesTest1) { |
| 325 Pickle p; | 325 base::Pickle p; |
| 326 // Version 14 | 326 // Version 14 |
| 327 p.WriteInt(14); | 327 p.WriteInt(14); |
| 328 // Empty strings. | 328 // Empty strings. |
| 329 for (int i = 0; i < 6; ++i) | 329 for (int i = 0; i < 6; ++i) |
| 330 p.WriteInt(-1); | 330 p.WriteInt(-1); |
| 331 // Bad real number. | 331 // Bad real number. |
| 332 p.WriteInt(-1); | 332 p.WriteInt(-1); |
| 333 | 333 |
| 334 std::string s(static_cast<const char*>(p.data()), p.size()); | 334 std::string s(static_cast<const char*>(p.data()), p.size()); |
| 335 | 335 |
| 336 ExplodedPageState output; | 336 ExplodedPageState output; |
| 337 EXPECT_FALSE(DecodePageState(s, &output)); | 337 EXPECT_FALSE(DecodePageState(s, &output)); |
| 338 } | 338 } |
| 339 | 339 |
| 340 TEST_F(PageStateSerializationTest, BadMessagesTest2) { | 340 TEST_F(PageStateSerializationTest, BadMessagesTest2) { |
| 341 double d = 0; | 341 double d = 0; |
| 342 Pickle p; | 342 base::Pickle p; |
| 343 // Version 14 | 343 // Version 14 |
| 344 p.WriteInt(14); | 344 p.WriteInt(14); |
| 345 // Empty strings. | 345 // Empty strings. |
| 346 for (int i = 0; i < 6; ++i) | 346 for (int i = 0; i < 6; ++i) |
| 347 p.WriteInt(-1); | 347 p.WriteInt(-1); |
| 348 // More misc fields. | 348 // More misc fields. |
| 349 p.WriteData(reinterpret_cast<const char*>(&d), sizeof(d)); | 349 p.WriteData(reinterpret_cast<const char*>(&d), sizeof(d)); |
| 350 p.WriteInt(1); | 350 p.WriteInt(1); |
| 351 p.WriteInt(1); | 351 p.WriteInt(1); |
| 352 p.WriteInt(0); | 352 p.WriteInt(0); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 TEST_F(PageStateSerializationTest, BackwardsCompat_v21) { | 434 TEST_F(PageStateSerializationTest, BackwardsCompat_v21) { |
| 435 TestBackwardsCompat(21); | 435 TestBackwardsCompat(21); |
| 436 } | 436 } |
| 437 | 437 |
| 438 TEST_F(PageStateSerializationTest, BackwardsCompat_v22) { | 438 TEST_F(PageStateSerializationTest, BackwardsCompat_v22) { |
| 439 TestBackwardsCompat(22); | 439 TestBackwardsCompat(22); |
| 440 } | 440 } |
| 441 | 441 |
| 442 } // namespace | 442 } // namespace |
| 443 } // namespace content | 443 } // namespace content |
| OLD | NEW |