Reverts "Refactor external_ui → external_textures" (#142173)

Reverts flutter/flutter#142062
Initiated by: eliasyishak
This change reverts the following previous change:
Original Description:
This PR makes no _behavioral_ changes to executed code, and instead focuses on organization and naming:

1. Almost[^1] anything named `external_ui` is renamed `external_textures`
1. Extended the README to explain the intent of the test, as well as how to run it
1. Renamed `main.dart` and `main_test.dart` to `frame_rate_main.dart` and `frame_rate_test.dart` (we'll add more)
1. Did some refactoring of the test to make it more obvious what is being asserted (i.e. `widgetBuilds` and friends)

Given how complex (and in-flux) this directory is, I'm also requesting either John, Jonah or I review any changes.

[^1]: Except the name of the `.ci.yaml` task, i.e. `name: Linux_pixel_7pro external_ui_integration_test` because I'm apparently not able to change that without creating a new task as `bringup: true` and playing a bit of a dance. Maybe that's worth doing though (in future PRs)?
This commit is contained in:
auto-submit[bot]
2024-01-24 21:41:17 +00:00
committed by GitHub
parent 2e2042ff8e
commit 54e9f2dbe6
35 changed files with 82 additions and 132 deletions

View File

@@ -1,73 +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:async';
import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
final RegExp _calibrationRegExp = RegExp('Flutter frame rate is (.*)fps');
final RegExp _statsRegExp = RegExp('Produced: (.*)fps\nConsumed: (.*)fps\nWidget builds: (.*)');
const Duration _samplingTime = Duration(seconds: 8);
Future<void> main() async {
late final FlutterDriver driver;
setUpAll(() async {
driver = await FlutterDriver.connect();
});
tearDownAll(() async {
await driver.close();
});
// Verifies we consume texture frames at a rate close to the minimum of the
// rate at which they are produced and Flutter's frame rate. In addition,
// it verifies that widget builds are not triggered by external texture
// frames.
test('renders frames from the device at a rate similar to the frames produced', () async {
final SerializableFinder fab = find.byValueKey('fab');
final SerializableFinder summary = find.byValueKey('summary');
// Wait for calibration to complete and fab to appear.
await driver.waitFor(fab);
final String calibrationResult = await driver.getText(summary);
final Match? matchCalibration = _calibrationRegExp.matchAsPrefix(calibrationResult);
expect(matchCalibration, isNotNull);
final double flutterFrameRate = double.parse(matchCalibration?.group(1) ?? '0');
// Texture frame stats at 0.5x Flutter frame rate
await driver.tap(fab);
await Future<void>.delayed(_samplingTime);
await driver.tap(fab);
final String statsSlow = await driver.getText(summary);
final Match matchSlow = _statsRegExp.matchAsPrefix(statsSlow)!;
expect(matchSlow, isNotNull);
double framesProduced = double.parse(matchSlow.group(1)!);
expect(framesProduced, closeTo(flutterFrameRate / 2.0, 5.0));
double framesConsumed = double.parse(matchSlow.group(2)!);
expect(framesConsumed, closeTo(flutterFrameRate / 2.0, 5.0));
int widgetBuilds = int.parse(matchSlow.group(3)!);
expect(widgetBuilds, 1);
// Texture frame stats at 2.0x Flutter frame rate
await driver.tap(fab);
await Future<void>.delayed(_samplingTime);
await driver.tap(fab);
final String statsFast = await driver.getText(summary);
final Match matchFast = _statsRegExp.matchAsPrefix(statsFast)!;
expect(matchFast, isNotNull);
framesProduced = double.parse(matchFast.group(1)!);
expect(framesProduced, closeTo(flutterFrameRate * 2.0, 5.0));
framesConsumed = double.parse(matchFast.group(2)!);
expect(framesConsumed, closeTo(flutterFrameRate, 10.0));
widgetBuilds = int.parse(matchSlow.group(3)!);
expect(widgetBuilds, 1);
}, timeout: Timeout.none);
}