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
658710b6
Unverified
Commit
658710b6
authored
Sep 18, 2023
by
Polina Cherkasova
Committed by
GitHub
Sep 18, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cover more tests with leak tracking. (#134805)
parent
56cbf3e1
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
215 additions
and
146 deletions
+215
-146
activity_indicator_test.dart
packages/flutter/test/cupertino/activity_indicator_test.dart
+8
-7
adaptive_text_selection_toolbar_test.dart
.../test/cupertino/adaptive_text_selection_toolbar_test.dart
+12
-7
app_test.dart
packages/flutter/test/cupertino/app_test.dart
+52
-27
bottom_tab_bar_test.dart
packages/flutter/test/cupertino/bottom_tab_bar_test.dart
+16
-15
button_test.dart
packages/flutter/test/cupertino/button_test.dart
+16
-15
checkbox_test.dart
packages/flutter/test/cupertino/checkbox_test.dart
+8
-7
app_test.dart
packages/flutter/test/material/app_test.dart
+36
-10
calendar_date_picker_test.dart
...ages/flutter/test/material/calendar_date_picker_test.dart
+41
-41
chip_test.dart
packages/flutter/test/material/chip_test.dart
+13
-4
undo_history_test.dart
packages/flutter/test/widgets/undo_history_test.dart
+13
-13
No files found.
packages/flutter/test/cupertino/activity_indicator_test.dart
View file @
658710b6
...
...
@@ -10,9 +10,10 @@ library;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/scheduler.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'
;
void
main
(
)
{
testWidgets
(
'Activity indicator animate property works'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Activity indicator animate property works'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
buildCupertinoActivityIndicator
());
expect
(
SchedulerBinding
.
instance
.
transientCallbackCount
,
equals
(
1
));
...
...
@@ -28,7 +29,7 @@ void main() {
expect
(
SchedulerBinding
.
instance
.
transientCallbackCount
,
equals
(
1
));
});
testWidgets
(
'Activity indicator dark mode'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Activity indicator dark mode'
,
(
WidgetTester
tester
)
async
{
final
Key
key
=
UniqueKey
();
await
tester
.
pumpWidget
(
Center
(
...
...
@@ -77,7 +78,7 @@ void main() {
);
});
testWidgets
(
'Activity indicator 0% in progress'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Activity indicator 0% in progress'
,
(
WidgetTester
tester
)
async
{
final
Key
key
=
UniqueKey
();
await
tester
.
pumpWidget
(
Center
(
...
...
@@ -99,7 +100,7 @@ void main() {
);
});
testWidgets
(
'Activity indicator 30% in progress'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Activity indicator 30% in progress'
,
(
WidgetTester
tester
)
async
{
final
Key
key
=
UniqueKey
();
await
tester
.
pumpWidget
(
Center
(
...
...
@@ -121,7 +122,7 @@ void main() {
);
});
testWidgets
(
'Activity indicator 100% in progress'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Activity indicator 100% in progress'
,
(
WidgetTester
tester
)
async
{
final
Key
key
=
UniqueKey
();
await
tester
.
pumpWidget
(
Center
(
...
...
@@ -142,7 +143,7 @@ void main() {
});
// Regression test for https://github.com/flutter/flutter/issues/41345.
testWidgets
(
'has the correct corner radius'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'has the correct corner radius'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
CupertinoActivityIndicator
(
animating:
false
,
radius:
100
),
);
...
...
@@ -158,7 +159,7 @@ void main() {
);
});
testWidgets
(
'Can specify color'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Can specify color'
,
(
WidgetTester
tester
)
async
{
final
Key
key
=
UniqueKey
();
await
tester
.
pumpWidget
(
Center
(
...
...
packages/flutter/test/cupertino/adaptive_text_selection_toolbar_test.dart
View file @
658710b6
...
...
@@ -6,6 +6,7 @@ import 'package:flutter/cupertino.dart';
import
'package:flutter/foundation.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'
;
import
'../widgets/clipboard_utils.dart'
;
import
'../widgets/live_text_utils.dart'
;
...
...
@@ -37,7 +38,7 @@ void main() {
);
}
testWidgets
(
'Builds the right toolbar on each platform, including web, and shows buttonItems'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Builds the right toolbar on each platform, including web, and shows buttonItems'
,
(
WidgetTester
tester
)
async
{
const
String
buttonText
=
'Click me'
;
await
tester
.
pumpWidget
(
...
...
@@ -78,7 +79,7 @@ void main() {
skip:
isBrowser
,
// [intended] see https://github.com/flutter/flutter/issues/108382
);
testWidgets
(
'Can build children directly as well'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Can build children directly as well'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
key
=
GlobalKey
();
await
tester
.
pumpWidget
(
...
...
@@ -101,17 +102,21 @@ void main() {
skip:
isBrowser
,
// [intended] see https://github.com/flutter/flutter/issues/108382
);
testWidgets
(
'Can build from EditableTextState'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Can build from EditableTextState'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
key
=
GlobalKey
();
final
FocusNode
focusNode
=
FocusNode
();
addTearDown
(
focusNode
.
dispose
);
final
TextEditingController
controller
=
TextEditingController
();
addTearDown
(
controller
.
dispose
);
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
Align
(
alignment:
Alignment
.
topLeft
,
child:
SizedBox
(
width:
400
,
child:
EditableText
(
controller:
TextEditingController
()
,
controller:
controller
,
backgroundCursorColor:
const
Color
(
0xff00ffff
),
focusNode:
FocusNode
()
,
focusNode:
focusNode
,
style:
const
TextStyle
(),
cursorColor:
const
Color
(
0xff00ffff
),
selectionControls:
cupertinoTextSelectionHandleControls
,
...
...
@@ -160,7 +165,7 @@ void main() {
variant:
TargetPlatformVariant
.
all
(),
);
testWidgets
(
'Can build for editable text from raw parameters'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Can build for editable text from raw parameters'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
key
=
GlobalKey
();
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
Center
(
...
...
@@ -210,7 +215,7 @@ void main() {
variant:
TargetPlatformVariant
.
all
(),
);
testWidgets
(
'Builds the correct button per-platform'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Builds the correct button per-platform'
,
(
WidgetTester
tester
)
async
{
const
String
buttonText
=
'Click me'
;
await
tester
.
pumpWidget
(
...
...
packages/flutter/test/cupertino/app_test.dart
View file @
658710b6
This diff is collapsed.
Click to expand it.
packages/flutter/test/cupertino/bottom_tab_bar_test.dart
View file @
658710b6
...
...
@@ -7,6 +7,7 @@ import 'package:flutter/foundation.dart';
import
'package:flutter/gestures.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'
;
import
'../image_data.dart'
;
import
'../widgets/semantics_tester.dart'
;
...
...
@@ -29,7 +30,7 @@ Future<void> pumpWidgetWithBoilerplate(WidgetTester tester, Widget widget) async
Future
<
void
>
main
()
async
{
testWidgets
(
'Need at least 2 tabs'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Need at least 2 tabs'
,
(
WidgetTester
tester
)
async
{
await
expectLater
(
()
=>
pumpWidgetWithBoilerplate
(
tester
,
CupertinoTabBar
(
items:
<
BottomNavigationBarItem
>[
...
...
@@ -47,7 +48,7 @@ Future<void> main() async {
);
});
testWidgets
(
'Active and inactive colors'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Active and inactive colors'
,
(
WidgetTester
tester
)
async
{
await
pumpWidgetWithBoilerplate
(
tester
,
MediaQuery
(
data:
const
MediaQueryData
(),
child:
CupertinoTabBar
(
...
...
@@ -81,7 +82,7 @@ Future<void> main() async {
});
testWidgets
(
'BottomNavigationBar.label will create a text widget'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'BottomNavigationBar.label will create a text widget'
,
(
WidgetTester
tester
)
async
{
await
pumpWidgetWithBoilerplate
(
tester
,
MediaQuery
(
data:
const
MediaQueryData
(),
child:
CupertinoTabBar
(
...
...
@@ -103,7 +104,7 @@ Future<void> main() async {
expect
(
find
.
text
(
'Tab 2'
),
findsOneWidget
);
});
testWidgets
(
'Active and inactive colors dark mode'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Active and inactive colors dark mode'
,
(
WidgetTester
tester
)
async
{
const
CupertinoDynamicColor
dynamicActiveColor
=
CupertinoDynamicColor
.
withBrightness
(
color:
Color
(
0xFF000000
),
darkColor:
Color
(
0xFF000001
),
...
...
@@ -191,7 +192,7 @@ Future<void> main() async {
expect
(
decoration2
.
border
!.
top
.
color
.
value
,
0x29000000
);
});
testWidgets
(
'Tabs respects themes'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Tabs respects themes'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
CupertinoTabBar
(
...
...
@@ -255,7 +256,7 @@ Future<void> main() async {
expect
(
actualActive
.
text
.
style
!.
color
,
isSameColorAs
(
CupertinoColors
.
activeBlue
.
darkColor
));
});
testWidgets
(
'Use active icon'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Use active icon'
,
(
WidgetTester
tester
)
async
{
final
MemoryImage
activeIcon
=
MemoryImage
(
Uint8List
.
fromList
(
kBlueSquarePng
));
final
MemoryImage
inactiveIcon
=
MemoryImage
(
Uint8List
.
fromList
(
kTransparentImage
));
...
...
@@ -288,7 +289,7 @@ Future<void> main() async {
expect
(
image
.
image
,
activeIcon
);
});
testWidgets
(
'Adjusts height to account for bottom padding'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Adjusts height to account for bottom padding'
,
(
WidgetTester
tester
)
async
{
final
CupertinoTabBar
tabBar
=
CupertinoTabBar
(
items:
<
BottomNavigationBarItem
>[
BottomNavigationBarItem
(
...
...
@@ -327,7 +328,7 @@ Future<void> main() async {
expect
(
tester
.
getSize
(
find
.
byType
(
CupertinoTabBar
)).
height
,
90.0
);
});
testWidgets
(
'Set custom height'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Set custom height'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/51704
const
double
tabBarHeight
=
56.0
;
final
CupertinoTabBar
tabBar
=
CupertinoTabBar
(
...
...
@@ -370,7 +371,7 @@ Future<void> main() async {
expect
(
tester
.
getSize
(
find
.
byType
(
CupertinoTabBar
)).
height
,
tabBarHeight
+
bottomPadding
);
});
testWidgets
(
'Ensure bar height will not change when toggle keyboard'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Ensure bar height will not change when toggle keyboard'
,
(
WidgetTester
tester
)
async
{
const
double
tabBarHeight
=
56.0
;
final
CupertinoTabBar
tabBar
=
CupertinoTabBar
(
height:
tabBarHeight
,
...
...
@@ -424,7 +425,7 @@ Future<void> main() async {
expect
(
tester
.
getSize
(
find
.
byType
(
CupertinoTabBar
)).
height
,
tabBarHeight
+
bottomPadding
);
});
testWidgets
(
'Opaque background does not add blur effects'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Opaque background does not add blur effects'
,
(
WidgetTester
tester
)
async
{
await
pumpWidgetWithBoilerplate
(
tester
,
MediaQuery
(
data:
const
MediaQueryData
(),
child:
CupertinoTabBar
(
...
...
@@ -463,7 +464,7 @@ Future<void> main() async {
expect
(
find
.
byType
(
BackdropFilter
),
findsNothing
);
});
testWidgets
(
'Tap callback'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Tap callback'
,
(
WidgetTester
tester
)
async
{
late
int
callbackTab
;
await
pumpWidgetWithBoilerplate
(
tester
,
MediaQuery
(
...
...
@@ -491,7 +492,7 @@ Future<void> main() async {
expect
(
callbackTab
,
1
);
});
testWidgets
(
'tabs announce semantics'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'tabs announce semantics'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
await
pumpWidgetWithBoilerplate
(
tester
,
MediaQuery
(
...
...
@@ -526,7 +527,7 @@ Future<void> main() async {
semantics
.
dispose
();
});
testWidgets
(
'Label of items should be nullable'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Label of items should be nullable'
,
(
WidgetTester
tester
)
async
{
final
MemoryImage
iconProvider
=
MemoryImage
(
Uint8List
.
fromList
(
kTransparentImage
));
final
List
<
int
>
itemsTapped
=
<
int
>[];
...
...
@@ -563,7 +564,7 @@ Future<void> main() async {
expect
(
itemsTapped
,
<
int
>[
1
]);
});
testWidgets
(
'Hide border hides the top border of the tabBar'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Hide border hides the top border of the tabBar'
,
(
WidgetTester
tester
)
async
{
await
pumpWidgetWithBoilerplate
(
tester
,
MediaQuery
(
...
...
@@ -623,7 +624,7 @@ Future<void> main() async {
expect
(
boxDecorationHiddenBorder
.
border
,
isNull
);
});
testWidgets
(
'Hovering over tab bar item updates cursor to clickable on Web'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Hovering over tab bar item updates cursor to clickable on Web'
,
(
WidgetTester
tester
)
async
{
await
pumpWidgetWithBoilerplate
(
tester
,
MediaQuery
(
...
...
packages/flutter/test/cupertino/button_test.dart
View file @
658710b6
...
...
@@ -8,6 +8,7 @@ import 'package:flutter/gestures.dart';
import
'package:flutter/rendering.dart'
;
import
'package:flutter/scheduler.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'
;
import
'../widgets/semantics_tester.dart'
;
...
...
@@ -17,7 +18,7 @@ const TextStyle testStyle = TextStyle(
);
void
main
(
)
{
testWidgets
(
'Default layout minimum size'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Default layout minimum size'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
boilerplate
(
child:
const
CupertinoButton
(
onPressed:
null
,
...
...
@@ -32,7 +33,7 @@ void main() {
);
});
testWidgets
(
'Minimum size parameter'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Minimum size parameter'
,
(
WidgetTester
tester
)
async
{
const
double
minSize
=
60.0
;
await
tester
.
pumpWidget
(
boilerplate
(
child:
const
CupertinoButton
(
...
...
@@ -49,7 +50,7 @@ void main() {
);
});
testWidgets
(
'Size grows with text'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Size grows with text'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
boilerplate
(
child:
const
CupertinoButton
(
onPressed:
null
,
...
...
@@ -102,7 +103,7 @@ void main() {
});
*/
testWidgets
(
'Button child alignment'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Button child alignment'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
CupertinoButton
(
...
...
@@ -129,7 +130,7 @@ void main() {
expect
(
align
.
alignment
,
Alignment
.
centerLeft
);
});
testWidgets
(
'Button with background is wider'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Button with background is wider'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
boilerplate
(
child:
const
CupertinoButton
(
onPressed:
null
,
color:
Color
(
0xFFFFFFFF
),
...
...
@@ -143,7 +144,7 @@ void main() {
);
});
testWidgets
(
'Custom padding'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Custom padding'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
boilerplate
(
child:
const
CupertinoButton
(
onPressed:
null
,
padding:
EdgeInsets
.
all
(
100.0
),
...
...
@@ -156,7 +157,7 @@ void main() {
);
});
testWidgets
(
'Button takes taps'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Button takes taps'
,
(
WidgetTester
tester
)
async
{
bool
value
=
false
;
await
tester
.
pumpWidget
(
StatefulBuilder
(
...
...
@@ -195,7 +196,7 @@ void main() {
expect
(
SchedulerBinding
.
instance
.
transientCallbackCount
,
equals
(
0
));
});
testWidgets
(
'Enabled button animates'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Enabled button animates'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
boilerplate
(
child:
CupertinoButton
(
child:
const
Text
(
'Tap me'
),
onPressed:
()
{
},
...
...
@@ -231,7 +232,7 @@ void main() {
expect
(
transition
.
opacity
.
value
,
moreOrLessEquals
(
1.0
,
epsilon:
0.001
));
});
testWidgets
(
'pressedOpacity defaults to 0.1'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'pressedOpacity defaults to 0.1'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
boilerplate
(
child:
CupertinoButton
(
child:
const
Text
(
'Tap me'
),
onPressed:
()
{
},
...
...
@@ -250,7 +251,7 @@ void main() {
expect
(
opacity
.
opacity
.
value
,
0.4
);
});
testWidgets
(
'pressedOpacity parameter'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'pressedOpacity parameter'
,
(
WidgetTester
tester
)
async
{
const
double
pressedOpacity
=
0.5
;
await
tester
.
pumpWidget
(
boilerplate
(
child:
CupertinoButton
(
pressedOpacity:
pressedOpacity
,
...
...
@@ -271,7 +272,7 @@ void main() {
expect
(
opacity
.
opacity
.
value
,
pressedOpacity
);
});
testWidgets
(
'Cupertino button is semantically a button'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Cupertino button is semantically a button'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
await
tester
.
pumpWidget
(
boilerplate
(
...
...
@@ -302,7 +303,7 @@ void main() {
semantics
.
dispose
();
});
testWidgets
(
'Can specify colors'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Can specify colors'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
boilerplate
(
child:
CupertinoButton
(
color:
const
Color
(
0x000000FF
),
disabledColor:
const
Color
(
0x0000FF00
),
...
...
@@ -330,7 +331,7 @@ void main() {
expect
(
boxDecoration
.
color
,
const
Color
(
0x0000FF00
));
});
testWidgets
(
'Can specify dynamic colors'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Can specify dynamic colors'
,
(
WidgetTester
tester
)
async
{
const
Color
bgColor
=
CupertinoDynamicColor
.
withBrightness
(
color:
Color
(
0xFF123456
),
darkColor:
Color
(
0xFF654321
),
...
...
@@ -379,7 +380,7 @@ void main() {
expect
(
boxDecoration
.
color
!.
value
,
0xFF111111
);
});
testWidgets
(
'Button respects themes'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Button respects themes'
,
(
WidgetTester
tester
)
async
{
late
TextStyle
textStyle
;
await
tester
.
pumpWidget
(
...
...
@@ -453,7 +454,7 @@ void main() {
expect
(
decoration
.
color
,
isSameColorAs
(
CupertinoColors
.
systemBlue
.
darkColor
));
});
testWidgets
(
'Hovering over Cupertino button updates cursor to clickable on Web'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Hovering over Cupertino button updates cursor to clickable on Web'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
Center
(
...
...
packages/flutter/test/cupertino/checkbox_test.dart
View file @
658710b6
...
...
@@ -7,6 +7,7 @@ import 'package:flutter/foundation.dart';
import
'package:flutter/rendering.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'
;
import
'../widgets/semantics_tester.dart'
;
...
...
@@ -15,7 +16,7 @@ void main() {
debugResetSemanticsIdCounter
();
});
testWidgets
(
'CupertinoCheckbox semantics'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'CupertinoCheckbox semantics'
,
(
WidgetTester
tester
)
async
{
final
SemanticsHandle
handle
=
tester
.
ensureSemantics
();
await
tester
.
pumpWidget
(
...
...
@@ -155,7 +156,7 @@ void main() {
handle
.
dispose
();
});
testWidgets
(
'Can wrap CupertinoCheckbox with Semantics'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Can wrap CupertinoCheckbox with Semantics'
,
(
WidgetTester
tester
)
async
{
final
SemanticsHandle
handle
=
tester
.
ensureSemantics
();
await
tester
.
pumpWidget
(
...
...
@@ -183,7 +184,7 @@ void main() {
handle
.
dispose
();
});
testWidgets
(
'CupertinoCheckbox tristate: true'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'CupertinoCheckbox tristate: true'
,
(
WidgetTester
tester
)
async
{
bool
?
checkBoxValue
;
await
tester
.
pumpWidget
(
...
...
@@ -227,7 +228,7 @@ void main() {
expect
(
checkBoxValue
,
null
);
});
testWidgets
(
'has semantics for tristate'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'has semantics for tristate'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
await
tester
.
pumpWidget
(
CupertinoApp
(
...
...
@@ -294,7 +295,7 @@ void main() {
semantics
.
dispose
();
});
testWidgets
(
'has semantic events'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'has semantic events'
,
(
WidgetTester
tester
)
async
{
dynamic
semanticEvent
;
bool
?
checkboxValue
=
false
;
tester
.
binding
.
defaultBinaryMessenger
.
setMockDecodedMessageHandler
<
dynamic
>(
SystemChannels
.
accessibility
,
(
dynamic
message
)
async
{
...
...
@@ -334,7 +335,7 @@ void main() {
semanticsTester
.
dispose
();
});
testWidgets
(
'Checkbox can be toggled by keyboard shortcuts'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Checkbox can be toggled by keyboard shortcuts'
,
(
WidgetTester
tester
)
async
{
tester
.
binding
.
focusManager
.
highlightStrategy
=
FocusHighlightStrategy
.
alwaysTraditional
;
bool
?
value
=
true
;
Widget
buildApp
({
bool
enabled
=
true
})
{
...
...
@@ -371,7 +372,7 @@ void main() {
expect
(
value
,
isTrue
);
});
testWidgets
(
'Checkbox respects shape and side'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Checkbox respects shape and side'
,
(
WidgetTester
tester
)
async
{
const
RoundedRectangleBorder
roundedRectangleBorder
=
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
5
)));
...
...
packages/flutter/test/material/app_test.dart
View file @
658710b6
...
...
@@ -1083,12 +1083,13 @@ void main() {
expect
(
key1
.
currentState
,
isNull
);
});
testWidgets
(
'MaterialApp.router works'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'MaterialApp.router works'
,
(
WidgetTester
tester
)
async
{
final
PlatformRouteInformationProvider
provider
=
PlatformRouteInformationProvider
(
initialRouteInformation:
RouteInformation
(
uri:
Uri
.
parse
(
'initial'
),
),
);
addTearDown
(
provider
.
dispose
);
final
SimpleNavigatorRouterDelegate
delegate
=
SimpleNavigatorRouterDelegate
(
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
return
Text
(
information
.
uri
.
toString
());
...
...
@@ -1100,6 +1101,7 @@ void main() {
return
route
.
didPop
(
result
);
},
);
addTearDown
(
delegate
.
dispose
);
await
tester
.
pumpWidget
(
MaterialApp
.
router
(
routeInformationProvider:
provider
,
routeInformationParser:
SimpleRouteInformationParser
(),
...
...
@@ -1112,9 +1114,14 @@ void main() {
await
tester
.
binding
.
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/navigation'
,
message
,
(
_
)
{
});
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'popped'
),
findsOneWidget
);
});
testWidgets
(
'MaterialApp.router route information parser is optional'
,
(
WidgetTester
tester
)
async
{
},
// TODO(polina-c): remove after fixing
// https://github.com/flutter/flutter/issues/134205
leakTrackingTestConfig:
const
LeakTrackingTestConfig
(
allowAllNotDisposed:
true
,
));
testWidgetsWithLeakTracking
(
'MaterialApp.router route information parser is optional'
,
(
WidgetTester
tester
)
async
{
final
SimpleNavigatorRouterDelegate
delegate
=
SimpleNavigatorRouterDelegate
(
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
return
Text
(
information
.
uri
.
toString
());
...
...
@@ -1126,6 +1133,7 @@ void main() {
return
route
.
didPop
(
result
);
},
);
addTearDown
(
delegate
.
dispose
);
delegate
.
routeInformation
=
RouteInformation
(
uri:
Uri
.
parse
(
'initial'
));
await
tester
.
pumpWidget
(
MaterialApp
.
router
(
routerDelegate:
delegate
,
...
...
@@ -1137,7 +1145,12 @@ void main() {
await
tester
.
binding
.
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/navigation'
,
message
,
(
_
)
{
});
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'popped'
),
findsOneWidget
);
});
},
// TODO(polina-c): remove after fixing
// https://github.com/flutter/flutter/issues/134205
leakTrackingTestConfig:
const
LeakTrackingTestConfig
(
allowAllNotDisposed:
true
,
));
testWidgetsWithLeakTracking
(
'MaterialApp.router throw if route information provider is provided but no route information parser'
,
(
WidgetTester
tester
)
async
{
final
SimpleNavigatorRouterDelegate
delegate
=
SimpleNavigatorRouterDelegate
(
...
...
@@ -1151,6 +1164,7 @@ void main() {
return
route
.
didPop
(
result
);
},
);
addTearDown
(
delegate
.
dispose
);
delegate
.
routeInformation
=
RouteInformation
(
uri:
Uri
.
parse
(
'initial'
));
final
PlatformRouteInformationProvider
provider
=
PlatformRouteInformationProvider
(
initialRouteInformation:
RouteInformation
(
...
...
@@ -1177,6 +1191,7 @@ void main() {
return
route
.
didPop
(
result
);
},
);
addTearDown
(
delegate
.
dispose
);
delegate
.
routeInformation
=
RouteInformation
(
uri:
Uri
.
parse
(
'initial'
));
final
RouterConfig
<
RouteInformation
>
routerConfig
=
RouterConfig
<
RouteInformation
>(
routerDelegate:
delegate
);
await
tester
.
pumpWidget
(
MaterialApp
.
router
(
...
...
@@ -1186,15 +1201,19 @@ void main() {
expect
(
tester
.
takeException
(),
isAssertionError
);
});
testWidgets
(
'MaterialApp.router router config works'
,
(
WidgetTester
tester
)
async
{
testWidgetsWithLeakTracking
(
'MaterialApp.router router config works'
,
(
WidgetTester
tester
)
async
{
late
SimpleNavigatorRouterDelegate
routerDelegate
;
addTearDown
(()
=>
routerDelegate
.
dispose
());
late
PlatformRouteInformationProvider
provider
;
addTearDown
(()
=>
provider
.
dispose
());
final
RouterConfig
<
RouteInformation
>
routerConfig
=
RouterConfig
<
RouteInformation
>(
routeInformationProvider:
PlatformRouteInformationProvider
(
routeInformationProvider:
provider
=
PlatformRouteInformationProvider
(
initialRouteInformation:
RouteInformation
(
uri:
Uri
.
parse
(
'initial'
),
),
),
routeInformationParser:
SimpleRouteInformationParser
(),
routerDelegate:
SimpleNavigatorRouterDelegate
(
routerDelegate:
routerDelegate
=
SimpleNavigatorRouterDelegate
(
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
return
Text
(
information
.
uri
.
toString
());
},
...
...
@@ -1217,7 +1236,12 @@ void main() {
await
tester
.
binding
.
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/navigation'
,
message
,
(
_
)
{
});
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'popped'
),
findsOneWidget
);
});
},
// TODO(polina-c): remove after fixing
// https://github.com/flutter/flutter/issues/134205
leakTrackingTestConfig:
const
LeakTrackingTestConfig
(
allowAllNotDisposed:
true
,
));
testWidgetsWithLeakTracking
(
'MaterialApp.builder can build app without a Navigator'
,
(
WidgetTester
tester
)
async
{
Widget
?
builderChild
;
...
...
@@ -1545,7 +1569,9 @@ class SimpleNavigatorRouterDelegate extends RouterDelegate<RouteInformation> wit
SimpleNavigatorRouterDelegate
({
required
this
.
builder
,
required
this
.
onPopPage
,
});
})
{
maybeDispatchObjectCreation
();
}
@override
GlobalKey
<
NavigatorState
>
navigatorKey
=
GlobalKey
<
NavigatorState
>();
...
...
packages/flutter/test/material/calendar_date_picker_test.dart
View file @
658710b6
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/chip_test.dart
View file @
658710b6
...
...
@@ -703,11 +703,13 @@ void main() {
expect
(
calledDelete
,
isFalse
);
});
testWidgets
(
'Chip elements are ordered horizontally for locale'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Chip elements are ordered horizontally for locale'
,
(
WidgetTester
tester
)
async
{
final
UniqueKey
iconKey
=
UniqueKey
();
late
final
OverlayEntry
entry
;
addTearDown
(()
=>
entry
..
remove
()..
dispose
());
final
Widget
test
=
Overlay
(
initialEntries:
<
OverlayEntry
>[
OverlayEntry
(
entry
=
OverlayEntry
(
builder:
(
BuildContext
context
)
{
return
Material
(
child:
Chip
(
...
...
@@ -882,11 +884,14 @@ void main() {
testWidgets
(
'Chip padding - LTR'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
keyA
=
GlobalKey
();
final
GlobalKey
keyB
=
GlobalKey
();
late
final
OverlayEntry
entry
;
addTearDown
(()
=>
entry
..
remove
()..
dispose
());
await
tester
.
pumpWidget
(
wrapForChip
(
child:
Overlay
(
initialEntries:
<
OverlayEntry
>[
OverlayEntry
(
entry
=
OverlayEntry
(
builder:
(
BuildContext
context
)
{
return
Material
(
child:
Center
(
...
...
@@ -918,12 +923,16 @@ void main() {
testWidgets
(
'Chip padding - RTL'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
keyA
=
GlobalKey
();
final
GlobalKey
keyB
=
GlobalKey
();
late
final
OverlayEntry
entry
;
addTearDown
(()
=>
entry
..
remove
()..
dispose
());
await
tester
.
pumpWidget
(
wrapForChip
(
textDirection:
TextDirection
.
rtl
,
child:
Overlay
(
initialEntries:
<
OverlayEntry
>[
OverlayEntry
(
entry
=
OverlayEntry
(
builder:
(
BuildContext
context
)
{
return
Material
(
child:
Center
(
...
...
packages/flutter/test/widgets/undo_history_test.dart
View file @
658710b6
...
...
@@ -9,7 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
import
'editable_text_utils.dart'
;
final
FocusNode
focusNode
=
FocusNode
(
debugLabel:
'UndoHistory Node'
);
final
FocusNode
_
focusNode
=
FocusNode
(
debugLabel:
'UndoHistory Node'
);
void
main
(
)
{
TestWidgetsFlutterBinding
.
ensureInitialized
();
...
...
@@ -41,7 +41,7 @@ void main() {
onTriggered:
(
int
newValue
)
{
value
.
value
=
newValue
;
},
focusNode:
focusNode
,
focusNode:
_
focusNode
,
child:
Container
(),
),
),
...
...
@@ -57,7 +57,7 @@ void main() {
controller
.
redo
();
expect
(
value
.
value
,
0
);
focusNode
.
requestFocus
();
_
focusNode
.
requestFocus
();
await
tester
.
pump
();
expect
(
controller
.
value
.
canUndo
,
false
);
expect
(
controller
.
value
.
canRedo
,
false
);
...
...
@@ -130,9 +130,9 @@ void main() {
onTriggered:
(
int
newValue
)
{
value
.
value
=
newValue
;
},
focusNode:
focusNode
,
focusNode:
_
focusNode
,
child:
Focus
(
focusNode:
focusNode
,
focusNode:
_
focusNode
,
child:
Container
(),
),
),
...
...
@@ -149,7 +149,7 @@ void main() {
await
sendRedo
(
tester
);
expect
(
value
.
value
,
0
);
focusNode
.
requestFocus
();
_
focusNode
.
requestFocus
();
await
tester
.
pump
();
expect
(
controller
.
value
.
canUndo
,
false
);
expect
(
controller
.
value
.
canRedo
,
false
);
...
...
@@ -222,13 +222,13 @@ void main() {
onTriggered:
(
int
newValue
)
{
value
.
value
=
newValue
;
},
focusNode:
focusNode
,
focusNode:
_
focusNode
,
child:
Container
(),
),
),
);
focusNode
.
requestFocus
();
_
focusNode
.
requestFocus
();
// Wait for the throttling.
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
...
...
@@ -275,7 +275,7 @@ void main() {
onTriggered:
(
int
newValue
)
{
value
.
value
=
valueToUse
(
newValue
);
},
focusNode:
focusNode
,
focusNode:
_
focusNode
,
child:
Container
(),
),
),
...
...
@@ -291,7 +291,7 @@ void main() {
controller
.
redo
();
expect
(
value
.
value
,
0
);
focusNode
.
requestFocus
();
_
focusNode
.
requestFocus
();
await
tester
.
pump
();
expect
(
controller
.
value
.
canUndo
,
false
);
expect
(
controller
.
value
.
canRedo
,
false
);
...
...
@@ -389,9 +389,9 @@ void main() {
onTriggered:
(
int
newValue
)
{
value
.
value
=
newValue
;
},
focusNode:
focusNode
,
focusNode:
_
focusNode
,
child:
Focus
(
focusNode:
focusNode
,
focusNode:
_
focusNode
,
child:
Container
(),
),
),
...
...
@@ -399,7 +399,7 @@ void main() {
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
focusNode
.
requestFocus
();
_
focusNode
.
requestFocus
();
await
tester
.
pump
();
// Undo/redo have no effect if the value has never changed.
...
...
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