Unverified Commit 8c253280 authored by Emmanuel Garcia's avatar Emmanuel Garcia Committed by GitHub

Handle case where lastLogcatTimestamp is null (#45937)

parent c59151b1
......@@ -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', () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment