import 'package:cutdex/app/shells/desktop_window_frame.dart'; import 'package:cutdex/features/projects/project_tabs_bar.dart'; import 'package:cutdex/integrations/platform/editor_window_chrome.dart'; import 'package:cutdex/l10n/app_localizations.dart'; import 'package:cutdex/workspace/project_state.dart'; import 'package:cutdex_native/cutdex_native.dart'; import 'package:cutdex_ui/theme.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets( 'header separates native buttons from project entry and uses equal margins', (tester) async { const width = 720.0; const captionWidth = 132.0; for (final platform in [TargetPlatform.macOS, TargetPlatform.windows]) { for (final integrated in [false, true]) { debugDefaultTargetPlatformOverride = platform; final caption = integrated && platform == TargetPlatform.windows; await tester.pumpWidget( MaterialApp( theme: AppTheme.desktopWorkspaceTheme(AppTheme.penDark), localizationsDelegates: AppLocalizations.localizationsDelegates, supportedLocales: AppLocalizations.supportedLocales, home: Scaffold( body: Align( alignment: Alignment.topLeft, child: SizedBox( width: width, height: 120, child: WindowHeaderLayout( captionBounds: caption ? const Rect.fromLTWH( width - captionWidth, 0, captionWidth, 44, ) : Rect.zero, child: DesktopWindowFrame( integratedTitlebar: integrated, headerControls: const SizedBox.shrink(), projectTabs: ProjectTabsBar( projects: const [ RecentProject(id: 'one', name: 'One', path: '/one'), ], recent: const [], selectedId: 'one', leadingActions: [ IconButton( key: const Key('header-sidebar-action'), onPressed: () {}, icon: const Icon(Icons.menu, size: 16), ), ], trailingActions: [ IconButton( key: const Key('header-task-action'), onPressed: () {}, icon: const Icon(Icons.task_alt, size: 16), ), ], onSelect: (_) {}, onClose: (_) {}, onCreate: () {}, onOpen: () {}, onRename: (_) {}, ), onHomePressed: () {}, onSettingsPressed: () {}, child: const SizedBox.shrink(), ), ), ), ), ), ), ); await tester.pumpAndSettle(); final entry = tester.getRect( find.byKey(const Key('project-tabs-projects')), ); final sidebar = tester.getRect( find.byKey(const Key('header-sidebar-action')), ); final list = tester.getRect( find.byKey(const Key('project-tabs-list')), ); final task = tester.getRect( find.byKey(const Key('header-task-action')), ); final start = integrated ? EditorWindowChrome.leadingWidth : 0.0; final end = caption ? width - captionWidth : width; final macButtons = integrated && platform == TargetPlatform.macOS; expect( sidebar.left - start, 12, reason: '$platform integrated=$integrated left', ); expect( end - task.right, 12, reason: '$platform integrated=$integrated right', ); if (macButtons) { expect(sidebar.left, 80); // The last native button is centered at 59 with a 14px frame. expect(sidebar.left - (59 + 14 / 2), 14); } expect(entry.center.dy, 22); expect(sidebar.center.dy, 22); expect(entry.left - sidebar.right, AppProjectTabMetrics.gap); expect(list.center.dy, 22); expect(task.center.dy, 22); expect(task.left - list.right, AppProjectTabMetrics.gap); expect(task.size, const Size.square(AppProjectTabMetrics.height)); expect(tester.takeException(), isNull); } } debugDefaultTargetPlatformOverride = null; }, ); }