[dart:html] Migrate fileapi tests to NNBD
Change-Id: I4c653fcac0f0a2c5ff7dc5b00f794fba4c3fc028 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140647 Reviewed-by: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
39509bae5f
commit
364db086ef
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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> _fileSystem;
|
||||
Future<FileSystem>? _fileSystem;
|
||||
|
||||
Future<FileSystem> 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);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user