1 // Copyright (c) 2012 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 CHROME_COMMON_FORM_FIELD_DATA_H_
6 #define CHROME_COMMON_FORM_FIELD_DATA_H_
10 #include "base/string16.h"
12 // Stores information about a field in a form.
13 struct FormFieldData
{
15 virtual ~FormFieldData();
17 // Equality tests for identity which does not include |value| or
19 // TODO(dhollowa): These operators need to be revised when we implement field
21 bool operator==(const FormFieldData
& field
) const;
22 bool operator!=(const FormFieldData
& field
) const;
23 // Comparsion operator exposed for STL map. Uses label, then name to sort.
24 bool operator<(const FormFieldData
& field
) const;
29 std::string form_control_type
;
30 std::string autocomplete_attribute
;
34 bool should_autocomplete
;
36 // For the HTML snippet |<option value="US">United States</option>|, the
37 // value is "US" and the contents are "United States".
38 std::vector
<string16
> option_values
;
39 std::vector
<string16
> option_contents
;
42 // So we can compare FormFieldDatas with EXPECT_EQ().
43 std::ostream
& operator<<(std::ostream
& os
, const FormFieldData
& field
);
45 // Prefer to use this macro in place of |EXPECT_EQ()| for comparing
46 // |FormFieldData|s in test code.
47 #define EXPECT_FORM_FIELD_DATA_EQUALS(expected, actual) \
49 EXPECT_EQ(expected.label, actual.label); \
50 EXPECT_EQ(expected.name, actual.name); \
51 EXPECT_EQ(expected.value, actual.value); \
52 EXPECT_EQ(expected.form_control_type, actual.form_control_type); \
53 EXPECT_EQ(expected.autocomplete_attribute, actual.autocomplete_attribute); \
54 EXPECT_EQ(expected.max_length, actual.max_length); \
55 EXPECT_EQ(expected.is_autofilled, actual.is_autofilled); \
58 #endif // CHROME_COMMON_FORM_FIELD_DATA_H_