41a9e99da8
On a wide split window a run's stage page (or an artifact, a file) opens inside the detail pane's own navigator. Selecting another run kept that page on top, so the pane still showed the old stage. ListDetailPanes now takes the selected item's identity (run, chat or pipeline id) and the pane navigator pops back to the item when it changes.
75 lines
2.5 KiB
Dart
75 lines
2.5 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
|
import 'package:pipelines_app/shell/destination.dart';
|
|
import 'package:pipelines_app/shell/list_detail.dart';
|
|
|
|
/// On a wide split window a page an item opened in its pane (a run's stage
|
|
/// page) closes when another item is selected, so the pane shows the newly
|
|
/// selected item instead of the old item's page.
|
|
void main() {
|
|
for (final cupertino in [false, true]) {
|
|
testWidgets('selecting another item closes the previous item\'s page '
|
|
'(${cupertino ? 'cupertino' : 'material'})', (tester) async {
|
|
tester.view.physicalSize = const Size(1200, 800);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
final selected = ValueNotifier<int>(1);
|
|
addTearDown(selected.dispose);
|
|
|
|
Widget detail(int id) => Builder(
|
|
builder: (context) => Center(
|
|
child: GestureDetector(
|
|
key: const Key('open-page'),
|
|
onTap: () => Navigator.of(context).push(
|
|
PageRouteBuilder<void>(
|
|
pageBuilder: (_, _, _) => Text('page of item $id'),
|
|
),
|
|
),
|
|
child: Text('item $id'),
|
|
),
|
|
),
|
|
);
|
|
|
|
final shell = AdaptiveShell(
|
|
cupertino: cupertino,
|
|
destination: AppDestination.runs,
|
|
destinationBodies: {
|
|
AppDestination.runs: (_) => ValueListenableBuilder<int>(
|
|
valueListenable: selected,
|
|
builder: (_, id, _) => ListDetailPanes(
|
|
list: const Text('list'),
|
|
detailIdentity: id,
|
|
detail: detail(id),
|
|
),
|
|
),
|
|
},
|
|
);
|
|
await tester.pumpWidget(
|
|
cupertino
|
|
? CupertinoApp(home: shell)
|
|
: MaterialApp(
|
|
theme: ThemeData(platform: TargetPlatform.android),
|
|
home: shell,
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
await tester.tap(find.byKey(const Key('open-page')));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('page of item 1'), findsOneWidget);
|
|
|
|
// The same item rebuilt keeps its page open.
|
|
selected.value = 1;
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('page of item 1'), findsOneWidget);
|
|
|
|
selected.value = 2;
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('page of item 1'), findsNothing);
|
|
expect(find.text('item 2'), findsOneWidget);
|
|
});
|
|
}
|
|
}
|