flutter/packages/flutter_driver/test_driver/screenshot_test.dart
Jonah Williams 1050959d19
[flutter_driver] use mostly public screenshot API. (#157888)
Instead of completely private. This has been broken for Impeller for years, which shows how much this method is getting used.

Fixes https://github.com/flutter/flutter/issues/130461
2024-10-31 21:31:07 +00:00

31 lines
748 B
Dart

// 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:flutter_driver/flutter_driver.dart';
import '../test/common.dart';
void main() {
late FlutterDriver driver;
setUpAll(() async {
driver = await FlutterDriver.connect();
await driver.waitUntilFirstFrameRasterized();
});
test('it takes a screenshot', () async {
// PNG Encoded Bytes.
final Uint8List bytes = (await driver.screenshot()) as Uint8List;
// Check PNG header.
expect(bytes.sublist(0, 8), <int>[137, 80, 78, 71, 13, 10, 26, 10]);
});
tearDownAll(() async {
await driver.close();
});
}