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.
This commit is contained in:
commit
27e77fff39
718 files changed
+183958
No files matched your search
@@ -0,0 +1,86 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:cutdex_native/cutdex_native.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('moving a cached layer updates native bounds', (tester) async {
|
||||
final offset = ValueNotifier(Offset.zero);
|
||||
addTearDown(offset.dispose);
|
||||
final reports = <Rect>[];
|
||||
final content = RepaintBoundary(
|
||||
child: NativeBoundsReporter(
|
||||
onBounds: reports.add,
|
||||
child: const SizedBox(width: 100, height: 40),
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: ValueListenableBuilder(
|
||||
valueListenable: offset,
|
||||
child: content,
|
||||
builder: (_, position, child) =>
|
||||
Transform.translate(offset: position, child: child),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(reports.last, const Rect.fromLTWH(0, 0, 100, 40));
|
||||
offset.value = const Offset(50, 25);
|
||||
await tester.pump();
|
||||
expect(reports.last, const Rect.fromLTWH(50, 25, 100, 40));
|
||||
final count = reports.length;
|
||||
await tester.pump();
|
||||
expect(reports, hasLength(count));
|
||||
expect(tester.binding.hasScheduledFrame, isFalse);
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
await tester.pump();
|
||||
expect(reports, hasLength(count));
|
||||
});
|
||||
|
||||
for (final rotated in [false, true]) {
|
||||
testWidgets('native bounds include ${rotated ? 'rotation' : 'scaling'}', (
|
||||
tester,
|
||||
) async {
|
||||
Rect? bounds;
|
||||
final reporter = NativeBoundsReporter(
|
||||
onBounds: (rect) => bounds = rect,
|
||||
child: const SizedBox(width: 100, height: 40),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 120, top: 100),
|
||||
child: rotated
|
||||
? Transform.rotate(
|
||||
angle: math.pi / 2,
|
||||
alignment: Alignment.topLeft,
|
||||
child: reporter,
|
||||
)
|
||||
: Transform.scale(
|
||||
scale: 2,
|
||||
alignment: Alignment.topLeft,
|
||||
child: reporter,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(bounds, isNotNull);
|
||||
final expected = rotated
|
||||
? const Rect.fromLTWH(80, 100, 40, 100)
|
||||
: const Rect.fromLTWH(120, 100, 200, 80);
|
||||
expect(bounds!.left, closeTo(expected.left, 1e-8));
|
||||
expect(bounds!.top, closeTo(expected.top, 1e-8));
|
||||
expect(bounds!.width, closeTo(expected.width, 1e-8));
|
||||
expect(bounds!.height, closeTo(expected.height, 1e-8));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import 'package:cutdex_native/cutdex_native.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
const channel = MethodChannel('cutdex_native/device_info');
|
||||
final messenger =
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;
|
||||
tearDown(() => messenger.setMockMethodCallHandler(channel, null));
|
||||
|
||||
test(
|
||||
'Android display facts accept integer and floating point values',
|
||||
() async {
|
||||
for (final value in [600, 599.5]) {
|
||||
messenger.setMockMethodCallHandler(channel, (call) async {
|
||||
expect(call.method, 'getDeviceInfo');
|
||||
return {'displayShortestSideDp': value};
|
||||
});
|
||||
final info = await NativeDeviceInfo.read();
|
||||
expect(info?.displayShortestSideDp, value.toDouble());
|
||||
expect(info?.interfaceIdiom, isNull);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
test('iOS idioms remain raw device facts', () async {
|
||||
for (final idiom in NativeInterfaceIdiom.values) {
|
||||
messenger.setMockMethodCallHandler(
|
||||
channel,
|
||||
(call) async => {'interfaceIdiom': idiom.name},
|
||||
);
|
||||
final info = await NativeDeviceInfo.read();
|
||||
expect(info?.interfaceIdiom, idiom);
|
||||
expect(info?.displayShortestSideDp, isNull);
|
||||
}
|
||||
});
|
||||
|
||||
test('invalid responses do not expose unusable device facts', () async {
|
||||
for (final value in <Object?>[
|
||||
null,
|
||||
'phone',
|
||||
<String, Object?>{},
|
||||
{'interfaceIdiom': 'unknown'},
|
||||
{'displayShortestSideDp': '600'},
|
||||
{'displayShortestSideDp': 0},
|
||||
{'displayShortestSideDp': -1},
|
||||
{'displayShortestSideDp': double.nan},
|
||||
{'displayShortestSideDp': double.infinity},
|
||||
]) {
|
||||
messenger.setMockMethodCallHandler(channel, (call) async => value);
|
||||
expect(await NativeDeviceInfo.read(), isNull, reason: '$value');
|
||||
}
|
||||
});
|
||||
|
||||
test('unregistered and unavailable native hosts return no facts', () async {
|
||||
expect(await NativeDeviceInfo.read(), isNull);
|
||||
messenger.setMockMethodCallHandler(channel, (call) async {
|
||||
throw PlatformException(code: 'unavailable');
|
||||
});
|
||||
expect(await NativeDeviceInfo.read(), isNull);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import 'package:cutdex_native/cutdex_native.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
test('invalid policies fail before reaching native registration', () {
|
||||
expect(
|
||||
() => NativeDropConfiguration(maximumFileCount: 0),
|
||||
throwsArgumentError,
|
||||
);
|
||||
expect(
|
||||
() => NativeDropConfiguration(allowedExtensions: ['']),
|
||||
throwsArgumentError,
|
||||
);
|
||||
});
|
||||
test('configuration owns an immutable extension whitelist', () {
|
||||
final extensions = ['wav'];
|
||||
final configuration = NativeDropConfiguration(
|
||||
allowedExtensions: extensions,
|
||||
);
|
||||
extensions[0] = 'mp4';
|
||||
expect(configuration.accepts(['/sample.wav']), true);
|
||||
expect(configuration.accepts(['/sample.mp4']), false);
|
||||
expect(
|
||||
() => configuration.allowedExtensions!.add('mp4'),
|
||||
throwsUnsupportedError,
|
||||
);
|
||||
});
|
||||
|
||||
test('equivalent whitelist sets share equality and hashing', () {
|
||||
final first = NativeDropConfiguration(
|
||||
allowedExtensions: ['WAV', 'mp4', 'wav'],
|
||||
maximumFileCount: 2,
|
||||
);
|
||||
final second = NativeDropConfiguration(
|
||||
allowedExtensions: ['mp4', 'wav'],
|
||||
maximumFileCount: 2,
|
||||
);
|
||||
expect(first, second);
|
||||
expect(first.hashCode, second.hashCode);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,340 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:cutdex_native/cutdex_native.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
const manager = MethodChannel('cutdex_native/file_drop');
|
||||
const destination = MethodChannel('cutdex_native/file_drop/test');
|
||||
final messenger =
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;
|
||||
final calls = <MethodCall>[];
|
||||
setUp(() {
|
||||
calls.clear();
|
||||
messenger.setMockMethodCallHandler(manager, (_) async => null);
|
||||
messenger.setMockMethodCallHandler(destination, (call) async {
|
||||
calls.add(call);
|
||||
return null;
|
||||
});
|
||||
});
|
||||
tearDown(() {
|
||||
messenger.setMockMethodCallHandler(manager, null);
|
||||
messenger.setMockMethodCallHandler(destination, null);
|
||||
});
|
||||
|
||||
Future<void> event(
|
||||
String phase,
|
||||
int session, {
|
||||
String channelName = 'cutdex_native/file_drop/test',
|
||||
}) async {
|
||||
await messenger.handlePlatformMessage(
|
||||
channelName,
|
||||
const StandardMethodCodec().encodeMethodCall(
|
||||
MethodCall('event', {
|
||||
'phase': phase,
|
||||
'session': session,
|
||||
'x': 12.0,
|
||||
'y': 8.0,
|
||||
'files': [
|
||||
{'path': '/example/input.wav'},
|
||||
],
|
||||
}),
|
||||
),
|
||||
(_) {},
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets(
|
||||
'inactive routes reject late drag events and release their grants',
|
||||
(tester) async {
|
||||
var entered = 0;
|
||||
var dropped = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: TickerMode(
|
||||
enabled: false,
|
||||
child: NativeFileDropRegion(
|
||||
regionId: 'test',
|
||||
enabled: true,
|
||||
onEnter: (_) => entered++,
|
||||
onExit: () {},
|
||||
onDrop: (_) async => dropped++,
|
||||
child: const SizedBox.expand(),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await event('enter', 7);
|
||||
await event('drop', 7);
|
||||
await tester.pump();
|
||||
expect(entered, 0);
|
||||
expect(dropped, 0);
|
||||
expect(calls.where((c) => c.method == 'release'), hasLength(1));
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
await tester.pumpAndSettle();
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'equivalent policies at fixed bounds do not rewrite native state',
|
||||
(tester) async {
|
||||
Widget target() => MaterialApp(
|
||||
home: NativeFileDropRegion(
|
||||
regionId: 'test',
|
||||
enabled: true,
|
||||
configuration: NativeDropConfiguration(
|
||||
allowedExtensions: ['wav'],
|
||||
maximumFileCount: 1,
|
||||
),
|
||||
onEnter: (_) {},
|
||||
onExit: () {},
|
||||
onDrop: (_) async {},
|
||||
child: const SizedBox.expand(),
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(target());
|
||||
await tester.pumpAndSettle();
|
||||
final reports = calls.where((c) => c.method == 'setRegion').length;
|
||||
await tester.pumpWidget(target());
|
||||
await tester.pumpAndSettle();
|
||||
expect(calls.where((c) => c.method == 'setRegion'), hasLength(reports));
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
await tester.pumpAndSettle();
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('a completed drop cannot erase the next drag session', (
|
||||
tester,
|
||||
) async {
|
||||
final pending = Completer<void>();
|
||||
var dropped = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: NativeFileDropRegion(
|
||||
regionId: 'test',
|
||||
enabled: true,
|
||||
onEnter: (_) {},
|
||||
onExit: () {},
|
||||
onDrop: (_) async {
|
||||
if (++dropped == 1) await pending.future;
|
||||
},
|
||||
child: const SizedBox.expand(),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await event('enter', 7);
|
||||
unawaited(event('drop', 7));
|
||||
await tester.pump();
|
||||
await event('enter', 8);
|
||||
pending.complete();
|
||||
await tester.pump();
|
||||
await event('drop', 8);
|
||||
await tester.pump();
|
||||
expect(dropped, 2);
|
||||
expect(
|
||||
calls
|
||||
.where((c) => c.method == 'release')
|
||||
.map((c) => (c.arguments as Map)['session']),
|
||||
[7, 8],
|
||||
);
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
await tester.pumpAndSettle();
|
||||
});
|
||||
|
||||
testWidgets('a disposed connection cannot steal a replacement binding', (
|
||||
tester,
|
||||
) async {
|
||||
final first = NativeFileDropConnection(
|
||||
regionId: 'test',
|
||||
onEvent: (_) async {},
|
||||
);
|
||||
final events = <NativeFileDropEvent>[];
|
||||
final second = NativeFileDropConnection(
|
||||
regionId: 'test',
|
||||
onEvent: (e) async => events.add(e),
|
||||
);
|
||||
first.bind();
|
||||
first.dispose();
|
||||
await tester.pump();
|
||||
second.bind();
|
||||
expect(first.bind, throwsStateError);
|
||||
await event('move', 8);
|
||||
expect(events, hasLength(1));
|
||||
second.dispose();
|
||||
await tester.pump();
|
||||
});
|
||||
|
||||
testWidgets('a stale connection cannot change native destination options', (
|
||||
tester,
|
||||
) async {
|
||||
final registrations = <MethodCall>[];
|
||||
messenger.setMockMethodCallHandler(manager, (call) async {
|
||||
registrations.add(call);
|
||||
return null;
|
||||
});
|
||||
final first = NativeFileDropConnection(
|
||||
regionId: 'test',
|
||||
hidesSourceImage: true,
|
||||
onEvent: (_) async {},
|
||||
);
|
||||
final second = NativeFileDropConnection(
|
||||
regionId: 'test',
|
||||
onEvent: (_) async {},
|
||||
);
|
||||
first.bind();
|
||||
second.bind();
|
||||
await second.setRegion(
|
||||
const Rect.fromLTWH(0, 0, 200, 100),
|
||||
NativeDropConfiguration.unrestricted,
|
||||
);
|
||||
await first.setRegion(
|
||||
const Rect.fromLTWH(0, 0, 100, 100),
|
||||
NativeDropConfiguration.unrestricted,
|
||||
);
|
||||
first.dispose();
|
||||
expect(registrations, hasLength(1));
|
||||
expect((registrations.single.arguments as Map)['hidesSourceImage'], false);
|
||||
second.dispose();
|
||||
await tester.pump();
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'security grant survives disposal until the drop callback finishes',
|
||||
(tester) async {
|
||||
final pending = Completer<void>();
|
||||
var dropped = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: NativeFileDropRegion(
|
||||
regionId: 'test',
|
||||
enabled: true,
|
||||
onEnter: (_) {},
|
||||
onExit: () {},
|
||||
onDrop: (paths) async {
|
||||
expect(paths, ['/example/input.wav']);
|
||||
dropped++;
|
||||
await pending.future;
|
||||
},
|
||||
child: const SizedBox.expand(),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await event('enter', 7);
|
||||
unawaited(event('drop', 7));
|
||||
await tester.pump();
|
||||
expect(dropped, 1);
|
||||
expect(calls.where((call) => call.method == 'release'), isEmpty);
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
await tester.pumpAndSettle();
|
||||
expect(calls.where((call) => call.method == 'release'), isEmpty);
|
||||
pending.complete();
|
||||
await tester.pump();
|
||||
expect(calls.where((call) => call.method == 'release'), hasLength(1));
|
||||
expect((calls.last.arguments as Map)['session'], 7);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('late registration cannot clear a replacement destination', (
|
||||
tester,
|
||||
) async {
|
||||
final registrations = <Completer<void>>[];
|
||||
messenger.setMockMethodCallHandler(manager, (call) async {
|
||||
expect((call.arguments as Map)['id'], 'test');
|
||||
final pending = Completer<void>();
|
||||
registrations.add(pending);
|
||||
await pending.future;
|
||||
return null;
|
||||
});
|
||||
final first = NativeFileDropConnection(
|
||||
regionId: 'test',
|
||||
onEvent: (_) async {},
|
||||
);
|
||||
final events = <NativeFileDropEvent>[];
|
||||
final second = NativeFileDropConnection(
|
||||
regionId: 'test',
|
||||
onEvent: (event) async => events.add(event),
|
||||
);
|
||||
first.bind();
|
||||
final oldReport = first.setRegion(
|
||||
const Rect.fromLTWH(0, 0, 100, 100),
|
||||
NativeDropConfiguration.unrestricted,
|
||||
);
|
||||
await tester.pump();
|
||||
second.bind();
|
||||
first.dispose();
|
||||
final newReport = second.setRegion(
|
||||
const Rect.fromLTWH(0, 0, 200, 100),
|
||||
NativeDropConfiguration.unrestricted,
|
||||
);
|
||||
await tester.pump();
|
||||
for (final pending in registrations) {
|
||||
pending.complete();
|
||||
}
|
||||
await tester.pump();
|
||||
await Future.wait([oldReport, newReport]);
|
||||
expect(calls.where((call) => call.method == 'setRegion'), hasLength(1));
|
||||
expect((calls.single.arguments as Map)['width'], 200.0);
|
||||
await event('move', 8);
|
||||
expect(events.single.position, const Offset(12, 8));
|
||||
expect(events.single.phase, NativeFileDropPhase.move);
|
||||
messenger.setMockMethodCallHandler(manager, (_) async => null);
|
||||
second.dispose();
|
||||
await tester.pump();
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'changing destinations preserves a pending drop on its original channel',
|
||||
(tester) async {
|
||||
const other = MethodChannel('cutdex_native/file_drop/other');
|
||||
final otherCalls = <MethodCall>[];
|
||||
messenger.setMockMethodCallHandler(other, (call) async {
|
||||
otherCalls.add(call);
|
||||
return null;
|
||||
});
|
||||
addTearDown(() => messenger.setMockMethodCallHandler(other, null));
|
||||
final pending = Completer<void>();
|
||||
Widget target(String id) => MaterialApp(
|
||||
home: NativeFileDropRegion(
|
||||
regionId: id,
|
||||
enabled: true,
|
||||
onEnter: (_) {},
|
||||
onExit: () {},
|
||||
onDrop: (_) async {
|
||||
if (id == 'test') await pending.future;
|
||||
},
|
||||
child: const SizedBox.expand(),
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(target('test'));
|
||||
await tester.pumpAndSettle();
|
||||
await event('enter', 7);
|
||||
unawaited(event('drop', 7));
|
||||
await tester.pump();
|
||||
await tester.pumpWidget(target('other'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(calls.where((call) => call.method == 'release'), isEmpty);
|
||||
await event('enter', 8, channelName: other.name);
|
||||
await event('drop', 8, channelName: other.name);
|
||||
await tester.pump();
|
||||
expect(
|
||||
otherCalls.where((call) => call.method == 'release'),
|
||||
hasLength(1),
|
||||
);
|
||||
pending.complete();
|
||||
await tester.pump();
|
||||
expect((calls.last.arguments as Map)['session'], 7);
|
||||
expect(
|
||||
otherCalls.where((call) => call.method == 'release'),
|
||||
hasLength(1),
|
||||
);
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
await tester.pumpAndSettle();
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:cutdex_native/cutdex_native.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
const channel = MethodChannel('cutdex_native/fullscreen');
|
||||
final messenger =
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;
|
||||
final requests = <bool>[];
|
||||
setUp(() {
|
||||
requests.clear();
|
||||
messenger.setMockMethodCallHandler(channel, (call) async {
|
||||
requests.add(call.arguments as bool);
|
||||
return null;
|
||||
});
|
||||
});
|
||||
tearDown(() => messenger.setMockMethodCallHandler(channel, null));
|
||||
|
||||
testWidgets('a disposed session cannot reclaim the window', (tester) async {
|
||||
final first = NativeFullscreenSession(onExit: () {});
|
||||
var exits = 0;
|
||||
final second = NativeFullscreenSession(onExit: () => exits++);
|
||||
first.attach();
|
||||
first.dispose();
|
||||
second.attach();
|
||||
expect(first.attach, throwsStateError);
|
||||
await first.setFullscreen(false);
|
||||
await messenger.handlePlatformMessage(
|
||||
channel.name,
|
||||
const StandardMethodCodec().encodeMethodCall(const MethodCall('exited')),
|
||||
(_) {},
|
||||
);
|
||||
expect(exits, 1);
|
||||
expect(requests, isEmpty);
|
||||
second.dispose();
|
||||
});
|
||||
|
||||
testWidgets('a replacement takes ownership while an entry is pending', (
|
||||
tester,
|
||||
) async {
|
||||
final entered = Completer<void>();
|
||||
messenger.setMockMethodCallHandler(channel, (call) async {
|
||||
requests.add(call.arguments as bool);
|
||||
if (requests.length == 1) await entered.future;
|
||||
return null;
|
||||
});
|
||||
final first = NativeFullscreenSession(onExit: () {});
|
||||
final second = NativeFullscreenSession(onExit: () {});
|
||||
first.attach();
|
||||
final entering = first.setFullscreen(true);
|
||||
await tester.pump();
|
||||
second.attach();
|
||||
final replacement = second.setFullscreen(true);
|
||||
first.dispose(exitFullscreen: true);
|
||||
await tester.pump();
|
||||
expect(requests, [true]);
|
||||
entered.complete();
|
||||
await tester.pump();
|
||||
await Future.wait([entering, replacement]);
|
||||
expect(requests, [true, true]);
|
||||
second.dispose(exitFullscreen: true);
|
||||
await tester.pump();
|
||||
expect(requests, [true, true, false]);
|
||||
});
|
||||
|
||||
testWidgets('a failed transition does not block the next request', (
|
||||
tester,
|
||||
) async {
|
||||
messenger.setMockMethodCallHandler(channel, (call) async {
|
||||
requests.add(call.arguments as bool);
|
||||
if (call.arguments == true) throw PlatformException(code: 'failed');
|
||||
return null;
|
||||
});
|
||||
final session = NativeFullscreenSession(onExit: () {});
|
||||
session.attach();
|
||||
await expectLater(
|
||||
session.setFullscreen(true),
|
||||
throwsA(isA<PlatformException>()),
|
||||
);
|
||||
await session.setFullscreen(false);
|
||||
expect(requests, [true, false]);
|
||||
session.dispose();
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import 'package:cutdex_native/cutdex_native.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'inactive routes unregister header hit regions and restore them on return',
|
||||
(tester) async {
|
||||
const channel = MethodChannel('cutdex_native/window_controls');
|
||||
final calls = <MethodCall>[];
|
||||
final messenger = tester.binding.defaultBinaryMessenger;
|
||||
messenger.setMockMethodCallHandler(channel, (call) async {
|
||||
calls.add(call);
|
||||
return null;
|
||||
});
|
||||
addTearDown(() => messenger.setMockMethodCallHandler(channel, null));
|
||||
Widget target(bool enabled) => MaterialApp(
|
||||
home: TickerMode(
|
||||
enabled: enabled,
|
||||
child: const HeaderControlRegion(
|
||||
child: SizedBox(width: 100, height: 40),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(target(true));
|
||||
await tester.pumpAndSettle();
|
||||
expect((calls.last.arguments as Map)['rect'], isNotNull);
|
||||
final id = (calls.last.arguments as Map)['id'];
|
||||
await tester.pumpWidget(target(false));
|
||||
await tester.pumpAndSettle();
|
||||
expect((calls.last.arguments as Map)['id'], id);
|
||||
expect((calls.last.arguments as Map)['rect'], isNull);
|
||||
await tester.pumpWidget(target(true));
|
||||
await tester.pumpAndSettle();
|
||||
expect((calls.last.arguments as Map)['rect'], isNotNull);
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
await tester.pumpAndSettle();
|
||||
expect((calls.last.arguments as Map)['rect'], isNull);
|
||||
},
|
||||
variant: TargetPlatformVariant.only(TargetPlatform.macOS),
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user