mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Added bottom_sheet_rebuild_test
This commit is contained in:
parent
1062c44f4a
commit
ba93987c6e
45
packages/flutter/test/widget/bottom_sheet_rebuild_test.dart
Normal file
45
packages/flutter/test/widget/bottom_sheet_rebuild_test.dart
Normal file
@ -0,0 +1,45 @@
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
test('Verify that a BottomSheet can be rebuilt with ScaffoldFeatureController.setState()', () {
|
||||
testWidgets((WidgetTester tester) {
|
||||
final GlobalKey<ScaffoldState> scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
ScaffoldFeatureController bottomSheet;
|
||||
int buildCount = 0;
|
||||
|
||||
tester.pumpWidget(new MaterialApp(
|
||||
routes: <String, RouteBuilder>{
|
||||
'/': (RouteArguments args) {
|
||||
return new Scaffold(
|
||||
key: scaffoldKey,
|
||||
body: new Center(child: new Text('body'))
|
||||
);
|
||||
}
|
||||
}
|
||||
));
|
||||
|
||||
bottomSheet = scaffoldKey.currentState.showBottomSheet((_) {
|
||||
return new Builder(
|
||||
builder: (_) {
|
||||
buildCount += 1;
|
||||
return new Container(height: 200.0);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
tester.pump();
|
||||
expect(buildCount, equals(1));
|
||||
|
||||
bottomSheet.setState((){ });
|
||||
tester.pump();
|
||||
expect(buildCount, equals(2));
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user