mirror of
https://github.com/flutter/flutter.git
synced 2026-02-14 14:50:22 +08:00
Handle case where lastLogcatTimestamp is null (#45937)
This commit is contained in:
parent
c59151b1cd
commit
8c25328014
@ -1009,7 +1009,13 @@ class _AdbLogReader extends DeviceLogReader {
|
||||
void _start() {
|
||||
final String lastTimestamp = device.lastLogcatTimestamp;
|
||||
// Start the adb logcat process and filter the most recent logs since `lastTimestamp`.
|
||||
final List<String> args = <String>['logcat', '-v', 'time', '-T', lastTimestamp];
|
||||
final List<String> args = <String>[
|
||||
'logcat',
|
||||
'-v',
|
||||
'time',
|
||||
'-T',
|
||||
lastTimestamp ?? '', // Empty `-T` means the timestamp of the logcat command invocation.
|
||||
];
|
||||
processUtils.start(device.adbCommandForDevice(args)).then<void>((Process process) {
|
||||
_process = process;
|
||||
// We expect logcat streams to occasionally contain invalid utf-8,
|
||||
|
||||
@ -707,6 +707,24 @@ flutter:
|
||||
AndroidSdk: () => mockAndroidSdk,
|
||||
ProcessManager: () => mockProcessManager,
|
||||
});
|
||||
|
||||
testUsingContext('calls adb logcat with expected flags when the device logs are empty', () async {
|
||||
when(mockAndroidSdk.adbPath).thenReturn('adb');
|
||||
when(mockProcessManager.runSync(<String>['adb', '-s', '1234', 'shell', '-x', 'logcat', '-v', 'time', '-t', '1']))
|
||||
.thenReturn(ProcessResult(0, 0, '', ''));
|
||||
when(mockProcessManager.start(argThat(contains('logcat'))))
|
||||
.thenAnswer((_) => Future<Process>.value(createMockProcess()));
|
||||
|
||||
final AndroidDevice device = AndroidDevice('1234');
|
||||
final DeviceLogReader logReader = device.getLogReader();
|
||||
logReader.logLines.listen((_) {});
|
||||
|
||||
verify(mockProcessManager.start(const <String>['adb', '-s', '1234', 'logcat', '-v', 'time', '-T', '']))
|
||||
.called(1);
|
||||
}, overrides: <Type, Generator>{
|
||||
AndroidSdk: () => mockAndroidSdk,
|
||||
ProcessManager: () => mockProcessManager,
|
||||
});
|
||||
});
|
||||
|
||||
test('Can parse adb shell dumpsys info', () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user