Add the shell window host with layering acceptance tests
Phase 1.3 and 1.4 of docs/plans/floating-windows.md. Windows are plain children of the terminal stage's stack in the shell page, outside every destination, so popups opened from one are above all of them. Each window has its own page navigator: pushed pages open inside the window, and popup routes go to the root navigator. One WindowFrame chrome (move, resize, minimise, maximise, close), a focus scope per window, a ScaffoldMessenger per window. No feature uses it yet. The capture fixture opens probe windows with ?windows=N, and window_layering_test.dart covers every popup type from a window over Chat and over another destination.
This commit is contained in:
@@ -0,0 +1,249 @@
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_frame.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_layer.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_manager.dart';
|
||||
|
||||
import 'window_test_harness.dart';
|
||||
|
||||
void main() {
|
||||
late WindowManager manager;
|
||||
setUp(() => manager = probeManager());
|
||||
|
||||
Finder window(String title) => find.byWidgetPredicate(
|
||||
(w) => w is WindowLayer && 'Probe ${w.entry.contentId}' == title,
|
||||
);
|
||||
Finder inWindow(String title, Finder what) =>
|
||||
find.descendant(of: window(title), matching: what);
|
||||
|
||||
testWidgets('a window shows its title, actions and content', (tester) async {
|
||||
manager.open('probe', 'a');
|
||||
await pumpProbe(tester, manager);
|
||||
expect(
|
||||
windowRect(tester, 'Probe a'),
|
||||
const Rect.fromLTWH(100, 80, 360, 420),
|
||||
);
|
||||
expect(find.byTooltip('Probe action'), findsOneWidget);
|
||||
for (final tip in ['Minimise', 'Maximise', 'Close']) {
|
||||
expect(find.byTooltip(tip), findsOneWidget);
|
||||
}
|
||||
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).
|
||||
final handle = tester.ensureSemantics();
|
||||
expect(find.bySemanticsLabel('Window: Probe a'), findsOneWidget);
|
||||
expect(
|
||||
tester.getSemantics(find.byTooltip('Minimise')).tooltip,
|
||||
'Minimise',
|
||||
);
|
||||
expect(find.bySemanticsLabel('sheet'), findsOneWidget);
|
||||
expect(find.bySemanticsLabel('Chat'), findsOneWidget);
|
||||
expect(
|
||||
tester.getSemantics(find.bySemanticsLabel('Window: Probe a')).rect.size,
|
||||
const Size(360, 420),
|
||||
);
|
||||
handle.dispose();
|
||||
// The content is laid out for the window, not the app.
|
||||
final content = tester.element(find.byType(ProbeContent));
|
||||
expect(MediaQuery.sizeOf(content).width, 360);
|
||||
expect(tester.getRect(find.byType(ProbeContent)).top, greaterThan(80));
|
||||
});
|
||||
|
||||
testWidgets('the app behind takes input everywhere outside a window', (
|
||||
tester,
|
||||
) async {
|
||||
manager.open('probe', 'a');
|
||||
await pumpProbe(tester, manager, destination: 1);
|
||||
expect(find.text('Runs content').hitTestable(), findsOneWidget);
|
||||
await tester.tap(find.byKey(const ValueKey('a-page')));
|
||||
await tester.pumpAndSettle();
|
||||
// A page pushed inside the window still leaves the app usable.
|
||||
expect(find.text('Runs content').hitTestable(), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('drag the title to move, the corner to resize, inside the app', (
|
||||
tester,
|
||||
) async {
|
||||
final entry = manager.open('probe', 'a');
|
||||
await pumpProbe(tester, manager);
|
||||
await tester.drag(
|
||||
find.byKey(const ValueKey('window-title')),
|
||||
const Offset(50, 30),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
windowRect(tester, 'Probe a'),
|
||||
const Rect.fromLTWH(150, 110, 360, 420),
|
||||
);
|
||||
await tester.drag(
|
||||
find.byKey(const ValueKey('window-resize')),
|
||||
const Offset(40, -500),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
// Never smaller than the kind's minimum.
|
||||
expect(
|
||||
windowRect(tester, 'Probe a'),
|
||||
const Rect.fromLTWH(150, 110, 400, 160),
|
||||
);
|
||||
await tester.drag(
|
||||
find.byKey(const ValueKey('window-title')),
|
||||
const Offset(5000, 5000),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
windowRect(tester, 'Probe a'),
|
||||
const Rect.fromLTWH(880, 640, 400, 160),
|
||||
);
|
||||
expect(
|
||||
manager.byId(entry.id)!.frame,
|
||||
const Rect.fromLTWH(880, 640, 400, 160),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('maximise fills the app and restores; double click toggles', (
|
||||
tester,
|
||||
) async {
|
||||
manager.open('probe', 'a');
|
||||
await pumpProbe(tester, manager);
|
||||
await tester.tap(find.byTooltip('Maximise'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(windowRect(tester, 'Probe a'), const Rect.fromLTWH(8, 8, 1264, 784));
|
||||
expect(find.byKey(const ValueKey('window-resize')), findsNothing);
|
||||
await tester.tap(find.byTooltip('Restore size'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
windowRect(tester, 'Probe a'),
|
||||
const Rect.fromLTWH(100, 80, 360, 420),
|
||||
);
|
||||
final title = tester.getCenter(find.byKey(const ValueKey('window-title')));
|
||||
await tester.tapAt(title);
|
||||
await tester.pump(kDoubleTapMinTime);
|
||||
await tester.tapAt(title);
|
||||
await tester.pumpAndSettle();
|
||||
expect(manager.windows.single.maximized, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('minimise hides the window and keeps its state; the group '
|
||||
'brings it back', (tester) async {
|
||||
final entry = manager.open('probe', 'a');
|
||||
await pumpProbe(tester, manager);
|
||||
await tester.enterText(find.byKey(const ValueKey('a-field')), 'typed');
|
||||
final state = tester.state<ProbeContentState>(find.byType(ProbeContent));
|
||||
await tester.tap(find.byTooltip('Minimise'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(manager.byId(entry.id)!.minimized, isTrue);
|
||||
expect(find.text('Probe a').hitTestable(), findsNothing);
|
||||
expect(find.byType(WindowFrame, skipOffstage: false), findsOneWidget);
|
||||
manager.toggleGroup('probe');
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Probe a').hitTestable(), findsOneWidget);
|
||||
expect(
|
||||
tester.state<ProbeContentState>(find.byType(ProbeContent)),
|
||||
same(state),
|
||||
);
|
||||
expect(find.text('typed'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('X closes the window', (tester) async {
|
||||
final entry = manager.open('probe', 'a');
|
||||
await pumpProbe(tester, manager);
|
||||
await tester.tap(find.byTooltip('Close'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(manager.windows, isEmpty);
|
||||
expect(find.byType(ProbeContent, skipOffstage: false), findsNothing);
|
||||
expect((manager.kinds['probe']! as ProbeWindowKind).closed_, [entry.id]);
|
||||
});
|
||||
|
||||
testWidgets('pressing a window brings it to the top and keeps both alive', (
|
||||
tester,
|
||||
) async {
|
||||
final a = manager.open('probe', 'a');
|
||||
final b = manager.open('probe', 'b');
|
||||
await pumpProbe(tester, manager);
|
||||
final stateA = tester.state(find.byKey(const ValueKey('a-field')));
|
||||
// b covers a where they overlap.
|
||||
expect(find.byKey(const ValueKey('a-dialog')).hitTestable(), findsNothing);
|
||||
expect(manager.active!.id, b.id);
|
||||
// a's title bar shows above b.
|
||||
await tester.tapAt(
|
||||
windowRect(tester, 'Probe a').topLeft + const Offset(16, 12),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(manager.active!.id, a.id);
|
||||
expect(
|
||||
find.byKey(const ValueKey('a-dialog')).hitTestable(),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(tester.state(find.byKey(const ValueKey('a-field'))), same(stateA));
|
||||
expect(inWindow('Probe b', find.byType(ProbeContent)), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('the keyboard goes to the shown window and back when it hides', (
|
||||
tester,
|
||||
) async {
|
||||
await pumpProbe(tester, manager);
|
||||
await tester.tap(find.byKey(const ValueKey('chat-composer')));
|
||||
await tester.pump();
|
||||
final composer = FocusManager.instance.primaryFocus;
|
||||
bool focusIn(Finder area) => find
|
||||
.descendant(
|
||||
of: area,
|
||||
matching: find.byWidget(
|
||||
FocusManager.instance.primaryFocus!.context!.widget,
|
||||
),
|
||||
)
|
||||
.evaluate()
|
||||
.isNotEmpty;
|
||||
expect(focusIn(find.byKey(const ValueKey('chat-composer'))), isTrue);
|
||||
|
||||
final a = manager.open('probe', 'a');
|
||||
await tester.pumpAndSettle();
|
||||
bool inside(String title) => focusIn(window(title));
|
||||
expect(inside('Probe a'), isTrue);
|
||||
|
||||
final b = manager.open('probe', 'b');
|
||||
await tester.pumpAndSettle();
|
||||
expect(inside('Probe b'), isTrue);
|
||||
|
||||
// The top window hides: the next one takes the keyboard.
|
||||
manager.setMinimized(b.id, true);
|
||||
await tester.pumpAndSettle();
|
||||
expect(inside('Probe a'), isTrue);
|
||||
|
||||
manager.setGroupShown('probe', false);
|
||||
await tester.pumpAndSettle();
|
||||
expect(FocusManager.instance.primaryFocus, same(composer));
|
||||
expect(manager.byId(a.id), isNotNull);
|
||||
});
|
||||
|
||||
testWidgets('a window works and animates over another destination', (
|
||||
tester,
|
||||
) async {
|
||||
manager.open('probe', 'a');
|
||||
await pumpProbe(tester, manager, destination: 1);
|
||||
expect(find.text('Probe a').hitTestable(), findsOneWidget);
|
||||
// Not muted by the hidden destination.
|
||||
final content = tester.element(find.byType(ProbeContent));
|
||||
expect(TickerMode.valuesOf(content).enabled, isTrue);
|
||||
await tester.tap(find.byKey(const ValueKey('a-field')));
|
||||
await tester.pump();
|
||||
await tester.enterText(find.byKey(const ValueKey('a-field')), 'over runs');
|
||||
expect(find.text('over runs'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('a frame larger than a small app is drawn inside it', (
|
||||
tester,
|
||||
) async {
|
||||
manager.open('probe', 'a', frame: const Rect.fromLTWH(900, 600, 800, 700));
|
||||
await pumpProbe(tester, manager);
|
||||
expect(
|
||||
windowRect(tester, 'Probe a'),
|
||||
const Rect.fromLTWH(480, 100, 800, 700),
|
||||
);
|
||||
tester.view.physicalSize = const Size(600, 400);
|
||||
await tester.pumpAndSettle();
|
||||
expect(windowRect(tester, 'Probe a'), const Rect.fromLTWH(0, 0, 600, 400));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_manager.dart';
|
||||
|
||||
import 'window_test_harness.dart';
|
||||
|
||||
/// Layering acceptance (docs/plans/floating-windows.md, Phase 1.4): every
|
||||
/// kind of popup opened from inside a window is above every window, over the
|
||||
/// Chat destination and over another one; a pushed page stays inside its
|
||||
/// window. "Above" is a hit test at the popup reaching the popup
|
||||
/// ([Finder.hitTestable]), or its pixels for a tooltip, which takes no input.
|
||||
void main() {
|
||||
late WindowManager manager;
|
||||
|
||||
/// Two overlapping windows; `a` is pressed, so it is on top, and `b`
|
||||
/// covers the area to its lower right.
|
||||
Future<void> open(
|
||||
WidgetTester tester,
|
||||
int destination, {
|
||||
GlobalKey? boundary,
|
||||
}) async {
|
||||
manager = probeManager();
|
||||
manager.open('probe', 'b', frame: const Rect.fromLTWH(300, 200, 600, 500));
|
||||
manager.open('probe', 'a', frame: const Rect.fromLTWH(100, 80, 360, 640));
|
||||
await pumpProbe(
|
||||
tester,
|
||||
manager,
|
||||
destination: destination,
|
||||
boundary: boundary,
|
||||
);
|
||||
}
|
||||
|
||||
String? picked(WidgetTester tester, String id) => tester
|
||||
.state<ProbeContentState>(find.byKey(ValueKey('content-$id')))
|
||||
.picked;
|
||||
|
||||
NavigatorState root(WidgetTester tester) =>
|
||||
tester.state<NavigatorState>(find.byType(Navigator).first);
|
||||
|
||||
for (final (destination, where) in [
|
||||
(0, 'Chat'),
|
||||
(1, 'another destination'),
|
||||
]) {
|
||||
group('over $where:', () {
|
||||
testWidgets('bottom sheet', (tester) async {
|
||||
await open(tester, destination);
|
||||
await tester.tap(find.byKey(const ValueKey('a-sheet')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Sheet item').hitTestable(), findsOneWidget);
|
||||
// On the root navigator: full width, not clipped to the window.
|
||||
expect(
|
||||
tester.getSize(find.byType(BottomSheet)).width,
|
||||
greaterThan(600),
|
||||
);
|
||||
expect(root(tester).canPop(), isTrue);
|
||||
// The sheet closes itself with its own navigator.
|
||||
await tester.tap(find.text('Sheet item'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Sheet item'), findsNothing);
|
||||
expect(find.byKey(const ValueKey('a-sheet')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('dialog', (tester) async {
|
||||
await open(tester, destination);
|
||||
await tester.tap(find.byKey(const ValueKey('a-dialog')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Dialog title').hitTestable(), findsOneWidget);
|
||||
// Its barrier covers the windows.
|
||||
expect(
|
||||
find.byKey(const ValueKey('b-dialog')).hitTestable(),
|
||||
findsNothing,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('MenuAnchor', (tester) async {
|
||||
await open(tester, destination);
|
||||
await tester.tap(find.byKey(const ValueKey('a-anchor')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Anchor item').hitTestable(), findsOneWidget);
|
||||
await tester.tap(find.text('Anchor item'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(picked(tester, 'a'), 'anchor');
|
||||
});
|
||||
|
||||
testWidgets('PopupMenuButton opens at its button', (tester) async {
|
||||
await open(tester, destination);
|
||||
final button = tester.getRect(find.byKey(const ValueKey('a-popup')));
|
||||
await tester.tap(find.byKey(const ValueKey('a-popup')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Popup item').hitTestable(), findsOneWidget);
|
||||
final item = tester.getRect(find.text('Popup item'));
|
||||
expect((item.top - button.top).abs(), lessThan(80));
|
||||
expect((item.left - button.left).abs(), lessThan(200));
|
||||
await tester.tap(find.text('Popup item'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(picked(tester, 'a'), 'popup');
|
||||
});
|
||||
|
||||
testWidgets('DropdownButton opens at its button', (tester) async {
|
||||
await open(tester, destination);
|
||||
final button = tester.getRect(find.byKey(const ValueKey('a-dropdown')));
|
||||
await tester.tap(find.byKey(const ValueKey('a-dropdown')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Drop two').hitTestable(), findsOneWidget);
|
||||
final item = tester.getRect(find.text('Drop two').last);
|
||||
expect((item.top - button.top).abs(), lessThan(120));
|
||||
expect((item.left - button.left).abs(), lessThan(40));
|
||||
await tester.tap(find.text('Drop two').last);
|
||||
await tester.pumpAndSettle();
|
||||
expect(picked(tester, 'a'), 'two');
|
||||
});
|
||||
|
||||
testWidgets('pushed page opens inside its window, with Back inside', (
|
||||
tester,
|
||||
) async {
|
||||
await open(tester, destination);
|
||||
final window = windowRect(tester, 'Probe a');
|
||||
await tester.tap(find.byKey(const ValueKey('a-page')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Page body').hitTestable(), findsOneWidget);
|
||||
final page = tester.getRect(find.text('Page of a'));
|
||||
expect(window.contains(page.topLeft), isTrue);
|
||||
expect(window.contains(page.bottomRight), isTrue);
|
||||
// The window keeps its title bar; the app has no new page.
|
||||
expect(find.text('Probe a').hitTestable(), findsOneWidget);
|
||||
expect(root(tester).canPop(), isFalse);
|
||||
// The other window is untouched.
|
||||
expect(
|
||||
find.byKey(const ValueKey('b-snack')).hitTestable(),
|
||||
findsOneWidget,
|
||||
);
|
||||
await tester.tap(find.byType(BackButton));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Page body'), findsNothing);
|
||||
expect(
|
||||
find.byKey(const ValueKey('a-page')).hitTestable(),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('SnackBar shows inside its window', (tester) async {
|
||||
await open(tester, destination);
|
||||
await tester.tap(find.byKey(const ValueKey('a-snack')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Snack text').hitTestable(), findsOneWidget);
|
||||
final window = windowRect(tester, 'Probe a');
|
||||
final snack = tester.getRect(find.byType(SnackBar));
|
||||
expect(window.contains(snack.topLeft), isTrue);
|
||||
expect(window.contains(snack.bottomRight - const Offset(1, 1)), isTrue);
|
||||
});
|
||||
|
||||
testWidgets('text selection menu', (tester) async {
|
||||
await open(tester, destination);
|
||||
// On the text itself, which selects a word.
|
||||
await tester.longPressAt(
|
||||
tester.getRect(find.byKey(const ValueKey('a-field'))).centerLeft +
|
||||
const Offset(30, 0),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Select all').hitTestable(), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('tooltip of content and of the title bar', (tester) async {
|
||||
final boundary = GlobalKey();
|
||||
await open(tester, destination, boundary: boundary);
|
||||
final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
|
||||
addTearDown(mouse.removePointer);
|
||||
await mouse.addPointer(location: Offset.zero);
|
||||
await mouse.moveTo(
|
||||
tester.getCenter(find.byKey(const ValueKey('a-tip'))),
|
||||
);
|
||||
await tester.pumpAndSettle(const Duration(seconds: 1));
|
||||
expect(find.text('Tip text'), findsOneWidget);
|
||||
// Its own pixels show: nothing is painted over it.
|
||||
final tip = tester.getRect(find.text('Tip text'));
|
||||
final image = await _capture(tester, boundary);
|
||||
expect(
|
||||
await _pixel(tester, image, tip.topLeft - const Offset(3, 2)),
|
||||
probeTooltipColor,
|
||||
);
|
||||
|
||||
await mouse.moveTo(tester.getCenter(find.byTooltip('Close').last));
|
||||
await tester.pumpAndSettle(const Duration(seconds: 1));
|
||||
expect(find.text('Close'), 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))
|
||||
.first,
|
||||
);
|
||||
expect(overlay.size, const Size(1280, 800));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('a popup from a window under another window is above both', (
|
||||
tester,
|
||||
) async {
|
||||
await open(tester, 0);
|
||||
// b is under a; its sheet button is outside a.
|
||||
await tester.tap(find.byKey(const ValueKey('b-sheet')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(manager.active!.contentId, 'b');
|
||||
expect(find.text('Sheet item').hitTestable(), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Escape closes the popup, not the window', (tester) async {
|
||||
await open(tester, 0);
|
||||
await tester.tap(find.byKey(const ValueKey('a-dialog')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Dialog title'), findsNothing);
|
||||
expect(manager.windows, hasLength(2));
|
||||
expect(find.text('Probe a').hitTestable(), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
Future<ui.Image> _capture(WidgetTester tester, GlobalKey boundary) async {
|
||||
final render =
|
||||
boundary.currentContext!.findRenderObject()! as RenderRepaintBoundary;
|
||||
return (await tester.runAsync(() => render.toImage()))!;
|
||||
}
|
||||
|
||||
Future<Color> _pixel(WidgetTester tester, ui.Image image, Offset at) async {
|
||||
final data = (await tester.runAsync(
|
||||
() => image.toByteData(format: ui.ImageByteFormat.rawRgba),
|
||||
))!;
|
||||
final i = (at.dy.round() * image.width + at.dx.round()) * 4;
|
||||
return Color.fromARGB(
|
||||
data.getUint8(i + 3),
|
||||
data.getUint8(i),
|
||||
data.getUint8(i + 1),
|
||||
data.getUint8(i + 2),
|
||||
);
|
||||
}
|
||||
@@ -111,9 +111,15 @@ void main() {
|
||||
_window({'content': ' padded '}),
|
||||
_window({'server': '#remove'}),
|
||||
_window({'kind': 'terminal'}),
|
||||
_window({'frame': [1, 2, 3]}),
|
||||
_window({'frame': [1, 2, 0, 5]}),
|
||||
_window({'frame': [1, 2, 'a', 5]}),
|
||||
_window({
|
||||
'frame': [1, 2, 3],
|
||||
}),
|
||||
_window({
|
||||
'frame': [1, 2, 0, 5],
|
||||
}),
|
||||
_window({
|
||||
'frame': [1, 2, 'a', 5],
|
||||
}),
|
||||
_window({'data': 7}),
|
||||
'text',
|
||||
]) {
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_frame.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_host.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_manager.dart';
|
||||
import 'package:pipelines_app/ui/motion/fade_through_stack.dart';
|
||||
|
||||
export '../../../tool/capture/window_probe.dart';
|
||||
|
||||
/// The shell in miniature: a root navigator whose one page holds two
|
||||
/// destinations (only one shown, as in the app) and the window host above
|
||||
/// them.
|
||||
class ProbeApp extends StatelessWidget {
|
||||
const ProbeApp({
|
||||
super.key,
|
||||
required this.manager,
|
||||
this.destination = 0,
|
||||
this.boundary,
|
||||
});
|
||||
|
||||
final WindowManager manager;
|
||||
final int destination;
|
||||
final GlobalKey? boundary;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => RepaintBoundary(
|
||||
key: boundary,
|
||||
child: MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
FadeThroughStack(
|
||||
index: destination,
|
||||
children: [
|
||||
Center(
|
||||
child: TextField(
|
||||
key: const ValueKey('chat-composer'),
|
||||
decoration: const InputDecoration(hintText: 'Chat'),
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: TextButton(
|
||||
key: const ValueKey('runs-button'),
|
||||
onPressed: () {},
|
||||
child: const Text('Runs content'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Positioned.fill(child: WindowHost(manager: manager)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Pumps a 1280x800 app with [manager]'s windows.
|
||||
Future<void> pumpProbe(
|
||||
WidgetTester tester,
|
||||
WindowManager manager, {
|
||||
int destination = 0,
|
||||
GlobalKey? boundary,
|
||||
}) async {
|
||||
tester.view.physicalSize = const Size(1280, 800);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
await tester.pumpWidget(
|
||||
ProbeApp(manager: manager, destination: destination, boundary: boundary),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
/// The window's card (title bar and body) in global coordinates.
|
||||
Rect windowRect(WidgetTester tester, String title) => tester.getRect(
|
||||
find.ancestor(of: find.text(title), matching: find.byType(WindowFrame)),
|
||||
);
|
||||
Reference in New Issue
Block a user