import 'dart:io'; import 'package:cutdex_native/cutdex_native.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); testWidgets( 'desktop host registers native window and dynamic file destinations', (tester) async { // This harness has no project state to save when the native host quits. const lifecycle = MethodChannel('cutdex/lifecycle'); lifecycle.setMethodCallHandler( (call) async => call.method == 'prepareToQuit', ); await lifecycle.invokeMethod('ready'); await tester.pumpWidget( const MaterialApp(home: Scaffold(body: SizedBox.expand())), ); final chrome = WindowChromeSession(headerHeight: 40); chrome.attach(); addTearDown(chrome.dispose); for (var attempt = 0; attempt < 20 && !chrome.integrated; attempt++) { await tester.pump(const Duration(milliseconds: 50)); } expect( chrome.integrated, isTrue, reason: 'The real native host must register window chrome.', ); final drop = NativeFileDropConnection( regionId: 'integration-host', onEvent: (_) async {}, ); drop.bind(); addTearDown(drop.dispose); await drop.setRegion( const Rect.fromLTWH(0, 80, 100, 100), NativeDropConfiguration( allowedExtensions: ['wav'], maximumFileCount: 1, ), ); // No mock handler: this must reach a destination created by the real plugin. await drop.release(0); await drop.setRegion(null, NativeDropConfiguration.unrestricted); if (Platform.isMacOS) { var exits = 0; final fullscreen = NativeFullscreenSession(onExit: () => exits++); fullscreen.attach(); await fullscreen.setFullscreen(true); await fullscreen.setFullscreen(false); await tester.pump(); expect(exits, 1); fullscreen.dispose(); } }, skip: !(Platform.isMacOS || Platform.isWindows), ); }