flutter-test: Let simple test pass

This commit is contained in:
Calcitem 2021-03-07 09:22:29 +08:00
parent 7f2d91ffa3
commit e0510bf89e
1 changed files with 25 additions and 23 deletions

View File

@ -16,32 +16,34 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// This is a basic Flutter widget test. import 'package:flutter/material.dart';
// import 'package:flutter_localizations/flutter_localizations.dart';
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
//import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
//import '../lib/main.dart'; import 'package:sanmill/generated/l10n.dart';
import 'package:sanmill/widgets/navigation_home_screen.dart';
void main() { void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async { Widget makeTestableWidget({@required Widget child, @required Locale locale}) {
// Build our app and trigger a frame. return MaterialApp(
//await tester.pumpWidget(SanmillApp()); localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: S.delegate.supportedLocales,
locale: locale,
home: child,
);
}
// Verify that our counter starts at 0. testWidgets('Widget', (WidgetTester tester) async {
//expect(find.text('0'), findsOneWidget); NavigationHomeScreen screen = NavigationHomeScreen();
//expect(find.text('1'), findsNothing); await tester.pumpWidget(makeTestableWidget(
child: screen,
// Tap the '+' icon and trigger a frame. locale: const Locale('en'),
//await tester.tap(find.byIcon(Icons.add)); ));
// await tester.pump(); await tester.pump();
expect(find.text(S.current.appName), findsOneWidget);
// Verify that our counter has incremented.
//expect(find.text('0'), findsNothing);
//expect(find.text('1'), findsOneWidget);
}); });
} }