mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
[flutter_tools] Don't stringify null values in EventPrinter (#76579)
This commit is contained in:
parent
2d0fa57cbc
commit
a341da6e0e
@ -22,7 +22,7 @@ class EventPrinter extends TestWatcher {
|
|||||||
@override
|
@override
|
||||||
void handleStartedDevice(Uri observatoryUri) {
|
void handleStartedDevice(Uri observatoryUri) {
|
||||||
_sendEvent('test.startedProcess',
|
_sendEvent('test.startedProcess',
|
||||||
<String, dynamic>{'observatoryUri': observatoryUri.toString()});
|
<String, dynamic>{'observatoryUri': observatoryUri?.toString()});
|
||||||
_parent?.handleStartedDevice(observatoryUri);
|
_parent?.handleStartedDevice(observatoryUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,16 +11,49 @@ import 'package:mockito/mockito.dart';
|
|||||||
import '../../src/common.dart';
|
import '../../src/common.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWithoutContext('EventPrinter handles a null parent', () {
|
group(EventPrinter, () {
|
||||||
final EventPrinter eventPrinter = EventPrinter(out: StringBuffer());
|
|
||||||
final _Device device = _Device();
|
|
||||||
final Uri observatoryUri = Uri.parse('http://localhost:1234');
|
final Uri observatoryUri = Uri.parse('http://localhost:1234');
|
||||||
|
EventPrinter eventPrinter;
|
||||||
|
StringBuffer output;
|
||||||
|
|
||||||
|
setUp(() {
|
||||||
|
output = StringBuffer();
|
||||||
|
eventPrinter = EventPrinter(out: output);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWithoutContext('handles a null parent', () {
|
||||||
|
final _Device device = _Device();
|
||||||
|
|
||||||
expect(() => eventPrinter.handleFinishedTest(device), returnsNormally);
|
expect(() => eventPrinter.handleFinishedTest(device), returnsNormally);
|
||||||
expect(() => eventPrinter.handleStartedDevice(observatoryUri), returnsNormally);
|
expect(() => eventPrinter.handleStartedDevice(observatoryUri), returnsNormally);
|
||||||
expect(() => eventPrinter.handleTestCrashed(device), returnsNormally);
|
expect(() => eventPrinter.handleTestCrashed(device), returnsNormally);
|
||||||
expect(() => eventPrinter.handleTestTimedOut(device), returnsNormally);
|
expect(() => eventPrinter.handleTestTimedOut(device), returnsNormally);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
group('handleStartedDevice', () {
|
||||||
|
testWithoutContext('with non-null observatory', () {
|
||||||
|
eventPrinter.handleStartedDevice(observatoryUri);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
output.toString(),
|
||||||
|
'\n'
|
||||||
|
'[{"event":"test.startedProcess","params":{"observatoryUri":"http://localhost:1234"}}]'
|
||||||
|
'\n',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWithoutContext('with null observatory', () {
|
||||||
|
eventPrinter.handleStartedDevice(null);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
output.toString(),
|
||||||
|
'\n'
|
||||||
|
'[{"event":"test.startedProcess","params":{"observatoryUri":null}}]'
|
||||||
|
'\n',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class _Device extends Mock implements TestDevice {}
|
class _Device extends Mock implements TestDevice {}
|
||||||
|
Loading…
Reference in New Issue
Block a user