Complete Material-only APIs and fixtures
Remove obsolete control-family flags and icon metadata across all callers, dead alternate themes and host helpers, obsolete test setup, and the unused icon-font dependency. Preserve native Material Back transitions. Make navigation fixtures independent of update plugins and answer auxiliary shell snapshots so the complete application suite can run deterministically.
This commit is contained in:
@@ -17,9 +17,9 @@ Future<void> pumpApp(
|
||||
}) async {
|
||||
await tester.pumpWidget(
|
||||
PipelinesApp(
|
||||
androidSupported: false,
|
||||
server: webServer(),
|
||||
client: client,
|
||||
cupertino: false,
|
||||
routeInformationProvider: provider,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:pipelines_app/application/app_router.dart';
|
||||
|
||||
AppRouterDelegate delegate(AppRoute initial) => AppRouterDelegate(
|
||||
builder: (context, route) => const SizedBox.shrink(),
|
||||
cupertino: false,
|
||||
initial: initial,
|
||||
);
|
||||
|
||||
@@ -16,7 +15,6 @@ Future<AppRouterDelegate> pumpRouter(
|
||||
final router = AppRouterDelegate(
|
||||
builder: (_, route) => Scaffold(body: Text(route.path)),
|
||||
templatesBuilder: (_) => const Scaffold(body: Text('Templates page')),
|
||||
cupertino: false,
|
||||
initial: initial,
|
||||
);
|
||||
addTearDown(router.dispose);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@@ -51,6 +50,17 @@ Future<Map<String, dynamic>> waitForRequest(
|
||||
if (type != 'chat_automations') {
|
||||
for (final raw in channel.outgoing.toList()) {
|
||||
final metadata = jsonDecode(raw as String) as Map<String, dynamic>;
|
||||
if (metadata['type'] == 'chat_shell_runs' &&
|
||||
type != 'chat_shell_runs' &&
|
||||
replied.add('${metadata['id']}')) {
|
||||
channel.incoming.add(
|
||||
jsonEncode({
|
||||
'id': metadata['id'],
|
||||
'type': 'chat_shell_runs',
|
||||
'chat_shell_runs': const [],
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (metadata['type'] == 'chat_automations' &&
|
||||
replied.add('${metadata['id']}')) {
|
||||
channel.incoming.add(
|
||||
@@ -71,7 +81,10 @@ Future<Map<String, dynamic>> waitForRequest(
|
||||
if (request != null) return request;
|
||||
await tester.pump(const Duration(milliseconds: 5));
|
||||
}
|
||||
fail('Timed out waiting for $type #$index');
|
||||
final emitted = channel.outgoing
|
||||
.map((raw) => (jsonDecode(raw as String) as Map)['type'])
|
||||
.toList();
|
||||
fail('Timed out waiting for $type #$index; emitted requests: $emitted');
|
||||
}
|
||||
|
||||
Future<void> replySessions(
|
||||
@@ -246,7 +259,6 @@ void main() {
|
||||
androidSupported: false,
|
||||
server: webServer(),
|
||||
client: client,
|
||||
cupertino: false,
|
||||
routeInformationProvider: provider,
|
||||
),
|
||||
);
|
||||
@@ -282,7 +294,6 @@ void main() {
|
||||
// The shell's bar and the conversation's own header.
|
||||
expect(find.byType(SegmentedBar), findsNWidgets(2));
|
||||
expect(find.byType(AppBar), findsNothing);
|
||||
expect(find.byType(CupertinoNavigationBar), findsNothing);
|
||||
expect(find.byKey(const Key('chat-thread-header')), findsOneWidget);
|
||||
expect(findNativeBack(), findsNothing);
|
||||
|
||||
@@ -371,7 +382,6 @@ void main() {
|
||||
androidSupported: false,
|
||||
server: webServer(),
|
||||
client: client,
|
||||
cupertino: false,
|
||||
routeInformationProvider: provider,
|
||||
),
|
||||
);
|
||||
@@ -580,7 +590,6 @@ void main() {
|
||||
androidSupported: false,
|
||||
server: webServer(),
|
||||
client: client,
|
||||
cupertino: false,
|
||||
routeInformationProvider: provider,
|
||||
),
|
||||
);
|
||||
@@ -663,7 +672,6 @@ void main() {
|
||||
androidSupported: false,
|
||||
server: webServer(),
|
||||
client: client,
|
||||
cupertino: false,
|
||||
routeInformationProvider: provider,
|
||||
),
|
||||
);
|
||||
@@ -733,7 +741,6 @@ void main() {
|
||||
androidSupported: false,
|
||||
server: webServer(),
|
||||
client: client,
|
||||
cupertino: false,
|
||||
routeInformationProvider: provider,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -74,7 +74,6 @@ void main() {
|
||||
late final AppRouterDelegate router;
|
||||
router = AppRouterDelegate(
|
||||
initial: AppRoute.chat,
|
||||
cupertino: false,
|
||||
builder: (_, route) => AdaptiveShell(
|
||||
destination: AppDestination.chat,
|
||||
destinationBodies: {
|
||||
|
||||
@@ -54,7 +54,6 @@ void main() {
|
||||
late final AppRouterDelegate router;
|
||||
router = AppRouterDelegate(
|
||||
initial: AppRoute.chat,
|
||||
cupertino: false,
|
||||
builder: (_, route) => AdaptiveShell(
|
||||
destination: AppDestination.chat,
|
||||
destinationBodies: {
|
||||
|
||||
@@ -184,7 +184,7 @@ void main() {
|
||||
tester.widget<Material>(surface).color,
|
||||
selected
|
||||
? tester.widget<AppListRow>(row).selectedFill ??
|
||||
AppListRow.selectedColor(context, cupertino: false)
|
||||
AppListRow.selectedColor(context)
|
||||
: const Color(0x00000000),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -66,9 +66,9 @@ void main() {
|
||||
|
||||
await tester.pumpWidget(
|
||||
PipelinesApp(
|
||||
androidSupported: false,
|
||||
server: webServer(),
|
||||
client: client,
|
||||
cupertino: false,
|
||||
routeInformationProvider: provider,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -39,7 +39,6 @@ Future<void> pumpApp(
|
||||
client: client,
|
||||
// Navigation fixtures do not exercise native update plugins.
|
||||
androidSupported: false,
|
||||
cupertino: false,
|
||||
routeInformationProvider: provider,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -35,9 +35,9 @@ void main() {
|
||||
|
||||
await tester.pumpWidget(
|
||||
PipelinesApp(
|
||||
androidSupported: false,
|
||||
server: webServer(),
|
||||
client: client,
|
||||
cupertino: false,
|
||||
routeInformationProvider: provider,
|
||||
),
|
||||
);
|
||||
@@ -64,9 +64,7 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
|
||||
await tester.pump();
|
||||
expect(
|
||||
selectableText(
|
||||
'name: Alpha review\nstages:\n review:\n type: model',
|
||||
),
|
||||
selectableText('name: Alpha review\nstages:\n review:\n type: model'),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
|
||||
@@ -79,9 +79,9 @@ void main() {
|
||||
|
||||
await tester.pumpWidget(
|
||||
PipelinesApp(
|
||||
androidSupported: false,
|
||||
server: webServer(),
|
||||
client: client,
|
||||
cupertino: false,
|
||||
routeInformationProvider: provider,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -807,7 +807,6 @@ void main() {
|
||||
test('openSearch keeps the previous route and closing restores it', () async {
|
||||
final router = AppRouterDelegate(
|
||||
builder: (context, route) => const SizedBox.shrink(),
|
||||
cupertino: false,
|
||||
initial: AppRoute.run(3),
|
||||
);
|
||||
addTearDown(router.dispose);
|
||||
|
||||
@@ -33,9 +33,9 @@ void main() {
|
||||
addTearDown(provider.dispose);
|
||||
await tester.pumpWidget(
|
||||
PipelinesApp(
|
||||
androidSupported: false,
|
||||
server: webServer(),
|
||||
client: PipelinesClient(channelFactory: (_) => channel),
|
||||
cupertino: false,
|
||||
routeInformationProvider: provider,
|
||||
),
|
||||
);
|
||||
@@ -61,9 +61,7 @@ void main() {
|
||||
// Four tabs; Settings is none of them.
|
||||
expect(
|
||||
tester
|
||||
.widget<FloatingDestinationBar>(
|
||||
find.byType(FloatingDestinationBar),
|
||||
)
|
||||
.widget<FloatingDestinationBar>(find.byType(FloatingDestinationBar))
|
||||
.items
|
||||
.map((item) => item.label),
|
||||
['Pipelines', 'Runs', 'Chat', 'Search'],
|
||||
|
||||
@@ -31,9 +31,9 @@ void main() {
|
||||
addTearDown(provider.dispose);
|
||||
await tester.pumpWidget(
|
||||
PipelinesApp(
|
||||
androidSupported: false,
|
||||
server: webServer(),
|
||||
client: client,
|
||||
cupertino: false,
|
||||
routeInformationProvider: provider,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -8,13 +8,14 @@ import 'package:pipelines_app/features/updates/app_updates.dart';
|
||||
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
||||
|
||||
ServerEndpoint server() => ServerEndpoint.resolve(
|
||||
base: Uri.parse('http://127.0.0.1:8096/'),
|
||||
web: true,
|
||||
);
|
||||
base: Uri.parse('http://127.0.0.1:8096/'),
|
||||
web: true,
|
||||
);
|
||||
|
||||
void main() {
|
||||
testWidgets('web launch check is injected, asks once, and does not refresh',
|
||||
(tester) async {
|
||||
testWidgets('web launch check is injected, asks once, and does not refresh', (
|
||||
tester,
|
||||
) async {
|
||||
final channel = FakeChannel()..readyCompleter.complete();
|
||||
final client = PipelinesClient(channelFactory: (_) => channel);
|
||||
final provider = PlatformRouteInformationProvider(
|
||||
@@ -24,19 +25,20 @@ void main() {
|
||||
var reads = 0;
|
||||
var refreshes = 0;
|
||||
|
||||
await tester.pumpWidget(PipelinesApp(
|
||||
server: server(),
|
||||
client: client,
|
||||
cupertino: false,
|
||||
routeInformationProvider: provider,
|
||||
webPlatform: true,
|
||||
webBuildId: 'web-old',
|
||||
webReleaseReader: (_) async {
|
||||
reads++;
|
||||
return '{"schema":1,"platform":"web","buildId":"web-new"}';
|
||||
},
|
||||
webRefresher: () async => refreshes++,
|
||||
));
|
||||
await tester.pumpWidget(
|
||||
PipelinesApp(
|
||||
server: server(),
|
||||
client: client,
|
||||
routeInformationProvider: provider,
|
||||
webPlatform: true,
|
||||
webBuildId: 'web-old',
|
||||
webReleaseReader: (_) async {
|
||||
reads++;
|
||||
return '{"schema":1,"platform":"web","buildId":"web-new"}';
|
||||
},
|
||||
webRefresher: () async => refreshes++,
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(find.text('Update available'), findsOneWidget);
|
||||
@@ -44,25 +46,28 @@ void main() {
|
||||
|
||||
await tester.tap(find.text('Later'));
|
||||
await tester.pump();
|
||||
await tester.pumpWidget(PipelinesApp(
|
||||
server: server(),
|
||||
client: client,
|
||||
cupertino: false,
|
||||
routeInformationProvider: provider,
|
||||
webPlatform: true,
|
||||
webBuildId: 'web-old',
|
||||
webReleaseReader: (_) async {
|
||||
reads++;
|
||||
return '{"schema":1,"platform":"web","buildId":"web-new"}';
|
||||
},
|
||||
webRefresher: () async => refreshes++,
|
||||
));
|
||||
await tester.pumpWidget(
|
||||
PipelinesApp(
|
||||
server: server(),
|
||||
client: client,
|
||||
routeInformationProvider: provider,
|
||||
webPlatform: true,
|
||||
webBuildId: 'web-old',
|
||||
webReleaseReader: (_) async {
|
||||
reads++;
|
||||
return '{"schema":1,"platform":"web","buildId":"web-new"}';
|
||||
},
|
||||
webRefresher: () async => refreshes++,
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.text('Update available'), findsNothing);
|
||||
expect(refreshes, 0);
|
||||
});
|
||||
|
||||
testWidgets('Android launch choice uses the injected installer', (tester) async {
|
||||
testWidgets('Android launch choice uses the injected installer', (
|
||||
tester,
|
||||
) async {
|
||||
final channel = FakeChannel()..readyCompleter.complete();
|
||||
final client = PipelinesClient(channelFactory: (_) => channel);
|
||||
final provider = PlatformRouteInformationProvider(
|
||||
@@ -75,17 +80,18 @@ void main() {
|
||||
versionName: '4',
|
||||
apk: Uri.parse('https://example.test/pipelines.apk'),
|
||||
);
|
||||
await tester.pumpWidget(PipelinesApp(
|
||||
server: server(),
|
||||
client: client,
|
||||
cupertino: false,
|
||||
routeInformationProvider: provider,
|
||||
webPlatform: false,
|
||||
androidSupported: true,
|
||||
installedVersionReader: () async => 3,
|
||||
androidFeedReader: (_) async => update,
|
||||
androidInstaller: (_, {onProgress}) async => installs++,
|
||||
));
|
||||
await tester.pumpWidget(
|
||||
PipelinesApp(
|
||||
server: server(),
|
||||
client: client,
|
||||
routeInformationProvider: provider,
|
||||
webPlatform: false,
|
||||
androidSupported: true,
|
||||
installedVersionReader: () async => 3,
|
||||
androidFeedReader: (_) async => update,
|
||||
androidInstaller: (_, {onProgress}) async => installs++,
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(find.text('Download'), findsOneWidget);
|
||||
|
||||
@@ -30,7 +30,6 @@ void main() {
|
||||
web: true,
|
||||
),
|
||||
client: PipelinesClient(channelFactory: (_) => channel),
|
||||
cupertino: false,
|
||||
routeInformationProvider: provider,
|
||||
webPlatform: web,
|
||||
webPageUri: Uri.parse('https://app.test/chats?selected=1'),
|
||||
@@ -75,7 +74,6 @@ void main() {
|
||||
PipelinesApp(
|
||||
server: ServerEndpoint.resolve(base: Uri(), web: false),
|
||||
client: client,
|
||||
cupertino: false,
|
||||
routeInformationProvider: provider,
|
||||
webPlatform: false,
|
||||
androidSupported: true,
|
||||
@@ -124,7 +122,6 @@ void main() {
|
||||
web: true,
|
||||
),
|
||||
client: client,
|
||||
cupertino: false,
|
||||
routeInformationProvider: provider,
|
||||
webPlatform: false,
|
||||
androidSupported: true,
|
||||
|
||||
@@ -36,9 +36,9 @@ mount(
|
||||
addTearDown(client.dispose);
|
||||
await tester.pumpWidget(
|
||||
PipelinesApp(
|
||||
androidSupported: false,
|
||||
server: webServer(),
|
||||
client: client,
|
||||
cupertino: false,
|
||||
serverId: 'navigation-test',
|
||||
routeInformationProvider: provider,
|
||||
tabLocationsStore: store,
|
||||
@@ -210,11 +210,7 @@ void main() {
|
||||
..value = const TabLocationsSnapshot(
|
||||
routes: {AppDestination.pipelines: AppRoute.settings},
|
||||
);
|
||||
final app = await mount(
|
||||
tester,
|
||||
route: '/?appearance=cupertino',
|
||||
store: store,
|
||||
);
|
||||
final app = await mount(tester, route: '/?preview=1', store: store);
|
||||
await tester.pumpAndSettle();
|
||||
expect(app.provider.value.uri.path, '/settings');
|
||||
expect(find.byType(SettingsScreen), findsOneWidget);
|
||||
|
||||
@@ -21,13 +21,7 @@ void main() {
|
||||
initialRouteInformation: RouteInformation(uri: Uri.parse('/pipelines')),
|
||||
);
|
||||
addTearDown(provider.dispose);
|
||||
await pumpApp(
|
||||
tester,
|
||||
channel: channel,
|
||||
client: client,
|
||||
provider: provider,
|
||||
cupertino: false,
|
||||
);
|
||||
await pumpApp(tester, channel: channel, client: client, provider: provider);
|
||||
await replyPipelines(tester, channel, PipelineFixture());
|
||||
await openSettings(tester, channel, provider);
|
||||
await openTemplates(tester, channel, provider);
|
||||
|
||||
@@ -67,7 +67,6 @@ Future<void> pumpApp(
|
||||
required FakeChannel channel,
|
||||
required PipelinesClient client,
|
||||
required PlatformRouteInformationProvider provider,
|
||||
required bool cupertino,
|
||||
}) async {
|
||||
tester.view.physicalSize = const Size(1100, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
@@ -80,7 +79,6 @@ Future<void> pumpApp(
|
||||
client: client,
|
||||
// This fixture tests template routing, not native update plugins.
|
||||
androidSupported: false,
|
||||
cupertino: false,
|
||||
routeInformationProvider: provider,
|
||||
),
|
||||
);
|
||||
@@ -176,7 +174,6 @@ void main() {
|
||||
channel: channel,
|
||||
client: client,
|
||||
provider: provider,
|
||||
cupertino: false,
|
||||
);
|
||||
await replyPipelines(tester, channel, fixture);
|
||||
|
||||
@@ -272,13 +269,7 @@ void main() {
|
||||
);
|
||||
addTearDown(provider.dispose);
|
||||
|
||||
await pumpApp(
|
||||
tester,
|
||||
channel: channel,
|
||||
client: client,
|
||||
provider: provider,
|
||||
cupertino: false,
|
||||
);
|
||||
await pumpApp(tester, channel: channel, client: client, provider: provider);
|
||||
await replyPipelines(tester, channel, fixture);
|
||||
expect(
|
||||
find.byKey(const Key('pipeline-row-41'), skipOffstage: false),
|
||||
|
||||
@@ -81,16 +81,13 @@ void main() {
|
||||
expect(requested, 1);
|
||||
});
|
||||
|
||||
testWidgets('a stale cupertino flag still draws the Material row', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('the permission prompt draws the Material row', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
attentionApp(
|
||||
Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
child: NotificationPermissionTile(
|
||||
state: NotificationPermissionState.notRequested,
|
||||
cupertino: true,
|
||||
onRequest: _noop,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -55,7 +55,6 @@ Future<void> _pumpShell(
|
||||
child: child!,
|
||||
),
|
||||
home: AdaptiveShell(
|
||||
cupertino: false,
|
||||
destination: AppDestination.chat,
|
||||
destinationBodies: {
|
||||
AppDestination.chat: (_) => ChatScreen(gateway: gateway),
|
||||
|
||||
@@ -64,7 +64,6 @@ Future<_Gateway> _pumpShell(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: platform, brightness: brightness),
|
||||
home: AdaptiveShell(
|
||||
cupertino: false,
|
||||
destination: AppDestination.chat,
|
||||
destinationBodies: {
|
||||
AppDestination.chat: (_) => ChatScreen(gateway: gateway),
|
||||
|
||||
@@ -182,7 +182,6 @@ void main() {
|
||||
test('the route reads its timing from Motion', () {
|
||||
final route = ContainerTransformPageRoute<void>(
|
||||
link: ContainerTransformLink(() => null),
|
||||
cupertino: false,
|
||||
builder: (_) => const SizedBox(),
|
||||
);
|
||||
expect(route.transitionDuration, Motion.containerTransform);
|
||||
|
||||
@@ -102,7 +102,7 @@ Future<void> _pump(
|
||||
}
|
||||
|
||||
/// The mode the drawn control names, or null when the bar has none. A
|
||||
/// Cupertino phone bar draws only the shield, so read the control itself.
|
||||
/// A narrow phone bar draws only the shield, so read the control itself.
|
||||
String? _shown(WidgetTester tester) {
|
||||
if (_modeControl.evaluate().isEmpty) return null;
|
||||
final control = find.byType(ChatModeControl);
|
||||
@@ -112,7 +112,7 @@ String? _shown(WidgetTester tester) {
|
||||
|
||||
void main() {
|
||||
for (final platform in [TargetPlatform.android, TargetPlatform.iOS]) {
|
||||
final style = platform == TargetPlatform.iOS ? 'Cupertino' : 'Material';
|
||||
final style = 'Material on ${platform.name}';
|
||||
|
||||
testWidgets(
|
||||
'$style: an existing chat opened from the list shows its mode',
|
||||
|
||||
@@ -64,7 +64,6 @@ Future<_Gateway> _setup(WidgetTester tester, {bool inShell = false}) async {
|
||||
inShell
|
||||
? MaterialApp(
|
||||
home: AdaptiveShell(
|
||||
cupertino: false,
|
||||
destination: AppDestination.chat,
|
||||
destinationBodies: {
|
||||
AppDestination.chat: (_) => ChatScreen(gateway: gateway),
|
||||
|
||||
@@ -58,7 +58,6 @@ Future<void> _mount(WidgetTester tester, Size size) async {
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.android),
|
||||
home: AdaptiveShell(
|
||||
cupertino: false,
|
||||
destination: AppDestination.chat,
|
||||
destinationBodies: {
|
||||
AppDestination.chat: (_) => ChatScreen(gateway: gateway),
|
||||
|
||||
@@ -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';
|
||||
@@ -17,7 +16,6 @@ void main() {
|
||||
await pumpIosMaterialChat(tester, FakeChatGateway());
|
||||
|
||||
expect(find.byType(Scaffold), findsWidgets);
|
||||
expect(find.byType(CupertinoPageScaffold), findsNothing);
|
||||
|
||||
const message = 'No chat sessions on this server yet.';
|
||||
expect(find.text(message), findsOneWidget);
|
||||
@@ -42,7 +40,15 @@ void main() {
|
||||
expect(find.text(message), findsOneWidget);
|
||||
expectNormalTextStyle(tester, message);
|
||||
expect(find.text('No chat sessions on this server yet.'), findsNothing);
|
||||
expect(find.widgetWithText(CupertinoButton, 'Retry'), findsNothing);
|
||||
expect(
|
||||
find.ancestor(
|
||||
of: find.text('Retry'),
|
||||
matching: find.byWidgetPredicate(
|
||||
(widget) => widget is ButtonStyleButton,
|
||||
),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Retry'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -56,8 +56,7 @@ Future<void> pumpMaterialChat(
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
/// The screen's iOS/macOS path: Cupertino controls under the app's ordinary
|
||||
/// `MaterialApp` root, with no Material or CupertinoTheme ancestor.
|
||||
/// The screen's iOS/macOS path uses the same ordinary Material app root.
|
||||
Future<void> pumpIosMaterialChat(
|
||||
WidgetTester tester,
|
||||
FakeChatGateway gateway, {
|
||||
|
||||
@@ -69,7 +69,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final context = tester.element(find.byType(ChatMessageView));
|
||||
final fontSize = chatMessageTextStyle(context, false)!.fontSize!;
|
||||
final fontSize = chatMessageTextStyle(context)!.fontSize!;
|
||||
final line = fontSize * scale;
|
||||
Rect rect(String text) =>
|
||||
tester.getRect(find.textContaining(text, findRichText: true).first);
|
||||
|
||||
@@ -62,7 +62,6 @@ void main() {
|
||||
find.byKey(const Key('pipeline-version-3')),
|
||||
);
|
||||
expect(row.selected, isTrue);
|
||||
expect(row.cupertino, isFalse);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -39,13 +39,14 @@ void main() {
|
||||
),
|
||||
);
|
||||
Widget scaled(BuildContext context, Widget? child) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: TextScaler.linear(2)),
|
||||
data: MediaQuery.of(context).copyWith(textScaler: TextScaler.linear(2)),
|
||||
child: child!,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(builder: scaled, home: Scaffold(body: body)),
|
||||
MaterialApp(
|
||||
builder: scaled,
|
||||
home: Scaffold(body: body),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
// One floating bar of separate round tab buttons.
|
||||
@@ -55,10 +56,7 @@ void main() {
|
||||
expect(pill.right, width - 16);
|
||||
expect(
|
||||
pill.width,
|
||||
FloatingDestinationBar.rowWidth(
|
||||
cupertino: false,
|
||||
tabs: PipelineDetailTab.values.length,
|
||||
),
|
||||
FloatingDestinationBar.rowWidth(tabs: PipelineDetailTab.values.length),
|
||||
);
|
||||
for (final tab in PipelineDetailTab.values) {
|
||||
final rect = tester.getRect(
|
||||
|
||||
@@ -100,10 +100,7 @@ void main() {
|
||||
// Sized to its tabs at the right, floating above the bottom.
|
||||
expect(
|
||||
pill.width,
|
||||
FloatingDestinationBar.rowWidth(
|
||||
cupertino: false,
|
||||
tabs: renderedRunDetailTabs.length,
|
||||
),
|
||||
FloatingDestinationBar.rowWidth(tabs: renderedRunDetailTabs.length),
|
||||
);
|
||||
expect(pill.right, 390 - 16);
|
||||
expect(pill.bottom, 844 - 16);
|
||||
|
||||
@@ -114,7 +114,6 @@ void main() {
|
||||
builder: (context) => runDetailSummaryTab(
|
||||
context: context,
|
||||
run: _running,
|
||||
cupertino: false,
|
||||
copying: false,
|
||||
copyStatus: null,
|
||||
onCopy: () {},
|
||||
@@ -152,11 +151,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
_host(
|
||||
time,
|
||||
RunTimelineList(
|
||||
visits: detailTimeline(steps),
|
||||
cupertino: false,
|
||||
onSelected: (_) {},
|
||||
),
|
||||
RunTimelineList(visits: detailTimeline(steps), onSelected: (_) {}),
|
||||
),
|
||||
);
|
||||
expect(find.text('2m 0s'), findsOneWidget);
|
||||
|
||||
@@ -29,7 +29,6 @@ void main() {
|
||||
testWidgets('timeline rows lead with their real status', (tester) async {
|
||||
final list = RunTimelineList(
|
||||
visits: detailTimeline(_steps),
|
||||
cupertino: false,
|
||||
onSelected: (_) {},
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: list)));
|
||||
@@ -71,10 +70,7 @@ void main() {
|
||||
'outcome': outcome,
|
||||
},
|
||||
];
|
||||
final list = RunTimelineList(
|
||||
visits: detailTimeline(steps),
|
||||
cupertino: false,
|
||||
);
|
||||
final list = RunTimelineList(visits: detailTimeline(steps));
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: list)));
|
||||
Color chip(String text, [int at = 0]) =>
|
||||
tester.widget<Text>(find.text(text).at(at)).style!.color!;
|
||||
|
||||
@@ -19,14 +19,10 @@ void main() {
|
||||
(type, fields) async => schedulesReply(longScheduleList(30)),
|
||||
);
|
||||
final screen = SchedulesScreen(gateway: gateway, onOpen: (_) {});
|
||||
final bar = const SegmentedBar(cupertino: false, title: 'Schedules');
|
||||
final bar = const SegmentedBar(title: 'Schedules');
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: bar,
|
||||
body: screen,
|
||||
),
|
||||
home: Scaffold(extendBodyBehindAppBar: true, appBar: bar, body: screen),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -189,12 +189,7 @@ void main() {
|
||||
Future<void> openMenu(JsonMap run) async {
|
||||
await pumpAction(
|
||||
tester,
|
||||
RunMoreMenu(
|
||||
run: run,
|
||||
gateway: gateway,
|
||||
onRunChanged: (_) {},
|
||||
cupertino: false,
|
||||
),
|
||||
RunMoreMenu(run: run, gateway: gateway, onRunChanged: (_) {}),
|
||||
);
|
||||
// A run with nothing to offer shows no menu at all.
|
||||
if (find.byKey(runMoreMenuKey).evaluate().isEmpty) return;
|
||||
|
||||
@@ -31,7 +31,7 @@ void main() {
|
||||
_size(tester, 390);
|
||||
final gateway = ImmediateGateway((_, _) => response([pipeline]));
|
||||
await tester.pumpWidget(
|
||||
_app(SearchScreen(gateway: gateway, onOpen: (_) {}, cupertino: false)),
|
||||
_app(SearchScreen(gateway: gateway, onOpen: (_) {})),
|
||||
);
|
||||
|
||||
for (final key in [searchFieldKey, searchKindKey, searchHelpKey]) {
|
||||
@@ -63,7 +63,7 @@ void main() {
|
||||
return reply;
|
||||
});
|
||||
await tester.pumpWidget(
|
||||
_app(SearchScreen(gateway: gateway, onOpen: (_) {}, cupertino: false)),
|
||||
_app(SearchScreen(gateway: gateway, onOpen: (_) {})),
|
||||
);
|
||||
|
||||
await _search(tester, 'release');
|
||||
@@ -81,13 +81,13 @@ void main() {
|
||||
_size(tester, 390);
|
||||
final gateway = ImmediateGateway((_, _) => response([field]));
|
||||
await tester.pumpWidget(
|
||||
_app(SearchScreen(gateway: gateway, onOpen: (_) {}, cupertino: false)),
|
||||
_app(SearchScreen(gateway: gateway, onOpen: (_) {})),
|
||||
);
|
||||
await _search(tester, 'release');
|
||||
|
||||
final row = find.byKey(const ValueKey('search.result.run:11:4:output'));
|
||||
expect(row, findsOneWidget);
|
||||
expect(tester.widget<AppListRow>(row).cupertino, isFalse);
|
||||
expect(tester.widget<AppListRow>(row).title, isNotNull);
|
||||
// The kind leads the one muted line, before the snippet.
|
||||
expect(
|
||||
find.descendant(of: row, matching: find.textContaining('Field · ')),
|
||||
@@ -106,7 +106,7 @@ void main() {
|
||||
_size(tester, 1200);
|
||||
final gateway = ImmediateGateway((_, _) => response([pipeline]));
|
||||
await tester.pumpWidget(
|
||||
_app(SearchScreen(gateway: gateway, onOpen: (_) {}, cupertino: false)),
|
||||
_app(SearchScreen(gateway: gateway, onOpen: (_) {})),
|
||||
);
|
||||
await _search(tester, 'release');
|
||||
|
||||
@@ -130,7 +130,7 @@ void main() {
|
||||
_size(tester, width);
|
||||
final gateway = ImmediateGateway((_, _) => response([pipeline]));
|
||||
await tester.pumpWidget(
|
||||
_app(SearchScreen(gateway: gateway, onOpen: (_) {}, cupertino: false)),
|
||||
_app(SearchScreen(gateway: gateway, onOpen: (_) {})),
|
||||
);
|
||||
await _search(tester, 'release');
|
||||
|
||||
|
||||
@@ -25,13 +25,7 @@ void main() {
|
||||
final gateway = ImmediateGateway(replies);
|
||||
JsonMap? opened;
|
||||
await tester.pumpWidget(
|
||||
host(
|
||||
SearchScreen(
|
||||
gateway: gateway,
|
||||
onOpen: (value) => opened = value,
|
||||
cupertino: false,
|
||||
),
|
||||
),
|
||||
host(SearchScreen(gateway: gateway, onOpen: (value) => opened = value)),
|
||||
);
|
||||
await search(tester, 'release');
|
||||
|
||||
@@ -77,7 +71,7 @@ void main() {
|
||||
final gateway = ImmediateGateway(replies);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SearchScreen(gateway: gateway, onOpen: (_) {}, cupertino: false),
|
||||
home: SearchScreen(gateway: gateway, onOpen: (_) {}),
|
||||
),
|
||||
);
|
||||
await search(tester, 't:chat release');
|
||||
@@ -100,7 +94,7 @@ void main() {
|
||||
});
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SearchScreen(gateway: gateway, onOpen: (_) {}, cupertino: false),
|
||||
home: SearchScreen(gateway: gateway, onOpen: (_) {}),
|
||||
),
|
||||
);
|
||||
await search(tester, 'release');
|
||||
|
||||
@@ -110,11 +110,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: largeText(
|
||||
SearchScreen(
|
||||
gateway: gateway,
|
||||
onOpen: (value) => opened = value,
|
||||
cupertino: false,
|
||||
),
|
||||
SearchScreen(gateway: gateway, onOpen: (value) => opened = value),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -155,11 +151,7 @@ void main() {
|
||||
JsonMap? opened;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SearchScreen(
|
||||
gateway: gateway,
|
||||
onOpen: (value) => opened = value,
|
||||
cupertino: false,
|
||||
),
|
||||
home: SearchScreen(gateway: gateway, onOpen: (value) => opened = value),
|
||||
),
|
||||
);
|
||||
await search(tester, 'widget');
|
||||
@@ -176,7 +168,7 @@ void main() {
|
||||
final gateway = FailingThenSucceedingGateway(response([pipeline]));
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SearchScreen(gateway: gateway, onOpen: (_) {}, cupertino: false),
|
||||
home: SearchScreen(gateway: gateway, onOpen: (_) {}),
|
||||
),
|
||||
);
|
||||
await search(tester, 'release');
|
||||
|
||||
@@ -63,15 +63,12 @@ class TemplateCreateHost extends StatelessWidget {
|
||||
super.key,
|
||||
required this.gateway,
|
||||
required this.onCreated,
|
||||
this.cupertino = false,
|
||||
this.template = templateCreateFixture,
|
||||
});
|
||||
|
||||
final FakeTemplateCreateGateway gateway;
|
||||
final ValueChanged<JsonMap> onCreated;
|
||||
|
||||
/// Retained for callers that still pass it; the host is always Material.
|
||||
final bool cupertino;
|
||||
final TemplateEntry template;
|
||||
|
||||
void _open(BuildContext context) {
|
||||
@@ -79,7 +76,6 @@ class TemplateCreateHost extends StatelessWidget {
|
||||
context: context,
|
||||
template: template,
|
||||
repository: TemplateRepository(gateway),
|
||||
cupertino: cupertino,
|
||||
onCreated: onCreated,
|
||||
);
|
||||
}
|
||||
@@ -97,11 +93,7 @@ class TemplateCreateHost extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
Widget templateCreateApp(
|
||||
Widget child, {
|
||||
bool cupertino = false,
|
||||
double textScale = 1,
|
||||
}) {
|
||||
Widget templateCreateApp(Widget child, {double textScale = 1}) {
|
||||
Widget media(BuildContext context, Widget? app) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
|
||||
@@ -82,7 +82,6 @@ Future<JsonMap> acceptedCreate(String type, JsonMap fields) async {
|
||||
Future<void> pumpGallery(
|
||||
WidgetTester tester,
|
||||
GalleryGateway gateway, {
|
||||
bool cupertino = false,
|
||||
bool embedded = false,
|
||||
ValueChanged<JsonMap>? onCreated,
|
||||
double textScale = 1,
|
||||
|
||||
@@ -20,7 +20,6 @@ void main() {
|
||||
onPressed: () => showLaunchUpdateDialog(
|
||||
context,
|
||||
web: false,
|
||||
cupertino: false,
|
||||
nativePlatform: platform,
|
||||
sourceName: 'Home Linux',
|
||||
),
|
||||
@@ -43,8 +42,7 @@ void main() {
|
||||
MaterialApp(
|
||||
home: Builder(
|
||||
builder: (context) => TextButton(
|
||||
onPressed: () =>
|
||||
showLaunchUpdateFailure(context, 'boom', cupertino: false),
|
||||
onPressed: () => showLaunchUpdateFailure(context, 'boom'),
|
||||
child: const Text('Fail'),
|
||||
),
|
||||
),
|
||||
@@ -84,7 +82,6 @@ void main() {
|
||||
onProgress?.call(0.5);
|
||||
await finished.future;
|
||||
},
|
||||
cupertino: false,
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(AlertDialog), findsOneWidget);
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
/// Find the platform's actual Back control, not an app-specific button key.
|
||||
Finder findNativeBack() => find.byWidgetPredicate(
|
||||
(widget) =>
|
||||
widget is BackButton || widget is CupertinoNavigationBarBackButton,
|
||||
);
|
||||
Finder findNativeBack() => find.byType(BackButton);
|
||||
|
||||
@@ -232,7 +232,7 @@ void main() {
|
||||
}
|
||||
expect(
|
||||
bounds.height,
|
||||
greaterThan(FloatingDestinationBar.selectedButtonSize(cupertino: false)),
|
||||
greaterThan(FloatingDestinationBar.selectedButtonSize()),
|
||||
);
|
||||
expect(tester.getRect(pill()).right, 320 - 16);
|
||||
});
|
||||
|
||||
@@ -39,7 +39,6 @@ void main() {
|
||||
bar: KeyedSubtree(
|
||||
key: const Key('item-tabs'),
|
||||
child: FloatingDestinationBar(
|
||||
cupertino: false,
|
||||
edge: edge,
|
||||
currentIndex: 0,
|
||||
onTap: (_) {},
|
||||
|
||||
@@ -7,7 +7,6 @@ void main() {
|
||||
testWidgets('compact menu exposes all named destinations', (tester) async {
|
||||
AppDestination? selected;
|
||||
final menu = ShellDestinationMenu(
|
||||
cupertino: false,
|
||||
current: AppDestination.chat,
|
||||
onSelected: (value) => selected = value,
|
||||
);
|
||||
|
||||
@@ -49,7 +49,6 @@ void main() {
|
||||
bar: KeyedSubtree(
|
||||
key: const Key('detail-tabs'),
|
||||
child: FloatingDestinationBar(
|
||||
cupertino: false,
|
||||
currentIndex: 0,
|
||||
onTap: (_) {},
|
||||
items: const [
|
||||
|
||||
@@ -47,7 +47,6 @@ void main() {
|
||||
bar: KeyedSubtree(
|
||||
key: const Key('item-tabs'),
|
||||
child: FloatingDestinationBar(
|
||||
cupertino: false,
|
||||
edge: edge,
|
||||
currentIndex: 0,
|
||||
onTap: (_) {},
|
||||
@@ -75,7 +74,6 @@ void main() {
|
||||
child: SegmentedBarOverlay(
|
||||
bar: SegmentedBar(
|
||||
key: const Key('own-header'),
|
||||
cupertino: false,
|
||||
automaticallyImplyLeading: false,
|
||||
title: 'Own header',
|
||||
),
|
||||
|
||||
@@ -220,7 +220,6 @@ void main() {
|
||||
};
|
||||
router = AppRouterDelegate(
|
||||
initial: AppRoute.runs,
|
||||
cupertino: false,
|
||||
builder: (_, route) => AdaptiveShell(
|
||||
destination: destinationOf(route),
|
||||
onDestinationSelected: (value) => router.goTo(routeOf(value)),
|
||||
|
||||
@@ -148,7 +148,6 @@ void main() {
|
||||
) async {
|
||||
await setSize(tester, const Size(1280, 800));
|
||||
final bar = SegmentedBar(
|
||||
cupertino: false,
|
||||
title: 'Settings',
|
||||
actions: const [Icon(Icons.more_vert, semanticLabel: 'More')],
|
||||
);
|
||||
|
||||
@@ -18,12 +18,10 @@ void main() {
|
||||
Key tabKey(int index) => ValueKey('tab-$index');
|
||||
|
||||
Widget bar({
|
||||
required bool cupertino,
|
||||
required int count,
|
||||
required int selected,
|
||||
ValueChanged<int>? onTap,
|
||||
}) => FloatingDestinationBar(
|
||||
cupertino: cupertino,
|
||||
currentIndex: selected,
|
||||
onTap: onTap ?? (_) {},
|
||||
items: [
|
||||
@@ -38,7 +36,6 @@ void main() {
|
||||
|
||||
Future<void> pump(
|
||||
WidgetTester tester, {
|
||||
required bool cupertino,
|
||||
required Size size,
|
||||
required Widget child,
|
||||
double textScale = 1,
|
||||
@@ -76,10 +73,9 @@ void main() {
|
||||
];
|
||||
|
||||
{
|
||||
const cupertino = false;
|
||||
const host = 'Material';
|
||||
final diameter = FloatingDestinationBar.buttonSize(cupertino: cupertino);
|
||||
final gap = FloatingDestinationBar.buttonGap(cupertino: cupertino);
|
||||
final diameter = FloatingDestinationBar.buttonSize();
|
||||
final gap = FloatingDestinationBar.buttonGap();
|
||||
final iconSize = FloatingDestinationBar.materialIconSize;
|
||||
|
||||
test('$host: buttons are larger than the old 44/42 circle, hit targets '
|
||||
@@ -93,11 +89,10 @@ void main() {
|
||||
'centred in it', (tester) async {
|
||||
await pump(
|
||||
tester,
|
||||
cupertino: cupertino,
|
||||
size: const Size(390, 844),
|
||||
child: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: bar(cupertino: cupertino, count: 3, selected: 0),
|
||||
child: bar(count: 3, selected: 0),
|
||||
),
|
||||
);
|
||||
expect(
|
||||
@@ -111,7 +106,7 @@ void main() {
|
||||
final circle = button(tester, index);
|
||||
// Tab 0 is selected: its whole button is larger than the others.
|
||||
final across = index == 0
|
||||
? FloatingDestinationBar.selectedButtonSize(cupertino: cupertino)
|
||||
? FloatingDestinationBar.selectedButtonSize()
|
||||
: diameter;
|
||||
expect(circle.width, moreOrLessEquals(across));
|
||||
expect(circle.height, moreOrLessEquals(across));
|
||||
@@ -129,10 +124,8 @@ void main() {
|
||||
final icon = tester.getRect(find.byIcon(icons[index]));
|
||||
final side = index == 0
|
||||
? iconSize *
|
||||
FloatingDestinationBar.selectedButtonSize(
|
||||
cupertino: cupertino,
|
||||
) /
|
||||
FloatingDestinationBar.buttonSize(cupertino: cupertino)
|
||||
FloatingDestinationBar.selectedButtonSize() /
|
||||
FloatingDestinationBar.buttonSize()
|
||||
: iconSize;
|
||||
expect(icon.width, moreOrLessEquals(side));
|
||||
expect(icon.height, moreOrLessEquals(side));
|
||||
@@ -147,11 +140,10 @@ void main() {
|
||||
final size = placement.size;
|
||||
await pump(
|
||||
tester,
|
||||
cupertino: cupertino,
|
||||
size: size,
|
||||
child: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: bar(cupertino: cupertino, count: count, selected: 0),
|
||||
child: bar(count: count, selected: 0),
|
||||
),
|
||||
);
|
||||
final box = row(tester);
|
||||
@@ -160,15 +152,11 @@ void main() {
|
||||
// As tall as the selected (larger) button.
|
||||
expect(
|
||||
box.height,
|
||||
moreOrLessEquals(
|
||||
FloatingDestinationBar.selectedButtonSize(cupertino: cupertino),
|
||||
),
|
||||
moreOrLessEquals(FloatingDestinationBar.selectedButtonSize()),
|
||||
);
|
||||
expect(
|
||||
box.width,
|
||||
moreOrLessEquals(
|
||||
FloatingDestinationBar.rowWidth(cupertino: cupertino, tabs: count),
|
||||
),
|
||||
moreOrLessEquals(FloatingDestinationBar.rowWidth(tabs: count)),
|
||||
);
|
||||
expect(button(tester, 0).left, box.left);
|
||||
expect(button(tester, count - 1).right, box.right);
|
||||
@@ -192,14 +180,12 @@ void main() {
|
||||
// The shell's wide placement: under the list pane, centred in it.
|
||||
await pump(
|
||||
tester,
|
||||
cupertino: cupertino,
|
||||
size: const Size(1280, 800),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.bottomStart,
|
||||
child: SizedBox(
|
||||
width: listWidth,
|
||||
child: FloatingDestinationBar(
|
||||
cupertino: cupertino,
|
||||
currentIndex: 1,
|
||||
onTap: (_) {},
|
||||
alignment: Alignment.bottomCenter,
|
||||
@@ -221,12 +207,7 @@ void main() {
|
||||
expect(
|
||||
box.center.dy,
|
||||
moreOrLessEquals(
|
||||
800 -
|
||||
16 -
|
||||
FloatingDestinationBar.selectedButtonSize(
|
||||
cupertino: cupertino,
|
||||
) /
|
||||
2,
|
||||
800 - 16 - FloatingDestinationBar.selectedButtonSize() / 2,
|
||||
),
|
||||
);
|
||||
expect(box.left, greaterThanOrEqualTo(16 - 0.01));
|
||||
@@ -235,8 +216,7 @@ void main() {
|
||||
expect(
|
||||
button(tester, 1).width / button(tester, 0).width,
|
||||
moreOrLessEquals(
|
||||
FloatingDestinationBar.selectedButtonSize(cupertino: cupertino) /
|
||||
diameter,
|
||||
FloatingDestinationBar.selectedButtonSize() / diameter,
|
||||
),
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
@@ -249,7 +229,6 @@ void main() {
|
||||
var content = 0;
|
||||
await pump(
|
||||
tester,
|
||||
cupertino: cupertino,
|
||||
size: const Size(390, 844),
|
||||
child: Stack(
|
||||
children: [
|
||||
@@ -261,12 +240,7 @@ void main() {
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: bar(
|
||||
cupertino: cupertino,
|
||||
count: 3,
|
||||
selected: 1,
|
||||
onTap: tapped.add,
|
||||
),
|
||||
child: bar(count: 3, selected: 1, onTap: tapped.add),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -287,12 +261,11 @@ void main() {
|
||||
'stay within the margins', (tester) async {
|
||||
await pump(
|
||||
tester,
|
||||
cupertino: cupertino,
|
||||
size: const Size(320, 640),
|
||||
textScale: 2,
|
||||
child: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: bar(cupertino: cupertino, count: 5, selected: 4),
|
||||
child: bar(count: 5, selected: 4),
|
||||
),
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
@@ -300,9 +273,7 @@ void main() {
|
||||
expect(box.right, 320 - 16);
|
||||
expect(box.left, greaterThanOrEqualTo(16));
|
||||
// Tab 4 is selected and larger; the gaps narrow around it.
|
||||
final selected = FloatingDestinationBar.selectedButtonSize(
|
||||
cupertino: cupertino,
|
||||
);
|
||||
final selected = FloatingDestinationBar.selectedButtonSize();
|
||||
final narrowed = (288 - 4 * diameter - selected) / 4;
|
||||
for (var index = 1; index < 5; index += 1) {
|
||||
expect(
|
||||
@@ -320,13 +291,12 @@ void main() {
|
||||
'reads from the right', (tester) async {
|
||||
await pump(
|
||||
tester,
|
||||
cupertino: cupertino,
|
||||
size: const Size(390, 844),
|
||||
child: Directionality(
|
||||
textDirection: TextDirection.rtl,
|
||||
child: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: bar(cupertino: cupertino, count: 3, selected: 0),
|
||||
child: bar(count: 3, selected: 0),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -12,7 +12,6 @@ void main() {
|
||||
home: Scaffold(
|
||||
body: FloatingBarOverlay(
|
||||
bar: FloatingDestinationBar(
|
||||
cupertino: false,
|
||||
currentIndex: 0,
|
||||
onTap: (_) {},
|
||||
items: const [
|
||||
|
||||
@@ -16,7 +16,6 @@ void main() {
|
||||
children: [
|
||||
TextField(focusNode: focus),
|
||||
FloatingDestinationBar(
|
||||
cupertino: false,
|
||||
currentIndex: 0,
|
||||
showLabels: true,
|
||||
items: const [
|
||||
|
||||
@@ -49,7 +49,6 @@ void main() {
|
||||
builder: (context, setState) => Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: FloatingDestinationBar(
|
||||
cupertino: false,
|
||||
currentIndex: selected,
|
||||
onTap: (index) => setState(() => selected = index),
|
||||
items: items(count),
|
||||
@@ -95,7 +94,7 @@ void main() {
|
||||
}
|
||||
|
||||
final host = 'Material';
|
||||
final size = FloatingDestinationBar.buttonSize(cupertino: false);
|
||||
final size = FloatingDestinationBar.buttonSize();
|
||||
final iconSize = FloatingDestinationBar.materialIconSize;
|
||||
|
||||
testWidgets('$host: each button pops in on its own, staggered, from '
|
||||
@@ -106,7 +105,7 @@ void main() {
|
||||
final tab = find.byKey(tabKey(index));
|
||||
expect(opacityOf(tester, tab), 0);
|
||||
final rest = index == 0
|
||||
? FloatingDestinationBar.selectedButtonSize(cupertino: false)
|
||||
? FloatingDestinationBar.selectedButtonSize()
|
||||
: size;
|
||||
expect(widthOf(tester, tab), moreOrLessEquals(rest * 0.6));
|
||||
}
|
||||
@@ -123,9 +122,7 @@ void main() {
|
||||
// Tab 0 is selected, so it settles at the larger size.
|
||||
expect(
|
||||
widthOf(tester, tab),
|
||||
index == 0
|
||||
? FloatingDestinationBar.selectedButtonSize(cupertino: false)
|
||||
: size,
|
||||
index == 0 ? FloatingDestinationBar.selectedButtonSize() : size,
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -168,7 +165,6 @@ void main() {
|
||||
return Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: FloatingDestinationBar(
|
||||
cupertino: false,
|
||||
currentIndex: 0,
|
||||
onTap: (_) {},
|
||||
items: items(count),
|
||||
@@ -219,8 +215,8 @@ void main() {
|
||||
iconWidth(tester, 2),
|
||||
moreOrLessEquals(
|
||||
iconSize *
|
||||
FloatingDestinationBar.selectedButtonSize(cupertino: false) /
|
||||
FloatingDestinationBar.buttonSize(cupertino: false),
|
||||
FloatingDestinationBar.selectedButtonSize() /
|
||||
FloatingDestinationBar.buttonSize(),
|
||||
),
|
||||
);
|
||||
expect(iconWidth(tester, 0), moreOrLessEquals(iconSize));
|
||||
@@ -251,15 +247,12 @@ void main() {
|
||||
// Tab 0 is selected, so it is the larger button; the press leaves it.
|
||||
expect(
|
||||
widthOf(tester, find.byKey(tabKey(0))),
|
||||
FloatingDestinationBar.selectedButtonSize(cupertino: false),
|
||||
FloatingDestinationBar.selectedButtonSize(),
|
||||
);
|
||||
await gesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
// The tap selected it: it springs back to the selected size.
|
||||
expect(
|
||||
widthOf(tester, tab),
|
||||
FloatingDestinationBar.selectedButtonSize(cupertino: false),
|
||||
);
|
||||
expect(widthOf(tester, tab), FloatingDestinationBar.selectedButtonSize());
|
||||
});
|
||||
|
||||
testWidgets('$host: under reduced motion the tint jumps and the buttons '
|
||||
@@ -280,8 +273,8 @@ void main() {
|
||||
iconWidth(tester, 2),
|
||||
moreOrLessEquals(
|
||||
iconSize *
|
||||
FloatingDestinationBar.selectedButtonSize(cupertino: false) /
|
||||
FloatingDestinationBar.buttonSize(cupertino: false),
|
||||
FloatingDestinationBar.selectedButtonSize() /
|
||||
FloatingDestinationBar.buttonSize(),
|
||||
),
|
||||
);
|
||||
expect(iconWidth(tester, 0), moreOrLessEquals(iconSize));
|
||||
@@ -289,7 +282,7 @@ void main() {
|
||||
|
||||
testWidgets('switching the shell tabs never replays the main '
|
||||
"bar's entrance", (tester) async {
|
||||
final size = FloatingDestinationBar.buttonSize(cupertino: false);
|
||||
final size = FloatingDestinationBar.buttonSize();
|
||||
animate(tester, on: true);
|
||||
var destination = AppDestination.runs;
|
||||
final shell = StatefulBuilder(
|
||||
|
||||
@@ -17,7 +17,6 @@ void main() {
|
||||
home: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: SegmentedBar(
|
||||
cupertino: false,
|
||||
title: 'Release train run',
|
||||
subtitle: 'Run 7',
|
||||
expandableTitle: true,
|
||||
@@ -49,7 +48,7 @@ void main() {
|
||||
testWidgets('a lone piece reads the backdrop on its own', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Center(child: GlassPill(cupertino: false, child: Text('Tabs'))),
|
||||
home: Center(child: GlassPill(child: Text('Tabs'))),
|
||||
),
|
||||
);
|
||||
expect(_keys(tester), [isNull]);
|
||||
|
||||
@@ -139,7 +139,7 @@ void main() {
|
||||
if (count > 1) {
|
||||
_expectEvenNeighbours(controls.sublist(controls.length - 2));
|
||||
}
|
||||
expect(pill.height, closeTo(GlassBarMetrics.height(false), 1));
|
||||
expect(pill.height, closeTo(GlassBarMetrics.height(), 1));
|
||||
expect(tester.takeException(), isNull);
|
||||
}
|
||||
});
|
||||
@@ -240,7 +240,7 @@ void main() {
|
||||
// The controls keep to the field's last line: each end control is as
|
||||
// far from the pill's side as from its bottom, and while the field is
|
||||
// one line (no taller than a control) as far from its top.
|
||||
final row = GlassBarMetrics.controlExtent(false);
|
||||
final row = GlassBarMetrics.controlExtent();
|
||||
final oneLine =
|
||||
pill.height <= row + 2 * GlassBarMetrics.fieldEdgeGap + 0.5;
|
||||
for (final (control, start) in [(attach, true), (send, false)]) {
|
||||
@@ -273,11 +273,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: SegmentedBar(
|
||||
cupertino: false,
|
||||
title: 'Title',
|
||||
actions: actions,
|
||||
),
|
||||
appBar: SegmentedBar(title: 'Title', actions: actions),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -307,16 +303,13 @@ void _expectPager(WidgetTester tester, Finder inside, Finder position) {
|
||||
_expectEvenNeighbours(controls);
|
||||
final text = tester.getRect(position);
|
||||
final gap = (pill.height - last.height) / 2;
|
||||
expect(
|
||||
text.left - pill.left,
|
||||
closeTo(gap + GlassBarMetrics.iconInset(false), 1),
|
||||
);
|
||||
expect(text.left - pill.left, closeTo(gap + GlassBarMetrics.iconInset(), 1));
|
||||
// The chevrons keep the same gap from the position as from each other's
|
||||
// icons: one icon inset on each side.
|
||||
expect(
|
||||
controls.first.left - text.right,
|
||||
greaterThanOrEqualTo(GlassBarMetrics.iconInset(false) - 1),
|
||||
greaterThanOrEqualTo(GlassBarMetrics.iconInset() - 1),
|
||||
);
|
||||
expect(pill.height, closeTo(GlassBarMetrics.height(false), 1));
|
||||
expect(pill.height, closeTo(GlassBarMetrics.height(), 1));
|
||||
expect(tester.takeException(), isNull);
|
||||
}
|
||||
|
||||
@@ -9,9 +9,7 @@ Widget _pill({Brightness brightness = Brightness.light, bool solid = false}) =>
|
||||
theme: ThemeData(brightness: brightness),
|
||||
home: MediaQuery(
|
||||
data: MediaQueryData(highContrast: solid),
|
||||
child: const Center(
|
||||
child: GlassPill(cupertino: false, child: Text('Runs')),
|
||||
),
|
||||
child: const Center(child: GlassPill(child: Text('Runs'))),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/application/app.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/platform.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_theme.dart';
|
||||
|
||||
void main() {
|
||||
test('no platform prefers the Cupertino host', () {
|
||||
expect(prefersCupertino(), isFalse);
|
||||
});
|
||||
|
||||
for (final platform in TargetPlatform.values) {
|
||||
testWidgets('the app uses the Material host on $platform', (tester) async {
|
||||
debugDefaultTargetPlatformOverride = platform;
|
||||
addTearDown(() => debugDefaultTargetPlatformOverride = null);
|
||||
await tester.pumpWidget(const MyApp());
|
||||
expect(find.byType(MaterialApp), findsOneWidget);
|
||||
expect(find.byType(CupertinoApp), findsNothing);
|
||||
// Native hosts keep the target platform so Flutter's automatic
|
||||
// behaviours (scroll physics, text selection, back-swipe) still apply.
|
||||
final expected = kIsWeb ? TargetPlatform.android : platform;
|
||||
|
||||
@@ -7,21 +7,15 @@ import 'package:pipelines_app/ui/motion/motion.dart';
|
||||
/// Every piece of the top bar (Back, the title, the actions pill and each
|
||||
/// action in it) pops in with the tab buttons' entrance, once.
|
||||
void main() {
|
||||
Widget page(
|
||||
bool cupertino, {
|
||||
Widget page({
|
||||
String title = 'Runs',
|
||||
List<Widget> actions = const [],
|
||||
Object? actionsKey,
|
||||
bool reduced = false,
|
||||
}) {
|
||||
final bar = SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
title: title,
|
||||
leading: SegmentedBackButton(
|
||||
key: const Key('back'),
|
||||
cupertino: cupertino,
|
||||
onPressed: () {},
|
||||
),
|
||||
leading: SegmentedBackButton(key: const Key('back'), onPressed: () {}),
|
||||
actions: actions,
|
||||
actionsKey: actionsKey,
|
||||
);
|
||||
@@ -56,7 +50,6 @@ void main() {
|
||||
const step = Motion.tabEntranceStagger;
|
||||
|
||||
{
|
||||
const cupertino = false;
|
||||
const host = 'Material';
|
||||
const icon = Icons.refresh;
|
||||
Widget action(String key) =>
|
||||
@@ -67,9 +60,7 @@ void main() {
|
||||
testWidgets('$host: each piece pops in turn, left to right, from 0.6', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
page(cupertino, actions: [action('a'), action('b')]),
|
||||
);
|
||||
await tester.pumpWidget(page(actions: [action('a'), action('b')]));
|
||||
expect(scaleOf(tester, back), begin);
|
||||
expect(scaleOf(tester, title), begin);
|
||||
expect(scaleOf(tester, a), begin, reason: 'the pill');
|
||||
@@ -104,7 +95,7 @@ void main() {
|
||||
testWidgets('$host: a lone action pops as its pill, not twice', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(page(cupertino, actions: [action('a')]));
|
||||
await tester.pumpWidget(page(actions: [action('a')]));
|
||||
expect(scaleOf(tester, a), begin);
|
||||
expect(scaleOf(tester, a, inner: true), 1);
|
||||
await tester.pump(step * 2 + const Duration(milliseconds: 40));
|
||||
@@ -117,11 +108,9 @@ void main() {
|
||||
testWidgets('$host: a rebuild or new title does not replay it', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(page(cupertino, actions: [action('a')]));
|
||||
await tester.pumpWidget(page(actions: [action('a')]));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(
|
||||
page(cupertino, title: 'Other', actions: [action('a')]),
|
||||
);
|
||||
await tester.pumpWidget(page(title: 'Other', actions: [action('a')]));
|
||||
await tester.pump();
|
||||
expect(scaleOf(tester, back), 1);
|
||||
expect(scaleOf(tester, find.text('Other')), 1);
|
||||
@@ -133,11 +122,9 @@ void main() {
|
||||
testWidgets('$host: an action that becomes available pops in alone', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(page(cupertino, actions: [action('a')]));
|
||||
await tester.pumpWidget(page(actions: [action('a')]));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(
|
||||
page(cupertino, actions: [action('b'), action('a')]),
|
||||
);
|
||||
await tester.pumpWidget(page(actions: [action('b'), action('a')]));
|
||||
expect(scaleOf(tester, b, inner: true), begin);
|
||||
// The pill, the action already there and the rest stay put.
|
||||
expect(scaleOf(tester, a), 1);
|
||||
@@ -154,21 +141,16 @@ void main() {
|
||||
tester,
|
||||
) async {
|
||||
final list = Object();
|
||||
await tester.pumpWidget(
|
||||
page(cupertino, actionsKey: list, actions: [action('a')]),
|
||||
);
|
||||
await tester.pumpWidget(page(actionsKey: list, actions: [action('a')]));
|
||||
await tester.pumpAndSettle();
|
||||
// The same screen republishing its bar is not a new entrance.
|
||||
await tester.pumpWidget(
|
||||
page(cupertino, actionsKey: list, actions: [action('a')]),
|
||||
);
|
||||
await tester.pumpWidget(page(actionsKey: list, actions: [action('a')]));
|
||||
await tester.pump();
|
||||
expect(tester.hasRunningAnimations, isFalse);
|
||||
// Another screen's actions are new, though keyed alike; Back, the
|
||||
// title and the pill stay.
|
||||
await tester.pumpWidget(
|
||||
page(
|
||||
cupertino,
|
||||
title: 'Chats',
|
||||
actionsKey: Object(),
|
||||
actions: [action('a'), action('b')],
|
||||
@@ -189,11 +171,9 @@ void main() {
|
||||
testWidgets('$host: a pill arriving later pops, then its actions', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(page(cupertino));
|
||||
await tester.pumpWidget(page());
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(
|
||||
page(cupertino, actions: [action('a'), action('b')]),
|
||||
);
|
||||
await tester.pumpWidget(page(actions: [action('a'), action('b')]));
|
||||
expect(scaleOf(tester, back), 1);
|
||||
await tester.pump(const Duration(milliseconds: 20));
|
||||
expect(scaleOf(tester, a), greaterThan(begin), reason: 'at once');
|
||||
@@ -206,7 +186,7 @@ void main() {
|
||||
|
||||
testWidgets('$host: reduced motion shows the bar at once', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
page(cupertino, actions: [action('a'), action('b')], reduced: true),
|
||||
page(actions: [action('a'), action('b')], reduced: true),
|
||||
);
|
||||
expect(scaleOf(tester, back), 1);
|
||||
expect(scaleOf(tester, title), 1);
|
||||
|
||||
@@ -10,8 +10,7 @@ import 'package:pipelines_app/ui/motion/motion.dart';
|
||||
/// The top bar's glass fades in with its blur, and its controls sink when
|
||||
/// pressed (its entrance is in segmented_bar_entrance_test.dart).
|
||||
void main() {
|
||||
Widget page(
|
||||
bool cupertino, {
|
||||
Widget page({
|
||||
String title = 'Runs',
|
||||
List<Widget> actions = const [],
|
||||
VoidCallback? onTitle,
|
||||
@@ -19,12 +18,10 @@ void main() {
|
||||
VoidCallback? onBack,
|
||||
}) {
|
||||
final bar = SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
title: title,
|
||||
onTitlePressed: onTitle,
|
||||
leading: SegmentedBackButton(
|
||||
key: const Key('back'),
|
||||
cupertino: cupertino,
|
||||
onPressed: onBack ?? () {},
|
||||
),
|
||||
actions: actions,
|
||||
@@ -70,7 +67,6 @@ void main() {
|
||||
final title = find.text('Runs');
|
||||
|
||||
{
|
||||
const cupertino = false;
|
||||
const host = 'Material';
|
||||
const icon = Icons.refresh;
|
||||
Widget action(String key) =>
|
||||
@@ -79,7 +75,7 @@ void main() {
|
||||
testWidgets('$host: the glass fades in with its blur, not under a layer', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(page(cupertino));
|
||||
await tester.pumpWidget(page());
|
||||
// Back and the title are both still popping in.
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
final backdrops = tester.layers.whereType<BackdropFilterLayer>().toList();
|
||||
@@ -106,7 +102,7 @@ void main() {
|
||||
'$host: Back sinks and tints while pressed, then springs back',
|
||||
(tester) async {
|
||||
var backs = 0;
|
||||
await tester.pumpWidget(page(cupertino, onBack: () => backs++));
|
||||
await tester.pumpWidget(page(onBack: () => backs++));
|
||||
await tester.pumpAndSettle();
|
||||
expect(pressScale(tester, back), 1);
|
||||
expect(pressTint(tester, back).a, 0);
|
||||
@@ -126,7 +122,7 @@ void main() {
|
||||
testWidgets('$host: a quick tap still shows the whole press', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(page(cupertino, actions: [action('a')]));
|
||||
await tester.pumpWidget(page(actions: [action('a')]));
|
||||
await tester.pumpAndSettle();
|
||||
final a = find.byKey(const Key('a'));
|
||||
await tester.tap(a);
|
||||
@@ -144,11 +140,7 @@ void main() {
|
||||
) async {
|
||||
var taps = 0;
|
||||
await tester.pumpWidget(
|
||||
page(
|
||||
cupertino,
|
||||
onTitle: () => taps++,
|
||||
actions: [action('a'), action('b')],
|
||||
),
|
||||
page(onTitle: () => taps++, actions: [action('a'), action('b')]),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final a = find.byKey(const Key('a'));
|
||||
@@ -168,13 +160,13 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('$host: hit testing is unchanged at rest', (tester) async {
|
||||
await tester.pumpWidget(page(cupertino, actions: [action('a')]));
|
||||
await tester.pumpWidget(page(actions: [action('a')]));
|
||||
await tester.pumpAndSettle();
|
||||
final pill = tester.getRect(
|
||||
find.ancestor(of: back, matching: find.byType(GlassPill)).first,
|
||||
);
|
||||
expect(pill.left, 12);
|
||||
expect(pill.height, segmentedPieceHeight(cupertino));
|
||||
expect(pill.height, segmentedPieceHeight());
|
||||
// A tap between the pieces reaches no piece; on Back it reaches Back.
|
||||
final backBox = tester.renderObject(back);
|
||||
bool hitsBack(Offset at) =>
|
||||
|
||||
@@ -14,7 +14,7 @@ const _names = ['Needs you', 'Usage', 'Filter', 'Sort', 'Select'];
|
||||
Key _key(String name) => ValueKey('action.$name');
|
||||
|
||||
/// An icon action like the list bars' own, at the host's touch target.
|
||||
Widget _icon(bool cupertino, String name, VoidCallback onPressed) => IconButton(
|
||||
Widget _icon(String name, VoidCallback onPressed) => IconButton(
|
||||
key: _key(name),
|
||||
tooltip: name,
|
||||
onPressed: onPressed,
|
||||
@@ -22,10 +22,10 @@ Widget _icon(bool cupertino, String name, VoidCallback onPressed) => IconButton(
|
||||
);
|
||||
|
||||
/// The Runs bar's shape: a bell that always stays, then four that may move.
|
||||
List<Widget> _actions(bool cupertino, List<String> pressed) => [
|
||||
List<Widget> _actions(List<String> pressed) => [
|
||||
for (final name in _names)
|
||||
if (name == 'Needs you')
|
||||
_icon(cupertino, name, () => pressed.add(name))
|
||||
_icon(name, () => pressed.add(name))
|
||||
else
|
||||
SegmentedOverflowAction(
|
||||
overflowEntry: SegmentedOverflowEntry(
|
||||
@@ -33,19 +33,18 @@ List<Widget> _actions(bool cupertino, List<String> pressed) => [
|
||||
icon: Icons.circle_outlined,
|
||||
onPressed: () => pressed.add(name),
|
||||
),
|
||||
child: _icon(cupertino, name, () => pressed.add(name)),
|
||||
child: _icon(name, () => pressed.add(name)),
|
||||
),
|
||||
];
|
||||
|
||||
Widget _app(bool cupertino, SegmentedBar bar, {Brightness? brightness}) =>
|
||||
MaterialApp(
|
||||
theme: ThemeData(brightness: brightness ?? Brightness.light),
|
||||
home: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: bar,
|
||||
body: const SizedBox.expand(),
|
||||
),
|
||||
);
|
||||
Widget _app(SegmentedBar bar, {Brightness? brightness}) => MaterialApp(
|
||||
theme: ThemeData(brightness: brightness ?? Brightness.light),
|
||||
home: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: bar,
|
||||
body: const SizedBox.expand(),
|
||||
),
|
||||
);
|
||||
|
||||
/// Pumps the bar and the frame its More menu settles in.
|
||||
Future<void> _pump(WidgetTester tester, Widget app) async {
|
||||
@@ -66,7 +65,6 @@ bool _whole(WidgetTester tester, String text) {
|
||||
|
||||
void main() {
|
||||
{
|
||||
const cupertino = false;
|
||||
const host = 'Material';
|
||||
for (final width in [240.0, 270.0, 320.0]) {
|
||||
for (final brightness in Brightness.values) {
|
||||
@@ -79,13 +77,8 @@ void main() {
|
||||
await _pump(
|
||||
tester,
|
||||
_app(
|
||||
cupertino,
|
||||
brightness: brightness,
|
||||
SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
title: 'Runs',
|
||||
actions: _actions(cupertino, pressed),
|
||||
),
|
||||
SegmentedBar(title: 'Runs', actions: _actions(pressed)),
|
||||
),
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
@@ -139,14 +132,7 @@ void main() {
|
||||
_size(tester, 800);
|
||||
await _pump(
|
||||
tester,
|
||||
_app(
|
||||
cupertino,
|
||||
SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
title: 'Runs',
|
||||
actions: _actions(cupertino, []),
|
||||
),
|
||||
),
|
||||
_app(SegmentedBar(title: 'Runs', actions: _actions([]))),
|
||||
);
|
||||
for (final name in _names) {
|
||||
expect(find.byKey(_key(name)).hitTestable(), findsOneWidget);
|
||||
@@ -162,14 +148,7 @@ void main() {
|
||||
_size(tester, 240);
|
||||
await _pump(
|
||||
tester,
|
||||
_app(
|
||||
cupertino,
|
||||
SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
title: 'Pipelines',
|
||||
actions: _actions(cupertino, []),
|
||||
),
|
||||
),
|
||||
_app(SegmentedBar(title: 'Pipelines', actions: _actions([]))),
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
// The test font's glyphs are squares, wider than a real font's, so
|
||||
@@ -189,9 +168,7 @@ void main() {
|
||||
await _pump(
|
||||
tester,
|
||||
_app(
|
||||
cupertino,
|
||||
SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
title: 'Runs',
|
||||
actions: [
|
||||
for (final name in ['A', 'B', 'C'])
|
||||
@@ -208,7 +185,7 @@ void main() {
|
||||
),
|
||||
],
|
||||
),
|
||||
child: _icon(cupertino, name, () {}),
|
||||
child: _icon(name, () {}),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -47,7 +47,6 @@ void main() {
|
||||
home: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: SegmentedBar(
|
||||
cupertino: false,
|
||||
leading: const BackButton(),
|
||||
title: 'A conversation with a rather long title indeed',
|
||||
subtitle: 'tank',
|
||||
@@ -69,8 +68,7 @@ void main() {
|
||||
testWidgets('320px at 2x text lays out without overflow', (tester) async {
|
||||
_size(tester, 320, scale: 2);
|
||||
final bar = SegmentedBar(
|
||||
cupertino: false,
|
||||
leading: SegmentedBackButton(cupertino: false, onPressed: () {}),
|
||||
leading: SegmentedBackButton(onPressed: () {}),
|
||||
title: 'A long conversation title',
|
||||
subtitle: 'a-working-folder',
|
||||
subtitleIcon: Icons.folder_outlined,
|
||||
@@ -103,7 +101,6 @@ void main() {
|
||||
home: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: SegmentedBar(
|
||||
cupertino: false,
|
||||
leading: BackButton(onPressed: () => back++),
|
||||
title: 'Short',
|
||||
),
|
||||
@@ -130,7 +127,7 @@ void main() {
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: SegmentedBarOverlay(
|
||||
bar: const SegmentedBar(cupertino: false, title: 'Overlay'),
|
||||
bar: const SegmentedBar(title: 'Overlay'),
|
||||
child: ListView(
|
||||
children: const [ListTile(title: Text('First row'))],
|
||||
),
|
||||
@@ -152,7 +149,7 @@ void main() {
|
||||
home: MediaQuery(
|
||||
data: MediaQueryData(highContrast: highContrast),
|
||||
child: Scaffold(
|
||||
appBar: const SegmentedBar(cupertino: false, title: 'Glass'),
|
||||
appBar: const SegmentedBar(title: 'Glass'),
|
||||
body: const SizedBox.expand(),
|
||||
),
|
||||
),
|
||||
@@ -170,7 +167,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: SegmentedBar(cupertino: false, title: 'Title'),
|
||||
appBar: SegmentedBar(title: 'Title'),
|
||||
body: SizedBox.expand(),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -41,7 +41,6 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
page(
|
||||
SegmentedBar(
|
||||
cupertino: false,
|
||||
title: 'Search',
|
||||
titleWidget: field,
|
||||
titleWidgetMaxWidth: 840,
|
||||
@@ -71,9 +70,8 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
page(
|
||||
SegmentedBar(
|
||||
cupertino: false,
|
||||
title: 'Search',
|
||||
leading: SegmentedBackButton(cupertino: false, onPressed: () {}),
|
||||
leading: SegmentedBackButton(onPressed: () {}),
|
||||
titleWidget: field,
|
||||
titleWidgetMaxWidth: 600,
|
||||
actions: const [Icon(Icons.info_outline, key: Key('action'))],
|
||||
|
||||
@@ -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/ui/adaptive/floating_bar_layout.dart';
|
||||
@@ -23,13 +22,8 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
Widget page(Widget body, {bool cupertino = false}) {
|
||||
final bar = SegmentedBar(cupertino: cupertino, title: 'Page');
|
||||
if (cupertino) {
|
||||
return CupertinoApp(
|
||||
home: CupertinoPageScaffold(navigationBar: bar, child: body),
|
||||
);
|
||||
}
|
||||
Widget page(Widget body) {
|
||||
final bar = SegmentedBar(title: 'Page');
|
||||
return MaterialApp(
|
||||
home: Scaffold(extendBodyBehindAppBar: true, appBar: bar, body: body),
|
||||
);
|
||||
@@ -46,13 +40,13 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
{
|
||||
const host = 'Material';
|
||||
|
||||
testWidgets('$host: a list reaches the top edge, starts below the bar at '
|
||||
'rest and scrolls behind it', (tester) async {
|
||||
await setSize(tester, const Size(390, 844));
|
||||
await tester.pumpWidget(page(rows(), cupertino: cupertino));
|
||||
await tester.pumpWidget(page(rows()));
|
||||
|
||||
expect(tester.getTopLeft(find.byKey(const Key('list'))).dy, 0);
|
||||
final bar = barRect(tester);
|
||||
@@ -162,7 +156,6 @@ void main() {
|
||||
child: FloatingBarOverlay(
|
||||
edge: FloatingBarEdge.top,
|
||||
bar: FloatingDestinationBar(
|
||||
cupertino: false,
|
||||
edge: FloatingBarEdge.top,
|
||||
currentIndex: 0,
|
||||
onTap: (_) {},
|
||||
|
||||
@@ -18,7 +18,7 @@ void _window(WidgetTester tester, {double top = 10, double width = 800}) {
|
||||
}
|
||||
|
||||
SegmentedBar _bar({String title = 'Chat', List<Widget> actions = const []}) =>
|
||||
SegmentedBar(cupertino: false, title: title, actions: actions);
|
||||
SegmentedBar(title: title, actions: actions);
|
||||
|
||||
Widget _page(SegmentedBar bar, {ValueListenable<Rect?>? controls}) {
|
||||
final page = Scaffold(
|
||||
|
||||
@@ -138,7 +138,7 @@ void main() {
|
||||
final context = tester.element(row);
|
||||
expect(
|
||||
tester.widget<Material>(surface).color,
|
||||
AppListRow.selectedColor(context, cupertino: false),
|
||||
AppListRow.selectedColor(context),
|
||||
);
|
||||
final accent = Theme.of(context).colorScheme.primary;
|
||||
expect(_paint(tester, 'Fixture run').fontWeight, FontWeight.w700);
|
||||
|
||||
@@ -31,7 +31,6 @@ class _List extends StatelessWidget {
|
||||
onTap: () => Navigator.of(context).push(
|
||||
ContainerTransformPageRoute<void>(
|
||||
link: sources.link(() => id),
|
||||
cupertino: false,
|
||||
builder: (_) => _Page(id: id),
|
||||
),
|
||||
),
|
||||
@@ -172,7 +171,6 @@ void main() {
|
||||
navigator.push(
|
||||
ContainerTransformPageRoute<void>(
|
||||
link: sources.link(() => 'missing'),
|
||||
cupertino: false,
|
||||
builder: (_) => const _Page(id: 'x'),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -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/ui/input/app_search_field.dart';
|
||||
@@ -14,7 +13,6 @@ Widget _row(List<Widget> children) {
|
||||
BarIconButton _action(Key key, {bool busy = false}) => BarIconButton(
|
||||
key: key,
|
||||
icon: Icons.refresh,
|
||||
cupertinoIcon: CupertinoIcons.refresh,
|
||||
label: 'Refresh',
|
||||
busy: busy,
|
||||
onPressed: () {},
|
||||
|
||||
@@ -19,13 +19,12 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
test('page backgrounds are gray in dark mode and unchanged in light', () {
|
||||
expect(AppColors.background.darkColor, const Color(0xFF141416));
|
||||
expect(AppColors.background.color, const Color(0xFFFFFFFF));
|
||||
expect(
|
||||
AppColors.groupedBackground.darkColor,
|
||||
isNot(const Color(0xFF000000)),
|
||||
);
|
||||
test('page backgrounds use their Material surface roles', () {
|
||||
final dark = appDarkTheme();
|
||||
final light = appLightTheme();
|
||||
expect(dark.scaffoldBackgroundColor, dark.colorScheme.surface);
|
||||
expect(light.scaffoldBackgroundColor, light.colorScheme.surface);
|
||||
expect(dark.colorScheme.surface, isNot(const Color(0xFF000000)));
|
||||
});
|
||||
|
||||
test('Android pages retain native predictive Back in both themes', () {
|
||||
|
||||
Reference in New Issue
Block a user