merge(app): land browser-verified adaptive shell
This commit is contained in:
+89
-18
@@ -1,30 +1,101 @@
|
||||
// This is a basic Flutter widget test.
|
||||
//
|
||||
// To perform an interaction with a widget in your test, use the WidgetTester
|
||||
// utility in the flutter_test package. 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/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:pipelines_app/main.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
||||
// Build our app and trigger a frame.
|
||||
await tester.pumpWidget(const MyApp());
|
||||
for (final width in [390.0, 1000.0]) {
|
||||
testWidgets(
|
||||
'Material shell adapts at width $width and supports large text',
|
||||
(tester) async {
|
||||
tester.view.physicalSize = Size(width, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: MediaQuery(
|
||||
data: MediaQueryData(textScaler: TextScaler.linear(2)),
|
||||
child: AdaptiveShell(),
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(find.text('Pipelines'), findsWidgets);
|
||||
expect(find.text('Pipelines — Not implemented'), findsOneWidget);
|
||||
expect(
|
||||
find.byType(NavigationBar),
|
||||
width < 600 ? findsOneWidget : findsNothing,
|
||||
);
|
||||
expect(
|
||||
find.byType(NavigationRail),
|
||||
width >= 600 ? findsOneWidget : findsNothing,
|
||||
);
|
||||
await tester.tap(find.text('Runs').last);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Runs — Not implemented'), findsOneWidget);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// Verify that our counter starts at 0.
|
||||
expect(find.text('0'), findsOneWidget);
|
||||
expect(find.text('1'), findsNothing);
|
||||
testWidgets('Cupertino shell uses native navigation controls', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(const MyApp(cupertino: true));
|
||||
expect(find.byType(CupertinoNavigationBar), findsOneWidget);
|
||||
expect(find.byType(CupertinoTabBar), findsOneWidget);
|
||||
expect(find.text('Pipelines — Not implemented'), findsOneWidget);
|
||||
});
|
||||
|
||||
// Tap the '+' icon and trigger a frame.
|
||||
await tester.tap(find.byIcon(Icons.add));
|
||||
testWidgets('Cupertino content stays inside safe area', (tester) async {
|
||||
tester.view.padding = const FakeViewPadding(top: 36, bottom: 28);
|
||||
addTearDown(tester.view.resetPadding);
|
||||
await tester.pumpWidget(const MyApp(cupertino: true));
|
||||
final tabBar = tester.getRect(find.byType(CupertinoTabBar));
|
||||
expect(tabBar.bottom, lessThanOrEqualTo(900 - 28));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('destination state survives switching tabs', (tester) async {
|
||||
var builds = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: AdaptiveShell(
|
||||
destinationBodies: {
|
||||
AppDestination.pipelines: (_) => StatefulBuilder(
|
||||
builder: (context, setState) => TextButton(
|
||||
onPressed: () => setState(() => builds++),
|
||||
child: Text('Builds: $builds'),
|
||||
),
|
||||
),
|
||||
AppDestination.runs: (_) => const Text('Runs screen'),
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.tap(find.text('Builds: 0'));
|
||||
await tester.pump();
|
||||
await tester.tap(find.text('Runs').last);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Pipelines').last);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Builds: 1'), findsOneWidget);
|
||||
});
|
||||
|
||||
// Verify that our counter has incremented.
|
||||
expect(find.text('0'), findsNothing);
|
||||
expect(find.text('1'), findsOneWidget);
|
||||
testWidgets('destination content can be supplied by integration', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: AdaptiveShell(
|
||||
destinationBodies: {
|
||||
AppDestination.pipelines: (_) =>
|
||||
const Text('Injected pipelines screen'),
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(find.text('Injected pipelines screen'), findsOneWidget);
|
||||
expect(find.text('Pipelines — Not implemented'), findsNothing);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user