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
a6aaad34
Unverified
Commit
a6aaad34
authored
Nov 10, 2023
by
Kostia Sokolovskyi
Committed by
GitHub
Nov 10, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GestureRecognizer should dispatch creation and disposal events. (#138223)
parent
28ea2f84
Changes
17
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
245 additions
and
56 deletions
+245
-56
context_menu.dart
packages/flutter/lib/src/cupertino/context_menu.dart
+1
-0
recognizer.dart
packages/flutter/lib/src/gestures/recognizer.dart
+18
-2
range_slider.dart
packages/flutter/lib/src/material/range_slider.dart
+2
-0
slider.dart
packages/flutter/lib/src/material/slider.dart
+2
-0
platform_view.dart
packages/flutter/lib/src/rendering/platform_view.dart
+12
-0
reorderable_list.dart
packages/flutter/lib/src/widgets/reorderable_list.dart
+1
-0
recognizer_test.dart
packages/flutter/test/gestures/recognizer_test.dart
+11
-0
reorderable_list_test.dart
packages/flutter/test/material/reorderable_list_test.dart
+2
-0
slider_test.dart
packages/flutter/test/material/slider_test.dart
+1
-0
tooltip_test.dart
packages/flutter/test/material/tooltip_test.dart
+3
-1
hyperlink_test.dart
packages/flutter/test/widgets/hyperlink_test.dart
+2
-0
platform_view_test.dart
packages/flutter/test/widgets/platform_view_test.dart
+70
-20
rich_text_test.dart
packages/flutter/test/widgets/rich_text_test.dart
+24
-7
selectable_text_test.dart
packages/flutter/test/widgets/selectable_text_test.dart
+11
-3
semantics_tester_test.dart
packages/flutter/test/widgets/semantics_tester_test.dart
+4
-1
text_semantics_test.dart
packages/flutter/test/widgets/text_semantics_test.dart
+27
-8
text_test.dart
packages/flutter/test/widgets/text_test.dart
+54
-14
No files found.
packages/flutter/lib/src/cupertino/context_menu.dart
View file @
a6aaad34
...
@@ -685,6 +685,7 @@ class _CupertinoContextMenuState extends State<CupertinoContextMenu> with Ticker
...
@@ -685,6 +685,7 @@ class _CupertinoContextMenuState extends State<CupertinoContextMenu> with Ticker
@override
@override
void
dispose
()
{
void
dispose
()
{
_tapGestureRecognizer
.
dispose
();
_openController
.
dispose
();
_openController
.
dispose
();
super
.
dispose
();
super
.
dispose
();
}
}
...
...
packages/flutter/lib/src/gestures/recognizer.dart
View file @
a6aaad34
...
@@ -80,7 +80,17 @@ abstract class GestureRecognizer extends GestureArenaMember with DiagnosticableT
...
@@ -80,7 +80,17 @@ abstract class GestureRecognizer extends GestureArenaMember with DiagnosticableT
this
.
debugOwner
,
this
.
debugOwner
,
this
.
supportedDevices
,
this
.
supportedDevices
,
AllowedButtonsFilter
?
allowedButtonsFilter
,
AllowedButtonsFilter
?
allowedButtonsFilter
,
})
:
_allowedButtonsFilter
=
allowedButtonsFilter
??
_defaultButtonAcceptBehavior
;
})
:
_allowedButtonsFilter
=
allowedButtonsFilter
??
_defaultButtonAcceptBehavior
{
// TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435
if
(
kFlutterMemoryAllocationsEnabled
)
{
MemoryAllocations
.
instance
.
dispatchObjectCreated
(
library
:
'package:flutter/gestures.dart'
,
className:
'
$GestureRecognizer
'
,
object:
this
,
);
}
}
/// The recognizer's owner.
/// The recognizer's owner.
///
///
...
@@ -242,7 +252,13 @@ abstract class GestureRecognizer extends GestureArenaMember with DiagnosticableT
...
@@ -242,7 +252,13 @@ abstract class GestureRecognizer extends GestureArenaMember with DiagnosticableT
/// recognizer is being unregistered from a [GestureDetector], the
/// recognizer is being unregistered from a [GestureDetector], the
/// GestureDetector widget calls this method).
/// GestureDetector widget calls this method).
@mustCallSuper
@mustCallSuper
void
dispose
()
{
}
void
dispose
()
{
// TODO(polina-c): stop duplicating code across disposables
// https://github.com/flutter/flutter/issues/137435
if
(
kFlutterMemoryAllocationsEnabled
)
{
MemoryAllocations
.
instance
.
dispatchObjectDisposed
(
object:
this
);
}
}
/// Returns a very short pretty description of the gesture that the
/// Returns a very short pretty description of the gesture that the
/// recognizer looks for, like 'tap' or 'horizontal drag'.
/// recognizer looks for, like 'tap' or 'horizontal drag'.
...
...
packages/flutter/lib/src/material/range_slider.dart
View file @
a6aaad34
...
@@ -1193,6 +1193,8 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
...
@@ -1193,6 +1193,8 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
@override
@override
void
dispose
()
{
void
dispose
()
{
_drag
.
dispose
();
_tap
.
dispose
();
_startLabelPainter
.
dispose
();
_startLabelPainter
.
dispose
();
_endLabelPainter
.
dispose
();
_endLabelPainter
.
dispose
();
super
.
dispose
();
super
.
dispose
();
...
...
packages/flutter/lib/src/material/slider.dart
View file @
a6aaad34
...
@@ -1457,6 +1457,8 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
...
@@ -1457,6 +1457,8 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
@override
@override
void
dispose
()
{
void
dispose
()
{
_drag
.
dispose
();
_tap
.
dispose
();
_labelPainter
.
dispose
();
_labelPainter
.
dispose
();
super
.
dispose
();
super
.
dispose
();
}
}
...
...
packages/flutter/lib/src/rendering/platform_view.dart
View file @
a6aaad34
...
@@ -441,6 +441,12 @@ class RenderUiKitView extends RenderDarwinPlatformView<UiKitViewController> {
...
@@ -441,6 +441,12 @@ class RenderUiKitView extends RenderDarwinPlatformView<UiKitViewController> {
_gestureRecognizer
!.
reset
();
_gestureRecognizer
!.
reset
();
super
.
detach
();
super
.
detach
();
}
}
@override
void
dispose
()
{
_gestureRecognizer
?.
dispose
();
super
.
dispose
();
}
}
}
/// A render object for a macOS platform view.
/// A render object for a macOS platform view.
...
@@ -810,4 +816,10 @@ mixin _PlatformViewGestureMixin on RenderBox implements MouseTrackerAnnotation {
...
@@ -810,4 +816,10 @@ mixin _PlatformViewGestureMixin on RenderBox implements MouseTrackerAnnotation {
_gestureRecognizer
!.
reset
();
_gestureRecognizer
!.
reset
();
super
.
detach
();
super
.
detach
();
}
}
@override
void
dispose
()
{
_gestureRecognizer
?.
dispose
();
super
.
dispose
();
}
}
}
packages/flutter/lib/src/widgets/reorderable_list.dart
View file @
a6aaad34
...
@@ -671,6 +671,7 @@ class SliverReorderableListState extends State<SliverReorderableList> with Ticke
...
@@ -671,6 +671,7 @@ class SliverReorderableListState extends State<SliverReorderableList> with Ticke
@override
@override
void
dispose
()
{
void
dispose
()
{
_dragReset
();
_dragReset
();
_recognizer
?.
dispose
();
super
.
dispose
();
super
.
dispose
();
}
}
...
...
packages/flutter/test/gestures/recognizer_test.dart
View file @
a6aaad34
...
@@ -6,6 +6,7 @@ import 'dart:ui' show VoidCallback;
...
@@ -6,6 +6,7 @@ import 'dart:ui' show VoidCallback;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'
;
import
'gesture_tester.dart'
;
import
'gesture_tester.dart'
;
...
@@ -49,6 +50,16 @@ void main() {
...
@@ -49,6 +50,16 @@ void main() {
expect
(
recognizer
,
hasAGoodToStringDeep
);
expect
(
recognizer
,
hasAGoodToStringDeep
);
});
});
test
(
'GestureRecognizer dispatches memory events'
,
()
async
{
await
expectLater
(
await
memoryEvents
(
()
=>
TestGestureRecognizer
().
dispose
(),
TestGestureRecognizer
,),
areCreateAndDispose
,
);
});
test
(
'OffsetPair'
,
()
{
test
(
'OffsetPair'
,
()
{
const
OffsetPair
offset1
=
OffsetPair
(
const
OffsetPair
offset1
=
OffsetPair
(
local:
Offset
(
10
,
20
),
local:
Offset
(
10
,
20
),
...
...
packages/flutter/test/material/reorderable_list_test.dart
View file @
a6aaad34
...
@@ -1568,6 +1568,7 @@ void main() {
...
@@ -1568,6 +1568,7 @@ void main() {
),
),
);
);
},
},
buildDefaultDragHandles:
false
,
itemCount:
items
.
length
,
itemCount:
items
.
length
,
onReorder:
handleReorder
,
onReorder:
handleReorder
,
),
),
...
@@ -1634,6 +1635,7 @@ void main() {
...
@@ -1634,6 +1635,7 @@ void main() {
),
),
);
);
},
},
buildDefaultDragHandles:
false
,
itemCount:
items
.
length
,
itemCount:
items
.
length
,
onReorder:
handleReorder
,
onReorder:
handleReorder
,
onReorderStart:
(
int
index
)
{
onReorderStart:
(
int
index
)
{
...
...
packages/flutter/test/material/slider_test.dart
View file @
a6aaad34
...
@@ -3650,6 +3650,7 @@ void main() {
...
@@ -3650,6 +3650,7 @@ void main() {
double
value
=
0.0
;
double
value
=
0.0
;
final
ValueNotifier
<
bool
>
shouldShowSliderListenable
=
final
ValueNotifier
<
bool
>
shouldShowSliderListenable
=
ValueNotifier
<
bool
>(
true
);
ValueNotifier
<
bool
>(
true
);
addTearDown
(
shouldShowSliderListenable
.
dispose
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
...
...
packages/flutter/test/material/tooltip_test.dart
View file @
a6aaad34
...
@@ -2189,13 +2189,15 @@ void main() {
...
@@ -2189,13 +2189,15 @@ void main() {
testWidgetsWithLeakTracking
(
'Tooltip should not ignore users tap on richMessage'
,
(
WidgetTester
tester
)
async
{
testWidgetsWithLeakTracking
(
'Tooltip should not ignore users tap on richMessage'
,
(
WidgetTester
tester
)
async
{
bool
isTapped
=
false
;
bool
isTapped
=
false
;
final
TapGestureRecognizer
recognizer
=
TapGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
home:
Tooltip
(
home:
Tooltip
(
richMessage:
TextSpan
(
richMessage:
TextSpan
(
text:
tooltipText
,
text:
tooltipText
,
recognizer:
TapGestureRecognizer
()
..
onTap
=
()
{
recognizer:
recognizer
..
onTap
=
()
{
isTapped
=
true
;
isTapped
=
true
;
}
}
),
),
...
...
packages/flutter/test/widgets/hyperlink_test.dart
View file @
a6aaad34
...
@@ -14,12 +14,14 @@ void main() {
...
@@ -14,12 +14,14 @@ void main() {
..
onTap
=
()
{
..
onTap
=
()
{
didTapLeft
=
true
;
didTapLeft
=
true
;
};
};
addTearDown
(
tapLeft
.
dispose
);
bool
didTapRight
=
false
;
bool
didTapRight
=
false
;
final
TapGestureRecognizer
tapRight
=
TapGestureRecognizer
()
final
TapGestureRecognizer
tapRight
=
TapGestureRecognizer
()
..
onTap
=
()
{
..
onTap
=
()
{
didTapRight
=
true
;
didTapRight
=
true
;
};
};
addTearDown
(
tapRight
.
dispose
);
const
Key
textKey
=
Key
(
'text'
);
const
Key
textKey
=
Key
(
'text'
);
...
...
packages/flutter/test/widgets/platform_view_test.dart
View file @
a6aaad34
...
@@ -638,7 +638,9 @@ void main() {
...
@@ -638,7 +638,9 @@ void main() {
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
Factory
<
VerticalDragGestureRecognizer
>(
Factory
<
VerticalDragGestureRecognizer
>(
()
{
()
{
return
VerticalDragGestureRecognizer
();
final
VerticalDragGestureRecognizer
recognizer
=
VerticalDragGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
return
recognizer
;
},
},
),
),
},
},
...
@@ -684,7 +686,9 @@ void main() {
...
@@ -684,7 +686,9 @@ void main() {
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
Factory
<
LongPressGestureRecognizer
>(
Factory
<
LongPressGestureRecognizer
>(
()
{
()
{
return
LongPressGestureRecognizer
();
final
LongPressGestureRecognizer
recognizer
=
LongPressGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
return
recognizer
;
},
},
),
),
},
},
...
@@ -727,7 +731,9 @@ void main() {
...
@@ -727,7 +731,9 @@ void main() {
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
Factory
<
TapGestureRecognizer
>(
Factory
<
TapGestureRecognizer
>(
()
{
()
{
return
TapGestureRecognizer
();
final
TapGestureRecognizer
recognizer
=
TapGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
return
recognizer
;
},
},
),
),
},
},
...
@@ -853,7 +859,11 @@ void main() {
...
@@ -853,7 +859,11 @@ void main() {
viewType:
'webview'
,
viewType:
'webview'
,
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
Factory
<
OneSequenceGestureRecognizer
>(
Factory
<
OneSequenceGestureRecognizer
>(
()
=>
EagerGestureRecognizer
(),
()
{
final
EagerGestureRecognizer
recognizer
=
EagerGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
return
recognizer
;
},
),
),
},
},
layoutDirection:
TextDirection
.
ltr
,
layoutDirection:
TextDirection
.
ltr
,
...
@@ -893,7 +903,11 @@ void main() {
...
@@ -893,7 +903,11 @@ void main() {
viewType:
'webview'
,
viewType:
'webview'
,
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
Factory
<
EagerGestureRecognizer
>(
Factory
<
EagerGestureRecognizer
>(
()
=>
EagerGestureRecognizer
(),
()
{
final
EagerGestureRecognizer
recognizer
=
EagerGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
return
recognizer
;
},
),
),
},
},
layoutDirection:
TextDirection
.
ltr
,
layoutDirection:
TextDirection
.
ltr
,
...
@@ -912,7 +926,9 @@ void main() {
...
@@ -912,7 +926,9 @@ void main() {
int
factoryInvocationCount
=
0
;
int
factoryInvocationCount
=
0
;
EagerGestureRecognizer
constructRecognizer
()
{
EagerGestureRecognizer
constructRecognizer
()
{
factoryInvocationCount
+=
1
;
factoryInvocationCount
+=
1
;
return
EagerGestureRecognizer
();
final
EagerGestureRecognizer
recognizer
=
EagerGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
return
recognizer
;
}
}
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
@@ -1728,7 +1744,9 @@ void main() {
...
@@ -1728,7 +1744,9 @@ void main() {
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
Factory
<
VerticalDragGestureRecognizer
>(
Factory
<
VerticalDragGestureRecognizer
>(
()
{
()
{
return
VerticalDragGestureRecognizer
();
final
VerticalDragGestureRecognizer
recognizer
=
VerticalDragGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
return
recognizer
;
},
},
),
),
},
},
...
@@ -1772,7 +1790,9 @@ void main() {
...
@@ -1772,7 +1790,9 @@ void main() {
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
Factory
<
LongPressGestureRecognizer
>(
Factory
<
LongPressGestureRecognizer
>(
()
{
()
{
return
LongPressGestureRecognizer
();
final
LongPressGestureRecognizer
recognizer
=
LongPressGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
return
recognizer
;
},
},
),
),
},
},
...
@@ -1814,7 +1834,9 @@ void main() {
...
@@ -1814,7 +1834,9 @@ void main() {
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
Factory
<
TapGestureRecognizer
>(
Factory
<
TapGestureRecognizer
>(
()
{
()
{
return
TapGestureRecognizer
();
final
TapGestureRecognizer
recognizer
=
TapGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
return
recognizer
;
},
},
),
),
},
},
...
@@ -1937,7 +1959,11 @@ void main() {
...
@@ -1937,7 +1959,11 @@ void main() {
viewType:
'webview'
,
viewType:
'webview'
,
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
Factory
<
OneSequenceGestureRecognizer
>(
Factory
<
OneSequenceGestureRecognizer
>(
()
=>
EagerGestureRecognizer
(),
()
{
final
EagerGestureRecognizer
recognizer
=
EagerGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
return
recognizer
;
},
),
),
},
},
layoutDirection:
TextDirection
.
ltr
,
layoutDirection:
TextDirection
.
ltr
,
...
@@ -2052,7 +2078,9 @@ void main() {
...
@@ -2052,7 +2078,9 @@ void main() {
int
factoryInvocationCount
=
0
;
int
factoryInvocationCount
=
0
;
EagerGestureRecognizer
constructRecognizer
()
{
EagerGestureRecognizer
constructRecognizer
()
{
factoryInvocationCount
+=
1
;
factoryInvocationCount
+=
1
;
return
EagerGestureRecognizer
();
final
EagerGestureRecognizer
recognizer
=
EagerGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
return
recognizer
;
}
}
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
@@ -2653,7 +2681,9 @@ void main() {
...
@@ -2653,7 +2681,9 @@ void main() {
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
Factory
<
VerticalDragGestureRecognizer
>(
Factory
<
VerticalDragGestureRecognizer
>(
()
{
()
{
return
VerticalDragGestureRecognizer
();
final
VerticalDragGestureRecognizer
recognizer
=
VerticalDragGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
return
recognizer
;
},
},
),
),
},
},
...
@@ -2697,7 +2727,9 @@ void main() {
...
@@ -2697,7 +2727,9 @@ void main() {
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
Factory
<
LongPressGestureRecognizer
>(
Factory
<
LongPressGestureRecognizer
>(
()
{
()
{
return
LongPressGestureRecognizer
();
final
LongPressGestureRecognizer
recognizer
=
LongPressGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
return
recognizer
;
},
},
),
),
},
},
...
@@ -2739,7 +2771,9 @@ void main() {
...
@@ -2739,7 +2771,9 @@ void main() {
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
Factory
<
TapGestureRecognizer
>(
Factory
<
TapGestureRecognizer
>(
()
{
()
{
return
TapGestureRecognizer
();
final
TapGestureRecognizer
recognizer
=
TapGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
return
recognizer
;
},
},
),
),
},
},
...
@@ -2862,7 +2896,11 @@ void main() {
...
@@ -2862,7 +2896,11 @@ void main() {
viewType:
'webview'
,
viewType:
'webview'
,
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
Factory
<
OneSequenceGestureRecognizer
>(
Factory
<
OneSequenceGestureRecognizer
>(
()
=>
EagerGestureRecognizer
(),
()
{
final
EagerGestureRecognizer
recognizer
=
EagerGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
return
recognizer
;
},
),
),
},
},
layoutDirection:
TextDirection
.
ltr
,
layoutDirection:
TextDirection
.
ltr
,
...
@@ -2977,7 +3015,9 @@ void main() {
...
@@ -2977,7 +3015,9 @@ void main() {
int
factoryInvocationCount
=
0
;
int
factoryInvocationCount
=
0
;
EagerGestureRecognizer
constructRecognizer
()
{
EagerGestureRecognizer
constructRecognizer
()
{
factoryInvocationCount
+=
1
;
factoryInvocationCount
+=
1
;
return
EagerGestureRecognizer
();
final
EagerGestureRecognizer
recognizer
=
EagerGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
return
recognizer
;
}
}
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
@@ -3241,7 +3281,9 @@ void main() {
...
@@ -3241,7 +3281,9 @@ void main() {
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
Factory
<
VerticalDragGestureRecognizer
>(
Factory
<
VerticalDragGestureRecognizer
>(
()
{
()
{
return
VerticalDragGestureRecognizer
();
final
VerticalDragGestureRecognizer
recognizer
=
VerticalDragGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
return
recognizer
;
},
},
),
),
},
},
...
@@ -3353,7 +3395,11 @@ void main() {
...
@@ -3353,7 +3395,11 @@ void main() {
hitTestBehavior:
PlatformViewHitTestBehavior
.
opaque
,
hitTestBehavior:
PlatformViewHitTestBehavior
.
opaque
,
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
gestureRecognizers:
<
Factory
<
OneSequenceGestureRecognizer
>>{
Factory
<
OneSequenceGestureRecognizer
>(
Factory
<
OneSequenceGestureRecognizer
>(
()
=>
EagerGestureRecognizer
(),
()
{
final
EagerGestureRecognizer
recognizer
=
EagerGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
return
recognizer
;
},
),
),
},
},
),
),
...
@@ -3382,7 +3428,9 @@ void main() {
...
@@ -3382,7 +3428,9 @@ void main() {
int
factoryInvocationCount
=
0
;
int
factoryInvocationCount
=
0
;
EagerGestureRecognizer
constructRecognizer
()
{
EagerGestureRecognizer
constructRecognizer
()
{
++
factoryInvocationCount
;
++
factoryInvocationCount
;
return
EagerGestureRecognizer
();
final
EagerGestureRecognizer
recognizer
=
EagerGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
return
recognizer
;
}
}
final
PlatformViewSurface
platformViewSurface
=
PlatformViewSurface
(
final
PlatformViewSurface
platformViewSurface
=
PlatformViewSurface
(
...
@@ -3406,7 +3454,9 @@ void main() {
...
@@ -3406,7 +3454,9 @@ void main() {
int
factoryInvocationCount
=
0
;
int
factoryInvocationCount
=
0
;
EagerGestureRecognizer
constructRecognizer
()
{
EagerGestureRecognizer
constructRecognizer
()
{
++
factoryInvocationCount
;
++
factoryInvocationCount
;
return
EagerGestureRecognizer
();
final
EagerGestureRecognizer
recognizer
=
EagerGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
return
recognizer
;
}
}
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
...
packages/flutter/test/widgets/rich_text_test.dart
View file @
a6aaad34
...
@@ -10,14 +10,21 @@ import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
...
@@ -10,14 +10,21 @@ import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void
main
(
)
{
void
main
(
)
{
testWidgetsWithLeakTracking
(
'RichText with recognizers without handlers does not throw'
,
(
WidgetTester
tester
)
async
{
testWidgetsWithLeakTracking
(
'RichText with recognizers without handlers does not throw'
,
(
WidgetTester
tester
)
async
{
final
TapGestureRecognizer
recognizer1
=
TapGestureRecognizer
();
addTearDown
(
recognizer1
.
dispose
);
final
LongPressGestureRecognizer
recognizer2
=
LongPressGestureRecognizer
();
addTearDown
(
recognizer2
.
dispose
);
final
DoubleTapGestureRecognizer
recognizer3
=
DoubleTapGestureRecognizer
();
addTearDown
(
recognizer3
.
dispose
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
Directionality
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
textDirection:
TextDirection
.
ltr
,
child:
RichText
(
child:
RichText
(
text:
TextSpan
(
text:
'root'
,
children:
<
InlineSpan
>[
text:
TextSpan
(
text:
'root'
,
children:
<
InlineSpan
>[
TextSpan
(
text:
'one'
,
recognizer:
TapGestureRecognizer
()
),
TextSpan
(
text:
'one'
,
recognizer:
recognizer1
),
TextSpan
(
text:
'two'
,
recognizer:
LongPressGestureRecognizer
()
),
TextSpan
(
text:
'two'
,
recognizer:
recognizer2
),
TextSpan
(
text:
'three'
,
recognizer:
DoubleTapGestureRecognizer
()
),
TextSpan
(
text:
'three'
,
recognizer:
recognizer3
),
]),
]),
),
),
),
),
...
@@ -42,6 +49,11 @@ void main() {
...
@@ -42,6 +49,11 @@ void main() {
});
});
testWidgetsWithLeakTracking
(
'TextSpan Locale works'
,
(
WidgetTester
tester
)
async
{
testWidgetsWithLeakTracking
(
'TextSpan Locale works'
,
(
WidgetTester
tester
)
async
{
final
TapGestureRecognizer
recognizer1
=
TapGestureRecognizer
();
addTearDown
(
recognizer1
.
dispose
);
final
DoubleTapGestureRecognizer
recognizer2
=
DoubleTapGestureRecognizer
();
addTearDown
(
recognizer2
.
dispose
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
Directionality
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
textDirection:
TextDirection
.
ltr
,
...
@@ -50,11 +62,11 @@ void main() {
...
@@ -50,11 +62,11 @@ void main() {
text:
'root'
,
text:
'root'
,
locale:
const
Locale
(
'es'
,
'MX'
),
locale:
const
Locale
(
'es'
,
'MX'
),
children:
<
InlineSpan
>[
children:
<
InlineSpan
>[
TextSpan
(
text:
'one'
,
recognizer:
TapGestureRecognizer
()
),
TextSpan
(
text:
'one'
,
recognizer:
recognizer1
),
const
WidgetSpan
(
const
WidgetSpan
(
child:
SizedBox
(),
child:
SizedBox
(),
),
),
TextSpan
(
text:
'three'
,
recognizer:
DoubleTapGestureRecognizer
()
),
TextSpan
(
text:
'three'
,
recognizer:
recognizer2
),
]
]
),
),
),
),
...
@@ -91,6 +103,11 @@ void main() {
...
@@ -91,6 +103,11 @@ void main() {
});
});
testWidgetsWithLeakTracking
(
'TextSpan spellOut works'
,
(
WidgetTester
tester
)
async
{
testWidgetsWithLeakTracking
(
'TextSpan spellOut works'
,
(
WidgetTester
tester
)
async
{
final
TapGestureRecognizer
recognizer1
=
TapGestureRecognizer
();
addTearDown
(
recognizer1
.
dispose
);
final
DoubleTapGestureRecognizer
recognizer2
=
DoubleTapGestureRecognizer
();
addTearDown
(
recognizer2
.
dispose
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
Directionality
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
textDirection:
TextDirection
.
ltr
,
...
@@ -99,11 +116,11 @@ void main() {
...
@@ -99,11 +116,11 @@ void main() {
text:
'root'
,
text:
'root'
,
spellOut:
true
,
spellOut:
true
,
children:
<
InlineSpan
>[
children:
<
InlineSpan
>[
TextSpan
(
text:
'one'
,
recognizer:
TapGestureRecognizer
()
),
TextSpan
(
text:
'one'
,
recognizer:
recognizer1
),
const
WidgetSpan
(
const
WidgetSpan
(
child:
SizedBox
(),
child:
SizedBox
(),
),
),
TextSpan
(
text:
'three'
,
recognizer:
DoubleTapGestureRecognizer
()
),
TextSpan
(
text:
'three'
,
recognizer:
recognizer2
),
]
]
),
),
),
),
...
...
packages/flutter/test/widgets/selectable_text_test.dart
View file @
a6aaad34
...
@@ -1573,6 +1573,9 @@ void main() {
...
@@ -1573,6 +1573,9 @@ void main() {
testWidgetsWithLeakTracking
(
'Selectable rich text with gesture recognizer has correct semantics'
,
(
WidgetTester
tester
)
async
{
testWidgetsWithLeakTracking
(
'Selectable rich text with gesture recognizer has correct semantics'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
final
TapGestureRecognizer
recognizer
=
TapGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
overlay
(
overlay
(
child:
SelectableText
.
rich
(
child:
SelectableText
.
rich
(
...
@@ -1581,8 +1584,7 @@ void main() {
...
@@ -1581,8 +1584,7 @@ void main() {
const
TextSpan
(
text:
'text'
),
const
TextSpan
(
text:
'text'
),
TextSpan
(
TextSpan
(
text:
'link'
,
text:
'link'
,
recognizer:
TapGestureRecognizer
()
recognizer:
recognizer
..
onTap
=
()
{
},
..
onTap
=
()
{
},
),
),
],
],
),
),
...
@@ -2467,6 +2469,8 @@ void main() {
...
@@ -2467,6 +2469,8 @@ void main() {
const
String
offScreenText
=
'off screen'
;
const
String
offScreenText
=
'off screen'
;
final
ScrollController
controller
=
ScrollController
();
final
ScrollController
controller
=
ScrollController
();
addTearDown
(
controller
.
dispose
);
addTearDown
(
controller
.
dispose
);
final
TapGestureRecognizer
recognizer
=
TapGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
...
@@ -2478,7 +2482,7 @@ void main() {
...
@@ -2478,7 +2482,7 @@ void main() {
const
TextSpan
(
text:
onScreenText
),
const
TextSpan
(
text:
onScreenText
),
TextSpan
(
TextSpan
(
text:
offScreenText
,
text:
offScreenText
,
recognizer:
TapGestureRecognizer
()
..
onTap
=
()
{
},
recognizer:
recognizer
..
onTap
=
()
{
},
),
),
],
],
style:
textStyle
,
style:
textStyle
,
...
@@ -4640,6 +4644,8 @@ void main() {
...
@@ -4640,6 +4644,8 @@ void main() {
..
onTap
=
()
{
..
onTap
=
()
{
spyTaps
+=
1
;
spyTaps
+=
1
;
};
};
addTearDown
(
spyRecognizer
.
dispose
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
home:
Material
(
home:
Material
(
...
@@ -4690,6 +4696,8 @@ void main() {
...
@@ -4690,6 +4696,8 @@ void main() {
..
onLongPress
=
()
{
..
onLongPress
=
()
{
spyLongPress
+=
1
;
spyLongPress
+=
1
;
};
};
addTearDown
(
spyRecognizer
.
dispose
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
home:
Material
(
home:
Material
(
...
...
packages/flutter/test/widgets/semantics_tester_test.dart
View file @
a6aaad34
...
@@ -13,12 +13,15 @@ void main() {
...
@@ -13,12 +13,15 @@ void main() {
testWidgetsWithLeakTracking
(
'Semantics tester visits last child'
,
(
WidgetTester
tester
)
async
{
testWidgetsWithLeakTracking
(
'Semantics tester visits last child'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
const
TextStyle
textStyle
=
TextStyle
();
const
TextStyle
textStyle
=
TextStyle
();
final
TapGestureRecognizer
recognizer
=
TapGestureRecognizer
();
addTearDown
(
recognizer
.
dispose
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
Text
.
rich
(
Text
.
rich
(
TextSpan
(
TextSpan
(
children:
<
TextSpan
>[
children:
<
TextSpan
>[
const
TextSpan
(
text:
'hello'
),
const
TextSpan
(
text:
'hello'
),
TextSpan
(
text:
'world'
,
recognizer:
TapGestureRecognizer
()
..
onTap
=
()
{
}),
TextSpan
(
text:
'world'
,
recognizer:
recognizer
..
onTap
=
()
{
}),
],
],
style:
textStyle
,
style:
textStyle
,
),
),
...
...
packages/flutter/test/widgets/text_semantics_test.dart
View file @
a6aaad34
...
@@ -14,20 +14,27 @@ void main() {
...
@@ -14,20 +14,27 @@ void main() {
testWidgetsWithLeakTracking
(
'SemanticsNode ids are stable'
,
(
WidgetTester
tester
)
async
{
testWidgetsWithLeakTracking
(
'SemanticsNode ids are stable'
,
(
WidgetTester
tester
)
async
{
// Regression test for b/151732341.
// Regression test for b/151732341.
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
final
TapGestureRecognizer
recognizer1
=
TapGestureRecognizer
();
addTearDown
(
recognizer1
.
dispose
);
final
TapGestureRecognizer
recognizer2
=
TapGestureRecognizer
();
addTearDown
(
recognizer2
.
dispose
);
final
TapGestureRecognizer
recognizer3
=
TapGestureRecognizer
();
addTearDown
(
recognizer3
.
dispose
);
await
tester
.
pumpWidget
(
Directionality
(
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
textDirection:
TextDirection
.
ltr
,
child:
Text
.
rich
(
child:
Text
.
rich
(
TextSpan
(
TextSpan
(
text:
'Hallo '
,
text:
'Hallo '
,
recognizer:
TapGestureRecognizer
()
..
onTap
=
()
{},
recognizer:
recognizer1
..
onTap
=
()
{},
children:
<
TextSpan
>[
children:
<
TextSpan
>[
TextSpan
(
TextSpan
(
text:
'Welt '
,
text:
'Welt '
,
recognizer:
TapGestureRecognizer
()
..
onTap
=
()
{},
recognizer:
recognizer2
..
onTap
=
()
{},
),
),
TextSpan
(
TextSpan
(
text:
'!!!'
,
text:
'!!!'
,
recognizer:
TapGestureRecognizer
()
..
onTap
=
()
{},
recognizer:
recognizer3
..
onTap
=
()
{},
),
),
],
],
),
),
...
@@ -64,17 +71,22 @@ void main() {
...
@@ -64,17 +71,22 @@ void main() {
expect
(
labelToNodeIdAfterRebuild
[
'!!!'
],
labelToNodeId
[
'!!!'
]);
expect
(
labelToNodeIdAfterRebuild
[
'!!!'
],
labelToNodeId
[
'!!!'
]);
expect
(
labelToNodeIdAfterRebuild
.
length
,
3
);
expect
(
labelToNodeIdAfterRebuild
.
length
,
3
);
final
TapGestureRecognizer
recognizer4
=
TapGestureRecognizer
();
addTearDown
(
recognizer4
.
dispose
);
final
TapGestureRecognizer
recognizer5
=
TapGestureRecognizer
();
addTearDown
(
recognizer5
.
dispose
);
// Remove one node.
// Remove one node.
await
tester
.
pumpWidget
(
Directionality
(
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
textDirection:
TextDirection
.
ltr
,
child:
Text
.
rich
(
child:
Text
.
rich
(
TextSpan
(
TextSpan
(
text:
'Hallo '
,
text:
'Hallo '
,
recognizer:
TapGestureRecognizer
()
..
onTap
=
()
{},
recognizer:
recognizer4
..
onTap
=
()
{},
children:
<
TextSpan
>[
children:
<
TextSpan
>[
TextSpan
(
TextSpan
(
text:
'Welt '
,
text:
'Welt '
,
recognizer:
TapGestureRecognizer
()
..
onTap
=
()
{},
recognizer:
recognizer5
..
onTap
=
()
{},
),
),
],
],
),
),
...
@@ -94,20 +106,27 @@ void main() {
...
@@ -94,20 +106,27 @@ void main() {
expect
(
labelToNodeIdAfterRemoval
[
'Welt '
],
labelToNodeId
[
'Welt '
]);
expect
(
labelToNodeIdAfterRemoval
[
'Welt '
],
labelToNodeId
[
'Welt '
]);
expect
(
labelToNodeIdAfterRemoval
.
length
,
2
);
expect
(
labelToNodeIdAfterRemoval
.
length
,
2
);
final
TapGestureRecognizer
recognizer6
=
TapGestureRecognizer
();
addTearDown
(
recognizer6
.
dispose
);
final
TapGestureRecognizer
recognizer7
=
TapGestureRecognizer
();
addTearDown
(
recognizer7
.
dispose
);
final
TapGestureRecognizer
recognizer8
=
TapGestureRecognizer
();
addTearDown
(
recognizer8
.
dispose
);
await
tester
.
pumpWidget
(
Directionality
(
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
textDirection:
TextDirection
.
ltr
,
child:
Text
.
rich
(
child:
Text
.
rich
(
TextSpan
(
TextSpan
(
text:
'Hallo '
,
text:
'Hallo '
,
recognizer:
TapGestureRecognizer
()
..
onTap
=
()
{},
recognizer:
recognizer6
..
onTap
=
()
{},
children:
<
TextSpan
>[
children:
<
TextSpan
>[
TextSpan
(
TextSpan
(
text:
'Welt '
,
text:
'Welt '
,
recognizer:
TapGestureRecognizer
()
..
onTap
=
()
{},
recognizer:
recognizer7
..
onTap
=
()
{},
),
),
TextSpan
(
TextSpan
(
text:
'!!!'
,
text:
'!!!'
,
recognizer:
TapGestureRecognizer
()
..
onTap
=
()
{},
recognizer:
recognizer8
..
onTap
=
()
{},
),
),
],
],
),
),
...
...
packages/flutter/test/widgets/text_test.dart
View file @
a6aaad34
This diff is collapsed.
Click to expand it.
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