Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
7533c474
Unverified
Commit
7533c474
authored
Apr 09, 2021
by
Jonah Williams
Committed by
GitHub
Apr 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] dont require a device for screenshot type skia/rasterizer (#80153)
parent
645432ac
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
41 deletions
+75
-41
screenshot.dart
packages/flutter_tools/lib/src/commands/screenshot.dart
+6
-3
screenshot_command_test.dart
...test/commands.shard/hermetic/screenshot_command_test.dart
+69
-0
screenshot_command_test.dart
...ter_tools/test/general.shard/screenshot_command_test.dart
+0
-38
No files found.
packages/flutter_tools/lib/src/commands/screenshot.dart
View file @
7533c474
...
...
@@ -65,9 +65,13 @@ class ScreenshotCommand extends FlutterCommand {
Device
device
;
static
void
validateOptions
(
String
screenshotType
,
Device
device
,
String
observatoryUri
)
{
Future
<
void
>
_validateOptions
(
String
screenshotType
,
String
observatoryUri
)
async
{
switch
(
screenshotType
)
{
case
_kDeviceType:
if
(
observatoryUri
!=
null
)
{
throwToolExit
(
'Observatory URI cannot be provided for screenshot type
$screenshotType
'
);
}
device
=
await
findTargetDevice
();
if
(
device
==
null
)
{
throwToolExit
(
'Must have a connected device for screenshot type
$screenshotType
'
);
}
...
...
@@ -87,8 +91,7 @@ class ScreenshotCommand extends FlutterCommand {
@override
Future
<
FlutterCommandResult
>
verifyThenRunCommand
(
String
commandPath
)
async
{
device
=
await
findTargetDevice
();
validateOptions
(
stringArg
(
_kType
),
device
,
stringArg
(
_kObservatoryUri
));
await
_validateOptions
(
stringArg
(
_kType
),
stringArg
(
_kObservatoryUri
));
return
super
.
verifyThenRunCommand
(
commandPath
);
}
...
...
packages/flutter_tools/test/commands.shard/hermetic/screenshot_command_test.dart
0 → 100644
View file @
7533c474
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/screenshot.dart'
;
import
'package:flutter_tools/src/vmservice.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
import
'../../src/test_flutter_command_runner.dart'
;
void
main
(
)
{
setUpAll
(()
{
Cache
.
disableLocking
();
});
group
(
'Validate screenshot options'
,
()
{
testUsingContext
(
'rasterizer and skia screenshots do not require a device'
,
()
async
{
// Throw a specific exception when attempting to make a VM Service connection to
// verify that we've made it past the initial validation.
openChannelForTesting
=
(
String
url
,
{
CompressionOptions
compression
,
Logger
logger
})
async
{
expect
(
url
,
'ws://localhost:8181/ws'
);
throw
Exception
(
'dummy'
);
};
await
expectLater
(()
=>
createTestCommandRunner
(
ScreenshotCommand
())
.
run
(<
String
>[
'screenshot'
,
'--type=skia'
,
'--observatory-uri=http://localhost:8181'
]),
throwsA
(
isA
<
Exception
>().
having
((
dynamic
exception
)
=>
exception
.
toString
(),
'message'
,
contains
(
'dummy'
))),
);
await
expectLater
(()
=>
createTestCommandRunner
(
ScreenshotCommand
())
.
run
(<
String
>[
'screenshot'
,
'--type=rasterizer'
,
'--observatory-uri=http://localhost:8181'
]),
throwsA
(
isA
<
Exception
>().
having
((
dynamic
exception
)
=>
exception
.
toString
(),
'message'
,
contains
(
'dummy'
))),
);
});
testUsingContext
(
'rasterizer and skia screenshots require observatory uri'
,
()
async
{
await
expectLater
(()
=>
createTestCommandRunner
(
ScreenshotCommand
())
.
run
(<
String
>[
'screenshot'
,
'--type=skia'
]),
throwsToolExit
(
message:
'Observatory URI must be specified for screenshot type skia'
)
);
await
expectLater
(()
=>
createTestCommandRunner
(
ScreenshotCommand
())
.
run
(<
String
>[
'screenshot'
,
'--type=rasterizer'
,]),
throwsToolExit
(
message:
'Observatory URI must be specified for screenshot type rasterizer'
),
);
});
testUsingContext
(
'device screenshots require device'
,
()
async
{
await
expectLater
(()
=>
createTestCommandRunner
(
ScreenshotCommand
())
.
run
(<
String
>[
'screenshot'
]),
throwsToolExit
(
message:
'Must have a connected device for screenshot type device'
),
);
});
testUsingContext
(
'device screenshots cannot provided Observatory'
,
()
async
{
await
expectLater
(()
=>
createTestCommandRunner
(
ScreenshotCommand
())
.
run
(<
String
>[
'screenshot'
,
'--observatory-uri=http://localhost:8181'
]),
throwsToolExit
(
message:
'Observatory URI cannot be provided for screenshot type device'
),
);
});
});
}
packages/flutter_tools/test/general.shard/screenshot_command_test.dart
deleted
100644 → 0
View file @
645432ac
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_tools/src/commands/screenshot.dart'
;
import
'../src/common.dart'
;
import
'../src/context.dart'
;
void
main
(
)
{
group
(
'Validate screenshot options'
,
()
{
testUsingContext
(
'rasterizer and skia screenshots do not require a device'
,
()
async
{
ScreenshotCommand
.
validateOptions
(
'rasterizer'
,
null
,
'dummy_observatory_uri'
);
ScreenshotCommand
.
validateOptions
(
'skia'
,
null
,
'dummy_observatory_uri'
);
});
testUsingContext
(
'rasterizer and skia screenshots require observatory uri'
,
()
async
{
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
{
expect
(()
=>
ScreenshotCommand
.
validateOptions
(
'device'
,
null
,
null
),
throwsToolExit
());
});
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment