Remove Cupertino shell branches
Keep the Material-only shell path while preserving public cupertino parameters for callers. Narrow matching tests to Material hosts and behavior because the app always runs under MaterialApp.
This commit is contained in:
@@ -1,52 +1,37 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/shell/destination.dart';
|
||||
import 'package:pipelines_app/shell/empty_detail_pane.dart';
|
||||
|
||||
/// One placeholder for an empty detail pane: the destination's icon above a
|
||||
/// short muted line, centred, on both hosts.
|
||||
/// short muted line, centred.
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
for (final destination in [
|
||||
AppDestination.runs,
|
||||
AppDestination.chat,
|
||||
AppDestination.pipelines,
|
||||
]) {
|
||||
testWidgets('$host ${destination.name}: icon over a muted line', (
|
||||
tester,
|
||||
) async {
|
||||
final content = EmptyDetailPane(
|
||||
destination: destination,
|
||||
message: 'Select one to open it here.',
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: content))
|
||||
: MaterialApp(home: Scaffold(body: content)),
|
||||
);
|
||||
final details = destinationDetails(destination);
|
||||
final icon = find.byIcon(
|
||||
cupertino ? details.cupertinoIcon : details.icon,
|
||||
);
|
||||
expect(icon, findsOneWidget);
|
||||
final text = find.text('Select one to open it here.');
|
||||
expect(
|
||||
tester.getTopLeft(text).dy,
|
||||
greaterThan(tester.getRect(icon).bottom),
|
||||
);
|
||||
// Centred in the pane.
|
||||
final size = tester.view.physicalSize / tester.view.devicePixelRatio;
|
||||
expect(tester.getCenter(text).dx, closeTo(size.width / 2, 1));
|
||||
// Muted: the same secondary colour on the icon and the line.
|
||||
final context = tester.element(text);
|
||||
final muted = cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
expect(tester.widget<Icon>(icon).color, muted);
|
||||
expect(tester.widget<Text>(text).style?.color, muted);
|
||||
});
|
||||
}
|
||||
for (final destination in [
|
||||
AppDestination.runs,
|
||||
AppDestination.chat,
|
||||
AppDestination.pipelines,
|
||||
]) {
|
||||
testWidgets('${destination.name}: icon over a muted line', (tester) async {
|
||||
final content = EmptyDetailPane(
|
||||
destination: destination,
|
||||
message: 'Select one to open it here.',
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: content)));
|
||||
final icon = find.byIcon(destinationDetails(destination).icon);
|
||||
expect(icon, findsOneWidget);
|
||||
final text = find.text('Select one to open it here.');
|
||||
expect(
|
||||
tester.getTopLeft(text).dy,
|
||||
greaterThan(tester.getRect(icon).bottom),
|
||||
);
|
||||
// Centred in the pane.
|
||||
final size = tester.view.physicalSize / tester.view.devicePixelRatio;
|
||||
expect(tester.getCenter(text).dx, closeTo(size.width / 2, 1));
|
||||
// Muted: the same secondary colour on the icon and the line.
|
||||
final context = tester.element(text);
|
||||
final muted = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
expect(tester.widget<Icon>(icon).color, muted);
|
||||
expect(tester.widget<Text>(text).style?.color, muted);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user