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 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)), );