@@ -46,13 +46,14 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistent) {
46
46
47
47
auto & context = GetEmbedderContext (EmbedderTestContextType::kOpenGLContext );
48
48
49
- fml::AutoResetWaitableEvent latch ;
49
+ fml::AutoResetWaitableEvent signal_native_latch ;
50
50
51
51
// Called by the Dart text fixture on the UI thread to signal that the C++
52
52
// unittest should resume.
53
53
context.AddNativeCallback (
54
- " SignalNativeTest" , CREATE_NATIVE_ENTRY (([&latch](Dart_NativeArguments) {
55
- latch.Signal ();
54
+ " SignalNativeTest" ,
55
+ CREATE_NATIVE_ENTRY (([&signal_native_latch](Dart_NativeArguments) {
56
+ signal_native_latch.Signal ();
56
57
})));
57
58
58
59
// Called by test fixture on UI thread to pass data back to this test.
@@ -120,14 +121,15 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistent) {
120
121
ASSERT_TRUE (engine.is_valid ());
121
122
122
123
// Wait for initial NotifySemanticsEnabled(false).
124
+ fml::AutoResetWaitableEvent notify_semantics_enabled_latch;
123
125
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
124
126
bool enabled = true ;
125
127
auto handle = Dart_GetNativeBooleanArgument (args, 0 , &enabled);
126
128
ASSERT_FALSE (Dart_IsError (handle));
127
129
ASSERT_FALSE (enabled);
128
- latch .Signal ();
130
+ notify_semantics_enabled_latch .Signal ();
129
131
};
130
- latch .Wait ();
132
+ notify_semantics_enabled_latch .Wait ();
131
133
132
134
// Prepare to NotifyAccessibilityFeatures call
133
135
fml::AutoResetWaitableEvent notify_features_latch;
@@ -140,39 +142,42 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistent) {
140
142
};
141
143
142
144
// Enable semantics. Wait for NotifySemanticsEnabled(true).
145
+ fml::AutoResetWaitableEvent notify_semantics_enabled_latch_2;
143
146
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
144
147
bool enabled = false ;
145
148
auto handle = Dart_GetNativeBooleanArgument (args, 0 , &enabled);
146
149
ASSERT_FALSE (Dart_IsError (handle));
147
150
ASSERT_TRUE (enabled);
148
- latch .Signal ();
151
+ notify_semantics_enabled_latch_2 .Signal ();
149
152
};
150
153
auto result = FlutterEngineUpdateSemanticsEnabled (engine.get (), true );
151
154
ASSERT_EQ (result, FlutterEngineResult::kSuccess );
152
- latch .Wait ();
155
+ notify_semantics_enabled_latch_2 .Wait ();
153
156
154
157
// Wait for initial accessibility features (reduce_motion == false)
155
158
notify_features_latch.Wait ();
156
159
157
160
// Set accessibility features: (reduce_motion == true)
161
+ fml::AutoResetWaitableEvent notify_features_latch_2;
158
162
notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
159
163
bool enabled = false ;
160
164
auto handle = Dart_GetNativeBooleanArgument (args, 0 , &enabled);
161
165
ASSERT_FALSE (Dart_IsError (handle));
162
166
ASSERT_TRUE (enabled);
163
- latch .Signal ();
167
+ notify_features_latch_2 .Signal ();
164
168
};
165
169
result = FlutterEngineUpdateAccessibilityFeatures (
166
170
engine.get (), kFlutterAccessibilityFeatureReduceMotion );
167
171
ASSERT_EQ (result, FlutterEngineResult::kSuccess );
168
- latch .Wait ();
172
+ notify_features_latch_2 .Wait ();
169
173
170
174
// Wait for UpdateSemantics callback on platform (current) thread.
171
- latch .Wait ();
175
+ signal_native_latch .Wait ();
172
176
fml::MessageLoop::GetCurrent ().RunExpiredTasksNow ();
173
177
semantics_update_latch.Wait ();
174
178
175
179
// Dispatch a tap to semantics node 42. Wait for NotifySemanticsAction.
180
+ fml::AutoResetWaitableEvent notify_semantics_action_latch;
176
181
notify_semantics_action_callback = [&](Dart_NativeArguments args) {
177
182
int64_t node_id = 0 ;
178
183
Dart_GetNativeIntegerArgument (args, 0 , &node_id);
@@ -192,36 +197,38 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistent) {
192
197
dart_int = Dart_ListGetAt (semantic_args, 1 );
193
198
Dart_IntegerToInt64 (dart_int, &data);
194
199
ASSERT_EQ (1 , data);
195
- latch .Signal ();
200
+ notify_semantics_action_latch .Signal ();
196
201
};
197
202
std::vector<uint8_t > bytes ({2 , 1 });
198
203
result = FlutterEngineDispatchSemanticsAction (
199
204
engine.get (), 42 , kFlutterSemanticsActionTap , &bytes[0 ], bytes.size ());
200
205
ASSERT_EQ (result, FlutterEngineResult::kSuccess );
201
- latch .Wait ();
206
+ notify_semantics_action_latch .Wait ();
202
207
203
208
// Disable semantics. Wait for NotifySemanticsEnabled(false).
209
+ fml::AutoResetWaitableEvent notify_semantics_enabled_latch_3;
204
210
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
205
211
bool enabled = true ;
206
212
Dart_GetNativeBooleanArgument (args, 0 , &enabled);
207
213
ASSERT_FALSE (enabled);
208
- latch .Signal ();
214
+ notify_semantics_enabled_latch_3 .Signal ();
209
215
};
210
216
result = FlutterEngineUpdateSemanticsEnabled (engine.get (), false );
211
217
ASSERT_EQ (result, FlutterEngineResult::kSuccess );
212
- latch .Wait ();
218
+ notify_semantics_enabled_latch_3 .Wait ();
213
219
}
214
220
215
221
TEST_F (EmbedderA11yTest, A11yTreeIsConsistentUsingLegacyCallbacks) {
216
222
auto & context = GetEmbedderContext (EmbedderTestContextType::kOpenGLContext );
217
223
218
- fml::AutoResetWaitableEvent latch ;
224
+ fml::AutoResetWaitableEvent signal_native_latch ;
219
225
220
226
// Called by the Dart text fixture on the UI thread to signal that the C++
221
227
// unittest should resume.
222
228
context.AddNativeCallback (
223
- " SignalNativeTest" , CREATE_NATIVE_ENTRY (([&latch](Dart_NativeArguments) {
224
- latch.Signal ();
229
+ " SignalNativeTest" ,
230
+ CREATE_NATIVE_ENTRY (([&signal_native_latch](Dart_NativeArguments) {
231
+ signal_native_latch.Signal ();
225
232
})));
226
233
227
234
// Called by test fixture on UI thread to pass data back to this test.
@@ -310,14 +317,15 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingLegacyCallbacks) {
310
317
ASSERT_TRUE (engine.is_valid ());
311
318
312
319
// Wait for initial NotifySemanticsEnabled(false).
320
+ fml::AutoResetWaitableEvent notify_semantics_enabled_latch;
313
321
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
314
322
bool enabled = true ;
315
323
auto handle = Dart_GetNativeBooleanArgument (args, 0 , &enabled);
316
324
ASSERT_FALSE (Dart_IsError (handle));
317
325
ASSERT_FALSE (enabled);
318
- latch .Signal ();
326
+ notify_semantics_enabled_latch .Signal ();
319
327
};
320
- latch .Wait ();
328
+ notify_semantics_enabled_latch .Wait ();
321
329
322
330
// Prepare to NotifyAccessibilityFeatures call
323
331
fml::AutoResetWaitableEvent notify_features_latch;
@@ -330,35 +338,37 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingLegacyCallbacks) {
330
338
};
331
339
332
340
// Enable semantics. Wait for NotifySemanticsEnabled(true).
341
+ fml::AutoResetWaitableEvent notify_semantics_enabled_latch_2;
333
342
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
334
343
bool enabled = false ;
335
344
auto handle = Dart_GetNativeBooleanArgument (args, 0 , &enabled);
336
345
ASSERT_FALSE (Dart_IsError (handle));
337
346
ASSERT_TRUE (enabled);
338
- latch .Signal ();
347
+ notify_semantics_enabled_latch_2 .Signal ();
339
348
};
340
349
auto result = FlutterEngineUpdateSemanticsEnabled (engine.get (), true );
341
350
ASSERT_EQ (result, FlutterEngineResult::kSuccess );
342
- latch .Wait ();
351
+ notify_semantics_enabled_latch_2 .Wait ();
343
352
344
353
// Wait for initial accessibility features (reduce_motion == false)
345
354
notify_features_latch.Wait ();
346
355
347
356
// Set accessibility features: (reduce_motion == true)
357
+ fml::AutoResetWaitableEvent notify_features_latch_2;
348
358
notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
349
359
bool enabled = false ;
350
360
auto handle = Dart_GetNativeBooleanArgument (args, 0 , &enabled);
351
361
ASSERT_FALSE (Dart_IsError (handle));
352
362
ASSERT_TRUE (enabled);
353
- latch .Signal ();
363
+ notify_features_latch_2 .Signal ();
354
364
};
355
365
result = FlutterEngineUpdateAccessibilityFeatures (
356
366
engine.get (), kFlutterAccessibilityFeatureReduceMotion );
357
367
ASSERT_EQ (result, FlutterEngineResult::kSuccess );
358
- latch .Wait ();
368
+ notify_features_latch_2 .Wait ();
359
369
360
370
// Wait for UpdateSemantics callback on platform (current) thread.
361
- latch .Wait ();
371
+ signal_native_latch .Wait ();
362
372
fml::MessageLoop::GetCurrent ().RunExpiredTasksNow ();
363
373
semantics_node_latch.Wait ();
364
374
semantics_action_latch.Wait ();
@@ -368,6 +378,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingLegacyCallbacks) {
368
378
ASSERT_EQ (1 , action_batch_end_count);
369
379
370
380
// Dispatch a tap to semantics node 42. Wait for NotifySemanticsAction.
381
+ fml::AutoResetWaitableEvent notify_semantics_action_latch;
371
382
notify_semantics_action_callback = [&](Dart_NativeArguments args) {
372
383
int64_t node_id = 0 ;
373
384
Dart_GetNativeIntegerArgument (args, 0 , &node_id);
@@ -387,24 +398,25 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingLegacyCallbacks) {
387
398
dart_int = Dart_ListGetAt (semantic_args, 1 );
388
399
Dart_IntegerToInt64 (dart_int, &data);
389
400
ASSERT_EQ (1 , data);
390
- latch .Signal ();
401
+ notify_semantics_action_latch .Signal ();
391
402
};
392
403
std::vector<uint8_t > bytes ({2 , 1 });
393
404
result = FlutterEngineDispatchSemanticsAction (
394
405
engine.get (), 42 , kFlutterSemanticsActionTap , &bytes[0 ], bytes.size ());
395
406
ASSERT_EQ (result, FlutterEngineResult::kSuccess );
396
- latch .Wait ();
407
+ notify_semantics_action_latch .Wait ();
397
408
398
409
// Disable semantics. Wait for NotifySemanticsEnabled(false).
410
+ fml::AutoResetWaitableEvent notify_semantics_enabled_latch_3;
399
411
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
400
412
bool enabled = true ;
401
413
Dart_GetNativeBooleanArgument (args, 0 , &enabled);
402
414
ASSERT_FALSE (enabled);
403
- latch .Signal ();
415
+ notify_semantics_enabled_latch_3 .Signal ();
404
416
};
405
417
result = FlutterEngineUpdateSemanticsEnabled (engine.get (), false );
406
418
ASSERT_EQ (result, FlutterEngineResult::kSuccess );
407
- latch .Wait ();
419
+ notify_semantics_enabled_latch_3 .Wait ();
408
420
}
409
421
410
422
} // namespace testing
0 commit comments