5 #include "flutter/shell/platform/android/platform_view_android_delegate/platform_view_android_delegate.h" 7 #include "flutter/shell/platform/android/jni/jni_mock.h" 8 #include "gmock/gmock.h" 9 #include "gtest/gtest.h" 14 TEST(PlatformViewShell, UpdateSemanticsDoesFlutterViewUpdateSemantics) {
15 auto jni_mock = std::make_shared<JNIMock>();
16 auto delegate = std::make_unique<PlatformViewAndroidDelegate>(jni_mock);
21 node0.
label =
"label";
23 update.insert(std::make_pair(0, std::move(node0)));
25 std::vector<uint8_t> expected_buffer(188);
26 std::vector<std::vector<uint8_t>> expected_string_attribute_args(0);
28 int32_t* buffer_int32 =
reinterpret_cast<int32_t*
>(&expected_buffer[0]);
29 float* buffer_float32 =
reinterpret_cast<float*
>(&expected_buffer[0]);
30 std::vector<std::string> expected_strings;
31 buffer_int32[position++] = node0.
id;
32 buffer_int32[position++] = node0.
flags;
33 buffer_int32[position++] = node0.
actions;
41 buffer_float32[position++] =
static_cast<float>(node0.
scrollPosition);
44 buffer_int32[position++] = expected_strings.size();
45 expected_strings.push_back(node0.
label);
46 buffer_int32[position++] = -1;
47 buffer_int32[position++] = -1;
48 buffer_int32[position++] = -1;
49 buffer_int32[position++] = -1;
50 buffer_int32[position++] = -1;
51 buffer_int32[position++] = -1;
52 buffer_int32[position++] = -1;
53 buffer_int32[position++] = -1;
54 buffer_int32[position++] = -1;
55 buffer_int32[position++] = expected_strings.size();
56 expected_strings.push_back(node0.
tooltip);
58 buffer_float32[position++] = node0.
rect.left();
59 buffer_float32[position++] = node0.
rect.top();
60 buffer_float32[position++] = node0.
rect.right();
61 buffer_float32[position++] = node0.
rect.bottom();
62 node0.
transform.getColMajor(&buffer_float32[position]);
64 buffer_int32[position++] = 0;
65 buffer_int32[position++] = 0;
66 EXPECT_CALL(*jni_mock,
67 FlutterViewUpdateSemantics(expected_buffer, expected_strings,
68 expected_string_attribute_args));
71 delegate->UpdateSemantics(update, actions);
75 UpdateSemanticsDoesFlutterViewUpdateSemanticsWithStringAttribtes) {
76 auto jni_mock = std::make_shared<JNIMock>();
77 auto delegate = std::make_unique<PlatformViewAndroidDelegate>(jni_mock);
81 std::shared_ptr<SpellOutStringAttribute> spell_out_attribute =
82 std::make_shared<SpellOutStringAttribute>();
83 spell_out_attribute->start = 2;
84 spell_out_attribute->end = 4;
86 std::shared_ptr<LocaleStringAttribute> locale_attribute =
87 std::make_shared<LocaleStringAttribute>();
88 locale_attribute->start = 1;
89 locale_attribute->end = 3;
91 locale_attribute->locale =
"en-US";
93 node0.
label =
"label";
97 update.insert(std::make_pair(0, std::move(node0)));
99 std::vector<uint8_t> expected_buffer(220);
100 std::vector<std::vector<uint8_t>> expected_string_attribute_args;
102 int32_t* buffer_int32 =
reinterpret_cast<int32_t*
>(&expected_buffer[0]);
103 float* buffer_float32 =
reinterpret_cast<float*
>(&expected_buffer[0]);
104 std::vector<std::string> expected_strings;
105 buffer_int32[position++] = node0.
id;
106 buffer_int32[position++] = node0.
flags;
107 buffer_int32[position++] = node0.
actions;
115 buffer_float32[position++] =
static_cast<float>(node0.
scrollPosition);
116 buffer_float32[position++] =
static_cast<float>(node0.
scrollExtentMax);
117 buffer_float32[position++] =
static_cast<float>(node0.
scrollExtentMin);
118 buffer_int32[position++] = expected_strings.size();
119 expected_strings.push_back(node0.
label);
120 buffer_int32[position++] = 1;
121 buffer_int32[position++] = 2;
122 buffer_int32[position++] = 4;
123 buffer_int32[position++] = 0;
124 buffer_int32[position++] = -1;
125 buffer_int32[position++] = -1;
126 buffer_int32[position++] = -1;
127 buffer_int32[position++] = -1;
128 buffer_int32[position++] = -1;
129 buffer_int32[position++] = -1;
130 buffer_int32[position++] = -1;
131 buffer_int32[position++] = expected_strings.size();
132 expected_strings.push_back(node0.
hint);
133 buffer_int32[position++] = 1;
134 buffer_int32[position++] = 1;
135 buffer_int32[position++] = 3;
136 buffer_int32[position++] = 1;
137 buffer_int32[position++] =
138 expected_string_attribute_args.size();
139 expected_string_attribute_args.push_back(
140 {locale_attribute->locale.begin(), locale_attribute->locale.end()});
141 buffer_int32[position++] = -1;
143 buffer_float32[position++] = node0.
rect.left();
144 buffer_float32[position++] = node0.
rect.top();
145 buffer_float32[position++] = node0.
rect.right();
146 buffer_float32[position++] = node0.
rect.bottom();
147 node0.
transform.getColMajor(&buffer_float32[position]);
149 buffer_int32[position++] = 0;
150 buffer_int32[position++] = 0;
151 EXPECT_CALL(*jni_mock,
152 FlutterViewUpdateSemantics(expected_buffer, expected_strings,
153 expected_string_attribute_args));
156 delegate->UpdateSemantics(update, actions);
160 UpdateSemanticsDoesFlutterViewUpdateCustomAccessibilityActions) {
161 auto jni_mock = std::make_shared<JNIMock>();
162 auto delegate = std::make_unique<PlatformViewAndroidDelegate>(jni_mock);
168 action0.
label =
"label";
169 action0.
hint =
"hint";
170 actions.insert(std::make_pair(0, std::move(action0)));
172 std::vector<uint8_t> expected_actions_buffer(16);
173 int32_t* actions_buffer_int32 =
174 reinterpret_cast<int32_t*
>(&expected_actions_buffer[0]);
175 std::vector<std::string> expected_action_strings;
176 actions_buffer_int32[0] = action0.
id;
178 actions_buffer_int32[2] = expected_action_strings.size();
179 expected_action_strings.push_back(action0.
label);
180 actions_buffer_int32[3] = expected_action_strings.size();
181 expected_action_strings.push_back(action0.
hint);
183 EXPECT_CALL(*jni_mock, FlutterViewUpdateCustomAccessibilityActions(
184 expected_actions_buffer, expected_action_strings));
187 delegate->UpdateSemantics(update, actions);
int32_t textSelectionBase
TEST(DisplayListColorFilter, BuilderSetGet)
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
int32_t currentValueLength
int32_t textSelectionExtent
StringAttributes hintAttributes
StringAttributes labelAttributes
std::unordered_map< int32_t, CustomAccessibilityAction > CustomAccessibilityActionUpdates