This commit is contained in:
@@ -171,7 +171,6 @@ void main() {
|
||||
FileSystem: () => MemoryFileSystem(),
|
||||
IOSWorkflow: () => MockIosWorkFlow(),
|
||||
Platform: _kNoColorTerminalPlatform,
|
||||
OperatingSystemUtils: () => MockOperatingSystemUtils(),
|
||||
};
|
||||
testUsingContext('Error on non-existing file', () {
|
||||
final PrebuiltIOSApp iosApp =
|
||||
@@ -494,5 +493,3 @@ const String badPlistData = '''
|
||||
const String plistData = '''
|
||||
{"CFBundleIdentifier": "fooBundleId"}
|
||||
''';
|
||||
|
||||
class MockOperatingSystemUtils extends Mock implements OperatingSystemUtils { }
|
||||
|
||||
@@ -95,7 +95,7 @@ void main() {
|
||||
}
|
||||
|
||||
for (String testOs in testPlatforms) {
|
||||
testUsingContext('AnsiSpinner works for $testOs (1)', () async {
|
||||
testUsingContext('AnsiSpinner works for $testOs', () async {
|
||||
bool done = false;
|
||||
FakeAsync().run((FakeAsync time) {
|
||||
final AnsiSpinner ansiSpinner = AnsiSpinner(
|
||||
@@ -131,18 +131,21 @@ void main() {
|
||||
Stdio: () => mockStdio,
|
||||
});
|
||||
|
||||
testUsingContext('AnsiSpinner works for $testOs (2)', () async {
|
||||
testUsingContext('AnsiSpinner works for $testOs', () async {
|
||||
bool done = false;
|
||||
mockStopwatch = FakeStopwatch();
|
||||
FakeAsync().run((FakeAsync time) {
|
||||
// We pad the time here so that we have a little slack in terms of the first part of this test
|
||||
// taking longer to run than we'd like, since we are forced to start the timer before the actual
|
||||
// stopwatch that we're trying to test. This is an unfortunate possible race condition. If this
|
||||
// turns out to be flaky, we will need to find another solution.
|
||||
final Future<void> tenMillisecondsLater = Future<void>.delayed(const Duration(milliseconds: 15));
|
||||
await FakeAsync().run((FakeAsync time) async {
|
||||
final AnsiSpinner ansiSpinner = AnsiSpinner(
|
||||
timeout: const Duration(seconds: 2),
|
||||
timeout: const Duration(milliseconds: 10),
|
||||
)..start();
|
||||
mockStopwatch.elapsed = const Duration(seconds: 1);
|
||||
doWhileAsync(time, () => ansiSpinner.ticks < 10); // one second
|
||||
expect(ansiSpinner.seemsSlow, isFalse);
|
||||
expect(outputStdout().join('\n'), isNot(contains('This is taking an unexpectedly long time.')));
|
||||
mockStopwatch.elapsed = const Duration(seconds: 3);
|
||||
await tenMillisecondsLater;
|
||||
doWhileAsync(time, () => ansiSpinner.ticks < 30); // three seconds
|
||||
expect(ansiSpinner.seemsSlow, isTrue);
|
||||
// Check the 2nd line to verify there's a newline before the warning
|
||||
@@ -155,7 +158,6 @@ void main() {
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => FakePlatform(operatingSystem: testOs),
|
||||
Stdio: () => mockStdio,
|
||||
Stopwatch: () => mockStopwatch,
|
||||
});
|
||||
|
||||
testUsingContext('Stdout startProgress on colored terminal for $testOs', () async {
|
||||
|
||||
@@ -26,10 +26,6 @@ void main() {
|
||||
await tools.main(<String>['devices', '--bug-report']);
|
||||
expect(exitCode, 0);
|
||||
verify(os.zip(any, argThat(hasPath(matches(r'bugreport_01\.zip')))));
|
||||
}, overrides: <Type, Generator>{
|
||||
OperatingSystemUtils: () => MockOperatingSystemUtils(),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
class MockOperatingSystemUtils extends Mock implements OperatingSystemUtils { }
|
||||
|
||||
@@ -7,8 +7,8 @@ import 'dart:convert';
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/devfs.dart';
|
||||
import 'package:flutter_tools/src/vmservice.dart';
|
||||
import 'package:json_rpc_2/json_rpc_2.dart' as rpc;
|
||||
|
||||
@@ -386,16 +386,16 @@ abstract class FlutterTestDriver {
|
||||
final Future<T> future = callback();
|
||||
|
||||
future.timeout(timeout ?? defaultTimeout, onTimeout: () {
|
||||
_debugPrint(messages.toString());
|
||||
print(messages.toString());
|
||||
timeoutExpired = true;
|
||||
_debugPrint('$task is taking longer than usual...');
|
||||
print('$task is taking longer than usual...');
|
||||
return null;
|
||||
});
|
||||
|
||||
return future.catchError((dynamic error) {
|
||||
if (!timeoutExpired) {
|
||||
timeoutExpired = true;
|
||||
_debugPrint(messages.toString());
|
||||
print(messages.toString());
|
||||
}
|
||||
throw error;
|
||||
}).whenComplete(() => subscription.cancel());
|
||||
|
||||
@@ -222,42 +222,15 @@ class MockSimControl extends Mock implements SimControl {
|
||||
}
|
||||
}
|
||||
|
||||
class MockOperatingSystemUtils implements OperatingSystemUtils {
|
||||
@override
|
||||
ProcessResult makeExecutable(File file) => null;
|
||||
|
||||
@override
|
||||
File which(String execName) => null;
|
||||
|
||||
class MockOperatingSystemUtils extends Mock implements OperatingSystemUtils {
|
||||
@override
|
||||
List<File> whichAll(String execName) => <File>[];
|
||||
|
||||
@override
|
||||
File makePipe(String path) => null;
|
||||
|
||||
@override
|
||||
void zip(Directory data, File zipFile) { }
|
||||
|
||||
@override
|
||||
void unzip(File file, Directory targetDirectory) { }
|
||||
|
||||
@override
|
||||
bool verifyZip(File file) => true;
|
||||
|
||||
@override
|
||||
void unpack(File gzippedTarFile, Directory targetDirectory) { }
|
||||
|
||||
@override
|
||||
bool verifyGzip(File gzippedFile) => true;
|
||||
|
||||
@override
|
||||
String get name => 'fake OS name and version';
|
||||
|
||||
@override
|
||||
String get pathVarSeparator => ';';
|
||||
|
||||
@override
|
||||
Future<int> findFreePort({bool ipv6 = false}) async => 12345;
|
||||
}
|
||||
|
||||
class MockIOSSimulatorUtils extends Mock implements IOSSimulatorUtils {}
|
||||
|
||||
Reference in New Issue
Block a user