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 "components/autofill/core/common/form_field_data.h" | 5 #include "components/autofill/core/common/form_field_data.h" |
6 | 6 |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 Pickle pickle; | 33 Pickle pickle; |
34 SerializeFormFieldData(data, &pickle); | 34 SerializeFormFieldData(data, &pickle); |
35 | 35 |
36 PickleIterator iter(pickle); | 36 PickleIterator iter(pickle); |
37 FormFieldData actual; | 37 FormFieldData actual; |
38 EXPECT_TRUE(DeserializeFormFieldData(&iter, &actual)); | 38 EXPECT_TRUE(DeserializeFormFieldData(&iter, &actual)); |
39 | 39 |
40 EXPECT_TRUE(actual.SameFieldAs(data)); | 40 EXPECT_TRUE(actual.SameFieldAs(data)); |
41 } | 41 } |
42 | 42 |
| 43 TEST(FormFieldDataTest, DeserializeVersion1) { |
| 44 FormFieldData data; |
| 45 data.label = base::ASCIIToUTF16("label"); |
| 46 data.name = base::ASCIIToUTF16("name"); |
| 47 data.value = base::ASCIIToUTF16("value"); |
| 48 data.form_control_type = "password"; |
| 49 data.autocomplete_attribute = "off"; |
| 50 data.max_length = 200; |
| 51 data.is_autofilled = true; |
| 52 data.is_checked = true; |
| 53 data.is_checkable = true; |
| 54 data.is_focusable = true; |
| 55 data.should_autocomplete = false; |
| 56 data.text_direction = base::i18n::RIGHT_TO_LEFT; |
| 57 data.option_values.push_back(base::ASCIIToUTF16("First")); |
| 58 data.option_values.push_back(base::ASCIIToUTF16("Second")); |
| 59 data.option_contents.push_back(base::ASCIIToUTF16("First")); |
| 60 data.option_contents.push_back(base::ASCIIToUTF16("Second")); |
| 61 |
| 62 Pickle pickle; |
| 63 pickle.WriteInt(1); |
| 64 pickle.WriteString16(data.label); |
| 65 pickle.WriteString16(data.name); |
| 66 pickle.WriteString16(data.value); |
| 67 pickle.WriteString(data.form_control_type); |
| 68 pickle.WriteString(data.autocomplete_attribute); |
| 69 pickle.WriteSizeT(data.max_length); |
| 70 pickle.WriteBool(data.is_autofilled); |
| 71 pickle.WriteBool(data.is_checked); |
| 72 pickle.WriteBool(data.is_checkable); |
| 73 pickle.WriteBool(data.is_focusable); |
| 74 pickle.WriteBool(data.should_autocomplete); |
| 75 pickle.WriteInt(data.text_direction); |
| 76 pickle.WriteInt(static_cast<int>(data.option_values.size())); |
| 77 for (auto s: data.option_values) |
| 78 pickle.WriteString16(s); |
| 79 pickle.WriteInt(static_cast<int>(data.option_contents.size())); |
| 80 for (auto s: data.option_contents) |
| 81 pickle.WriteString16(s); |
| 82 |
| 83 PickleIterator iter(pickle); |
| 84 FormFieldData actual; |
| 85 EXPECT_TRUE(DeserializeFormFieldData(&iter, &actual)); |
| 86 |
| 87 EXPECT_TRUE(actual.SameFieldAs(data)); |
| 88 } |
| 89 |
43 } // namespace autofill | 90 } // namespace autofill |
OLD | NEW |