Remove Cupertino settings branches
Keep the Material settings implementation while preserving public Cupertino parameters for later cleanup. Narrow settings tests to the Material-only behavior.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@@ -252,7 +251,6 @@ void main() {
|
||||
|
||||
await _pump(tester, client, platform: TargetPlatform.iOS);
|
||||
|
||||
expect(find.byType(CupertinoTextField), findsNothing);
|
||||
expect(find.byType(TextField), findsWidgets);
|
||||
expect(find.byKey(SettingsKeys.connect), findsOneWidget);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_tabs.dart';
|
||||
@@ -33,7 +32,7 @@ class _PageState extends State<_Page> {
|
||||
controller: scroll,
|
||||
child: Column(
|
||||
children: [
|
||||
CupertinoTextField(controller: text),
|
||||
TextField(controller: text),
|
||||
for (var i = 0; i < 80; i++) Text('${widget.name} item $i'),
|
||||
],
|
||||
),
|
||||
@@ -41,84 +40,66 @@ class _PageState extends State<_Page> {
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('lazy topic pages retain draft and scroll ($cupertino)', (
|
||||
tester,
|
||||
) async {
|
||||
final mounts = <SettingsTopic, int>{};
|
||||
final tabs = SettingsTopicTabs(
|
||||
pages: {
|
||||
for (final topic in SettingsTopic.values)
|
||||
topic: (_) => _Page(
|
||||
name: topic.name,
|
||||
onMount: () =>
|
||||
mounts.update(topic, (count) => count + 1, ifAbsent: () => 1),
|
||||
),
|
||||
},
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: tabs))
|
||||
: MaterialApp(home: Scaffold(body: tabs)),
|
||||
);
|
||||
expect(mounts, {SettingsTopic.appearance: 1});
|
||||
final appearance = tester.state<_PageState>(find.byType(_Page));
|
||||
appearance.text.text = 'Keep this draft';
|
||||
appearance.scroll.jumpTo(150);
|
||||
await tester.pump();
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
expect(mounts, {
|
||||
SettingsTopic.appearance: 1,
|
||||
SettingsTopic.connection: 1,
|
||||
});
|
||||
final connection = tester.state<_PageState>(find.byType(_Page));
|
||||
connection.text.text = 'Unsubmitted server';
|
||||
connection.scroll.jumpTo(280);
|
||||
await selectSettingsTopic(tester, 'Appearance');
|
||||
expect(tester.state(find.byType(_Page)), same(appearance));
|
||||
expect(appearance.text.text, 'Keep this draft');
|
||||
expect(appearance.scroll.offset, 150);
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
expect(tester.state(find.byType(_Page)), same(connection));
|
||||
expect(connection.text.text, 'Unsubmitted server');
|
||||
expect(connection.scroll.offset, 280);
|
||||
expect(mounts.values, everyElement(1));
|
||||
});
|
||||
testWidgets('lazy topic pages retain draft and scroll', (tester) async {
|
||||
final mounts = <SettingsTopic, int>{};
|
||||
final tabs = SettingsTopicTabs(
|
||||
pages: {
|
||||
for (final topic in SettingsTopic.values)
|
||||
topic: (_) => _Page(
|
||||
name: topic.name,
|
||||
onMount: () =>
|
||||
mounts.update(topic, (count) => count + 1, ifAbsent: () => 1),
|
||||
),
|
||||
},
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: tabs)));
|
||||
expect(mounts, {SettingsTopic.appearance: 1});
|
||||
final appearance = tester.state<_PageState>(find.byType(_Page));
|
||||
appearance.text.text = 'Keep this draft';
|
||||
appearance.scroll.jumpTo(150);
|
||||
await tester.pump();
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
expect(mounts, {SettingsTopic.appearance: 1, SettingsTopic.connection: 1});
|
||||
final connection = tester.state<_PageState>(find.byType(_Page));
|
||||
connection.text.text = 'Unsubmitted server';
|
||||
connection.scroll.jumpTo(280);
|
||||
await selectSettingsTopic(tester, 'Appearance');
|
||||
expect(tester.state(find.byType(_Page)), same(appearance));
|
||||
expect(appearance.text.text, 'Keep this draft');
|
||||
expect(appearance.scroll.offset, 150);
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
expect(tester.state(find.byType(_Page)), same(connection));
|
||||
expect(connection.text.text, 'Unsubmitted server');
|
||||
expect(connection.scroll.offset, 280);
|
||||
expect(mounts.values, everyElement(1));
|
||||
});
|
||||
|
||||
testWidgets('all topics reachable at narrow large text ($cupertino)', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final tabs = SettingsTopicTabs(
|
||||
pages: {
|
||||
for (final topic in SettingsTopic.values)
|
||||
topic: (_) => Text('${topic.label} content'),
|
||||
},
|
||||
);
|
||||
Widget scale(BuildContext context, Widget? child) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: const TextScaler.linear(2)),
|
||||
child: child!,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
builder: scale,
|
||||
home: CupertinoPageScaffold(child: tabs),
|
||||
)
|
||||
: MaterialApp(
|
||||
builder: scale,
|
||||
home: Scaffold(body: tabs),
|
||||
),
|
||||
);
|
||||
for (final topic in SettingsTopic.values) {
|
||||
await selectSettingsTopic(tester, topic.label);
|
||||
expect(find.text('${topic.label} content'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
}
|
||||
});
|
||||
}
|
||||
testWidgets('all topics reachable at narrow large text', (tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final tabs = SettingsTopicTabs(
|
||||
pages: {
|
||||
for (final topic in SettingsTopic.values)
|
||||
topic: (_) => Text('${topic.label} content'),
|
||||
},
|
||||
);
|
||||
Widget scale(BuildContext context, Widget? child) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: const TextScaler.linear(2)),
|
||||
child: child!,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: scale,
|
||||
home: Scaffold(body: tabs),
|
||||
),
|
||||
);
|
||||
for (final topic in SettingsTopic.values) {
|
||||
await selectSettingsTopic(tester, topic.label);
|
||||
expect(find.text('${topic.label} content'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/servers/server_scope.dart';
|
||||
@@ -11,11 +10,7 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'settings_topic_test_helper.dart';
|
||||
|
||||
Widget host({
|
||||
bool cupertino = false,
|
||||
String? scope,
|
||||
SettingsTopicStore? store,
|
||||
}) {
|
||||
Widget host({String? scope, SettingsTopicStore? store}) {
|
||||
final tabs = SettingsTopicTabs(
|
||||
navigationScope: scope,
|
||||
selectionStore: store,
|
||||
@@ -24,9 +19,7 @@ Widget host({
|
||||
topic: (_) => Text('${topic.name} page'),
|
||||
},
|
||||
);
|
||||
return cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: tabs))
|
||||
: MaterialApp(home: Scaffold(body: tabs));
|
||||
return MaterialApp(home: Scaffold(body: tabs));
|
||||
}
|
||||
|
||||
class DelayedStore implements SettingsTopicStore {
|
||||
@@ -67,26 +60,22 @@ class SharedQueuedTopicStore implements SettingsTopicStore {
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('restores selected category after recreation ($cupertino)', (
|
||||
tester,
|
||||
) async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
await tester.pumpWidget(host(cupertino: cupertino, scope: 'server-a'));
|
||||
await tester.pumpAndSettle();
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
expect(find.text('connection page'), findsOneWidget);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pumpWidget(host(cupertino: cupertino, scope: 'server-a'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('connection page'), findsOneWidget);
|
||||
final preferences = await SharedPreferences.getInstance();
|
||||
expect(
|
||||
preferences.getString(scopedServerKey(settingsTopicKey, 'server-a')),
|
||||
'connection',
|
||||
);
|
||||
});
|
||||
}
|
||||
testWidgets('restores selected category after recreation', (tester) async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
await tester.pumpWidget(host(scope: 'server-a'));
|
||||
await tester.pumpAndSettle();
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
expect(find.text('connection page'), findsOneWidget);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pumpWidget(host(scope: 'server-a'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('connection page'), findsOneWidget);
|
||||
final preferences = await SharedPreferences.getInstance();
|
||||
expect(
|
||||
preferences.getString(scopedServerKey(settingsTopicKey, 'server-a')),
|
||||
'connection',
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('server scopes and malformed selections are independent', (
|
||||
tester,
|
||||
|
||||
Reference in New Issue
Block a user