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
18795b47
Unverified
Commit
18795b47
authored
Oct 12, 2020
by
Michael Goderbauer
Committed by
GitHub
Oct 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate some widget tests to NNBD (#67776)
parent
b4e4e8d9
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
145 additions
and
163 deletions
+145
-163
dismissible_test.dart
packages/flutter/test/widgets/dismissible_test.dart
+16
-18
disposable_build_context_test.dart
...s/flutter/test/widgets/disposable_build_context_test.dart
+2
-4
dispose_ancestor_lookup_test.dart
...es/flutter/test/widgets/dispose_ancestor_lookup_test.dart
+1
-3
draggable_scrollable_sheet_test.dart
...flutter/test/widgets/draggable_scrollable_sheet_test.dart
+4
-6
draggable_test.dart
packages/flutter/test/widgets/draggable_test.dart
+67
-69
drawer_test.dart
packages/flutter/test/widgets/drawer_test.dart
+10
-12
dual_transition_builder_test.dart
...es/flutter/test/widgets/dual_transition_builder_test.dart
+9
-11
editable_text_cursor_test.dart
packages/flutter/test/widgets/editable_text_cursor_test.dart
+30
-32
editable_text_show_on_screen_test.dart
...utter/test/widgets/editable_text_show_on_screen_test.dart
+6
-8
No files found.
packages/flutter/test/widgets/dismissible_test.dart
View file @
18795b47
...
...
@@ -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/gestures.dart'
show
DragStartBehavior
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
@@ -12,15 +10,15 @@ import 'package:flutter_test/flutter_test.dart';
const
double
itemExtent
=
100.0
;
Axis
scrollDirection
=
Axis
.
vertical
;
DismissDirection
dismissDirection
=
DismissDirection
.
horizontal
;
DismissDirection
reportedDismissDirection
;
late
DismissDirection
reportedDismissDirection
;
List
<
int
>
dismissedItems
=
<
int
>[];
Widget
background
;
Widget
?
background
;
const
double
crossAxisEndOffset
=
0.5
;
Widget
buildTest
(
{
double
startToEndThreshold
,
double
?
startToEndThreshold
,
TextDirection
textDirection
=
TextDirection
.
ltr
,
Future
<
bool
>
Function
(
BuildContext
context
,
DismissDirection
direction
)
confirmDismiss
,
Future
<
bool
>
Function
(
BuildContext
context
,
DismissDirection
direction
)
?
confirmDismiss
,
})
{
return
Directionality
(
textDirection:
textDirection
,
...
...
@@ -73,9 +71,9 @@ Widget buildTest({
);
}
typedef
DismissMethod
=
Future
<
void
>
Function
(
WidgetTester
tester
,
Finder
finder
,
{
@
required
AxisDirection
gestureDirection
});
typedef
DismissMethod
=
Future
<
void
>
Function
(
WidgetTester
tester
,
Finder
finder
,
{
required
AxisDirection
gestureDirection
});
Future
<
void
>
dismissElement
(
WidgetTester
tester
,
Finder
finder
,
{
@
required
AxisDirection
gestureDirection
})
async
{
Future
<
void
>
dismissElement
(
WidgetTester
tester
,
Finder
finder
,
{
required
AxisDirection
gestureDirection
})
async
{
Offset
downLocation
;
Offset
upLocation
;
switch
(
gestureDirection
)
{
...
...
@@ -110,7 +108,7 @@ Future<void> dismissElement(WidgetTester tester, Finder finder, { @required Axis
await
gesture
.
up
();
}
Future
<
void
>
flingElement
(
WidgetTester
tester
,
Finder
finder
,
{
@
required
AxisDirection
gestureDirection
,
double
initialOffsetFactor
=
0.0
})
async
{
Future
<
void
>
flingElement
(
WidgetTester
tester
,
Finder
finder
,
{
required
AxisDirection
gestureDirection
,
double
initialOffsetFactor
=
0.0
})
async
{
Offset
delta
;
switch
(
gestureDirection
)
{
case
AxisDirection
.
left
:
...
...
@@ -131,7 +129,7 @@ Future<void> flingElement(WidgetTester tester, Finder finder, { @required AxisDi
await
tester
.
fling
(
finder
,
delta
,
1000.0
,
initialOffset:
delta
*
initialOffsetFactor
);
}
Future
<
void
>
flingElementFromZero
(
WidgetTester
tester
,
Finder
finder
,
{
@
required
AxisDirection
gestureDirection
})
async
{
Future
<
void
>
flingElementFromZero
(
WidgetTester
tester
,
Finder
finder
,
{
required
AxisDirection
gestureDirection
})
async
{
// This is a special case where we drag in one direction, then fling back so
// that at the point of release, we're at exactly the point at which we
// started, but with velocity. This is needed to check a boundary condition
...
...
@@ -142,7 +140,7 @@ Future<void> flingElementFromZero(WidgetTester tester, Finder finder, { @require
Future
<
void
>
dismissItem
(
WidgetTester
tester
,
int
item
,
{
@
required
AxisDirection
gestureDirection
,
required
AxisDirection
gestureDirection
,
DismissMethod
mechanism
=
dismissElement
,
})
async
{
assert
(
gestureDirection
!=
null
);
...
...
@@ -161,7 +159,7 @@ Future<void> dismissItem(
Future
<
void
>
checkFlingItemBeforeMovementEnd
(
WidgetTester
tester
,
int
item
,
{
@
required
AxisDirection
gestureDirection
,
required
AxisDirection
gestureDirection
,
DismissMethod
mechanism
=
rollbackElement
,
})
async
{
assert
(
gestureDirection
!=
null
);
...
...
@@ -177,7 +175,7 @@ Future<void> checkFlingItemBeforeMovementEnd(
Future
<
void
>
checkFlingItemAfterMovement
(
WidgetTester
tester
,
int
item
,
{
@
required
AxisDirection
gestureDirection
,
required
AxisDirection
gestureDirection
,
DismissMethod
mechanism
=
rollbackElement
,
})
async
{
assert
(
gestureDirection
!=
null
);
...
...
@@ -190,7 +188,7 @@ Future<void> checkFlingItemAfterMovement(
await
tester
.
pump
(
const
Duration
(
milliseconds:
300
));
}
Future
<
void
>
rollbackElement
(
WidgetTester
tester
,
Finder
finder
,
{
@
required
AxisDirection
gestureDirection
,
double
initialOffsetFactor
=
0.0
})
async
{
Future
<
void
>
rollbackElement
(
WidgetTester
tester
,
Finder
finder
,
{
required
AxisDirection
gestureDirection
,
double
initialOffsetFactor
=
0.0
})
async
{
Offset
delta
;
switch
(
gestureDirection
)
{
case
AxisDirection
.
left
:
...
...
@@ -210,7 +208,7 @@ Future<void> rollbackElement(WidgetTester tester, Finder finder, { @required Axi
}
class
Test1215DismissibleWidget
extends
StatelessWidget
{
const
Test1215DismissibleWidget
(
this
.
text
,
{
Key
key
})
:
super
(
key:
key
);
const
Test1215DismissibleWidget
(
this
.
text
,
{
Key
?
key
})
:
super
(
key:
key
);
final
String
text
;
...
...
@@ -679,9 +677,9 @@ void main() {
testWidgets
(
'confirmDismiss returns values: true, false, null'
,
(
WidgetTester
tester
)
async
{
scrollDirection
=
Axis
.
vertical
;
dismissDirection
=
DismissDirection
.
horizontal
;
DismissDirection
confirmDismissDirection
;
late
DismissDirection
confirmDismissDirection
;
Widget
buildFrame
(
bool
confirmDismissValue
)
{
Widget
buildFrame
(
bool
?
confirmDismissValue
)
{
return
buildTest
(
confirmDismiss:
(
BuildContext
context
,
DismissDirection
dismissDirection
)
{
confirmDismissDirection
=
dismissDirection
;
...
...
@@ -802,7 +800,7 @@ void main() {
testWidgets
(
'Dismissible.behavior should behave correctly during hit testing'
,
(
WidgetTester
tester
)
async
{
bool
didReceivePointerDown
=
false
;
Widget
buildStack
({
Widget
child
})
{
Widget
buildStack
({
required
Widget
child
})
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Stack
(
...
...
packages/flutter/test/widgets/disposable_build_context_test.dart
View file @
18795b47
...
...
@@ -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'
;
...
...
@@ -14,7 +12,7 @@ void main() {
final
GlobalKey
<
TestWidgetState
>
key
=
GlobalKey
<
TestWidgetState
>();
await
tester
.
pumpWidget
(
TestWidget
(
key
));
final
TestWidgetState
state
=
key
.
currentState
;
final
TestWidgetState
state
=
key
.
currentState
!
;
expect
(
state
.
mounted
,
true
);
final
DisposableBuildContext
context
=
DisposableBuildContext
(
state
);
...
...
@@ -35,7 +33,7 @@ void main() {
}
class
TestWidget
extends
StatefulWidget
{
const
TestWidget
(
Key
key
)
:
super
(
key:
key
);
const
TestWidget
(
Key
?
key
)
:
super
(
key:
key
);
@override
State
<
TestWidget
>
createState
()
=>
TestWidgetState
();
...
...
packages/flutter/test/widgets/dispose_ancestor_lookup_test.dart
View file @
18795b47
...
...
@@ -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'
;
typedef
TestCallback
=
void
Function
(
BuildContext
context
);
class
TestWidget
extends
StatefulWidget
{
const
TestWidget
(
this
.
callback
,
{
Key
key
})
:
super
(
key:
key
);
const
TestWidget
(
this
.
callback
,
{
Key
?
key
})
:
super
(
key:
key
);
final
TestCallback
callback
;
...
...
packages/flutter/test/widgets/draggable_scrollable_sheet_test.dart
View file @
18795b47
...
...
@@ -2,22 +2,20 @@
// 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/foundation.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
Widget
_boilerplate
(
VoidCallback
onButtonPressed
,
{
Widget
_boilerplate
(
VoidCallback
?
onButtonPressed
,
{
int
itemCount
=
100
,
double
initialChildSize
=
.
5
,
double
maxChildSize
=
1.0
,
double
minChildSize
=
.
25
,
double
itemExtent
,
Key
containerKey
,
NotificationListenerCallback
<
ScrollNotification
>
onScrollNotification
,
double
?
itemExtent
,
Key
?
containerKey
,
NotificationListenerCallback
<
ScrollNotification
>
?
onScrollNotification
,
})
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
...
...
packages/flutter/test/widgets/draggable_test.dart
View file @
18795b47
...
...
@@ -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/semantics.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/services.dart'
;
...
...
@@ -31,7 +29,7 @@ void main() {
},
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
},
onMove:
(
_
)
=>
moveCount
++,
...
...
@@ -102,22 +100,22 @@ void main() {
feedback:
Text
(
'Dragging'
),
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target 1'
));
},
onLeave:
(
Object
data
)
{
onLeave:
(
Object
?
data
)
{
if
(
data
is
int
)
{
leftBehind
[
'Target 1'
]
=
leftBehind
[
'Target 1'
]
+
data
;
leftBehind
[
'Target 1'
]
=
leftBehind
[
'Target 1'
]
!
+
data
;
}
},
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target 2'
));
},
onLeave:
(
Object
data
)
{
onLeave:
(
Object
?
data
)
{
if
(
data
is
int
)
{
leftBehind
[
'Target 2'
]
=
leftBehind
[
'Target 2'
]
+
data
;
leftBehind
[
'Target 2'
]
=
leftBehind
[
'Target 2'
]
!
+
data
;
}
},
),
...
...
@@ -177,24 +175,24 @@ void main() {
feedback:
Text
(
'Dragging'
),
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target 1'
));
},
onMove:
(
DragTargetDetails
<
dynamic
>
details
)
{
if
(
details
.
data
is
int
)
{
targetMoveCount
[
'Target 1'
]
=
targetMoveCount
[
'Target 1'
]
+
(
details
.
data
as
int
);
targetMoveCount
[
'Target 1'
]
!
+
(
details
.
data
as
int
);
}
},
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target 2'
));
},
onMove:
(
DragTargetDetails
<
dynamic
>
details
)
{
if
(
details
.
data
is
int
)
{
targetMoveCount
[
'Target 2'
]
=
targetMoveCount
[
'Target 2'
]
+
(
details
.
data
as
int
);
targetMoveCount
[
'Target 2'
]
!
+
(
details
.
data
as
int
);
}
},
),
...
...
@@ -263,12 +261,12 @@ void main() {
),
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
IgnorePointer
(
child:
Container
(
child:
const
Text
(
'Target'
)),
);
},
onAccept:
(
int
data
)
{
onAccept:
(
int
?
data
)
{
events
.
add
(
'drop'
);
},
onAcceptWithDetails:
(
DragTargetDetails
<
int
>
_
)
{
...
...
@@ -353,10 +351,10 @@ void main() {
feedback:
const
Text
(
'Dragging'
),
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
const
Text
(
'Target'
);
},
onAccept:
(
int
data
)
{
onAccept:
(
int
?
data
)
{
events
.
add
(
'drop'
);
},
onAcceptWithDetails:
(
DragTargetDetails
<
int
>
_
)
{
...
...
@@ -404,10 +402,10 @@ void main() {
feedback:
Text
(
'Dragging'
),
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
const
Text
(
'Target'
);
},
onAccept:
(
int
data
)
{
onAccept:
(
int
?
data
)
{
events
.
add
(
'drop'
);
},
onAcceptWithDetails:
(
DragTargetDetails
<
int
>
_
)
{
...
...
@@ -453,10 +451,10 @@ void main() {
feedback:
Text
(
'Dragging'
),
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
const
Text
(
'Target'
);
},
onAccept:
(
int
data
)
{
onAccept:
(
int
?
data
)
{
events
.
add
(
'drop'
);
},
onAcceptWithDetails:
(
DragTargetDetails
<
int
>
_
)
{
...
...
@@ -500,10 +498,10 @@ void main() {
dragStartBehavior:
DragStartBehavior
.
down
,
children:
<
Widget
>[
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
const
Text
(
'Target'
);
},
onAccept:
(
int
data
)
{
onAccept:
(
int
?
data
)
{
events
.
add
(
'drop
$data
'
);
},
onAcceptWithDetails:
(
DragTargetDetails
<
int
>
_
)
{
...
...
@@ -611,10 +609,10 @@ void main() {
scrollDirection:
Axis
.
horizontal
,
children:
<
Widget
>[
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
const
Text
(
'Target'
);
},
onAccept:
(
int
data
)
{
onAccept:
(
int
?
data
)
{
events
.
add
(
'drop
$data
'
);
},
onAcceptWithDetails:
(
DragTargetDetails
<
int
>
_
)
{
...
...
@@ -721,10 +719,10 @@ void main() {
scrollDirection:
Axis
.
horizontal
,
children:
<
Widget
>[
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
const
Text
(
'Target'
);
},
onAccept:
(
int
data
)
{
onAccept:
(
int
?
data
)
{
events
.
add
(
'drop
$data
'
);
},
onAcceptWithDetails:
(
DragTargetDetails
<
int
>
_
)
{
...
...
@@ -860,7 +858,7 @@ void main() {
},
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
},
onAccept:
accepted
.
add
,
...
...
@@ -915,8 +913,8 @@ void main() {
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
DragTargetDetails
<
int
>>
acceptedDetails
=
<
DragTargetDetails
<
int
>>[];
bool
onDraggableCanceledCalled
=
false
;
Velocity
onDraggableCanceledVelocity
;
Offset
onDraggableCanceledOffset
;
late
Velocity
onDraggableCanceledVelocity
;
late
Offset
onDraggableCanceledOffset
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Column
(
...
...
@@ -932,13 +930,13 @@ void main() {
},
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
),
);
},
onWillAccept:
(
int
data
)
=>
false
,
onWillAccept:
(
int
?
data
)
=>
false
,
onAccept:
accepted
.
add
,
onAcceptWithDetails:
acceptedDetails
.
add
,
),
...
...
@@ -992,8 +990,8 @@ void main() {
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
DragTargetDetails
<
int
>>
acceptedDetails
=
<
DragTargetDetails
<
int
>>[];
bool
onDraggableCanceledCalled
=
false
;
Velocity
onDraggableCanceledVelocity
;
Offset
onDraggableCanceledOffset
;
late
Velocity
onDraggableCanceledVelocity
;
late
Offset
onDraggableCanceledOffset
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Column
(
children:
<
Widget
>[
...
...
@@ -1008,13 +1006,13 @@ void main() {
},
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
),
);
},
onWillAccept:
(
int
data
)
=>
false
,
onWillAccept:
(
int
?
data
)
=>
false
,
onAccept:
accepted
.
add
,
onAcceptWithDetails:
acceptedDetails
.
add
,
),
...
...
@@ -1047,7 +1045,7 @@ void main() {
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
DragTargetDetails
<
int
>>
acceptedDetails
=
<
DragTargetDetails
<
int
>>[];
bool
onDragEndCalled
=
false
;
DraggableDetails
onDragEndDraggableDetails
;
late
DraggableDetails
onDragEndDraggableDetails
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Column
(
children:
<
Widget
>[
...
...
@@ -1061,13 +1059,13 @@ void main() {
},
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
),
);
},
onWillAccept:
(
int
data
)
=>
false
,
onWillAccept:
(
int
?
data
)
=>
false
,
onAccept:
accepted
.
add
,
onAcceptWithDetails:
acceptedDetails
.
add
,
),
...
...
@@ -1131,7 +1129,7 @@ void main() {
feedback:
Text
(
'Dragging'
),
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
Container
(
height:
100.0
,
child:
rejects
.
isNotEmpty
...
...
@@ -1139,7 +1137,7 @@ void main() {
:
const
Text
(
'Target'
),
);
},
onWillAccept:
(
int
data
)
=>
false
,
onWillAccept:
(
int
?
data
)
=>
false
,
),
],
),
...
...
@@ -1189,7 +1187,7 @@ void main() {
},
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
Container
(
height:
100.0
,
child:
rejects
.
isNotEmpty
...
...
@@ -1197,7 +1195,7 @@ void main() {
:
const
Text
(
'Target'
),
);
},
onWillAccept:
(
int
data
)
=>
false
,
onWillAccept:
(
int
?
data
)
=>
false
,
),
],
),
...
...
@@ -1274,13 +1272,13 @@ void main() {
},
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
),
);
},
onWillAccept:
(
int
data
)
=>
false
,
onWillAccept:
(
int
?
data
)
=>
false
,
onAccept:
accepted
.
add
,
onAcceptWithDetails:
acceptedDetails
.
add
,
),
...
...
@@ -1332,7 +1330,7 @@ void main() {
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
DragTargetDetails
<
int
>>
acceptedDetails
=
<
DragTargetDetails
<
int
>>[];
bool
onDragEndCalled
=
false
;
DraggableDetails
onDragEndDraggableDetails
;
late
DraggableDetails
onDragEndDraggableDetails
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Column
(
children:
<
Widget
>[
...
...
@@ -1346,7 +1344,7 @@ void main() {
},
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
},
onAccept:
accepted
.
add
,
...
...
@@ -1420,10 +1418,10 @@ void main() {
},
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
const
Text
(
'Target'
);
},
onAccept:
(
int
data
)
{
onAccept:
(
int
?
data
)
{
events
.
add
(
'drop'
);
},
onAcceptWithDetails:
(
DragTargetDetails
<
int
>
_
)
{
...
...
@@ -1487,7 +1485,7 @@ void main() {
},
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
},
onAccept:
accepted
.
add
,
...
...
@@ -1560,7 +1558,7 @@ void main() {
Stack
(
children:
<
Widget
>[
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
IgnorePointer
(
child:
Container
(
height:
100.0
,
...
...
@@ -1572,7 +1570,7 @@ void main() {
onAcceptWithDetails:
acceptedIntsDetails
.
add
,
),
DragTarget
<
double
>(
builder:
(
BuildContext
context
,
List
<
double
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
double
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
IgnorePointer
(
child:
Container
(
height:
100.0
,
...
...
@@ -1689,7 +1687,7 @@ void main() {
Stack
(
children:
<
Widget
>[
DragTarget
<
DragTargetData
>(
builder:
(
BuildContext
context
,
List
<
DragTargetData
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
DragTargetData
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
IgnorePointer
(
child:
Container
(
height:
100.0
,
...
...
@@ -1700,7 +1698,7 @@ void main() {
onAcceptWithDetails:
acceptedDragTargetDataDetails
.
add
,
),
DragTarget
<
ExtendedDragTargetData
>(
builder:
(
BuildContext
context
,
List
<
ExtendedDragTargetData
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
ExtendedDragTargetData
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
IgnorePointer
(
child:
Container
(
height:
100.0
,
...
...
@@ -1755,7 +1753,7 @@ void main() {
feedback:
const
Text
(
'Dragging'
),
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
},
onAccept:
accepted
.
add
,
...
...
@@ -1879,7 +1877,7 @@ void main() {
onTap:
()
{
didTap
=
true
;
},
child:
Draggable
<
dynamic
>(
child:
Draggable
<
Object
>(
child:
Container
(
color:
const
Color
(
0xFFFFFF00
),
),
...
...
@@ -1915,7 +1913,7 @@ void main() {
OverlayEntry
(
builder:
(
BuildContext
context
)
=>
GestureDetector
(
onTap:
()
{
/* registers a tap recognizer */
},
child:
Draggable
<
dynamic
>(
child:
Draggable
<
Object
>(
child:
Container
(
color:
const
Color
(
0xFFFFFF00
),
),
...
...
@@ -1952,10 +1950,10 @@ void main() {
feedback:
Text
(
'Dragging'
),
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
const
Text
(
'Target'
);
},
onAccept:
(
int
data
)
{
onAccept:
(
int
?
data
)
{
events
.
add
(
'drop'
);
},
onAcceptWithDetails:
(
DragTargetDetails
<
int
>
_
)
{
...
...
@@ -2014,7 +2012,7 @@ void main() {
feedback:
Text
(
'Dragging'
),
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
},
onAccept:
accepted
.
add
,
...
...
@@ -2044,7 +2042,7 @@ void main() {
home:
Column
(
children:
<
Widget
>[
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
},
onAccept:
accepted
.
add
,
...
...
@@ -2109,7 +2107,7 @@ void main() {
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
DragTargetDetails
<
int
>>
acceptedDetails
=
<
DragTargetDetails
<
int
>>[];
bool
onDragEndCalled
=
false
;
DraggableDetails
onDragEndDraggableDetails
;
late
DraggableDetails
onDragEndDraggableDetails
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Column
(
...
...
@@ -2124,7 +2122,7 @@ void main() {
},
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
},
onAccept:
accepted
.
add
,
...
...
@@ -2209,7 +2207,7 @@ void main() {
},
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
},
onAccept:
accepted
.
add
,
...
...
@@ -2348,7 +2346,7 @@ void main() {
),
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
Container
(
height:
300.0
,
child:
const
Center
(
child:
Text
(
'Target 1'
)),
);
...
...
@@ -2391,7 +2389,7 @@ void main() {
addSemanticIndexes:
false
,
children:
<
Widget
>[
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
const
Text
(
'Target'
);
},
),
...
...
@@ -2544,7 +2542,7 @@ void main() {
});
}
Future
<
void
>
_testLongPressDraggableHapticFeedback
({
WidgetTester
tester
,
bool
hapticFeedbackOnStart
,
int
expectedHapticFeedbackCount
})
async
{
Future
<
void
>
_testLongPressDraggableHapticFeedback
({
required
WidgetTester
tester
,
required
bool
hapticFeedbackOnStart
,
required
int
expectedHapticFeedbackCount
})
async
{
bool
onDragStartedCalled
=
false
;
int
hapticFeedbackCalls
=
0
;
...
...
@@ -2586,7 +2584,7 @@ Future<void> _testLongPressDraggableHapticFeedback({ WidgetTester tester, bool h
expect
(
hapticFeedbackCalls
,
expectedHapticFeedbackCount
);
}
Future
<
void
>
_testChildAnchorFeedbackPosition
({
WidgetTester
tester
,
double
top
=
0.0
,
double
left
=
0.0
})
async
{
Future
<
void
>
_testChildAnchorFeedbackPosition
({
required
WidgetTester
tester
,
double
top
=
0.0
,
double
left
=
0.0
})
async
{
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
DragTargetDetails
<
int
>>
acceptedDetails
=
<
DragTargetDetails
<
int
>>[];
int
dragStartedCount
=
0
;
...
...
@@ -2612,7 +2610,7 @@ Future<void> _testChildAnchorFeedbackPosition({ WidgetTester tester, double top
},
),
DragTarget
<
int
>(
builder:
(
BuildContext
context
,
List
<
int
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
int
?
>
data
,
List
<
dynamic
>
rejects
)
{
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
},
onAccept:
accepted
.
add
,
...
...
packages/flutter/test/widgets/drawer_test.dart
View file @
18795b47
...
...
@@ -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:ui'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -19,7 +17,7 @@ void main() {
testWidgets
(
'Drawer control test'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
<
ScaffoldState
>
scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
BuildContext
savedContext
;
late
BuildContext
savedContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Builder
(
...
...
@@ -36,7 +34,7 @@ void main() {
);
await
tester
.
pump
();
// no effect
expect
(
find
.
text
(
'drawer'
),
findsNothing
);
scaffoldKey
.
currentState
.
openDrawer
();
scaffoldKey
.
currentState
!
.
openDrawer
();
await
tester
.
pump
();
// drawer should be starting to animate in
expect
(
find
.
text
(
'drawer'
),
findsOneWidget
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// animation done
...
...
@@ -61,7 +59,7 @@ void main() {
);
await
tester
.
pump
();
// no effect
expect
(
find
.
text
(
'drawer'
),
findsNothing
);
scaffoldKey
.
currentState
.
openDrawer
();
scaffoldKey
.
currentState
!
.
openDrawer
();
await
tester
.
pump
();
// drawer should be starting to animate in
expect
(
find
.
text
(
'drawer'
),
findsOneWidget
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// animation done
...
...
@@ -120,7 +118,7 @@ void main() {
logs
.
clear
();
// When drawer is open, hover is uninteractable
scaffoldKey
.
currentState
.
openDrawer
();
scaffoldKey
.
currentState
!
.
openDrawer
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// animation done
expect
(
find
.
text
(
'drawer'
),
findsOneWidget
);
...
...
@@ -174,7 +172,7 @@ void main() {
),
);
expect
(
find
.
text
(
'drawer'
),
findsNothing
);
scaffoldKey
.
currentState
.
openDrawer
();
scaffoldKey
.
currentState
!
.
openDrawer
();
await
tester
.
pump
();
// drawer should be starting to animate in
expect
(
find
.
text
(
'drawer'
),
findsOneWidget
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// animation done
...
...
@@ -228,7 +226,7 @@ void main() {
),
);
expect
(
find
.
text
(
'drawer'
),
findsNothing
);
scaffoldKey
.
currentState
.
openDrawer
();
scaffoldKey
.
currentState
!
.
openDrawer
();
await
tester
.
pump
();
// drawer should be starting to animate in
expect
(
find
.
text
(
'drawer'
),
findsOneWidget
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// animation done
...
...
@@ -290,7 +288,7 @@ void main() {
);
// Open the drawer.
scaffoldKey
.
currentState
.
openDrawer
();
scaffoldKey
.
currentState
!
.
openDrawer
();
await
tester
.
pump
();
// drawer should be starting to animate in
expect
(
find
.
text
(
'drawer'
),
findsOneWidget
);
...
...
@@ -324,7 +322,7 @@ void main() {
);
// Open the drawer.
scaffoldKey
.
currentState
.
openDrawer
();
scaffoldKey
.
currentState
!
.
openDrawer
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
expect
(
semantics
,
includesNodeWith
(
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
]));
...
...
@@ -352,7 +350,7 @@ void main() {
);
// Open the drawer.
scaffoldKey
.
currentState
.
openDrawer
();
scaffoldKey
.
currentState
!
.
openDrawer
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
expect
(
semantics
,
isNot
(
includesNodeWith
(
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
])));
...
...
@@ -380,7 +378,7 @@ void main() {
);
// Open the drawer.
scaffoldKey
.
currentState
.
openDrawer
();
scaffoldKey
.
currentState
!
.
openDrawer
();
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
...
...
packages/flutter/test/widgets/dual_transition_builder_test.dart
View file @
18795b47
...
...
@@ -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/widgets.dart'
;
...
...
@@ -23,7 +21,7 @@ void main() {
forwardBuilder:
(
BuildContext
context
,
Animation
<
double
>
animation
,
Widget
child
,
Widget
?
child
,
)
{
return
ScaleTransition
(
scale:
animation
,
...
...
@@ -33,7 +31,7 @@ void main() {
reverseBuilder:
(
BuildContext
context
,
Animation
<
double
>
animation
,
Widget
child
,
Widget
?
child
,
)
{
return
FadeTransition
(
opacity:
Tween
<
double
>(
begin:
1.0
,
end:
0.0
).
animate
(
animation
),
...
...
@@ -93,7 +91,7 @@ void main() {
forwardBuilder:
(
BuildContext
context
,
Animation
<
double
>
animation
,
Widget
child
,
Widget
?
child
,
)
{
return
ScaleTransition
(
scale:
animation
,
...
...
@@ -103,7 +101,7 @@ void main() {
reverseBuilder:
(
BuildContext
context
,
Animation
<
double
>
animation
,
Widget
child
,
Widget
?
child
,
)
{
return
FadeTransition
(
opacity:
Tween
<
double
>(
begin:
1.0
,
end:
0.0
).
animate
(
animation
),
...
...
@@ -155,7 +153,7 @@ void main() {
forwardBuilder:
(
BuildContext
context
,
Animation
<
double
>
animation
,
Widget
child
,
Widget
?
child
,
)
{
return
ScaleTransition
(
scale:
animation
,
...
...
@@ -165,7 +163,7 @@ void main() {
reverseBuilder:
(
BuildContext
context
,
Animation
<
double
>
animation
,
Widget
child
,
Widget
?
child
,
)
{
return
FadeTransition
(
opacity:
Tween
<
double
>(
begin:
1.0
,
end:
0.0
).
animate
(
animation
),
...
...
@@ -221,7 +219,7 @@ void main() {
forwardBuilder:
(
BuildContext
context
,
Animation
<
double
>
animation
,
Widget
child
,
Widget
?
child
,
)
{
return
ScaleTransition
(
scale:
animation
,
...
...
@@ -231,7 +229,7 @@ void main() {
reverseBuilder:
(
BuildContext
context
,
Animation
<
double
>
animation
,
Widget
child
,
Widget
?
child
,
)
{
return
FadeTransition
(
opacity:
Tween
<
double
>(
begin:
1.0
,
end:
0.0
).
animate
(
animation
),
...
...
@@ -286,7 +284,7 @@ double _getOpacity(WidgetTester tester) {
}
class
_StatefulTestWidget
extends
StatefulWidget
{
const
_StatefulTestWidget
({
Key
key
,
this
.
name
})
:
super
(
key:
key
);
const
_StatefulTestWidget
({
Key
?
key
,
required
this
.
name
})
:
super
(
key:
key
);
final
String
name
;
...
...
packages/flutter/test/widgets/editable_text_cursor_test.dart
View file @
18795b47
...
...
@@ -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/foundation.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -46,13 +44,13 @@ void main() {
final
EditableText
editableText
=
tester
.
firstWidget
(
find
.
byType
(
EditableText
));
expect
(
editableText
.
cursorWidth
,
10.0
);
expect
(
editableText
.
cursorHeight
,
10.0
);
expect
(
editableText
.
cursorRadius
.
x
,
2.0
);
expect
(
editableText
.
cursorRadius
!
.
x
,
2.0
);
});
testWidgets
(
'cursor layout has correct width'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
<
EditableTextState
>
editableTextKey
=
GlobalKey
<
EditableTextState
>();
String
changedValue
;
late
String
changedValue
;
final
Widget
widget
=
MaterialApp
(
home:
RepaintBoundary
(
key:
const
ValueKey
<
int
>(
1
),
...
...
@@ -61,7 +59,7 @@ void main() {
key:
editableTextKey
,
controller:
TextEditingController
(),
focusNode:
FocusNode
(),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
selectionControls:
materialTextSelectionControls
,
keyboardType:
TextInputType
.
text
,
...
...
@@ -103,7 +101,7 @@ void main() {
testWidgets
(
'cursor layout has correct radius'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
<
EditableTextState
>
editableTextKey
=
GlobalKey
<
EditableTextState
>();
String
changedValue
;
late
String
changedValue
;
final
Widget
widget
=
MaterialApp
(
home:
RepaintBoundary
(
key:
const
ValueKey
<
int
>(
1
),
...
...
@@ -112,7 +110,7 @@ void main() {
key:
editableTextKey
,
controller:
TextEditingController
(),
focusNode:
FocusNode
(),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
selectionControls:
materialTextSelectionControls
,
keyboardType:
TextInputType
.
text
,
...
...
@@ -167,43 +165,43 @@ void main() {
final
EditableTextState
editableTextState
=
tester
.
firstState
(
find
.
byType
(
EditableText
));
final
RenderEditable
renderEditable
=
editableTextState
.
renderEditable
;
expect
(
renderEditable
.
cursorColor
.
alpha
,
255
);
expect
(
renderEditable
.
cursorColor
!
.
alpha
,
255
);
// Trigger initial timer. When focusing the first time, the cursor shows
// for slightly longer than the average on time.
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
200
));
// Start timing standard cursor show period.
expect
(
renderEditable
.
cursorColor
.
alpha
,
255
);
expect
(
renderEditable
.
cursorColor
!
.
alpha
,
255
);
expect
(
renderEditable
,
paints
..
rrect
(
color:
const
Color
(
0xff2196f3
)));
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
// Start to animate the cursor away.
expect
(
renderEditable
.
cursorColor
.
alpha
,
255
);
expect
(
renderEditable
.
cursorColor
!
.
alpha
,
255
);
expect
(
renderEditable
,
paints
..
rrect
(
color:
const
Color
(
0xff2196f3
)));
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
expect
(
renderEditable
.
cursorColor
.
alpha
,
110
);
expect
(
renderEditable
.
cursorColor
!
.
alpha
,
110
);
expect
(
renderEditable
,
paints
..
rrect
(
color:
const
Color
(
0x6e2196f3
)));
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
expect
(
renderEditable
.
cursorColor
.
alpha
,
16
);
expect
(
renderEditable
.
cursorColor
!
.
alpha
,
16
);
expect
(
renderEditable
,
paints
..
rrect
(
color:
const
Color
(
0x102196f3
)));
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
expect
(
renderEditable
.
cursorColor
.
alpha
,
0
);
expect
(
renderEditable
.
cursorColor
!
.
alpha
,
0
);
// Don't try to draw the cursor.
expect
(
renderEditable
,
paintsExactlyCountTimes
(
#drawRRect
,
0
));
// Wait some more while the cursor is gone. It'll trigger the cursor to
// start animating in again.
await
tester
.
pump
(
const
Duration
(
milliseconds:
300
));
expect
(
renderEditable
.
cursorColor
.
alpha
,
0
);
expect
(
renderEditable
.
cursorColor
!
.
alpha
,
0
);
expect
(
renderEditable
,
paintsExactlyCountTimes
(
#drawRRect
,
0
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
50
));
// Cursor starts coming back.
expect
(
renderEditable
.
cursorColor
.
alpha
,
79
);
expect
(
renderEditable
.
cursorColor
!
.
alpha
,
79
);
expect
(
renderEditable
,
paints
..
rrect
(
color:
const
Color
(
0x4f2196f3
)));
},
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
iOS
,
TargetPlatform
.
macOS
}));
...
...
@@ -225,25 +223,25 @@ void main() {
final
RenderEditable
renderEditable
=
editableTextState
.
renderEditable
;
await
tester
.
pump
();
expect
(
renderEditable
.
cursorColor
.
alpha
,
255
);
expect
(
renderEditable
.
cursorColor
!
.
alpha
,
255
);
expect
(
renderEditable
,
paints
..
rect
(
color:
defaultCursorColor
));
// Android cursor goes from exactly on to exactly off on the 500ms dot.
await
tester
.
pump
(
const
Duration
(
milliseconds:
499
));
expect
(
renderEditable
.
cursorColor
.
alpha
,
255
);
expect
(
renderEditable
.
cursorColor
!
.
alpha
,
255
);
expect
(
renderEditable
,
paints
..
rect
(
color:
defaultCursorColor
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
1
));
expect
(
renderEditable
.
cursorColor
.
alpha
,
0
);
expect
(
renderEditable
.
cursorColor
!
.
alpha
,
0
);
// Don't try to draw the cursor.
expect
(
renderEditable
,
paintsExactlyCountTimes
(
#drawRect
,
0
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
expect
(
renderEditable
.
cursorColor
.
alpha
,
255
);
expect
(
renderEditable
.
cursorColor
!
.
alpha
,
255
);
expect
(
renderEditable
,
paints
..
rect
(
color:
defaultCursorColor
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
expect
(
renderEditable
.
cursorColor
.
alpha
,
0
);
expect
(
renderEditable
.
cursorColor
!
.
alpha
,
0
);
expect
(
renderEditable
,
paintsExactlyCountTimes
(
#drawRect
,
0
));
});
...
...
@@ -265,21 +263,21 @@ void main() {
final
EditableTextState
editableTextState
=
tester
.
firstState
(
find
.
byType
(
EditableText
));
final
RenderEditable
renderEditable
=
editableTextState
.
renderEditable
;
expect
(
renderEditable
.
cursorColor
.
alpha
,
255
);
expect
(
renderEditable
.
cursorColor
!
.
alpha
,
255
);
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
200
));
expect
(
renderEditable
.
cursorColor
.
alpha
,
255
);
expect
(
renderEditable
.
cursorColor
!
.
alpha
,
255
);
expect
(
renderEditable
,
paints
..
rrect
(
color:
defaultCursorColor
));
// Cursor draw never changes.
await
tester
.
pump
(
const
Duration
(
milliseconds:
200
));
expect
(
renderEditable
.
cursorColor
.
alpha
,
255
);
expect
(
renderEditable
.
cursorColor
!
.
alpha
,
255
);
expect
(
renderEditable
,
paints
..
rrect
(
color:
defaultCursorColor
));
// No more transient calls.
await
tester
.
pumpAndSettle
();
expect
(
renderEditable
.
cursorColor
.
alpha
,
255
);
expect
(
renderEditable
.
cursorColor
!
.
alpha
,
255
);
expect
(
renderEditable
,
paints
..
rrect
(
color:
defaultCursorColor
));
EditableText
.
debugDeterministicCursor
=
false
;
...
...
@@ -304,21 +302,21 @@ void main() {
final
RenderEditable
renderEditable
=
editableTextState
.
renderEditable
;
await
tester
.
pump
();
expect
(
renderEditable
.
cursorColor
.
alpha
,
255
);
expect
(
renderEditable
.
cursorColor
!
.
alpha
,
255
);
expect
(
renderEditable
,
paints
..
rect
(
color:
defaultCursorColor
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
expect
(
renderEditable
.
cursorColor
.
alpha
,
255
);
expect
(
renderEditable
.
cursorColor
!
.
alpha
,
255
);
expect
(
renderEditable
,
paints
..
rect
(
color:
defaultCursorColor
));
// Cursor draw never changes.
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
expect
(
renderEditable
.
cursorColor
.
alpha
,
255
);
expect
(
renderEditable
.
cursorColor
!
.
alpha
,
255
);
expect
(
renderEditable
,
paints
..
rect
(
color:
defaultCursorColor
));
// No more transient calls.
await
tester
.
pumpAndSettle
();
expect
(
renderEditable
.
cursorColor
.
alpha
,
255
);
expect
(
renderEditable
.
cursorColor
!
.
alpha
,
255
);
expect
(
renderEditable
,
paints
..
rect
(
color:
defaultCursorColor
));
EditableText
.
debugDeterministicCursor
=
false
;
...
...
@@ -716,7 +714,7 @@ void main() {
testWidgets
(
'cursor layout'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
<
EditableTextState
>
editableTextKey
=
GlobalKey
<
EditableTextState
>();
String
changedValue
;
late
String
changedValue
;
final
Widget
widget
=
MaterialApp
(
home:
RepaintBoundary
(
key:
const
ValueKey
<
int
>(
1
),
...
...
@@ -728,7 +726,7 @@ void main() {
key:
editableTextKey
,
controller:
TextEditingController
(),
focusNode:
FocusNode
(),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
iOS
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
iOS
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
selectionControls:
materialTextSelectionControls
,
keyboardType:
TextInputType
.
text
,
...
...
@@ -772,7 +770,7 @@ void main() {
testWidgets
(
'cursor layout has correct height'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
<
EditableTextState
>
editableTextKey
=
GlobalKey
<
EditableTextState
>();
String
changedValue
;
late
String
changedValue
;
final
Widget
widget
=
MaterialApp
(
home:
RepaintBoundary
(
key:
const
ValueKey
<
int
>(
1
),
...
...
@@ -784,7 +782,7 @@ void main() {
key:
editableTextKey
,
controller:
TextEditingController
(),
focusNode:
FocusNode
(),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
iOS
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
iOS
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
selectionControls:
materialTextSelectionControls
,
keyboardType:
TextInputType
.
text
,
...
...
packages/flutter/test/widgets/editable_text_show_on_screen_test.dart
View file @
18795b47
...
...
@@ -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_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
...
...
@@ -12,9 +10,9 @@ import 'package:flutter/services.dart';
class
_TestSliverPersistentHeaderDelegate
extends
SliverPersistentHeaderDelegate
{
_TestSliverPersistentHeaderDelegate
({
this
.
minExtent
,
this
.
maxExtent
,
this
.
child
,
required
this
.
minExtent
,
required
this
.
maxExtent
,
required
this
.
child
,
this
.
vsync
=
const
TestVSync
(),
this
.
showOnScreenConfiguration
=
const
PersistentHeaderShowOnScreenConfiguration
(),
});
...
...
@@ -28,7 +26,7 @@ class _TestSliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate
final
double
minExtent
;
@override
final
TickerProvider
vsync
;
final
TickerProvider
?
vsync
;
@override
final
PersistentHeaderShowOnScreenConfiguration
showOnScreenConfiguration
;
...
...
@@ -496,13 +494,13 @@ void main() {
}
class
NoImplicitScrollPhysics
extends
AlwaysScrollableScrollPhysics
{
const
NoImplicitScrollPhysics
({
ScrollPhysics
parent
})
:
super
(
parent:
parent
);
const
NoImplicitScrollPhysics
({
ScrollPhysics
?
parent
})
:
super
(
parent:
parent
);
@override
bool
get
allowImplicitScrolling
=>
false
;
@override
NoImplicitScrollPhysics
applyTo
(
ScrollPhysics
ancestor
)
{
NoImplicitScrollPhysics
applyTo
(
ScrollPhysics
?
ancestor
)
{
return
NoImplicitScrollPhysics
(
parent:
buildParent
(
ancestor
));
}
}
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