Skip to content

Commit

Permalink
add test to needCallback argument
Browse files Browse the repository at this point in the history
  • Loading branch information
peng8350 committed May 7, 2021
1 parent 9f84946 commit 22a700f
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion test/refresh_controller_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Widget buildRefresher(RefreshController controller, {int count: 20}) {
enablePullUp: true,
child: ListView.builder(
itemBuilder: (c, i) => Text(data[i]),
itemCount: 0,
itemCount: count,
itemExtent: 100,
),
controller: controller,
Expand Down Expand Up @@ -74,6 +74,50 @@ void testRequestFun(bool full) {
await tester.pumpAndSettle();
expect(_refreshController.headerStatus, RefreshStatus.idle);
});

testWidgets("requestRefresh needCallBack test",
(tester) async {
final RefreshController _refreshController =
RefreshController(initialRefresh: false);
int timerr = 0;
await tester
.pumpWidget(Directionality(
textDirection: TextDirection.ltr,
child: Container(
width: 375.0,
height: 690.0,
child: SmartRefresher(
header: TestHeader(),
footer: TestFooter(),
enablePullDown: true,
enablePullUp: true,
onRefresh: (){
timerr++;

},
onLoading: (){
timerr++;

},
child: ListView.builder(
itemBuilder: (c, i) => Text(data[i]),
itemCount: 20,
itemExtent: 100,
),
controller: _refreshController,
),
),
));
_refreshController.requestRefresh(needCallback: false);
await tester.pumpAndSettle();
expect(timerr, 0);

_refreshController.requestLoading(needCallback: false);
await tester.pumpAndSettle();
expect(timerr, 0);


});
}

void main() {
Expand Down

0 comments on commit 22a700f

Please sign in to comment.