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:
Matan Lurey
2025-01-09 19:23:40 -08:00
committed by GitHub
parent 99fe90a05e
commit 89b336109f
15 changed files with 250 additions and 16 deletions

View File

@@ -21,7 +21,7 @@ Future<int> _fetchTexture(int width, int height) async {
}
void main() async {
ensureAndroidOrIosDevice();
ensureAndroidDevice();
enableFlutterDriverExtension(commands: <CommandExtension>[nativeDriverCommands]);
// Run on full screen.

View File

@@ -10,7 +10,7 @@ import 'package:flutter_driver/driver_extension.dart';
import 'src/allow_list_devices.dart';
void main() {
ensureAndroidOrIosDevice();
ensureAndroidDevice();
enableFlutterDriverExtension(commands: <CommandExtension>[nativeDriverCommands]);
// Run on full screen.

View File

@@ -7,10 +7,10 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_driver/driver_extension.dart';
import 'src/allow_list_devices.dart';
import '../src/allow_list_devices.dart';
void main() async {
ensureAndroidOrIosDevice();
ensureAndroidDevice();
enableFlutterDriverExtension(commands: <CommandExtension>[nativeDriverCommands]);
// Run on full screen.
@@ -25,6 +25,11 @@ final class MainApp extends StatelessWidget {
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
// It is assumed:
// - The Android SDK version is >= 23 (the test driver checks)
// - This view does NOT use a SurfaceView
//
// See https://github.com/flutter/flutter/blob/main/docs/platforms/android/Android-Platform-Views.md.
home: AndroidView(viewType: 'blue_orange_gradient_platform_view'),
);
}

View File

@@ -0,0 +1,36 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:android_driver_extensions/extension.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_driver/driver_extension.dart';
import '../src/allow_list_devices.dart';
void main() async {
ensureAndroidDevice();
enableFlutterDriverExtension(commands: <CommandExtension>[nativeDriverCommands]);
// Run on full screen.
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
runApp(const MainApp());
}
final class MainApp extends StatelessWidget {
const MainApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
// It is assumed:
// - The Android SDK version is >= 23 (the test driver checks)
// - This view DOES use a SurfaceView
//
// See https://github.com/flutter/flutter/blob/main/docs/platforms/android/Android-Platform-Views.md.
home: AndroidView(viewType: 'blue_orange_gradient_surface_view_platform_view'),
);
}
}

View File

@@ -10,7 +10,7 @@ import 'package:flutter_driver/driver_extension.dart';
import 'src/allow_list_devices.dart';
void main() async {
ensureAndroidOrIosDevice();
ensureAndroidDevice();
enableFlutterDriverExtension(commands: <CommandExtension>[nativeDriverCommands]);
// Run on full screen.

View File

@@ -6,11 +6,11 @@ import 'dart:io' as io;
import 'package:flutter/foundation.dart';
/// Throws an [UnsupportedError] if the current platform is not Android or iOS.
void ensureAndroidOrIosDevice() {
if (kIsWeb || (!io.Platform.isAndroid && !io.Platform.isIOS)) {
/// Throws an [UnsupportedError] if the current platform is not Android.
void ensureAndroidDevice() {
if (kIsWeb || !io.Platform.isAndroid) {
throw UnsupportedError(
'This app should only run on Android or iOS devices. It uses native '
'This app should only run on Android devices. It uses native Android '
'plugins that are not developed for other platforms, and would need to '
'be adapted to run on other platforms. See the README.md for details.',
);