Auto-format Framework (#160545)
This auto-formats all *.dart files in the repository outside of the `engine` subdirectory and enforces that these files stay formatted with a presubmit check. **Reviewers:** Please carefully review all the commits except for the one titled "formatted". The "formatted" commit was auto-generated by running `dev/tools/format.sh -a -f`. The other commits were hand-crafted to prepare the repo for the formatting change. I recommend reviewing the commits one-by-one via the "Commits" tab and avoiding Github's "Files changed" tab as it will likely slow down your browser because of the size of this PR. --------- Co-authored-by: Kate Lovett <katelovett@google.com> Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
8e0993eda8
commit
5491c8c146
@@ -8,58 +8,48 @@ import 'package:args/args.dart';
|
||||
import 'package:vitool/vitool.dart';
|
||||
|
||||
const String kCodegenComment =
|
||||
'// AUTOGENERATED FILE DO NOT EDIT!\n'
|
||||
'// This file was generated by vitool.\n';
|
||||
'// AUTOGENERATED FILE DO NOT EDIT!\n'
|
||||
'// This file was generated by vitool.\n';
|
||||
|
||||
void main(List<String> args) {
|
||||
final ArgParser parser = ArgParser();
|
||||
|
||||
parser.addFlag(
|
||||
'help',
|
||||
abbr: 'h',
|
||||
negatable: false,
|
||||
help: "Display the tool's usage instructions and quit.",
|
||||
'help',
|
||||
abbr: 'h',
|
||||
negatable: false,
|
||||
help: "Display the tool's usage instructions and quit.",
|
||||
);
|
||||
|
||||
parser.addOption(
|
||||
'output',
|
||||
abbr: 'o',
|
||||
help: 'Target path to write the generated Dart file to.',
|
||||
);
|
||||
parser.addOption('output', abbr: 'o', help: 'Target path to write the generated Dart file to.');
|
||||
|
||||
parser.addOption('asset-name', abbr: 'n', help: 'Name to be used for the generated constant.');
|
||||
|
||||
parser.addOption('part-of', abbr: 'p', help: "Library name to add a dart 'part of' clause for.");
|
||||
|
||||
parser.addOption(
|
||||
'asset-name',
|
||||
abbr: 'n',
|
||||
help: 'Name to be used for the generated constant.',
|
||||
);
|
||||
|
||||
parser.addOption(
|
||||
'part-of',
|
||||
abbr: 'p',
|
||||
help: "Library name to add a dart 'part of' clause for.",
|
||||
);
|
||||
|
||||
parser.addOption(
|
||||
'header',
|
||||
abbr: 'd',
|
||||
help: 'File whose contents are to be prepended to the beginning of '
|
||||
'the generated Dart file; this can be used for a license comment.',
|
||||
'header',
|
||||
abbr: 'd',
|
||||
help:
|
||||
'File whose contents are to be prepended to the beginning of '
|
||||
'the generated Dart file; this can be used for a license comment.',
|
||||
);
|
||||
|
||||
parser.addFlag(
|
||||
'codegen_comment',
|
||||
abbr: 'c',
|
||||
defaultsTo: true,
|
||||
help: 'Whether to include the following comment after the header:\n'
|
||||
'$kCodegenComment',
|
||||
'codegen_comment',
|
||||
abbr: 'c',
|
||||
defaultsTo: true,
|
||||
help:
|
||||
'Whether to include the following comment after the header:\n'
|
||||
'$kCodegenComment',
|
||||
);
|
||||
|
||||
final ArgResults argResults = parser.parse(args);
|
||||
|
||||
if (argResults['help'] as bool ||
|
||||
!argResults.wasParsed('output') ||
|
||||
!argResults.wasParsed('asset-name') ||
|
||||
argResults.rest.isEmpty) {
|
||||
!argResults.wasParsed('output') ||
|
||||
!argResults.wasParsed('asset-name') ||
|
||||
argResults.rest.isEmpty) {
|
||||
printUsage(parser);
|
||||
return;
|
||||
}
|
||||
@@ -80,7 +70,9 @@ void main(List<String> args) {
|
||||
}
|
||||
|
||||
if (argResults.wasParsed('part-of')) {
|
||||
generatedSb.write('part of ${argResults['part-of']}; // ignore: use_string_in_part_of_directives\n');
|
||||
generatedSb.write(
|
||||
'part of ${argResults['part-of']}; // ignore: use_string_in_part_of_directives\n',
|
||||
);
|
||||
}
|
||||
|
||||
final Animation animation = Animation.fromFrameData(frames);
|
||||
@@ -92,6 +84,8 @@ void main(List<String> args) {
|
||||
|
||||
void printUsage(ArgParser parser) {
|
||||
print('Usage: vitool --asset-name=<asset_name> --output=<output_path> <frames_list>');
|
||||
print('\nExample: vitool --asset-name=_\$menu_arrow --output=lib/data/menu_arrow.g.dart assets/svg/menu_arrow/*.svg\n');
|
||||
print(
|
||||
'\nExample: vitool --asset-name=_\$menu_arrow --output=lib/data/menu_arrow.g.dart assets/svg/menu_arrow/*.svg\n',
|
||||
);
|
||||
print(parser.usage);
|
||||
}
|
||||
|
||||
@@ -40,16 +40,16 @@ class Animation {
|
||||
final FrameData frame = frames[i];
|
||||
if (size != frame.size) {
|
||||
throw Exception(
|
||||
'All animation frames must have the same size,\n'
|
||||
'first frame size was: (${size.x}, ${size.y})\n'
|
||||
'frame $i size was: (${frame.size.x}, ${frame.size.y})'
|
||||
'All animation frames must have the same size,\n'
|
||||
'first frame size was: (${size.x}, ${size.y})\n'
|
||||
'frame $i size was: (${frame.size.x}, ${frame.size.y})',
|
||||
);
|
||||
}
|
||||
if (numPaths != frame.paths.length) {
|
||||
throw Exception(
|
||||
'All animation frames must have the same number of paths,\n'
|
||||
'first frame has $numPaths paths\n'
|
||||
'frame $i has ${frame.paths.length} paths'
|
||||
'All animation frames must have the same number of paths,\n'
|
||||
'first frame has $numPaths paths\n'
|
||||
'frame $i has ${frame.paths.length} paths',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -79,18 +79,25 @@ class PathAnimation {
|
||||
}
|
||||
|
||||
final List<PathCommandAnimation> commands = <PathCommandAnimation>[];
|
||||
for (int commandIdx = 0; commandIdx < frames[0].paths[pathIdx].commands.length; commandIdx += 1) {
|
||||
for (
|
||||
int commandIdx = 0;
|
||||
commandIdx < frames[0].paths[pathIdx].commands.length;
|
||||
commandIdx += 1
|
||||
) {
|
||||
final int numPointsInCommand = frames[0].paths[pathIdx].commands[commandIdx].points.length;
|
||||
final List<List<Point<double>>> points = List<List<Point<double>>>.filled(numPointsInCommand, <Point<double>>[]);
|
||||
final List<List<Point<double>>> points = List<List<Point<double>>>.filled(
|
||||
numPointsInCommand,
|
||||
<Point<double>>[],
|
||||
);
|
||||
final String commandType = frames[0].paths[pathIdx].commands[commandIdx].type;
|
||||
for (int i = 0; i < frames.length; i += 1) {
|
||||
final FrameData frame = frames[i];
|
||||
final String currentCommandType = frame.paths[pathIdx].commands[commandIdx].type;
|
||||
if (commandType != currentCommandType) {
|
||||
throw Exception(
|
||||
'Paths must be built from the same commands in all frames '
|
||||
"command $commandIdx at frame 0 was of type '$commandType' "
|
||||
"command $commandIdx at frame $i was of type '$currentCommandType'"
|
||||
'Paths must be built from the same commands in all frames '
|
||||
"command $commandIdx at frame 0 was of type '$commandType' "
|
||||
"command $commandIdx at frame $i was of type '$currentCommandType'",
|
||||
);
|
||||
}
|
||||
for (int j = 0; j < numPointsInCommand; j += 1) {
|
||||
@@ -101,13 +108,14 @@ class PathAnimation {
|
||||
}
|
||||
|
||||
final List<double> opacities =
|
||||
frames.map<double>((FrameData d) => d.paths[pathIdx].opacity).toList();
|
||||
frames.map<double>((FrameData d) => d.paths[pathIdx].opacity).toList();
|
||||
|
||||
return PathAnimation(commands, opacities: opacities);
|
||||
}
|
||||
|
||||
/// List of commands for drawing the path.
|
||||
final List<PathCommandAnimation> commands;
|
||||
|
||||
/// The path opacity for each animation frame.
|
||||
final List<double> opacities;
|
||||
|
||||
@@ -190,8 +198,7 @@ FrameData interpretSvg(String svgFilePath) {
|
||||
final double width = parsePixels(_extractAttr(svgElement, 'width')).toDouble();
|
||||
final double height = parsePixels(_extractAttr(svgElement, 'height')).toDouble();
|
||||
|
||||
final List<SvgPath> paths =
|
||||
_interpretSvgGroup(svgElement.children, _Transform());
|
||||
final List<SvgPath> paths = _interpretSvgGroup(svgElement.children, _Transform());
|
||||
return FrameData(Point<double>(width, height), paths);
|
||||
}
|
||||
|
||||
@@ -216,7 +223,8 @@ List<SvgPath> _interpretSvgGroup(List<XmlNode> children, _Transform transform) {
|
||||
Matrix3 transformMatrix = transform.transformMatrix;
|
||||
if (_hasAttr(element, 'transform')) {
|
||||
transformMatrix = transformMatrix.multiplied(
|
||||
_parseSvgTransform(_extractAttr(element, 'transform')));
|
||||
_parseSvgTransform(_extractAttr(element, 'transform')),
|
||||
);
|
||||
}
|
||||
|
||||
final _Transform subtreeTransform = _Transform(
|
||||
@@ -249,10 +257,7 @@ List<Point<double>> parsePoints(String points) {
|
||||
final List<Point<double>> result = <Point<double>>[];
|
||||
while (unParsed.isNotEmpty && _pointMatcher.hasMatch(unParsed)) {
|
||||
final Match m = _pointMatcher.firstMatch(unParsed)!;
|
||||
result.add(Point<double>(
|
||||
double.parse(m.group(1)!),
|
||||
double.parse(m.group(2)!),
|
||||
));
|
||||
result.add(Point<double>(double.parse(m.group(1)!), double.parse(m.group(2)!)));
|
||||
unParsed = m.group(3)!;
|
||||
}
|
||||
return result;
|
||||
@@ -271,9 +276,9 @@ class FrameData {
|
||||
if (other.runtimeType != runtimeType) {
|
||||
return false;
|
||||
}
|
||||
return other is FrameData
|
||||
&& other.size == size
|
||||
&& const ListEquality<SvgPath>().equals(other.paths, paths);
|
||||
return other is FrameData &&
|
||||
other.size == size &&
|
||||
const ListEquality<SvgPath>().equals(other.paths, paths);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -317,7 +322,7 @@ class SvgPath {
|
||||
|
||||
SvgPath _applyTransform(_Transform transform) {
|
||||
final List<SvgPathCommand> transformedCommands =
|
||||
commands.map<SvgPathCommand>((SvgPathCommand c) => c._applyTransform(transform)).toList();
|
||||
commands.map<SvgPathCommand>((SvgPathCommand c) => c._applyTransform(transform)).toList();
|
||||
return SvgPath(id, transformedCommands, opacity: opacity * transform.opacity);
|
||||
}
|
||||
|
||||
@@ -326,10 +331,10 @@ class SvgPath {
|
||||
if (other.runtimeType != runtimeType) {
|
||||
return false;
|
||||
}
|
||||
return other is SvgPath
|
||||
&& other.id == id
|
||||
&& other.opacity == opacity
|
||||
&& const ListEquality<SvgPathCommand>().equals(other.commands, commands);
|
||||
return other is SvgPath &&
|
||||
other.id == id &&
|
||||
other.opacity == opacity &&
|
||||
const ListEquality<SvgPathCommand>().equals(other.commands, commands);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -339,7 +344,6 @@ class SvgPath {
|
||||
String toString() {
|
||||
return 'SvgPath(id: $id, opacity: $opacity, commands: $commands)';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// Represents a single SVG path command from an SVG d element.
|
||||
@@ -363,11 +367,8 @@ class SvgPathCommand {
|
||||
final List<Point<double>> points;
|
||||
|
||||
SvgPathCommand _applyTransform(_Transform transform) {
|
||||
final List<Point<double>> transformedPoints =
|
||||
_vector3ArrayToPoints(
|
||||
transform.transformMatrix.applyToVector3Array(
|
||||
_pointsToVector3Array(points)
|
||||
)
|
||||
final List<Point<double>> transformedPoints = _vector3ArrayToPoints(
|
||||
transform.transformMatrix.applyToVector3Array(_pointsToVector3Array(points)),
|
||||
);
|
||||
return SvgPathCommand(type, transformedPoints);
|
||||
}
|
||||
@@ -377,9 +378,9 @@ class SvgPathCommand {
|
||||
if (other.runtimeType != runtimeType) {
|
||||
return false;
|
||||
}
|
||||
return other is SvgPathCommand
|
||||
&& other.type == type
|
||||
&& const ListEquality<Point<double>>().equals(other.points, points);
|
||||
return other is SvgPathCommand &&
|
||||
other.type == type &&
|
||||
const ListEquality<Point<double>>().equals(other.points, points);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -392,7 +393,7 @@ class SvgPathCommand {
|
||||
}
|
||||
|
||||
class SvgPathCommandBuilder {
|
||||
static const Map<String, void> kRelativeCommands = <String, void> {
|
||||
static const Map<String, void> kRelativeCommands = <String, void>{
|
||||
'c': null,
|
||||
'l': null,
|
||||
'm': null,
|
||||
@@ -440,8 +441,7 @@ List<double> _pointsToVector3Array(List<Point<double>> points) {
|
||||
List<Point<double>> _vector3ArrayToPoints(List<double> vector) {
|
||||
final int numPoints = (vector.length / 3).floor();
|
||||
final List<Point<double>> points = <Point<double>>[
|
||||
for (int i = 0; i < numPoints; i += 1)
|
||||
Point<double>(vector[i*3], vector[i*3 + 1]),
|
||||
for (int i = 0; i < numPoints; i += 1) Point<double>(vector[i * 3], vector[i * 3 + 1]),
|
||||
];
|
||||
return points;
|
||||
}
|
||||
@@ -451,23 +451,21 @@ List<Point<double>> _vector3ArrayToPoints(List<double> vector) {
|
||||
/// This includes more transforms than the ones described by the SVG transform
|
||||
/// attribute, e.g opacity.
|
||||
class _Transform {
|
||||
|
||||
/// Constructs a new _Transform, default arguments create a no-op transform.
|
||||
_Transform({Matrix3? transformMatrix, this.opacity = 1.0}) :
|
||||
transformMatrix = transformMatrix ?? Matrix3.identity();
|
||||
_Transform({Matrix3? transformMatrix, this.opacity = 1.0})
|
||||
: transformMatrix = transformMatrix ?? Matrix3.identity();
|
||||
|
||||
final Matrix3 transformMatrix;
|
||||
final double opacity;
|
||||
|
||||
_Transform applyTransform(_Transform transform) {
|
||||
return _Transform(
|
||||
transformMatrix: transform.transformMatrix.multiplied(transformMatrix),
|
||||
opacity: transform.opacity * opacity,
|
||||
transformMatrix: transform.transformMatrix.multiplied(transformMatrix),
|
||||
opacity: transform.opacity * opacity,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const String _transformCommandAtom = r' *([^(]+)\(([^)]*)\)';
|
||||
final RegExp _transformValidator = RegExp('^($_transformCommandAtom)*\$');
|
||||
final RegExp _transformCommand = RegExp(_transformCommandAtom);
|
||||
@@ -476,7 +474,7 @@ Matrix3 _parseSvgTransform(String transform) {
|
||||
if (!_transformValidator.hasMatch(transform)) {
|
||||
throw Exception('illegal or unsupported transform: $transform');
|
||||
}
|
||||
final Iterable<Match> matches =_transformCommand.allMatches(transform).toList().reversed;
|
||||
final Iterable<Match> matches = _transformCommand.allMatches(transform).toList().reversed;
|
||||
Matrix3 result = Matrix3.identity();
|
||||
for (final Match m in matches) {
|
||||
final String command = m.group(1)!;
|
||||
@@ -539,19 +537,19 @@ int parsePixels(String pixels) {
|
||||
if (!_pixelsExp.hasMatch(pixels)) {
|
||||
throw ArgumentError(
|
||||
"illegal pixels expression: '$pixels'"
|
||||
' (the tool currently only support pixel units).');
|
||||
' (the tool currently only support pixel units).',
|
||||
);
|
||||
}
|
||||
return int.parse(_pixelsExp.firstMatch(pixels)!.group(1)!);
|
||||
}
|
||||
|
||||
String _extractAttr(XmlElement element, String name) {
|
||||
try {
|
||||
return element.attributes.singleWhere((XmlAttribute x) => x.name.local == name)
|
||||
.value;
|
||||
return element.attributes.singleWhere((XmlAttribute x) => x.name.local == name).value;
|
||||
} catch (e) {
|
||||
throw ArgumentError(
|
||||
"Can't find a single '$name' attributes in ${element.name}, "
|
||||
'attributes were: ${element.attributes}'
|
||||
"Can't find a single '$name' attributes in ${element.name}, "
|
||||
'attributes were: ${element.attributes}',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -562,9 +560,10 @@ bool _hasAttr(XmlElement element, String name) {
|
||||
|
||||
XmlElement _extractSvgElement(XmlDocument document) {
|
||||
return document.children.singleWhere(
|
||||
(XmlNode node) => node.nodeType == XmlNodeType.ELEMENT &&
|
||||
_asElement(node).name.local == 'svg'
|
||||
) as XmlElement;
|
||||
(XmlNode node) =>
|
||||
node.nodeType == XmlNodeType.ELEMENT && _asElement(node).name.local == 'svg',
|
||||
)
|
||||
as XmlElement;
|
||||
}
|
||||
|
||||
XmlElement _asElement(XmlNode node) => node as XmlElement;
|
||||
|
||||
@@ -11,29 +11,24 @@ import 'package:path/path.dart' as path;
|
||||
import 'package:vitool/vitool.dart';
|
||||
|
||||
void main() {
|
||||
|
||||
test('parsePixels', () {
|
||||
expect(parsePixels('23px'), 23);
|
||||
expect(parsePixels('9px'), 9);
|
||||
expect(() { parsePixels('9pt'); }, throwsArgumentError);
|
||||
expect(() {
|
||||
parsePixels('9pt');
|
||||
}, throwsArgumentError);
|
||||
});
|
||||
|
||||
test('parsePoints', () {
|
||||
expect(parsePoints('1.0, 2.0'),
|
||||
const <Point<double>>[Point<double>(1.0, 2.0)],
|
||||
);
|
||||
expect(parsePoints('12.0, 34.0 5.0, 6.6'),
|
||||
const <Point<double>>[
|
||||
Point<double>(12.0, 34.0),
|
||||
Point<double>(5.0, 6.6),
|
||||
],
|
||||
);
|
||||
expect(parsePoints('12.0 34.0 5.0 6.6'),
|
||||
const <Point<double>>[
|
||||
Point<double>(12.0, 34.0),
|
||||
Point<double>(5.0, 6.6),
|
||||
],
|
||||
);
|
||||
expect(parsePoints('1.0, 2.0'), const <Point<double>>[Point<double>(1.0, 2.0)]);
|
||||
expect(parsePoints('12.0, 34.0 5.0, 6.6'), const <Point<double>>[
|
||||
Point<double>(12.0, 34.0),
|
||||
Point<double>(5.0, 6.6),
|
||||
]);
|
||||
expect(parsePoints('12.0 34.0 5.0 6.6'), const <Point<double>>[
|
||||
Point<double>(12.0, 34.0),
|
||||
Point<double>(5.0, 6.6),
|
||||
]);
|
||||
});
|
||||
|
||||
group('parseSvg', () {
|
||||
@@ -43,21 +38,20 @@ void main() {
|
||||
});
|
||||
|
||||
test('illegal SVGs', () {
|
||||
expect(
|
||||
() { interpretSvg(testAsset('illegal_svg_multiple_roots.svg')); },
|
||||
throwsA(anything),
|
||||
);
|
||||
expect(() {
|
||||
interpretSvg(testAsset('illegal_svg_multiple_roots.svg'));
|
||||
}, throwsA(anything));
|
||||
});
|
||||
|
||||
test('SVG size', () {
|
||||
expect(
|
||||
interpretSvg(testAsset('empty_svg_1_48x48.svg')).size,
|
||||
const Point<double>(48.0, 48.0),
|
||||
interpretSvg(testAsset('empty_svg_1_48x48.svg')).size,
|
||||
const Point<double>(48.0, 48.0),
|
||||
);
|
||||
|
||||
expect(
|
||||
interpretSvg(testAsset('empty_svg_2_100x50.svg')).size,
|
||||
const Point<double>(100.0, 50.0),
|
||||
interpretSvg(testAsset('empty_svg_2_100x50.svg')).size,
|
||||
const Point<double>(100.0, 50.0),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -79,13 +73,11 @@ void main() {
|
||||
});
|
||||
|
||||
test('SVG illegal path', () {
|
||||
expect(
|
||||
() { interpretSvg(testAsset('illegal_path.svg')); },
|
||||
throwsA(anything),
|
||||
);
|
||||
expect(() {
|
||||
interpretSvg(testAsset('illegal_path.svg'));
|
||||
}, throwsA(anything));
|
||||
});
|
||||
|
||||
|
||||
test('SVG group', () {
|
||||
final FrameData frameData = interpretSvg(testAsset('bars_group.svg'));
|
||||
expect(frameData.paths, const <SvgPath>[
|
||||
@@ -122,8 +114,7 @@ void main() {
|
||||
test('SVG group scale', () {
|
||||
final FrameData frameData = interpretSvg(testAsset('bar_group_scale.svg'));
|
||||
expect(frameData.paths, const <SvgPath>[
|
||||
SvgPath(
|
||||
'path_1', <SvgPathCommand>[
|
||||
SvgPath('path_1', <SvgPathCommand>[
|
||||
SvgPathCommand('M', <Point<double>>[Point<double>(0.0, 9.5)]),
|
||||
SvgPathCommand('L', <Point<double>>[Point<double>(24.0, 9.5)]),
|
||||
SvgPathCommand('L', <Point<double>>[Point<double>(24.0, 14.5)]),
|
||||
@@ -137,40 +128,34 @@ void main() {
|
||||
final FrameData frameData = interpretSvg(testAsset('bar_group_rotate_scale.svg'));
|
||||
expect(frameData.paths, const <PathMatcher>[
|
||||
PathMatcher(
|
||||
SvgPath(
|
||||
'path_1', <SvgPathCommand>[
|
||||
SvgPathCommand('L', <Point<double>>[Point<double>(29.0, 0.0)]),
|
||||
SvgPathCommand('L', <Point<double>>[Point<double>(29.0, 48.0)]),
|
||||
SvgPathCommand('L', <Point<double>>[Point<double>(19.0, 48.0)]),
|
||||
SvgPathCommand('M', <Point<double>>[Point<double>(19.0, 0.0)]),
|
||||
SvgPathCommand('Z', <Point<double>>[]),
|
||||
]),
|
||||
margin: precisionErrorTolerance,
|
||||
SvgPath('path_1', <SvgPathCommand>[
|
||||
SvgPathCommand('L', <Point<double>>[Point<double>(29.0, 0.0)]),
|
||||
SvgPathCommand('L', <Point<double>>[Point<double>(29.0, 48.0)]),
|
||||
SvgPathCommand('L', <Point<double>>[Point<double>(19.0, 48.0)]),
|
||||
SvgPathCommand('M', <Point<double>>[Point<double>(19.0, 0.0)]),
|
||||
SvgPathCommand('Z', <Point<double>>[]),
|
||||
]),
|
||||
margin: precisionErrorTolerance,
|
||||
),
|
||||
]);
|
||||
});
|
||||
|
||||
test('SVG illegal transform', () {
|
||||
expect(
|
||||
() { interpretSvg(testAsset('illegal_transform.svg')); },
|
||||
throwsA(anything),
|
||||
);
|
||||
expect(() {
|
||||
interpretSvg(testAsset('illegal_transform.svg'));
|
||||
}, throwsA(anything));
|
||||
});
|
||||
|
||||
test('SVG group opacity', () {
|
||||
final FrameData frameData = interpretSvg(testAsset('bar_group_opacity.svg'));
|
||||
expect(frameData.paths, const <SvgPath>[
|
||||
SvgPath(
|
||||
'path_1',
|
||||
<SvgPathCommand>[
|
||||
SvgPathCommand('M', <Point<double>>[Point<double>(0.0, 19.0)]),
|
||||
SvgPathCommand('L', <Point<double>>[Point<double>(48.0, 19.0)]),
|
||||
SvgPathCommand('L', <Point<double>>[Point<double>(48.0, 29.0)]),
|
||||
SvgPathCommand('L', <Point<double>>[Point<double>(0.0, 29.0)]),
|
||||
SvgPathCommand('Z', <Point<double>>[]),
|
||||
],
|
||||
opacity: 0.5,
|
||||
),
|
||||
SvgPath('path_1', <SvgPathCommand>[
|
||||
SvgPathCommand('M', <Point<double>>[Point<double>(0.0, 19.0)]),
|
||||
SvgPathCommand('L', <Point<double>>[Point<double>(48.0, 19.0)]),
|
||||
SvgPathCommand('L', <Point<double>>[Point<double>(48.0, 29.0)]),
|
||||
SvgPathCommand('L', <Point<double>>[Point<double>(0.0, 29.0)]),
|
||||
SvgPathCommand('Z', <Point<double>>[]),
|
||||
], opacity: 0.5),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -178,8 +163,7 @@ void main() {
|
||||
// This asset uses the relative 'l' command instead of 'L'.
|
||||
final FrameData frameData = interpretSvg(testAsset('horizontal_bar_relative.svg'));
|
||||
expect(frameData.paths, const <SvgPath>[
|
||||
SvgPath(
|
||||
'path_1', <SvgPathCommand>[
|
||||
SvgPath('path_1', <SvgPathCommand>[
|
||||
SvgPathCommand('M', <Point<double>>[Point<double>(0.0, 19.0)]),
|
||||
SvgPathCommand('L', <Point<double>>[Point<double>(48.0, 19.0)]),
|
||||
SvgPathCommand('L', <Point<double>>[Point<double>(48.0, 29.0)]),
|
||||
@@ -193,8 +177,7 @@ void main() {
|
||||
// This asset uses the relative 'l' command instead of 'L'.
|
||||
final FrameData frameData = interpretSvg(testAsset('close_path_in_middle.svg'));
|
||||
expect(frameData.paths, const <SvgPath>[
|
||||
SvgPath(
|
||||
'path_1', <SvgPathCommand>[
|
||||
SvgPath('path_1', <SvgPathCommand>[
|
||||
SvgPathCommand('M', <Point<double>>[Point<double>(50.0, 50.0)]),
|
||||
SvgPathCommand('L', <Point<double>>[Point<double>(60.0, 50.0)]),
|
||||
SvgPathCommand('L', <Point<double>>[Point<double>(60.0, 60.0)]),
|
||||
@@ -210,115 +193,96 @@ void main() {
|
||||
group('create PathAnimation', () {
|
||||
test('single path', () {
|
||||
const List<FrameData> frameData = <FrameData>[
|
||||
FrameData(
|
||||
Point<double>(10.0, 10.0),
|
||||
<SvgPath>[
|
||||
SvgPath(
|
||||
'path_1',
|
||||
<SvgPathCommand>[
|
||||
SvgPathCommand('M', <Point<double>>[Point<double>(0.0, 0.0)]),
|
||||
SvgPathCommand('L', <Point<double>>[Point<double>(10.0, 10.0)]),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
FrameData(Point<double>(10.0, 10.0), <SvgPath>[
|
||||
SvgPath('path_1', <SvgPathCommand>[
|
||||
SvgPathCommand('M', <Point<double>>[Point<double>(0.0, 0.0)]),
|
||||
SvgPathCommand('L', <Point<double>>[Point<double>(10.0, 10.0)]),
|
||||
]),
|
||||
]),
|
||||
];
|
||||
expect(PathAnimation.fromFrameData(frameData, 0),
|
||||
const PathAnimationMatcher(PathAnimation(
|
||||
<PathCommandAnimation>[
|
||||
PathCommandAnimation('M', <List<Point<double>>>[
|
||||
<Point<double>>[Point<double>(0.0, 0.0)],
|
||||
]),
|
||||
PathCommandAnimation('L', <List<Point<double>>>[
|
||||
<Point<double>>[Point<double>(10.0, 10.0)],
|
||||
]),
|
||||
],
|
||||
opacities: <double>[1.0],
|
||||
)),
|
||||
expect(
|
||||
PathAnimation.fromFrameData(frameData, 0),
|
||||
const PathAnimationMatcher(
|
||||
PathAnimation(
|
||||
<PathCommandAnimation>[
|
||||
PathCommandAnimation('M', <List<Point<double>>>[
|
||||
<Point<double>>[Point<double>(0.0, 0.0)],
|
||||
]),
|
||||
PathCommandAnimation('L', <List<Point<double>>>[
|
||||
<Point<double>>[Point<double>(10.0, 10.0)],
|
||||
]),
|
||||
],
|
||||
opacities: <double>[1.0],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test('multiple paths', () {
|
||||
const List<FrameData> frameData = <FrameData>[
|
||||
FrameData(
|
||||
Point<double>(10.0, 10.0),
|
||||
<SvgPath>[
|
||||
SvgPath(
|
||||
'path_1',
|
||||
<SvgPathCommand>[
|
||||
SvgPathCommand('M', <Point<double>>[Point<double>(0.0, 0.0)]),
|
||||
],
|
||||
),
|
||||
SvgPath(
|
||||
'path_2',
|
||||
<SvgPathCommand>[
|
||||
SvgPathCommand('M', <Point<double>>[Point<double>(5.0, 6.0)]),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
FrameData(Point<double>(10.0, 10.0), <SvgPath>[
|
||||
SvgPath('path_1', <SvgPathCommand>[
|
||||
SvgPathCommand('M', <Point<double>>[Point<double>(0.0, 0.0)]),
|
||||
]),
|
||||
SvgPath('path_2', <SvgPathCommand>[
|
||||
SvgPathCommand('M', <Point<double>>[Point<double>(5.0, 6.0)]),
|
||||
]),
|
||||
]),
|
||||
];
|
||||
expect(PathAnimation.fromFrameData(frameData, 0),
|
||||
const PathAnimationMatcher(PathAnimation(
|
||||
<PathCommandAnimation>[
|
||||
PathCommandAnimation('M', <List<Point<double>>>[
|
||||
<Point<double>>[Point<double>(0.0, 0.0)],
|
||||
]),
|
||||
],
|
||||
opacities: <double>[1.0],
|
||||
)),
|
||||
expect(
|
||||
PathAnimation.fromFrameData(frameData, 0),
|
||||
const PathAnimationMatcher(
|
||||
PathAnimation(
|
||||
<PathCommandAnimation>[
|
||||
PathCommandAnimation('M', <List<Point<double>>>[
|
||||
<Point<double>>[Point<double>(0.0, 0.0)],
|
||||
]),
|
||||
],
|
||||
opacities: <double>[1.0],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(PathAnimation.fromFrameData(frameData, 1),
|
||||
const PathAnimationMatcher(PathAnimation(
|
||||
<PathCommandAnimation>[
|
||||
PathCommandAnimation('M', <List<Point<double>>>[
|
||||
<Point<double>>[Point<double>(5.0, 6.0)],
|
||||
]),
|
||||
],
|
||||
opacities: <double>[1.0],
|
||||
)),
|
||||
expect(
|
||||
PathAnimation.fromFrameData(frameData, 1),
|
||||
const PathAnimationMatcher(
|
||||
PathAnimation(
|
||||
<PathCommandAnimation>[
|
||||
PathCommandAnimation('M', <List<Point<double>>>[
|
||||
<Point<double>>[Point<double>(5.0, 6.0)],
|
||||
]),
|
||||
],
|
||||
opacities: <double>[1.0],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test('multiple frames', () {
|
||||
const List<FrameData> frameData = <FrameData>[
|
||||
FrameData(
|
||||
Point<double>(10.0, 10.0),
|
||||
<SvgPath>[
|
||||
SvgPath(
|
||||
'path_1',
|
||||
<SvgPathCommand>[
|
||||
SvgPathCommand('M', <Point<double>>[Point<double>(0.0, 0.0)]),
|
||||
],
|
||||
opacity: 0.5,
|
||||
),
|
||||
],
|
||||
),
|
||||
FrameData(
|
||||
Point<double>(10.0, 10.0),
|
||||
<SvgPath>[
|
||||
SvgPath(
|
||||
'path_1',
|
||||
<SvgPathCommand>[
|
||||
SvgPathCommand('M', <Point<double>>[Point<double>(10.0, 10.0)]),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
FrameData(Point<double>(10.0, 10.0), <SvgPath>[
|
||||
SvgPath('path_1', <SvgPathCommand>[
|
||||
SvgPathCommand('M', <Point<double>>[Point<double>(0.0, 0.0)]),
|
||||
], opacity: 0.5),
|
||||
]),
|
||||
FrameData(Point<double>(10.0, 10.0), <SvgPath>[
|
||||
SvgPath('path_1', <SvgPathCommand>[
|
||||
SvgPathCommand('M', <Point<double>>[Point<double>(10.0, 10.0)]),
|
||||
]),
|
||||
]),
|
||||
];
|
||||
expect(PathAnimation.fromFrameData(frameData, 0),
|
||||
const PathAnimationMatcher(PathAnimation(
|
||||
<PathCommandAnimation>[
|
||||
PathCommandAnimation('M', <List<Point<double>>>[
|
||||
<Point<double>>[
|
||||
Point<double>(0.0, 0.0),
|
||||
Point<double>(10.0, 10.0),
|
||||
],
|
||||
]),
|
||||
],
|
||||
opacities: <double>[0.5, 1.0],
|
||||
)),
|
||||
expect(
|
||||
PathAnimation.fromFrameData(frameData, 0),
|
||||
const PathAnimationMatcher(
|
||||
PathAnimation(
|
||||
<PathCommandAnimation>[
|
||||
PathCommandAnimation('M', <List<Point<double>>>[
|
||||
<Point<double>>[Point<double>(0.0, 0.0), Point<double>(10.0, 10.0)],
|
||||
]),
|
||||
],
|
||||
opacities: <double>[0.5, 1.0],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -326,45 +290,42 @@ void main() {
|
||||
group('create Animation', () {
|
||||
test('multiple paths', () {
|
||||
const List<FrameData> frameData = <FrameData>[
|
||||
FrameData(
|
||||
Point<double>(10.0, 10.0),
|
||||
<SvgPath>[
|
||||
SvgPath(
|
||||
'path_1',
|
||||
<SvgPathCommand>[
|
||||
SvgPathCommand('M', <Point<double>>[Point<double>(0.0, 0.0)]),
|
||||
],
|
||||
),
|
||||
SvgPath(
|
||||
'path_1',
|
||||
<SvgPathCommand>[
|
||||
SvgPathCommand('M', <Point<double>>[Point<double>(5.0, 6.0)]),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
FrameData(Point<double>(10.0, 10.0), <SvgPath>[
|
||||
SvgPath('path_1', <SvgPathCommand>[
|
||||
SvgPathCommand('M', <Point<double>>[Point<double>(0.0, 0.0)]),
|
||||
]),
|
||||
SvgPath('path_1', <SvgPathCommand>[
|
||||
SvgPathCommand('M', <Point<double>>[Point<double>(5.0, 6.0)]),
|
||||
]),
|
||||
]),
|
||||
];
|
||||
final Animation animation = Animation.fromFrameData(frameData);
|
||||
expect(animation.paths[0],
|
||||
const PathAnimationMatcher(PathAnimation(
|
||||
<PathCommandAnimation>[
|
||||
PathCommandAnimation('M', <List<Point<double>>>[
|
||||
<Point<double>>[Point<double>(0.0, 0.0)],
|
||||
]),
|
||||
],
|
||||
opacities: <double>[1.0],
|
||||
)),
|
||||
expect(
|
||||
animation.paths[0],
|
||||
const PathAnimationMatcher(
|
||||
PathAnimation(
|
||||
<PathCommandAnimation>[
|
||||
PathCommandAnimation('M', <List<Point<double>>>[
|
||||
<Point<double>>[Point<double>(0.0, 0.0)],
|
||||
]),
|
||||
],
|
||||
opacities: <double>[1.0],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(animation.paths[1],
|
||||
const PathAnimationMatcher(PathAnimation(
|
||||
<PathCommandAnimation>[
|
||||
PathCommandAnimation('M', <List<Point<double>>>[
|
||||
<Point<double>>[Point<double>(5.0, 6.0)],
|
||||
]),
|
||||
],
|
||||
opacities: <double>[1.0],
|
||||
)),
|
||||
expect(
|
||||
animation.paths[1],
|
||||
const PathAnimationMatcher(
|
||||
PathAnimation(
|
||||
<PathCommandAnimation>[
|
||||
PathCommandAnimation('M', <List<Point<double>>>[
|
||||
<Point<double>>[Point<double>(5.0, 6.0)],
|
||||
]),
|
||||
],
|
||||
opacities: <double>[1.0],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(animation.size, const Point<double>(10.0, 10.0));
|
||||
@@ -373,230 +334,184 @@ void main() {
|
||||
|
||||
group('toDart', () {
|
||||
test('_PathMoveTo', () {
|
||||
const PathCommandAnimation command = PathCommandAnimation(
|
||||
'M',
|
||||
<List<Point<double>>>[
|
||||
<Point<double>>[
|
||||
Point<double>(1.0, 2.0),
|
||||
Point<double>(3.0, 4.0),
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
expect(command.toDart(),
|
||||
' const _PathMoveTo(\n'
|
||||
' const <Offset>[\n'
|
||||
' const Offset(1.0, 2.0),\n'
|
||||
' const Offset(3.0, 4.0),\n'
|
||||
' ],\n'
|
||||
' ),\n',
|
||||
const PathCommandAnimation command = PathCommandAnimation('M', <List<Point<double>>>[
|
||||
<Point<double>>[Point<double>(1.0, 2.0), Point<double>(3.0, 4.0)],
|
||||
]);
|
||||
|
||||
expect(
|
||||
command.toDart(),
|
||||
' const _PathMoveTo(\n'
|
||||
' const <Offset>[\n'
|
||||
' const Offset(1.0, 2.0),\n'
|
||||
' const Offset(3.0, 4.0),\n'
|
||||
' ],\n'
|
||||
' ),\n',
|
||||
);
|
||||
});
|
||||
|
||||
test('_PathLineTo', () {
|
||||
const PathCommandAnimation command = PathCommandAnimation(
|
||||
'L',
|
||||
<List<Point<double>>>[
|
||||
<Point<double>>[
|
||||
Point<double>(1.0, 2.0),
|
||||
Point<double>(3.0, 4.0),
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
expect(command.toDart(),
|
||||
' const _PathLineTo(\n'
|
||||
' const <Offset>[\n'
|
||||
' const Offset(1.0, 2.0),\n'
|
||||
' const Offset(3.0, 4.0),\n'
|
||||
' ],\n'
|
||||
' ),\n',
|
||||
const PathCommandAnimation command = PathCommandAnimation('L', <List<Point<double>>>[
|
||||
<Point<double>>[Point<double>(1.0, 2.0), Point<double>(3.0, 4.0)],
|
||||
]);
|
||||
|
||||
expect(
|
||||
command.toDart(),
|
||||
' const _PathLineTo(\n'
|
||||
' const <Offset>[\n'
|
||||
' const Offset(1.0, 2.0),\n'
|
||||
' const Offset(3.0, 4.0),\n'
|
||||
' ],\n'
|
||||
' ),\n',
|
||||
);
|
||||
});
|
||||
|
||||
test('_PathCubicTo', () {
|
||||
const PathCommandAnimation command = PathCommandAnimation(
|
||||
'C',
|
||||
<List<Point<double>>>[
|
||||
<Point<double>>[
|
||||
Point<double>(16.0, 24.0),
|
||||
Point<double>(16.0, 10.0),
|
||||
],
|
||||
<Point<double>>[
|
||||
Point<double>(16.0, 25.0),
|
||||
Point<double>(16.0, 11.0),
|
||||
],
|
||||
<Point<double>>[
|
||||
Point<double>(40.0, 40.0),
|
||||
Point<double>(40.0, 40.0),
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
expect(command.toDart(),
|
||||
' const _PathCubicTo(\n'
|
||||
' const <Offset>[\n'
|
||||
' const Offset(16.0, 24.0),\n'
|
||||
' const Offset(16.0, 10.0),\n'
|
||||
' ],\n'
|
||||
' const <Offset>[\n'
|
||||
' const Offset(16.0, 25.0),\n'
|
||||
' const Offset(16.0, 11.0),\n'
|
||||
' ],\n'
|
||||
' const <Offset>[\n'
|
||||
' const Offset(40.0, 40.0),\n'
|
||||
' const Offset(40.0, 40.0),\n'
|
||||
' ],\n'
|
||||
' ),\n',
|
||||
const PathCommandAnimation command = PathCommandAnimation('C', <List<Point<double>>>[
|
||||
<Point<double>>[Point<double>(16.0, 24.0), Point<double>(16.0, 10.0)],
|
||||
<Point<double>>[Point<double>(16.0, 25.0), Point<double>(16.0, 11.0)],
|
||||
<Point<double>>[Point<double>(40.0, 40.0), Point<double>(40.0, 40.0)],
|
||||
]);
|
||||
|
||||
expect(
|
||||
command.toDart(),
|
||||
' const _PathCubicTo(\n'
|
||||
' const <Offset>[\n'
|
||||
' const Offset(16.0, 24.0),\n'
|
||||
' const Offset(16.0, 10.0),\n'
|
||||
' ],\n'
|
||||
' const <Offset>[\n'
|
||||
' const Offset(16.0, 25.0),\n'
|
||||
' const Offset(16.0, 11.0),\n'
|
||||
' ],\n'
|
||||
' const <Offset>[\n'
|
||||
' const Offset(40.0, 40.0),\n'
|
||||
' const Offset(40.0, 40.0),\n'
|
||||
' ],\n'
|
||||
' ),\n',
|
||||
);
|
||||
});
|
||||
|
||||
test('_PathClose', () {
|
||||
const PathCommandAnimation command = PathCommandAnimation(
|
||||
'Z',
|
||||
<List<Point<double>>>[],
|
||||
);
|
||||
|
||||
expect(command.toDart(),
|
||||
' const _PathClose(\n'
|
||||
' ),\n',
|
||||
const PathCommandAnimation command = PathCommandAnimation('Z', <List<Point<double>>>[]);
|
||||
|
||||
expect(
|
||||
command.toDart(),
|
||||
' const _PathClose(\n'
|
||||
' ),\n',
|
||||
);
|
||||
});
|
||||
|
||||
test('Unsupported path command', () {
|
||||
const PathCommandAnimation command = PathCommandAnimation(
|
||||
'h',
|
||||
<List<Point<double>>>[],
|
||||
);
|
||||
const PathCommandAnimation command = PathCommandAnimation('h', <List<Point<double>>>[]);
|
||||
|
||||
expect(
|
||||
() { command.toDart(); },
|
||||
throwsA(anything),
|
||||
);
|
||||
expect(() {
|
||||
command.toDart();
|
||||
}, throwsA(anything));
|
||||
});
|
||||
|
||||
test('_PathFrames', () {
|
||||
const PathAnimation pathAnimation = PathAnimation(
|
||||
<PathCommandAnimation>[
|
||||
PathCommandAnimation('M', <List<Point<double>>>[
|
||||
<Point<double>>[
|
||||
Point<double>(0.0, 0.0),
|
||||
Point<double>(10.0, 10.0),
|
||||
],
|
||||
]),
|
||||
PathCommandAnimation('L', <List<Point<double>>>[
|
||||
<Point<double>>[
|
||||
Point<double>(48.0, 10.0),
|
||||
Point<double>(0.0, 0.0),
|
||||
],
|
||||
]),
|
||||
],
|
||||
opacities: <double>[0.5, 1.0],
|
||||
<PathCommandAnimation>[
|
||||
PathCommandAnimation('M', <List<Point<double>>>[
|
||||
<Point<double>>[Point<double>(0.0, 0.0), Point<double>(10.0, 10.0)],
|
||||
]),
|
||||
PathCommandAnimation('L', <List<Point<double>>>[
|
||||
<Point<double>>[Point<double>(48.0, 10.0), Point<double>(0.0, 0.0)],
|
||||
]),
|
||||
],
|
||||
opacities: <double>[0.5, 1.0],
|
||||
);
|
||||
|
||||
expect(pathAnimation.toDart(),
|
||||
' const _PathFrames(\n'
|
||||
' opacities: const <double>[\n'
|
||||
' 0.5,\n'
|
||||
' 1.0,\n'
|
||||
' ],\n'
|
||||
' commands: const <_PathCommand>[\n'
|
||||
' const _PathMoveTo(\n'
|
||||
' const <Offset>[\n'
|
||||
' const Offset(0.0, 0.0),\n'
|
||||
' const Offset(10.0, 10.0),\n'
|
||||
' ],\n'
|
||||
' ),\n'
|
||||
' const _PathLineTo(\n'
|
||||
' const <Offset>[\n'
|
||||
' const Offset(48.0, 10.0),\n'
|
||||
' const Offset(0.0, 0.0),\n'
|
||||
' ],\n'
|
||||
' ),\n'
|
||||
' ],\n'
|
||||
' ),\n',
|
||||
expect(
|
||||
pathAnimation.toDart(),
|
||||
' const _PathFrames(\n'
|
||||
' opacities: const <double>[\n'
|
||||
' 0.5,\n'
|
||||
' 1.0,\n'
|
||||
' ],\n'
|
||||
' commands: const <_PathCommand>[\n'
|
||||
' const _PathMoveTo(\n'
|
||||
' const <Offset>[\n'
|
||||
' const Offset(0.0, 0.0),\n'
|
||||
' const Offset(10.0, 10.0),\n'
|
||||
' ],\n'
|
||||
' ),\n'
|
||||
' const _PathLineTo(\n'
|
||||
' const <Offset>[\n'
|
||||
' const Offset(48.0, 10.0),\n'
|
||||
' const Offset(0.0, 0.0),\n'
|
||||
' ],\n'
|
||||
' ),\n'
|
||||
' ],\n'
|
||||
' ),\n',
|
||||
);
|
||||
});
|
||||
|
||||
test('Animation', () {
|
||||
const Animation animation = Animation(
|
||||
Point<double>(48.0, 48.0),
|
||||
<PathAnimation>[
|
||||
PathAnimation(
|
||||
<PathCommandAnimation>[
|
||||
PathCommandAnimation('M', <List<Point<double>>>[
|
||||
<Point<double>>[
|
||||
Point<double>(0.0, 0.0),
|
||||
Point<double>(10.0, 10.0),
|
||||
],
|
||||
]),
|
||||
PathCommandAnimation('L', <List<Point<double>>>[
|
||||
<Point<double>>[
|
||||
Point<double>(48.0, 10.0),
|
||||
Point<double>(0.0, 0.0),
|
||||
],
|
||||
]),
|
||||
],
|
||||
opacities: <double>[0.5, 1.0],
|
||||
),
|
||||
const Animation animation = Animation(Point<double>(48.0, 48.0), <PathAnimation>[
|
||||
PathAnimation(
|
||||
<PathCommandAnimation>[
|
||||
PathCommandAnimation('M', <List<Point<double>>>[
|
||||
<Point<double>>[Point<double>(0.0, 0.0), Point<double>(10.0, 10.0)],
|
||||
]),
|
||||
PathCommandAnimation('L', <List<Point<double>>>[
|
||||
<Point<double>>[Point<double>(48.0, 10.0), Point<double>(0.0, 0.0)],
|
||||
]),
|
||||
],
|
||||
opacities: <double>[0.5, 1.0],
|
||||
),
|
||||
|
||||
PathAnimation(
|
||||
<PathCommandAnimation>[
|
||||
PathCommandAnimation('M', <List<Point<double>>>[
|
||||
<Point<double>>[
|
||||
Point<double>(0.0, 0.0),
|
||||
Point<double>(10.0, 10.0),
|
||||
],
|
||||
]),
|
||||
],
|
||||
opacities: <double>[0.5, 1.0],
|
||||
),
|
||||
]);
|
||||
PathAnimation(
|
||||
<PathCommandAnimation>[
|
||||
PathCommandAnimation('M', <List<Point<double>>>[
|
||||
<Point<double>>[Point<double>(0.0, 0.0), Point<double>(10.0, 10.0)],
|
||||
]),
|
||||
],
|
||||
opacities: <double>[0.5, 1.0],
|
||||
),
|
||||
]);
|
||||
|
||||
expect(animation.toDart('_AnimatedIconData', r'_$data1'),
|
||||
'const _AnimatedIconData _\$data1 = const _AnimatedIconData(\n'
|
||||
' const Size(48.0, 48.0),\n'
|
||||
' const <_PathFrames>[\n'
|
||||
' const _PathFrames(\n'
|
||||
' opacities: const <double>[\n'
|
||||
' 0.5,\n'
|
||||
' 1.0,\n'
|
||||
' ],\n'
|
||||
' commands: const <_PathCommand>[\n'
|
||||
' const _PathMoveTo(\n'
|
||||
' const <Offset>[\n'
|
||||
' const Offset(0.0, 0.0),\n'
|
||||
' const Offset(10.0, 10.0),\n'
|
||||
' ],\n'
|
||||
' ),\n'
|
||||
' const _PathLineTo(\n'
|
||||
' const <Offset>[\n'
|
||||
' const Offset(48.0, 10.0),\n'
|
||||
' const Offset(0.0, 0.0),\n'
|
||||
' ],\n'
|
||||
' ),\n'
|
||||
' ],\n'
|
||||
' ),\n'
|
||||
' const _PathFrames(\n'
|
||||
' opacities: const <double>[\n'
|
||||
' 0.5,\n'
|
||||
' 1.0,\n'
|
||||
' ],\n'
|
||||
' commands: const <_PathCommand>[\n'
|
||||
' const _PathMoveTo(\n'
|
||||
' const <Offset>[\n'
|
||||
' const Offset(0.0, 0.0),\n'
|
||||
' const Offset(10.0, 10.0),\n'
|
||||
' ],\n'
|
||||
' ),\n'
|
||||
' ],\n'
|
||||
' ),\n'
|
||||
' ],\n'
|
||||
');',
|
||||
expect(
|
||||
animation.toDart('_AnimatedIconData', r'_$data1'),
|
||||
'const _AnimatedIconData _\$data1 = const _AnimatedIconData(\n'
|
||||
' const Size(48.0, 48.0),\n'
|
||||
' const <_PathFrames>[\n'
|
||||
' const _PathFrames(\n'
|
||||
' opacities: const <double>[\n'
|
||||
' 0.5,\n'
|
||||
' 1.0,\n'
|
||||
' ],\n'
|
||||
' commands: const <_PathCommand>[\n'
|
||||
' const _PathMoveTo(\n'
|
||||
' const <Offset>[\n'
|
||||
' const Offset(0.0, 0.0),\n'
|
||||
' const Offset(10.0, 10.0),\n'
|
||||
' ],\n'
|
||||
' ),\n'
|
||||
' const _PathLineTo(\n'
|
||||
' const <Offset>[\n'
|
||||
' const Offset(48.0, 10.0),\n'
|
||||
' const Offset(0.0, 0.0),\n'
|
||||
' ],\n'
|
||||
' ),\n'
|
||||
' ],\n'
|
||||
' ),\n'
|
||||
' const _PathFrames(\n'
|
||||
' opacities: const <double>[\n'
|
||||
' 0.5,\n'
|
||||
' 1.0,\n'
|
||||
' ],\n'
|
||||
' commands: const <_PathCommand>[\n'
|
||||
' const _PathMoveTo(\n'
|
||||
' const <Offset>[\n'
|
||||
' const Offset(0.0, 0.0),\n'
|
||||
' const Offset(10.0, 10.0),\n'
|
||||
' ],\n'
|
||||
' ),\n'
|
||||
' ],\n'
|
||||
' ),\n'
|
||||
' ],\n'
|
||||
');',
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -700,8 +615,8 @@ class PathAnimationMatcher extends Matcher {
|
||||
for (int i = 0; i < other.points.length; i += 1) {
|
||||
if (!const ListEquality<Point<double>>().equals(other.points[i], expected.points[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user