[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
This commit is contained in:
12
dev/devicelab/bin/tasks/linux_desktop_impeller.dart
Normal file
12
dev/devicelab/bin/tasks/linux_desktop_impeller.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
// 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_devicelab/framework/devices.dart';
|
||||
import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/tasks/integration_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.linux;
|
||||
await task(createSolidColorTest(enableImpeller: true));
|
||||
}
|
||||
12
dev/devicelab/bin/tasks/mac_desktop_impeller.dart
Normal file
12
dev/devicelab/bin/tasks/mac_desktop_impeller.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
// 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_devicelab/framework/devices.dart';
|
||||
import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/tasks/integration_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.macos;
|
||||
await task(createSolidColorTest(enableImpeller: true));
|
||||
}
|
||||
12
dev/devicelab/bin/tasks/windows_desktop_impeller.dart
Normal file
12
dev/devicelab/bin/tasks/windows_desktop_impeller.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
// 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_devicelab/framework/devices.dart';
|
||||
import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/tasks/integration_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.windows;
|
||||
await task(createSolidColorTest(enableImpeller: true));
|
||||
}
|
||||
@@ -131,6 +131,17 @@ TaskFunction createEndToEndKeyboardTextfieldTest() {
|
||||
).call;
|
||||
}
|
||||
|
||||
TaskFunction createSolidColorTest({required bool enableImpeller}) {
|
||||
return DriverTest(
|
||||
'${flutterDirectory.path}/dev/integration_tests/ui',
|
||||
'lib/solid_color.dart',
|
||||
extraOptions: <String>[
|
||||
if (enableImpeller)
|
||||
'--enable-impeller'
|
||||
]
|
||||
).call;
|
||||
}
|
||||
|
||||
TaskFunction dartDefinesTask() {
|
||||
return DriverTest(
|
||||
'${flutterDirectory.path}/dev/integration_tests/ui',
|
||||
|
||||
14
dev/integration_tests/ui/lib/solid_color.dart
Normal file
14
dev/integration_tests/ui/lib/solid_color.dart
Normal file
@@ -0,0 +1,14 @@
|
||||
// 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_driver/driver_extension.dart';
|
||||
|
||||
void main() {
|
||||
enableFlutterDriverExtension();
|
||||
|
||||
runApp(Container(
|
||||
color: const Color(0xFFFF0000),
|
||||
));
|
||||
}
|
||||
28
dev/integration_tests/ui/test_driver/solid_color_test.dart
Normal file
28
dev/integration_tests/ui/test_driver/solid_color_test.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
// 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 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
|
||||
|
||||
void main() {
|
||||
late FlutterDriver driver;
|
||||
|
||||
setUpAll(() async {
|
||||
driver = await FlutterDriver.connect();
|
||||
await driver.waitUntilFirstFrameRasterized();
|
||||
});
|
||||
|
||||
test('Can render solid red', () async {
|
||||
// RGBA Encoded Bytes.
|
||||
final Uint8List data = (await driver.screenshot(format: ScreenshotFormat.rawStraightRgba)) as Uint8List;
|
||||
|
||||
expect(data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3], 0xFF0000FF);
|
||||
}, timeout: Timeout.none);
|
||||
|
||||
tearDownAll(() async {
|
||||
await driver.close();
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user