Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

refactor: migrate test , test_driver , test_goldens #627

Merged
merged 2 commits into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions test/code_segments_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

import 'package:test/test.dart';

import '../tool/codeviewer_cli/segment_generator.dart';
Expand Down
2 changes: 0 additions & 2 deletions test/demo_descriptions_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

import 'package:collection/collection.dart';
import 'package:flutter_gen/gen_l10n/gallery_localizations_en.dart';
import 'package:flutter_test/flutter_test.dart';
Expand Down
2 changes: 0 additions & 2 deletions test/l10n_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

import 'package:test/test.dart';

import '../tool/l10n_cli/l10n_cli.dart';
Expand Down
2 changes: 0 additions & 2 deletions test/pages/home_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/gallery_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
Expand Down
2 changes: 0 additions & 2 deletions test/restoration_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @dart=2.9

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:gallery/data/demos.dart';
Expand Down
2 changes: 0 additions & 2 deletions test/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

// Replace Windows line endings with Unix line endings
String standardizeLineEndings(String str) => str.replaceAll('\r\n', '\n');
2 changes: 0 additions & 2 deletions test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

void main() {}
4 changes: 1 addition & 3 deletions test_driver/transitions_perf.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

import 'dart:async';
import 'dart:convert' show JsonEncoder;

Expand All @@ -14,7 +12,7 @@ import 'package:gallery/main.dart' show GalleryApp;

// See transitions_perf_test.dart for how to run this test.

Future<String> _handleMessages(String message) async {
Future<String> _handleMessages(String? message) async {
switch (message) {
case 'demoDescriptions':
final demoDescriptions = allGalleryDemoDescriptions();
Expand Down
23 changes: 9 additions & 14 deletions test_driver/transitions_perf_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

import 'dart:async';
import 'dart:convert' show json;
import 'dart:io' show sleep, stdout;

Expand Down Expand Up @@ -131,12 +128,12 @@ Future<bool> isPresent(SerializableFinder finder, FlutterDriver driver,
Future<void> runDemos(
List<String> demos,
FlutterDriver driver, {
Future<void> Function() additionalActions,
Future<void> Function()? additionalActions,
bool scrollToTopWhenDone = true,
}) async {
String currentDemoCategory;
SerializableFinder demoList;
SerializableFinder demoItem;
String? currentDemoCategory;
late SerializableFinder demoList;
SerializableFinder? demoItem;

for (final demo in demos) {
if (_skippedDemos.contains(demo)) continue;
Expand Down Expand Up @@ -199,15 +196,15 @@ Future<void> runDemos(
stdout.writeln('< Success');
}

if (scrollToTopWhenDone) await scrollToTop(demoItem, driver);
if (scrollToTopWhenDone) await scrollToTop(demoItem!, driver);
}

void main([List<String> args = const <String>[]]) {
group('Flutter Gallery transitions', () {
FlutterDriver driver;
late FlutterDriver driver;

bool isTestingCraneOnly;
bool isTestingReplyOnly;
late bool isTestingCraneOnly;
late bool isTestingReplyOnly;

setUpAll(() async {
driver = await FlutterDriver.connect();
Expand Down Expand Up @@ -235,9 +232,7 @@ void main([List<String> args = const <String>[]]) {
});

tearDownAll(() async {
if (driver != null) {
await driver.close();
}
await driver.close();

stdout.writeln(
'Timeline summaries for profiled demos have been output to the build/ directory.');
Expand Down
2 changes: 0 additions & 2 deletions test_goldens/demo_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

Expand Down
2 changes: 0 additions & 2 deletions test_goldens/flutter_test_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

import 'dart:async';
import 'dart:io';

Expand Down
2 changes: 0 additions & 2 deletions test_goldens/home_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';

Expand Down
23 changes: 12 additions & 11 deletions test_goldens/testing/font_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

import 'dart:convert';
import 'dart:io';

Expand All @@ -20,15 +18,17 @@ Future<void> loadFonts() async {
..addAll(loadFontsFromTestingDir()));
}

Future<Map<String, List<Future<ByteData>>>> loadFontsFromManifest() async {
final fontManifest = await rootBundle.loadStructuredData<Iterable<dynamic>>(
Future<Map<String?, List<Future<ByteData>>>> loadFontsFromManifest() async {
final List<dynamic> fontManifest =
await (rootBundle.loadStructuredData<List<dynamic>>(
'FontManifest.json',
(data) async => json.decode(data) as Iterable<dynamic>,
);
final fontFamilyToData = <String, List<Future<ByteData>>>{};
(data) async => json.decode(data) as List<dynamic>,
));

final fontFamilyToData = <String?, List<Future<ByteData>>>{};
for (final fontData in fontManifest) {
final fontFamily = fontData['family'] as String;
final fonts = fontData['fonts'] as Iterable<dynamic>;
final fontFamily = fontData['family'] as String?;
final fonts = fontData['fonts'] as List<dynamic>;
for (final font in fonts) {
(fontFamilyToData[fontFamily] ??= [])
.add(rootBundle.load(font['asset'] as String));
Expand Down Expand Up @@ -77,10 +77,11 @@ Map<String, List<Future<ByteData>>> loadGoogleFonts() {
return fontFamilyToData;
}

Future<void> _load(Map<String, List<Future<ByteData>>> fontFamilyToData) async {
Future<void> _load(
Map<String?, List<Future<ByteData>>> fontFamilyToData) async {
final waitList = <Future<void>>[];
for (final entry in fontFamilyToData.entries) {
final loader = FontLoader(entry.key);
final loader = FontLoader(entry.key!);
for (final data in entry.value) {
loader.addFont(data);
}
Expand Down
4 changes: 1 addition & 3 deletions test_goldens/testing/precache_images.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';

Expand All @@ -13,7 +11,7 @@ Future<void> pumpWidgetWithImages(
Widget widget,
List<String> assetNames,
) async {
Future<void> precacheFuture;
Future<void>? precacheFuture;
await tester.pumpWidget(
Builder(builder: (buildContext) {
precacheFuture = tester.runAsync(() async {
Expand Down
2 changes: 0 additions & 2 deletions test_goldens/testing/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

Expand Down