Scaffolding for NativeDriver and AndroidNativeDriver for taking screenshots using adb. (#152194)
Closes https://github.com/flutter/flutter/issues/152189. I have next to no clue how to configure this to run on CI, so bear with me as I rediscover the wheel.
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
# `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
|
||||
@@ -0,0 +1,25 @@
|
||||
// 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();
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user