Files
cutdex/packages/cutdex_ui/test/app_item_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

108 lines
3.2 KiB
Dart

import 'package:cutdex_ui/theme.dart';
import 'package:cutdex_ui/widgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('property list rows use the project item gap without a line', (
tester,
) async {
await tester.pumpWidget(
MaterialApp(
theme: AppTheme.penDark,
home: Theme(
data: AppTheme.propertiesPanelTheme(AppTheme.penDark),
child: Scaffold(
body: AppItemGroup(
children: [
AppItem(
key: const Key('first-mask'),
leading: IconButton(
key: const Key('mask-visibility'),
icon: const Icon(Icons.visibility_outlined),
onPressed: () {},
),
actions: [
IconButton(
key: const Key('mask-delete'),
icon: const Icon(Icons.delete_outline),
onPressed: () {},
),
],
child: const Text('蒙版 1'),
),
const AppItem(key: Key('second-mask'), child: Text('蒙版 2')),
],
),
),
),
),
);
expect(
tester.getSize(find.byKey(const Key('first-mask'))).height,
AppControlSize.propertyItem,
);
expect(
tester.getSize(find.byKey(const Key('second-mask'))).height,
AppControlSize.propertyItem,
);
expect(
tester.getSize(find.byKey(const Key('mask-visibility'))).height,
AppControlSize.propertyControl,
);
expect(
tester.getRect(find.byKey(const Key('second-mask'))).top -
tester.getRect(find.byKey(const Key('first-mask'))).bottom,
AppSidebarMetrics.projectGap,
);
expect(find.byType(Divider), findsNothing);
});
testWidgets('property list hover and selection use translucent ink', (
tester,
) async {
for (final theme in [AppTheme.penLight, AppTheme.penDark]) {
Future<void> mount({required bool selected}) => tester.pumpWidget(
MaterialApp(
theme: theme,
home: Theme(
data: AppTheme.propertiesPanelTheme(theme),
child: Scaffold(
body: AppItem(
selected: selected,
onPressed: () {},
child: const Text('蒙版 1'),
),
),
),
),
);
Finder row<T extends Widget>() =>
find.descendant(of: find.byType(AppItem), matching: find.byType(T));
final ink = theme.colorScheme.onSurface;
await mount(selected: false);
expect(
tester.widget<Material>(row<Material>()).color,
Colors.transparent,
);
expect(
tester.widget<InkWell>(row<InkWell>()).hoverColor,
ink.withValues(
alpha: theme.brightness == Brightness.dark ? .078 : .058,
),
);
await mount(selected: true);
expect(
tester.widget<Material>(row<Material>()).color,
ink.withValues(alpha: .05),
);
expect(
tester.widget<InkWell>(row<InkWell>()).hoverColor,
ink.withValues(alpha: .05),
);
}
});
}