Unverified Commit 8522ec7e authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Validate empty observatory URI for screenshot (#71451)

parent a5ee7f7c
...@@ -77,6 +77,9 @@ class ScreenshotCommand extends FlutterCommand { ...@@ -77,6 +77,9 @@ class ScreenshotCommand extends FlutterCommand {
if (observatoryUri == null) { if (observatoryUri == null) {
throwToolExit('Observatory URI must be specified for screenshot type $screenshotType'); throwToolExit('Observatory URI must be specified for screenshot type $screenshotType');
} }
if (observatoryUri.isEmpty || Uri.tryParse(observatoryUri) == null) {
throwToolExit('Observatory URI "$observatoryUri" is invalid');
}
} }
} }
......
...@@ -15,8 +15,18 @@ void main() { ...@@ -15,8 +15,18 @@ void main() {
}); });
testUsingContext('rasterizer and skia screenshots require observatory uri', () async { testUsingContext('rasterizer and skia screenshots require observatory uri', () async {
expect(() => ScreenshotCommand.validateOptions('rasterizer', null, null), throwsToolExit()); expect(
expect(() => ScreenshotCommand.validateOptions('skia', null, null), throwsToolExit()); () => 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 { testUsingContext('device screenshots require device', () async {
......
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