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
bafac177
Unverified
Commit
bafac177
authored
Apr 06, 2022
by
Taha Tesser
Committed by
GitHub
Apr 06, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing `ListTile` tests, remove duplicate test and fix typos (#101141)
parent
d2fcccf5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
159 additions
and
62 deletions
+159
-62
data_table_theme_test.dart
packages/flutter/test/material/data_table_theme_test.dart
+20
-20
list_tile_test.dart
packages/flutter/test/material/list_tile_test.dart
+139
-42
No files found.
packages/flutter/test/material/data_table_theme_test.dart
View file @
bafac177
...
...
@@ -245,16 +245,16 @@ void main() {
});
testWidgets
(
'Local DataTableTheme can override global DataTableTheme'
,
(
WidgetTester
tester
)
async
{
const
BoxDecoration
glo
ab
lThemeDecoration
=
BoxDecoration
(
color:
Color
(
0xfffffff1
));
final
MaterialStateProperty
<
Color
>
glo
ab
lThemeDataRowColor
=
MaterialStateProperty
.
all
<
Color
>(
const
Color
(
0xfffffff0
));
const
double
glo
ab
lThemeDataRowHeight
=
50.0
;
const
TextStyle
glo
ab
lThemeDataTextStyle
=
TextStyle
(
fontSize:
11.5
);
final
MaterialStateProperty
<
Color
>
glo
ab
lThemeHeadingRowColor
=
MaterialStateProperty
.
all
<
Color
>(
const
Color
(
0xfffffff1
));
const
double
glo
ab
lThemeHeadingRowHeight
=
51.0
;
const
TextStyle
glo
ab
lThemeHeadingTextStyle
=
TextStyle
(
fontSize:
13.5
);
const
double
glo
ab
lThemeHorizontalMargin
=
2.0
;
const
double
glo
ab
lThemeColumnSpacing
=
3.0
;
const
double
glo
ab
lThemeDividerThickness
=
4.0
;
const
BoxDecoration
glo
ba
lThemeDecoration
=
BoxDecoration
(
color:
Color
(
0xfffffff1
));
final
MaterialStateProperty
<
Color
>
glo
ba
lThemeDataRowColor
=
MaterialStateProperty
.
all
<
Color
>(
const
Color
(
0xfffffff0
));
const
double
glo
ba
lThemeDataRowHeight
=
50.0
;
const
TextStyle
glo
ba
lThemeDataTextStyle
=
TextStyle
(
fontSize:
11.5
);
final
MaterialStateProperty
<
Color
>
glo
ba
lThemeHeadingRowColor
=
MaterialStateProperty
.
all
<
Color
>(
const
Color
(
0xfffffff1
));
const
double
glo
ba
lThemeHeadingRowHeight
=
51.0
;
const
TextStyle
glo
ba
lThemeHeadingTextStyle
=
TextStyle
(
fontSize:
13.5
);
const
double
glo
ba
lThemeHorizontalMargin
=
2.0
;
const
double
glo
ba
lThemeColumnSpacing
=
3.0
;
const
double
glo
ba
lThemeDividerThickness
=
4.0
;
const
BoxDecoration
localThemeDecoration
=
BoxDecoration
(
color:
Color
(
0xfffffff0
));
final
MaterialStateProperty
<
Color
>
localThemeDataRowColor
=
MaterialStateProperty
.
all
<
Color
>(
const
Color
(
0xfffffff1
));
...
...
@@ -271,16 +271,16 @@ void main() {
MaterialApp
(
theme:
ThemeData
(
dataTableTheme:
DataTableThemeData
(
decoration:
glo
ab
lThemeDecoration
,
dataRowColor:
glo
ab
lThemeDataRowColor
,
dataRowHeight:
glo
ab
lThemeDataRowHeight
,
dataTextStyle:
glo
ab
lThemeDataTextStyle
,
headingRowColor:
glo
ab
lThemeHeadingRowColor
,
headingRowHeight:
glo
ab
lThemeHeadingRowHeight
,
headingTextStyle:
glo
ab
lThemeHeadingTextStyle
,
horizontalMargin:
glo
ab
lThemeHorizontalMargin
,
columnSpacing:
glo
ab
lThemeColumnSpacing
,
dividerThickness:
glo
ab
lThemeDividerThickness
,
decoration:
glo
ba
lThemeDecoration
,
dataRowColor:
glo
ba
lThemeDataRowColor
,
dataRowHeight:
glo
ba
lThemeDataRowHeight
,
dataTextStyle:
glo
ba
lThemeDataTextStyle
,
headingRowColor:
glo
ba
lThemeHeadingRowColor
,
headingRowHeight:
glo
ba
lThemeHeadingRowHeight
,
headingTextStyle:
glo
ba
lThemeHeadingTextStyle
,
horizontalMargin:
glo
ba
lThemeHorizontalMargin
,
columnSpacing:
glo
ba
lThemeColumnSpacing
,
dividerThickness:
glo
ba
lThemeDividerThickness
,
),
),
home:
Scaffold
(
...
...
packages/flutter/test/material/list_tile_test.dart
View file @
bafac177
...
...
@@ -397,48 +397,6 @@ void main() {
expect
(
right
(
'L'
),
790.0
);
// 800 - contentPadding.start
});
testWidgets
(
'ListTile contentPadding'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
(
TextDirection
textDirection
)
{
return
MediaQuery
(
data:
const
MediaQueryData
(),
child:
Directionality
(
textDirection:
textDirection
,
child:
Material
(
child:
Container
(
alignment:
Alignment
.
topLeft
,
child:
const
ListTile
(
contentPadding:
EdgeInsetsDirectional
.
only
(
start:
10.0
,
end:
20.0
,
top:
30.0
,
bottom:
40.0
,
),
leading:
Text
(
'L'
),
title:
Text
(
'title'
),
trailing:
Text
(
'T'
),
),
),
),
),
);
}
double
left
(
String
text
)
=>
tester
.
getTopLeft
(
find
.
text
(
text
)).
dx
;
double
right
(
String
text
)
=>
tester
.
getTopRight
(
find
.
text
(
text
)).
dx
;
await
tester
.
pumpWidget
(
buildFrame
(
TextDirection
.
ltr
));
expect
(
tester
.
getSize
(
find
.
byType
(
ListTile
)),
const
Size
(
800.0
,
126.0
));
// 126 = 56 + 30 + 40
expect
(
left
(
'L'
),
10.0
);
// contentPadding.start = 10
expect
(
right
(
'T'
),
780.0
);
// 800 - contentPadding.end
await
tester
.
pumpWidget
(
buildFrame
(
TextDirection
.
rtl
));
expect
(
tester
.
getSize
(
find
.
byType
(
ListTile
)),
const
Size
(
800.0
,
126.0
));
// 126 = 56 + 30 + 40
expect
(
left
(
'T'
),
20.0
);
// contentPadding.end = 20
expect
(
right
(
'L'
),
790.0
);
// 800 - contentPadding.start
});
testWidgets
(
'ListTile wide leading Widget'
,
(
WidgetTester
tester
)
async
{
const
Key
leadingKey
=
ValueKey
<
String
>(
'L'
);
...
...
@@ -2138,4 +2096,143 @@ void main() {
expect
(
iconColor
(
subtitleKey
),
Colors
.
white
);
expect
(
iconColor
(
trailingKey
),
Colors
.
white
);
});
testWidgets
(
'ListTile font size'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
({
bool
dense
=
false
,
bool
enabled
=
true
,
bool
selected
=
false
,
ListTileStyle
?
style
,
})
{
return
MaterialApp
(
home:
Material
(
child:
Center
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
return
ListTile
(
dense:
dense
,
enabled:
enabled
,
selected:
selected
,
style:
style
,
leading:
const
TestText
(
'leading'
),
title:
const
TestText
(
'title'
),
subtitle:
const
TestText
(
'subtitle'
)
,
trailing:
const
TestText
(
'trailing'
),
);
},
),
),
),
);
}
// ListTile - ListTileStyle.list (default).
await
tester
.
pumpWidget
(
buildFrame
());
RenderParagraph
leading
=
_getTextRenderObject
(
tester
,
'leading'
);
expect
(
leading
.
text
.
style
!.
fontSize
,
14.0
);
RenderParagraph
title
=
_getTextRenderObject
(
tester
,
'title'
);
expect
(
title
.
text
.
style
!.
fontSize
,
16.0
);
RenderParagraph
subtitle
=
_getTextRenderObject
(
tester
,
'subtitle'
);
expect
(
subtitle
.
text
.
style
!.
fontSize
,
14.0
);
RenderParagraph
trailing
=
_getTextRenderObject
(
tester
,
'trailing'
);
expect
(
trailing
.
text
.
style
!.
fontSize
,
14.0
);
// ListTile - Densed - ListTileStyle.list (default).
await
tester
.
pumpWidget
(
buildFrame
(
dense:
true
));
await
tester
.
pumpAndSettle
();
leading
=
_getTextRenderObject
(
tester
,
'leading'
);
expect
(
leading
.
text
.
style
!.
fontSize
,
14.0
);
title
=
_getTextRenderObject
(
tester
,
'title'
);
expect
(
title
.
text
.
style
!.
fontSize
,
13.0
);
subtitle
=
_getTextRenderObject
(
tester
,
'subtitle'
);
expect
(
subtitle
.
text
.
style
!.
fontSize
,
12.0
);
trailing
=
_getTextRenderObject
(
tester
,
'trailing'
);
expect
(
trailing
.
text
.
style
!.
fontSize
,
14.0
);
// ListTile - ListTileStyle.drawer.
await
tester
.
pumpWidget
(
buildFrame
(
style:
ListTileStyle
.
drawer
));
await
tester
.
pumpAndSettle
();
leading
=
_getTextRenderObject
(
tester
,
'leading'
);
expect
(
leading
.
text
.
style
!.
fontSize
,
14.0
);
title
=
_getTextRenderObject
(
tester
,
'title'
);
expect
(
title
.
text
.
style
!.
fontSize
,
14.0
);
subtitle
=
_getTextRenderObject
(
tester
,
'subtitle'
);
expect
(
subtitle
.
text
.
style
!.
fontSize
,
14.0
);
trailing
=
_getTextRenderObject
(
tester
,
'trailing'
);
expect
(
trailing
.
text
.
style
!.
fontSize
,
14.0
);
// ListTile - Densed - ListTileStyle.drawer.
await
tester
.
pumpWidget
(
buildFrame
(
dense:
true
,
style:
ListTileStyle
.
drawer
));
await
tester
.
pumpAndSettle
();
leading
=
_getTextRenderObject
(
tester
,
'leading'
);
expect
(
leading
.
text
.
style
!.
fontSize
,
14.0
);
title
=
_getTextRenderObject
(
tester
,
'title'
);
expect
(
title
.
text
.
style
!.
fontSize
,
13.0
);
subtitle
=
_getTextRenderObject
(
tester
,
'subtitle'
);
expect
(
subtitle
.
text
.
style
!.
fontSize
,
12.0
);
trailing
=
_getTextRenderObject
(
tester
,
'trailing'
);
expect
(
trailing
.
text
.
style
!.
fontSize
,
14.0
);
});
testWidgets
(
'ListTile text color'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
({
bool
dense
=
false
,
bool
enabled
=
true
,
bool
selected
=
false
,
ListTileStyle
?
style
,
})
{
return
MaterialApp
(
home:
Material
(
child:
Center
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
return
ListTile
(
dense:
dense
,
enabled:
enabled
,
selected:
selected
,
style:
style
,
leading:
const
TestText
(
'leading'
),
title:
const
TestText
(
'title'
),
subtitle:
const
TestText
(
'subtitle'
)
,
trailing:
const
TestText
(
'trailing'
),
);
},
),
),
),
);
}
final
ThemeData
theme
=
ThemeData
();
// ListTile - ListTileStyle.list (default).
await
tester
.
pumpWidget
(
buildFrame
());
RenderParagraph
leading
=
_getTextRenderObject
(
tester
,
'leading'
);
expect
(
leading
.
text
.
style
!.
color
,
theme
.
textTheme
.
bodyText2
!.
color
);
RenderParagraph
title
=
_getTextRenderObject
(
tester
,
'title'
);
expect
(
title
.
text
.
style
!.
color
,
theme
.
textTheme
.
subtitle1
!.
color
);
RenderParagraph
subtitle
=
_getTextRenderObject
(
tester
,
'subtitle'
);
expect
(
subtitle
.
text
.
style
!.
color
,
theme
.
textTheme
.
caption
!.
color
);
RenderParagraph
trailing
=
_getTextRenderObject
(
tester
,
'trailing'
);
expect
(
trailing
.
text
.
style
!.
color
,
theme
.
textTheme
.
bodyText2
!.
color
);
// ListTile - ListTileStyle.drawer.
await
tester
.
pumpWidget
(
buildFrame
(
style:
ListTileStyle
.
drawer
));
await
tester
.
pumpAndSettle
();
leading
=
_getTextRenderObject
(
tester
,
'leading'
);
expect
(
leading
.
text
.
style
!.
color
,
theme
.
textTheme
.
bodyText2
!.
color
);
title
=
_getTextRenderObject
(
tester
,
'title'
);
expect
(
title
.
text
.
style
!.
color
,
theme
.
textTheme
.
bodyText1
!.
color
);
subtitle
=
_getTextRenderObject
(
tester
,
'subtitle'
);
expect
(
subtitle
.
text
.
style
!.
color
,
theme
.
textTheme
.
caption
!.
color
);
trailing
=
_getTextRenderObject
(
tester
,
'trailing'
);
expect
(
trailing
.
text
.
style
!.
color
,
theme
.
textTheme
.
bodyText2
!.
color
);
});
}
RenderParagraph
_getTextRenderObject
(
WidgetTester
tester
,
String
text
)
{
return
tester
.
renderObject
(
find
.
descendant
(
of:
find
.
byType
(
ListTile
),
matching:
find
.
text
(
text
),
));
}
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