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"
14TEST(PlatformViewShell, UpdateSemanticsDoesFlutterViewUpdateSemantics) {
15 auto jni_mock = std::make_shared<JNIMock>();
16 auto delegate = std::make_unique<PlatformViewAndroidDelegate>(jni_mock);
22 node0.
label =
"label";
24 update.insert(std::make_pair(0, node0));
26 std::vector<uint8_t> expected_buffer(192);
27 std::vector<std::vector<uint8_t>> expected_string_attribute_args(0);
29 int32_t* buffer_int32 =
reinterpret_cast<int32_t*
>(&expected_buffer[0]);
30 float* buffer_float32 =
reinterpret_cast<float*
>(&expected_buffer[0]);
31 std::vector<std::string> expected_strings;
32 buffer_int32[position++] = node0.
id;
33 buffer_int32[position++] = node0.
flags;
34 buffer_int32[position++] = node0.
actions;
42 buffer_float32[position++] =
static_cast<float>(node0.
scrollPosition);
45 buffer_int32[position++] = expected_strings.size();
47 buffer_int32[position++] = expected_strings.size();
48 expected_strings.push_back(node0.
label);
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++] = -1;
56 buffer_int32[position++] = -1;
57 buffer_int32[position++] = -1;
58 buffer_int32[position++] = expected_strings.size();
59 expected_strings.push_back(node0.
tooltip);
61 buffer_float32[position++] = node0.
rect.
left();
62 buffer_float32[position++] = node0.
rect.
top();
63 buffer_float32[position++] = node0.
rect.
right();
64 buffer_float32[position++] = node0.
rect.
bottom();
67 buffer_int32[position++] = 0;
68 buffer_int32[position++] = 0;
69 EXPECT_CALL(*jni_mock,
70 FlutterViewUpdateSemantics(expected_buffer, expected_strings,
71 expected_string_attribute_args));
74 delegate->UpdateSemantics(
update, actions);
78 UpdateSemanticsDoesFlutterViewUpdateSemanticsWithStringAttribtes) {
79 auto jni_mock = std::make_shared<JNIMock>();
80 auto delegate = std::make_unique<PlatformViewAndroidDelegate>(jni_mock);
84 std::shared_ptr<SpellOutStringAttribute> spell_out_attribute =
85 std::make_shared<SpellOutStringAttribute>();
86 spell_out_attribute->start = 2;
87 spell_out_attribute->end = 4;
89 std::shared_ptr<LocaleStringAttribute> locale_attribute =
90 std::make_shared<LocaleStringAttribute>();
91 locale_attribute->start = 1;
92 locale_attribute->end = 3;
94 locale_attribute->locale =
"en-US";
97 node0.
label =
"label";
101 update.insert(std::make_pair(0, node0));
103 std::vector<uint8_t> expected_buffer(224);
104 std::vector<std::vector<uint8_t>> expected_string_attribute_args;
106 int32_t* buffer_int32 =
reinterpret_cast<int32_t*
>(&expected_buffer[0]);
107 float* buffer_float32 =
reinterpret_cast<float*
>(&expected_buffer[0]);
108 std::vector<std::string> expected_strings;
109 buffer_int32[position++] = node0.
id;
110 buffer_int32[position++] = node0.
flags;
111 buffer_int32[position++] = node0.
actions;
119 buffer_float32[position++] =
static_cast<float>(node0.
scrollPosition);
120 buffer_float32[position++] =
static_cast<float>(node0.
scrollExtentMax);
121 buffer_float32[position++] =
static_cast<float>(node0.
scrollExtentMin);
122 buffer_int32[position++] = expected_strings.size();
124 buffer_int32[position++] = expected_strings.size();
125 expected_strings.push_back(node0.
label);
126 buffer_int32[position++] = 1;
127 buffer_int32[position++] = 2;
128 buffer_int32[position++] = 4;
129 buffer_int32[position++] = 0;
130 buffer_int32[position++] = -1;
131 buffer_int32[position++] = -1;
132 buffer_int32[position++] = -1;
133 buffer_int32[position++] = -1;
134 buffer_int32[position++] = -1;
135 buffer_int32[position++] = -1;
136 buffer_int32[position++] = -1;
137 buffer_int32[position++] = expected_strings.size();
138 expected_strings.push_back(node0.
hint);
139 buffer_int32[position++] = 1;
140 buffer_int32[position++] = 1;
141 buffer_int32[position++] = 3;
142 buffer_int32[position++] = 1;
143 buffer_int32[position++] =
144 expected_string_attribute_args.size();
145 expected_string_attribute_args.push_back(
146 {locale_attribute->locale.begin(), locale_attribute->locale.end()});
147 buffer_int32[position++] = -1;
149 buffer_float32[position++] = node0.
rect.
left();
150 buffer_float32[position++] = node0.
rect.
top();
151 buffer_float32[position++] = node0.
rect.
right();
152 buffer_float32[position++] = node0.
rect.
bottom();
155 buffer_int32[position++] = 0;
156 buffer_int32[position++] = 0;
157 EXPECT_CALL(*jni_mock,
158 FlutterViewUpdateSemantics(expected_buffer, expected_strings,
159 expected_string_attribute_args));
162 delegate->UpdateSemantics(
update, actions);
166 UpdateSemanticsDoesFlutterViewUpdateCustomAccessibilityActions) {
167 auto jni_mock = std::make_shared<JNIMock>();
168 auto delegate = std::make_unique<PlatformViewAndroidDelegate>(jni_mock);
174 action0.
label =
"label";
175 action0.
hint =
"hint";
176 actions.insert(std::make_pair(0, action0));
178 std::vector<uint8_t> expected_actions_buffer(16);
179 int32_t* actions_buffer_int32 =
180 reinterpret_cast<int32_t*
>(&expected_actions_buffer[0]);
181 std::vector<std::string> expected_action_strings;
182 actions_buffer_int32[0] = action0.
id;
184 actions_buffer_int32[2] = expected_action_strings.size();
185 expected_action_strings.push_back(action0.
label);
186 actions_buffer_int32[3] = expected_action_strings.size();
187 expected_action_strings.push_back(action0.
hint);
189 EXPECT_CALL(*jni_mock, FlutterViewUpdateCustomAccessibilityActions(
190 expected_actions_buffer, expected_action_strings));
193 delegate->UpdateSemantics(
update, actions);
void getColMajor(SkScalar v[]) const
TEST(DisplayListComplexity, EmptyDisplayList)
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
std::unordered_map< int32_t, CustomAccessibilityAction > CustomAccessibilityActionUpdates
constexpr float left() const
constexpr float top() const
constexpr float right() const
constexpr float bottom() const
StringAttributes hintAttributes
StringAttributes labelAttributes
int32_t textSelectionExtent
int32_t currentValueLength
int32_t textSelectionBase