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.
85 lines
2.7 KiB
Dart
85 lines
2.7 KiB
Dart
import 'package:cutdex_ui/widgets.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
const channel = MethodChannel('cutdex_native/context_menu');
|
|
setUp(() => debugDefaultTargetPlatformOverride = TargetPlatform.macOS);
|
|
tearDown(() {
|
|
debugDefaultTargetPlatformOverride = null;
|
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
|
.setMockMethodCallHandler(channel, null);
|
|
});
|
|
|
|
test(
|
|
'native entries preserve nested actions, disabled items and coordinates',
|
|
() async {
|
|
var invoked = false;
|
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
|
.setMockMethodCallHandler(channel, (call) async {
|
|
expect(call.method, 'show');
|
|
final args = call.arguments as Map;
|
|
expect(args['x'], 120.0);
|
|
expect(args['y'], 80.0);
|
|
final items = args['items'] as List;
|
|
expect(items[0]['enabled'], false);
|
|
expect(items[1]['separator'], true);
|
|
expect(items[2]['children'][0]['selected'], true);
|
|
return 1;
|
|
});
|
|
expect(
|
|
await showNativeContextMenu(
|
|
[
|
|
const AppMenuItem(label: 'Disabled'),
|
|
const AppMenuSeparator(),
|
|
AppSubmenu(
|
|
label: 'More',
|
|
items: [
|
|
AppMenuItem(
|
|
label: 'Selected',
|
|
selected: true,
|
|
onPressed: () => invoked = true,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
const Offset(120, 80),
|
|
() => true,
|
|
),
|
|
isTrue,
|
|
);
|
|
expect(invoked, isTrue);
|
|
},
|
|
);
|
|
|
|
test('dismissal and disposed owners do not invoke actions', () async {
|
|
var invoked = false;
|
|
final items = [
|
|
AppMenuItem(label: 'Action', onPressed: () => invoked = true),
|
|
];
|
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
|
.setMockMethodCallHandler(channel, (_) async => null);
|
|
expect(await showNativeContextMenu(items, Offset.zero, () => true), isTrue);
|
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
|
.setMockMethodCallHandler(channel, (_) async => 0);
|
|
expect(
|
|
await showNativeContextMenu(items, Offset.zero, () => false),
|
|
isTrue,
|
|
);
|
|
expect(invoked, isFalse);
|
|
});
|
|
|
|
test('missing native plugin falls back to Flutter', () async {
|
|
expect(
|
|
await showNativeContextMenu(
|
|
[const AppMenuItem(label: 'Action')],
|
|
Offset.zero,
|
|
() => true,
|
|
),
|
|
isFalse,
|
|
);
|
|
});
|
|
}
|