Add a virtual-display (VD) platform view test, and refactor tests a bit. (#161349)
Towards https://github.com/flutter/flutter/issues/161261. Still need to add a HC (Hybrid Composition) variant, but figured I'd do this incrementally to make it easier to review.
This commit is contained in:
@@ -49,10 +49,14 @@ final class NativeDriverCommandExtension implements CommandExtension {
|
||||
if (result == null) {
|
||||
return const _MethodChannelResult(<String, Object?>{});
|
||||
}
|
||||
if (result is! Map<String, Object?>) {
|
||||
throw ArgumentError.value(result, 'result', 'Expected a Map<String, Object?>');
|
||||
if (result is! Map<Object?, Object?>) {
|
||||
throw ArgumentError.value(
|
||||
result,
|
||||
'result',
|
||||
'Expected a Map<String, Object?>, got ${result.runtimeType}',
|
||||
);
|
||||
}
|
||||
return _MethodChannelResult(result);
|
||||
return _MethodChannelResult(result.cast());
|
||||
}
|
||||
|
||||
// While these could have been implemented in native code, they are already
|
||||
|
||||
@@ -71,6 +71,12 @@ final class AndroidNativeDriver implements NativeDriver {
|
||||
await _driver.sendCommand(NativeCommand.tap(finder));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> get sdkVersion async {
|
||||
final Map<String, Object?> result = await _driver.sendCommand(NativeCommand.getSdkVersion);
|
||||
return result['version']! as int;
|
||||
}
|
||||
|
||||
/// Waits for 2 seconds before completing.
|
||||
///
|
||||
/// There is no perfect way, outside of polling, to know when the device is
|
||||
|
||||
@@ -27,6 +27,9 @@ final class NativeCommand extends Command {
|
||||
/// Pings the device to ensure it is responsive.
|
||||
static const NativeCommand ping = NativeCommand('ping');
|
||||
|
||||
/// Gets the SDK version code.
|
||||
static const NativeCommand getSdkVersion = NativeCommand('sdk_version');
|
||||
|
||||
/// The method to call on the plugin.
|
||||
final String method;
|
||||
|
||||
|
||||
@@ -45,6 +45,9 @@ abstract interface class NativeDriver {
|
||||
/// ```
|
||||
Future<Duration> ping();
|
||||
|
||||
/// Returns the SDK version.
|
||||
Future<int> get sdkVersion;
|
||||
|
||||
/// Take a screenshot using a platform-specific mechanism.
|
||||
///
|
||||
/// The image is returned as an opaque handle that can be used to retrieve
|
||||
|
||||
Reference in New Issue
Block a user