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
96dd1984
Unverified
Commit
96dd1984
authored
Mar 07, 2024
by
Valentin Vignal
Committed by
GitHub
Mar 07, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix memory leak in `editable_gesture_test.dart` (#144691)
parent
3e63c738
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
editable_gesture_test.dart
packages/flutter/test/rendering/editable_gesture_test.dart
+12
-10
No files found.
packages/flutter/test/rendering/editable_gesture_test.dart
View file @
96dd1984
...
@@ -6,23 +6,21 @@ import 'package:flutter/gestures.dart';
...
@@ -6,23 +6,21 @@ import 'package:flutter/gestures.dart';
import
'package:flutter/material.dart'
;
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
'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'
;
void
main
(
)
{
void
main
(
)
{
final
TestWidgetsFlutterBinding
binding
=
_GestureBindingSpy
();
final
TestWidgetsFlutterBinding
binding
=
_GestureBindingSpy
();
testWidgets
(
'attach and detach correctly handle gesture'
,
testWidgets
(
'attach and detach correctly handle gesture'
,
(
_
)
async
{
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787
experimentalLeakTesting:
LeakTesting
.
settings
.
withIgnoredAll
(),
(
_
)
async
{
expect
(
WidgetsBinding
.
instance
,
binding
);
expect
(
WidgetsBinding
.
instance
,
binding
);
final
TextSelectionDelegate
delegate
=
FakeEditableTextState
();
final
TextSelectionDelegate
delegate
=
FakeEditableTextState
();
final
ViewportOffset
offset
=
ViewportOffset
.
zero
();
addTearDown
(
offset
.
dispose
);
final
RenderEditable
editable
=
RenderEditable
(
final
RenderEditable
editable
=
RenderEditable
(
backgroundCursorColor:
Colors
.
grey
,
backgroundCursorColor:
Colors
.
grey
,
selectionColor:
Colors
.
black
,
selectionColor:
Colors
.
black
,
textDirection:
TextDirection
.
ltr
,
textDirection:
TextDirection
.
ltr
,
cursorColor:
Colors
.
red
,
cursorColor:
Colors
.
red
,
offset:
ViewportOffset
.
zero
()
,
offset:
offset
,
textSelectionDelegate:
delegate
,
textSelectionDelegate:
delegate
,
text:
const
TextSpan
(
text:
const
TextSpan
(
text:
'test'
,
text:
'test'
,
...
@@ -36,13 +34,17 @@ void main() {
...
@@ -36,13 +34,17 @@ void main() {
affinity:
TextAffinity
.
upstream
,
affinity:
TextAffinity
.
upstream
,
),
),
);
);
addTearDown
(
editable
.
dispose
);
editable
.
layout
(
BoxConstraints
.
loose
(
const
Size
(
1000.0
,
1000.0
)));
editable
.
layout
(
BoxConstraints
.
loose
(
const
Size
(
1000.0
,
1000.0
)));
final
PipelineOwner
owner
=
PipelineOwner
(
onNeedVisualUpdate:
()
{
});
final
PipelineOwner
owner
=
PipelineOwner
(
onNeedVisualUpdate:
()
{});
final
_PointerRouterSpy
spy
=
GestureBinding
.
instance
.
pointerRouter
as
_PointerRouterSpy
;
addTearDown
(
owner
.
dispose
);
final
_PointerRouterSpy
spy
=
GestureBinding
.
instance
.
pointerRouter
as
_PointerRouterSpy
;
editable
.
attach
(
owner
);
editable
.
attach
(
owner
);
// This should register pointer into GestureBinding.instance.pointerRouter.
// This should register pointer into GestureBinding.instance.pointerRouter.
editable
.
handleEvent
(
const
PointerDownEvent
(),
BoxHitTestEntry
(
editable
,
const
Offset
(
10
,
10
)));
editable
.
handleEvent
(
const
PointerDownEvent
(),
BoxHitTestEntry
(
editable
,
const
Offset
(
10
,
10
)));
GestureBinding
.
instance
.
pointerRouter
.
route
(
const
PointerDownEvent
());
GestureBinding
.
instance
.
pointerRouter
.
route
(
const
PointerDownEvent
());
expect
(
spy
.
routeCount
,
greaterThan
(
0
));
expect
(
spy
.
routeCount
,
greaterThan
(
0
));
editable
.
detach
();
editable
.
detach
();
...
@@ -57,7 +59,7 @@ class _GestureBindingSpy extends AutomatedTestWidgetsFlutterBinding {
...
@@ -57,7 +59,7 @@ class _GestureBindingSpy extends AutomatedTestWidgetsFlutterBinding {
PointerRouter
get
pointerRouter
=>
_testPointerRouter
;
PointerRouter
get
pointerRouter
=>
_testPointerRouter
;
}
}
class
FakeEditableTextState
extends
Fake
implements
TextSelectionDelegate
{
}
class
FakeEditableTextState
extends
Fake
implements
TextSelectionDelegate
{}
class
_PointerRouterSpy
extends
PointerRouter
{
class
_PointerRouterSpy
extends
PointerRouter
{
int
routeCount
=
0
;
int
routeCount
=
0
;
...
...
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