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
86b62a3c
Unverified
Commit
86b62a3c
authored
Dec 16, 2022
by
fzyzcjy
Committed by
GitHub
Dec 16, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tiny fix about outdated message (#114391)
parent
a41c447c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
4 deletions
+26
-4
screenshot.dart
packages/flutter_tools/lib/src/commands/screenshot.dart
+6
-4
screenshot_command_test.dart
...test/commands.shard/hermetic/screenshot_command_test.dart
+20
-0
No files found.
packages/flutter_tools/lib/src/commands/screenshot.dart
View file @
86b62a3c
...
...
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:meta/meta.dart'
;
import
'package:vm_service/vm_service.dart'
as
vm_service
;
import
'../base/common.dart'
;
...
...
@@ -168,7 +169,7 @@ class ScreenshotCommand extends FlutterCommand {
sink
.
add
(
base64
.
decode
(
skp
.
json
?[
'skp'
]
as
String
));
await
sink
.
close
();
_showOutputFileInfo
(
outputFile
);
_
ensureOutputIsNotJsonRpcError
(
outputFile
);
ensureOutputIsNotJsonRpcError
(
outputFile
);
return
true
;
}
...
...
@@ -192,7 +193,7 @@ class ScreenshotCommand extends FlutterCommand {
sink
.
add
(
base64
.
decode
(
response
.
json
?[
'screenshot'
]
as
String
));
await
sink
.
close
();
_showOutputFileInfo
(
outputFile
);
_
ensureOutputIsNotJsonRpcError
(
outputFile
);
ensureOutputIsNotJsonRpcError
(
outputFile
);
return
true
;
}
...
...
@@ -205,7 +206,8 @@ class ScreenshotCommand extends FlutterCommand {
}
}
void
_ensureOutputIsNotJsonRpcError
(
File
outputFile
)
{
@visibleForTesting
static
void
ensureOutputIsNotJsonRpcError
(
File
outputFile
)
{
if
(
outputFile
.
lengthSync
()
>=
1000
)
{
return
;
}
...
...
@@ -213,7 +215,7 @@ class ScreenshotCommand extends FlutterCommand {
encoding:
const
AsciiCodec
(
allowInvalid:
true
),
);
if
(
content
.
startsWith
(
'{"jsonrpc":"2.0", "error"'
))
{
throwToolExit
(
'It appears the output file contains an error message, not valid
skia
output.'
);
throwToolExit
(
'It appears the output file contains an error message, not valid output.'
);
}
}
...
...
packages/flutter_tools/test/commands.shard/hermetic/screenshot_command_test.dart
View file @
86b62a3c
...
...
@@ -106,4 +106,24 @@ void main() {
message:
'File was not created, ensure path is valid'
));
});
});
group
(
'Screenshot output validation'
,
()
{
testWithoutContext
(
'successful'
,
()
async
{
final
MemoryFileSystem
fs
=
MemoryFileSystem
.
test
();
fs
.
file
(
'test.png'
).
createSync
();
expect
(()
=>
ScreenshotCommand
.
ensureOutputIsNotJsonRpcError
(
fs
.
file
(
'test.png'
)),
returnsNormally
);
});
testWithoutContext
(
'failed'
,
()
async
{
final
MemoryFileSystem
fs
=
MemoryFileSystem
.
test
();
fs
.
file
(
'test.png'
).
writeAsStringSync
(
'{"jsonrpc":"2.0", "error":"something"}'
);
expect
(
()
=>
ScreenshotCommand
.
ensureOutputIsNotJsonRpcError
(
fs
.
file
(
'test.png'
)),
throwsToolExit
(
message:
'It appears the output file contains an error message, not valid output.'
));
});
});
}
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