Flutter Engine
The Flutter Engine
ax_role_properties_unittest.cc
Go to the documentation of this file.
1// Copyright 2019 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 <unordered_set>
6
7#include "gtest/gtest.h"
8
9#include "ax_enum_util.h"
10#include "ax_enums.h"
11#include "ax_role_properties.h"
12
13namespace ui {
14
15TEST(AXRolePropertiesTest, TestSupportsHierarchicalLevel) {
16 // Test for iterating through all roles and validate if a role supports
17 // hierarchical level.
18 std::unordered_set<ax::mojom::Role>
19 roles_expected_supports_hierarchical_level = {
23
24 for (int role_idx = static_cast<int>(ax::mojom::Role::kMinValue);
25 role_idx <= static_cast<int>(ax::mojom::Role::kMaxValue); role_idx++) {
26 ax::mojom::Role role = static_cast<ax::mojom::Role>(role_idx);
27 bool supports_hierarchical_level = SupportsHierarchicalLevel(role);
28
29 SCOPED_TRACE(testing::Message() << "ax::mojom::Role=" << ToString(role)
30 << ", Actual: supportsHierarchicalLevel="
31 << supports_hierarchical_level
32 << ", Expected: supportsHierarchicalLevel="
33 << !supports_hierarchical_level);
34
35 if (roles_expected_supports_hierarchical_level.find(role) !=
36 roles_expected_supports_hierarchical_level.end())
37 EXPECT_TRUE(supports_hierarchical_level);
38 else
39 EXPECT_FALSE(supports_hierarchical_level);
40 }
41}
42
43TEST(AXRolePropertiesTest, TestSupportsToggle) {
44 // Test for iterating through all roles and validate if a role supports
45 // toggle.
46 std::unordered_set<ax::mojom::Role> roles_expected_supports_toggle = {
49
50 for (int role_idx = static_cast<int>(ax::mojom::Role::kMinValue);
51 role_idx <= static_cast<int>(ax::mojom::Role::kMaxValue); role_idx++) {
52 ax::mojom::Role role = static_cast<ax::mojom::Role>(role_idx);
53 bool supports_toggle = SupportsToggle(role);
54
55 SCOPED_TRACE(testing::Message()
56 << "ax::mojom::Role=" << ToString(role)
57 << ", Actual: supportsToggle=" << supports_toggle
58 << ", Expected: supportsToggle=" << !supports_toggle);
59
60 if (roles_expected_supports_toggle.find(role) !=
61 roles_expected_supports_toggle.end())
62 EXPECT_TRUE(supports_toggle);
63 else
64 EXPECT_FALSE(supports_toggle);
65 }
66}
67} // namespace ui
TEST(AXEnumUtilTest, Event)
const char * ToString(ax::mojom::Event event)
Definition: ax_enum_util.cc:9
bool SupportsHierarchicalLevel(const ax::mojom::Role role)
bool SupportsToggle(const ax::mojom::Role role)
#define EXPECT_TRUE(handle)
Definition: unit_test.h:678