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
c880680c
Unverified
Commit
c880680c
authored
Apr 23, 2021
by
xubaolin
Committed by
GitHub
Apr 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a test for popupMenuButton (#80930)
parent
a94e63a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
0 deletions
+65
-0
popup_menu_test.dart
packages/flutter/test/material/popup_menu_test.dart
+65
-0
No files found.
packages/flutter/test/material/popup_menu_test.dart
View file @
c880680c
...
@@ -2209,6 +2209,71 @@ void main() {
...
@@ -2209,6 +2209,71 @@ void main() {
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'foo'
),
findsOneWidget
);
expect
(
find
.
text
(
'foo'
),
findsOneWidget
);
});
});
// Regression test for https://github.com/flutter/flutter/issues/80869
testWidgets
(
'The menu position test in the scrollable widget'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
buttonKey
=
GlobalKey
();
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
SingleChildScrollView
(
child:
Column
(
children:
<
Widget
>[
const
SizedBox
(
height:
100
),
PopupMenuButton
<
int
>(
child:
SizedBox
(
key:
buttonKey
,
height:
10.0
,
width:
10.0
,
child:
const
ColoredBox
(
color:
Colors
.
pink
,
),
),
itemBuilder:
(
BuildContext
context
)
=>
<
PopupMenuEntry
<
int
>>[
const
PopupMenuItem
<
int
>(
child:
Text
(
'-1-'
),
value:
1
,),
const
PopupMenuItem
<
int
>(
child:
Text
(
'-2-'
),
value:
2
,),
],
),
const
SizedBox
(
height:
600
),
],
),
),
),
),
);
// Open the menu.
await
tester
.
tap
(
find
.
byKey
(
buttonKey
));
await
tester
.
pumpAndSettle
();
Offset
button
=
tester
.
getTopLeft
(
find
.
byKey
(
buttonKey
));
expect
(
button
,
const
Offset
(
0.0
,
100.0
));
Offset
popupMenu
=
tester
.
getTopLeft
(
find
.
byType
(
SingleChildScrollView
).
last
);
// The menu should be positioned directly next to the top of the button.
// The 8.0 pixels is [_kMenuScreenPadding].
expect
(
popupMenu
,
const
Offset
(
8.0
,
100.0
));
// Close the menu.
await
tester
.
tap
(
find
.
byKey
(
buttonKey
),
warnIfMissed:
false
);
await
tester
.
pumpAndSettle
();
// Scroll a little bit.
await
tester
.
drag
(
find
.
byType
(
SingleChildScrollView
),
const
Offset
(
0.0
,
-
50.0
));
button
=
tester
.
getTopLeft
(
find
.
byKey
(
buttonKey
));
expect
(
button
,
const
Offset
(
0.0
,
50.0
));
// Open the menu again.
await
tester
.
tap
(
find
.
byKey
(
buttonKey
));
await
tester
.
pumpAndSettle
();
popupMenu
=
tester
.
getTopLeft
(
find
.
byType
(
SingleChildScrollView
).
last
);
// The menu should be positioned directly next to the top of the button.
// The 8.0 pixels is [_kMenuScreenPadding].
expect
(
popupMenu
,
const
Offset
(
8.0
,
50.0
));
});
}
}
class
TestApp
extends
StatefulWidget
{
class
TestApp
extends
StatefulWidget
{
...
...
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