Unverified Commit 11bf7f06 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Take screenshots of wirelessly paired iOS devices (#60623)

parent 60deae85
......@@ -509,11 +509,11 @@ class IOSDevice extends Device {
void clearLogs() { }
@override
bool get supportsScreenshot => _iMobileDevice.isInstalled && interfaceType == IOSDeviceInterface.usb;
bool get supportsScreenshot => _iMobileDevice.isInstalled;
@override
Future<void> takeScreenshot(File outputFile) async {
await _iMobileDevice.takeScreenshot(outputFile, id);
await _iMobileDevice.takeScreenshot(outputFile, id, interfaceType);
}
@override
......
......@@ -24,6 +24,7 @@ import '../macos/xcode.dart';
import '../project.dart';
import '../reporting/reporting.dart';
import 'code_signing.dart';
import 'devices.dart';
import 'migrations/ios_migrator.dart';
import 'migrations/project_base_configuration_migration.dart';
import 'migrations/remove_framework_link_and_embedding_migration.dart';
......@@ -66,13 +67,19 @@ class IMobileDevice {
}
/// Captures a screenshot to the specified outputFile.
Future<void> takeScreenshot(File outputFile, String deviceID) {
Future<void> takeScreenshot(
File outputFile,
String deviceID,
IOSDeviceInterface interfaceType,
) {
return _processUtils.run(
<String>[
_idevicescreenshotPath,
outputFile.path,
'--udid',
deviceID,
if (interfaceType == IOSDeviceInterface.network)
'--network',
],
throwOnError: true,
environment: Map<String, String>.fromEntries(
......
......@@ -14,6 +14,7 @@ import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/process.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/ios/devices.dart';
import 'package:flutter_tools/src/ios/mac.dart';
import 'package:flutter_tools/src/ios/xcodeproj.dart';
import 'package:flutter_tools/src/project.dart';
......@@ -85,10 +86,14 @@ void main() {
logger: logger,
);
expect(() async => await iMobileDevice.takeScreenshot(mockOutputFile, '1234'), throwsA(anything));
expect(() async => await iMobileDevice.takeScreenshot(
mockOutputFile,
'1234',
IOSDeviceInterface.usb,
), throwsA(anything));
});
testWithoutContext('idevicescreenshot captures and returns screenshot', () async {
testWithoutContext('idevicescreenshot captures and returns USB screenshot', () async {
when(mockOutputFile.path).thenReturn(outputPath);
when(mockProcessManager.run(any, environment: anyNamed('environment'), workingDirectory: null)).thenAnswer(
(Invocation invocation) => Future<ProcessResult>.value(ProcessResult(4, 0, '', '')));
......@@ -100,12 +105,39 @@ void main() {
logger: logger,
);
await iMobileDevice.takeScreenshot(mockOutputFile, '1234');
await iMobileDevice.takeScreenshot(
mockOutputFile,
'1234',
IOSDeviceInterface.usb,
);
verify(mockProcessManager.run(<String>[idevicescreenshotPath, outputPath, '--udid', '1234'],
environment: <String, String>{'DYLD_LIBRARY_PATH': libimobiledevicePath},
workingDirectory: null,
));
});
testWithoutContext('idevicescreenshot captures and returns network screenshot', () async {
when(mockOutputFile.path).thenReturn(outputPath);
when(mockProcessManager.run(any, environment: anyNamed('environment'), workingDirectory: null)).thenAnswer(
(Invocation invocation) => Future<ProcessResult>.value(ProcessResult(4, 0, '', '')));
final IMobileDevice iMobileDevice = IMobileDevice(
artifacts: mockArtifacts,
cache: mockCache,
processManager: mockProcessManager,
logger: logger,
);
await iMobileDevice.takeScreenshot(
mockOutputFile,
'1234',
IOSDeviceInterface.network,
);
verify(mockProcessManager.run(<String>[idevicescreenshotPath, outputPath, '--udid', '1234', '--network'],
environment: <String, String>{'DYLD_LIBRARY_PATH': libimobiledevicePath},
workingDirectory: null,
));
});
});
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment