[O] Remove many timeouts. (#23531)
* Remove many timeouts. These are essentially self-inflicted race conditions. Instead of timeouts we're going to try a more verbose logging mechanism that points out when things are taking a long time. * Get the attach tests to pass. * Apply review comments from Todd * More review comment fixes * Put back the extended timeouts here now that I know why we have them...
This commit is contained in:
@@ -11,13 +11,13 @@ import 'package:flutter_driver/src/driver/timeline.dart';
|
||||
import 'package:json_rpc_2/json_rpc_2.dart' as rpc;
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:vm_service_client/vm_service_client.dart';
|
||||
import 'package:quiver/testing/async.dart';
|
||||
|
||||
import 'common.dart';
|
||||
|
||||
/// Magical timeout value that's different from the default.
|
||||
const Duration _kTestTimeout = Duration(milliseconds: 1234);
|
||||
const String _kSerializedTestTimeout = '1234';
|
||||
const Duration _kDefaultCommandTimeout = Duration(seconds: 5);
|
||||
|
||||
void main() {
|
||||
group('FlutterDriver.connect', () {
|
||||
@@ -358,17 +358,19 @@ void main() {
|
||||
|
||||
group('sendCommand error conditions', () {
|
||||
test('local timeout', () async {
|
||||
final List<String> log = <String>[];
|
||||
final StreamSubscription<LogRecord> logSub = flutterDriverLog.listen((LogRecord s) => log.add(s.toString()));
|
||||
when(mockIsolate.invokeExtension(any, any)).thenAnswer((Invocation i) {
|
||||
// completer never competed to trigger timeout
|
||||
// completer never completed to trigger timeout
|
||||
return Completer<Map<String, dynamic>>().future;
|
||||
});
|
||||
try {
|
||||
await driver.waitFor(find.byTooltip('foo'), timeout: const Duration(milliseconds: 100));
|
||||
fail('expected an exception');
|
||||
} catch (error) {
|
||||
expect(error is DriverError, isTrue);
|
||||
expect(error.message, 'Failed to fulfill WaitFor: Flutter application not responding');
|
||||
}
|
||||
FakeAsync().run((FakeAsync time) {
|
||||
driver.waitFor(find.byTooltip('foo'));
|
||||
expect(log, <String>[]);
|
||||
time.elapse(const Duration(hours: 1));
|
||||
});
|
||||
expect(log, <String>['[warning] FlutterDriver: waitFor message is taking a long time to complete...']);
|
||||
await logSub.cancel();
|
||||
});
|
||||
|
||||
test('remote error', () async {
|
||||
@@ -389,7 +391,6 @@ void main() {
|
||||
});
|
||||
|
||||
group('FlutterDriver with custom timeout', () {
|
||||
const double kTestMultiplier = 3.0;
|
||||
MockVMServiceClient mockClient;
|
||||
MockPeer mockPeer;
|
||||
MockIsolate mockIsolate;
|
||||
@@ -399,21 +400,21 @@ void main() {
|
||||
mockClient = MockVMServiceClient();
|
||||
mockPeer = MockPeer();
|
||||
mockIsolate = MockIsolate();
|
||||
driver = FlutterDriver.connectedTo(mockClient, mockPeer, mockIsolate, timeoutMultiplier: kTestMultiplier);
|
||||
driver = FlutterDriver.connectedTo(mockClient, mockPeer, mockIsolate);
|
||||
});
|
||||
|
||||
test('multiplies the timeout', () async {
|
||||
test('GetHealth has no default timeout', () async {
|
||||
when(mockIsolate.invokeExtension(any, any)).thenAnswer((Invocation i) {
|
||||
expect(i.positionalArguments[1], <String, String>{
|
||||
'command': 'get_health',
|
||||
'timeout': '${(_kDefaultCommandTimeout * kTestMultiplier).inMilliseconds}',
|
||||
'timeout': null,
|
||||
});
|
||||
return makeMockResponse(<String, dynamic>{'status': 'ok'});
|
||||
});
|
||||
await driver.checkHealth();
|
||||
});
|
||||
|
||||
test('does not multiply explicit timeouts', () async {
|
||||
test('does not interfere with explicit timeouts', () async {
|
||||
when(mockIsolate.invokeExtension(any, any)).thenAnswer((Invocation i) {
|
||||
expect(i.positionalArguments[1], <String, String>{
|
||||
'command': 'get_health',
|
||||
|
||||
Reference in New Issue
Block a user