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
7c942e39
Unverified
Commit
7c942e39
authored
Jul 28, 2020
by
Yuqian Li
Committed by
GitHub
Jul 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test for 3D transform with needsCompositing (#61779)
parent
59e0a2ec
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
transform_test.dart
packages/flutter/test/widgets/transform_test.dart
+42
-0
No files found.
packages/flutter/test/widgets/transform_test.dart
View file @
7c942e39
...
...
@@ -5,6 +5,7 @@
// @dart = 2.8
import
'dart:math'
as
math
;
import
'dart:ui'
as
ui
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -360,4 +361,45 @@ void main() {
await
tester
.
tap
(
find
.
byKey
(
key1
));
expect
(
_pointerDown
,
isTrue
);
});
Widget
_generateTransform
(
bool
needsCompositing
,
double
angle
)
{
final
Widget
customPaint
=
CustomPaint
(
painter:
TestRectPainter
());
return
Transform
(
transform:
MatrixUtils
.
createCylindricalProjectionTransform
(
radius:
100
,
angle:
angle
,
perspective:
0.003
,
),
// A RepaintBoundary child forces the Transform to needsCompositing
child:
needsCompositing
?
RepaintBoundary
(
child:
customPaint
)
:
customPaint
,
);
}
testWidgets
(
'3D transform renders the same with or without needsCompositing'
,
(
WidgetTester
tester
)
async
{
for
(
double
angle
=
0
;
angle
<=
math
.
pi
/
4
;
angle
+=
0.01
)
{
await
tester
.
pumpWidget
(
RepaintBoundary
(
child:
_generateTransform
(
true
,
angle
)));
final
RenderBox
renderBox
=
tester
.
binding
.
renderView
.
child
;
final
OffsetLayer
layer
=
renderBox
.
debugLayer
as
OffsetLayer
;
final
ui
.
Image
imageWithCompositing
=
await
layer
.
toImage
(
renderBox
.
paintBounds
);
await
tester
.
pumpWidget
(
RepaintBoundary
(
child:
_generateTransform
(
false
,
angle
)));
await
expectLater
(
find
.
byType
(
RepaintBoundary
).
first
,
matchesReferenceImage
(
imageWithCompositing
));
}
},
skip:
isBrowser
,
// due to https://github.com/flutter/flutter/issues/42767
);
}
class
TestRectPainter
extends
CustomPainter
{
@override
void
paint
(
ui
.
Canvas
canvas
,
ui
.
Size
size
)
{
canvas
.
drawRect
(
const
Offset
(
200
,
200
)
&
const
Size
(
10
,
10
),
Paint
()..
color
=
const
Color
(
0xFFFF0000
),
);
}
@override
bool
shouldRepaint
(
CustomPainter
oldDelegate
)
=>
true
;
}
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