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

Side by Side 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, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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_data.h"
6
7 #include "base/pickle.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace autofill {
12
13 TEST(FormDataTest, SerializeAndDeserialize) {
14 FormData data;
15 data.name = ASCIIToUTF16("name");
16 data.method = ASCIIToUTF16("POST");
17 data.origin = GURL("origin");
18 data.action = GURL("action");
19 data.user_submitted = true;
20
21 FormFieldData field_data;
22 field_data.label = ASCIIToUTF16("label");
23 field_data.name = ASCIIToUTF16("name");
24 field_data.value = ASCIIToUTF16("value");
25 field_data.form_control_type = "password";
26 field_data.autocomplete_attribute = "off";
27 field_data.max_length = 200;
28 field_data.is_autofilled = true;
29 field_data.is_checked = true;
30 field_data.is_checkable = true;
31 field_data.is_focusable = true;
32 field_data.should_autocomplete = false;
33 field_data.text_direction = base::i18n::RIGHT_TO_LEFT;
34 field_data.option_values.push_back(ASCIIToUTF16("First"));
35 field_data.option_values.push_back(ASCIIToUTF16("Second"));
36 field_data.option_contents.push_back(ASCIIToUTF16("First"));
37 field_data.option_contents.push_back(ASCIIToUTF16("Second"));
38
39 data.fields.push_back(field_data);
40
41 // Change a few fields.
42 field_data.max_length = 150;
43 field_data.option_values.push_back(ASCIIToUTF16("Third"));
44 field_data.option_contents.push_back(ASCIIToUTF16("Third"));
45 data.fields.push_back(field_data);
46
47 Pickle pickle;
48 SerializeFormData(data, &pickle);
49
50 PickleIterator iter(pickle);
51 FormData actual;
52 EXPECT_TRUE(DeserializeFormData(&iter, &actual));
53
54 EXPECT_EQ(actual, data);
55 }
56
57 } // namespace autofill
OLDNEW
« 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