Index: components/autofill/core/common/form_data_unittest.cc |
diff --git a/components/autofill/core/common/form_data_unittest.cc b/components/autofill/core/common/form_data_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2d4b7aacb24d6a698d8d4f6322b77cf21ae67b1c |
--- /dev/null |
+++ b/components/autofill/core/common/form_data_unittest.cc |
@@ -0,0 +1,57 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "components/autofill/core/common/form_data.h" |
+ |
+#include "base/pickle.h" |
+#include "base/strings/utf_string_conversions.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace autofill { |
+ |
+TEST(FormDataTest, SerializeAndDeserialize) { |
+ FormData data; |
+ data.name = ASCIIToUTF16("name"); |
+ data.method = ASCIIToUTF16("POST"); |
+ data.origin = GURL("origin"); |
+ data.action = GURL("action"); |
+ data.user_submitted = true; |
+ |
+ FormFieldData field_data; |
+ field_data.label = ASCIIToUTF16("label"); |
+ field_data.name = ASCIIToUTF16("name"); |
+ field_data.value = ASCIIToUTF16("value"); |
+ field_data.form_control_type = "password"; |
+ field_data.autocomplete_attribute = "off"; |
+ field_data.max_length = 200; |
+ field_data.is_autofilled = true; |
+ field_data.is_checked = true; |
+ field_data.is_checkable = true; |
+ field_data.is_focusable = true; |
+ field_data.should_autocomplete = false; |
+ field_data.text_direction = base::i18n::RIGHT_TO_LEFT; |
+ field_data.option_values.push_back(ASCIIToUTF16("First")); |
+ field_data.option_values.push_back(ASCIIToUTF16("Second")); |
+ field_data.option_contents.push_back(ASCIIToUTF16("First")); |
+ field_data.option_contents.push_back(ASCIIToUTF16("Second")); |
+ |
+ data.fields.push_back(field_data); |
+ |
+ // Change a few fields. |
+ field_data.max_length = 150; |
+ field_data.option_values.push_back(ASCIIToUTF16("Third")); |
+ field_data.option_contents.push_back(ASCIIToUTF16("Third")); |
+ data.fields.push_back(field_data); |
+ |
+ Pickle pickle; |
+ SerializeFormData(data, &pickle); |
+ |
+ PickleIterator iter(pickle); |
+ FormData actual; |
+ EXPECT_TRUE(DeserializeFormData(&iter, &actual)); |
+ |
+ EXPECT_EQ(actual, data); |
+} |
+ |
+} // namespace autofill |