Move (dev/tools), complete v0 of native_driver (Android) (#154843)
**This is a WIP**, and the only reason it is not a draft PR is so that Flutter (Skia) Gold is executed. --- Closes https://github.com/flutter/flutter/issues/148269. Work towards https://github.com/flutter/flutter/issues/148269.
@@ -2,9 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io' as io;
|
||||
|
||||
import 'package:path/path.dart' as path;
|
||||
import '../run_command.dart';
|
||||
import '../utils.dart';
|
||||
@@ -19,32 +16,15 @@ import '../utils.dart';
|
||||
/// ```
|
||||
///
|
||||
/// For debugging, it is recommended to instead just run and launch these tests
|
||||
/// individually _in_ the `dev/integration_tests/android_driver_test` directory.
|
||||
/// individually _in_ the `dev/integration_tests/native_driver_test` directory.
|
||||
Future<void> runFlutterDriverAndroidTests() async {
|
||||
print('Running Flutter Driver Android tests...');
|
||||
|
||||
// Print out the results of `adb devices`, for uh, science:
|
||||
print('Listing devices...');
|
||||
final io.ProcessResult devices = await _adb(
|
||||
<String>[
|
||||
'devices',
|
||||
],
|
||||
);
|
||||
print(devices.stdout);
|
||||
print(devices.stderr);
|
||||
|
||||
// We need to configure the emulator to disable confirmations before the
|
||||
// application starts. Some of these configuration options won't work once
|
||||
// the application is running.
|
||||
print('Configuring device...');
|
||||
await _configureForScreenshotTesting();
|
||||
|
||||
// TODO(matanlurey): Should we be using another instrumentation method?
|
||||
await runCommand(
|
||||
'flutter',
|
||||
<String>[
|
||||
'drive',
|
||||
'lib/blue_rectangle_main.dart',
|
||||
'lib/flutter_rendered_blue_rectangle_main.dart',
|
||||
// There are no reason to enable development flags for this test.
|
||||
// Disable them to work around flakiness issues, and in general just
|
||||
// make less things start up unnecessarily.
|
||||
@@ -56,7 +36,7 @@ Future<void> runFlutterDriverAndroidTests() async {
|
||||
workingDirectory: path.join(
|
||||
'dev',
|
||||
'integration_tests',
|
||||
'android_driver_test',
|
||||
'native_driver_test',
|
||||
),
|
||||
);
|
||||
|
||||
@@ -64,7 +44,7 @@ Future<void> runFlutterDriverAndroidTests() async {
|
||||
'flutter',
|
||||
<String>[
|
||||
'drive',
|
||||
'lib/blue_orange_gradient_platform_view_main.dart',
|
||||
'lib/platform_view_blue_orange_gradient_main.dart',
|
||||
// There are no reason to enable development flags for this test.
|
||||
// Disable them to work around flakiness issues, and in general just
|
||||
// make less things start up unnecessarily.
|
||||
@@ -76,64 +56,27 @@ Future<void> runFlutterDriverAndroidTests() async {
|
||||
workingDirectory: path.join(
|
||||
'dev',
|
||||
'integration_tests',
|
||||
'android_driver_test',
|
||||
'native_driver_test',
|
||||
),
|
||||
);
|
||||
|
||||
await runCommand(
|
||||
'flutter',
|
||||
<String>[
|
||||
'drive',
|
||||
'lib/external_texture_smiley_face_main.dart',
|
||||
// There are no reason to enable development flags for this test.
|
||||
// Disable them to work around flakiness issues, and in general just
|
||||
// make less things start up unnecessarily.
|
||||
'--no-dds',
|
||||
'--no-enable-dart-profiling',
|
||||
'--test-arguments=test',
|
||||
'--test-arguments=--reporter=expanded',
|
||||
],
|
||||
workingDirectory: path.join(
|
||||
'dev',
|
||||
'integration_tests',
|
||||
'native_driver_test',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// TODO(matanlurey): Move this code into flutter_driver instead of here.
|
||||
Future<void> _configureForScreenshotTesting() async {
|
||||
// Disable confirmation for immersive mode.
|
||||
final io.ProcessResult immersive = await _adb(
|
||||
<String>[
|
||||
'shell',
|
||||
'settings',
|
||||
'put',
|
||||
'secure',
|
||||
'immersive_mode_confirmations',
|
||||
'confirmed',
|
||||
],
|
||||
);
|
||||
|
||||
if (immersive.exitCode != 0) {
|
||||
throw StateError('Failed to configure device: ${immersive.stderr}');
|
||||
}
|
||||
|
||||
const Map<String, String> settings = <String, String>{
|
||||
'show_surface_updates': '1',
|
||||
'transition_animation_scale': '0',
|
||||
'window_animation_scale': '0',
|
||||
'animator_duration_scale': '0',
|
||||
};
|
||||
|
||||
for (final MapEntry<String, String> entry in settings.entries) {
|
||||
final io.ProcessResult result = await _adb(
|
||||
<String>[
|
||||
'shell',
|
||||
'settings',
|
||||
'put',
|
||||
'global',
|
||||
entry.key,
|
||||
entry.value,
|
||||
],
|
||||
);
|
||||
|
||||
if (result.exitCode != 0) {
|
||||
throw StateError('Failed to configure device: ${result.stderr}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<io.ProcessResult> _adb(
|
||||
List<String> args, {
|
||||
Encoding? stdoutEncoding = io.systemEncoding,
|
||||
}) {
|
||||
// TODO(matanlurey): Ideally we should specify the device target here.
|
||||
return io.Process.run(
|
||||
'adb',
|
||||
<String>[
|
||||
...args,
|
||||
],
|
||||
stdoutEncoding: stdoutEncoding,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
# Flutter Driver Android Integration Tests
|
||||
|
||||
This directory contains a sample app and tests that demonstrate how to use the
|
||||
(experimental) _native_ Flutter Driver API to drive Flutter apps that run on
|
||||
Android devices or emulators, interact with and capture screenshots of the app,
|
||||
and compare the screenshots against golden images.
|
||||
@@ -1,34 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// This file is auto generated.
|
||||
// To update all the build.gradle files in the Flutter repo,
|
||||
// See dev/tools/bin/generate_gradle_lockfiles.dart.
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.buildDir = '../build'
|
||||
|
||||
subprojects {
|
||||
project.buildDir = "${rootProject.buildDir}/${project.name}"
|
||||
}
|
||||
subprojects {
|
||||
project.evaluationDependsOn(':app')
|
||||
dependencyLocking {
|
||||
ignoredDependencies.add('io.flutter:*')
|
||||
lockFile = file("${rootProject.projectDir}/project-${project.name}.lockfile")
|
||||
if (!project.hasProperty('local-engine-repo')) {
|
||||
lockAllConfigurations()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("clean", Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
// 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:flutter_driver/flutter_driver.dart';
|
||||
import 'package:flutter_driver/src/native_driver.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import '_flutter_goldens_fork.dart';
|
||||
|
||||
// TODO(matanlurey): This is done automatically by 'flutter test' but not by
|
||||
// 'flutter drive'. If we get closer to shipping the native 'flutter drive'
|
||||
// command, we should look into if 'flutter_test_config.dart', or a similar
|
||||
// mechanism, can be used to configure this automatically.
|
||||
void main() async {
|
||||
await testExecutable(_main);
|
||||
}
|
||||
|
||||
Future<void> _main() async {
|
||||
// To generate golden files locally, uncomment the following line.
|
||||
// autoUpdateGoldenFiles = true;
|
||||
|
||||
late FlutterDriver flutterDriver;
|
||||
late NativeDriver nativeDriver;
|
||||
|
||||
setUpAll(() async {
|
||||
flutterDriver = await FlutterDriver.connect();
|
||||
nativeDriver = await AndroidNativeDriver.connect();
|
||||
});
|
||||
|
||||
tearDownAll(() async {
|
||||
await nativeDriver.close();
|
||||
await flutterDriver.close();
|
||||
});
|
||||
|
||||
test(
|
||||
'should screenshot and match a blue (top left) -> orange (bottom right) gradient',
|
||||
() async {
|
||||
await flutterDriver.waitFor(find.byType('AndroidView'));
|
||||
await expectLater(
|
||||
nativeDriver.screenshot(),
|
||||
matchesGoldenFile('android_driver_test.BlueOrangeGradient.png'),
|
||||
);
|
||||
},
|
||||
timeout: Timeout.none,
|
||||
);
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: "6a346df51b97840ff2c06805e5482be28c6dd7c4"
|
||||
revision: "6c380ffb86ea5048f0650629fe4f0e904afd50e1"
|
||||
channel: "[user-branch]"
|
||||
|
||||
project_type: app
|
||||
@@ -13,11 +13,14 @@ project_type: app
|
||||
migration:
|
||||
platforms:
|
||||
- platform: root
|
||||
create_revision: 6a346df51b97840ff2c06805e5482be28c6dd7c4
|
||||
base_revision: 6a346df51b97840ff2c06805e5482be28c6dd7c4
|
||||
create_revision: 6c380ffb86ea5048f0650629fe4f0e904afd50e1
|
||||
base_revision: 6c380ffb86ea5048f0650629fe4f0e904afd50e1
|
||||
- platform: android
|
||||
create_revision: 6a346df51b97840ff2c06805e5482be28c6dd7c4
|
||||
base_revision: 6a346df51b97840ff2c06805e5482be28c6dd7c4
|
||||
create_revision: 6c380ffb86ea5048f0650629fe4f0e904afd50e1
|
||||
base_revision: 6c380ffb86ea5048f0650629fe4f0e904afd50e1
|
||||
- platform: ios
|
||||
create_revision: 6c380ffb86ea5048f0650629fe4f0e904afd50e1
|
||||
base_revision: 6c380ffb86ea5048f0650629fe4f0e904afd50e1
|
||||
|
||||
# User provided section
|
||||
|
||||
37
dev/integration_tests/native_driver_test/README.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# native_driver_test
|
||||
|
||||
This directory contains a sample app and tests that demonstrate how to use the
|
||||
(experimental) _native_ Flutter Driver API to drive Flutter apps that run on
|
||||
Android or iOS devices or emulators, interact with and capture screenshots of
|
||||
the app, and compare the screenshots against golden images.
|
||||
|
||||
## Running the apps and tests
|
||||
|
||||
Each `lib/{prefix}_main.dart` file is a standalone Flutter app that you can run
|
||||
on an Android or iOS device or emulator:
|
||||
|
||||
### `flutter_rendered_blue_rectangle`
|
||||
|
||||
This app displays a full screen blue rectangle. It mostly serves as a test that
|
||||
Flutter can run at all on the target device, and that the Flutter (native)
|
||||
driver can take a screenshot and compare it to a golden image. If this app or
|
||||
test fails, it's likely none of the other apps or tests will work either.
|
||||
|
||||
```sh
|
||||
# Run the app
|
||||
$ flutter run lib/flutter_rendered_blue_rectangle_main.dart
|
||||
|
||||
# Run the test
|
||||
$ flutter drive lib/flutter_rendered_blue_rectangle_main.dart
|
||||
```
|
||||
|
||||
Files of significance:
|
||||
|
||||
- [Entrypoint](lib/flutter_rendered_blue_rectangle_main.dart)
|
||||
- [Test](test_driver/flutter_rendered_blue_rectangle_main_test.dart)
|
||||
|
||||
## Debugging tips
|
||||
|
||||
- Use `flutter drive --keep-app-running` to keep the app running after the test.
|
||||
- USe `flutter run` followed by `flutter drive --use-existing-app` for faster
|
||||
test iterations.
|
||||
@@ -10,7 +10,7 @@ plugins {
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.example.android_driver_test"
|
||||
namespace = "com.example.native_driver_test"
|
||||
compileSdk = flutter.compileSdkVersion
|
||||
ndkVersion = flutter.ndkVersion
|
||||
|
||||
@@ -25,7 +25,7 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||
applicationId = "com.example.android_driver_test"
|
||||
applicationId = "com.example.native_driver_test"
|
||||
// You can update the following values to match your application needs.
|
||||
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
||||
minSdk = flutter.minSdkVersion
|
||||
@@ -4,7 +4,7 @@ found in the LICENSE file. -->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<application
|
||||
android:label="android_driver_test"
|
||||
android:label="native_driver_test"
|
||||
android:name="${applicationName}"
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
<activity
|
||||
@@ -4,12 +4,16 @@
|
||||
|
||||
@file:Suppress("PackageName")
|
||||
|
||||
package com.example.android_driver_test
|
||||
package com.example.native_driver_test
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.WindowInsetsControllerCompat
|
||||
import com.example.native_driver_test.extensions.NativeDriverSupportPlugin
|
||||
import com.example.native_driver_test.fixtures.BlueOrangeGradientPlatformViewFactory
|
||||
import com.example.native_driver_test.fixtures.ChangingColorButtonPlatformViewFactory
|
||||
import com.example.native_driver_test.fixtures.SmileyFaceTexturePlugin
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
import io.flutter.embedding.engine.FlutterEngine
|
||||
|
||||
@@ -17,10 +21,20 @@ class MainActivity : FlutterActivity() {
|
||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||
// Intentionally do not use GeneratedPluginRegistrant.
|
||||
|
||||
flutterEngine
|
||||
.plugins
|
||||
.apply {
|
||||
add(SmileyFaceTexturePlugin())
|
||||
add(NativeDriverSupportPlugin())
|
||||
}
|
||||
|
||||
flutterEngine
|
||||
.platformViewsController
|
||||
.registry
|
||||
.registerViewFactory("blue_orange_gradient_platform_view", BlueOrangeGradientPlatformViewFactory())
|
||||
.apply {
|
||||
registerViewFactory("blue_orange_gradient_platform_view", BlueOrangeGradientPlatformViewFactory())
|
||||
registerViewFactory("changing_color_button_platform_view", ChangingColorButtonPlatformViewFactory())
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -0,0 +1,109 @@
|
||||
// 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.
|
||||
|
||||
@file:Suppress("PackageName")
|
||||
|
||||
package com.example.native_driver_test.extensions
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.SystemClock
|
||||
import android.view.MotionEvent
|
||||
import io.flutter.Log
|
||||
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||
import io.flutter.embedding.engine.plugins.activity.ActivityAware
|
||||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
|
||||
import io.flutter.plugin.common.MethodCall
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
|
||||
|
||||
class NativeDriverSupportPlugin :
|
||||
ActivityAware,
|
||||
FlutterPlugin,
|
||||
MethodCallHandler {
|
||||
private val tag = "NativeDriverSupportPlugin"
|
||||
private lateinit var channel: MethodChannel
|
||||
private var activity: Activity? = null
|
||||
|
||||
override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) {
|
||||
channel = MethodChannel(binding.binaryMessenger, "native_driver")
|
||||
channel.setMethodCallHandler(this)
|
||||
}
|
||||
|
||||
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
|
||||
channel.setMethodCallHandler(null)
|
||||
}
|
||||
|
||||
override fun onMethodCall(
|
||||
call: MethodCall,
|
||||
result: MethodChannel.Result
|
||||
) {
|
||||
val activity = this.activity
|
||||
if (activity == null) {
|
||||
Log.w(tag, "Received method channel, but no current activity")
|
||||
return
|
||||
}
|
||||
when (call.method) {
|
||||
"ping" -> {
|
||||
result.success(null)
|
||||
}
|
||||
"tap_view" -> {
|
||||
// Decode the selector.
|
||||
val kind = call.argument<String>("kind")
|
||||
lateinit var selector: NativeSelector
|
||||
when (kind) {
|
||||
"byNativeAccessibilityLabel" -> {
|
||||
selector = NativeSelector.ByContentDescription(call.argument("label")!!)
|
||||
}
|
||||
"byNativeIntegerId" -> {
|
||||
selector = NativeSelector.ByViewId(call.argument("id")!!)
|
||||
}
|
||||
else -> {
|
||||
result.error("INVALID_SELECTOR", "Not supported", kind)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Fail if not found.
|
||||
val found = selector.find(activity.window.decorView.rootView)
|
||||
if (found == null) {
|
||||
result.error("VIEW_NOT_FOUND", "No view was found", call.arguments())
|
||||
return
|
||||
}
|
||||
|
||||
// Send tap event.
|
||||
val x = found.x + found.width / 2
|
||||
val y = found.y + found.height / 2
|
||||
val downTime = SystemClock.uptimeMillis()
|
||||
|
||||
val pressDown = MotionEvent.obtain(downTime, downTime, MotionEvent.ACTION_DOWN, x, y, 0)
|
||||
found.dispatchTouchEvent(pressDown)
|
||||
pressDown.recycle()
|
||||
|
||||
val pressUp = MotionEvent.obtain(downTime, downTime, MotionEvent.ACTION_UP, x, y, 0)
|
||||
found.dispatchTouchEvent(pressUp)
|
||||
pressUp.recycle()
|
||||
result.success(null)
|
||||
}
|
||||
else -> {
|
||||
result.notImplemented()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
|
||||
activity = binding.activity
|
||||
}
|
||||
|
||||
override fun onDetachedFromActivityForConfigChanges() {
|
||||
activity = null
|
||||
}
|
||||
|
||||
override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) {
|
||||
activity = binding.activity
|
||||
}
|
||||
|
||||
override fun onDetachedFromActivity() {
|
||||
activity = null
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
// 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.
|
||||
|
||||
@file:Suppress("PackageName")
|
||||
|
||||
package com.example.native_driver_test.extensions
|
||||
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.view.children
|
||||
|
||||
// / Finds a native view using serialized data provided by a driver script.
|
||||
sealed class NativeSelector {
|
||||
// / Finds a native view by a {@code contentDescription} attribute.
|
||||
data class ByContentDescription(
|
||||
val contentDescription: String
|
||||
) : NativeSelector() {
|
||||
override fun find(root: View): View? {
|
||||
val found = ArrayList<View>()
|
||||
findRecursive(root, found)
|
||||
if (found.isEmpty()) {
|
||||
return null
|
||||
}
|
||||
if (found.size > 1) {
|
||||
throw IllegalStateException("Expected a single matching view, got ${found.size}")
|
||||
}
|
||||
return found[0]
|
||||
}
|
||||
|
||||
private fun findRecursive(
|
||||
parent: View,
|
||||
found: ArrayList<View>
|
||||
) {
|
||||
if (contentDescription == parent.contentDescription) {
|
||||
found.add(parent)
|
||||
}
|
||||
if (parent is ViewGroup) {
|
||||
for (child in parent.children) {
|
||||
findRecursive(child, found)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// / Finds a native view by a {@code id} attribute.
|
||||
data class ByViewId(
|
||||
val id: Int
|
||||
) : NativeSelector() {
|
||||
override fun find(root: View): View? = root.findViewById(id)
|
||||
}
|
||||
|
||||
// / Given a root view, returns the only view that matches this selector.
|
||||
// /
|
||||
// / If no view is found, returns null.
|
||||
abstract fun find(root: View): View?
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
@file:Suppress("PackageName")
|
||||
|
||||
package com.example.android_driver_test
|
||||
package com.example.native_driver_test.fixtures
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Canvas
|
||||
@@ -0,0 +1,68 @@
|
||||
// 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.
|
||||
|
||||
@file:Suppress("PackageName")
|
||||
|
||||
package com.example.native_driver_test.fixtures
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.graphics.Paint
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import io.flutter.plugin.platform.PlatformView
|
||||
import io.flutter.plugin.platform.PlatformViewFactory
|
||||
|
||||
class ChangingColorButtonPlatformViewFactory : PlatformViewFactory(null) {
|
||||
override fun create(
|
||||
context: Context,
|
||||
viewId: Int,
|
||||
args: Any?
|
||||
): PlatformView = ChangingColorButtonPlatformView(context)
|
||||
}
|
||||
|
||||
private class ChangingColorButtonPlatformView(
|
||||
context: Context
|
||||
) : View(context),
|
||||
PlatformView {
|
||||
private val paintRed =
|
||||
Paint().apply {
|
||||
color = Color.RED
|
||||
style = Paint.Style.FILL
|
||||
}
|
||||
private val paintBlue =
|
||||
Paint().apply {
|
||||
color = Color.BLUE
|
||||
style = Paint.Style.FILL
|
||||
}
|
||||
|
||||
private var isBlue = false
|
||||
|
||||
init {
|
||||
layoutParams =
|
||||
ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
|
||||
contentDescription = "Change color"
|
||||
|
||||
setOnClickListener {
|
||||
run {
|
||||
isBlue = !isBlue
|
||||
invalidate() // Force a redraw
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getView(): View = this
|
||||
|
||||
override fun dispose() {}
|
||||
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
super.onDraw(canvas)
|
||||
canvas.drawRect(0f, 0f, width.toFloat(), height.toFloat(), if (isBlue) paintBlue else paintRed)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
// 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.
|
||||
|
||||
@file:Suppress("PackageName")
|
||||
|
||||
package com.example.native_driver_test.fixtures
|
||||
|
||||
import android.graphics.Color
|
||||
import android.graphics.Paint
|
||||
import android.os.Build
|
||||
import android.view.Surface
|
||||
import io.flutter.Log
|
||||
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||
import io.flutter.embedding.engine.plugins.FlutterPlugin.FlutterPluginBinding
|
||||
import io.flutter.plugin.common.MethodCall
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
|
||||
import io.flutter.view.TextureRegistry.SurfaceProducer
|
||||
|
||||
class SmileyFaceTexturePlugin :
|
||||
FlutterPlugin,
|
||||
MethodCallHandler,
|
||||
SurfaceProducer.Callback {
|
||||
private val tag = "SmileyFaceTexturePlugin"
|
||||
private lateinit var channel: MethodChannel
|
||||
private lateinit var binding: FlutterPluginBinding
|
||||
private lateinit var producer: SurfaceProducer
|
||||
|
||||
private var surface: Surface? = null
|
||||
|
||||
override fun onAttachedToEngine(binding: FlutterPluginBinding) {
|
||||
this.binding = binding
|
||||
channel = MethodChannel(binding.binaryMessenger, "smiley_face_texture")
|
||||
channel.setMethodCallHandler(this)
|
||||
producer = binding.textureRegistry.createSurfaceProducer()
|
||||
producer.setCallback(this)
|
||||
}
|
||||
|
||||
override fun onDetachedFromEngine(binding: FlutterPluginBinding) {
|
||||
channel.setMethodCallHandler(null)
|
||||
producer.release()
|
||||
}
|
||||
|
||||
override fun onMethodCall(
|
||||
call: MethodCall,
|
||||
result: MethodChannel.Result
|
||||
) {
|
||||
if (call.method == "initTexture") {
|
||||
val height = call.argument<Int>("height") ?: 1
|
||||
val width = call.argument<Int>("width") ?: 1
|
||||
producer.setSize(width, height)
|
||||
result.success(updateTexture())
|
||||
} else {
|
||||
result.notImplemented()
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateTexture(): Long {
|
||||
var surface = this.surface
|
||||
if (surface == null) {
|
||||
surface = producer.surface
|
||||
this.surface = surface
|
||||
}
|
||||
drawOnSurface(producer.surface)
|
||||
return producer.id()
|
||||
}
|
||||
|
||||
private fun drawOnSurface(surface: Surface) {
|
||||
val canvas =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
surface.lockHardwareCanvas()
|
||||
} else {
|
||||
surface.lockCanvas(null)
|
||||
}
|
||||
|
||||
// Yellow background
|
||||
canvas.drawRGB(255, 230, 15)
|
||||
|
||||
val paint = Paint()
|
||||
paint.style = Paint.Style.FILL
|
||||
|
||||
// Black eyes
|
||||
paint.color = Color.BLACK
|
||||
canvas.drawRect(200f, 200f, 250f, 250f, paint) // Left eye
|
||||
canvas.drawRect(400f, 200f, 450f, 250f, paint) // Right eye
|
||||
|
||||
// Black mouth
|
||||
paint.color = Color.BLACK
|
||||
canvas.drawRect(250f, 400f, 400f, 420f, paint) // Simple mouth
|
||||
|
||||
surface.unlockCanvasAndPost(canvas)
|
||||
}
|
||||
|
||||
override fun onSurfaceCreated() {
|
||||
Log.i(tag, "onSurfaceCreated()")
|
||||
updateTexture()
|
||||
}
|
||||
|
||||
override fun onSurfaceDestroyed() {
|
||||
Log.i(tag, "onSurfaceDestroyed()")
|
||||
surface?.release()
|
||||
surface = null
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,4 @@ found in the LICENSE file. -->
|
||||
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="?android:colorBackground" />
|
||||
|
||||
<!-- You can insert your own image assets here -->
|
||||
<!-- <item>
|
||||
<bitmap
|
||||
android:gravity="center"
|
||||
android:src="@mipmap/launch_image" />
|
||||
</item> -->
|
||||
</layer-list>
|
||||
@@ -5,11 +5,4 @@ found in the LICENSE file. -->
|
||||
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@android:color/white" />
|
||||
|
||||
<!-- You can insert your own image assets here -->
|
||||
<!-- <item>
|
||||
<bitmap
|
||||
android:gravity="center"
|
||||
android:src="@mipmap/launch_image" />
|
||||
</item> -->
|
||||
</layer-list>
|
||||
|
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 544 B |
|
Before Width: | Height: | Size: 442 B After Width: | Height: | Size: 442 B |
|
Before Width: | Height: | Size: 721 B After Width: | Height: | Size: 721 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,22 @@
|
||||
// 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.
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.buildDir = "../build"
|
||||
subprojects {
|
||||
project.buildDir = "${rootProject.buildDir}/${project.name}"
|
||||
}
|
||||
subprojects {
|
||||
project.evaluationDependsOn(":app")
|
||||
}
|
||||
|
||||
tasks.register("clean", Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
@@ -2,10 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// This file is auto generated.
|
||||
// To update all the settings.gradle files in the Flutter repo,
|
||||
// See dev/tools/bin/generate_gradle_lockfiles.dart.
|
||||
|
||||
pluginManagement {
|
||||
def flutterSdkPath = {
|
||||
def properties = new Properties()
|
||||
@@ -13,10 +9,9 @@ pluginManagement {
|
||||
def flutterSdkPath = properties.getProperty("flutter.sdk")
|
||||
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
|
||||
return flutterSdkPath
|
||||
}
|
||||
settings.ext.flutterSdkPath = flutterSdkPath()
|
||||
}()
|
||||
|
||||
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
|
||||
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
|
||||
|
||||
repositories {
|
||||
google()
|
||||
@@ -25,17 +20,10 @@ pluginManagement {
|
||||
}
|
||||
}
|
||||
|
||||
buildscript {
|
||||
dependencyLocking {
|
||||
lockFile = file("${rootProject.projectDir}/buildscript-gradle.lockfile")
|
||||
lockAllConfigurations()
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
|
||||
id "com.android.application" version "8.1.0" apply false
|
||||
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
|
||||
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
|
||||
}
|
||||
|
||||
include ":app"
|
||||
34
dev/integration_tests/native_driver_test/ios/.gitignore
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
**/dgph
|
||||
*.mode1v3
|
||||
*.mode2v3
|
||||
*.moved-aside
|
||||
*.pbxuser
|
||||
*.perspectivev3
|
||||
**/*sync/
|
||||
.sconsign.dblite
|
||||
.tags*
|
||||
**/.vagrant/
|
||||
**/DerivedData/
|
||||
Icon?
|
||||
**/Pods/
|
||||
**/.symlinks/
|
||||
profile
|
||||
xcuserdata
|
||||
**/.generated/
|
||||
Flutter/App.framework
|
||||
Flutter/Flutter.framework
|
||||
Flutter/Flutter.podspec
|
||||
Flutter/Generated.xcconfig
|
||||
Flutter/ephemeral/
|
||||
Flutter/app.flx
|
||||
Flutter/app.zip
|
||||
Flutter/flutter_assets/
|
||||
Flutter/flutter_export_environment.sh
|
||||
ServiceDefinitions.json
|
||||
Runner/GeneratedPluginRegistrant.*
|
||||
|
||||
# Exceptions to above rules.
|
||||
!default.mode1v3
|
||||
!default.mode2v3
|
||||
!default.pbxuser
|
||||
!default.perspectivev3
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>App</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>io.flutter.flutter.app</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>App</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>12.0</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1 @@
|
||||
#include "Generated.xcconfig"
|
||||
@@ -0,0 +1 @@
|
||||
#include "Generated.xcconfig"
|
||||
@@ -0,0 +1,619 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 54;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
||||
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
|
||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
|
||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
||||
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
|
||||
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
331C8085294A63A400263BE5 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 97C146E61CF9000F007C117D /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 97C146ED1CF9000F007C117D;
|
||||
remoteInfo = Runner;
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
9705A1C41CF9048500538489 /* Embed Frameworks */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
);
|
||||
name = "Embed Frameworks";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
|
||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
|
||||
331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = "<group>"; };
|
||||
331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
|
||||
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
97C146EB1CF9000F007C117D /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
331C8082294A63A400263BE5 /* RunnerTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
331C807B294A618700263BE5 /* RunnerTests.swift */,
|
||||
);
|
||||
path = RunnerTests;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
9740EEB11CF90186004384FC /* Flutter */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */,
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
|
||||
9740EEB31CF90195004384FC /* Generated.xcconfig */,
|
||||
);
|
||||
name = Flutter;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
97C146E51CF9000F007C117D = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9740EEB11CF90186004384FC /* Flutter */,
|
||||
97C146F01CF9000F007C117D /* Runner */,
|
||||
97C146EF1CF9000F007C117D /* Products */,
|
||||
331C8082294A63A400263BE5 /* RunnerTests */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
97C146EF1CF9000F007C117D /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
97C146EE1CF9000F007C117D /* Runner.app */,
|
||||
331C8081294A63A400263BE5 /* RunnerTests.xctest */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
97C146F01CF9000F007C117D /* Runner */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
97C146FA1CF9000F007C117D /* Main.storyboard */,
|
||||
97C146FD1CF9000F007C117D /* Assets.xcassets */,
|
||||
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
|
||||
97C147021CF9000F007C117D /* Info.plist */,
|
||||
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
|
||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
|
||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
|
||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
|
||||
);
|
||||
path = Runner;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
331C8080294A63A400263BE5 /* RunnerTests */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */;
|
||||
buildPhases = (
|
||||
331C807D294A63A400263BE5 /* Sources */,
|
||||
331C807F294A63A400263BE5 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
331C8086294A63A400263BE5 /* PBXTargetDependency */,
|
||||
);
|
||||
name = RunnerTests;
|
||||
productName = RunnerTests;
|
||||
productReference = 331C8081294A63A400263BE5 /* RunnerTests.xctest */;
|
||||
productType = "com.apple.product-type.bundle.unit-test";
|
||||
};
|
||||
97C146ED1CF9000F007C117D /* Runner */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
|
||||
buildPhases = (
|
||||
9740EEB61CF901F6004384FC /* Run Script */,
|
||||
97C146EA1CF9000F007C117D /* Sources */,
|
||||
97C146EB1CF9000F007C117D /* Frameworks */,
|
||||
97C146EC1CF9000F007C117D /* Resources */,
|
||||
9705A1C41CF9048500538489 /* Embed Frameworks */,
|
||||
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = Runner;
|
||||
productName = Runner;
|
||||
productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
97C146E61CF9000F007C117D /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
BuildIndependentTargetsInParallel = YES;
|
||||
LastUpgradeCheck = 1510;
|
||||
ORGANIZATIONNAME = "";
|
||||
TargetAttributes = {
|
||||
331C8080294A63A400263BE5 = {
|
||||
CreatedOnToolsVersion = 14.0;
|
||||
TestTargetID = 97C146ED1CF9000F007C117D;
|
||||
};
|
||||
97C146ED1CF9000F007C117D = {
|
||||
CreatedOnToolsVersion = 7.3.1;
|
||||
LastSwiftMigration = 1100;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
|
||||
compatibilityVersion = "Xcode 9.3";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = 97C146E51CF9000F007C117D;
|
||||
productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
97C146ED1CF9000F007C117D /* Runner */,
|
||||
331C8080294A63A400263BE5 /* RunnerTests */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
331C807F294A63A400263BE5 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
97C146EC1CF9000F007C117D /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
|
||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
|
||||
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
|
||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
alwaysOutOfDate = 1;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
|
||||
);
|
||||
name = "Thin Binary";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
|
||||
};
|
||||
9740EEB61CF901F6004384FC /* Run Script */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
alwaysOutOfDate = 1;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "Run Script";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
331C807D294A63A400263BE5 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
97C146EA1CF9000F007C117D /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
|
||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
331C8086294A63A400263BE5 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 97C146ED1CF9000F007C117D /* Runner */;
|
||||
targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
97C146FA1CF9000F007C117D /* Main.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
97C146FB1CF9000F007C117D /* Base */,
|
||||
);
|
||||
name = Main.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
97C147001CF9000F007C117D /* Base */,
|
||||
);
|
||||
name = LaunchScreen.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
249021D3217E4FDB00AE95B9 /* Profile */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTED_PLATFORMS = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Profile;
|
||||
};
|
||||
249021D4217E4FDB00AE95B9 /* Profile */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||
DEVELOPMENT_TEAM = QA3N6G4XTH;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.nativeDriverTest;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
SWIFT_VERSION = 5.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
};
|
||||
name = Profile;
|
||||
};
|
||||
331C8088294A63A400263BE5 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.nativeDriverTest.RunnerTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
331C8089294A63A400263BE5 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.nativeDriverTest.RunnerTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
331C808A294A63A400263BE5 /* Profile */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.nativeDriverTest.RunnerTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
|
||||
};
|
||||
name = Profile;
|
||||
};
|
||||
97C147031CF9000F007C117D /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
97C147041CF9000F007C117D /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTED_PLATFORMS = iphoneos;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
97C147061CF9000F007C117D /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||
DEVELOPMENT_TEAM = QA3N6G4XTH;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.nativeDriverTest;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
97C147071CF9000F007C117D /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||
DEVELOPMENT_TEAM = QA3N6G4XTH;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.nativeDriverTest;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
SWIFT_VERSION = 5.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
331C8088294A63A400263BE5 /* Debug */,
|
||||
331C8089294A63A400263BE5 /* Release */,
|
||||
331C808A294A63A400263BE5 /* Profile */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
97C147031CF9000F007C117D /* Debug */,
|
||||
97C147041CF9000F007C117D /* Release */,
|
||||
249021D3217E4FDB00AE95B9 /* Profile */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
97C147061CF9000F007C117D /* Debug */,
|
||||
97C147071CF9000F007C117D /* Release */,
|
||||
249021D4217E4FDB00AE95B9 /* Profile */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 97C146E61CF9000F007C117D /* Project object */;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>PreviewsEnabled</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1510"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO"
|
||||
parallelizable = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "331C8080294A63A400263BE5"
|
||||
BuildableName = "RunnerTests.xctest"
|
||||
BlueprintName = "RunnerTests"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Profile"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
7
dev/integration_tests/native_driver_test/ios/Runner.xcworkspace/contents.xcworkspacedata
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:Runner.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>PreviewsEnabled</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,17 @@
|
||||
// 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 Flutter
|
||||
import UIKit
|
||||
|
||||
@main
|
||||
@objc class AppDelegate: FlutterAppDelegate {
|
||||
override func application(
|
||||
_ application: UIApplication,
|
||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
||||
) -> Bool {
|
||||
GeneratedPluginRegistrant.register(with: self)
|
||||
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"images" : [],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"images" : [],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="EHf-IW-A2E">
|
||||
<objects>
|
||||
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="Ydg-fD-yQy"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="xbc-2k-c8Z"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4">
|
||||
</imageView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstItem="YRO-k0-Ey4" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="1a2-6s-vTC"/>
|
||||
<constraint firstItem="YRO-k0-Ey4" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="4X2-HB-R7a"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="53" y="375"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<image name="LaunchImage" width="168" height="185"/>
|
||||
</resources>
|
||||
</document>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Flutter View Controller-->
|
||||
<scene sceneID="tne-QT-ifu">
|
||||
<objects>
|
||||
<viewController id="BYZ-38-t0r" customClass="FlutterViewController" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
||||
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Native Driver Test</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>native_driver_test</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(FLUTTER_BUILD_NAME)</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(FLUTTER_BUILD_NUMBER)</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||
<true/>
|
||||
<key>UIApplicationSupportsIndirectInputEvents</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,5 @@
|
||||
// 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 "GeneratedPluginRegistrant.h"
|
||||
@@ -0,0 +1,59 @@
|
||||
// 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:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_driver/driver_extension.dart';
|
||||
import 'package:native_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();
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2,18 +2,21 @@
|
||||
// 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';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_driver/driver_extension.dart';
|
||||
import 'package:native_driver/extension.dart';
|
||||
|
||||
import 'src/allow_list_devices.dart';
|
||||
|
||||
void main() {
|
||||
enableFlutterDriverExtension();
|
||||
ensureAndroidOrIosDevice();
|
||||
enableFlutterDriverExtension(commands: <CommandExtension>[
|
||||
nativeDriverCommands,
|
||||
]);
|
||||
|
||||
if (kIsWeb || !io.Platform.isAndroid) {
|
||||
throw UnsupportedError('This app should only run on Android devices.');
|
||||
}
|
||||
// Run on full screen.
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
|
||||
|
||||
runApp(const MainApp());
|
||||
}
|
||||
@@ -2,19 +2,21 @@
|
||||
// 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';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_driver/driver_extension.dart';
|
||||
import 'package:native_driver/extension.dart';
|
||||
|
||||
void main() {
|
||||
enableFlutterDriverExtension();
|
||||
import 'src/allow_list_devices.dart';
|
||||
|
||||
if (kIsWeb || !io.Platform.isAndroid) {
|
||||
throw UnsupportedError('This app should only run on Android devices.');
|
||||
}
|
||||
void main() async {
|
||||
ensureAndroidOrIosDevice();
|
||||
enableFlutterDriverExtension(commands: <CommandExtension>[
|
||||
nativeDriverCommands,
|
||||
]);
|
||||
|
||||
// Run on full screen.
|
||||
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
|
||||
runApp(const MainApp());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// 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:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_driver/driver_extension.dart';
|
||||
import 'package:native_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.',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
name: android_driver_test
|
||||
name: native_driver_test
|
||||
publish_to: none
|
||||
|
||||
environment:
|
||||
sdk: ^3.6.0-77.0.dev
|
||||
sdk: ^3.6.0-216.0.dev
|
||||
|
||||
dependencies:
|
||||
native_driver:
|
||||
path: ../../tools/native_driver
|
||||
flutter:
|
||||
sdk: flutter
|
||||
flutter_driver:
|
||||
@@ -19,6 +21,8 @@ dependencies:
|
||||
material_color_utilities: 0.11.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
meta: 1.15.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
path: 1.9.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
platform: 3.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
process: 5.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
source_span: 1.10.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
stack_trace: 1.11.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
stream_channel: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
@@ -31,10 +35,6 @@ dependencies:
|
||||
webdriver: 3.0.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
|
||||
dev_dependencies:
|
||||
flutter_goldens:
|
||||
sdk: flutter
|
||||
platform: 3.1.5
|
||||
process: 5.0.2
|
||||
test: 1.25.8
|
||||
|
||||
_fe_analyzer_shared: 74.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
@@ -2,11 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
@experimental
|
||||
library;
|
||||
import 'dart:io' as io;
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
export 'native/android.dart';
|
||||
export 'native/driver.dart';
|
||||
export 'native/goldens.dart';
|
||||
/// Whether the current environment is LUCI.
|
||||
bool get isLuci => io.Platform.environment['LUCI_CI'] == 'True';
|
||||
@@ -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 'package:flutter_driver/flutter_driver.dart';
|
||||
import 'package:native_driver/native_driver.dart';
|
||||
import 'package:native_driver/skia_gold.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import '_luci_skia_gold_prelude.dart';
|
||||
|
||||
void main() async {
|
||||
// To test the golden file generation locally, comment out the following line.
|
||||
// autoUpdateGoldenFiles = true;
|
||||
|
||||
const String appName = 'com.example.native_driver_test';
|
||||
late final FlutterDriver flutterDriver;
|
||||
late final NativeDriver nativeDriver;
|
||||
|
||||
setUpAll(() async {
|
||||
if (isLuci) {
|
||||
await enableSkiaGoldComparator();
|
||||
}
|
||||
flutterDriver = await FlutterDriver.connect();
|
||||
nativeDriver = await AndroidNativeDriver.connect(flutterDriver);
|
||||
await nativeDriver.configureForScreenshotTesting();
|
||||
});
|
||||
|
||||
tearDownAll(() async {
|
||||
await nativeDriver.close();
|
||||
await flutterDriver.close();
|
||||
});
|
||||
|
||||
test('should screenshot and match an external smiley face texture', () async {
|
||||
await flutterDriver.waitFor(find.byType('Texture'));
|
||||
|
||||
// On Android: Background the app, trim memory, and restore the app.
|
||||
if (nativeDriver case final AndroidNativeDriver nativeDriver) {
|
||||
print('Backgrounding the app, trimming memory, and resuming the app.');
|
||||
await nativeDriver.backgroundApp();
|
||||
|
||||
print('Trimming memory.');
|
||||
await nativeDriver.simulateLowMemory(appName: appName);
|
||||
|
||||
print('Resuming the app.');
|
||||
await nativeDriver.resumeApp(appName: appName);
|
||||
}
|
||||
|
||||
await expectLater(
|
||||
nativeDriver.screenshot(),
|
||||
matchesGoldenFile('external_texture_smiley_face.android.png'),
|
||||
);
|
||||
}, timeout: Timeout.none);
|
||||
}
|
||||
@@ -3,29 +3,26 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_driver/flutter_driver.dart';
|
||||
import 'package:flutter_driver/src/native_driver.dart';
|
||||
import 'package:native_driver/native_driver.dart';
|
||||
import 'package:native_driver/skia_gold.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import '_flutter_goldens_fork.dart';
|
||||
import '_luci_skia_gold_prelude.dart';
|
||||
|
||||
// TODO(matanlurey): This is done automatically by 'flutter test' but not by
|
||||
// 'flutter drive'. If we get closer to shipping the native 'flutter drive'
|
||||
// command, we should look into if 'flutter_test_config.dart', or a similar
|
||||
// mechanism, can be used to configure this automatically.
|
||||
void main() async {
|
||||
await testExecutable(_main);
|
||||
}
|
||||
|
||||
Future<void> _main() async {
|
||||
// To generate golden files locally, uncomment the following line.
|
||||
// To test the golden file generation locally, comment out the following line.
|
||||
// autoUpdateGoldenFiles = true;
|
||||
|
||||
late FlutterDriver flutterDriver;
|
||||
late NativeDriver nativeDriver;
|
||||
late final FlutterDriver flutterDriver;
|
||||
late final NativeDriver nativeDriver;
|
||||
|
||||
setUpAll(() async {
|
||||
if (isLuci) {
|
||||
await enableSkiaGoldComparator();
|
||||
}
|
||||
flutterDriver = await FlutterDriver.connect();
|
||||
nativeDriver = await AndroidNativeDriver.connect();
|
||||
nativeDriver = await AndroidNativeDriver.connect(flutterDriver);
|
||||
await nativeDriver.configureForScreenshotTesting();
|
||||
});
|
||||
|
||||
tearDownAll(() async {
|
||||
@@ -37,7 +34,7 @@ Future<void> _main() async {
|
||||
await flutterDriver.waitFor(find.byType('DecoratedBox'));
|
||||
await expectLater(
|
||||
nativeDriver.screenshot(),
|
||||
matchesGoldenFile('android_driver_test.BlueRectangle.png'),
|
||||
matchesGoldenFile('fluttered_rendered_blue_rectangle.android.png'),
|
||||
);
|
||||
}, timeout: Timeout.none);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
// 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:flutter_driver/flutter_driver.dart';
|
||||
import 'package:native_driver/native_driver.dart';
|
||||
import 'package:native_driver/skia_gold.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import '_luci_skia_gold_prelude.dart';
|
||||
|
||||
void main() async {
|
||||
// To test the golden file generation locally, comment out the following line.
|
||||
// autoUpdateGoldenFiles = true;
|
||||
|
||||
late final FlutterDriver flutterDriver;
|
||||
late final NativeDriver nativeDriver;
|
||||
|
||||
setUpAll(() async {
|
||||
if (isLuci) {
|
||||
await enableSkiaGoldComparator();
|
||||
}
|
||||
flutterDriver = await FlutterDriver.connect();
|
||||
nativeDriver = await AndroidNativeDriver.connect(flutterDriver);
|
||||
await nativeDriver.configureForScreenshotTesting();
|
||||
});
|
||||
|
||||
tearDownAll(() async {
|
||||
await nativeDriver.close();
|
||||
await flutterDriver.close();
|
||||
});
|
||||
|
||||
test('should screenshot and match a blue -> orange gradient', () async {
|
||||
await flutterDriver.waitFor(find.byType('AndroidView'));
|
||||
await expectLater(
|
||||
nativeDriver.screenshot(),
|
||||
matchesGoldenFile(
|
||||
'platform_view_blue_orange_gradient_portrait.android.png',
|
||||
),
|
||||
);
|
||||
}, timeout: Timeout.none);
|
||||
|
||||
test('should rotate landscape and screenshot the gradient', () async {
|
||||
await flutterDriver.waitFor(find.byType('AndroidView'));
|
||||
await nativeDriver.rotateToLandscape();
|
||||
await expectLater(
|
||||
nativeDriver.screenshot(),
|
||||
matchesGoldenFile(
|
||||
'platform_view_blue_orange_gradient_landscape.android.png',
|
||||
),
|
||||
);
|
||||
|
||||
await nativeDriver.rotateResetDefault();
|
||||
await expectLater(
|
||||
nativeDriver.screenshot(),
|
||||
matchesGoldenFile(
|
||||
'platform_view_blue_orange_gradient_portrait_post_rotation.android.png',
|
||||
),
|
||||
);
|
||||
}, timeout: Timeout.none);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// 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:flutter_driver/flutter_driver.dart';
|
||||
import 'package:native_driver/native_driver.dart';
|
||||
import 'package:native_driver/skia_gold.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import '_luci_skia_gold_prelude.dart';
|
||||
|
||||
void main() async {
|
||||
// To test the golden file generation locally, comment out the following line.
|
||||
// autoUpdateGoldenFiles = true;
|
||||
|
||||
late final FlutterDriver flutterDriver;
|
||||
late final NativeDriver nativeDriver;
|
||||
|
||||
setUpAll(() async {
|
||||
if (isLuci) {
|
||||
await enableSkiaGoldComparator();
|
||||
}
|
||||
flutterDriver = await FlutterDriver.connect();
|
||||
nativeDriver = await AndroidNativeDriver.connect(flutterDriver);
|
||||
await nativeDriver.configureForScreenshotTesting();
|
||||
});
|
||||
|
||||
tearDownAll(() async {
|
||||
await nativeDriver.close();
|
||||
await flutterDriver.close();
|
||||
});
|
||||
|
||||
test('should screenshot a rectangle that becomes blue after a tap', () async {
|
||||
await flutterDriver.waitFor(find.byType('AndroidView'));
|
||||
await expectLater(
|
||||
nativeDriver.screenshot(),
|
||||
matchesGoldenFile(
|
||||
'platform_view_tap_color_change_initial.android.png',
|
||||
),
|
||||
);
|
||||
|
||||
await nativeDriver.tap(const ByNativeAccessibilityLabel('Change color'));
|
||||
await expectLater(
|
||||
nativeDriver.screenshot(),
|
||||
matchesGoldenFile(
|
||||
'platform_view_tap_color_change_tapped.android.png',
|
||||
),
|
||||
);
|
||||
}, timeout: Timeout.none);
|
||||
}
|
||||
21
dev/tools/native_driver/README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Flutter Native Driver
|
||||
|
||||
This a minimal library on top of `flutter_driver` that provides extensions for
|
||||
interacting with the native platform, to otherwise perform actions that are not
|
||||
possible purely through Flutter Driver, and would want to run as an _external_
|
||||
test (run on the host, not on the device):
|
||||
|
||||
- Take a screenshot, including of _native_ widgets (platform views, textures)
|
||||
- Tap on a native widget
|
||||
- Rotate the device
|
||||
- (Android Only) Background an app and send a "trim memory" signal to the device
|
||||
|
||||
> [!NOTE]
|
||||
>
|
||||
> While this library runs on Flutter's own CI, and is used to test Flutter's
|
||||
> Platform Views, it is not officially supported as an external API, and may
|
||||
> change or be removed at any time. We recommend you use existing testing
|
||||
> infrastructure, such as:
|
||||
>
|
||||
> - [Integration Test](https://docs.flutter.dev/testing/integration-tests)
|
||||
> - [Patrol](https://github.com/leancodepl/patrol)
|
||||
123
dev/tools/native_driver/lib/extension.dart
Normal file
@@ -0,0 +1,123 @@
|
||||
// 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:convert';
|
||||
|
||||
import 'package:flutter/services.dart' as flt;
|
||||
import 'package:flutter_driver/driver_extension.dart';
|
||||
import 'package:flutter_driver/flutter_driver.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'src/common.dart';
|
||||
|
||||
/// An extension that forwards [NativeCommand]s to a registered plugin.
|
||||
const CommandExtension nativeDriverCommands = NativeDriverCommandExtension(
|
||||
flt.MethodChannel('native_driver'),
|
||||
);
|
||||
|
||||
/// An extension that forwards [NativeCommand]s to a registered plugin.
|
||||
///
|
||||
/// This extension is used to communicate with a platform plugin, and relays
|
||||
/// [NativeCommand]s to the platform plugin, and resolves the result as a
|
||||
/// [NativeResult], both thin wrappers around a `Map<String, Object?>` (JSON
|
||||
/// compatible object).
|
||||
///
|
||||
/// A singleton default instance of this class is [nativeDriverCommands].
|
||||
final class NativeDriverCommandExtension implements CommandExtension {
|
||||
/// Creates a new [NativeDriverCommandExtension] with the given [channel].
|
||||
///
|
||||
/// Can be used in exceptional cases where a custom [MethodChannel] is needed;
|
||||
/// otherwise, use the singleton [nativeDriverCommands].
|
||||
const NativeDriverCommandExtension(this._channel);
|
||||
final flt.MethodChannel _channel;
|
||||
|
||||
@override
|
||||
Future<Result> call(
|
||||
Command command,
|
||||
WidgetController prober,
|
||||
CreateFinderFactory finderFactory,
|
||||
CommandHandlerFactory handlerFactory,
|
||||
) async {
|
||||
if (command is! NativeCommand) {
|
||||
throw ArgumentError.value(command, 'command', 'Expected a NativeCommand');
|
||||
}
|
||||
if (await _builtInCall(command.method) case final Result result) {
|
||||
return result;
|
||||
}
|
||||
final Object? result = await _channel.invokeMethod<Object>(
|
||||
command.method,
|
||||
command.arguments,
|
||||
);
|
||||
if (result == null) {
|
||||
return const _MethodChannelResult(<String, Object?>{});
|
||||
}
|
||||
if (result is! Map<String, Object?>) {
|
||||
throw ArgumentError.value(
|
||||
result,
|
||||
'result',
|
||||
'Expected a Map<String, Object?>',
|
||||
);
|
||||
}
|
||||
return _MethodChannelResult(result);
|
||||
}
|
||||
|
||||
// While these could have been implemented in native code, they are already
|
||||
// available as engine-bundled platform plugins, so using them directly
|
||||
// reduces the amount of code to be written and maintained.
|
||||
Future<Result?> _builtInCall(String method) async {
|
||||
switch (method) {
|
||||
case 'rotate_landscape':
|
||||
await flt.SystemChrome.setPreferredOrientations(
|
||||
const <flt.DeviceOrientation>[flt.DeviceOrientation.landscapeLeft],
|
||||
);
|
||||
return Result.empty;
|
||||
case 'rotate_default':
|
||||
await flt.SystemChrome.setPreferredOrientations(
|
||||
const <flt.DeviceOrientation>[],
|
||||
);
|
||||
return Result.empty;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String get commandKind => 'native_driver';
|
||||
|
||||
@override
|
||||
NativeCommand deserialize(
|
||||
Map<String, String> params,
|
||||
DeserializeFinderFactory finderFactory,
|
||||
DeserializeCommandFactory commandFactory,
|
||||
) {
|
||||
final String? method = params['method'];
|
||||
if (method == null) {
|
||||
throw ArgumentError.value(params, 'params', 'Missing method');
|
||||
}
|
||||
final String? arguments = params['arguments'];
|
||||
final Map<String, Object?>? decoded;
|
||||
if (arguments == null) {
|
||||
decoded = null;
|
||||
} else {
|
||||
final Object? intermediate = json.decode(arguments);
|
||||
if (intermediate is! Map<String, Object?>) {
|
||||
throw ArgumentError.value(
|
||||
arguments,
|
||||
'arguments',
|
||||
'Expected a Map<String, Object?>',
|
||||
);
|
||||
}
|
||||
decoded = intermediate;
|
||||
}
|
||||
return NativeCommand(method, arguments: decoded);
|
||||
}
|
||||
}
|
||||
|
||||
final class _MethodChannelResult implements Result {
|
||||
const _MethodChannelResult(this._json);
|
||||
final Map<String, Object?> _json;
|
||||
|
||||
@override
|
||||
Map<String, Object?> toJson() => _json;
|
||||
}
|
||||
27
dev/tools/native_driver/lib/native_driver.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
// 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 'dart:io' as io;
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter_driver/flutter_driver.dart';
|
||||
|
||||
import 'package:matcher/matcher.dart';
|
||||
|
||||
// Similar to `flutter_test`, we ignore the implementation import.
|
||||
// ignore: implementation_imports
|
||||
import 'package:matcher/src/expect/async_matcher.dart';
|
||||
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:test_api/test_api.dart';
|
||||
|
||||
import 'src/common.dart';
|
||||
|
||||
export 'src/backend/android.dart' show AndroidDeviceTarget, AndroidNativeDriver;
|
||||
export 'src/common.dart'
|
||||
show ByNativeAccessibilityLabel, ByNativeIntegerId, NativeFinder;
|
||||
|
||||
part 'src/driver.dart';
|
||||
part 'src/goldens.dart';
|
||||
@@ -12,21 +12,28 @@ import 'dart:io' as io;
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:file/local.dart';
|
||||
import 'package:flutter_driver/src/native_driver.dart';
|
||||
import 'package:flutter_goldens/skia_client.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:platform/platform.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import 'native_driver.dart';
|
||||
|
||||
const LocalFileSystem _localFs = LocalFileSystem();
|
||||
const String _kGoldctlKey = 'GOLDCTL';
|
||||
const String _kGoldctlPresubmitKey = 'GOLD_TRYJOB';
|
||||
|
||||
// TODO(matanlurey): Refactor flutter_goldens to just re-use that code instead.
|
||||
Future<void> testExecutable(
|
||||
FutureOr<void> Function() testMain, {
|
||||
String? namePrefix,
|
||||
}) async {
|
||||
/// Configures [goldenFileComparator] to use Skia Gold (i.e. on CI).
|
||||
///
|
||||
/// Requires that the `GOLDCTL` environment variable is set.
|
||||
///
|
||||
/// If the `GOLD_TRYJOB` environment variable is set, the test will be run in
|
||||
/// presubmit mode; that is, the test will not fail if the comparison fails.
|
||||
/// See <https://github.com/flutter/flutter/blob/main/docs/contributing/testing/Writing-a-golden-file-test-for-package-flutter.md>
|
||||
/// for more information.
|
||||
///
|
||||
/// May optionally provide a [namePrefix] to be used when uploading images.
|
||||
Future<void> enableSkiaGoldComparator({String? namePrefix}) async {
|
||||
assert(
|
||||
goldenFileComparator is NaiveLocalFileComparator,
|
||||
'The flutter_goldens_fork library should be used from a *_test.dart file '
|
||||
@@ -34,11 +41,10 @@ Future<void> testExecutable(
|
||||
'that the correct comparator is used for the current test environment.',
|
||||
);
|
||||
if (!io.Platform.environment.containsKey(_kGoldctlKey)) {
|
||||
io.stderr.writeln(
|
||||
'Environment variable $_kGoldctlKey is not set. Assuming this is a local '
|
||||
'test run and will not upload results to Skia Gold.',
|
||||
throw StateError(
|
||||
'Environment variable $_kGoldctlKey is not set. '
|
||||
'Set it to use Skia Gold.',
|
||||
);
|
||||
return testMain();
|
||||
}
|
||||
final io.Directory tmpDir = io.Directory.systemTemp.createTempSync(
|
||||
'android_driver_test',
|
||||
@@ -67,7 +73,6 @@ Future<void> testExecutable(
|
||||
namePrefix: namePrefix,
|
||||
isPresubmit: isPresubmit,
|
||||
);
|
||||
return testMain();
|
||||
}
|
||||
|
||||
final class _GoldenFileComparator extends GoldenFileComparator {
|
||||
6
dev/tools/native_driver/lib/src/backend/android.dart
Normal file
@@ -0,0 +1,6 @@
|
||||
// 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.
|
||||
|
||||
export 'android/adb.dart';
|
||||
export 'android/driver.dart';
|
||||
318
dev/tools/native_driver/lib/src/backend/android/adb.dart
Normal file
@@ -0,0 +1,318 @@
|
||||
// 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 'dart:typed_data';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
/// A minimal wrapper around the `adb` command-line tool.
|
||||
@internal
|
||||
class Adb {
|
||||
const Adb._(this._prefixArgs, this._proccess);
|
||||
|
||||
/// Creates a new `adb` command runner that uses the `adb` command-line tool.
|
||||
///
|
||||
/// If [adbPath] is not provided, the `adb` command is assumed to be in the
|
||||
/// system's PATH.
|
||||
///
|
||||
/// If [target] is not provided, the target is assumed to be the only running
|
||||
/// emulator or connected device.
|
||||
///
|
||||
/// For testing, [processManager] can be provided to mock the process manager.
|
||||
static Future<Adb> create({
|
||||
String? adbPath,
|
||||
AndroidDeviceTarget? target,
|
||||
@visibleForTesting ProcessManager? processManager,
|
||||
}) async {
|
||||
target ??= const AndroidDeviceTarget.onlyEmulatorOrDevice();
|
||||
final String tool = adbPath ?? 'adb';
|
||||
final Adb adb = Adb._(
|
||||
<String>[tool, ...target._toAdbArgs()],
|
||||
processManager ?? const LocalProcessManager(),
|
||||
);
|
||||
final (bool connected, String? error) = await adb.isDeviceConnected();
|
||||
if (!connected) {
|
||||
throw StateError('No device connected: $error');
|
||||
}
|
||||
return adb;
|
||||
}
|
||||
|
||||
Future<AdbStringResult> _runString(List<String> args) async {
|
||||
final io.ProcessResult result = await _proccess.run(
|
||||
<String>[
|
||||
..._prefixArgs,
|
||||
...args,
|
||||
],
|
||||
);
|
||||
return AdbStringResult(
|
||||
result.stdout as String,
|
||||
exitCode: result.exitCode,
|
||||
stderr: result.stderr as String,
|
||||
);
|
||||
}
|
||||
|
||||
Future<AdbBinaryResult> _runBinary(List<String> args) async {
|
||||
final io.ProcessResult result = await _proccess.run(
|
||||
<String>[
|
||||
..._prefixArgs,
|
||||
...args,
|
||||
],
|
||||
stdoutEncoding: null,
|
||||
);
|
||||
return AdbBinaryResult(
|
||||
result.stdout as Uint8List,
|
||||
exitCode: result.exitCode,
|
||||
stderr: result.stderr as String,
|
||||
);
|
||||
}
|
||||
|
||||
final List<String> _prefixArgs;
|
||||
final ProcessManager _proccess;
|
||||
|
||||
/// Returns whether the device is currently connected.
|
||||
///
|
||||
/// Returns a tuple of a boolean indicating whether the device is connected
|
||||
/// and an error message if the device is not connected. If the device is
|
||||
/// connected, the error message is `null`.
|
||||
Future<(bool connected, String? error)> isDeviceConnected() async {
|
||||
final AdbStringResult result = await _runString(<String>[
|
||||
'shell',
|
||||
'echo',
|
||||
'connected',
|
||||
]);
|
||||
if (result.exitCode != 0) {
|
||||
return (false, result.stderr);
|
||||
} else {
|
||||
return (true, null);
|
||||
}
|
||||
}
|
||||
|
||||
/// Takes a screenshot of the device.
|
||||
Future<Uint8List> screencap() async {
|
||||
final AdbBinaryResult result = await _runBinary(<String>[
|
||||
'exec-out',
|
||||
'screencap',
|
||||
'-p',
|
||||
]);
|
||||
if (result.exitCode != 0) {
|
||||
throw StateError('Failed to take screenshot: ${result.stderr}');
|
||||
}
|
||||
return result.stdout;
|
||||
}
|
||||
|
||||
/// Taps on the screen at the given [x] and [y] coordinates.
|
||||
Future<void> tap(int x, int y) async {
|
||||
final AdbStringResult result = await _runString(<String>[
|
||||
'shell',
|
||||
'input',
|
||||
'tap',
|
||||
'$x',
|
||||
'$y',
|
||||
]);
|
||||
if (result.exitCode != 0) {
|
||||
throw StateError('Failed to tap at $x, $y: ${result.stderr}');
|
||||
}
|
||||
}
|
||||
|
||||
/// Sends the device to the home screen.
|
||||
Future<void> sendToHome() async {
|
||||
final AdbStringResult result = await _runString(<String>[
|
||||
'shell',
|
||||
'input',
|
||||
'keyevent',
|
||||
'KEYCODE_HOME',
|
||||
]);
|
||||
if (result.exitCode != 0) {
|
||||
throw StateError('Failed to send to home: ${result.stderr}');
|
||||
}
|
||||
}
|
||||
|
||||
/// Simulate low memory conditions on the device.
|
||||
Future<void> trimMemory({required String appName}) async {
|
||||
final AdbStringResult result = await _runString(<String>[
|
||||
'shell',
|
||||
'am',
|
||||
'send-trim-memory',
|
||||
appName,
|
||||
'MODERATE',
|
||||
]);
|
||||
if (result.exitCode != 0) {
|
||||
throw StateError('Failed to simulate low memory: ${result.stderr}');
|
||||
}
|
||||
}
|
||||
|
||||
/// Resume a backgrounded app (i.e. after [sendToHome]).
|
||||
Future<void> resumeApp({
|
||||
required String appName,
|
||||
String activityName = '.MainActivity',
|
||||
}) async {
|
||||
final AdbStringResult result = await _runString(<String>[
|
||||
'shell',
|
||||
'am',
|
||||
'start',
|
||||
'-n',
|
||||
'$appName/$activityName',
|
||||
]);
|
||||
if (result.exitCode != 0) {
|
||||
throw StateError('Failed to resume app: ${result.stderr}');
|
||||
}
|
||||
}
|
||||
|
||||
/// Disable confirnations for immersive mode.
|
||||
Future<void> disableImmersiveModeConfirmations() async {
|
||||
final AdbStringResult result = await _runString(<String>[
|
||||
'shell',
|
||||
'settings',
|
||||
'put',
|
||||
'secure',
|
||||
'immersive_mode_confirmations',
|
||||
'confirmed',
|
||||
]);
|
||||
if (result.exitCode != 0) {
|
||||
throw StateError(
|
||||
'Failed to disable immersive mode confirmations: ${result.stderr}',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Disable animations on the device.
|
||||
Future<void> disableAnimations() async {
|
||||
const Map<String, String> settings = <String, String>{
|
||||
'show_surface_updates': '1',
|
||||
'transition_animation_scale': '0',
|
||||
'window_animation_scale': '0',
|
||||
'animator_duration_scale': '0',
|
||||
};
|
||||
for (final MapEntry<String, String> entry in settings.entries) {
|
||||
final AdbStringResult result = await _runString(<String>[
|
||||
'shell',
|
||||
'settings',
|
||||
'put',
|
||||
'global',
|
||||
entry.key,
|
||||
entry.value,
|
||||
]);
|
||||
if (result.exitCode != 0) {
|
||||
throw StateError('Failed to disable animations: ${result.stderr}');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Possible results of an `adb` command.
|
||||
@internal
|
||||
sealed class AdbResult {
|
||||
/// Creates a new `adb` result.
|
||||
const AdbResult._({this.exitCode = 0, this.stderr = ''});
|
||||
|
||||
/// The exit code of the `adb` command.
|
||||
final int exitCode;
|
||||
|
||||
/// The standard error output of the `adb` command.
|
||||
final String stderr;
|
||||
}
|
||||
|
||||
@internal
|
||||
final class AdbStringResult extends AdbResult {
|
||||
AdbStringResult(this.stdout, {super.stderr, super.exitCode}) : super._();
|
||||
|
||||
/// The standard output of the `adb` command.
|
||||
final String stdout;
|
||||
}
|
||||
|
||||
@internal
|
||||
final class AdbBinaryResult extends AdbResult {
|
||||
AdbBinaryResult(this.stdout, {super.stderr, super.exitCode}) : super._();
|
||||
|
||||
/// The standard output of the `adb` command.
|
||||
final Uint8List stdout;
|
||||
}
|
||||
|
||||
/// Represents a target device running Android.
|
||||
sealed class AndroidDeviceTarget {
|
||||
/// Represents a device with the given [serialNumber].
|
||||
///
|
||||
/// This is the recommended way to target a specific device, and uses the
|
||||
/// device's serial number, as reported by `adb devices`, to identify the
|
||||
/// device:
|
||||
///
|
||||
/// ```sh
|
||||
/// $ adb devices
|
||||
/// List of devices attached
|
||||
/// emulator-5554 device
|
||||
/// ```
|
||||
///
|
||||
/// In this example, the serial number is `emulator-5554`:
|
||||
///
|
||||
/// ```dart
|
||||
/// const AndroidDeviceTarget target = AndroidDeviceTarget.bySerial('emulator-5554');
|
||||
/// ```
|
||||
const factory AndroidDeviceTarget.bySerial(
|
||||
String serialNumber,
|
||||
) = _SerialDeviceTarget;
|
||||
|
||||
/// Represents the only running emulator _or_ connected device.
|
||||
///
|
||||
/// This is equivalent to using `adb` without `-e`, `-d`, or `-s`.
|
||||
const factory AndroidDeviceTarget.onlyEmulatorOrDevice() = _SingleAnyTarget;
|
||||
|
||||
/// Represents the only running emulator on the host machine.
|
||||
///
|
||||
/// This is equivalent to using `adb -e`, a _single_ emulator must be running.
|
||||
const factory AndroidDeviceTarget.onlyEmulator() = _SingleEmulatorTarget;
|
||||
|
||||
/// Represents the only connected device on the host machine.
|
||||
///
|
||||
/// This is equivalent to using `adb -d`, a _single_ device must be connected.
|
||||
const factory AndroidDeviceTarget.onlyDevice() = _SingleDeviceTarget;
|
||||
|
||||
/// Returns the arguments to pass to `adb` to target this device.
|
||||
List<String> _toAdbArgs();
|
||||
}
|
||||
|
||||
final class _SerialDeviceTarget implements AndroidDeviceTarget {
|
||||
const _SerialDeviceTarget(this.serialNumber);
|
||||
final String serialNumber;
|
||||
|
||||
@override
|
||||
List<String> _toAdbArgs() => <String>['-s', serialNumber];
|
||||
}
|
||||
|
||||
final class _SingleEmulatorTarget implements AndroidDeviceTarget {
|
||||
const _SingleEmulatorTarget();
|
||||
|
||||
@override
|
||||
List<String> _toAdbArgs() => const <String>['-e'];
|
||||
}
|
||||
|
||||
final class _SingleDeviceTarget implements AndroidDeviceTarget {
|
||||
const _SingleDeviceTarget();
|
||||
|
||||
@override
|
||||
List<String> _toAdbArgs() => const <String>['-d'];
|
||||
}
|
||||
|
||||
final class _SingleAnyTarget implements AndroidDeviceTarget {
|
||||
const _SingleAnyTarget();
|
||||
|
||||
@override
|
||||
List<String> _toAdbArgs() => const <String>[];
|
||||
}
|
||||
|
||||
/// Represents the possible screen orientations on Android.
|
||||
enum AdbUserRotation {
|
||||
/// Portrait orientation.
|
||||
portrait,
|
||||
|
||||
/// Landscape orientation.
|
||||
landscape,
|
||||
|
||||
/// Reverse portrait orientation, i.e., portrait upside down.
|
||||
reversePortrait,
|
||||
|
||||
/// Reverse landscape orientation, i.e., landscape upside down.
|
||||
reverseLandscape;
|
||||
}
|
||||
151
dev/tools/native_driver/lib/src/backend/android/driver.dart
Normal file
@@ -0,0 +1,151 @@
|
||||
// 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 'dart:typed_data';
|
||||
|
||||
import 'package:flutter_driver/flutter_driver.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
|
||||
import '../../../native_driver.dart';
|
||||
import '../../common.dart';
|
||||
import 'adb.dart';
|
||||
|
||||
/// Drives an Android device or emulator that is running a Flutter application.
|
||||
final class AndroidNativeDriver implements NativeDriver {
|
||||
/// Assumes a connected device or emulator via [adb].
|
||||
///
|
||||
/// This constructor is intended for testing purposes only.
|
||||
@visibleForTesting
|
||||
AndroidNativeDriver.forTesting({
|
||||
required Adb adb,
|
||||
required FlutterDriver driver,
|
||||
required io.Directory tempDirectory,
|
||||
}) : this._(adb, driver, tempDirectory);
|
||||
|
||||
AndroidNativeDriver._(this._adb, this._driver, this._tmpDir);
|
||||
final Adb _adb;
|
||||
final FlutterDriver _driver;
|
||||
final io.Directory _tmpDir;
|
||||
|
||||
/// Connects to a device or emulator identified by [target], which defaults to
|
||||
/// the only running emulator or connected device.
|
||||
///
|
||||
/// If [adbPath] is not provided, the `adb` command is assumed to be in the
|
||||
/// system's PATH.
|
||||
///
|
||||
/// If [tempDirectory] is not provided, a temporary directory will be created
|
||||
/// in the system's temporary directory.
|
||||
static Future<AndroidNativeDriver> connect(
|
||||
FlutterDriver driver, {
|
||||
AndroidDeviceTarget? target,
|
||||
String? adbPath,
|
||||
io.Directory? tempDirectory,
|
||||
}) async {
|
||||
final Adb adb = await Adb.create(
|
||||
adbPath: adbPath,
|
||||
target: target,
|
||||
);
|
||||
tempDirectory ??= io.Directory.systemTemp.createTempSync('native_driver.');
|
||||
final AndroidNativeDriver nativeDriver = AndroidNativeDriver.forTesting(
|
||||
adb: adb,
|
||||
driver: driver,
|
||||
tempDirectory: tempDirectory,
|
||||
);
|
||||
await nativeDriver.ping();
|
||||
return nativeDriver;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() async {
|
||||
await _tmpDir.delete(recursive: true);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> configureForScreenshotTesting() async {
|
||||
await _adb.disableImmersiveModeConfirmations();
|
||||
await _adb.disableAnimations();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> tap(NativeFinder finder) async {
|
||||
await _driver.sendCommand(NativeCommand.tap(finder));
|
||||
}
|
||||
|
||||
/// Waits for 2 seconds before completing.
|
||||
///
|
||||
/// There is no perfect way, outside of polling, to know when the device is
|
||||
/// "stable" or has "stabilized" after a state change. The way that commands
|
||||
/// such as [FlutterDriver.screenshot] handle this is to wait for 2 seconds
|
||||
/// as a baseline, and then proceed with the command.
|
||||
static Future<void> _waitFor2s() async {
|
||||
await Future<void>.delayed(const Duration(seconds: 2));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<NativeScreenshot> screenshot() async {
|
||||
// Indentical wait to what `FlutterDriver.screenshot` does.
|
||||
await _waitFor2s();
|
||||
return _AdbScreencap(await _adb.screencap(), _tmpDir);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Duration> ping() async {
|
||||
final Stopwatch stopwatch = Stopwatch()..start();
|
||||
await _driver.sendCommand(NativeCommand.ping);
|
||||
return stopwatch.elapsed;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> rotateToLandscape() async {
|
||||
_driver.sendCommand(NativeCommand.rotateLandscape);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> rotateResetDefault() async {
|
||||
_driver.sendCommand(NativeCommand.rotateDefault);
|
||||
}
|
||||
|
||||
/// Background the app by pressing the home button.
|
||||
Future<void> backgroundApp() async {
|
||||
await _adb.sendToHome();
|
||||
await _waitFor2s();
|
||||
}
|
||||
|
||||
/// Resumes the app by selecting it from the recent apps list.
|
||||
Future<void> resumeApp({required String appName}) async {
|
||||
await _adb.resumeApp(appName: appName);
|
||||
await _waitFor2s();
|
||||
}
|
||||
|
||||
/// Send a trim memory signal to the app to force it to release memory.
|
||||
Future<void> simulateLowMemory({required String appName}) async {
|
||||
await _adb.trimMemory(appName: appName);
|
||||
await _waitFor2s();
|
||||
}
|
||||
}
|
||||
|
||||
final class _AdbScreencap implements NativeScreenshot {
|
||||
const _AdbScreencap(this._bytes, this._tmpDir);
|
||||
|
||||
/// Raw bytes of the screenshot in PNG format.
|
||||
final Uint8List _bytes;
|
||||
|
||||
/// Temporary directory to use as a default location for saving.
|
||||
final io.Directory _tmpDir;
|
||||
|
||||
static int _lastScreenshotId = 0;
|
||||
|
||||
@override
|
||||
Future<String> saveAs([String? path]) async {
|
||||
final int id = _lastScreenshotId++;
|
||||
path ??= p.join(_tmpDir.path, 'screenshot_$id.png');
|
||||
await io.File(path).writeAsBytes(_bytes);
|
||||
return path;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Uint8List> readAsBytes() async => _bytes;
|
||||
}
|
||||
131
dev/tools/native_driver/lib/src/common.dart
Normal file
@@ -0,0 +1,131 @@
|
||||
// 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:convert';
|
||||
|
||||
// This code has to be available in both the Flutter app and Dart VM test.
|
||||
// ignore: implementation_imports
|
||||
import 'package:flutter_driver/src/common/message.dart';
|
||||
|
||||
/// A command that is forwarded to a registered plugin.
|
||||
final class NativeCommand extends Command {
|
||||
/// Creates a new [NativeCommand] with the given [method].
|
||||
const NativeCommand(this.method, {this.arguments, super.timeout});
|
||||
|
||||
/// Tries to tap a native view by a selector.
|
||||
factory NativeCommand.tap(NativeFinder finder) {
|
||||
return NativeCommand('tap_view', arguments: finder);
|
||||
}
|
||||
|
||||
/// Requests that the device be rotated to landscape mode.
|
||||
static const NativeCommand rotateLandscape = NativeCommand(
|
||||
'rotate_landscape',
|
||||
);
|
||||
|
||||
/// Requests that the device reset its rotation to the default orientation.
|
||||
static const NativeCommand rotateDefault = NativeCommand(
|
||||
'rotate_default',
|
||||
);
|
||||
|
||||
/// Pings the device to ensure it is responsive.
|
||||
static const NativeCommand ping = NativeCommand(
|
||||
'ping',
|
||||
);
|
||||
|
||||
/// The method to call on the plugin.
|
||||
final String method;
|
||||
|
||||
/// What arguments to pass when invoking the [method].
|
||||
final Object? arguments;
|
||||
|
||||
@override
|
||||
String get kind => 'native_driver';
|
||||
|
||||
@override
|
||||
Map<String, String> serialize() {
|
||||
final Map<String, String> serialized = super.serialize();
|
||||
serialized['method'] = method;
|
||||
if (arguments != null) {
|
||||
serialized['arguments'] = jsonEncode(arguments);
|
||||
}
|
||||
return serialized;
|
||||
}
|
||||
}
|
||||
|
||||
/// A result from a [NativeCommand].
|
||||
final class NativeResult extends Result {
|
||||
/// Creates a new [NativeResult].
|
||||
const NativeResult();
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() => const <String, Object?>{};
|
||||
}
|
||||
|
||||
/// An object that descrbes searching for _native_ elements.
|
||||
sealed class NativeFinder {
|
||||
const NativeFinder();
|
||||
|
||||
/// Serializes to JSON.
|
||||
Map<String, Object?> toJson() => const <String, Object?>{};
|
||||
}
|
||||
|
||||
/// Finds a native element by its native accessibility label.
|
||||
final class ByNativeAccessibilityLabel extends NativeFinder {
|
||||
/// Creates a new [ByNativeSemanticsLabel] finder.
|
||||
const ByNativeAccessibilityLabel(this.label);
|
||||
|
||||
/// The label to search for.
|
||||
///
|
||||
/// ## Android
|
||||
///
|
||||
/// On Android, this label is the `contentDescription` of the view:
|
||||
///
|
||||
/// ```java
|
||||
/// view.setContentDescription("My Label");
|
||||
/// ```
|
||||
final String label;
|
||||
|
||||
@override
|
||||
Map<String, String> toJson() {
|
||||
return <String, String>{
|
||||
'kind': 'byNativeAccessibilityLabel',
|
||||
'label': label,
|
||||
};
|
||||
}
|
||||
|
||||
/// Deserializes this finder from the value generated by [serialize].
|
||||
static ByNativeAccessibilityLabel deserialize(Map<String, String> params) {
|
||||
return ByNativeAccessibilityLabel(params['label']!);
|
||||
}
|
||||
}
|
||||
|
||||
/// Finds a native element by its native integer-based ID.
|
||||
final class ByNativeIntegerId extends NativeFinder {
|
||||
/// Creates a new [ByNativeIntegerId] finder.
|
||||
const ByNativeIntegerId(this.id);
|
||||
|
||||
/// The integer ID to search for.
|
||||
///
|
||||
/// ## Android
|
||||
///
|
||||
/// On Android, this ID is the `View.getId()` of the view:
|
||||
///
|
||||
/// ```java
|
||||
/// view.setId(42);
|
||||
/// ```
|
||||
final int id;
|
||||
|
||||
@override
|
||||
Map<String, String> toJson() {
|
||||
return <String, String>{
|
||||
'kind': 'byNativeIntegerId',
|
||||
'id': id.toString(),
|
||||
};
|
||||
}
|
||||
|
||||
/// Deserializes this finder from the value generated by [serialize].
|
||||
static ByNativeIntegerId deserialize(Map<String, String> params) {
|
||||
return ByNativeIntegerId(int.parse(params['id']!));
|
||||
}
|
||||
}
|
||||
@@ -2,18 +2,14 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
/// @docImport 'package:flutter_driver/flutter_driver.dart';
|
||||
library;
|
||||
|
||||
import 'dart:typed_data';
|
||||
part of '../native_driver.dart';
|
||||
|
||||
/// Drives a native device or emulator that is running a Flutter application.
|
||||
///
|
||||
/// Unlike [FlutterDriver], a [NativeDriver] is backed by a platform specific
|
||||
/// implementation that might interact with out-of-process services, such as
|
||||
/// `adb` for Android or `ios-deploy` for iOS, and might require additional
|
||||
/// setup (e.g., adding test-only plugins to the application under test) for
|
||||
/// full functionality.
|
||||
/// `adb` for Android and might require additional setup (e.g., adding test-only
|
||||
/// plugins to the application under test) for full functionality.
|
||||
///
|
||||
/// API that is available directly on [NativeDriver] is considered _lowest
|
||||
/// common denominator_ and is guaranteed to work on all platforms supported by
|
||||
@@ -26,6 +22,29 @@ abstract interface class NativeDriver {
|
||||
/// After calling this method, the driver is no longer usable.
|
||||
Future<void> close();
|
||||
|
||||
/// Configures the device for (more) deterministic screenshots if possible.
|
||||
///
|
||||
/// This method should be called during `setUpAll` if tests are going to
|
||||
/// compare screenshots to golden files.
|
||||
///
|
||||
/// Not all platforms support this method, and it is a no-op on platforms that
|
||||
/// do not.
|
||||
Future<void> configureForScreenshotTesting();
|
||||
|
||||
/// Pings the device to ensure it is responsive.
|
||||
///
|
||||
/// The implementation should return a future that completes when a command
|
||||
/// is passed to the device (from the driver script), and to the native driver
|
||||
/// plugin (if applicable), and back to the driver script.
|
||||
///
|
||||
/// The duration of the round trip is returned, typically calculated as:
|
||||
/// ```dart
|
||||
/// final Stopwatch stopwatch = Stopwatch()..start();
|
||||
/// await doPing();
|
||||
/// return stopwatch.elapsed;
|
||||
/// ```
|
||||
Future<Duration> ping();
|
||||
|
||||
/// Take a screenshot using a platform-specific mechanism.
|
||||
///
|
||||
/// The image is returned as an opaque handle that can be used to retrieve
|
||||
@@ -33,6 +52,19 @@ abstract interface class NativeDriver {
|
||||
/// include platform-specific system UI elements, such as the status bar or
|
||||
/// navigation bar.
|
||||
Future<NativeScreenshot> screenshot();
|
||||
|
||||
/// Rotates the device to landscape orientation.
|
||||
Future<void> rotateToLandscape();
|
||||
|
||||
/// Returns the device to its default orientation.
|
||||
Future<void> rotateResetDefault();
|
||||
|
||||
/// Taps on a native view found by a selector.
|
||||
///
|
||||
/// The [finder] is a platform-specific object that describes how to search
|
||||
/// for a view to tap on. The method completes when the tap is complete,
|
||||
/// or throws if a view cannot be found or tapped.
|
||||
Future<void> tap(NativeFinder finder);
|
||||
}
|
||||
|
||||
/// An opaque handle to a screenshot taken on a native device.
|
||||
@@ -2,47 +2,14 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
/// A partial copy of [flutter_test.matchesGoldenFile] and supporting code.
|
||||
///
|
||||
/// Flutter driver runs in the standalone Dart VM, which does not have access to
|
||||
/// the Flutter test library or `dart:ui`. This file provides a subset of the
|
||||
/// functionality of `flutter_test`'s `matchesGoldenFile` function, and we can
|
||||
/// consider refactoring this code to be shared between the two libraries
|
||||
/// (https://github.com/flutter/flutter/issues/152257).
|
||||
///
|
||||
/// ## TODOs
|
||||
///
|
||||
/// - [ ] Figure out a code-sharing strategy with `flutter_test`.
|
||||
///
|
||||
/// The basics, such as the matcher and APIs, could definitely be shared.
|
||||
///
|
||||
/// - [ ] Consider how local image diffing could be shared, if at all.
|
||||
///
|
||||
/// The `flutter_test` implementation uses `dart:ui`, which is not available
|
||||
/// today in a Flutter driver script. We could either (a) provide a different
|
||||
/// implementation for Flutter driver, or (b) provide a way, such as using
|
||||
/// `flutter_tester` to run the tests in a Flutter context, to use the same
|
||||
/// implementation.
|
||||
///
|
||||
/// - [ ] Teach `flutter drive` to use and provide `--update-goldens` flag.
|
||||
///
|
||||
/// @docImport 'package:flutter_test/flutter_test.dart' as flutter_test;
|
||||
library;
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io' as io;
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:matcher/matcher.dart';
|
||||
|
||||
// Similar to `flutter_test`, we ignore the implementation import.
|
||||
// ignore: implementation_imports
|
||||
import 'package:matcher/src/expect/async_matcher.dart';
|
||||
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:test_api/test_api.dart';
|
||||
|
||||
import 'driver.dart';
|
||||
// A partial copy of [flutter_test.matchesGoldenFile] and supporting code.
|
||||
//
|
||||
// Flutter driver runs in the standalone Dart VM, which does not have access to
|
||||
// the Flutter test library or `dart:ui`. This file provides a subset of the
|
||||
// functionality of `flutter_test`'s `matchesGoldenFile` function, and we can
|
||||
// consider refactoring this code to be shared between the two libraries
|
||||
// (https://github.com/flutter/flutter/issues/152257).
|
||||
part of '../native_driver.dart';
|
||||
|
||||
/// Whether golden files should be automatically updated during tests rather
|
||||
/// than compared to the image bytes recorded by the tests.
|
||||
@@ -62,7 +29,10 @@ GoldenFileComparator goldenFileComparator = const NaiveLocalFileComparator._();
|
||||
///
|
||||
/// Instances of this comparator will be used as the backend for
|
||||
/// [matchesGoldenFile].
|
||||
abstract mixin class GoldenFileComparator {
|
||||
abstract class GoldenFileComparator {
|
||||
/// @nodoc
|
||||
const GoldenFileComparator();
|
||||
|
||||
/// Compares the pixels of decoded png [imageBytes] against the golden file
|
||||
/// identified by [golden].
|
||||
///
|
||||
@@ -114,7 +84,7 @@ abstract mixin class GoldenFileComparator {
|
||||
/// returning true only if there's an exact match. In cases where the captured
|
||||
/// test image does not match the golden file, this comparator will provide a
|
||||
/// fairly unhelpful error message, which could be improved in the future.
|
||||
final class NaiveLocalFileComparator with GoldenFileComparator {
|
||||
final class NaiveLocalFileComparator extends GoldenFileComparator {
|
||||
const NaiveLocalFileComparator._();
|
||||
|
||||
@override
|
||||
79
dev/tools/native_driver/pubspec.yaml
Normal file
@@ -0,0 +1,79 @@
|
||||
name: native_driver
|
||||
|
||||
environment:
|
||||
sdk: ^3.5.0
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
flutter_driver:
|
||||
sdk: flutter
|
||||
flutter_goldens:
|
||||
sdk: flutter
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
matcher: 0.12.16+1
|
||||
meta: 1.15.0
|
||||
path: 1.9.0
|
||||
platform: 3.1.5
|
||||
process: 5.0.2
|
||||
test_api: 0.7.3
|
||||
|
||||
async: 2.11.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
boolean_selector: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
characters: 1.3.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
clock: 1.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
collection: 1.19.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
crypto: 3.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
fake_async: 1.3.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
file: 7.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
leak_tracker: 10.0.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
leak_tracker_flutter_testing: 3.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
leak_tracker_testing: 3.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
material_color_utilities: 0.11.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
source_span: 1.10.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
stack_trace: 1.11.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
stream_channel: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
string_scanner: 1.3.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
sync_http: 0.3.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
term_glyph: 1.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
typed_data: 1.3.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
vector_math: 2.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
vm_service: 14.2.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
webdriver: 3.0.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
|
||||
dev_dependencies:
|
||||
test: 1.25.8
|
||||
|
||||
_fe_analyzer_shared: 74.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
analyzer: 6.9.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
args: 2.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
convert: 3.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
coverage: 1.9.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
frontend_server_client: 4.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
glob: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
http_multi_server: 3.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
http_parser: 4.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
io: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
js: 0.7.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
logging: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
mime: 1.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
node_preamble: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
package_config: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
pool: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
pub_semver: 2.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
shelf: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
shelf_packages_handler: 3.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
shelf_static: 1.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
shelf_web_socket: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
source_map_stack_trace: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
source_maps: 0.10.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
test_core: 0.6.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
watcher: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
web: 1.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
web_socket: 0.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
web_socket_channel: 3.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
webkit_inspection_protocol: 1.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
yaml: 3.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
|
||||
# PUBSPEC CHECKSUM: 65e8
|
||||
132
dev/tools/native_driver/test/adb_fake_io_test.dart
Normal file
@@ -0,0 +1,132 @@
|
||||
// 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:typed_data';
|
||||
|
||||
import 'package:native_driver/src/backend/android/adb.dart';
|
||||
import 'package:process/process.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'src/fake_process_manager.dart';
|
||||
|
||||
// These tests are fake IO tests, so they don't actually run any commands.
|
||||
void main() {
|
||||
group('AndroidDeviceTarget', () {
|
||||
late List<String> caughtArgs;
|
||||
late FakeProcessManager processManager;
|
||||
|
||||
setUp(() {
|
||||
caughtArgs = <String>[];
|
||||
processManager = FakeProcessManager((
|
||||
String exec,
|
||||
List<String> args,
|
||||
) async {
|
||||
assert(caughtArgs.isEmpty, 'Should only catch one call to run');
|
||||
caughtArgs = args;
|
||||
return FakeProcessManager.ok();
|
||||
});
|
||||
});
|
||||
|
||||
test('bySerial emits "-s <number>"', () async {
|
||||
await Adb.create(
|
||||
target: const AndroidDeviceTarget.bySerial('1234'),
|
||||
processManager: processManager,
|
||||
);
|
||||
|
||||
expect(caughtArgs.take(2), <String>['-s', '1234']);
|
||||
});
|
||||
|
||||
test('onlyEmulatorOrDevice emits no arguments', () async {
|
||||
await Adb.create(
|
||||
target: const AndroidDeviceTarget.onlyEmulatorOrDevice(),
|
||||
processManager: processManager,
|
||||
);
|
||||
|
||||
expect(caughtArgs, <String>['shell', 'echo', 'connected']);
|
||||
});
|
||||
|
||||
test('onlyEmulator emits "-e"', () async {
|
||||
await Adb.create(
|
||||
target: const AndroidDeviceTarget.onlyEmulator(),
|
||||
processManager: processManager,
|
||||
);
|
||||
|
||||
expect(caughtArgs.take(1), <String>['-e']);
|
||||
});
|
||||
|
||||
test('onlyDevice emits "-d"', () async {
|
||||
await Adb.create(
|
||||
target: const AndroidDeviceTarget.onlyDevice(),
|
||||
processManager: processManager,
|
||||
);
|
||||
|
||||
expect(caughtArgs.take(1), <String>['-d']);
|
||||
});
|
||||
});
|
||||
|
||||
test('if isDeviceConnected fails, bootstrap fails', () async {
|
||||
final ProcessManager processManager = FakeProcessManager((
|
||||
String exec,
|
||||
List<String> args,
|
||||
) async {
|
||||
return FakeProcessManager.error('error');
|
||||
});
|
||||
|
||||
expect(
|
||||
Adb.create(
|
||||
processManager: processManager,
|
||||
),
|
||||
throwsA(isA<StateError>().having(
|
||||
(StateError e) => e.message,
|
||||
'message',
|
||||
'No device connected: error',
|
||||
)),
|
||||
);
|
||||
});
|
||||
|
||||
test('screencap invokes "exec-out screencap -p"', () async {
|
||||
final FakeProcessManager processManager = FakeProcessManager((
|
||||
String exec,
|
||||
List<String> args,
|
||||
) async {
|
||||
switch (args) {
|
||||
case ['shell', 'echo', 'connected']:
|
||||
return FakeProcessManager.ok('connected');
|
||||
case ['exec-out', 'screencap', '-p']:
|
||||
return FakeProcessManager.okBinary(<int>[0, 1, 2, 3]);
|
||||
default:
|
||||
throw UnsupportedError('Unknown command: $args');
|
||||
}
|
||||
});
|
||||
|
||||
final Adb adb = await Adb.create(
|
||||
processManager: processManager,
|
||||
);
|
||||
|
||||
final Uint8List result = await adb.screencap();
|
||||
expect(result, <int>[0, 1, 2, 3]);
|
||||
});
|
||||
|
||||
test('tap invokes "shell input tap"', () async {
|
||||
final FakeProcessManager processManager = FakeProcessManager((
|
||||
String exec,
|
||||
List<String> args,
|
||||
) async {
|
||||
switch (args) {
|
||||
case ['shell', 'echo', 'connected']:
|
||||
return FakeProcessManager.ok('connected');
|
||||
case ['shell', 'input', 'tap', '1', '2']:
|
||||
return FakeProcessManager.ok();
|
||||
default:
|
||||
throw UnsupportedError('Unknown command: $args');
|
||||
}
|
||||
});
|
||||
|
||||
final Adb adb = await Adb.create(
|
||||
processManager: processManager,
|
||||
);
|
||||
|
||||
await adb.tap(1, 2);
|
||||
});
|
||||
}
|
||||
49
dev/tools/native_driver/test/android_driver_fake_test.dart
Normal file
@@ -0,0 +1,49 @@
|
||||
// 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 'dart:typed_data';
|
||||
|
||||
import 'package:native_driver/native_driver.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'src/fake_adb.dart';
|
||||
import 'src/fake_driver.dart';
|
||||
|
||||
void main() async {
|
||||
test('screenshot calls ADB screencap', () async {
|
||||
final FakeAdb adb = FakeAdb(
|
||||
screencap: () async => Uint8List.fromList(<int>[1, 2, 3, 4]),
|
||||
);
|
||||
final io.Directory tmpDir = io.Directory.systemTemp.createTempSync();
|
||||
final AndroidNativeDriver driver = AndroidNativeDriver.forTesting(
|
||||
adb: adb,
|
||||
driver: const NullFlutterDriver(),
|
||||
tempDirectory: tmpDir,
|
||||
);
|
||||
|
||||
final NativeScreenshot screenshot = await driver.screenshot();
|
||||
await expectLater(screenshot.readAsBytes(), completion(<int>[1, 2, 3, 4]));
|
||||
|
||||
final String path = await screenshot.saveAs();
|
||||
final io.File file = io.File(path);
|
||||
expect(file.readAsBytes(), completion(<int>[1, 2, 3, 4]));
|
||||
|
||||
await driver.close();
|
||||
});
|
||||
|
||||
test('closes deletes the temporary directory', () async {
|
||||
final FakeAdb adb = FakeAdb();
|
||||
final io.Directory tmpDir = io.Directory.systemTemp.createTempSync();
|
||||
final AndroidNativeDriver driver = AndroidNativeDriver.forTesting(
|
||||
adb: adb,
|
||||
driver: const NullFlutterDriver(),
|
||||
tempDirectory: tmpDir,
|
||||
);
|
||||
|
||||
expect(tmpDir.existsSync(), isTrue);
|
||||
await driver.close();
|
||||
expect(tmpDir.existsSync(), isFalse);
|
||||
});
|
||||
}
|
||||
89
dev/tools/native_driver/test/src/fake_adb.dart
Normal file
@@ -0,0 +1,89 @@
|
||||
// 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:typed_data';
|
||||
|
||||
import 'package:native_driver/src/backend/android.dart';
|
||||
|
||||
/// A stub of [Adb] that allows overriding its methods.
|
||||
///
|
||||
/// The default implementation of each method is a simple success case.
|
||||
final class FakeAdb implements Adb {
|
||||
FakeAdb({
|
||||
Future<(bool, String?)> Function()? isDeviceConnected,
|
||||
Future<Uint8List> Function()? screencap,
|
||||
Future<void> Function(int x, int y)? tap,
|
||||
Future<void> Function()? disableImmersiveModeConfirmations,
|
||||
Future<void> Function()? disableAnimations,
|
||||
Future<void> Function()? sendToHome,
|
||||
Future<void> Function(String appName, [String? activityName])? resumeApp,
|
||||
Future<void> Function(String appName)? trimMemory,
|
||||
}) : _isDeviceConnected = isDeviceConnected,
|
||||
_screencap = screencap,
|
||||
_tap = tap,
|
||||
_disableImmersiveModeConfirmations = disableImmersiveModeConfirmations,
|
||||
_disableAnimations = disableAnimations,
|
||||
_sendToHome = sendToHome,
|
||||
_resumeApp = resumeApp,
|
||||
_trimMemory = trimMemory;
|
||||
|
||||
@override
|
||||
Future<(bool, String?)> isDeviceConnected() async {
|
||||
return _isDeviceConnected?.call() ?? (true, null);
|
||||
}
|
||||
|
||||
final Future<(bool, String?)> Function()? _isDeviceConnected;
|
||||
|
||||
@override
|
||||
Future<Uint8List> screencap() {
|
||||
return _screencap?.call() ?? Future<Uint8List>.value(Uint8List(0));
|
||||
}
|
||||
|
||||
final Future<Uint8List> Function()? _screencap;
|
||||
|
||||
@override
|
||||
Future<void> tap(int x, int y) async {
|
||||
return _tap?.call(x, y) ?? Future<void>.value();
|
||||
}
|
||||
|
||||
final Future<void> Function(int x, int y)? _tap;
|
||||
|
||||
@override
|
||||
Future<void> disableImmersiveModeConfirmations() {
|
||||
return _disableImmersiveModeConfirmations?.call() ?? Future<void>.value();
|
||||
}
|
||||
|
||||
final Future<void> Function()? _disableImmersiveModeConfirmations;
|
||||
|
||||
@override
|
||||
Future<void> disableAnimations() {
|
||||
return _disableAnimations?.call() ?? Future<void>.value();
|
||||
}
|
||||
|
||||
final Future<void> Function()? _disableAnimations;
|
||||
|
||||
@override
|
||||
Future<void> sendToHome() {
|
||||
return _sendToHome?.call() ?? Future<void>.value();
|
||||
}
|
||||
|
||||
final Future<void> Function()? _sendToHome;
|
||||
|
||||
@override
|
||||
Future<void> resumeApp({required String appName, String? activityName}) {
|
||||
return _resumeApp?.call(appName, activityName) ?? Future<void>.value();
|
||||
}
|
||||
|
||||
final Future<void> Function(
|
||||
String appName, [
|
||||
String? activityName,
|
||||
])? _resumeApp;
|
||||
|
||||
@override
|
||||
Future<void> trimMemory({required String appName}) {
|
||||
return _trimMemory?.call(appName) ?? Future<void>.value();
|
||||
}
|
||||
|
||||
final Future<void> Function(String appName)? _trimMemory;
|
||||
}
|
||||
13
dev/tools/native_driver/test/src/fake_driver.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
// 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:flutter_driver/flutter_driver.dart';
|
||||
|
||||
/// A fake [FlutterDriver] that throws [UnimplementedError] for all methods.
|
||||
final class NullFlutterDriver implements FlutterDriver {
|
||||
const NullFlutterDriver();
|
||||
|
||||
@override
|
||||
Never noSuchMethod(Invocation invocation) => throw UnimplementedError();
|
||||
}
|
||||
53
dev/tools/native_driver/test/src/fake_process_manager.dart
Normal file
@@ -0,0 +1,53 @@
|
||||
// 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:convert';
|
||||
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:process/process.dart';
|
||||
|
||||
/// A stub of [ProcessManager] that allows mocking the [run] method only.
|
||||
final class FakeProcessManager extends ProcessManager {
|
||||
/// Creates a new [FakeProcessManager] with the given delegate callback.
|
||||
FakeProcessManager(this._runDelegate);
|
||||
final Future<ProcessResult> Function(
|
||||
String executable,
|
||||
List<String> arguments,
|
||||
) _runDelegate;
|
||||
|
||||
@override
|
||||
Never noSuchMethod(_) => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<ProcessResult> run(
|
||||
List<Object> command, {
|
||||
String? workingDirectory,
|
||||
Map<String, String>? environment,
|
||||
bool includeParentEnvironment = true,
|
||||
bool runInShell = false,
|
||||
Encoding? stdoutEncoding = systemEncoding,
|
||||
Encoding? stderrEncoding = systemEncoding,
|
||||
}) {
|
||||
final List<String> strings = command.map((Object e) => '$e').toList();
|
||||
final [String executable, ...List<String> arguments] = strings;
|
||||
return _runDelegate(executable, arguments);
|
||||
}
|
||||
|
||||
/// Returns a [ProcessResult] with the given [stdout].
|
||||
static ProcessResult ok([String stdout = '']) {
|
||||
return ProcessResult(0, 0, stdout, '');
|
||||
}
|
||||
|
||||
/// Returns a [ProcessResult] with the given [stderr].
|
||||
static ProcessResult error([String stderr = '']) {
|
||||
return ProcessResult(0, 1, '', stderr);
|
||||
}
|
||||
|
||||
/// Returns a [ProcessResult] with the given [stdout] binary data.
|
||||
static ProcessResult okBinary(List<int> stdout) {
|
||||
return ProcessResult(0, 0, Uint8List.fromList(stdout), '');
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
# Flutter Native Driver
|
||||
|
||||
An experiment in adding platform-aware functionality to `flutter_driver`.
|
||||
|
||||
Project tracking: <https://github.com/orgs/flutter/projects/154>.
|
||||
|
||||
We'd like to be able to test, within `flutter/flutter` (and friends):
|
||||
|
||||
- Does a web-view load and render the expected content?
|
||||
- Unexpected changes with the native OS, i.e. Android edge-to-edge
|
||||
- Impeller rendering on Android using a real GPU (not swift_shader or Skia)
|
||||
- Does an app correctly respond to application backgrounding and resume?
|
||||
- Interact with native UI elements (not rendered by Flutter) and observe output
|
||||
- Native text/keyboard input (IMEs, virtual keyboards, anything a11y related)
|
||||
|
||||
This project is tracking augmenting `flutter_driver` towards these goals.
|
||||
|
||||
If the project is not successful, the experiment will be turned-down and the
|
||||
code removed or repurposed.
|
||||
|
||||
---
|
||||
|
||||
_Questions?_ Ask in the `#hackers-tests` channel on the Flutter Discord or
|
||||
`@matanlurey` or `@johnmccutchan` on GitHub.
|
||||
@@ -1,202 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// Examples can assume:
|
||||
// import 'package:flutter_driver/src/native/android.dart';
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io' as io;
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
|
||||
import 'driver.dart';
|
||||
|
||||
/// Drives an Android device or emulator that is running a Flutter application.
|
||||
final class AndroidNativeDriver implements NativeDriver {
|
||||
/// Creates a new Android native driver with the provided configuration.
|
||||
///
|
||||
/// The [tempDirectory] argument can be used to specify a custom directory
|
||||
/// where the driver will store temporary files. If not provided, a temporary
|
||||
/// directory will be created in the system's temporary directory.
|
||||
///
|
||||
/// @nodoc
|
||||
@visibleForTesting
|
||||
AndroidNativeDriver({
|
||||
required AndroidDeviceTarget target,
|
||||
String? adbPath,
|
||||
io.Directory? tempDirectory,
|
||||
}) : _adbPath = adbPath ?? 'adb',
|
||||
_target = target,
|
||||
_tmpDir = tempDirectory ??
|
||||
io.Directory.systemTemp.createTempSync('flutter_driver.');
|
||||
|
||||
/// Connects to a device or emulator identified by [target].
|
||||
static Future<AndroidNativeDriver> connect({
|
||||
AndroidDeviceTarget? target,
|
||||
}) async {
|
||||
target ??= const AndroidDeviceTarget.onlyEmulatorOrDevice();
|
||||
final AndroidNativeDriver driver = AndroidNativeDriver(target: target);
|
||||
await driver._smokeTest();
|
||||
return driver;
|
||||
}
|
||||
|
||||
Future<io.ProcessResult> _adb(
|
||||
List<String> args, {
|
||||
Encoding? stdoutEncoding = io.systemEncoding,
|
||||
}) {
|
||||
return io.Process.run(
|
||||
_adbPath,
|
||||
<String>[
|
||||
..._target._toAdbArgs(),
|
||||
...args,
|
||||
],
|
||||
stdoutEncoding: stdoutEncoding,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _smokeTest() async {
|
||||
final io.ProcessResult version = await _adb(<String>['version']);
|
||||
if (version.exitCode != 0) {
|
||||
throw StateError('Failed to run `$_adbPath version`: ${version.stderr}');
|
||||
}
|
||||
|
||||
final io.ProcessResult echo = await _adb(
|
||||
<String>[
|
||||
'shell',
|
||||
'echo',
|
||||
'connected',
|
||||
],
|
||||
);
|
||||
if (echo.exitCode != 0) {
|
||||
throw StateError('Failed to connect to target: ${echo.stderr}');
|
||||
}
|
||||
}
|
||||
|
||||
final String _adbPath;
|
||||
final AndroidDeviceTarget _target;
|
||||
final io.Directory _tmpDir;
|
||||
|
||||
@override
|
||||
Future<void> close() async {
|
||||
await _tmpDir.delete(recursive: true);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<NativeScreenshot> screenshot() async {
|
||||
// Similar pause to the one in `<FlutterDriver>.screenshot()`.
|
||||
await Future<void>.delayed(const Duration(seconds: 2));
|
||||
final io.ProcessResult result = await _adb(
|
||||
<String>[
|
||||
..._target._toAdbArgs(),
|
||||
'exec-out',
|
||||
'screencap',
|
||||
'-p',
|
||||
],
|
||||
stdoutEncoding: null,
|
||||
);
|
||||
|
||||
if (result.exitCode != 0) {
|
||||
throw StateError('Failed to take screenshot: ${result.stderr}');
|
||||
}
|
||||
|
||||
final Uint8List bytes = result.stdout as Uint8List;
|
||||
return _AdbScreencap(bytes, _tmpDir);
|
||||
}
|
||||
}
|
||||
|
||||
final class _AdbScreencap implements NativeScreenshot {
|
||||
const _AdbScreencap(this._bytes, this._tmpDir);
|
||||
|
||||
/// Raw bytes of the screenshot in PNG format.
|
||||
final Uint8List _bytes;
|
||||
|
||||
/// Temporary directory to default to when saving the screenshot.
|
||||
final io.Directory _tmpDir;
|
||||
|
||||
static int _lastScreenshotId = 0;
|
||||
|
||||
@override
|
||||
Future<String> saveAs([String? path]) async {
|
||||
final int id = _lastScreenshotId++;
|
||||
path ??= p.join(_tmpDir.path, '$id.png');
|
||||
await io.File(path).writeAsBytes(_bytes);
|
||||
return path;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Uint8List> readAsBytes() async => _bytes;
|
||||
}
|
||||
|
||||
/// Represents a target device running Android.
|
||||
sealed class AndroidDeviceTarget {
|
||||
/// Represents a device with the given [serialNumber].
|
||||
///
|
||||
/// This is the recommended way to target a specific device, and uses the
|
||||
/// device's serial number, as reported by `adb devices`, to identify the
|
||||
/// device:
|
||||
///
|
||||
/// ```sh
|
||||
/// $ adb devices
|
||||
/// List of devices attached
|
||||
/// emulator-5554 device
|
||||
/// ```
|
||||
///
|
||||
/// In this example, the serial number is `emulator-5554`:
|
||||
///
|
||||
/// ```dart
|
||||
/// const AndroidDeviceTarget target = AndroidDeviceTarget.bySerial('emulator-5554');
|
||||
/// ```
|
||||
const factory AndroidDeviceTarget.bySerial(String serialNumber) =
|
||||
_SerialDeviceTarget;
|
||||
|
||||
/// Represents the only running emulator _or_ connected device.
|
||||
///
|
||||
/// This is equivalent to using `adb` without `-e`, `-d`, or `-s`.
|
||||
const factory AndroidDeviceTarget.onlyEmulatorOrDevice() = _SingleAnyTarget;
|
||||
|
||||
/// Represents the only running emulator on the host machine.
|
||||
///
|
||||
/// This is equivalent to using `adb -e`, a _single_ emulator must be running.
|
||||
const factory AndroidDeviceTarget.onlyRunningEmulator() =
|
||||
_SingleEmulatorTarget;
|
||||
|
||||
/// Represents the only connected device on the host machine.
|
||||
///
|
||||
/// This is equivalent to using `adb -d`, a _single_ device must be connected.
|
||||
const factory AndroidDeviceTarget.onlyConnectedDevice() = _SingleDeviceTarget;
|
||||
|
||||
/// Returns the arguments to pass to `adb` to target this device.
|
||||
List<String> _toAdbArgs();
|
||||
}
|
||||
|
||||
final class _SerialDeviceTarget implements AndroidDeviceTarget {
|
||||
const _SerialDeviceTarget(this.serialNumber);
|
||||
final String serialNumber;
|
||||
|
||||
@override
|
||||
List<String> _toAdbArgs() => <String>['-s', serialNumber];
|
||||
}
|
||||
|
||||
final class _SingleEmulatorTarget implements AndroidDeviceTarget {
|
||||
const _SingleEmulatorTarget();
|
||||
|
||||
@override
|
||||
List<String> _toAdbArgs() => const <String>['-e'];
|
||||
}
|
||||
|
||||
final class _SingleDeviceTarget implements AndroidDeviceTarget {
|
||||
const _SingleDeviceTarget();
|
||||
|
||||
@override
|
||||
List<String> _toAdbArgs() => const <String>['-d'];
|
||||
}
|
||||
|
||||
final class _SingleAnyTarget implements AndroidDeviceTarget {
|
||||
const _SingleAnyTarget();
|
||||
|
||||
@override
|
||||
List<String> _toAdbArgs() => const <String>[];
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
# `AndroidNativeDriver` Tests
|
||||
|
||||
This directory are tests that require an Android device or emulator to run.
|
||||
|
||||
To run locally, connect an Android device or start an emulator and run:
|
||||
|
||||
```bash
|
||||
# Assumuing your current working directory is `packages/flutter_driver`.\
|
||||
|
||||
$ flutter test test/src/native_tests/android
|
||||
```
|
||||
|
||||
On CI, these tests are run via [`run_flutter_driver_android_tests.dart`][ci].
|
||||
|
||||
[ci]: ../../../../../../dev/bots/suite_runners/run_flutter_driver_android_tests.dart
|
||||
@@ -1,25 +0,0 @@
|
||||
// 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 'dart:typed_data';
|
||||
|
||||
import 'package:flutter_driver/src/native/android.dart';
|
||||
import 'package:flutter_driver/src/native/driver.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() async {
|
||||
test('should connect to an Android device and take a screenshot', () async {
|
||||
final NativeDriver driver = await AndroidNativeDriver.connect();
|
||||
final NativeScreenshot screenshot = await driver.screenshot();
|
||||
|
||||
final Uint8List bytes = await screenshot.readAsBytes();
|
||||
expect(bytes.length, greaterThan(0));
|
||||
|
||||
final String path = await screenshot.saveAs();
|
||||
expect(io.File(path).readAsBytesSync(), bytes);
|
||||
|
||||
await driver.close();
|
||||
});
|
||||
}
|
||||