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
dfc6c438
Unverified
Commit
dfc6c438
authored
Oct 15, 2020
by
Shi-Hao Hong
Committed by
GitHub
Oct 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NNBD] More widget tests (#68088)
* NNBD widget test migration
parent
8ba5732c
Changes
28
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
183 additions
and
402 deletions
+183
-402
intrinsic_width_test.dart
packages/flutter/test/widgets/intrinsic_width_test.dart
+1
-3
invert_colors_test.dart
packages/flutter/test/widgets/invert_colors_test.dart
+6
-8
keep_alive_test.dart
packages/flutter/test/widgets/keep_alive_test.dart
+12
-11
key_test.dart
packages/flutter/test/widgets/key_test.dart
+0
-2
layout_builder_and_global_keys_test.dart
...ter/test/widgets/layout_builder_and_global_keys_test.dart
+6
-8
layout_builder_and_parent_data_test.dart
...ter/test/widgets/layout_builder_and_parent_data_test.dart
+4
-6
layout_builder_and_state_test.dart
...s/flutter/test/widgets/layout_builder_and_state_test.dart
+4
-6
layout_builder_mutations_test.dart
...s/flutter/test/widgets/layout_builder_mutations_test.dart
+2
-4
layout_builder_test.dart
packages/flutter/test/widgets/layout_builder_test.dart
+19
-21
linked_scroll_view_test.dart
packages/flutter/test/widgets/linked_scroll_view_test.dart
+41
-40
list_body_test.dart
packages/flutter/test/widgets/list_body_test.dart
+2
-4
list_view_builder_test.dart
packages/flutter/test/widgets/list_view_builder_test.dart
+2
-4
list_view_correction_test.dart
packages/flutter/test/widgets/list_view_correction_test.dart
+0
-2
list_view_fling_test.dart
packages/flutter/test/widgets/list_view_fling_test.dart
+0
-2
list_view_horizontal_test.dart
packages/flutter/test/widgets/list_view_horizontal_test.dart
+1
-3
list_view_misc_test.dart
packages/flutter/test/widgets/list_view_misc_test.dart
+1
-3
list_view_relayout_test.dart
packages/flutter/test/widgets/list_view_relayout_test.dart
+3
-5
list_view_semantics_test.dart
packages/flutter/test/widgets/list_view_semantics_test.dart
+0
-2
list_view_test.dart
packages/flutter/test/widgets/list_view_test.dart
+4
-6
list_view_vertical_test.dart
packages/flutter/test/widgets/list_view_vertical_test.dart
+0
-2
list_view_viewporting_test.dart
...ages/flutter/test/widgets/list_view_viewporting_test.dart
+7
-9
list_view_with_inherited_test.dart
...s/flutter/test/widgets/list_view_with_inherited_test.dart
+23
-15
list_wheel_scroll_view_test.dart
...ges/flutter/test/widgets/list_wheel_scroll_view_test.dart
+7
-32
listener_test.dart
packages/flutter/test/widgets/listener_test.dart
+0
-2
listview_end_append_test.dart
packages/flutter/test/widgets/listview_end_append_test.dart
+0
-2
localizations_test.dart
packages/flutter/test/widgets/localizations_test.dart
+5
-8
media_query_test.dart
packages/flutter/test/widgets/media_query_test.dart
+25
-182
modal_barrier_test.dart
packages/flutter/test/widgets/modal_barrier_test.dart
+8
-10
No files found.
packages/flutter/test/widgets/intrinsic_width_test.dart
View file @
dfc6c438
...
...
@@ -2,15 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
void
main
(
)
{
testWidgets
(
'Intrinsic stepWidth, stepHeight'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/25224
Widget
buildFrame
(
double
stepWidth
,
double
stepHeight
)
{
Widget
buildFrame
(
double
?
stepWidth
,
double
?
stepHeight
)
{
return
Center
(
child:
IntrinsicWidth
(
stepWidth:
stepWidth
,
...
...
packages/flutter/test/widgets/invert_colors_test.dart
View file @
dfc6c438
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -49,13 +47,13 @@ void main() {
// and [invertColors] applied for testing the invert colors.
class
InvertColorTestWidget
extends
LeafRenderObjectWidget
{
const
InvertColorTestWidget
({
this
.
color
,
required
this
.
color
,
this
.
filter
,
Key
key
,
Key
?
key
,
})
:
super
(
key:
key
);
final
Color
color
;
final
ColorFilter
filter
;
final
ColorFilter
?
filter
;
@override
RenderInvertColorTest
createRenderObject
(
BuildContext
context
)
{
...
...
@@ -83,9 +81,9 @@ class RenderInvertColorTest extends RenderProxyBox {
}
ColorFilter
get
filter
=>
_filter
;
ColorFilter
_filter
;
set
filter
(
ColorFilter
value
)
{
ColorFilter
?
get
filter
=>
_filter
;
ColorFilter
?
_filter
;
set
filter
(
ColorFilter
?
value
)
{
if
(
filter
==
value
)
return
;
_filter
=
value
;
...
...
packages/flutter/test/widgets/keep_alive_test.dart
View file @
dfc6c438
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
@TestOn
(
'!chrome'
)
// diagnostics use Platform.operatingSystem.
import
'dart:io'
show
Platform
;
...
...
@@ -11,7 +9,10 @@ import 'package:flutter_test/flutter_test.dart';
import
'package:flutter/widgets.dart'
;
class
Leaf
extends
StatefulWidget
{
const
Leaf
({
Key
key
,
this
.
child
})
:
super
(
key:
key
);
const
Leaf
({
Key
?
key
,
required
this
.
child
,
})
:
super
(
key:
key
);
final
Widget
child
;
@override
_LeafState
createState
()
=>
_LeafState
();
...
...
@@ -73,7 +74,7 @@ void main() {
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
60
)),
findsOneWidget
);
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
61
)),
findsOneWidget
);
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
90
),
skipOffstage:
false
),
findsNothing
);
const
GlobalObjectKey
<
_LeafState
>(
60
).
currentState
.
setKeepAlive
(
true
);
const
GlobalObjectKey
<
_LeafState
>(
60
).
currentState
!
.
setKeepAlive
(
true
);
await
tester
.
drag
(
find
.
byType
(
ListView
),
const
Offset
(
0.0
,
300.0
));
// back to top
await
tester
.
pump
();
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
3
)),
findsOneWidget
);
...
...
@@ -83,7 +84,7 @@ void main() {
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
60
)),
findsNothing
);
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
61
),
skipOffstage:
false
),
findsNothing
);
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
90
),
skipOffstage:
false
),
findsNothing
);
const
GlobalObjectKey
<
_LeafState
>(
60
).
currentState
.
setKeepAlive
(
false
);
const
GlobalObjectKey
<
_LeafState
>(
60
).
currentState
!
.
setKeepAlive
(
false
);
await
tester
.
pump
();
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
3
)),
findsOneWidget
);
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
30
)),
findsOneWidget
);
...
...
@@ -120,7 +121,7 @@ void main() {
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
60
)),
findsOneWidget
);
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
61
)),
findsOneWidget
);
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
90
),
skipOffstage:
false
),
findsNothing
);
const
GlobalObjectKey
<
_LeafState
>(
60
).
currentState
.
setKeepAlive
(
true
);
const
GlobalObjectKey
<
_LeafState
>(
60
).
currentState
!
.
setKeepAlive
(
true
);
await
tester
.
drag
(
find
.
byType
(
ListView
),
const
Offset
(
0.0
,
300.0
));
// back to top
await
tester
.
pump
();
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
3
)),
findsOneWidget
);
...
...
@@ -130,7 +131,7 @@ void main() {
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
60
)),
findsNothing
);
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
61
),
skipOffstage:
false
),
findsNothing
);
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
90
),
skipOffstage:
false
),
findsNothing
);
const
GlobalObjectKey
<
_LeafState
>(
60
).
currentState
.
setKeepAlive
(
false
);
const
GlobalObjectKey
<
_LeafState
>(
60
).
currentState
!
.
setKeepAlive
(
false
);
await
tester
.
pump
();
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
3
)),
findsOneWidget
);
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
30
)),
findsOneWidget
);
...
...
@@ -169,7 +170,7 @@ void main() {
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
60
)),
findsOneWidget
);
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
61
)),
findsOneWidget
);
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
90
),
skipOffstage:
false
),
findsNothing
);
const
GlobalObjectKey
<
_LeafState
>(
60
).
currentState
.
setKeepAlive
(
true
);
const
GlobalObjectKey
<
_LeafState
>(
60
).
currentState
!
.
setKeepAlive
(
true
);
await
tester
.
drag
(
find
.
byType
(
GridView
),
const
Offset
(
0.0
,
300.0
));
// back to top
await
tester
.
pump
();
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
3
)),
findsOneWidget
);
...
...
@@ -179,7 +180,7 @@ void main() {
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
60
)),
findsNothing
);
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
61
),
skipOffstage:
false
),
findsNothing
);
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
90
),
skipOffstage:
false
),
findsNothing
);
const
GlobalObjectKey
<
_LeafState
>(
60
).
currentState
.
setKeepAlive
(
false
);
const
GlobalObjectKey
<
_LeafState
>(
60
).
currentState
!
.
setKeepAlive
(
false
);
await
tester
.
pump
();
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
3
)),
findsOneWidget
);
expect
(
find
.
byKey
(
const
GlobalObjectKey
<
_LeafState
>(
30
)),
findsOneWidget
);
...
...
@@ -345,10 +346,10 @@ void main() {
' constraints: BoxConstraints(w=800.0, h=400.0)
\n
'
' size: Size(800.0, 400.0)
\n
'
));
const
GlobalObjectKey
<
_LeafState
>(
0
).
currentState
.
setKeepAlive
(
true
);
const
GlobalObjectKey
<
_LeafState
>(
0
).
currentState
!
.
setKeepAlive
(
true
);
await
tester
.
drag
(
find
.
byType
(
ListView
),
const
Offset
(
0.0
,
-
1000.0
));
await
tester
.
pump
();
const
GlobalObjectKey
<
_LeafState
>(
3
).
currentState
.
setKeepAlive
(
true
);
const
GlobalObjectKey
<
_LeafState
>(
3
).
currentState
!
.
setKeepAlive
(
true
);
await
tester
.
drag
(
find
.
byType
(
ListView
),
const
Offset
(
0.0
,
-
1000.0
));
await
tester
.
pump
();
expect
(
tester
.
binding
.
renderView
.
toStringDeep
(
minLevel:
DiagnosticLevel
.
info
),
equalsIgnoringHashCodes
(
...
...
packages/flutter/test/widgets/key_test.dart
View file @
dfc6c438
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
packages/flutter/test/widgets/layout_builder_and_global_keys_test.dart
View file @
dfc6c438
...
...
@@ -2,16 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/src/rendering/sliver.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
class
Wrapper
extends
StatelessWidget
{
const
Wrapper
({
Key
key
,
this
.
child
,
Key
?
key
,
required
this
.
child
,
})
:
super
(
key:
key
);
final
Widget
child
;
...
...
@@ -22,8 +20,8 @@ class Wrapper extends StatelessWidget {
class
StatefulWrapper
extends
StatefulWidget
{
const
StatefulWrapper
({
Key
key
,
this
.
child
,
Key
?
key
,
required
this
.
child
,
})
:
super
(
key:
key
);
final
Widget
child
;
...
...
@@ -54,7 +52,7 @@ void main() {
);
await
tester
.
pumpWidget
(
LayoutBuilder
(
builder:
(
BuildContext
context
,
BoxConstraints
constraints
)
{
key
.
currentState
.
trigger
();
key
.
currentState
!
.
trigger
();
return
StatefulWrapper
(
key:
key
,
child:
Container
(
height:
100.0
));
}),
);
...
...
@@ -89,7 +87,7 @@ void main() {
slivers:
<
Widget
>[
SliverLayoutBuilder
(
builder:
(
BuildContext
context
,
SliverConstraints
constraint
)
{
key
.
currentState
.
trigger
();
key
.
currentState
!
.
trigger
();
return
SliverToBoxAdapter
(
child:
StatefulWrapper
(
key:
key
,
child:
Container
(
height:
100.0
)),
);
...
...
packages/flutter/test/widgets/layout_builder_and_parent_data_test.dart
View file @
dfc6c438
...
...
@@ -2,15 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
class
SizeChanger
extends
StatefulWidget
{
const
SizeChanger
({
Key
key
,
this
.
child
,
Key
?
key
,
required
this
.
child
,
})
:
super
(
key:
key
);
final
Widget
child
;
...
...
@@ -45,8 +43,8 @@ class SizeChangerState extends State<SizeChanger> {
class
Wrapper
extends
StatelessWidget
{
const
Wrapper
({
Key
key
,
this
.
child
,
Key
?
key
,
required
this
.
child
,
})
:
super
(
key:
key
);
final
Widget
child
;
...
...
packages/flutter/test/widgets/layout_builder_and_state_test.dart
View file @
dfc6c438
...
...
@@ -2,16 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
import
'test_widgets.dart'
;
class
StatefulWrapper
extends
StatefulWidget
{
const
StatefulWrapper
({
Key
key
,
this
.
child
,
Key
?
key
,
required
this
.
child
,
})
:
super
(
key:
key
);
final
Widget
child
;
...
...
@@ -37,8 +35,8 @@ class StatefulWrapperState extends State<StatefulWrapper> {
class
Wrapper
extends
StatelessWidget
{
const
Wrapper
({
Key
key
,
this
.
child
,
Key
?
key
,
required
this
.
child
,
})
:
super
(
key:
key
);
final
Widget
child
;
...
...
packages/flutter/test/widgets/layout_builder_mutations_test.dart
View file @
dfc6c438
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/src/rendering/sliver.dart'
;
import
'package:flutter/src/widgets/basic.dart'
;
import
'package:flutter/src/widgets/framework.dart'
;
...
...
@@ -14,8 +12,8 @@ import 'package:flutter_test/flutter_test.dart';
class
Wrapper
extends
StatelessWidget
{
const
Wrapper
({
Key
key
,
@
required
this
.
child
,
Key
?
key
,
required
this
.
child
,
})
:
assert
(
child
!=
null
),
super
(
key:
key
);
...
...
packages/flutter/test/widgets/layout_builder_test.dart
View file @
dfc6c438
...
...
@@ -2,15 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
void
main
(
)
{
testWidgets
(
'LayoutBuilder parent size'
,
(
WidgetTester
tester
)
async
{
Size
layoutBuilderSize
;
late
Size
layoutBuilderSize
;
final
Key
childKey
=
UniqueKey
();
final
Key
parentKey
=
UniqueKey
();
...
...
@@ -41,8 +39,8 @@ void main() {
});
testWidgets
(
'SliverLayoutBuilder parent geometry'
,
(
WidgetTester
tester
)
async
{
SliverConstraints
parentConstraints1
;
SliverConstraints
parentConstraints2
;
late
SliverConstraints
parentConstraints1
;
late
SliverConstraints
parentConstraints2
;
final
Key
childKey1
=
UniqueKey
();
final
Key
parentKey1
=
UniqueKey
();
final
Key
childKey2
=
UniqueKey
();
...
...
@@ -81,8 +79,8 @@ void main() {
final
RenderSliver
parentSliver2
=
tester
.
renderObject
(
find
.
byKey
(
parentKey2
));
// scrollExtent == top + bottom.
expect
(
parentSliver1
.
geometry
.
scrollExtent
,
2
+
4
);
expect
(
parentSliver2
.
geometry
.
scrollExtent
,
7
+
13
);
expect
(
parentSliver1
.
geometry
!
.
scrollExtent
,
2
+
4
);
expect
(
parentSliver2
.
geometry
!
.
scrollExtent
,
7
+
13
);
final
RenderSliver
childSliver1
=
tester
.
renderObject
(
find
.
byKey
(
childKey1
));
final
RenderSliver
childSliver2
=
tester
.
renderObject
(
find
.
byKey
(
childKey2
));
...
...
@@ -91,8 +89,8 @@ void main() {
});
testWidgets
(
'LayoutBuilder stateful child'
,
(
WidgetTester
tester
)
async
{
Size
layoutBuilderSize
;
StateSetter
setState
;
late
Size
layoutBuilderSize
;
late
StateSetter
setState
;
final
Key
childKey
=
UniqueKey
();
final
Key
parentKey
=
UniqueKey
();
double
childWidth
=
10.0
;
...
...
@@ -137,7 +135,7 @@ void main() {
});
testWidgets
(
'SliverLayoutBuilder stateful descendants'
,
(
WidgetTester
tester
)
async
{
StateSetter
setState
;
late
StateSetter
setState
;
double
childWidth
=
10.0
;
double
childHeight
=
20.0
;
final
Key
parentKey
=
UniqueKey
();
...
...
@@ -174,8 +172,8 @@ void main() {
RenderSliver
parentSliver
=
tester
.
renderObject
(
find
.
byKey
(
parentKey
));
expect
(
childBox
.
size
.
width
,
800
);
expect
(
childBox
.
size
.
height
,
childHeight
);
expect
(
parentSliver
.
geometry
.
scrollExtent
,
childHeight
);
expect
(
parentSliver
.
geometry
.
paintExtent
,
childHeight
);
expect
(
parentSliver
.
geometry
!
.
scrollExtent
,
childHeight
);
expect
(
parentSliver
.
geometry
!
.
paintExtent
,
childHeight
);
setState
(()
{
childWidth
=
100.0
;
...
...
@@ -187,8 +185,8 @@ void main() {
parentSliver
=
tester
.
renderObject
(
find
.
byKey
(
parentKey
));
expect
(
childBox
.
size
.
width
,
800
);
expect
(
childBox
.
size
.
height
,
childHeight
);
expect
(
parentSliver
.
geometry
.
scrollExtent
,
childHeight
);
expect
(
parentSliver
.
geometry
.
paintExtent
,
childHeight
);
expect
(
parentSliver
.
geometry
!
.
scrollExtent
,
childHeight
);
expect
(
parentSliver
.
geometry
!
.
paintExtent
,
childHeight
);
// Make child wider and higher than the viewport.
setState
(()
{
...
...
@@ -201,13 +199,13 @@ void main() {
parentSliver
=
tester
.
renderObject
(
find
.
byKey
(
parentKey
));
expect
(
childBox
.
size
.
width
,
800
);
expect
(
childBox
.
size
.
height
,
childHeight
);
expect
(
parentSliver
.
geometry
.
scrollExtent
,
childHeight
);
expect
(
parentSliver
.
geometry
.
paintExtent
,
600
);
expect
(
parentSliver
.
geometry
!
.
scrollExtent
,
childHeight
);
expect
(
parentSliver
.
geometry
!
.
paintExtent
,
600
);
});
testWidgets
(
'LayoutBuilder stateful parent'
,
(
WidgetTester
tester
)
async
{
Size
layoutBuilderSize
;
StateSetter
setState
;
late
Size
layoutBuilderSize
;
late
StateSetter
setState
;
final
Key
childKey
=
UniqueKey
();
double
childWidth
=
10.0
;
double
childHeight
=
20.0
;
...
...
@@ -362,8 +360,8 @@ void main() {
});
testWidgets
(
'nested SliverLayoutBuilder'
,
(
WidgetTester
tester
)
async
{
SliverConstraints
parentConstraints1
;
SliverConstraints
parentConstraints2
;
late
SliverConstraints
parentConstraints1
;
late
SliverConstraints
parentConstraints2
;
final
Key
childKey
=
UniqueKey
();
final
Key
parentKey1
=
UniqueKey
();
final
Key
parentKey2
=
UniqueKey
();
...
...
@@ -399,7 +397,7 @@ void main() {
final
RenderSliver
parentSliver1
=
tester
.
renderObject
(
find
.
byKey
(
parentKey1
));
final
RenderSliver
parentSliver2
=
tester
.
renderObject
(
find
.
byKey
(
parentKey2
));
// scrollExtent == top + bottom.
expect
(
parentSliver1
.
geometry
.
scrollExtent
,
2
+
4
);
expect
(
parentSliver1
.
geometry
!
.
scrollExtent
,
2
+
4
);
final
RenderSliver
childSliver
=
tester
.
renderObject
(
find
.
byKey
(
childKey
));
expect
(
childSliver
.
geometry
,
parentSliver1
.
geometry
);
...
...
packages/flutter/test/widgets/linked_scroll_view_test.dart
View file @
dfc6c438
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
// This file contains a wacky demonstration of creating a custom ScrollPosition
// setup. It's testing that we don't regress the factoring of the
// ScrollPosition/ScrollActivity logic into a state where you can no longer
...
...
@@ -21,18 +19,18 @@ import 'package:flutter_test/flutter_test.dart';
class
LinkedScrollController
extends
ScrollController
{
LinkedScrollController
({
this
.
before
,
this
.
after
});
LinkedScrollController
before
;
LinkedScrollController
after
;
LinkedScrollController
?
before
;
LinkedScrollController
?
after
;
ScrollController
_parent
;
ScrollController
?
_parent
;
void
setParent
(
ScrollController
newParent
)
{
void
setParent
(
ScrollController
?
newParent
)
{
if
(
_parent
!=
null
)
{
positions
.
forEach
(
_parent
.
detach
);
positions
.
forEach
(
_parent
!
.
detach
);
}
_parent
=
newParent
;
if
(
_parent
!=
null
)
{
positions
.
forEach
(
_parent
.
attach
);
positions
.
forEach
(
_parent
!
.
attach
);
}
}
...
...
@@ -54,13 +52,13 @@ class LinkedScrollController extends ScrollController {
@override
void
dispose
()
{
if
(
_parent
!=
null
)
{
positions
.
forEach
(
_parent
.
detach
);
positions
.
forEach
(
_parent
!
.
detach
);
}
super
.
dispose
();
}
@override
LinkedScrollPosition
createScrollPosition
(
ScrollPhysics
physics
,
ScrollContext
context
,
ScrollPosition
oldPosition
)
{
LinkedScrollPosition
createScrollPosition
(
ScrollPhysics
physics
,
ScrollContext
context
,
ScrollPosition
?
oldPosition
)
{
return
LinkedScrollPosition
(
this
,
physics:
physics
,
...
...
@@ -70,18 +68,18 @@ class LinkedScrollController extends ScrollController {
);
}
bool
get
canLinkWithBefore
=>
before
!=
null
&&
before
.
hasClients
;
bool
get
canLinkWithBefore
=>
before
!=
null
&&
before
!
.
hasClients
;
bool
get
canLinkWithAfter
=>
after
!=
null
&&
after
.
hasClients
;
bool
get
canLinkWithAfter
=>
after
!=
null
&&
after
!
.
hasClients
;
Iterable
<
LinkedScrollActivity
>
linkWithBefore
(
LinkedScrollPosition
driver
)
{
assert
(
canLinkWithBefore
);
return
before
.
link
(
driver
);
return
before
!
.
link
(
driver
);
}
Iterable
<
LinkedScrollActivity
>
linkWithAfter
(
LinkedScrollPosition
driver
)
{
assert
(
canLinkWithAfter
);
return
after
.
link
(
driver
);
return
after
!
.
link
(
driver
);
}
Iterable
<
LinkedScrollActivity
>
link
(
LinkedScrollPosition
driver
)
sync
*
{
...
...
@@ -109,10 +107,10 @@ class LinkedScrollController extends ScrollController {
class
LinkedScrollPosition
extends
ScrollPositionWithSingleContext
{
LinkedScrollPosition
(
this
.
owner
,
{
ScrollPhysics
physics
,
ScrollContext
context
,
double
initialPixels
,
ScrollPosition
oldPosition
,
required
ScrollPhysics
physics
,
required
ScrollContext
context
,
required
double
initialPixels
,
ScrollPosition
?
oldPosition
,
})
:
assert
(
owner
!=
null
),
super
(
physics:
physics
,
...
...
@@ -123,22 +121,22 @@ class LinkedScrollPosition extends ScrollPositionWithSingleContext {
final
LinkedScrollController
owner
;
Set
<
LinkedScrollActivity
>
_beforeActivities
;
Set
<
LinkedScrollActivity
>
_afterActivities
;
Set
<
LinkedScrollActivity
>
?
_beforeActivities
;
Set
<
LinkedScrollActivity
>
?
_afterActivities
;
@override
void
beginActivity
(
ScrollActivity
newActivity
)
{
void
beginActivity
(
ScrollActivity
?
newActivity
)
{
if
(
newActivity
==
null
)
return
;
if
(
_beforeActivities
!=
null
)
{
for
(
final
LinkedScrollActivity
activity
in
_beforeActivities
)
for
(
final
LinkedScrollActivity
activity
in
_beforeActivities
!
)
activity
.
unlink
(
this
);
_beforeActivities
.
clear
();
_beforeActivities
!
.
clear
();
}
if
(
_afterActivities
!=
null
)
{
for
(
final
LinkedScrollActivity
activity
in
_afterActivities
)
for
(
final
LinkedScrollActivity
activity
in
_afterActivities
!
)
activity
.
unlink
(
this
);
_afterActivities
.
clear
();
_afterActivities
!
.
clear
();
}
super
.
beginActivity
(
newActivity
);
}
...
...
@@ -155,8 +153,8 @@ class LinkedScrollPosition extends ScrollPositionWithSingleContext {
if
(
owner
.
canLinkWithBefore
&&
(
value
<
minScrollExtent
))
{
final
double
delta
=
value
-
minScrollExtent
;
_beforeActivities
??=
HashSet
<
LinkedScrollActivity
>();
_beforeActivities
.
addAll
(
owner
.
linkWithBefore
(
this
));
for
(
final
LinkedScrollActivity
activity
in
_beforeActivities
)
_beforeActivities
!
.
addAll
(
owner
.
linkWithBefore
(
this
));
for
(
final
LinkedScrollActivity
activity
in
_beforeActivities
!
)
beforeOverscroll
=
math
.
min
(
activity
.
moveBy
(
delta
),
beforeOverscroll
);
assert
(
beforeOverscroll
<=
0.0
);
}
...
...
@@ -165,8 +163,8 @@ class LinkedScrollPosition extends ScrollPositionWithSingleContext {
if
(
owner
.
canLinkWithAfter
&&
(
value
>
maxScrollExtent
))
{
final
double
delta
=
value
-
maxScrollExtent
;
_afterActivities
??=
HashSet
<
LinkedScrollActivity
>();
_afterActivities
.
addAll
(
owner
.
linkWithAfter
(
this
));
for
(
final
LinkedScrollActivity
activity
in
_afterActivities
)
_afterActivities
!
.
addAll
(
owner
.
linkWithAfter
(
this
));
for
(
final
LinkedScrollActivity
activity
in
_afterActivities
!
)
afterOverscroll
=
math
.
max
(
activity
.
moveBy
(
delta
),
afterOverscroll
);
assert
(
afterOverscroll
>=
0.0
);
}
...
...
@@ -176,7 +174,7 @@ class LinkedScrollPosition extends ScrollPositionWithSingleContext {
final
double
localOverscroll
=
setPixels
(
value
.
clamp
(
owner
.
canLinkWithBefore
?
minScrollExtent
:
-
double
.
infinity
,
owner
.
canLinkWithAfter
?
maxScrollExtent
:
double
.
infinity
,
)
as
double
);
));
assert
(
localOverscroll
==
0.0
||
(
beforeOverscroll
==
0.0
&&
afterOverscroll
==
0.0
));
}
...
...
@@ -188,16 +186,16 @@ class LinkedScrollPosition extends ScrollPositionWithSingleContext {
LinkedScrollActivity
link
(
LinkedScrollPosition
driver
)
{
if
(
this
.
activity
is
!
LinkedScrollActivity
)
beginActivity
(
LinkedScrollActivity
(
this
));
final
LinkedScrollActivity
activity
=
this
.
activity
as
LinkedScrollActivity
;
activity
.
link
(
driver
);
final
LinkedScrollActivity
?
activity
=
this
.
activity
as
LinkedScrollActivity
?
;
activity
!
.
link
(
driver
);
return
activity
;
}
void
unlink
(
LinkedScrollActivity
activity
)
{
if
(
_beforeActivities
!=
null
)
_beforeActivities
.
remove
(
activity
);
_beforeActivities
!
.
remove
(
activity
);
if
(
_afterActivities
!=
null
)
_afterActivities
.
remove
(
activity
);
_afterActivities
!
.
remove
(
activity
);
}
@override
...
...
@@ -224,7 +222,7 @@ class LinkedScrollActivity extends ScrollActivity {
void
unlink
(
LinkedScrollPosition
driver
)
{
drivers
.
remove
(
driver
);
if
(
drivers
.
isEmpty
)
delegate
?
.
goIdle
();
delegate
.
goIdle
();
}
@override
...
...
@@ -240,13 +238,16 @@ class LinkedScrollActivity extends ScrollActivity {
double
moveBy
(
double
delta
)
{
assert
(
drivers
.
isNotEmpty
);
ScrollDirection
commonDirection
;
ScrollDirection
?
commonDirection
;
for
(
final
LinkedScrollPosition
driver
in
drivers
)
{
commonDirection
??=
driver
.
userScrollDirection
;
if
(
driver
.
userScrollDirection
!=
commonDirection
)
commonDirection
=
ScrollDirection
.
idle
;
}
delegate
.
_userMoved
(
commonDirection
);
if
(
commonDirection
!=
null
)
{
delegate
.
_userMoved
(
commonDirection
);
}
return
delegate
.
setPixels
(
delegate
.
pixels
+
delta
);
}
...
...
@@ -259,14 +260,14 @@ class LinkedScrollActivity extends ScrollActivity {
}
class
Test
extends
StatefulWidget
{
const
Test
({
Key
key
})
:
super
(
key:
key
);
const
Test
({
Key
?
key
})
:
super
(
key:
key
);
@override
_TestState
createState
()
=>
_TestState
();
}
class
_TestState
extends
State
<
Test
>
{
LinkedScrollController
_beforeController
;
LinkedScrollController
_afterController
;
late
LinkedScrollController
_beforeController
;
late
LinkedScrollController
_afterController
;
@override
void
initState
()
{
...
...
packages/flutter/test/widgets/list_body_test.dart
View file @
dfc6c438
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/src/foundation/assertions.dart'
;
import
'package:flutter/src/painting/basic_types.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -112,7 +110,7 @@ void main() {
});
testWidgets
(
'Limited space along main axis error'
,
(
WidgetTester
tester
)
async
{
final
FlutterExceptionHandler
oldHandler
=
FlutterError
.
onError
;
final
FlutterExceptionHandler
oldHandler
=
FlutterError
.
onError
!
;
final
List
<
FlutterErrorDetails
>
errors
=
<
FlutterErrorDetails
>[];
FlutterError
.
onError
=
(
FlutterErrorDetails
error
)
=>
errors
.
add
(
error
);
try
{
...
...
@@ -145,7 +143,7 @@ void main() {
});
testWidgets
(
'Nested ListBody unbounded cross axis error'
,
(
WidgetTester
tester
)
async
{
final
FlutterExceptionHandler
oldHandler
=
FlutterError
.
onError
;
final
FlutterExceptionHandler
oldHandler
=
FlutterError
.
onError
!
;
final
List
<
FlutterErrorDetails
>
errors
=
<
FlutterErrorDetails
>[];
FlutterError
.
onError
=
(
FlutterErrorDetails
error
)
=>
errors
.
add
(
error
);
try
{
...
...
packages/flutter/test/widgets/list_view_builder_test.dart
View file @
dfc6c438
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
@@ -264,7 +262,7 @@ void main() {
});
testWidgets
(
'ListView.separated'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
({
int
itemCount
})
{
Widget
buildFrame
({
required
int
itemCount
})
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
ListView
.
separated
(
...
...
@@ -309,7 +307,7 @@ void main() {
testWidgets
(
'ListView.separated uses correct semanticChildCount'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
({
int
itemCount
})
{
Widget
buildFrame
({
required
int
itemCount
})
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
ListView
.
separated
(
...
...
packages/flutter/test/widgets/list_view_correction_test.dart
View file @
dfc6c438
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
...
...
packages/flutter/test/widgets/list_view_fling_test.dart
View file @
dfc6c438
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
...
...
packages/flutter/test/widgets/list_view_horizontal_test.dart
View file @
dfc6c438
...
...
@@ -2,15 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
const
List
<
int
>
items
=
<
int
>[
0
,
1
,
2
,
3
,
4
,
5
];
Widget
buildFrame
(
{
bool
reverse
=
false
,
@
required
TextDirection
textDirection
})
{
Widget
buildFrame
(
{
bool
reverse
=
false
,
required
TextDirection
textDirection
})
{
return
Directionality
(
textDirection:
textDirection
,
child:
Center
(
...
...
packages/flutter/test/widgets/list_view_misc_test.dart
View file @
dfc6c438
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
@@ -218,7 +216,7 @@ void main() {
await
tester
.
pumpWidget
(
buildFrame
());
expect
(
find
.
text
(
'top'
),
findsOneWidget
);
final
ScrollPosition
position
=
Scrollable
.
of
(
tester
.
element
(
find
.
text
(
'middle'
))).
position
;
final
ScrollPosition
position
=
Scrollable
.
of
(
tester
.
element
(
find
.
text
(
'middle'
)))
!
.
position
;
expect
(
position
.
viewportDimension
,
600.0
);
expect
(
position
.
pixels
,
0.0
);
...
...
packages/flutter/test/widgets/list_view_relayout_test.dart
View file @
dfc6c438
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -80,7 +78,7 @@ void main() {
);
final
RenderSliverList
list
=
tester
.
renderObject
(
find
.
byType
(
SliverList
));
expect
(
list
.
geometry
.
scrollExtent
,
equals
(
100.0
));
expect
(
list
.
geometry
!
.
scrollExtent
,
equals
(
100.0
));
await
tester
.
pumpWidget
(
Directionality
(
...
...
@@ -93,7 +91,7 @@ void main() {
),
),
);
expect
(
list
.
geometry
.
scrollExtent
,
equals
(
300.0
));
expect
(
list
.
geometry
!
.
scrollExtent
,
equals
(
300.0
));
await
tester
.
pumpWidget
(
Directionality
(
...
...
@@ -103,7 +101,7 @@ void main() {
),
),
);
expect
(
list
.
geometry
.
scrollExtent
,
equals
(
0.0
));
expect
(
list
.
geometry
!
.
scrollExtent
,
equals
(
0.0
));
});
testWidgets
(
'Overflowing ListView should relayout for missing children'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter/test/widgets/list_view_semantics_test.dart
View file @
dfc6c438
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
packages/flutter/test/widgets/list_view_test.dart
View file @
dfc6c438
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -24,7 +22,7 @@ class TestSliverChildListDelegate extends SliverChildListDelegate {
}
class
Alive
extends
StatefulWidget
{
const
Alive
(
this
.
alive
,
this
.
index
,
{
Key
key
})
:
super
(
key:
key
);
const
Alive
(
this
.
alive
,
this
.
index
,
{
Key
?
key
})
:
super
(
key:
key
);
final
bool
alive
;
final
int
index
;
...
...
@@ -371,7 +369,7 @@ void main() {
});
testWidgets
(
'ListView automatically pad MediaQuery on axis'
,
(
WidgetTester
tester
)
async
{
EdgeInsets
innerMediaQueryPadding
;
EdgeInsets
?
innerMediaQueryPadding
;
await
tester
.
pumpWidget
(
Directionality
(
...
...
@@ -384,7 +382,7 @@ void main() {
children:
<
Widget
>[
const
Text
(
'top'
,
textDirection:
TextDirection
.
ltr
),
Builder
(
builder:
(
BuildContext
context
)
{
innerMediaQueryPadding
=
MediaQuery
.
of
(
context
).
padding
;
innerMediaQueryPadding
=
MediaQuery
.
of
(
context
)
!
.
padding
;
return
Container
();
}),
],
...
...
@@ -545,7 +543,7 @@ void main() {
// Regression test for https://github.com/flutter/flutter/issues/43380.
final
ScrollController
controller
=
ScrollController
();
Widget
buildListView
({
@required
Axis
scrollDirection
})
{
Widget
buildListView
({
required
Axis
scrollDirection
})
{
assert
(
scrollDirection
!=
null
);
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
...
...
packages/flutter/test/widgets/list_view_vertical_test.dart
View file @
dfc6c438
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
packages/flutter/test/widgets/list_view_viewporting_test.dart
View file @
dfc6c438
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -182,7 +180,7 @@ void main() {
testWidgets
(
'ListView reinvoke builders'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
callbackTracker
=
<
int
>[];
final
List
<
String
>
text
=
<
String
>[];
final
List
<
String
?>
text
=
<
String
?
>[];
final
IndexedWidgetBuilder
itemBuilder
=
(
BuildContext
context
,
int
index
)
{
callbackTracker
.
add
(
index
);
...
...
@@ -232,7 +230,7 @@ void main() {
});
testWidgets
(
'ListView reinvoke builders'
,
(
WidgetTester
tester
)
async
{
StateSetter
setState
;
late
StateSetter
setState
;
ThemeData
themeData
=
ThemeData
.
light
();
final
IndexedWidgetBuilder
itemBuilder
=
(
BuildContext
context
,
int
index
)
{
...
...
@@ -240,7 +238,7 @@ void main() {
key:
ValueKey
<
int
>(
index
),
width:
500.0
,
// this should be ignored
height:
220.0
,
color:
Theme
.
of
(
context
).
primaryColor
,
color:
Theme
.
of
(
context
)
!
.
primaryColor
,
child:
Text
(
'
$index
'
,
textDirection:
TextDirection
.
ltr
),
);
};
...
...
@@ -319,10 +317,10 @@ void main() {
final
RenderSliverList
list
=
tester
.
renderObject
(
find
.
byType
(
SliverList
));
expect
(
list
.
indexOf
(
list
.
firstChild
),
equals
(
0
));
expect
(
list
.
indexOf
(
list
.
lastChild
),
equals
(
2
));
expect
(
list
.
childScrollOffset
(
list
.
firstChild
),
equals
(
0.0
));
expect
(
list
.
geometry
.
scrollExtent
,
equals
(
300.0
));
expect
(
list
.
indexOf
(
list
.
firstChild
!
),
equals
(
0
));
expect
(
list
.
indexOf
(
list
.
lastChild
!
),
equals
(
2
));
expect
(
list
.
childScrollOffset
(
list
.
firstChild
!
),
equals
(
0.0
));
expect
(
list
.
geometry
!
.
scrollExtent
,
equals
(
300.0
));
expect
(
list
,
hasAGoodToStringDeep
);
expect
(
...
...
packages/flutter/test/widgets/list_view_with_inherited_test.dart
View file @
dfc6c438
...
...
@@ -2,22 +2,30 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
List
<
int
>
items
=
<
int
>[
0
,
1
,
2
,
3
,
4
,
5
];
List
<
String
>
items
=
<
String
>[
'one'
,
'two'
,
'three'
,
'four'
,
'five'
,
];
Widget
buildCard
(
BuildContext
context
,
int
index
)
{
if
(
index
>=
items
.
length
)
return
null
;
// We still want to populate the list with items beyond the list
// provided.
if
(
index
>=
items
.
length
)
{
return
const
SizedBox
(
height:
100
);
}
return
Container
(
key:
ValueKey
<
int
>(
items
[
index
]),
key:
ValueKey
<
String
>(
items
[
index
]),
height:
100.0
,
child:
DefaultTextStyle
(
style:
TextStyle
(
fontSize:
2.0
+
items
.
length
.
toDouble
()),
child:
Text
(
'
${items[index]}
'
,
textDirection:
TextDirection
.
ltr
),
child:
Text
(
items
[
index
]
,
textDirection:
TextDirection
.
ltr
),
),
);
}
...
...
@@ -34,15 +42,15 @@ Widget buildFrame() {
void
main
(
)
{
testWidgets
(
'ListView is a build function (smoketest)'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
buildFrame
());
expect
(
find
.
text
(
'
0
'
),
findsOneWidget
);
expect
(
find
.
text
(
'
1
'
),
findsOneWidget
);
expect
(
find
.
text
(
'
2
'
),
findsOneWidget
);
expect
(
find
.
text
(
'
3
'
),
findsOneWidget
);
expect
(
find
.
text
(
'
one
'
),
findsOneWidget
);
expect
(
find
.
text
(
'
two
'
),
findsOneWidget
);
expect
(
find
.
text
(
'
three
'
),
findsOneWidget
);
expect
(
find
.
text
(
'
four
'
),
findsOneWidget
);
items
.
removeAt
(
2
);
await
tester
.
pumpWidget
(
buildFrame
());
expect
(
find
.
text
(
'
0
'
),
findsOneWidget
);
expect
(
find
.
text
(
'
1
'
),
findsOneWidget
);
expect
(
find
.
text
(
'
2
'
),
findsNothing
);
expect
(
find
.
text
(
'
3
'
),
findsOneWidget
);
expect
(
find
.
text
(
'
one
'
),
findsOneWidget
);
expect
(
find
.
text
(
'
two
'
),
findsOneWidget
);
expect
(
find
.
text
(
'
three
'
),
findsNothing
);
expect
(
find
.
text
(
'
four
'
),
findsOneWidget
);
});
}
packages/flutter/test/widgets/list_wheel_scroll_view_test.dart
View file @
dfc6c438
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -65,18 +63,6 @@ void main() {
}
});
testWidgets
(
'ListWheelScrollView needs positive item extent'
,
(
WidgetTester
tester
)
async
{
expect
(
()
{
ListWheelScrollView
(
itemExtent:
null
,
children:
<
Widget
>[
Container
()],
);
},
throwsAssertionError
,
);
});
testWidgets
(
'ListWheelScrollView can have zero child'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
Directionality
(
...
...
@@ -106,17 +92,6 @@ void main() {
});
testWidgets
(
'ListWheelScrollView needs valid overAndUnderCenterOpacity'
,
(
WidgetTester
tester
)
async
{
expect
(
()
{
ListWheelScrollView
(
overAndUnderCenterOpacity:
null
,
itemExtent:
20.0
,
children:
<
Widget
>[
Container
()],
);
},
throwsAssertionError
,
);
expect
(
()
{
ListWheelScrollView
(
...
...
@@ -426,7 +401,7 @@ void main() {
),
);
final
RenderListWheelViewport
viewport
=
tester
.
firstRenderObject
(
find
.
byType
(
Text
)).
parent
.
parent
as
RenderListWheelViewport
;
final
RenderListWheelViewport
viewport
=
tester
.
renderObject
(
find
.
byType
(
ListWheelViewport
))
as
RenderListWheelViewport
;
// Item 0 is in the middle. There are 3 children visible after it, so the
// value of childCount should be 4.
...
...
@@ -463,7 +438,7 @@ void main() {
),
);
final
RenderListWheelViewport
viewport
=
tester
.
firstRenderObject
(
find
.
byType
(
Text
)).
parent
.
parent
as
RenderListWheelViewport
;
final
RenderListWheelViewport
viewport
=
tester
.
renderObject
(
find
.
byType
(
ListWheelViewport
))
as
RenderListWheelViewport
;
// The screen is vertically 600px. Since the middle item is centered,
// half of the first and last items are visible, making 7 children visible.
...
...
@@ -654,7 +629,7 @@ void main() {
),
);
final
RenderListWheelViewport
viewport
=
tester
.
firstRenderObject
(
find
.
byType
(
Container
)).
parent
.
parent
as
RenderListWheelViewport
;
final
RenderListWheelViewport
viewport
=
tester
.
renderObject
(
find
.
byType
(
ListWheelViewport
))
as
RenderListWheelViewport
;
expect
(
viewport
,
paints
..
transform
(
matrix4:
equals
(<
dynamic
>[
1.0
,
0.0
,
0.0
,
0.0
,
...
...
@@ -711,7 +686,7 @@ void main() {
),
);
final
RenderListWheelViewport
viewport
=
tester
.
firstRenderObject
(
find
.
byType
(
Container
)).
parent
.
parent
as
RenderListWheelViewport
;
final
RenderListWheelViewport
viewport
=
tester
.
renderObject
(
find
.
byType
(
ListWheelViewport
))
as
RenderListWheelViewport
;
expect
(
viewport
,
paints
..
transform
(
matrix4:
equals
(<
dynamic
>[
1.0
,
0.0
,
0.0
,
0.0
,
...
...
@@ -832,7 +807,7 @@ void main() {
),
);
final
RenderListWheelViewport
viewport
=
tester
.
firstRenderObject
(
find
.
byType
(
Container
)).
parent
.
parent
as
RenderListWheelViewport
;
final
RenderListWheelViewport
viewport
=
tester
.
renderObject
(
find
.
byType
(
ListWheelViewport
))
as
RenderListWheelViewport
;
expect
(
viewport
,
paints
..
transform
(
matrix4:
equals
(<
dynamic
>[
...
...
@@ -1295,7 +1270,7 @@ void main() {
testWidgets
(
'ListWheelScrollView getOffsetToReveal'
,
(
WidgetTester
tester
)
async
{
List
<
Widget
>
outerChildren
;
final
List
<
Widget
>
innerChildren
=
List
<
Widget
>
(
10
);
final
List
<
Widget
>
innerChildren
=
List
<
Widget
>
.
generate
(
10
,
(
int
index
)
=>
Container
()
);
await
tester
.
pumpWidget
(
Directionality
(
...
...
@@ -1365,7 +1340,7 @@ void main() {
testWidgets
(
'ListWheelScrollView showOnScreen'
,
(
WidgetTester
tester
)
async
{
List
<
Widget
>
outerChildren
;
final
List
<
Widget
>
innerChildren
=
List
<
Widget
>
(
10
);
final
List
<
Widget
>
innerChildren
=
List
<
Widget
>
.
generate
(
10
,
(
int
index
)
=>
Container
()
);
ScrollController
controller
;
await
tester
.
pumpWidget
(
...
...
packages/flutter/test/widgets/listener_test.dart
View file @
dfc6c438
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'dart:math'
as
math
;
import
'package:flutter/material.dart'
;
...
...
packages/flutter/test/widgets/listview_end_append_test.dart
View file @
dfc6c438
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/gestures.dart'
show
DragStartBehavior
;
...
...
packages/flutter/test/widgets/localizations_test.dart
View file @
dfc6c438
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -22,11 +20,11 @@ void main() {
],
child:
const
Text
(
'loaded'
)
));
final
dynamic
state
=
tester
.
state
(
find
.
byType
(
Localizations
));
expect
(
state
.
locale
,
isNull
);
final
dynamic
state
=
tester
.
state
(
find
.
byType
(
Localizations
));
// ignore: unnecessary_nullable_for_final_variable_declarations
expect
(
state
!
.
locale
,
isNull
);
expect
(
find
.
text
(
'loaded'
),
findsNothing
);
Locale
locale
;
late
Locale
locale
;
binding
.
onAllowFrame
=
()
{
locale
=
state
.
locale
as
Locale
;
};
...
...
@@ -53,12 +51,11 @@ class FakeLocalizationsDelegate extends LocalizationsDelegate<String> {
class
TestAutomatedTestWidgetsFlutterBinding
extends
AutomatedTestWidgetsFlutterBinding
{
VoidCallback
onAllowFrame
;
VoidCallback
?
onAllowFrame
;
@override
void
allowFirstFrame
()
{
if
(
onAllowFrame
!=
null
)
onAllowFrame
();
onAllowFrame
?.
call
();
super
.
allowFirstFrame
();
}
}
...
...
packages/flutter/test/widgets/media_query_test.dart
View file @
dfc6c438
This diff is collapsed.
Click to expand it.
packages/flutter/test/widgets/modal_barrier_test.dart
View file @
dfc6c438
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
...
...
@@ -15,10 +13,10 @@ import 'package:flutter/gestures.dart' show kSecondaryButton, PointerDeviceKind;
import
'semantics_tester.dart'
;
void
main
(
)
{
bool
tapped
;
bool
hovered
;
Widget
tapTarget
;
Widget
hoverTarget
;
late
bool
tapped
;
late
bool
hovered
;
late
Widget
tapTarget
;
late
Widget
hoverTarget
;
setUp
(()
{
tapped
=
false
;
...
...
@@ -418,12 +416,12 @@ void main() {
await
tester
.
pump
();
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
basic
);
expect
(
RendererBinding
.
instance
!
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
basic
);
});
}
class
FirstWidget
extends
StatelessWidget
{
const
FirstWidget
({
Key
key
})
:
super
(
key:
key
);
const
FirstWidget
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
return
GestureDetector
(
...
...
@@ -438,7 +436,7 @@ class FirstWidget extends StatelessWidget {
}
class
SecondWidget
extends
StatelessWidget
{
const
SecondWidget
({
Key
key
})
:
super
(
key:
key
);
const
SecondWidget
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
return
const
ModalBarrier
(
...
...
@@ -449,7 +447,7 @@ class SecondWidget extends StatelessWidget {
}
class
SecondWidgetWithCompetence
extends
StatelessWidget
{
const
SecondWidgetWithCompetence
({
Key
key
})
:
super
(
key:
key
);
const
SecondWidgetWithCompetence
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
return
Stack
(
...
...
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