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
63cfe1e3
Commit
63cfe1e3
authored
May 16, 2017
by
Ian Hickson
Committed by
GitHub
May 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add strokeWidth to the paints matcher (#10121)
parent
765e5d5b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
26 deletions
+41
-26
mock_canvas.dart
packages/flutter/test/rendering/mock_canvas.dart
+33
-25
placeholder_test.dart
packages/flutter/test/widgets/placeholder_test.dart
+8
-1
No files found.
packages/flutter/test/rendering/mock_canvas.dart
View file @
63cfe1e3
...
...
@@ -133,7 +133,7 @@ abstract class PaintPattern {
///
/// Any calls made between the last matched call (if any) and the
/// [Canvas.drawRect] call are ignored.
void
rect
({
Rect
rect
,
Color
color
});
void
rect
({
Rect
rect
,
Color
color
,
double
strokeWidth
,
bool
hasMaskFilter
,
PaintingStyle
style
});
/// Indicates that a rounded rectangle clip is expected next.
///
...
...
@@ -157,7 +157,7 @@ abstract class PaintPattern {
///
/// Any calls made between the last matched call (if any) and the
/// [Canvas.drawRRect] call are ignored.
void
rrect
({
RRect
rrect
,
Color
color
,
bool
hasMaskFilter
,
PaintingStyle
style
});
void
rrect
({
RRect
rrect
,
Color
color
,
double
strokeWidth
,
bool
hasMaskFilter
,
PaintingStyle
style
});
/// Indicates that a circle is expected next.
///
...
...
@@ -169,7 +169,7 @@ abstract class PaintPattern {
///
/// Any calls made between the last matched call (if any) and the
/// [Canvas.drawCircle] call are ignored.
void
circle
({
double
x
,
double
y
,
double
radius
,
Color
color
,
bool
hasMaskFilter
,
PaintingStyle
style
});
void
circle
({
double
x
,
double
y
,
double
radius
,
Color
color
,
double
strokeWidth
,
bool
hasMaskFilter
,
PaintingStyle
style
});
/// Indicates that a path is expected next.
///
...
...
@@ -184,7 +184,7 @@ abstract class PaintPattern {
///
/// Any calls made between the last matched call (if any) and the
/// [Canvas.drawPath] call are ignored.
void
path
({
Color
color
,
bool
hasMaskFilter
,
PaintingStyle
style
});
void
path
({
Color
color
,
double
strokeWidth
,
bool
hasMaskFilter
,
PaintingStyle
style
});
/// Indicates that a line is expected next.
///
...
...
@@ -196,7 +196,7 @@ abstract class PaintPattern {
///
/// Any calls made between the last matched call (if any) and the
/// [Canvas.drawLine] call are ignored.
void
line
({
Color
color
,
bool
hasMaskFilter
,
PaintingStyle
style
});
void
line
({
Color
color
,
double
strokeWidth
,
bool
hasMaskFilter
,
PaintingStyle
style
});
/// Indicates that a paragraph is expected next.
///
...
...
@@ -270,8 +270,8 @@ class _TestRecordingCanvasPatternMatcher extends Matcher implements PaintPattern
}
@override
void
rect
({
Rect
rect
,
Color
color
,
bool
hasMaskFilter
,
PaintingStyle
style
})
{
_predicates
.
add
(
new
_RectPaintPredicate
(
rect:
rect
,
color:
color
,
hasMaskFilter:
hasMaskFilter
,
style:
style
));
void
rect
({
Rect
rect
,
Color
color
,
double
strokeWidth
,
bool
hasMaskFilter
,
PaintingStyle
style
})
{
_predicates
.
add
(
new
_RectPaintPredicate
(
rect:
rect
,
color:
color
,
strokeWidth:
strokeWidth
,
hasMaskFilter:
hasMaskFilter
,
style:
style
));
}
@override
...
...
@@ -280,23 +280,23 @@ class _TestRecordingCanvasPatternMatcher extends Matcher implements PaintPattern
}
@override
void
rrect
({
RRect
rrect
,
Color
color
,
bool
hasMaskFilter
,
PaintingStyle
style
})
{
_predicates
.
add
(
new
_RRectPaintPredicate
(
rrect:
rrect
,
color:
color
,
hasMaskFilter:
hasMaskFilter
,
style:
style
));
void
rrect
({
RRect
rrect
,
Color
color
,
double
strokeWidth
,
bool
hasMaskFilter
,
PaintingStyle
style
})
{
_predicates
.
add
(
new
_RRectPaintPredicate
(
rrect:
rrect
,
color:
color
,
strokeWidth:
strokeWidth
,
hasMaskFilter:
hasMaskFilter
,
style:
style
));
}
@override
void
circle
({
double
x
,
double
y
,
double
radius
,
Color
color
,
bool
hasMaskFilter
,
PaintingStyle
style
})
{
_predicates
.
add
(
new
_CirclePaintPredicate
(
x:
x
,
y:
y
,
radius:
radius
,
color:
color
,
hasMaskFilter:
hasMaskFilter
,
style:
style
));
void
circle
({
double
x
,
double
y
,
double
radius
,
Color
color
,
double
strokeWidth
,
bool
hasMaskFilter
,
PaintingStyle
style
})
{
_predicates
.
add
(
new
_CirclePaintPredicate
(
x:
x
,
y:
y
,
radius:
radius
,
color:
color
,
strokeWidth:
strokeWidth
,
hasMaskFilter:
hasMaskFilter
,
style:
style
));
}
@override
void
path
({
Color
color
,
bool
hasMaskFilter
,
PaintingStyle
style
})
{
_predicates
.
add
(
new
_PathPaintPredicate
(
color:
color
,
hasMaskFilter:
hasMaskFilter
,
style:
style
));
void
path
({
Color
color
,
double
strokeWidth
,
bool
hasMaskFilter
,
PaintingStyle
style
})
{
_predicates
.
add
(
new
_PathPaintPredicate
(
color:
color
,
strokeWidth:
strokeWidth
,
hasMaskFilter:
hasMaskFilter
,
style:
style
));
}
@override
void
line
({
Color
color
,
bool
hasMaskFilter
,
PaintingStyle
style
})
{
_predicates
.
add
(
new
_LinePaintPredicate
(
color:
color
,
hasMaskFilter:
hasMaskFilter
,
style:
style
));
void
line
({
Color
color
,
double
strokeWidth
,
bool
hasMaskFilter
,
PaintingStyle
style
})
{
_predicates
.
add
(
new
_LinePaintPredicate
(
color:
color
,
strokeWidth:
strokeWidth
,
hasMaskFilter:
hasMaskFilter
,
style:
style
));
}
@override
...
...
@@ -413,7 +413,7 @@ abstract class _PaintPredicate {
abstract
class
_DrawCommandPaintPredicate
extends
_PaintPredicate
{
_DrawCommandPaintPredicate
(
this
.
symbol
,
this
.
name
,
this
.
argumentCount
,
this
.
paintArgumentIndex
,
{
this
.
color
,
this
.
hasMaskFilter
,
this
.
style
}
{
this
.
color
,
this
.
strokeWidth
,
this
.
hasMaskFilter
,
this
.
style
}
);
final
Symbol
symbol
;
...
...
@@ -421,6 +421,7 @@ abstract class _DrawCommandPaintPredicate extends _PaintPredicate {
final
int
argumentCount
;
final
int
paintArgumentIndex
;
final
Color
color
;
final
double
strokeWidth
;
final
bool
hasMaskFilter
;
final
PaintingStyle
style
;
...
...
@@ -450,6 +451,8 @@ abstract class _DrawCommandPaintPredicate extends _PaintPredicate {
final
Paint
paintArgument
=
arguments
[
paintArgumentIndex
];
if
(
color
!=
null
&&
paintArgument
.
color
!=
color
)
throw
'called
$methodName
with a paint whose color,
${paintArgument.color}
, was not exactly the expected color (
$color
).'
;
if
(
strokeWidth
!=
null
&&
paintArgument
.
strokeWidth
!=
strokeWidth
)
throw
'called
$methodName
with a paint whose strokeWidth,
${paintArgument.strokeWidth}
, was not exactly the expected strokeWidth (
$strokeWidth
).'
;
if
(
hasMaskFilter
!=
null
&&
(
paintArgument
.
maskFilter
!=
null
)
!=
hasMaskFilter
)
{
if
(
hasMaskFilter
)
throw
'called
$methodName
with a paint that did not have a mask filter, despite expecting one.'
;
...
...
@@ -475,6 +478,8 @@ abstract class _DrawCommandPaintPredicate extends _PaintPredicate {
void
debugFillDescription
(
List
<
String
>
description
)
{
if
(
color
!=
null
)
description
.
add
(
'
$color
'
);
if
(
strokeWidth
!=
null
)
description
.
add
(
'strokeWidth:
$strokeWidth
'
);
if
(
hasMaskFilter
!=
null
)
description
.
add
(
hasMaskFilter
?
'a mask filter'
:
'no mask filter'
);
if
(
style
!=
null
)
...
...
@@ -486,10 +491,11 @@ class _OneParameterPaintPredicate<T> extends _DrawCommandPaintPredicate {
_OneParameterPaintPredicate
(
Symbol
symbol
,
String
name
,
{
@required
this
.
expected
,
@required
Color
color
,
@required
double
strokeWidth
,
@required
bool
hasMaskFilter
,
@required
PaintingStyle
style
})
:
super
(
symbol
,
name
,
2
,
1
,
color:
color
,
hasMaskFilter:
hasMaskFilter
,
style:
style
);
symbol
,
name
,
2
,
1
,
color:
color
,
strokeWidth:
strokeWidth
,
hasMaskFilter:
hasMaskFilter
,
style:
style
);
final
T
expected
;
...
...
@@ -516,30 +522,32 @@ class _OneParameterPaintPredicate<T> extends _DrawCommandPaintPredicate {
class
_RectPaintPredicate
extends
_OneParameterPaintPredicate
<
Rect
>
{
_RectPaintPredicate
({
Rect
rect
,
Color
color
,
bool
hasMaskFilter
,
PaintingStyle
style
})
:
super
(
_RectPaintPredicate
({
Rect
rect
,
Color
color
,
double
strokeWidth
,
bool
hasMaskFilter
,
PaintingStyle
style
})
:
super
(
#drawRect
,
'a rectangle'
,
expected:
rect
,
color:
color
,
strokeWidth:
strokeWidth
,
hasMaskFilter:
hasMaskFilter
,
style:
style
,
);
}
class
_RRectPaintPredicate
extends
_OneParameterPaintPredicate
<
RRect
>
{
_RRectPaintPredicate
({
RRect
rrect
,
Color
color
,
bool
hasMaskFilter
,
PaintingStyle
style
})
:
super
(
_RRectPaintPredicate
({
RRect
rrect
,
Color
color
,
double
strokeWidth
,
bool
hasMaskFilter
,
PaintingStyle
style
})
:
super
(
#drawRRect
,
'a rounded rectangle'
,
expected:
rrect
,
color:
color
,
strokeWidth:
strokeWidth
,
hasMaskFilter:
hasMaskFilter
,
style:
style
,
);
}
class
_CirclePaintPredicate
extends
_DrawCommandPaintPredicate
{
_CirclePaintPredicate
({
this
.
x
,
this
.
y
,
this
.
radius
,
Color
color
,
bool
hasMaskFilter
,
PaintingStyle
style
})
:
super
(
#drawCircle
,
'a circle'
,
3
,
2
,
color:
color
,
hasMaskFilter:
hasMaskFilter
,
style:
style
_CirclePaintPredicate
({
this
.
x
,
this
.
y
,
this
.
radius
,
Color
color
,
double
strokeWidth
,
bool
hasMaskFilter
,
PaintingStyle
style
})
:
super
(
#drawCircle
,
'a circle'
,
3
,
2
,
color:
color
,
strokeWidth:
strokeWidth
,
hasMaskFilter:
hasMaskFilter
,
style:
style
);
final
double
x
;
...
...
@@ -582,15 +590,15 @@ class _CirclePaintPredicate extends _DrawCommandPaintPredicate {
}
class
_PathPaintPredicate
extends
_DrawCommandPaintPredicate
{
_PathPaintPredicate
({
Color
color
,
bool
hasMaskFilter
,
PaintingStyle
style
})
:
super
(
#drawPath
,
'a path'
,
2
,
1
,
color:
color
,
hasMaskFilter:
hasMaskFilter
,
style:
style
_PathPaintPredicate
({
Color
color
,
double
strokeWidth
,
bool
hasMaskFilter
,
PaintingStyle
style
})
:
super
(
#drawPath
,
'a path'
,
2
,
1
,
color:
color
,
strokeWidth:
strokeWidth
,
hasMaskFilter:
hasMaskFilter
,
style:
style
);
}
// TODO(ianh): add arguments to test the points, length, angle, that kind of thing
class
_LinePaintPredicate
extends
_DrawCommandPaintPredicate
{
_LinePaintPredicate
({
Color
color
,
bool
hasMaskFilter
,
PaintingStyle
style
})
:
super
(
#drawLine
,
'a line'
,
3
,
2
,
color:
color
,
hasMaskFilter:
hasMaskFilter
,
style:
style
_LinePaintPredicate
({
Color
color
,
double
strokeWidth
,
bool
hasMaskFilter
,
PaintingStyle
style
})
:
super
(
#drawLine
,
'a line'
,
3
,
2
,
color:
color
,
strokeWidth:
strokeWidth
,
hasMaskFilter:
hasMaskFilter
,
style:
style
);
}
...
...
packages/flutter/test/widgets/placeholder_test.dart
View file @
63cfe1e3
...
...
@@ -23,8 +23,15 @@ void main() {
testWidgets
(
'Placeholder color'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
Placeholder
());
expect
(
tester
.
renderObject
(
find
.
byType
(
Placeholder
)),
paints
..
path
());
expect
(
tester
.
renderObject
(
find
.
byType
(
Placeholder
)),
paints
..
path
(
color:
const
Color
(
0xFF455A64
)
));
await
tester
.
pumpWidget
(
const
Placeholder
(
color:
const
Color
(
0xFF00FF00
)));
expect
(
tester
.
renderObject
(
find
.
byType
(
Placeholder
)),
paints
..
path
(
color:
const
Color
(
0xFF00FF00
)));
});
testWidgets
(
'Placeholder stroke width'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
Placeholder
());
expect
(
tester
.
renderObject
(
find
.
byType
(
Placeholder
)),
paints
..
path
(
strokeWidth:
2.0
));
await
tester
.
pumpWidget
(
const
Placeholder
(
strokeWidth:
10.0
));
expect
(
tester
.
renderObject
(
find
.
byType
(
Placeholder
)),
paints
..
path
(
strokeWidth:
10.0
));
});
}
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