Validate empty observatory URI for screenshot (#71451)

This commit is contained in:
Jenn Magder 2020-12-01 10:00:30 -08:00 committed by GitHub
parent a5ee7f7cfc
commit 8522ec7e11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -77,6 +77,9 @@ class ScreenshotCommand extends FlutterCommand {
if (observatoryUri == null) {
throwToolExit('Observatory URI must be specified for screenshot type $screenshotType');
}
if (observatoryUri.isEmpty || Uri.tryParse(observatoryUri) == null) {
throwToolExit('Observatory URI "$observatoryUri" is invalid');
}
}
}

View File

@ -15,8 +15,18 @@ void main() {
});
testUsingContext('rasterizer and skia screenshots require observatory uri', () async {
expect(() => ScreenshotCommand.validateOptions('rasterizer', null, null), throwsToolExit());
expect(() => ScreenshotCommand.validateOptions('skia', null, null), throwsToolExit());
expect(
() => ScreenshotCommand.validateOptions('rasterizer', null, null),
throwsToolExit(
message:
'Observatory URI must be specified for screenshot type rasterizer'));
expect(
() => ScreenshotCommand.validateOptions('skia', null, null),
throwsToolExit(
message:
'Observatory URI must be specified for screenshot type skia'));
expect(() => ScreenshotCommand.validateOptions('skia', null, ''),
throwsToolExit(message: 'Observatory URI "" is invalid'));
});
testUsingContext('device screenshots require device', () async {