From 364db086ef21553d758127baebdb59c23a8d2d44 Mon Sep 17 00:00:00 2001 From: Srujan Gaddam Date: Fri, 3 Apr 2020 17:43:57 +0000 Subject: [PATCH] [dart:html] Migrate fileapi tests to NNBD Change-Id: I4c653fcac0f0a2c5ff7dc5b00f794fba4c3fc028 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140647 Reviewed-by: Bob Nystrom --- tests/lib/html/fileapi_directory_reader_test.dart | 11 ++++------- tests/lib/html/fileapi_directory_test.dart | 7 ++----- tests/lib/html/fileapi_entry_test.dart | 8 +++----- tests/lib/html/fileapi_file_entry_test.dart | 11 ++++------- tests/lib/html/fileapi_file_test.dart | 7 ++----- tests/lib/html/fileapi_supported_test.dart | 13 ++++--------- 6 files changed, 19 insertions(+), 38 deletions(-) diff --git a/tests/lib/html/fileapi_directory_reader_test.dart b/tests/lib/html/fileapi_directory_reader_test.dart index a1b57ebf037..74687596cd9 100644 --- a/tests/lib/html/fileapi_directory_reader_test.dart +++ b/tests/lib/html/fileapi_directory_reader_test.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart = 2.7 - library fileapi; import 'dart:async'; @@ -18,12 +16,11 @@ class FileAndDir { FileAndDir(this.file, this.dir); } -FileSystem fs; +late FileSystem fs; main() async { getFileSystem() async { - var fileSystem = await window.requestFileSystem(100); - fs = fileSystem; + fs = await window.requestFileSystem(100); } // Do the boilerplate to get several files and directories created to then @@ -31,8 +28,8 @@ main() async { Future doDirSetup(String testName) async { await getFileSystem(); - var file = await fs.root.createFile('file_$testName'); - var dir = await fs.root.createDirectory('dir_$testName'); + var file = await fs.root.createFile('file_$testName') as FileEntry; + var dir = await fs.root.createDirectory('dir_$testName') as DirectoryEntry; return new Future.value(new FileAndDir(file, dir)); } diff --git a/tests/lib/html/fileapi_directory_test.dart b/tests/lib/html/fileapi_directory_test.dart index 679354d0d6d..b2c79451ac3 100644 --- a/tests/lib/html/fileapi_directory_test.dart +++ b/tests/lib/html/fileapi_directory_test.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart = 2.7 - library fileapi; import 'dart:async'; @@ -18,12 +16,11 @@ class FileAndDir { FileAndDir(this.file, this.dir); } -FileSystem fs; +late FileSystem fs; main() async { getFileSystem() async { - var fileSystem = await window.requestFileSystem(100); - fs = fileSystem; + fs = await window.requestFileSystem(100); } if (FileSystem.supported) { diff --git a/tests/lib/html/fileapi_entry_test.dart b/tests/lib/html/fileapi_entry_test.dart index 41360b06757..7669fc875ee 100644 --- a/tests/lib/html/fileapi_entry_test.dart +++ b/tests/lib/html/fileapi_entry_test.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart = 2.7 - library fileapi; import 'dart:async'; @@ -18,7 +16,7 @@ class FileAndDir { FileAndDir(this.file, this.dir); } -FileSystem fs; +late FileSystem fs; main() async { getFileSystem() async { @@ -32,8 +30,8 @@ main() async { Future doDirSetup(String testName) async { await getFileSystem(); - var file = await fs.root.createFile('file_$testName'); - var dir = await fs.root.createDirectory('dir_$testName'); + var file = await fs.root.createFile('file_$testName') as FileEntry; + var dir = await fs.root.createDirectory('dir_$testName') as DirectoryEntry; return new Future.value(new FileAndDir(file, dir)); } diff --git a/tests/lib/html/fileapi_file_entry_test.dart b/tests/lib/html/fileapi_file_entry_test.dart index c55010980a8..1789003b50d 100644 --- a/tests/lib/html/fileapi_file_entry_test.dart +++ b/tests/lib/html/fileapi_file_entry_test.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart = 2.7 - library fileapi; import 'dart:async'; @@ -18,12 +16,11 @@ class FileAndDir { FileAndDir(this.file, this.dir); } -FileSystem fs; +late FileSystem fs; main() async { getFileSystem() async { - var fileSystem = await window.requestFileSystem(100); - fs = fileSystem; + fs = await window.requestFileSystem(100); } // Do the boilerplate to get several files and directories created to then @@ -31,8 +28,8 @@ main() async { Future doDirSetup(String testName) async { await getFileSystem(); - var file = await fs.root.createFile('file_$testName'); - var dir = await fs.root.createDirectory('dir_$testName'); + var file = await fs.root.createFile('file_$testName') as FileEntry; + var dir = await fs.root.createDirectory('dir_$testName') as DirectoryEntry; return new Future.value(new FileAndDir(file, dir)); } diff --git a/tests/lib/html/fileapi_file_test.dart b/tests/lib/html/fileapi_file_test.dart index 25f469f5e1c..f70bb1325e0 100644 --- a/tests/lib/html/fileapi_file_test.dart +++ b/tests/lib/html/fileapi_file_test.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart = 2.7 - library fileapi; import 'dart:async'; @@ -18,12 +16,11 @@ class FileAndDir { FileAndDir(this.file, this.dir); } -FileSystem fs; +late FileSystem fs; main() async { getFileSystem() async { - var fileSystem = await window.requestFileSystem(100); - fs = fileSystem; + fs = await window.requestFileSystem(100); } if (FileSystem.supported) { diff --git a/tests/lib/html/fileapi_supported_test.dart b/tests/lib/html/fileapi_supported_test.dart index 36feb2f328a..75fe3b87ee4 100644 --- a/tests/lib/html/fileapi_supported_test.dart +++ b/tests/lib/html/fileapi_supported_test.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart = 2.7 - library fileapi; import 'dart:async'; @@ -12,20 +10,18 @@ import 'dart:html'; import 'package:async_helper/async_helper.dart'; import 'package:async_helper/async_minitest.dart'; -Future _fileSystem; +Future? _fileSystem; Future get fileSystem async { - if (_fileSystem != null) return _fileSystem; + if (_fileSystem != null) return _fileSystem!; _fileSystem = window.requestFileSystem(100); - var fs = await _fileSystem; - expect(fs != null, true); - expect(fs.root != null, true); + var fs = await _fileSystem!; expect(fs.runtimeType, FileSystem); expect(fs.root.runtimeType, DirectoryEntry); - return _fileSystem; + return _fileSystem!; } main() { @@ -37,7 +33,6 @@ main() { var expectation = FileSystem.supported ? returnsNormally : throws; expect(() async { var fs = await fileSystem; - expect(fs.root != null, true); }, expectation); }); }