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
b83749ca
Unverified
Commit
b83749ca
authored
Jun 01, 2018
by
Ian Hickson
Committed by
GitHub
Jun 01, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Golden file tests for clip (#18056)
Also, fixes "flutter run" for golden tests, and some docs.
parent
72c459bc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
289 additions
and
16 deletions
+289
-16
goldens.version
bin/internal/goldens.version
+1
-1
proxy_box.dart
packages/flutter/lib/src/rendering/proxy_box.dart
+4
-4
clip_test.dart
packages/flutter/test/widgets/clip_test.dart
+271
-0
goldens.dart
packages/flutter_test/lib/src/goldens.dart
+13
-11
No files found.
bin/internal/goldens.version
View file @
b83749ca
298b585e6eb2bf51b12cd0ea9261a1b7a83c9a29
95f60c7e328b53dd65de18a608830a872a92e3cd
packages/flutter/lib/src/rendering/proxy_box.dart
View file @
b83749ca
...
...
@@ -1004,10 +1004,10 @@ class RenderBackdropFilter extends RenderProxyBox {
///
/// See also:
///
/// * [ClipRect], which can be customized with a [CustomClipper].
/// * [ClipRRect], which can be customized with a [CustomClipper].
/// * [ClipOval], which can be customized with a [CustomClipper].
/// * [ClipPath], which can be customized with a [CustomClipper].
/// * [ClipRect], which can be customized with a [CustomClipper
<Rect>
].
/// * [ClipRRect], which can be customized with a [CustomClipper
<RRect>
].
/// * [ClipOval], which can be customized with a [CustomClipper
<Rect>
].
/// * [ClipPath], which can be customized with a [CustomClipper
<Path>
].
abstract
class
CustomClipper
<
T
>
{
/// Creates a custom clipper.
///
...
...
packages/flutter/test/widgets/clip_test.dart
View file @
b83749ca
...
...
@@ -247,4 +247,275 @@ void main() {
);
debugPaintSizeEnabled
=
false
;
});
testWidgets
(
'ClipRect painting'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
new
Center
(
child:
new
RepaintBoundary
(
child:
new
Container
(
color:
Colors
.
white
,
child:
new
Padding
(
padding:
const
EdgeInsets
.
all
(
100.0
),
child:
new
SizedBox
(
height:
100.0
,
width:
100.0
,
child:
new
Transform
.
rotate
(
angle:
1.0
,
// radians
child:
new
ClipRect
(
child:
new
Container
(
color:
Colors
.
red
,
child:
new
Container
(
color:
Colors
.
white
,
child:
new
RepaintBoundary
(
child:
new
Center
(
child:
new
Container
(
color:
Colors
.
black
,
height:
10.0
,
width:
10.0
,
),
),
),
),
),
),
),
),
),
),
),
),
);
await
expectLater
(
find
.
byType
(
RepaintBoundary
).
first
,
matchesGoldenFile
(
'clip.ClipRect.1.png'
),
);
});
testWidgets
(
'ClipRRect painting'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
new
Center
(
child:
new
RepaintBoundary
(
child:
new
Container
(
color:
Colors
.
white
,
child:
new
Padding
(
padding:
const
EdgeInsets
.
all
(
100.0
),
child:
new
SizedBox
(
height:
100.0
,
width:
100.0
,
child:
new
Transform
.
rotate
(
angle:
1.0
,
// radians
child:
new
ClipRRect
(
borderRadius:
const
BorderRadius
.
only
(
topLeft:
const
Radius
.
elliptical
(
10.0
,
20.0
),
topRight:
const
Radius
.
elliptical
(
5.0
,
30.0
),
bottomLeft:
const
Radius
.
elliptical
(
2.5
,
12.0
),
bottomRight:
const
Radius
.
elliptical
(
15.0
,
6.0
),
),
child:
new
Container
(
color:
Colors
.
red
,
child:
new
Container
(
color:
Colors
.
white
,
child:
new
RepaintBoundary
(
child:
new
Center
(
child:
new
Container
(
color:
Colors
.
black
,
height:
10.0
,
width:
10.0
,
),
),
),
),
),
),
),
),
),
),
),
),
);
await
expectLater
(
find
.
byType
(
RepaintBoundary
).
first
,
matchesGoldenFile
(
'clip.ClipRRect.1.png'
),
);
});
testWidgets
(
'ClipOval painting'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
new
Center
(
child:
new
RepaintBoundary
(
child:
new
Container
(
color:
Colors
.
white
,
child:
new
Padding
(
padding:
const
EdgeInsets
.
all
(
100.0
),
child:
new
SizedBox
(
height:
100.0
,
width:
100.0
,
child:
new
Transform
.
rotate
(
angle:
1.0
,
// radians
child:
new
ClipOval
(
child:
new
Container
(
color:
Colors
.
red
,
child:
new
Container
(
color:
Colors
.
white
,
child:
new
RepaintBoundary
(
child:
new
Center
(
child:
new
Container
(
color:
Colors
.
black
,
height:
10.0
,
width:
10.0
,
),
),
),
),
),
),
),
),
),
),
),
),
);
await
expectLater
(
find
.
byType
(
RepaintBoundary
).
first
,
matchesGoldenFile
(
'clip.ClipOval.1.png'
),
);
});
testWidgets
(
'ClipPath painting'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
new
Center
(
child:
new
RepaintBoundary
(
child:
new
Container
(
color:
Colors
.
white
,
child:
new
Padding
(
padding:
const
EdgeInsets
.
all
(
100.0
),
child:
new
SizedBox
(
height:
100.0
,
width:
100.0
,
child:
new
Transform
.
rotate
(
angle:
1.0
,
// radians
child:
new
ClipPath
(
clipper:
new
ShapeBorderClipper
(
shape:
new
BeveledRectangleBorder
(
borderRadius:
new
BorderRadius
.
circular
(
20.0
),
),
),
child:
new
Container
(
color:
Colors
.
red
,
child:
new
Container
(
color:
Colors
.
white
,
child:
new
RepaintBoundary
(
child:
new
Center
(
child:
new
Container
(
color:
Colors
.
black
,
height:
10.0
,
width:
10.0
,
),
),
),
),
),
),
),
),
),
),
),
),
);
await
expectLater
(
find
.
byType
(
RepaintBoundary
).
first
,
matchesGoldenFile
(
'clip.ClipPath.1.png'
),
);
});
testWidgets
(
'PhysicalModel painting'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
new
Center
(
child:
new
RepaintBoundary
(
child:
new
Container
(
color:
Colors
.
white
,
child:
new
Padding
(
padding:
const
EdgeInsets
.
all
(
100.0
),
child:
new
SizedBox
(
height:
100.0
,
width:
100.0
,
child:
new
Transform
.
rotate
(
angle:
1.0
,
// radians
child:
new
PhysicalModel
(
borderRadius:
new
BorderRadius
.
circular
(
20.0
),
color:
Colors
.
red
,
child:
new
Container
(
color:
Colors
.
white
,
child:
new
RepaintBoundary
(
child:
new
Center
(
child:
new
Container
(
color:
Colors
.
black
,
height:
10.0
,
width:
10.0
,
),
),
),
),
),
),
),
),
),
),
),
);
await
expectLater
(
find
.
byType
(
RepaintBoundary
).
first
,
matchesGoldenFile
(
'clip.PhysicalModel.1.png'
),
);
});
testWidgets
(
'PhysicalShape painting'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
new
Center
(
child:
new
RepaintBoundary
(
child:
new
Container
(
color:
Colors
.
white
,
child:
new
Padding
(
padding:
const
EdgeInsets
.
all
(
100.0
),
child:
new
SizedBox
(
height:
100.0
,
width:
100.0
,
child:
new
Transform
.
rotate
(
angle:
1.0
,
// radians
child:
new
PhysicalShape
(
clipper:
new
ShapeBorderClipper
(
shape:
new
BeveledRectangleBorder
(
borderRadius:
new
BorderRadius
.
circular
(
20.0
),
),
),
color:
Colors
.
red
,
child:
new
Container
(
color:
Colors
.
white
,
child:
new
RepaintBoundary
(
child:
new
Center
(
child:
new
Container
(
color:
Colors
.
black
,
height:
10.0
,
width:
10.0
,
),
),
),
),
),
),
),
),
),
),
),
);
await
expectLater
(
find
.
byType
(
RepaintBoundary
).
first
,
matchesGoldenFile
(
'clip.PhysicalShape.1.png'
),
);
});
}
packages/flutter_test/lib/src/goldens.dart
View file @
b83749ca
...
...
@@ -60,9 +60,9 @@ abstract class GoldenFileComparator {
/// When using `flutter test --update-goldens`, the [LocalFileComparator]
/// updates the files on disk to match the rendering.
///
/// When using `flutter run`, the default comparator (
null) is used. It prints
///
a message to the console but otherwise does nothing. This allows tests to
/// be developed visually on a real device.
/// When using `flutter run`, the default comparator (
[TrivialComparator])
///
is used. It prints a message to the console but otherwise does nothing. This
///
allows tests to
be developed visually on a real device.
///
/// Callers may choose to override the default comparator by setting this to a
/// custom comparator during test set-up (or using directory-level test
...
...
@@ -75,12 +75,11 @@ abstract class GoldenFileComparator {
///
/// * [flutter_test] for more information about how to configure tests at the
/// directory-level.
GoldenFileComparator
get
goldenFileComparator
{
return
_goldenFileComparator
==
const
_UninitializedComparator
()
?
null
:
_goldenFileComparator
;
}
GoldenFileComparator
_goldenFileComparator
=
const
_UninitializedComparator
();
set
goldenFileComparator
(
GoldenFileComparator
comparator
)
{
_goldenFileComparator
=
comparator
??
const
_UninitializedComparator
();
GoldenFileComparator
get
goldenFileComparator
=>
_goldenFileComparator
;
GoldenFileComparator
_goldenFileComparator
=
const
TrivialComparator
.
_
();
set
goldenFileComparator
(
GoldenFileComparator
value
)
{
assert
(
value
!=
null
);
_goldenFileComparator
=
value
;
}
/// Whether golden files should be automatically updated during tests rather
...
...
@@ -111,8 +110,11 @@ bool autoUpdateGoldenFiles = false;
/// via `flutter run`. In this case, the [compare] method will just print a
/// message that it would have otherwise run a real comparison, and it will
/// return trivial success.
class
_UninitializedComparator
implements
GoldenFileComparator
{
const
_UninitializedComparator
();
///
/// This class can't be constructed. It represents the default value of
/// [goldenFileComparator].
class
TrivialComparator
implements
GoldenFileComparator
{
const
TrivialComparator
.
_
();
@override
Future
<
bool
>
compare
(
Uint8List
imageBytes
,
Uri
golden
)
{
...
...
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