Unverified Commit 92e3436f authored by Abhishek Ghaskata's avatar Abhishek Ghaskata Committed by GitHub

migrate complex layout to null safety (#83894)

parent 1df798a5
This diff is collapsed.
......@@ -2,7 +2,7 @@ name: complex_layout
description: A benchmark of a relatively complex layout.
environment:
sdk: ">=2.2.2 <3.0.0"
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
......
......@@ -66,7 +66,7 @@ class ResampleFlagVariant extends TestVariant<TestScenario> {
@override
final Set<TestScenario> values = Set<TestScenario>.from(TestScenario.values);
TestScenario currentValue;
late TestScenario currentValue;
bool get resample {
switch(currentValue) {
case TestScenario.resampleOn90Hz:
......@@ -76,7 +76,6 @@ class ResampleFlagVariant extends TestVariant<TestScenario> {
case TestScenario.resampleOff59Hz:
return false;
}
throw ArgumentError;
}
double get frequency {
switch(currentValue) {
......@@ -87,10 +86,9 @@ class ResampleFlagVariant extends TestVariant<TestScenario> {
case TestScenario.resampleOff59Hz:
return 59.0;
}
throw ArgumentError;
}
Map<String, dynamic> result;
Map<String, dynamic>? result;
@override
String describeValue(TestScenario value) {
......@@ -104,7 +102,6 @@ class ResampleFlagVariant extends TestVariant<TestScenario> {
case TestScenario.resampleOff59Hz:
return 'resample off with 59Hz input';
}
throw ArgumentError;
}
@override
......@@ -118,7 +115,7 @@ class ResampleFlagVariant extends TestVariant<TestScenario> {
@override
Future<void> tearDown(TestScenario value, bool memento) async {
binding.resamplingEnabled = memento;
binding.reportData[describeValue(value)] = result;
binding.reportData![describeValue(value)] = result;
}
}
......@@ -134,16 +131,16 @@ Future<void> main() async {
await tester.pumpAndSettle();
final Finder scrollerFinder = find.byKey(const ValueKey<String>('complex-scroll'));
final ListView scroller = tester.widget<ListView>(scrollerFinder);
final ScrollController controller = scroller.controller;
final ScrollController? controller = scroller.controller;
final List<int> frameTimestamp = <int>[];
final List<double> scrollOffset = <double>[];
final List<Duration> delays = <Duration>[];
binding.addPersistentFrameCallback((Duration timeStamp) {
if (controller.hasClients) {
if (controller?.hasClients == true) {
// This if is necessary because by the end of the test the widget tree
// is destroyed.
frameTimestamp.add(timeStamp.inMicroseconds);
scrollOffset.add(controller.offset);
scrollOffset.add(controller!.offset);
}
});
......
......@@ -8,7 +8,7 @@ import 'package:integration_test/integration_test_driver.dart' as driver;
Future<void> main() => driver.integrationDriver(
timeout: const Duration(minutes: 5),
responseDataCallback: (Map<String, dynamic> data) async {
responseDataCallback: (Map<String, dynamic>? data) async {
await driver.writeResponseData(
data,
testOutputFilename: 'scroll_smoothness_test',
......
......@@ -9,7 +9,7 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
void main() {
group('scrolling performance test', () {
FlutterDriver driver;
late FlutterDriver driver;
setUpAll(() async {
driver = await FlutterDriver.connect();
......
......@@ -12,7 +12,7 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
void main() {
group('semantics performance test', () {
FlutterDriver driver;
late FlutterDriver driver;
setUpAll(() async {
driver = await FlutterDriver.connect(printCommunication: true);
......@@ -33,10 +33,10 @@ void main() {
expect(await driver.setSemantics(true), isTrue);
});
final Iterable<TimelineEvent> semanticsEvents = timeline.events.where((TimelineEvent event) => event.name == 'Semantics');
if (semanticsEvents.length != 2)
fail('Expected exactly two semantics events, got ${semanticsEvents.length}');
final Duration semanticsTreeCreation = Duration(microseconds: semanticsEvents.last.timestampMicros - semanticsEvents.first.timestampMicros);
final Iterable<TimelineEvent>? semanticsEvents = timeline.events?.where((TimelineEvent event) => event.name == 'Semantics');
if (semanticsEvents?.length != 2)
fail('Expected exactly two semantics events, got ${semanticsEvents?.length}');
final Duration semanticsTreeCreation = Duration(microseconds: semanticsEvents!.last.timestampMicros! - semanticsEvents.first.timestampMicros!);
final String jsonEncoded = json.encode(<String, dynamic>{'initialSemanticsTreeCreation': semanticsTreeCreation.inMilliseconds});
File(p.join(testOutputsDirectory, 'complex_layout_semantics_perf.json')).writeAsStringSync(jsonEncoded);
......
......@@ -32,7 +32,7 @@ Future<void> main() async {
child: ComplexLayoutApp(),
),
));
await SchedulerBinding.instance.endOfFrame;
await SchedulerBinding.instance?.endOfFrame;
/// Wait 50ms to allow the raster thread to actually put up the frame. (The
/// endOfFrame future ends when we send the data to the engine, before
......@@ -50,9 +50,9 @@ Future<void> main() async {
child: ComplexLayoutApp(),
),
));
await SchedulerBinding.instance.endOfFrame;
await SchedulerBinding.instance?.endOfFrame;
final WidgetController controller = LiveWidgetController(WidgetsBinding.instance);
final WidgetController controller = LiveWidgetController(WidgetsBinding.instance!);
// Scroll down
for (int iteration = 0; iteration < maxIterations; iteration += 1) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment