10#include "gtest/gtest.h"
25 T(ParseFunction)(
const char*),
26 int32_t(
step)(int32_t) = [](int32_t val) {
return val + 1; }) {
28 for (
int i =
static_cast<int>(T::kMinValue);
29 i <= static_cast<int>(T::kMaxValue);
i =
step(
i)) {
32 auto dst = ParseFunction(str.c_str());
37 EXPECT_EQ(
T::kNone, ParseFunction(
"bogus"));
40 int out_of_range_value =
static_cast<int>(T::kMaxValue) + 1;
41 EXPECT_STREQ(
"",
ToString(
static_cast<T>(out_of_range_value)));
49template <
typename T,
typename U>
53 for (
int i =
static_cast<int>(T::kMinValue) + 1;
54 i <= static_cast<int>(T::kMaxValue); ++
i) {
55 T attr =
static_cast<T>(
i);
56 ((node_data).*(Setter))(attr,
value);
63template <
typename T,
typename U>
66 for (
int i =
static_cast<int>(T::kMinValue) + 1;
67 i <= static_cast<int>(T::kMaxValue); ++
i) {
68 T attr =
static_cast<T>(
i);
69 ((node_data).*(Setter))(attr,
value);
75 TestEnumStringConversion<ax::mojom::Event>(
ParseEvent);
79 TestEnumStringConversion<ax::mojom::Role>(
ParseRole);
83 TestEnumStringConversion<ax::mojom::State>(
ParseState);
87 TestEnumStringConversion<ax::mojom::Action>(
ParseAction);
95 TestEnumStringConversion<ax::mojom::DefaultActionVerb>(
100 TestEnumStringConversion<ax::mojom::Mutation>(
ParseMutation);
105 TestAXNodeDataSetter<ax::mojom::StringAttribute>(
117 TestAXNodeDataSetter<ax::mojom::FloatAttribute>(
129 TestAXNodeDataSetter<ax::mojom::IntListAttribute>(
134 TestEnumStringConversion<ax::mojom::StringListAttribute>(
136 TestAXNodeDataSetter<ax::mojom::StringListAttribute>(
141 TestEnumStringConversion<ax::mojom::MarkerType>(
143 return val == 0 ? 1 :
152TEST(AXEnumUtilTest, Text_Decoration_Style) {
153 TestEnumStringConversion<ax::mojom::TextDecorationStyle>(
166 TestEnumStringConversion<ax::mojom::Command>(
ParseCommand);
194 TestEnumStringConversion<ax::mojom::HasPopup>(
ParseHasPopup);
214 TestEnumStringConversion<ax::mojom::NameFrom>(
ParseNameFrom);
226 TestEnumStringConversion<ax::mojom::Gesture>(
ParseGesture);
238 TestEnumStringConversion<ax::mojom::ImageAnnotationStatus>(
static int step(int x, SkScalar min, SkScalar max)
ax::mojom::IntListAttribute ParseIntListAttribute(const char *int_list_attribute)
ax::mojom::MoveDirection ParseMoveDirection(const char *move_direction)
ax::mojom::Event ParseEvent(const char *event)
ax::mojom::DescriptionFrom ParseDescriptionFrom(const char *description_from)
ax::mojom::FloatAttribute ParseFloatAttribute(const char *float_attribute)
ax::mojom::TextBoundary ParseTextBoundary(const char *text_boundary)
ax::mojom::ListStyle ParseListStyle(const char *list_style)
ax::mojom::TreeOrder ParseTreeOrder(const char *tree_order)
TEST(AXEnumUtilTest, Event)
ax::mojom::ActionFlags ParseActionFlags(const char *action_flags)
ax::mojom::TextAlign ParseTextAlign(const char *text_align)
ax::mojom::Action ParseAction(const char *action)
const char * ToString(ax::mojom::Event event)
ax::mojom::Restriction ParseRestriction(const char *restriction)
ax::mojom::StringAttribute ParseStringAttribute(const char *string_attribute)
void TestAXNodeDataSetter(void(AXNodeData::*Setter)(T, const U &), const U &value)
ax::mojom::Command ParseCommand(const char *command)
ax::mojom::SortDirection ParseSortDirection(const char *sort_direction)
ax::mojom::HasPopup ParseHasPopup(const char *has_popup)
ax::mojom::NameFrom ParseNameFrom(const char *name_from)
ax::mojom::StringListAttribute ParseStringListAttribute(const char *string_list_attribute)
ax::mojom::TextPosition ParseTextPosition(const char *text_position)
ax::mojom::Role ParseRole(const char *role)
ax::mojom::WritingDirection ParseTextDirection(const char *text_direction)
ax::mojom::IntAttribute ParseIntAttribute(const char *int_attribute)
ax::mojom::EventFrom ParseEventFrom(const char *event_from)
ax::mojom::TextAffinity ParseTextAffinity(const char *text_affinity)
ax::mojom::Dropeffect ParseDropeffect(const char *dropeffect)
ax::mojom::BoolAttribute ParseBoolAttribute(const char *bool_attribute)
ax::mojom::DefaultActionVerb ParseDefaultActionVerb(const char *default_action_verb)
ax::mojom::TextDecorationStyle ParseTextDecorationStyle(const char *text_decoration_style)
ax::mojom::AriaCurrentState ParseAriaCurrentState(const char *aria_current_state)
void TestEnumStringConversion(T(ParseFunction)(const char *), int32_t(step)(int32_t)=[](int32_t val) { return val+1;})
ax::mojom::InvalidState ParseInvalidState(const char *invalid_state)
ax::mojom::MarkerType ParseMarkerType(const char *marker_type)
ax::mojom::ImageAnnotationStatus ParseImageAnnotationStatus(const char *status)
ax::mojom::CheckedState ParseCheckedState(const char *checked_state)
ax::mojom::Mutation ParseMutation(const char *mutation)
ax::mojom::Gesture ParseGesture(const char *gesture)
ax::mojom::State ParseState(const char *state)
ax::mojom::TextStyle ParseTextStyle(const char *text_style)
void AddFloatAttribute(ax::mojom::FloatAttribute attribute, float value)
void AddIntListAttribute(ax::mojom::IntListAttribute attribute, const std::vector< int32_t > &value)
void AddIntAttribute(ax::mojom::IntAttribute attribute, int32_t value)
void AddStringListAttribute(ax::mojom::StringListAttribute attribute, const std::vector< std::string > &value)
virtual std::string ToString() const
void AddStringAttribute(ax::mojom::StringAttribute attribute, const std::string &value)
void AddBoolAttribute(ax::mojom::BoolAttribute attribute, bool value)
#define EXPECT_TRUE(handle)