Files
cutdex/integration_test/native_desktop_plugins_test.dart
lingjhf 27e77fff39 feat: initial Cutdex application
Add the Flutter video editing application with project management, media
import, timeline editing, preview, AI assistance, diagnostics and settings.

Include shared UI and native host packages, platform runners, application
tests and release tooling.

Provide usage and contribution guides, the MIT license and third-party
notices. Exclude local credentials, build outputs and validation data.
2026-10-05 23:36:23 +08:00

68 lines
2.2 KiB
Dart

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<void>('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),
);
}