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
e337343a
Unverified
Commit
e337343a
authored
Jul 17, 2023
by
Polina Cherkasova
Committed by
GitHub
Jul 17, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mark some leaks. (#130470)
parent
220b0c4d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
8 deletions
+64
-8
leak_tracking.dart
packages/flutter/test/foundation/leak_tracking.dart
+12
-0
leak_tracking_test.dart
packages/flutter/test/foundation/leak_tracking_test.dart
+30
-4
date_range_picker_test.dart
packages/flutter/test/material/date_range_picker_test.dart
+8
-2
text_selection_theme_test.dart
...ages/flutter/test/material/text_selection_theme_test.dart
+14
-2
No files found.
packages/flutter/test/foundation/leak_tracking.dart
View file @
e337343a
...
@@ -169,6 +169,18 @@ class LeakCleaner {
...
@@ -169,6 +169,18 @@ class LeakCleaner {
/// Returns true if [leak] should be reported as failure.
/// Returns true if [leak] should be reported as failure.
bool
_shouldReportLeak
(
LeakType
leakType
,
LeakReport
leak
,
Map
<(
String
,
LeakType
),
int
>
countByClassAndType
)
{
bool
_shouldReportLeak
(
LeakType
leakType
,
LeakReport
leak
,
Map
<(
String
,
LeakType
),
int
>
countByClassAndType
)
{
switch
(
leakType
)
{
case
LeakType
.
notDisposed
:
if
(
config
.
allowAllNotDisposed
)
{
return
false
;
}
case
LeakType
.
notGCed
:
case
LeakType
.
gcedLate
:
if
(
config
.
allowAllNotGCed
)
{
return
false
;
}
}
final
String
leakingClass
=
leak
.
type
;
final
String
leakingClass
=
leak
.
type
;
final
(
String
,
LeakType
)
classAndType
=
(
leakingClass
,
leakType
);
final
(
String
,
LeakType
)
classAndType
=
(
leakingClass
,
leakType
);
...
...
packages/flutter/test/foundation/leak_tracking_test.dart
View file @
e337343a
...
@@ -54,6 +54,28 @@ Future<void> main() async {
...
@@ -54,6 +54,28 @@ Future<void> main() async {
),
),
);
);
testWidgetsWithLeakTracking
(
'respects allowAllNotDisposed'
,
(
WidgetTester
tester
)
async
{
// ignore: avoid_redundant_argument_values, for readability.
await
tester
.
pumpWidget
(
_StatelessLeakingWidget
(
notDisposed:
true
,
notGCed:
false
));
},
leakTrackingTestConfig:
const
LeakTrackingTestConfig
(
allowAllNotDisposed:
true
,
),
);
testWidgetsWithLeakTracking
(
'respects allowAllNotGCed'
,
(
WidgetTester
tester
)
async
{
// ignore: avoid_redundant_argument_values, for readability.
await
tester
.
pumpWidget
(
_StatelessLeakingWidget
(
notDisposed:
false
,
notGCed:
true
));
},
leakTrackingTestConfig:
const
LeakTrackingTestConfig
(
allowAllNotGCed:
true
,
),
);
testWidgetsWithLeakTracking
(
testWidgetsWithLeakTracking
(
'respects count in allow lists'
,
'respects count in allow lists'
,
(
WidgetTester
tester
)
async
{
(
WidgetTester
tester
)
async
{
...
@@ -180,11 +202,15 @@ void _verifyLeakList(List<LeakReport> list, int expectedCount, bool shouldContai
...
@@ -180,11 +202,15 @@ void _verifyLeakList(List<LeakReport> list, int expectedCount, bool shouldContai
final
List
<
_LeakTrackedClass
>
_notGcedStorage
=
<
_LeakTrackedClass
>[];
final
List
<
_LeakTrackedClass
>
_notGcedStorage
=
<
_LeakTrackedClass
>[];
class
_StatelessLeakingWidget
extends
StatelessWidget
{
class
_StatelessLeakingWidget
extends
StatelessWidget
{
_StatelessLeakingWidget
()
{
_StatelessLeakingWidget
({
bool
notDisposed
=
true
,
bool
notGCed
=
true
})
{
if
(
notDisposed
)
{
// ignore: unused_local_variable, the variable is used to create non disposed leak
// ignore: unused_local_variable, the variable is used to create non disposed leak
final
_LeakTrackedClass
notDisposed
=
_LeakTrackedClass
();
final
_LeakTrackedClass
notDisposed
=
_LeakTrackedClass
();
}
if
(
notGCed
)
{
_notGcedStorage
.
add
(
_LeakTrackedClass
()..
dispose
());
_notGcedStorage
.
add
(
_LeakTrackedClass
()..
dispose
());
}
}
}
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
...
...
packages/flutter/test/material/date_range_picker_test.dart
View file @
e337343a
...
@@ -9,6 +9,7 @@ import 'package:flutter/material.dart';
...
@@ -9,6 +9,7 @@ import 'package:flutter/material.dart';
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'../foundation/leak_tracking.dart'
;
import
'feedback_tester.dart'
;
import
'feedback_tester.dart'
;
void
main
(
)
{
void
main
(
)
{
...
@@ -250,12 +251,17 @@ void main() {
...
@@ -250,12 +251,17 @@ void main() {
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
});
});
testWidgets
(
'landscape'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'landscape'
,
(
WidgetTester
tester
)
async
{
await
showPicker
(
tester
,
kCommonScreenSizeLandscape
);
await
showPicker
(
tester
,
kCommonScreenSizeLandscape
);
expect
(
tester
.
widget
<
Text
>(
find
.
text
(
'Jan 15 – Jan 25, 2016'
)).
style
?.
fontSize
,
24
);
expect
(
tester
.
widget
<
Text
>(
find
.
text
(
'Jan 15 – Jan 25, 2016'
)).
style
?.
fontSize
,
24
);
await
tester
.
tap
(
find
.
text
(
'Cancel'
));
await
tester
.
tap
(
find
.
text
(
'Cancel'
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
});
},
// TODO(polina-c): remove after resolving
// https://github.com/flutter/flutter/issues/130354
leakTrackingTestConfig:
const
LeakTrackingTestConfig
(
allowAllNotGCed:
true
,
));
});
});
testWidgets
(
'Save and help text is used'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Save and help text is used'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter/test/material/text_selection_theme_test.dart
View file @
e337343a
...
@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
...
@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'../foundation/leak_tracking.dart'
;
import
'../rendering/mock_canvas.dart'
;
import
'../rendering/mock_canvas.dart'
;
void
main
(
)
{
void
main
(
)
{
...
@@ -59,7 +60,7 @@ void main() {
...
@@ -59,7 +60,7 @@ void main() {
]);
]);
});
});
testWidgets
(
'Empty textSelectionTheme will use defaults'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Empty textSelectionTheme will use defaults'
,
(
WidgetTester
tester
)
async
{
final
ThemeData
theme
=
ThemeData
();
final
ThemeData
theme
=
ThemeData
();
final
bool
material3
=
theme
.
useMaterial3
;
final
bool
material3
=
theme
.
useMaterial3
;
final
Color
defaultCursorColor
=
material3
?
theme
.
colorScheme
.
primary
:
const
Color
(
0xff2196f3
);
final
Color
defaultCursorColor
=
material3
?
theme
.
colorScheme
.
primary
:
const
Color
(
0xff2196f3
);
...
@@ -106,7 +107,18 @@ void main() {
...
@@ -106,7 +107,18 @@ void main() {
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
final
RenderBox
handle
=
tester
.
firstRenderObject
<
RenderBox
>(
find
.
byType
(
CustomPaint
));
final
RenderBox
handle
=
tester
.
firstRenderObject
<
RenderBox
>(
find
.
byType
(
CustomPaint
));
expect
(
handle
,
paints
..
path
(
color:
defaultSelectionHandleColor
));
expect
(
handle
,
paints
..
path
(
color:
defaultSelectionHandleColor
));
});
},
// TODO(polina-c): remove after fixing
// https://github.com/flutter/flutter/issues/130469
leakTrackingTestConfig:
const
LeakTrackingTestConfig
(
notDisposedAllowList:
<
String
,
int
?>{
'ValueNotifier<MagnifierInfo>'
:
1
,
'ValueNotifier<_OverlayEntryWidgetState?>'
:
2
,
'ValueNotifier<bool>'
:
1
,
},
// TODO(polina-c): investigate notGCed, if it does not disappear after fixing notDisposed.
allowAllNotGCed:
true
,
));
testWidgets
(
'ThemeData.textSelectionTheme will be used if provided'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'ThemeData.textSelectionTheme will be used if provided'
,
(
WidgetTester
tester
)
async
{
const
TextSelectionThemeData
textSelectionTheme
=
TextSelectionThemeData
(
const
TextSelectionThemeData
textSelectionTheme
=
TextSelectionThemeData
(
...
...
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