Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Fix lint errors in video editor integration test and video widget

Prateek Sunal8ca3b0d3c253
diff --git a/mobile/apps/photos/integration_test/video_editor_test.dart b/mobile/apps/photos/integration_test/video_editor_test.dart
index 4ae30863e2..3c9bf4e466 100644
--- a/mobile/apps/photos/integration_test/video_editor_test.dart
+++ b/mobile/apps/photos/integration_test/video_editor_test.dart
@@ -1,11 +1,13 @@
import 'dart:io';
+
import 'package:flutter_test/flutter_test.dart';
+import 'package:fluttertoast/fluttertoast.dart';
import 'package:integration_test/integration_test.dart';
import 'package:logging/logging.dart';
import 'package:native_video_editor/native_video_editor.dart';
+import 'package:package_info_plus/package_info_plus.dart';
import 'package:path/path.dart' as path_helper;
import 'package:photo_manager/photo_manager.dart';
-import 'package:package_info_plus/package_info_plus.dart';
import 'package:photos/core/configuration.dart';
import 'package:photos/core/network/network.dart';
import 'package:photos/db/files_db.dart';
@@ -19,7 +21,6 @@ import 'package:photos/ui/tools/editor/video_editor/crop_value.dart';
import 'package:photos/utils/file_util.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:video_editor/video_editor.dart';
-import 'package:fluttertoast/fluttertoast.dart';
/// Trim configuration
class TrimConfig {
@@ -27,8 +28,11 @@ class TrimConfig {
final Duration? duration;
final Duration startOffset;
- const TrimConfig(
- {required this.label, this.duration, this.startOffset = Duration.zero});
+ const TrimConfig({
+ required this.label,
+ this.duration,
+ this.startOffset = Duration.zero,
+ });
bool get shouldTrim => duration != null;
@@ -60,8 +64,10 @@ class TrimConfigs {
}
/// Create a trim config from start offset and length
- static TrimConfig fromRange(
- {required int startSeconds, required int lengthSeconds}) {
+ static TrimConfig fromRange({
+ required int startSeconds,
+ required int lengthSeconds,
+ }) {
return TrimConfig(
label: "trim-${startSeconds}s-${startSeconds + lengthSeconds}s",
duration: Duration(seconds: lengthSeconds),
@@ -249,7 +255,8 @@ void main() {
testFiles.fold(0, (sum, config) => sum + config.totalIterations);
logger.info('═══════════════════════════════════════════════════════');
logger.info(
- 'Starting test with $totalFiles file(s), ${testFiles.length} configuration(s)');
+ 'Starting test with $totalFiles file(s), ${testFiles.length} configuration(s)',
+ );
logger.info('Total iterations: $totalIterations');
logger.info('═══════════════════════════════════════════════════════\n');
@@ -263,7 +270,8 @@ void main() {
final config = testFiles[configIndex];
logger.info(
- '\n╔═══════════════════════════════════════════════════════╗');
+ '\n╔═══════════════════════════════════════════════════════╗',
+ );
logger.info('β•‘ CONFIG ${configIndex + 1}/${testFiles.length}');
logger.info('β•‘ Files: ${config.fileIds}');
logger.info('β•‘ Iterations per file: ${config.totalIterationsPerFile}');
@@ -271,7 +279,8 @@ void main() {
logger.info('β•‘ Crop: ${config.cropOptions}');
logger.info('β•‘ Rotate: ${config.rotateOptions}');
logger.info(
- 'β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•\n');
+ 'β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•\n',
+ );
// Process each file in this configuration
for (int fileIndex = 0;
@@ -281,7 +290,8 @@ void main() {
logger.info('─────────────────────────────────────────────────────');
logger.info(
- 'File ${fileIndex + 1}/${config.fileIds.length} in config ${configIndex + 1}: ID $fileId');
+ 'File ${fileIndex + 1}/${config.fileIds.length} in config ${configIndex + 1}: ID $fileId',
+ );
logger.info('─────────────────────────────────────────────────────');
// Load source file
@@ -385,7 +395,8 @@ void main() {
}
logger.info(
- 'File $fileId completed: $fileIterationCount/${config.totalIterationsPerFile} iterations\n');
+ 'File $fileId completed: $fileIterationCount/${config.totalIterationsPerFile} iterations\n',
+ );
}
logger.info('═══════════════════════════════════════════════════════');
@@ -408,10 +419,12 @@ void main() {
if (failedExports.isNotEmpty) {
logger.severe(
- '\n╔═══════════════════════════════════════════════════════╗');
+ '\n╔═══════════════════════════════════════════════════════╗',
+ );
logger.severe('β•‘ EXPORT FAILURES (${failedExports.length})');
logger.severe(
- 'β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•');
+ 'β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•',
+ );
failedExports.forEach((desc, error) {
logger.severe(' βœ— $desc');
logger.severe(' Error: $error\n');
@@ -420,10 +433,12 @@ void main() {
if (validationFailures.isNotEmpty) {
logger.warning(
- '\n╔═══════════════════════════════════════════════════════╗');
+ '\n╔═══════════════════════════════════════════════════════╗',
+ );
logger.warning('β•‘ VALIDATION FAILURES (${validationFailures.length})');
logger.warning(
- 'β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•');
+ 'β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•',
+ );
// Group by failure type
final groupedFailures = <String, List<ValidationFailure>>{};
@@ -435,10 +450,12 @@ void main() {
groupedFailures.forEach((type, failures) {
logger.warning(
- '\n ${type.toUpperCase()} (${failures.length} failures):');
+ '\n ${type.toUpperCase()} (${failures.length} failures):',
+ );
for (final failure in failures) {
logger.warning(
- ' βœ— File ${failure.fileId}: ${failure.description}');
+ ' βœ— File ${failure.fileId}: ${failure.description}',
+ );
logger.warning(' Expected: ${failure.expected}');
logger.warning(' Actual: ${failure.actual}');
}
@@ -483,7 +500,8 @@ Future<IterationResult> _processVideoIteration({
controller = VideoEditorController.file(
sourceIoFile,
minDuration: const Duration(
- milliseconds: 100), // Allow very short videos for testing
+ milliseconds: 100,
+ ), // Allow very short videos for testing
);
await controller.initialize();
@@ -493,7 +511,8 @@ Future<IterationResult> _processVideoIteration({
logger
.info(' - Original duration: ${originalDuration.inMilliseconds}ms');
logger.info(
- ' - Original size: ${originalSize.width.toInt()}x${originalSize.height.toInt()}');
+ ' - Original size: ${originalSize.width.toInt()}x${originalSize.height.toInt()}',
+ );
// Track expected dimensions (will be updated after crop)
var expectedWidth = originalSize.width.toInt();
@@ -562,10 +581,7 @@ Future<IterationResult> _processVideoIteration({
if (cropValue != null) {
final aspectRatio = cropValue.getFraction()?.toDouble();
if (aspectRatio != null) {
- _applyAspectCropToController(
- controller: controller,
- aspectRatio: aspectRatio,
- );
+ controller.preferredCropAspectRatio = aspectRatio;
} else {
controller.applyCacheCrop();
}
@@ -579,7 +595,8 @@ Future<IterationResult> _processVideoIteration({
expectedWidth = cropCalc.width;
expectedHeight = cropCalc.height;
logger.info(
- ' β†’ Crop applied: $cropOption (${expectedWidth}x$expectedHeight)');
+ ' β†’ Crop applied: $cropOption (${expectedWidth}x$expectedHeight)',
+ );
} catch (e) {
logger.warning(' - Failed to calculate crop dimensions: $e');
logger.info(' β†’ Crop applied: $cropOption');
@@ -641,7 +658,10 @@ Future<IterationResult> _processVideoIteration({
},
onError: (e, s) {
logger.severe(
- ' βœ— Native export failed - NO FFmpeg fallback in test!', e, s);
+ ' βœ— Native export failed - NO FFmpeg fallback in test!',
+ e,
+ s,
+ );
},
);
@@ -699,7 +719,7 @@ Future<IterationResult> _processVideoIteration({
rotateOption: rotateOption,
);
if (settingsToast != null) {
- Fluttertoast.showToast(
+ await Fluttertoast.showToast(
msg: settingsToast,
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.TOP,
@@ -712,7 +732,8 @@ Future<IterationResult> _processVideoIteration({
final videoInfo =
await NativeVideoEditor.getVideoInfo(exportedFile.path);
final actualDuration = Duration(
- milliseconds: (videoInfo['duration'] as num?)?.toInt() ?? 0);
+ milliseconds: (videoInfo['duration'] as num?)?.toInt() ?? 0,
+ );
final actualWidth = (videoInfo['width'] as num?)?.toInt() ?? 0;
final actualHeight = (videoInfo['height'] as num?)?.toInt() ?? 0;
@@ -736,7 +757,8 @@ Future<IterationResult> _processVideoIteration({
),
);
logger.warning(
- ' ⚠ Duration mismatch! Expected: ${expectedDuration.inMilliseconds}ms, Got: ${actualDuration.inMilliseconds}ms');
+ ' ⚠ Duration mismatch! Expected: ${expectedDuration.inMilliseconds}ms, Got: ${actualDuration.inMilliseconds}ms',
+ );
}
// Validate dimensions (accounting for crop and rotation)
@@ -786,7 +808,8 @@ Future<IterationResult> _processVideoIteration({
),
);
logger.warning(
- ' ⚠ Width mismatch! Expected: $finalExpectedWidth, Got: $actualWidth');
+ ' ⚠ Width mismatch! Expected: $finalExpectedWidth, Got: $actualWidth',
+ );
}
// Check height (allow some tolerance for encoding)
@@ -801,7 +824,8 @@ Future<IterationResult> _processVideoIteration({
),
);
logger.warning(
- ' ⚠ Height mismatch! Expected: $finalExpectedHeight, Got: $actualHeight');
+ ' ⚠ Height mismatch! Expected: $finalExpectedHeight, Got: $actualHeight',
+ );
}
if (failures.isEmpty) {
diff --git a/mobile/apps/photos/lib/ui/viewer/file/video_widget.dart b/mobile/apps/photos/lib/ui/viewer/file/video_widget.dart
index 70f59e162a..7f1c530f48 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/video_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/video_widget.dart
@@ -211,14 +211,12 @@ class _VideoWidgetState extends State<VideoWidget> {
void _maybeShowTransformToast() {
if (!kDebugMode) return;
final name = widget.file.title ?? widget.file.displayName;
- if (name == null) return;
final editedIndex = name.indexOf('_edited');
if (editedIndex == -1) return;
final prefix = name.substring(0, editedIndex);
final hasTrim = prefix.contains('_t');
- final cropMatch =
- RegExp(r'_c_([0-9]+(?:[:_-][0-9]+)?)').firstMatch(prefix);
+ final cropMatch = RegExp(r'_c_([0-9]+(?:[:_-][0-9]+)?)').firstMatch(prefix);
final rotateMatch = RegExp(r'_r_([^_]+)').firstMatch(prefix);
if (!hasTrim && cropMatch == null && rotateMatch == null) return;