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
c86517c0
Commit
c86517c0
authored
Jan 07, 2020
by
wise86-android
Committed by
Flutter GitHub Bot
Jan 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[issue 7293] add test for rettangle box decoration with boarder radius (#47915)
parent
866fa64d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
215 additions
and
1 deletion
+215
-1
box_decoration_test.dart
packages/flutter/test/widgets/box_decoration_test.dart
+215
-1
No files found.
packages/flutter/test/widgets/box_decoration_test.dart
View file @
c86517c0
...
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:math'
as
math
;
import
'dart:typed_data'
;
import
'dart:ui'
as
ui
show
Image
;
...
...
@@ -342,4 +343,217 @@ Future<void> main() async {
});
}
testWidgets
(
'Can hit test on BoxDecoration border'
,
(
WidgetTester
tester
)
async
{
List
<
int
>
itemsTapped
;
const
Key
key
=
Key
(
'Container with BoxDecoration'
);
Widget
buildFrame
(
Border
border
)
{
itemsTapped
=
<
int
>[];
return
Center
(
child:
GestureDetector
(
behavior:
HitTestBehavior
.
deferToChild
,
child:
Container
(
key:
key
,
width:
100.0
,
height:
50.0
,
decoration:
BoxDecoration
(
border:
border
,
shape:
BoxShape
.
rectangle
,
borderRadius:
BorderRadius
.
circular
(
20.0
)),
),
onTap:
()
{
itemsTapped
.
add
(
1
);
},
),
);
}
await
tester
.
pumpWidget
(
buildFrame
(
Border
.
all
()));
expect
(
itemsTapped
,
isEmpty
);
await
tester
.
tapAt
(
const
Offset
(
0.0
,
0.0
));
expect
(
itemsTapped
,
isEmpty
);
await
tester
.
tapAt
(
const
Offset
(
350.0
,
275.0
));
expect
(
itemsTapped
,
isEmpty
);
await
tester
.
tapAt
(
const
Offset
(
400.0
,
300.0
));
expect
(
itemsTapped
,
<
int
>[
1
]);
await
tester
.
tap
(
find
.
byKey
(
key
));
expect
(
itemsTapped
,
<
int
>[
1
,
1
]);
});
testWidgets
(
'BoxDecoration not tap outside rounded angles - Top Left'
,
(
WidgetTester
tester
)
async
{
const
double
height
=
50.0
;
const
double
width
=
50.0
;
const
double
radius
=
12.3
;
List
<
int
>
itemsTapped
;
const
Key
key
=
Key
(
'Container with BoxDecoration'
);
Widget
buildFrame
(
Border
border
)
{
itemsTapped
=
<
int
>[];
return
Align
(
alignment:
Alignment
.
topLeft
,
child:
GestureDetector
(
behavior:
HitTestBehavior
.
deferToChild
,
child:
Container
(
key:
key
,
width:
width
,
height:
height
,
decoration:
BoxDecoration
(
border:
border
,
shape:
BoxShape
.
rectangle
,
borderRadius:
BorderRadius
.
circular
(
radius
))
),
onTap:
()
{
itemsTapped
.
add
(
1
);
},
)
);
}
await
tester
.
pumpWidget
(
buildFrame
(
Border
.
all
()));
expect
(
itemsTapped
,
isEmpty
);
// x, y
const
Offset
topLeft
=
Offset
(
0.0
,
0.0
);
const
Offset
borderTopTangent
=
Offset
(
radius
-
1
,
0.0
);
const
Offset
borderLeftTangent
=
Offset
(
0.0
,
radius
-
1
);
//the borderDiagonalOffset is the backslash line
//\\######@@@
//#\\###@####
//##\\@######
//##@########
//@##########
//@##########
const
double
borderDiagonalOffset
=
radius
-
radius
*
math
.
sqrt1_2
;
const
Offset
fartherBorderRadiusPoint
=
Offset
(
borderDiagonalOffset
,
borderDiagonalOffset
);
await
tester
.
tapAt
(
topLeft
);
expect
(
itemsTapped
,
isEmpty
,
reason:
'top left tapped'
);
await
tester
.
tapAt
(
borderTopTangent
);
expect
(
itemsTapped
,
isEmpty
,
reason:
'border top tapped'
);
await
tester
.
tapAt
(
borderLeftTangent
);
expect
(
itemsTapped
,
isEmpty
,
reason:
'border left tapped'
);
await
tester
.
tapAt
(
fartherBorderRadiusPoint
);
expect
(
itemsTapped
,
isEmpty
,
reason:
'border center tapped'
);
await
tester
.
tap
(
find
.
byKey
(
key
));
expect
(
itemsTapped
,
<
int
>[
1
]);
});
testWidgets
(
'BoxDecoration tap inside rounded angles - Top Left'
,
(
WidgetTester
tester
)
async
{
const
double
height
=
50.0
;
const
double
width
=
50.0
;
const
double
radius
=
12.3
;
List
<
int
>
itemsTapped
;
const
Key
key
=
Key
(
'Container with BoxDecoration'
);
Widget
buildFrame
(
Border
border
)
{
itemsTapped
=
<
int
>[];
return
Align
(
alignment:
Alignment
.
topLeft
,
child:
GestureDetector
(
behavior:
HitTestBehavior
.
deferToChild
,
child:
Container
(
key:
key
,
width:
width
,
height:
height
,
decoration:
BoxDecoration
(
border:
border
,
shape:
BoxShape
.
rectangle
,
borderRadius:
BorderRadius
.
circular
(
radius
))
),
onTap:
()
{
itemsTapped
.
add
(
1
);
},
)
);
}
await
tester
.
pumpWidget
(
buildFrame
(
Border
.
all
()));
expect
(
itemsTapped
,
isEmpty
);
// x, y
const
Offset
borderTopTangent
=
Offset
(
radius
,
0.0
);
const
Offset
borderLeftTangent
=
Offset
(
0.0
,
radius
);
const
double
borderDiagonalOffset
=
radius
-
radius
*
math
.
sqrt1_2
;
const
Offset
fartherBorderRadiusPoint
=
Offset
(
borderDiagonalOffset
+
1
,
borderDiagonalOffset
+
1
);
await
tester
.
tapAt
(
borderTopTangent
);
expect
(
itemsTapped
,
<
int
>[
1
],
reason:
'border Top not tapped'
);
await
tester
.
tapAt
(
borderLeftTangent
);
expect
(
itemsTapped
,
<
int
>[
1
,
1
],
reason:
'border Left not tapped'
);
await
tester
.
tapAt
(
fartherBorderRadiusPoint
);
expect
(
itemsTapped
,
<
int
>[
1
,
1
,
1
],
reason:
'border center not tapped'
);
await
tester
.
tap
(
find
.
byKey
(
key
));
expect
(
itemsTapped
,
<
int
>[
1
,
1
,
1
,
1
]);
});
testWidgets
(
'BoxDecoration rounded angles other corner works'
,
(
WidgetTester
tester
)
async
{
const
double
height
=
50.0
;
const
double
width
=
50.0
;
const
double
radius
=
20
;
List
<
int
>
itemsTapped
;
const
Key
key
=
Key
(
'Container with BoxDecoration'
);
Widget
buildFrame
(
Border
border
)
{
itemsTapped
=
<
int
>[];
return
Align
(
alignment:
Alignment
.
topLeft
,
child:
GestureDetector
(
behavior:
HitTestBehavior
.
deferToChild
,
child:
Container
(
key:
key
,
width:
width
,
height:
height
,
decoration:
BoxDecoration
(
border:
border
,
shape:
BoxShape
.
rectangle
,
borderRadius:
BorderRadius
.
circular
(
radius
))
),
onTap:
()
{
itemsTapped
.
add
(
1
);
},
)
);
}
await
tester
.
pumpWidget
(
buildFrame
(
Border
.
all
()));
expect
(
itemsTapped
,
isEmpty
);
await
tester
.
tap
(
find
.
byKey
(
key
));
expect
(
itemsTapped
,
<
int
>[
1
]);
// x, y
const
Offset
topRightOutside
=
Offset
(
width
,
0.0
);
const
Offset
topRightInside
=
Offset
(
width
-
radius
,
radius
);
const
Offset
bottomRightOutside
=
Offset
(
width
,
height
);
const
Offset
bottomRightInside
=
Offset
(
width
-
radius
,
height
-
radius
);
const
Offset
bottomLeftOutside
=
Offset
(
0
,
height
);
const
Offset
bottomLeftInside
=
Offset
(
radius
,
height
-
radius
);
const
Offset
topLeftOutside
=
Offset
(
0
,
0
);
const
Offset
topLeftInside
=
Offset
(
radius
,
radius
);
await
tester
.
tapAt
(
topRightInside
);
expect
(
itemsTapped
,
<
int
>[
1
,
1
],
reason:
'top right not tapped'
);
await
tester
.
tapAt
(
topRightOutside
);
expect
(
itemsTapped
,
<
int
>[
1
,
1
],
reason:
'top right tapped'
);
await
tester
.
tapAt
(
bottomRightInside
);
expect
(
itemsTapped
,
<
int
>[
1
,
1
,
1
],
reason:
'bottom right not tapped'
);
await
tester
.
tapAt
(
bottomRightOutside
);
expect
(
itemsTapped
,
<
int
>[
1
,
1
,
1
],
reason:
'bottom right tapped'
);
await
tester
.
tapAt
(
bottomLeftInside
);
expect
(
itemsTapped
,
<
int
>[
1
,
1
,
1
,
1
],
reason:
'bottom left not tapped'
);
await
tester
.
tapAt
(
bottomLeftOutside
);
expect
(
itemsTapped
,
<
int
>[
1
,
1
,
1
,
1
],
reason:
'bottom left tapped'
);
await
tester
.
tapAt
(
topLeftInside
);
expect
(
itemsTapped
,
<
int
>[
1
,
1
,
1
,
1
,
1
],
reason:
'top left not tapped'
);
await
tester
.
tapAt
(
topLeftOutside
);
expect
(
itemsTapped
,
<
int
>[
1
,
1
,
1
,
1
,
1
],
reason:
'top left tapped'
);
});
}
\ No newline at end of file
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