Files
pipelines/app/test/shell/list_pane_compact_test.dart

59 lines
1.9 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/list_detail.dart';
import 'package:pipelines_app/shell/list_pane_widths.dart';
void main() {
testWidgets('compact rail remains draggable in a tight desktop layout', (
tester,
) async {
tester.view.physicalSize = const Size(600, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final widths = ListPaneWidths(store: MemoryListPaneWidthStore());
addTearDown(widths.dispose);
var compact = false;
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Align(
alignment: Alignment.topLeft,
child: SizedBox(
width: 544,
child: ListPaneWidthsScope(
widths: widths,
child: StatefulBuilder(
builder: (context, update) => ListDetailPanes(
list: const Text('List'),
detail: const Text('Detail'),
compactListWidth: 72,
listWidthOverride: compact ? 72 : null,
onListCompactChanged: (value) =>
update(() => compact = value),
),
),
),
),
),
),
),
);
await tester.pumpAndSettle();
final divider = find.byKey(const ValueKey('list-detail-divider'));
expect(divider, findsOneWidget);
final gesture = await tester.startGesture(tester.getCenter(divider));
await gesture.moveBy(const Offset(-90, 0));
await tester.pumpAndSettle();
expect(compact, isTrue);
expect(
tester.getTopLeft(find.byKey(const ValueKey('list-detail-body'))).dx,
73,
);
await gesture.moveBy(const Offset(110, 0));
await tester.pumpAndSettle();
expect(compact, isFalse);
await gesture.up();
expect(tester.takeException(), isNull);
});
}