This commit is contained in:
parent
c83104682f
commit
cf7a6319e0
@ -311,7 +311,7 @@ abstract class FlutterDriver {
|
|||||||
/// See also:
|
/// See also:
|
||||||
///
|
///
|
||||||
/// * [getWidgetDiagnostics], which gets the [DiagnosticsNode] of a [Widget].
|
/// * [getWidgetDiagnostics], which gets the [DiagnosticsNode] of a [Widget].
|
||||||
Future<Map<String, Object>> getRenderObjectDiagnostics(
|
Future<Map<String, Object?>> getRenderObjectDiagnostics(
|
||||||
SerializableFinder finder, {
|
SerializableFinder finder, {
|
||||||
int subtreeDepth = 0,
|
int subtreeDepth = 0,
|
||||||
bool includeProperties = true,
|
bool includeProperties = true,
|
||||||
@ -323,7 +323,7 @@ abstract class FlutterDriver {
|
|||||||
subtreeDepth: subtreeDepth,
|
subtreeDepth: subtreeDepth,
|
||||||
includeProperties: includeProperties,
|
includeProperties: includeProperties,
|
||||||
timeout: timeout,
|
timeout: timeout,
|
||||||
)) as Map<String, Object>;
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a JSON map of the [DiagnosticsNode] that is associated with the
|
/// Returns a JSON map of the [DiagnosticsNode] that is associated with the
|
||||||
@ -344,7 +344,7 @@ abstract class FlutterDriver {
|
|||||||
///
|
///
|
||||||
/// * [getRenderObjectDiagnostics], which gets the [DiagnosticsNode] of a
|
/// * [getRenderObjectDiagnostics], which gets the [DiagnosticsNode] of a
|
||||||
/// [RenderObject].
|
/// [RenderObject].
|
||||||
Future<Map<String, Object>> getWidgetDiagnostics(
|
Future<Map<String, Object?>> getWidgetDiagnostics(
|
||||||
SerializableFinder finder, {
|
SerializableFinder finder, {
|
||||||
int subtreeDepth = 0,
|
int subtreeDepth = 0,
|
||||||
bool includeProperties = true,
|
bool includeProperties = true,
|
||||||
@ -356,7 +356,7 @@ abstract class FlutterDriver {
|
|||||||
subtreeDepth: subtreeDepth,
|
subtreeDepth: subtreeDepth,
|
||||||
includeProperties: includeProperties,
|
includeProperties: includeProperties,
|
||||||
timeout: timeout,
|
timeout: timeout,
|
||||||
)) as Map<String, Object>;
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tell the driver to perform a scrolling action.
|
/// Tell the driver to perform a scrolling action.
|
||||||
|
@ -149,6 +149,7 @@ class VMServiceFlutterDriver extends FlutterDriver {
|
|||||||
'when another tool (usually a debugger) resumed the isolate '
|
'when another tool (usually a debugger) resumed the isolate '
|
||||||
'before the flutter_driver did.'
|
'before the flutter_driver did.'
|
||||||
);
|
);
|
||||||
|
return vms.Success();
|
||||||
} else {
|
} else {
|
||||||
// Failed to resume due to another reason. Fail hard.
|
// Failed to resume due to another reason. Fail hard.
|
||||||
throw e;
|
throw e;
|
||||||
@ -312,11 +313,11 @@ class VMServiceFlutterDriver extends FlutterDriver {
|
|||||||
isolateId: _appIsolate.id,
|
isolateId: _appIsolate.id,
|
||||||
args: serialized,
|
args: serialized,
|
||||||
).then<Map<String, dynamic>>((vms.Response value) => value.json!);
|
).then<Map<String, dynamic>>((vms.Response value) => value.json!);
|
||||||
response = (await _warnIfSlow<Map<String, dynamic>>(
|
response = await _warnIfSlow<Map<String, dynamic>>(
|
||||||
future: future,
|
future: future,
|
||||||
timeout: command.timeout ?? kUnusuallyLongTimeout,
|
timeout: command.timeout ?? kUnusuallyLongTimeout,
|
||||||
message: '${command.kind} message is taking a long time to complete...',
|
message: '${command.kind} message is taking a long time to complete...',
|
||||||
))!;
|
);
|
||||||
_logCommunication('<<< $response');
|
_logCommunication('<<< $response');
|
||||||
} catch (error, stackTrace) {
|
} catch (error, stackTrace) {
|
||||||
throw DriverError(
|
throw DriverError(
|
||||||
@ -407,7 +408,7 @@ class VMServiceFlutterDriver extends FlutterDriver {
|
|||||||
const int kSecondInMicros = 1000000;
|
const int kSecondInMicros = 1000000;
|
||||||
int currentStart = startTime;
|
int currentStart = startTime;
|
||||||
int currentEnd = startTime + kSecondInMicros; // 1 second of timeline
|
int currentEnd = startTime + kSecondInMicros; // 1 second of timeline
|
||||||
final List<Map<String, Object?>?> chunks = <Map<String, Object>?>[];
|
final List<Map<String, Object?>?> chunks = <Map<String, Object?>?>[];
|
||||||
do {
|
do {
|
||||||
final vms.Timeline chunk = await _serviceClient.getVMTimeline(
|
final vms.Timeline chunk = await _serviceClient.getVMTimeline(
|
||||||
timeOriginMicros: currentStart,
|
timeOriginMicros: currentStart,
|
||||||
@ -420,9 +421,9 @@ class VMServiceFlutterDriver extends FlutterDriver {
|
|||||||
currentEnd += kSecondInMicros;
|
currentEnd += kSecondInMicros;
|
||||||
} while (currentStart < endTime!);
|
} while (currentStart < endTime!);
|
||||||
return Timeline.fromJson(<String, Object>{
|
return Timeline.fromJson(<String, Object>{
|
||||||
'traceEvents': <Object> [
|
'traceEvents': <Object?> [
|
||||||
for (Map<String, Object?>? chunk in chunks)
|
for (Map<String, Object?>? chunk in chunks)
|
||||||
...chunk!['traceEvents']! as List<Object>,
|
...chunk!['traceEvents']! as List<Object?>,
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
} catch (error, stackTrace) {
|
} catch (error, stackTrace) {
|
||||||
@ -621,22 +622,24 @@ void _log(String message) {
|
|||||||
driverLog('VMServiceFlutterDriver', message);
|
driverLog('VMServiceFlutterDriver', message);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<T?> _warnIfSlow<T>({
|
Future<T> _warnIfSlow<T>({
|
||||||
required Future<T?> future,
|
required Future<T> future,
|
||||||
required Duration timeout,
|
required Duration timeout,
|
||||||
required String message,
|
required String message,
|
||||||
}) {
|
}) async {
|
||||||
assert(future != null);
|
assert(future != null);
|
||||||
assert(timeout != null);
|
assert(timeout != null);
|
||||||
assert(message != null);
|
assert(message != null);
|
||||||
future
|
final Completer<void> completer = Completer<void>();
|
||||||
.timeout(timeout, onTimeout: () {
|
completer.future.timeout(timeout, onTimeout: () {
|
||||||
_log(message);
|
_log(message);
|
||||||
return null;
|
return null;
|
||||||
})
|
});
|
||||||
|
try {
|
||||||
|
await future.whenComplete(() { completer.complete(); });
|
||||||
|
} catch (e) {
|
||||||
// Don't duplicate errors if [future] completes with an error.
|
// Don't duplicate errors if [future] completes with an error.
|
||||||
.catchError((Object e, StackTrace s) => null);
|
}
|
||||||
|
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import 'package:flutter_driver/src/driver/timeline.dart';
|
|||||||
import 'package:fake_async/fake_async.dart';
|
import 'package:fake_async/fake_async.dart';
|
||||||
import 'package:vm_service/vm_service.dart' as vms;
|
import 'package:vm_service/vm_service.dart' as vms;
|
||||||
|
|
||||||
import 'common.dart';
|
import '../../common.dart';
|
||||||
|
|
||||||
/// Magical timeout value that's different from the default.
|
/// Magical timeout value that's different from the default.
|
||||||
const Duration _kTestTimeout = Duration(milliseconds: 1234);
|
const Duration _kTestTimeout = Duration(milliseconds: 1234);
|
||||||
@ -1010,4 +1010,4 @@ class FakeIsolate extends Fake implements vms.Isolate {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<String> get extensionRPCs => <String>[];
|
List<String> get extensionRPCs => <String>[];
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user