Revert of Enabling audio quality test on mac. (patchset #1 id:1 of https://codereview...
[chromium-blink-merge.git] / components / autofill / core / common / form_field_data.h
blob1bf163e95f28447d09ae4195b0087e745f8183ab
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.
5 #ifndef COMPONENTS_AUTOFILL_CORE_COMMON_FORM_FIELD_DATA_H_
6 #define COMPONENTS_AUTOFILL_CORE_COMMON_FORM_FIELD_DATA_H_
8 #include <vector>
10 #include "base/i18n/rtl.h"
11 #include "base/strings/string16.h"
13 class Pickle;
14 class PickleIterator;
16 namespace autofill {
18 // Stores information about a field in a form.
19 struct FormFieldData {
20 FormFieldData();
21 ~FormFieldData();
23 // Equality tests for identity which does not include |value| or
24 // |is_autofilled|.
25 // TODO(dhollowa): These operators need to be revised when we implement field
26 // ids.
27 bool operator==(const FormFieldData& field) const;
28 bool operator!=(const FormFieldData& field) const;
29 // Comparison operator exposed for STL map. Uses label, then name to sort.
30 bool operator<(const FormFieldData& field) const;
32 base::string16 label;
33 base::string16 name;
34 base::string16 value;
35 std::string form_control_type;
36 std::string autocomplete_attribute;
37 size_t max_length;
38 bool is_autofilled;
39 bool is_checked;
40 bool is_checkable;
41 bool is_focusable;
42 bool should_autocomplete;
43 base::i18n::TextDirection text_direction;
45 // For the HTML snippet |<option value="US">United States</option>|, the
46 // value is "US" and the contents are "United States".
47 std::vector<base::string16> option_values;
48 std::vector<base::string16> option_contents;
51 // Serialize and deserialize FormFieldData. These are used when FormData objects
52 // are serialized and deserialized.
53 void SerializeFormFieldData(const FormFieldData& form_field_data,
54 Pickle* serialized);
55 bool DeserializeFormFieldData(PickleIterator* pickle_iterator,
56 FormFieldData* form_field_data);
58 // So we can compare FormFieldDatas with EXPECT_EQ().
59 std::ostream& operator<<(std::ostream& os, const FormFieldData& field);
61 // Prefer to use this macro in place of |EXPECT_EQ()| for comparing
62 // |FormFieldData|s in test code.
63 #define EXPECT_FORM_FIELD_DATA_EQUALS(expected, actual) \
64 do { \
65 EXPECT_EQ(expected.label, actual.label); \
66 EXPECT_EQ(expected.name, actual.name); \
67 EXPECT_EQ(expected.value, actual.value); \
68 EXPECT_EQ(expected.form_control_type, actual.form_control_type); \
69 EXPECT_EQ(expected.autocomplete_attribute, actual.autocomplete_attribute); \
70 EXPECT_EQ(expected.max_length, actual.max_length); \
71 EXPECT_EQ(expected.is_autofilled, actual.is_autofilled); \
72 EXPECT_EQ(expected.is_checked, actual.is_checked); \
73 EXPECT_EQ(expected.is_checkable, actual.is_checkable); \
74 } while (0)
76 } // namespace autofill
78 #endif // COMPONENTS_AUTOFILL_CORE_COMMON_FORM_FIELD_DATA_H_