Remove Cupertino changes branches
Keep the Material-only changes feature while preserving public Cupertino parameters for callers. Remove Cupertino-only widgets, imports, hosts, and tests because the app never reaches that path.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@@ -363,49 +362,6 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino uses native list tiles and segmented control', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
cupertinoHost(
|
||||
ChangesViewer(
|
||||
steps: [
|
||||
stepFixture(
|
||||
fileChanges: captureFixture(
|
||||
files: [
|
||||
fileChangeFixture(
|
||||
path: 'lib/feature.dart',
|
||||
patch: multiHunkPatch,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(find.byType(CupertinoListTile), findsOneWidget);
|
||||
// No filter field: the changes list shows every recorded file.
|
||||
expect(find.byType(CupertinoSearchTextField), findsNothing);
|
||||
expect(find.byType(TextField), findsNothing);
|
||||
|
||||
await tester.tap(find.byKey(const ValueKey('change-1-lib/feature.dart')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.byType(CupertinoSlidingSegmentedControl<DiffForm>),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Rendered'), findsOneWidget);
|
||||
expect(find.text('Raw patch'), findsOneWidget);
|
||||
|
||||
await tester.pageBack();
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.byType(CupertinoSlidingSegmentedControl<DiffForm>),
|
||||
findsNothing,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('narrow viewport and large text keep every control reachable', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -219,81 +218,6 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('the Cupertino raw patch is a native selectable field', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
cupertinoHost(
|
||||
SizedBox(
|
||||
height: 400,
|
||||
child: FileDiffViewer(
|
||||
file: FileChange(
|
||||
path: 'lib/feature.dart',
|
||||
kind: ChangeKind.modified,
|
||||
patch: multiHunkPatch,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.tap(find.text('Raw patch'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// A CupertinoApp has no MaterialLocalizations, so Raw must not use the
|
||||
// Material SelectionArea; it renders the recorded bytes in a native field.
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(find.byType(SelectionArea), findsNothing);
|
||||
final field = tester.widget<CupertinoTextField>(
|
||||
find.byKey(const ValueKey('raw-patch-field')),
|
||||
);
|
||||
expect(field.readOnly, isTrue);
|
||||
expect(field.maxLines, isNull);
|
||||
expect(field.controller?.text, multiHunkPatch);
|
||||
expect(
|
||||
find.ancestor(
|
||||
of: find.byKey(const ValueKey('raw-patch-field')),
|
||||
matching: find.byWidgetPredicate(
|
||||
(widget) =>
|
||||
widget is SingleChildScrollView &&
|
||||
widget.scrollDirection == Axis.horizontal,
|
||||
),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('a Cupertino row wraps its recorded path instead of clipping it', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(320, 720);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
const path =
|
||||
'lib/features/changes/domain/a_rather_long_unified_patch_file_name.dart';
|
||||
await tester.pumpWidget(
|
||||
cupertinoHost(
|
||||
ChangesViewer(
|
||||
steps: [
|
||||
stepFixture(
|
||||
fileChanges: captureFixture(
|
||||
files: [fileChangeFixture(path: path, patch: multiHunkPatch)],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
final rich = tester
|
||||
.widgetList<RichText>(find.byType(RichText))
|
||||
.firstWhere((widget) => widget.text.toPlainText() == path);
|
||||
// CupertinoListTile caps a title at one ellipsized line; the row must lift
|
||||
// that cap so the filename stays visible.
|
||||
expect(rich.maxLines, isNull);
|
||||
expect(rich.overflow, TextOverflow.visible);
|
||||
expect(tester.getSize(find.text(path)).height, greaterThan(30));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('a file opens as a page that steps to the previous and next '
|
||||
'file', (tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
@@ -341,112 +265,72 @@ void main() {
|
||||
patch: multiHunkPatch,
|
||||
);
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets('$host diff labels stay whole at 320x720 with 2x text', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(320, 720);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final opener = _diffDialogOpener(diffFile);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? cupertinoHost(opener, scaler: const TextScaler.linear(2))
|
||||
: materialHost(opener, scaler: const TextScaler.linear(2)),
|
||||
);
|
||||
await tester.tap(find.text('Open diff'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// A segmented control cannot keep both fixed words at this size, so the
|
||||
// host's native menu carries them instead. "Rendered" used to break
|
||||
// mid-word and "Raw patch" used to be clipped to "Raw".
|
||||
expect(find.byType(SegmentedButton<DiffForm>), findsNothing);
|
||||
expect(
|
||||
find.byType(CupertinoSlidingSegmentedControl<DiffForm>),
|
||||
findsNothing,
|
||||
);
|
||||
|
||||
// Copy patch stays a standard action at intrinsic width; it must not
|
||||
// break its two words either.
|
||||
_expectWholeLabel(tester, find.text('Copy patch'), 'Copy patch');
|
||||
|
||||
await tester.tap(
|
||||
cupertino
|
||||
? find.byIcon(CupertinoIcons.ellipsis)
|
||||
: find.byTooltip('Diff form'),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final items = cupertino
|
||||
? find.byType(CupertinoActionSheetAction)
|
||||
: find.byType(ListTile);
|
||||
expect(items, findsNWidgets(2));
|
||||
for (final label in ['Rendered', 'Raw patch']) {
|
||||
_expectWholeLabel(
|
||||
tester,
|
||||
find.descendant(of: items, matching: find.text(label)),
|
||||
label,
|
||||
);
|
||||
}
|
||||
|
||||
await tester.tap(
|
||||
find.descendant(of: items, matching: find.text('Raw patch')),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
if (cupertino) {
|
||||
expect(find.byKey(const ValueKey('raw-patch-field')), findsOneWidget);
|
||||
} else {
|
||||
expect(find.text(multiHunkPatch), findsOneWidget);
|
||||
}
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets(
|
||||
'${cupertino ? 'Cupertino' : 'Material'} wide host keeps the native '
|
||||
'segmented control',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? cupertinoHost(_diffDialogOpener(diffFile))
|
||||
: materialHost(_diffDialogOpener(diffFile)),
|
||||
);
|
||||
await tester.tap(find.text('Open diff'));
|
||||
await tester.pumpAndSettle();
|
||||
final control = cupertino
|
||||
? find.byType(CupertinoSlidingSegmentedControl<DiffForm>)
|
||||
: find.byType(SegmentedButton<DiffForm>);
|
||||
expect(control, findsOneWidget);
|
||||
expect(tester.getSize(control).height, greaterThanOrEqualTo(44));
|
||||
expect(find.text('Rendered'), findsOneWidget);
|
||||
expect(find.text('Raw patch'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
testWidgets('diff labels stay whole at 320x720 with 2x text', (tester) async {
|
||||
tester.view.physicalSize = const Size(320, 720);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final opener = _diffDialogOpener(diffFile);
|
||||
await tester.pumpWidget(
|
||||
materialHost(opener, scaler: const TextScaler.linear(2)),
|
||||
);
|
||||
}
|
||||
await tester.tap(find.text('Open diff'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('Escape closes the full-screen diff '
|
||||
'(${cupertino ? 'cupertino' : 'material'})', (tester) async {
|
||||
final file = FileChange(
|
||||
path: 'lib/first.dart',
|
||||
kind: ChangeKind.modified,
|
||||
patch: _raggedPatch,
|
||||
// A segmented control cannot keep both fixed words at this size, so the
|
||||
// diff form menu carries them instead. "Rendered" used to break
|
||||
// mid-word and "Raw patch" used to be clipped to "Raw".
|
||||
expect(find.byType(SegmentedButton<DiffForm>), findsNothing);
|
||||
|
||||
// Copy patch stays a standard action at intrinsic width; it must not
|
||||
// break its two words either.
|
||||
_expectWholeLabel(tester, find.text('Copy patch'), 'Copy patch');
|
||||
|
||||
await tester.tap(find.byTooltip('Diff form'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final items = find.byType(ListTile);
|
||||
expect(items, findsNWidgets(2));
|
||||
for (final label in ['Rendered', 'Raw patch']) {
|
||||
_expectWholeLabel(
|
||||
tester,
|
||||
find.descendant(of: items, matching: find.text(label)),
|
||||
label,
|
||||
);
|
||||
final opener = _diffDialogOpener(file);
|
||||
await tester.pumpWidget(
|
||||
cupertino ? cupertinoHost(opener) : materialHost(opener),
|
||||
);
|
||||
await tester.tap(find.text('Open diff'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(FileDiffPage), findsOneWidget);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(FileDiffPage), findsNothing);
|
||||
expect(find.text('Open diff'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
await tester.tap(
|
||||
find.descendant(of: items, matching: find.text('Raw patch')),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(multiHunkPatch), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('wide host keeps the native segmented control', (tester) async {
|
||||
await tester.pumpWidget(materialHost(_diffDialogOpener(diffFile)));
|
||||
await tester.tap(find.text('Open diff'));
|
||||
await tester.pumpAndSettle();
|
||||
final control = find.byType(SegmentedButton<DiffForm>);
|
||||
expect(control, findsOneWidget);
|
||||
expect(tester.getSize(control).height, greaterThanOrEqualTo(44));
|
||||
expect(find.text('Rendered'), findsOneWidget);
|
||||
expect(find.text('Raw patch'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('Escape closes the full-screen diff', (tester) async {
|
||||
final file = FileChange(
|
||||
path: 'lib/first.dart',
|
||||
kind: ChangeKind.modified,
|
||||
patch: _raggedPatch,
|
||||
);
|
||||
await tester.pumpWidget(materialHost(_diffDialogOpener(file)));
|
||||
await tester.tap(find.text('Open diff'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(FileDiffPage), findsOneWidget);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(FileDiffPage), findsNothing);
|
||||
expect(find.text('Open diff'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// The two platform hosts the Changes widget tests share: Material for
|
||||
/// Android/desktop/web and Cupertino for iOS/macOS. They state the platform
|
||||
/// explicitly instead of mutating a global debug override.
|
||||
/// The host the Changes widget tests share. The app is Material-only on every
|
||||
/// platform, so the tests state the host explicitly instead of mutating a
|
||||
/// global debug override.
|
||||
Widget materialHost(
|
||||
Widget child, {
|
||||
TextScaler scaler = TextScaler.noScaling,
|
||||
@@ -18,24 +17,3 @@ Widget materialHost(
|
||||
home: Scaffold(body: child),
|
||||
);
|
||||
}
|
||||
|
||||
Widget cupertinoHost(
|
||||
Widget child, {
|
||||
TextScaler scaler = TextScaler.noScaling,
|
||||
Brightness brightness = Brightness.light,
|
||||
}) {
|
||||
return CupertinoApp(
|
||||
theme: CupertinoThemeData(brightness: brightness),
|
||||
builder: (context, app) => Theme(
|
||||
// The real app selects Cupertino by platform; the test host states it
|
||||
// explicitly without changing a global debug override. The Theme wraps
|
||||
// the Navigator so dialogs opened later resolve the same platform.
|
||||
data: ThemeData(platform: TargetPlatform.iOS),
|
||||
child: MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(textScaler: scaler),
|
||||
child: app!,
|
||||
),
|
||||
),
|
||||
home: CupertinoPageScaffold(child: SafeArea(child: child)),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user