Rename native_driver to android_{driver_extensions|engine_test} (#161263)
Towards https://github.com/flutter/flutter/issues/161261 (before I add more tests). This is a 1:1 move, with massaging of `run_flutter_driver_android_tests.dart` to be more automated as tests are added. /cc @reidbaker
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
// 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 'dart:async';
|
||||
|
||||
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';
|
||||
|
||||
const MethodChannel _channel = MethodChannel('smiley_face_texture');
|
||||
Future<int> _fetchTexture(int width, int height) async {
|
||||
final int? result = await _channel.invokeMethod<int>('initTexture', <String, int>{
|
||||
'width': width,
|
||||
'height': height,
|
||||
});
|
||||
return result!;
|
||||
}
|
||||
|
||||
void main() async {
|
||||
ensureAndroidOrIosDevice();
|
||||
enableFlutterDriverExtension(commands: <CommandExtension>[nativeDriverCommands]);
|
||||
|
||||
// Run on full screen.
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
|
||||
|
||||
// Fetch the texture ID.
|
||||
final Future<int> textureId = _fetchTexture(512, 512);
|
||||
runApp(MainApp(textureId));
|
||||
}
|
||||
|
||||
final class MainApp extends StatelessWidget {
|
||||
const MainApp(this.textureId, {super.key});
|
||||
final Future<int> textureId;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: FutureBuilder<int>(
|
||||
future: textureId,
|
||||
builder: (BuildContext context, AsyncSnapshot<int> snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return Texture(textureId: snapshot.data!);
|
||||
}
|
||||
return const CircularProgressIndicator();
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// 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() {
|
||||
ensureAndroidOrIosDevice();
|
||||
enableFlutterDriverExtension(commands: <CommandExtension>[nativeDriverCommands]);
|
||||
|
||||
// Run on full screen.
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
|
||||
|
||||
runApp(const MainApp());
|
||||
}
|
||||
|
||||
final class MainApp extends StatelessWidget {
|
||||
const MainApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Draw a full-screen blue rectangle.
|
||||
return const DecoratedBox(decoration: BoxDecoration(color: Colors.blue));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// 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 {
|
||||
ensureAndroidOrIosDevice();
|
||||
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,
|
||||
home: AndroidView(viewType: 'blue_orange_gradient_platform_view'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// 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 {
|
||||
ensureAndroidOrIosDevice();
|
||||
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,
|
||||
home: AndroidView(viewType: 'changing_color_button_platform_view'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// 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 '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)) {
|
||||
throw UnsupportedError(
|
||||
'This app should only run on Android or iOS devices. It uses native '
|
||||
'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.',
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user