Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ec2621f

Browse files
authored
Force a11y services to off for complex_layout_semantics_perf test (#108906)
1 parent c6aeaa3 commit ec2621f

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

dev/benchmarks/complex_layout/test_driver/semantics_perf_test.dart

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ void main() {
1515
late FlutterDriver driver;
1616

1717
setUpAll(() async {
18+
// Turn off any accessibility services that may be running. The purpose of
19+
// the test is to measure the time it takes to create the initial
20+
// semantics tree in isolation. If accessibility services are on, the
21+
// semantics tree gets generated during the first frame and we can't
22+
// measure it in isolation.
23+
final Process run = await Process.start(_adbPath(), const <String>[
24+
'shell',
25+
'settings',
26+
'put',
27+
'secure',
28+
'enabled_accessibility_services',
29+
'null',
30+
]);
31+
await run.exitCode;
32+
1833
driver = await FlutterDriver.connect(printCommunication: true);
1934
});
2035

@@ -31,7 +46,13 @@ void main() {
3146
await driver.forceGC();
3247

3348
final Timeline timeline = await driver.traceAction(() async {
34-
expect(await driver.setSemantics(true), isTrue);
49+
expect(
50+
await driver.setSemantics(true),
51+
isTrue,
52+
reason: 'Could not toggle semantics to on because semantics were already '
53+
'on, but the test needs to toggle semantics to measure the initial '
54+
'semantics tree generation in isolation.'
55+
);
3556
});
3657

3758
final Iterable<TimelineEvent>? semanticsEvents = timeline.events?.where((TimelineEvent event) => event.name == 'SEMANTICS');
@@ -45,3 +66,12 @@ void main() {
4566
}, timeout: Timeout.none);
4667
});
4768
}
69+
70+
String _adbPath() {
71+
final String? androidHome = Platform.environment['ANDROID_HOME'] ?? Platform.environment['ANDROID_SDK_ROOT'];
72+
if (androidHome == null) {
73+
return 'adb';
74+
} else {
75+
return p.join(androidHome, 'platform-tools', 'adb');
76+
}
77+
}

0 commit comments

Comments
 (0)