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
@@ -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