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
3// found in the LICENSE file.
4
5#include "components/autofill/core/common/form_field_data.h"
6
7#include "base/i18n/rtl.h"
8#include "base/pickle.h"
9#include "base/strings/utf_string_conversions.h"
10#include "testing/gtest/include/gtest/gtest.h"
11
12namespace autofill {
13
14TEST(FormFieldDataTest, SerializeAndDeserialize) {
15  FormFieldData data;
16  data.label = base::ASCIIToUTF16("label");
17  data.name = base::ASCIIToUTF16("name");
18  data.value = base::ASCIIToUTF16("value");
19  data.form_control_type = "password";
20  data.autocomplete_attribute = "off";
21  data.max_length = 200;
22  data.is_autofilled = true;
23  data.is_checked = true;
24  data.is_checkable = true;
25  data.is_focusable = true;
26  data.should_autocomplete = false;
27  data.text_direction = base::i18n::RIGHT_TO_LEFT;
28  data.option_values.push_back(base::ASCIIToUTF16("First"));
29  data.option_values.push_back(base::ASCIIToUTF16("Second"));
30  data.option_contents.push_back(base::ASCIIToUTF16("First"));
31  data.option_contents.push_back(base::ASCIIToUTF16("Second"));
32
33  Pickle pickle;
34  SerializeFormFieldData(data, &pickle);
35
36  PickleIterator iter(pickle);
37  FormFieldData actual;
38  EXPECT_TRUE(DeserializeFormFieldData(&iter, &actual));
39
40  EXPECT_EQ(actual, data);
41}
42
43}  // namespace autofill
44