diff --git a/dev/benchmarks/complex_layout/test_driver/semantics_perf_test.dart b/dev/benchmarks/complex_layout/test_driver/semantics_perf_test.dart index 9df73ccbda..ecd926b376 100644 --- a/dev/benchmarks/complex_layout/test_driver/semantics_perf_test.dart +++ b/dev/benchmarks/complex_layout/test_driver/semantics_perf_test.dart @@ -15,6 +15,21 @@ void main() { late FlutterDriver driver; setUpAll(() async { + // Turn off any accessibility services that may be running. The purpose of + // the test is to measure the time it takes to create the initial + // semantics tree in isolation. If accessibility services are on, the + // semantics tree gets generated during the first frame and we can't + // measure it in isolation. + final Process run = await Process.start(_adbPath(), const [ + 'shell', + 'settings', + 'put', + 'secure', + 'enabled_accessibility_services', + 'null', + ]); + await run.exitCode; + driver = await FlutterDriver.connect(printCommunication: true); }); @@ -31,7 +46,13 @@ void main() { await driver.forceGC(); final Timeline timeline = await driver.traceAction(() async { - expect(await driver.setSemantics(true), isTrue); + expect( + await driver.setSemantics(true), + isTrue, + reason: 'Could not toggle semantics to on because semantics were already ' + 'on, but the test needs to toggle semantics to measure the initial ' + 'semantics tree generation in isolation.' + ); }); final Iterable? semanticsEvents = timeline.events?.where((TimelineEvent event) => event.name == 'SEMANTICS'); @@ -45,3 +66,12 @@ void main() { }, timeout: Timeout.none); }); } + +String _adbPath() { + final String? androidHome = Platform.environment['ANDROID_HOME'] ?? Platform.environment['ANDROID_SDK_ROOT']; + if (androidHome == null) { + return 'adb'; + } else { + return p.join(androidHome, 'platform-tools', 'adb'); + } +}