Merge branch 'main' into pipelines/run-20261111-0323-cupertino-out-shell-eacf

# Conflicts:
#	app/test/application/search_artifact_open_test.dart
#	app/test/application/search_chat_open_test.dart
This commit is contained in:
2026-11-11 03:54:36 +00:00
36 changed files with 1107 additions and 1789 deletions
+112 -3
View File
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/windows/window_entry.dart';
import 'package:pipelines_app/shell/windows/window_frame.dart';
import 'package:pipelines_app/shell/windows/window_kind.dart';
import 'package:pipelines_app/shell/windows/window_layer.dart';
import 'package:pipelines_app/shell/windows/window_manager.dart';
@@ -36,6 +37,23 @@ void main() {
ProbeContentState content(WidgetTester tester, String id) =>
tester.state<ProbeContentState>(find.byKey(ValueKey('content-$id')));
Size windowSize(WidgetTester tester, String title) => tester.getSize(
find.ancestor(of: find.text(title), matching: find.byType(WindowFrame)),
);
/// The elements inside the probe windows that depend on the window's size:
/// its buttons and the scroll view around them.
Set<Element> contentElements() => {
for (final id in const ['a', 'b'])
for (final type in const [TextButton, ListView, Scrollable])
...find
.descendant(
of: find.byKey(ValueKey('content-$id')),
matching: find.byType(type),
)
.evaluate(),
};
Future<void> openTwo(WidgetTester tester) async {
manager.open('probe', 'a', frame: const Rect.fromLTWH(100, 80, 360, 420));
manager.open('probe', 'b', frame: const Rect.fromLTWH(600, 200, 360, 420));
@@ -77,6 +95,99 @@ void main() {
expect(content(tester, 'b').builds, beforeB);
});
testWidgets('a fractional title drag keeps the window size exactly and does '
'not rebuild content', (tester) async {
await openTwo(tester);
final start = windowRect(tester, 'Probe a').topLeft;
final startSize = windowSize(tester, 'Probe a');
final watched = contentElements();
expect(watched, isNotEmpty);
final rebuilt = <Element>{};
final gesture = await tester.startGesture(
tester.getCenter(
inWindow('Probe a', find.byKey(const ValueKey('window-title'))),
),
);
// The press raises and focuses the window before the drag starts; only
// the drag's own rebuilds are watched.
await tester.pump();
debugOnRebuildDirtyWidget = (element, builtOnce) {
if (watched.contains(element)) rebuilt.add(element);
};
try {
final a = content(tester, 'a');
final b = content(tester, 'b');
final beforeA = a.builds;
final beforeB = b.builds;
for (var i = 0; i < 8; i++) {
await gesture.moveBy(const Offset(10.3, 4.7));
await tester.pump();
expect(
rebuilt.map((e) => e.widget.runtimeType).toSet(),
isEmpty,
reason: 'window content rebuilt at move $i',
);
expect(
windowSize(tester, 'Probe a'),
startSize,
reason: 'window size changed at move $i',
);
}
await gesture.up();
await tester.pumpAndSettle();
expect(rebuilt, isEmpty);
expect(a.builds, beforeA);
expect(b.builds, beforeB);
// Eight fractional moves, rounded to whole pixels, without drift.
final moved = windowRect(tester, 'Probe a').topLeft - start;
expect(moved.dx, closeTo(8 * 10.3, 1));
expect(moved.dy, closeTo(8 * 4.7, 1));
} finally {
debugOnRebuildDirtyWidget = null;
}
});
testWidgets('resizing by fractional deltas gives whole-pixel sizes', (
tester,
) async {
await openTwo(tester);
final a = content(tester, 'a');
final b = content(tester, 'b');
final beforeA = a.builds;
final beforeB = b.builds;
final startSize = windowSize(tester, 'Probe b');
final startBody = b.lastSize!;
final titleHeight = startSize.height - startBody.height;
final gesture = await tester.startGesture(
tester.getCenter(
inWindow('Probe b', find.byKey(const ValueKey('window-resize'))),
),
);
for (var i = 0; i < 5; i++) {
await gesture.moveBy(const Offset(-10.3, -6.7));
await tester.pump();
final size = windowSize(tester, 'Probe b');
expect(size.width, size.width.roundToDouble(), reason: 'move $i width');
expect(
size.height,
size.height.roundToDouble(),
reason: 'move $i height',
);
expect(a.builds, beforeA, reason: 'other window rebuilt at move $i');
}
await gesture.up();
await tester.pumpAndSettle();
expect(content(tester, 'a').builds, beforeA);
final state = content(tester, 'b');
expect(state.builds, greaterThan(beforeB));
final size = windowSize(tester, 'Probe b');
expect(size.width, closeTo(startSize.width - 5 * 10.3, 1));
expect(size.height, closeTo(startSize.height - 5 * 6.7, 1));
// The content saw the new, whole-pixel size.
expect(state.lastSize!.width, size.width);
expect(state.lastSize!.height, size.height - titleHeight);
});
testWidgets('resizing a window keeps another window and sees the new size', (
tester,
) async {
@@ -108,9 +219,7 @@ void main() {
testWidgets('content still rebuilds when its window is retargeted', (
tester,
) async {
manager = WindowManager(
kinds: WindowKinds()..register(_StableProbeKind()),
);
manager = WindowManager(kinds: WindowKinds()..register(_StableProbeKind()));
final entry = manager.open('stable', 'a');
await pumpProbe(tester, manager);
final state = tester.state<ProbeContentState>(
@@ -162,6 +162,24 @@ void main() {
),
const Rect.fromLTWH(0, 0, 300, 200),
);
// A fractional minimum is never rounded below itself: the whole-pixel
// frame rounds up, and when the bounds cannot hold it the bounds win.
expect(
fitWindowFrame(
const Rect.fromLTWH(0, 0, 320.1, 240.4),
const Size(1000, 800),
const Size(320.1, 240.4),
),
const Rect.fromLTWH(0, 0, 321, 241),
);
expect(
fitWindowFrame(
const Rect.fromLTWH(0, 0, 320.1, 240.4),
const Size(319.6, 239.2),
const Size(320.1, 240.4),
),
const Rect.fromLTWH(0, 0, 319, 239),
);
const entry = WindowEntry(
id: 'w',
kind: 'chat',