Merge commit 'e3deb84dadad65339c17bfa8b78a2b3c97927d46' into pipelines/run-20261112-0140-run-details-open-with-output-expanded-81b3
This commit is contained in:
@@ -390,19 +390,24 @@ void main() {
|
||||
await app.stop(tester);
|
||||
});
|
||||
|
||||
testWidgets('X closes the window and returns nothing to the tiling', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('X minimises the window: the chat stays open, returns nothing '
|
||||
'to the tiling, and the chord brings the window back', (tester) async {
|
||||
await _saved('a', 'b');
|
||||
final app = _App(_Store());
|
||||
await app.start(tester);
|
||||
await _menu(tester, 'b', 'Float (Alt+Y)');
|
||||
await tester.tap(find.byTooltip('Close'));
|
||||
await tester.tap(find.byTooltip('Minimise'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(app.floating, isEmpty);
|
||||
// Still a window, hidden; not closed and not docked.
|
||||
expect(app.floating, ['b']);
|
||||
expect(app.windows.windows.single.minimized, isTrue);
|
||||
expect(_shown('Chat b'), findsNothing);
|
||||
expect(_workspace(tester).panes.map((p) => p.sessionId), ['a']);
|
||||
expect(_thread('b'), findsNothing);
|
||||
expect(app.gateway.calls.where((c) => c.type == 'chat_close'), isEmpty);
|
||||
await _chord(tester);
|
||||
expect(_shown('Chat b'), findsOneWidget);
|
||||
expect(_thread('b').hitTestable(), findsOneWidget);
|
||||
expect(app.floating, ['b']);
|
||||
await app.stop(tester);
|
||||
});
|
||||
|
||||
|
||||
@@ -40,6 +40,19 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
test('Runs and Pipelines switch is Ctrl+A on every platform', () {
|
||||
for (final platform in TargetPlatform.values) {
|
||||
final entry = KeyboardShortcutRegistry(platform: platform, web: false)
|
||||
.entries
|
||||
.firstWhere(
|
||||
(entry) => entry.action == 'Switch between Runs and Pipelines',
|
||||
);
|
||||
expect(entry.keys, 'Ctrl+A', reason: platform.name);
|
||||
expect(entry.caveat, contains('Pipelines'));
|
||||
expect(entry.caveat, contains('text field'));
|
||||
}
|
||||
});
|
||||
|
||||
test('uses the shell primary modifier rule on iOS', () {
|
||||
final entries = const KeyboardShortcutRegistry(
|
||||
platform: TargetPlatform.iOS,
|
||||
|
||||
@@ -167,10 +167,12 @@ void main() {
|
||||
expect(floatFinder, findsOneWidget);
|
||||
expect(frame().size, start.size + const Offset(80, 50));
|
||||
|
||||
await tester.tap(find.byTooltip('Close'));
|
||||
// The X minimises too: the window stays listed, hidden, with its shells.
|
||||
await tester.tap(find.byTooltip('Minimise'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(layout.visible, isFalse);
|
||||
expect(manager.windows, isEmpty);
|
||||
expect(manager.windows.single.minimized, isTrue);
|
||||
expect(floatFinder, findsNothing);
|
||||
expect(hub.tabs, hasLength(2));
|
||||
await ctrlBacktick(tester);
|
||||
expect(floatFinder, findsOneWidget);
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.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/shell_runs_pipelines_shortcut.dart';
|
||||
import 'package:pipelines_app/ui/input/keyboard_owner.dart';
|
||||
|
||||
const _a = KeyDownEvent(
|
||||
physicalKey: PhysicalKeyboardKey.keyA,
|
||||
logicalKey: LogicalKeyboardKey.keyA,
|
||||
timeStamp: Duration.zero,
|
||||
);
|
||||
|
||||
void main() {
|
||||
test('Ctrl+A matches only with Ctrl alone', () {
|
||||
bool chord(Set<LogicalKeyboardKey> held, [KeyEvent event = _a]) =>
|
||||
shellRunsPipelinesShortcut(event, _FakeKeyboard(held));
|
||||
expect(chord({}), isFalse);
|
||||
expect(chord({LogicalKeyboardKey.controlLeft}), isTrue);
|
||||
expect(chord({LogicalKeyboardKey.controlRight}), isTrue);
|
||||
expect(
|
||||
chord({LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.altLeft}),
|
||||
isFalse,
|
||||
);
|
||||
expect(
|
||||
chord({LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.shiftLeft}),
|
||||
isFalse,
|
||||
);
|
||||
expect(
|
||||
chord({LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.metaLeft}),
|
||||
isFalse,
|
||||
);
|
||||
expect(chord({LogicalKeyboardKey.altLeft}), isFalse);
|
||||
expect(chord({LogicalKeyboardKey.metaLeft}), isFalse);
|
||||
expect(
|
||||
shellRunsPipelinesShortcut(
|
||||
const KeyUpEvent(
|
||||
physicalKey: PhysicalKeyboardKey.keyA,
|
||||
logicalKey: LogicalKeyboardKey.keyA,
|
||||
timeStamp: Duration.zero,
|
||||
),
|
||||
_FakeKeyboard({LogicalKeyboardKey.controlLeft}),
|
||||
),
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
|
||||
test('Runs goes to Pipelines; every other destination goes to Runs', () {
|
||||
expect(
|
||||
shellRunsPipelinesTarget(AppDestination.runs),
|
||||
AppDestination.pipelines,
|
||||
);
|
||||
expect(
|
||||
shellRunsPipelinesTarget(AppDestination.pipelines),
|
||||
AppDestination.runs,
|
||||
);
|
||||
expect(shellRunsPipelinesTarget(AppDestination.chat), AppDestination.runs);
|
||||
expect(
|
||||
shellRunsPipelinesTarget(AppDestination.search),
|
||||
AppDestination.runs,
|
||||
);
|
||||
expect(
|
||||
shellRunsPipelinesTarget(AppDestination.settings),
|
||||
AppDestination.runs,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Ctrl+A bounces Chat, Runs, Pipelines, Runs', (tester) async {
|
||||
await _onAndroid(() async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: AdaptiveShell(
|
||||
destinationBodies: {
|
||||
for (final destination in shellTabDestinations)
|
||||
destination: (_) => Text('${destination.name} body'),
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(find.text('pipelines body'), isOnstage);
|
||||
|
||||
Future<void> pressCtrl(LogicalKeyboardKey key) async {
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
|
||||
await tester.sendKeyEvent(key);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
// Reach Chat first with Ctrl+K, then start the Ctrl+A sequence.
|
||||
await pressCtrl(LogicalKeyboardKey.keyK);
|
||||
expect(find.text('chat body'), isOnstage);
|
||||
expect(find.text('pipelines body'), findsNothing);
|
||||
|
||||
await pressCtrl(LogicalKeyboardKey.keyA);
|
||||
expect(find.text('runs body'), isOnstage);
|
||||
expect(find.text('chat body'), findsNothing);
|
||||
|
||||
await pressCtrl(LogicalKeyboardKey.keyA);
|
||||
expect(find.text('pipelines body'), isOnstage);
|
||||
expect(find.text('runs body'), findsNothing);
|
||||
|
||||
await pressCtrl(LogicalKeyboardKey.keyA);
|
||||
expect(find.text('runs body'), isOnstage);
|
||||
expect(find.text('pipelines body'), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('Ctrl+A is left to a focused text field', (tester) async {
|
||||
await _onAndroid(() async {
|
||||
final field = TextEditingController(text: 'draft message');
|
||||
final focus = FocusNode();
|
||||
addTearDown(field.dispose);
|
||||
addTearDown(focus.dispose);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: AdaptiveShell(
|
||||
destinationBodies: {
|
||||
AppDestination.pipelines: (_) =>
|
||||
TextField(controller: field, focusNode: focus),
|
||||
AppDestination.runs: (_) => const Text('runs body'),
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
focus.requestFocus();
|
||||
await tester.pump();
|
||||
expect(focus.hasPrimaryFocus, isTrue);
|
||||
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.keyA);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Destination unchanged; the field took the chord (select all on this
|
||||
// platform), so the text is still there and fully selected.
|
||||
expect(find.text('runs body'), findsNothing);
|
||||
expect(field.text, 'draft message');
|
||||
expect(field.selection.baseOffset, 0);
|
||||
expect(field.selection.extentOffset, field.text.length);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('Ctrl+A is left to the terminal while it has focus', (
|
||||
tester,
|
||||
) async {
|
||||
await _onAndroid(() async {
|
||||
final terminal = FocusNode();
|
||||
addTearDown(terminal.dispose);
|
||||
final received = <KeyEvent>[];
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: AdaptiveShell(
|
||||
destinationBodies: {
|
||||
AppDestination.pipelines: (_) => TypingSurface(
|
||||
child: Focus(
|
||||
focusNode: terminal,
|
||||
onKeyEvent: (node, event) {
|
||||
if (event.logicalKey == LogicalKeyboardKey.keyA) {
|
||||
received.add(event);
|
||||
}
|
||||
return KeyEventResult.ignored;
|
||||
},
|
||||
child: const Text('terminal'),
|
||||
),
|
||||
),
|
||||
AppDestination.runs: (_) => const Text('runs body'),
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
terminal.requestFocus();
|
||||
await tester.pump();
|
||||
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.keyA);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('runs body'), findsNothing);
|
||||
expect(find.text('terminal'), isOnstage);
|
||||
expect(received.whereType<KeyDownEvent>(), hasLength(1));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// Runs [body] with the platform pinned to Android, so Ctrl+A in a text field
|
||||
/// means select all everywhere. flutter_test requires the debug override to be
|
||||
/// cleared before the test body returns, hence the `finally`.
|
||||
Future<void> _onAndroid(Future<void> Function() body) async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.android;
|
||||
try {
|
||||
await body();
|
||||
} finally {
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
}
|
||||
}
|
||||
|
||||
class _FakeKeyboard extends HardwareKeyboard {
|
||||
_FakeKeyboard(this.pressed);
|
||||
final Set<LogicalKeyboardKey> pressed;
|
||||
@override
|
||||
bool isLogicalKeyPressed(LogicalKeyboardKey key) => pressed.contains(key);
|
||||
}
|
||||
@@ -25,9 +25,11 @@ void main() {
|
||||
const Rect.fromLTWH(100, 80, 360, 420),
|
||||
);
|
||||
expect(find.byTooltip('Probe action'), findsOneWidget);
|
||||
for (final tip in ['Minimise', 'Maximise', 'Close']) {
|
||||
for (final tip in ['Minimise', 'Maximise']) {
|
||||
expect(find.byTooltip(tip), findsOneWidget);
|
||||
}
|
||||
// There is no separate Minimise button: the X is the one minimise.
|
||||
expect(find.byTooltip('Close'), findsNothing);
|
||||
expect(find.text('sheet').hitTestable(), findsOneWidget);
|
||||
// The title bar, the content and the app behind all keep their
|
||||
// semantics (a page route's barrier hides what is behind it).
|
||||
@@ -172,14 +174,30 @@ void main() {
|
||||
expect(find.text('typed'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('X closes the window', (tester) async {
|
||||
testWidgets('X minimises the window and never closes it', (tester) async {
|
||||
final entry = manager.open('probe', 'a');
|
||||
await pumpProbe(tester, manager);
|
||||
await tester.tap(find.byTooltip('Close'));
|
||||
await tester.enterText(find.byKey(const ValueKey('a-field')), 'kept');
|
||||
final state = tester.state<ProbeContentState>(find.byType(ProbeContent));
|
||||
await tester.tap(find.byTooltip('Minimise'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(manager.windows, isEmpty);
|
||||
expect(find.byType(ProbeContent, skipOffstage: false), findsNothing);
|
||||
expect((manager.kinds['probe']! as ProbeWindowKind).closed_, [entry.id]);
|
||||
expect(manager.windows.single.id, entry.id);
|
||||
expect(manager.byId(entry.id)!.minimized, isTrue);
|
||||
expect(find.text('Probe a').hitTestable(), findsNothing);
|
||||
// Not a close: the kind's closed hook does not run, and the content
|
||||
// stays alive with its state.
|
||||
expect((manager.kinds['probe']! as ProbeWindowKind).closed_, isEmpty);
|
||||
expect(
|
||||
tester.state<ProbeContentState>(
|
||||
find.byType(ProbeContent, skipOffstage: false),
|
||||
),
|
||||
same(state),
|
||||
);
|
||||
// Listed and brought back by the group, as Minimise always was.
|
||||
manager.toggleGroup('probe');
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Probe a').hitTestable(), findsOneWidget);
|
||||
expect(find.text('kept'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('pressing a window brings it to the top and keeps both alive', (
|
||||
|
||||
@@ -209,14 +209,17 @@ void main() {
|
||||
probeTooltipColor,
|
||||
);
|
||||
|
||||
await mouse.moveTo(tester.getCenter(find.byTooltip('Close').last));
|
||||
await mouse.moveTo(tester.getCenter(find.byTooltip('Minimise').last));
|
||||
await tester.pumpAndSettle(const Duration(seconds: 1));
|
||||
expect(find.text('Close'), findsOneWidget);
|
||||
expect(find.text('Minimise'), findsOneWidget);
|
||||
// Not clipped to the window: tooltips paint in an overlay as large
|
||||
// as the app.
|
||||
final overlay = tester.renderObject<RenderBox>(
|
||||
find
|
||||
.ancestor(of: find.text('Close'), matching: find.byType(Overlay))
|
||||
.ancestor(
|
||||
of: find.text('Minimise'),
|
||||
matching: find.byType(Overlay),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
expect(overlay.size, const Size(1280, 800));
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/shell/destination.dart';
|
||||
import 'package:pipelines_app/shell/detail_page.dart';
|
||||
import 'package:pipelines_app/shell/shell_bar.dart';
|
||||
import 'package:pipelines_app/ui/motion/container_transform_flight.dart';
|
||||
import 'package:pipelines_app/ui/motion/container_transform_source.dart';
|
||||
import 'package:pipelines_app/ui/motion/motion.dart';
|
||||
|
||||
const _screen = Size(390, 844);
|
||||
|
||||
/// A phone-style owner: its selected row opens a detail page that grows from
|
||||
/// the row, as the chat screen's page does.
|
||||
class _Owner extends StatefulWidget {
|
||||
const _Owner({required this.selection, required this.sources});
|
||||
|
||||
final ValueNotifier<String?> selection;
|
||||
final ContainerTransformSources sources;
|
||||
|
||||
@override
|
||||
State<_Owner> createState() => _OwnerState();
|
||||
}
|
||||
|
||||
class _OwnerState extends State<_Owner> {
|
||||
final DetailPageHost page = DetailPageHost();
|
||||
|
||||
/// Stands in for work the owner might await when the page closes (a draft
|
||||
/// or scroll save). It never completes, so any pop that waited on it would
|
||||
/// never start.
|
||||
final Completer<void> neverSaved = Completer<void>();
|
||||
int closed = 0;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
page.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ValueListenableBuilder<String?>(
|
||||
valueListenable: widget.selection,
|
||||
builder: (context, selected, _) {
|
||||
page.sync(
|
||||
context,
|
||||
selected: selected != null,
|
||||
destination: AppDestination.chat,
|
||||
growFrom: widget.sources.link(() => widget.selection.value),
|
||||
onClosed: () {
|
||||
closed++;
|
||||
unawaited(_save());
|
||||
widget.selection.value = null;
|
||||
},
|
||||
builder: (context) =>
|
||||
ShellBar(title: 'Chat', child: const Text('chat body')),
|
||||
);
|
||||
return ContainerTransformScope(
|
||||
sources: widget.sources,
|
||||
child: const Column(
|
||||
children: [
|
||||
SizedBox(height: 200),
|
||||
ContainerTransformSource(
|
||||
id: '7',
|
||||
color: Color(0xFFE3F2FD),
|
||||
child: SizedBox(
|
||||
key: Key('row-7'),
|
||||
height: 72,
|
||||
child: Text('row 7'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Future<void> _save() => neverSaved.future;
|
||||
}
|
||||
|
||||
Future<void> _pumpOwner(
|
||||
WidgetTester tester,
|
||||
ValueNotifier<String?> selection,
|
||||
ContainerTransformSources sources,
|
||||
) async {
|
||||
tester.view.physicalSize = _screen;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: _Owner(selection: selection, sources: sources),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'system Back changes the route in one frame and shrinks the page at once',
|
||||
(tester) async {
|
||||
final selection = ValueNotifier<String?>(null);
|
||||
final sources = ContainerTransformSources();
|
||||
await _pumpOwner(tester, selection, sources);
|
||||
selection.value = '7';
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final row = tester.getRect(
|
||||
find.byKey(const Key('row-7'), skipOffstage: false),
|
||||
);
|
||||
final route = ModalRoute.of(
|
||||
tester.element(find.byKey(containerTransformSurfaceKey)),
|
||||
)!;
|
||||
expect(route.isCurrent, isTrue);
|
||||
|
||||
// The owner's close work never completes, yet Back starts at once.
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pump();
|
||||
expect(route.isCurrent, isFalse);
|
||||
expect(route.animation!.status, AnimationStatus.reverse);
|
||||
|
||||
// Two frames after the pop the page is visibly shrinking toward the row.
|
||||
await tester.pump(const Duration(milliseconds: 16));
|
||||
final height = tester
|
||||
.getRect(find.byKey(containerTransformSurfaceKey))
|
||||
.height;
|
||||
final travel = _screen.height - row.height;
|
||||
final shrunk = (_screen.height - height) / travel;
|
||||
expect(shrunk, greaterThan(0.1));
|
||||
expect(shrunk, lessThan(1));
|
||||
|
||||
// The reverse stays within the standard Material container transform.
|
||||
expect(
|
||||
Motion.containerTransformReverse,
|
||||
lessThanOrEqualTo(const Duration(milliseconds: 300)),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('chat body'), findsNothing);
|
||||
expect(selection.value, isNull);
|
||||
expect(tester.state<_OwnerState>(find.byType(_Owner)).closed, 1);
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user