Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
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
1 change: 0 additions & 1 deletion lib/web_ui/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ analyzer:

linter:
rules:
always_specify_types: false
annotate_overrides: false
avoid_classes_with_only_static_members: false
avoid_empty_else: false
Expand Down
26 changes: 13 additions & 13 deletions lib/web_ui/dev/browser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,20 @@ abstract class Browser {
///
/// This will fire once the process has started successfully.
Future<Process> get _process => _processCompleter.future;
final _processCompleter = Completer<Process>();
final Completer<Process> _processCompleter = Completer<Process>();

/// Whether [close] has been called.
var _closed = false;
bool _closed = false;

/// A future that completes when the browser exits.
///
/// If there's a problem starting or running the browser, this will complete
/// with an error.
Future<void> get onExit => _onExitCompleter.future;
final _onExitCompleter = Completer<void>();
final Completer<void> _onExitCompleter = Completer<void>();

/// Standard IO streams for the underlying browser process.
final _ioSubscriptions = <StreamSubscription>[];
final List<StreamSubscription<void>> _ioSubscriptions = <StreamSubscription<void>>[];

/// Creates a new browser.
///
Expand All @@ -102,10 +102,10 @@ abstract class Browser {
// for the process to actually start. They should just wait for the HTTP
// request instead.
runZonedGuarded(() async {
var process = await startBrowser();
Process process = await startBrowser();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is unrelated to your PR, but could this become final?

Suggested change
Process process = await startBrowser();
final Process process = await startBrowser();

_processCompleter.complete(process);

var output = Uint8Buffer();
Uint8Buffer output = Uint8Buffer();
void drainOutput(Stream<List<int>> stream) {
try {
_ioSubscriptions
Expand All @@ -117,7 +117,7 @@ abstract class Browser {
drainOutput(process.stdout);
drainOutput(process.stderr);

var exitCode = await process.exitCode;
int exitCode = await process.exitCode;

// This hack dodges an otherwise intractable race condition. When the user
// presses Control-C, the signal is sent to the browser and the test
Expand All @@ -134,8 +134,8 @@ abstract class Browser {
}

if (!_closed && exitCode != 0) {
var outputString = utf8.decode(output);
var message = '$name failed with exit code $exitCode.';
String outputString = utf8.decode(output);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
String outputString = utf8.decode(output);
final String outputString = utf8.decode(output);

String message = '$name failed with exit code $exitCode.';
if (outputString.isNotEmpty) {
message += '\nStandard output:\n$outputString';
}
Expand All @@ -151,7 +151,7 @@ abstract class Browser {
}

// Make sure the process dies even if the error wasn't fatal.
_process.then((process) => process.kill());
_process.then((Process process) => process.kill());

if (stackTrace == null) {
stackTrace = Trace.current();
Expand All @@ -170,13 +170,13 @@ abstract class Browser {
///
/// Returns the same [Future] as [onExit], except that it won't emit
/// exceptions.
Future close() async {
Future<void> close() async {
_closed = true;

// If we don't manually close the stream the test runner can hang.
// For example this happens with Chrome Headless.
// See SDK issue: https://github.com/dart-lang/sdk/issues/31264
for (var stream in _ioSubscriptions) {
for (StreamSubscription<void> stream in _ioSubscriptions) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (StreamSubscription<void> stream in _ioSubscriptions) {
for (final StreamSubscription<void> stream in _ioSubscriptions) {

unawaited(stream.cancel());
}

Expand All @@ -192,7 +192,7 @@ abstract class ScreenshotManager {
/// Capture a screenshot.
///
/// Please read the details for the implementing classes.
Future<Image> capture(math.Rectangle region);
Future<Image> capture(math.Rectangle<num> region);

/// Suffix to be added to the end of the filename.
///
Expand Down
5 changes: 3 additions & 2 deletions lib/web_ui/dev/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import 'dart:async';

import 'package:args/command_runner.dart';
import 'package:path/path.dart' as path;
import 'package:watcher/src/watch_event.dart';

import 'environment.dart';
import 'utils.dart';
import 'watcher.dart';

class BuildCommand extends Command<bool> with ArgUtils {
class BuildCommand extends Command<bool> with ArgUtils<bool> {
BuildCommand() {
argParser
..addFlag(
Expand Down Expand Up @@ -48,7 +49,7 @@ class BuildCommand extends Command<bool> with ArgUtils {
dir: libPath.absolute,
pipeline: buildPipeline,
// Ignore font files that are copied whenever tests run.
ignore: (event) => event.path.endsWith('.ttf'),
ignore: (WatchEvent event) => event.path.endsWith('.ttf'),
).start();
}
return true;
Expand Down
8 changes: 4 additions & 4 deletions lib/web_ui/dev/chrome.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ChromeEnvironment implements BrowserEnvironment {
/// Any errors starting or running the process are reported through [onExit].
class Chrome extends Browser {
@override
final name = 'Chrome';
final String name = 'Chrome';

@override
final Future<Uri> remoteDebuggerUrl;
Expand All @@ -60,7 +60,7 @@ class Chrome extends Browser {
/// [Uri] or a [String].
factory Chrome(Uri url, {bool debug = false}) {
String version = ChromeArgParser.instance.version;
var remoteDebuggerCompleter = Completer<Uri>.sync();
Completer<Uri> remoteDebuggerCompleter = Completer<Uri>.sync();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Completer<Uri> remoteDebuggerCompleter = Completer<Uri>.sync();
final Completer<Uri> remoteDebuggerCompleter = Completer<Uri>.sync();

return Chrome._(() async {
final BrowserInstallation installation = await getOrInstallChrome(
version,
Expand All @@ -80,7 +80,7 @@ class Chrome extends Browser {
final bool isChromeNoSandbox =
Platform.environment['CHROME_NO_SANDBOX'] == 'true';
final String dir = environment.webUiDartToolDir.createTempSync('test_chrome_user_data_').resolveSymbolicLinksSync();
var args = [
List<String> args = <String>[
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
List<String> args = <String>[
final List<String> args = <String>[

'--user-data-dir=$dir',
url.toString(),
if (!debug)
Expand Down Expand Up @@ -218,7 +218,7 @@ class ChromeScreenshotManager extends ScreenshotManager {
/// [region] is used to decide which part of the web content will be used in
/// test image. It includes starting coordinate x,y as well as height and
/// width of the area to capture.
Future<Image> capture(math.Rectangle? region) async {
Future<Image> capture(math.Rectangle<num>? region) async {
final wip.ChromeConnection chromeConnection =
wip.ChromeConnection('localhost', kDevtoolsPort);
final wip.ChromeTab? chromeTab = await chromeConnection.getTab(
Expand Down
5 changes: 3 additions & 2 deletions lib/web_ui/dev/chrome_installer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'dart:async';
import 'dart:io' as io;
import 'dart:typed_data';

import 'package:archive/archive.dart';
import 'package:archive/archive_io.dart';
Expand Down Expand Up @@ -220,15 +221,15 @@ class ChromeInstaller {
final Stopwatch stopwatch = Stopwatch()..start();

// Read the Zip file from disk.
final bytes = downloadedFile.readAsBytesSync();
final Uint8List bytes = downloadedFile.readAsBytesSync();

final Archive archive = ZipDecoder().decodeBytes(bytes);

// Extract the contents of the Zip archive to disk.
for (final ArchiveFile file in archive) {
final String filename = file.name;
if (file.isFile) {
final data = file.content as List<int>;
final List<int> data = file.content as List<int>;
io.File(path.join(versionDir.path, filename))
..createSync(recursive: true)
..writeAsBytesSync(data);
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/dev/clean.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:path/path.dart' as path;
import 'environment.dart';
import 'utils.dart';

class CleanCommand extends Command<bool> with ArgUtils {
class CleanCommand extends Command<bool> with ArgUtils<bool> {
CleanCommand() {
argParser
..addFlag(
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/dev/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class DevNull implements StringSink {
void write(Object? obj) {}

@override
void writeAll(Iterable objects, [String separator = ""]) {}
void writeAll(Iterable<dynamic> objects, [String separator = ""]) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not Object? like the other methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The StringSink interface spells it out as Iterable<dynamic>. I didn't want to change that.


@override
void writeCharCode(int charCode) {}
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/dev/create_simulator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:simulators/simulator_manager.dart';
import 'safari_installation.dart';
import 'utils.dart';

class CreateSimulatorCommand extends Command<bool> with ArgUtils {
class CreateSimulatorCommand extends Command<bool> with ArgUtils<bool> {
CreateSimulatorCommand() {
IosSafariArgParser.instance.populateOptions(argParser);
argParser
Expand Down
8 changes: 5 additions & 3 deletions lib/web_ui/dev/edge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class EdgeEnvironment implements BrowserEnvironment {
/// Any errors starting or running the process are reported through [onExit].
class Edge extends Browser {
@override
final name = 'Edge';
final String name = 'Edge';

/// Starts a new instance of Safari open to the given [url], which may be a
/// [Uri] or a [String].
Expand All @@ -63,8 +63,10 @@ class Edge extends Browser {
pathToOpen = pathToOpen.substring(0, index-1);
}

var process =
await Process.start(installation.executable, ['$pathToOpen','-k']);
Process process = await Process.start(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Process process = await Process.start(
final Process process = await Process.start(

installation.executable,
<String>['$pathToOpen','-k'],
);

return process;
});
Expand Down
4 changes: 2 additions & 2 deletions lib/web_ui/dev/felt.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'exceptions.dart';
import 'test_runner.dart';
import 'utils.dart';

CommandRunner runner = CommandRunner<bool>(
CommandRunner<bool> runner = CommandRunner<bool>(
'felt',
'Command-line utility for building and testing Flutter web engine.',
)
Expand All @@ -26,7 +26,7 @@ CommandRunner runner = CommandRunner<bool>(

void main(List<String> rawArgs) async {
// Remove --clean from the list as that's processed by the wrapper script.
final List<String> args = rawArgs.where((arg) => arg != '--clean').toList();
final List<String> args = rawArgs.where((String arg) => arg != '--clean').toList();

if (args.isEmpty) {
// The felt tool was invoked with no arguments. Print usage.
Expand Down
8 changes: 4 additions & 4 deletions lib/web_ui/dev/firefox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class FirefoxEnvironment implements BrowserEnvironment {
/// Any errors starting or running the process are reported through [onExit].
class Firefox extends Browser {
@override
final name = 'Firefox';
final String name = 'Firefox';

@override
final Future<Uri> remoteDebuggerUrl;
Expand All @@ -56,15 +56,15 @@ class Firefox extends Browser {
/// [Uri] or a [String].
factory Firefox(Uri url, {bool debug = false}) {
final String version = FirefoxArgParser.instance.version;
var remoteDebuggerCompleter = Completer<Uri>.sync();
Completer<Uri> remoteDebuggerCompleter = Completer<Uri>.sync();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Completer<Uri> remoteDebuggerCompleter = Completer<Uri>.sync();
final Completer<Uri> remoteDebuggerCompleter = Completer<Uri>.sync();

return Firefox._(() async {
final BrowserInstallation installation = await getOrInstallFirefox(
version,
infoLog: isCirrus ? stdout : DevNull(),
);

// Using a profile on opening will prevent popups related to profiles.
final _profile = '''
final String _profile = '''
user_pref("browser.shell.checkDefaultBrowser", false);
user_pref("dom.disable_open_during_load", false);
user_pref("dom.max_script_run_time", 0);
Expand All @@ -84,7 +84,7 @@ user_pref("dom.max_script_run_time", 0);
File(path.join(temporaryProfileDirectory.path, 'prefs.js'))
.writeAsStringSync(_profile);
bool isMac = Platform.isMacOS;
var args = [
List<String> args = <String>[
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
List<String> args = <String>[
final List<String> args = <String>[

url.toString(),
'--profile',
'${temporaryProfileDirectory.path}',
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/dev/firefox_installer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ Future<String> _findSystemFirefoxExecutable() async {
if (!found) {
if (io.Platform.isMacOS &&
io.File(fireFoxDefaultInstallPath).existsSync()) {
return Future.value(fireFoxDefaultInstallPath);
return Future<String>.value(fireFoxDefaultInstallPath);
}
throw BrowserInstallerException(
'Failed to locate system Firefox installation.');
Expand Down
8 changes: 4 additions & 4 deletions lib/web_ui/dev/licenses.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class LicensesCommand extends Command<bool> {
'Dart source listing of ${environment.webUiRootDir.path} must not be empty.');

final List<String> allDartPaths =
allSourceFiles.map((f) => f.path).toList();
allSourceFiles.map((io.File f) => f.path).toList();

for (String expectedDirectory in const <String>[
'lib',
Expand All @@ -41,7 +41,7 @@ class LicensesCommand extends Command<bool> {
path.join(environment.webUiRootDir.path, expectedDirectory);
_expect(
allDartPaths
.where((p) => p.startsWith(expectedAbsoluteDirectory))
.where((String p) => p.startsWith(expectedAbsoluteDirectory))
.isNotEmpty,
'Must include the $expectedDirectory/ directory',
);
Expand All @@ -51,7 +51,7 @@ class LicensesCommand extends Command<bool> {
print('License headers OK!');
}

final _copyRegex =
final RegExp _copyRegex =
RegExp(r'// Copyright 2013 The Flutter Authors\. All rights reserved\.');

void _expectLicenseHeader(io.File file) {
Expand Down Expand Up @@ -80,7 +80,7 @@ class LicensesCommand extends Command<bool> {
}

List<io.File> _flatListSourceFiles(io.Directory directory) {
return directory.listSync(recursive: true).whereType<io.File>().where((f) {
return directory.listSync(recursive: true).whereType<io.File>().where((io.File f) {
if (!f.path.endsWith('.dart') && !f.path.endsWith('.js')) {
// Not a source file we're checking.
return false;
Expand Down
8 changes: 4 additions & 4 deletions lib/web_ui/dev/macos_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MacOSInfo {
Future<void> _printSafariApplications() async {
final ProcessManager systemProfiler = await startProcess(
'system_profiler',
['SPApplicationsDataType', '-json'],
<String>['SPApplicationsDataType', '-json'],
evalOutput: true,
);
final String systemProfileJson = await systemProfiler.evalStdout();
Expand All @@ -44,19 +44,19 @@ class MacOSInfo {
Future<void> _printSafariDefaults() async {
final ProcessManager defaults = await startProcess(
'/usr/bin/defaults',
['find', 'Safari'],
<String>['find', 'Safari'],
evalOutput: true,
);
print('Safari related defaults:\n ${await defaults.evalStdout()}');
}

/// Print user limits (file and process).
Future<void> _printUserLimits() async {
ProcessManager ulimit = await startProcess('ulimit', ['-n'], evalOutput: true);
ProcessManager ulimit = await startProcess('ulimit', <String>['-n'], evalOutput: true);
final String fileLimit = await ulimit.evalStdout();
print('MacOS file limit: $fileLimit');

ulimit = await startProcess('ulimit', ['-u'], evalOutput: true);
ulimit = await startProcess('ulimit', <String>['-u'], evalOutput: true);
final String processLimit = await ulimit.evalStdout();
print('MacOS process limit: $processLimit');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/dev/safari_installation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class IosSafariArgParser extends BrowserArgParser {

@override
void populateOptions(ArgParser argParser) {
final pinnedIosVersion =
final String pinnedIosVersion =
'${_pinnedIosMajorVersion}.${_pinnedIosMinorVersion}';
argParser
..addOption('version',
Expand Down
Loading