import QtQuick 2.5 import QtTest 1.2 import "../../app/Shared/Format.js" as Format import "../../app/Shared/Remote.js" as Remote import "../../app/Core/DeviceProfile.js" as DeviceProfile // Fonctions pures : Format.js, Remote.js, DeviceProfile.js. TestCase { name: "Helpers" function test_ticks() { compare(Format.ticksToMs(600000000), 60000); compare(Format.msToTicks(1500), 15000000); compare(Format.ticksToMs(undefined), 0); compare(Format.msToTicks(null), 0); } function test_runtime_data() { return [ { tag: "vide", minutes: 0, expected: "" }, { tag: "minutes", minutes: 52, expected: "52 min" }, { tag: "heure pile", minutes: 120, expected: "2 h" }, { tag: "heure + minutes < 10", minutes: 63, expected: "1 h 03 min" }, { tag: "heure + minutes", minutes: 94, expected: "1 h 34 min" } ]; } function test_runtime(data) { compare(Format.runtime(Format.msToTicks(data.minutes * 60000)), data.expected); } function test_clock_data() { return [ { tag: "zéro", ms: 0, expected: "0:00" }, { tag: "négatif", ms: -5000, expected: "0:00" }, { tag: "secondes", ms: 4000, expected: "0:04" }, { tag: "minutes", ms: 245000, expected: "4:05" }, { tag: "heures", ms: 3723000, expected: "1:02:03" }, { tag: "heures, minutes à 2 chiffres", ms: 2 * 3600000 + 45 * 60000, expected: "2:45:00" } ]; } function test_clock(data) { compare(Format.clock(data.ms), data.expected); } function test_cardLabels() { var episode = { type: "Episode", name: "Pilote", seriesName: "Série", parentIndexNumber: 1, indexNumber: 3 }; compare(Format.episodeCode(episode), "S1 · É3"); compare(Format.cardTitle(episode), "Série"); compare(Format.cardSubtitle(episode), "S1 · É3 – Pilote"); compare(Format.episodeCode({ type: "Movie" }), ""); compare(Format.cardTitle({ type: "Movie", name: "Film" }), "Film"); compare(Format.cardSubtitle({ type: "Movie", year: 1997 }), "1997"); compare(Format.cardSubtitle({ type: "Movie", year: 0 }), ""); compare(Format.cardSubtitle({ type: "Series", childCount: 1 }), "1 saison"); compare(Format.cardSubtitle({ type: "Series", childCount: 3 }), "3 saisons"); } function test_progress() { compare(Format.progress({ playedPercentage: 25 }), 0.25); compare(Format.progress({ runtimeTicks: 1000, positionTicks: 500 }), 0.5); compare(Format.progress({ runtimeTicks: 0, positionTicks: 0 }), 0); } function test_infoLine() { compare(Format.infoLine({ type: "Movie", year: 1997, runtimeTicks: Format.msToTicks(94 * 60000), rating: "Tous publics", communityRating: 7.46 }), "1997 · 1 h 34 min · Tous publics · 7,5/10"); compare(Format.infoLine({ type: "Episode", parentIndexNumber: 2, indexNumber: 1 }), "S2 · É1"); compare(Format.infoLine({ type: "Movie" }), ""); } function test_remote() { verify(Remote.isAccept(Qt.Key_Return)); verify(Remote.isAccept(Qt.Key_Enter)); verify(Remote.isAccept(Qt.Key_Select)); verify(!Remote.isAccept(Qt.Key_Space)); verify(Remote.isBack(Qt.Key_Back)); verify(Remote.isBack(Qt.Key_Escape)); verify(!Remote.isBack(Qt.Key_Backspace)); } // La Revolution ne lit que le H.264 : jamais de HEVC déclaré, sinon Jellyfin // enverrait un flux illisible au lieu de transcoder. function test_deviceProfile_codecs() { var profile = DeviceProfile.profile(); verify(profile.DirectPlayProfiles.length > 0); for (var i = 0; i < profile.DirectPlayProfiles.length; i++) { compare(profile.DirectPlayProfiles[i].VideoCodec, "h264"); } var transcode = profile.TranscodingProfiles[0]; compare(transcode.Protocol, "hls"); compare(transcode.VideoCodec, "h264"); compare(profile.MaxStreamingBitrate, DeviceProfile.maxBitrate); verify(JSON.stringify(profile).toLowerCase().indexOf("hevc") < 0); verify(JSON.stringify(profile).toLowerCase().indexOf("h265") < 0); } // Sous-titres texte « External » : sinon Jellyfin transcode pour les incruster. function test_deviceProfile_subtitles() { var subtitles = DeviceProfile.profile().SubtitleProfiles; var formats = []; for (var i = 0; i < subtitles.length; i++) { compare(subtitles[i].Method, "External", subtitles[i].Format); formats.push(subtitles[i].Format); } verify(formats.indexOf("srt") >= 0); verify(formats.indexOf("subrip") >= 0); } }