1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 13:58:47 +00:00

Updates for 2.8! (#961)

This commit is contained in:
Andrew Brogdon
2021-12-08 22:15:57 -05:00
committed by GitHub
parent be34b0bf43
commit 664b63c03c
54 changed files with 216 additions and 233 deletions

View File

@@ -10,25 +10,33 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:platform_design/main.dart';
void main() {
testWidgets('Can change platform correctly', (tester) async {
await tester.pumpWidget(const MyAdaptingApp());
group('Platform tests', () {
testWidgets('Builds for Android correctly', (tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.android;
await tester.pumpWidget(const MyAdaptingApp());
// The test should be able to find the drawer button.
expect(find.byIcon(Icons.menu), findsOneWidget);
// There should be a refresh button.
expect(find.byIcon(Icons.refresh), findsOneWidget);
// The test should be able to find the drawer button.
expect(find.byIcon(Icons.menu), findsOneWidget);
// There should be a refresh button.
expect(find.byIcon(Icons.refresh), findsOneWidget);
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
await tester.pumpWidget(const MyAdaptingApp());
// Since this is a static, undo any change made in the test.
debugDefaultTargetPlatformOverride = null;
});
// There should now be a large title style nav bar.
expect(find.byType(CupertinoSliverNavigationBar), findsOneWidget);
// There's a tab button for the first tab.
expect(find.byIcon(CupertinoIcons.music_note), findsOneWidget);
// The hamburger button isn't there anymore.
expect(find.byIcon(Icons.menu), findsNothing);
testWidgets('Builds for iOS correctly', (tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
await tester.pumpWidget(const MyAdaptingApp());
// Since this is a static, undo the change made in the test.
debugDefaultTargetPlatformOverride = null;
// There should now be a large title style nav bar.
expect(find.byType(CupertinoSliverNavigationBar), findsOneWidget);
// There's a tab button for the first tab.
expect(find.byIcon(CupertinoIcons.music_note), findsOneWidget);
// The hamburger button isn't there anymore.
expect(find.byIcon(Icons.menu), findsNothing);
// Since this is a static, undo any change made in the test.
debugDefaultTargetPlatformOverride = null;
});
});
}