Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Unified Diff: components/autofill/core/common/form_data_unittest.cc

Issue 23033010: [password autofill] Add serialization for FormData and FormFieldData (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Windows Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/autofill/core/common/form_data.cc ('k') | components/autofill/core/common/form_field_data.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « components/autofill/core/common/form_data.cc ('k') | components/autofill/core/common/form_field_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698