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
874ea75d
Unverified
Commit
874ea75d
authored
Sep 30, 2022
by
Greg Spencer
Committed by
GitHub
Sep 30, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix menu_anchor_test.dart's state leak (#112718)
Merging on red to green the build.
parent
99fb2d36
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
8 deletions
+18
-8
menu_anchor_test.dart
packages/flutter/test/material/menu_anchor_test.dart
+18
-8
No files found.
packages/flutter/test/material/menu_anchor_test.dart
View file @
874ea75d
...
@@ -16,6 +16,7 @@ void main() {
...
@@ -16,6 +16,7 @@ void main() {
final
List
<
TestMenu
>
opened
=
<
TestMenu
>[];
final
List
<
TestMenu
>
opened
=
<
TestMenu
>[];
final
List
<
TestMenu
>
closed
=
<
TestMenu
>[];
final
List
<
TestMenu
>
closed
=
<
TestMenu
>[];
final
GlobalKey
menuItemKey
=
GlobalKey
();
final
GlobalKey
menuItemKey
=
GlobalKey
();
late
Size
defaultSize
;
void
onPressed
(
TestMenu
item
)
{
void
onPressed
(
TestMenu
item
)
{
selected
.
add
(
item
);
selected
.
add
(
item
);
...
@@ -33,6 +34,11 @@ void main() {
...
@@ -33,6 +34,11 @@ void main() {
focusedMenu
=
primaryFocus
?.
debugLabel
??
primaryFocus
?.
toString
();
focusedMenu
=
primaryFocus
?.
debugLabel
??
primaryFocus
?.
toString
();
}
}
setUpAll
(()
{
final
MediaQueryData
mediaQueryData
=
MediaQueryData
.
fromWindow
(
TestWidgetsFlutterBinding
.
instance
.
window
);
defaultSize
=
mediaQueryData
.
size
;
});
setUp
(()
{
setUp
(()
{
focusedMenu
=
null
;
focusedMenu
=
null
;
selected
.
clear
();
selected
.
clear
();
...
@@ -42,6 +48,13 @@ void main() {
...
@@ -42,6 +48,13 @@ void main() {
focusedMenu
=
null
;
focusedMenu
=
null
;
});
});
Future
<
void
>
changeSurfaceSize
(
WidgetTester
tester
,
Size
size
)
async
{
await
tester
.
binding
.
setSurfaceSize
(
size
);
addTearDown
(()
async
{
await
tester
.
binding
.
setSurfaceSize
(
defaultSize
);
});
}
void
listenForFocusChanges
()
{
void
listenForFocusChanges
()
{
FocusManager
.
instance
.
addListener
(
handleFocusChange
);
FocusManager
.
instance
.
addListener
(
handleFocusChange
);
addTearDown
(()
=>
FocusManager
.
instance
.
removeListener
(
handleFocusChange
));
addTearDown
(()
=>
FocusManager
.
instance
.
removeListener
(
handleFocusChange
));
...
@@ -1059,16 +1072,13 @@ void main() {
...
@@ -1059,16 +1072,13 @@ void main() {
opened
.
clear
();
opened
.
clear
();
const
Size
smallSize
=
Size
(
200
,
200
);
const
Size
smallSize
=
Size
(
200
,
200
);
await
tester
.
binding
.
setSurfaceSize
(
smallSize
);
await
changeSurfaceSize
(
tester
,
smallSize
);
await
tester
.
pumpWidget
(
build
(
smallSize
));
await
tester
.
pumpWidget
(
build
(
smallSize
));
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
opened
,
isEmpty
);
expect
(
opened
,
isEmpty
);
expect
(
closed
,
isNotEmpty
);
expect
(
closed
,
isNotEmpty
);
// Reset binding when done.
await
tester
.
binding
.
setSurfaceSize
(
mediaQueryData
.
size
);
});
});
});
});
...
@@ -1408,7 +1418,7 @@ void main() {
...
@@ -1408,7 +1418,7 @@ void main() {
}
}
testWidgets
(
'unconstrained menus show up in the right place in LTR'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'unconstrained menus show up in the right place in LTR'
,
(
WidgetTester
tester
)
async
{
await
tester
.
binding
.
setSurfaceSize
(
const
Size
(
800
,
600
));
await
changeSurfaceSize
(
tester
,
const
Size
(
800
,
600
));
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
home:
Material
(
home:
Material
(
...
@@ -1446,7 +1456,7 @@ void main() {
...
@@ -1446,7 +1456,7 @@ void main() {
});
});
testWidgets
(
'unconstrained menus show up in the right place in RTL'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'unconstrained menus show up in the right place in RTL'
,
(
WidgetTester
tester
)
async
{
await
tester
.
binding
.
setSurfaceSize
(
const
Size
(
800
,
600
));
await
changeSurfaceSize
(
tester
,
const
Size
(
800
,
600
));
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
home:
Directionality
(
home:
Directionality
(
...
@@ -1487,7 +1497,7 @@ void main() {
...
@@ -1487,7 +1497,7 @@ void main() {
});
});
testWidgets
(
'constrained menus show up in the right place in LTR'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'constrained menus show up in the right place in LTR'
,
(
WidgetTester
tester
)
async
{
await
tester
.
binding
.
setSurfaceSize
(
const
Size
(
300
,
300
));
await
changeSurfaceSize
(
tester
,
const
Size
(
300
,
300
));
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
home:
Builder
(
home:
Builder
(
...
@@ -1526,7 +1536,7 @@ void main() {
...
@@ -1526,7 +1536,7 @@ void main() {
});
});
testWidgets
(
'constrained menus show up in the right place in RTL'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'constrained menus show up in the right place in RTL'
,
(
WidgetTester
tester
)
async
{
await
tester
.
binding
.
setSurfaceSize
(
const
Size
(
300
,
300
));
await
changeSurfaceSize
(
tester
,
const
Size
(
300
,
300
));
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
home:
Builder
(
home:
Builder
(
...
...
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