From d71d0dc4af3936a0aa97a473488368f4f8f755c2 Mon Sep 17 00:00:00 2001 From: evgeny Date: Tue, 20 Oct 2026 00:54:29 +0200 Subject: [PATCH] Check fullscreen video fitting without cropping or rotating thumbnails --- .../utun/chat/ui/screens/VideoFrameFitTest.kt | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tools/chatgui-android/app/src/test/java/com/utun/chat/ui/screens/VideoFrameFitTest.kt diff --git a/tools/chatgui-android/app/src/test/java/com/utun/chat/ui/screens/VideoFrameFitTest.kt b/tools/chatgui-android/app/src/test/java/com/utun/chat/ui/screens/VideoFrameFitTest.kt new file mode 100644 index 00000000..3f9b3cba --- /dev/null +++ b/tools/chatgui-android/app/src/test/java/com/utun/chat/ui/screens/VideoFrameFitTest.kt @@ -0,0 +1,31 @@ +package com.utun.chat.ui.screens + +import org.junit.Assert.* +import org.junit.Test + +class VideoFrameFitTest { + @Test fun fullscreenLandscapeUsesLongSideOfPortraitWindow() { + val fit = fitVideoFrame(1080f, 2400f, 16f / 9f, true) + assertEquals(90f, fit.rotation, 0f) + assertEquals(1920f, fit.width, 0.001f); assertEquals(1080f, fit.height, 0.001f) + } + @Test fun thumbnailKeepsLandscapeOrientation() { + val fit = fitVideoFrame(1080f, 2400f, 16f / 9f, false) + assertEquals(0f, fit.rotation, 0f) + assertEquals(1080f, fit.width, 0f); assertEquals(607.5f, fit.height, 0.001f) + } + @Test fun matchingOrientationsAndSquareDoNotRotate() { + assertEquals(0f, fitVideoFrame(2400f, 1080f, 16f / 9f, true).rotation, 0f) + assertEquals(0f, fitVideoFrame(1080f, 2400f, 9f / 16f, true).rotation, 0f) + assertEquals(0f, fitVideoFrame(1080f, 2400f, 1f, true).rotation, 0f) + } + @Test fun everyFitKeepsAspectAndStaysInsideWindowAfterRotation() { + for ((w, h) in listOf(1080f to 2400f, 2400f to 1080f, 144f to 104f)) + for (aspect in listOf(16f / 9f, 9f / 16f, 4f / 3f, 1f)) for (turn in listOf(false, true)) { + val fit = fitVideoFrame(w, h, aspect, turn) + assertEquals(aspect, fit.width / fit.height, 0.001f) + assertTrue((if (fit.rotation == 0f) fit.width else fit.height) <= w + 0.001f) + assertTrue((if (fit.rotation == 0f) fit.height else fit.width) <= h + 0.001f) + } + } +}