Skip to content

Commit 3ea92d2

Browse files
gmackallGray Mackall
authored andcommitted
Fix verified input integration test without breaking the rest of the devicelab tests (attempt 5) (flutter#178093)
Reland of flutter#178018 On top of the above: Only gets the adb path if it is an android test, and also try catches to be doubly safe. Note that the above PR did work for the android case, so as long as we don't break the non-android case the test will be running now: https://ci.chromium.org/ui/p/flutter/builders/staging/Linux_pixel_7pro%20android_verified_input_test/228/overview ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --------- Co-authored-by: Gray Mackall <mackall@google.com>
1 parent d67bf69 commit 3ea92d2

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

dev/devicelab/lib/tasks/integration_tests.dart

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import '../framework/devices.dart';
66
import '../framework/framework.dart';
7-
import '../framework/talkback.dart';
7+
import '../framework/talkback.dart' hide adbPath;
88
import '../framework/task_result.dart';
99
import '../framework/utils.dart';
1010

@@ -265,20 +265,38 @@ class DriverTest {
265265
Future<TaskResult> call() {
266266
return inDirectory<TaskResult>(testDirectory, () async {
267267
String deviceId;
268+
Device? selectedDevice;
268269
if (deviceIdOverride != null) {
269270
deviceId = deviceIdOverride!;
270271
} else {
271-
final Device device = await devices.workingDevice;
272-
await device.unlock();
273-
deviceId = device.deviceId;
272+
selectedDevice = await devices.workingDevice;
273+
await selectedDevice.unlock();
274+
deviceId = selectedDevice.deviceId;
274275
}
275276
await flutter('packages', options: <String>['get']);
276277

278+
final bool isAndroidRun = selectedDevice != null
279+
? selectedDevice is AndroidDevice
280+
: const <DeviceOperatingSystem>{
281+
DeviceOperatingSystem.android,
282+
DeviceOperatingSystem.androidArm,
283+
DeviceOperatingSystem.androidArm64,
284+
}.contains(deviceOperatingSystem);
285+
286+
String? devicelabAdbPath;
287+
if (isAndroidRun) {
288+
try {
289+
devicelabAdbPath = adbPath;
290+
} on DeviceException {
291+
devicelabAdbPath = null;
292+
}
293+
}
277294
// Make the device ID available in the driver code, so tools like ADB can
278295
// reference it if needed.
279296
final Map<String, String> env = <String, String>{
280297
if (environment != null) ...environment!,
281-
'DEVICE_ID_NUMBER': deviceId,
298+
'FLUTTER_DEVICE_ID_NUMBER': deviceId,
299+
if (devicelabAdbPath != null) 'FLUTTER_ADB_PATH': devicelabAdbPath,
282300
};
283301

284302
final List<String> options = <String>[

dev/integration_tests/android_verified_input/test_driver/main_test.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ Future<void> main() async {
2828
final Future<String> inputEventWasVerified = driver.requestData('input_was_verified');
2929

3030
// Passed in by the driver task.
31-
final String? deviceId = Platform.environment['DEVICE_ID_NUMBER'];
31+
final String? deviceId = Platform.environment['FLUTTER_DEVICE_ID_NUMBER'];
32+
final String? adbPath = Platform.environment['FLUTTER_ADB_PATH'];
3233

3334
// Keep issuing taps until we get the requested data. The actual setup
3435
// of the platform view is asynchronous so we might have to tap more than
@@ -37,7 +38,7 @@ Future<void> main() async {
3738
inputEventWasVerified.whenComplete(() => stop = true);
3839
while (!stop) {
3940
// We must use the Android input tool to get verified input events.
40-
final ProcessResult result = await Process.run('adb', <String>[
41+
final ProcessResult result = await Process.run(adbPath ?? 'adb', <String>[
4142
if (deviceId != null) ...<String>['-s', deviceId],
4243
'shell',
4344
'input',

0 commit comments

Comments
 (0)