|
Kodi Documentation 23.0
Kodi is an open source media player and entertainment hub.
|
#include "filesystem/File.h"#include "filesystem/SpecialProtocol.h"#include "utils/AspectRatioVocabulary.h"#include <cmath>#include <cstdint>#include <limits>#include <set>#include <string>#include <string_view>#include <vector>#include <gtest/gtest.h>Classes | |
| class | TestAspectRatioVocabularyDefinition |
| Tests that apply a definition, and therefore have to put the vocabulary back. More... | |
Functions | |
| TEST (TestAspectRatioVocabulary, EntriesAreAscending) | |
| TEST (TestAspectRatioVocabulary, EveryEntryIsDeclarable) | |
| TEST (TestAspectRatioVocabulary, EveryEntryClassifiesAsItself) | |
| TEST (TestAspectRatioVocabulary, EveryLabelIsTheRatioWrittenOut) | |
| TEST (TestAspectRatioVocabulary, NearestNeverRejects) | |
| TEST (TestAspectRatioVocabulary, NearestRejectsNonRatios) | |
| TEST (TestAspectRatioVocabulary, NaNAndInfinityAreNotRatios) | |
| TEST (TestAspectRatioVocabulary, NearestCutsAtTheGeometricMean) | |
| TEST (TestAspectRatioVocabulary, RatiosThatAreExactFractionsAreHeldAsThemselves) | |
| TEST (TestAspectRatioVocabulary, ResolveErrsTowardTheShapeTheRoomRestsAt) | |
| TEST (TestAspectRatioVocabulary, ResolveRejectsExactlyAsMatchDoes) | |
| TEST (TestAspectRatioVocabulary, ResolveCannotBePulledBeyondTheTolerance) | |
| TEST (TestAspectRatioVocabulary, ResolveWithNoRestingShapeIsMatch) | |
| TEST (TestAspectRatioVocabulary, LabelMatchesNearest) | |
| TEST (TestAspectRatioVocabulary, NameIsServedBesideTheLabelAndMayBeEmpty) | |
| TEST (TestAspectRatioVocabulary, DistanceIsSymmetricAndZeroForEqual) | |
| TEST (TestAspectRatioVocabulary, DistanceRejectsNonRatios) | |
| TEST (TestAspectRatioVocabulary, MatchAcceptsOffNominalEncodes) | |
| TEST (TestAspectRatioVocabulary, MatchRejectsRatiosBetweenEntries) | |
| TEST (TestAspectRatioVocabulary, MatchRejectsImplausibleRatios) | |
| TEST (TestAspectRatioVocabulary, MatchNeverRejectsBetweenTheClosestNeighbours) | |
| TEST (TestAspectRatioVocabulary, MatchHonoursAnExplicitTolerance) | |
| TEST (TestAspectRatioVocabulary, DetectionExcludesRatiosItCannotDistinguish) | |
| TEST (TestAspectRatioVocabulary, ADetectedRatioNeverLandsOnANonDetectableEntry) | |
| TEST_F (TestAspectRatioVocabularyDefinition, AnEntryIsReplacedByValueRatherThanAppended) | |
| TEST_F (TestAspectRatioVocabularyDefinition, AValueMatchesAnEntryAtTwoDecimals) | |
| TEST_F (TestAspectRatioVocabularyDefinition, AnAbsentAttributeKeepsWhatTheEntryHad) | |
| TEST_F (TestAspectRatioVocabularyDefinition, ANewRatioIsAddedInOrderAndLabelledFromItsValue) | |
| TEST_F (TestAspectRatioVocabularyDefinition, ToleranceComesFromTheDefinition) | |
| TEST_F (TestAspectRatioVocabularyDefinition, ABadDefinitionChangesNothingAtAll) | |
| TEST_F (TestAspectRatioVocabularyDefinition, AMalformedDocumentIsRejected) | |
| TEST_F (TestAspectRatioVocabularyDefinition, ARatioWithNoKeyOfItsOwnIsRejected) | |
| TEST (TestAspectRatioVocabulary, EveryEntryRoundTripsThroughItsKey) | |
| TEST (TestAspectRatioVocabulary, EveryKeyIsDistinct) | |
| TEST (TestAspectRatioVocabulary, KeyZeroIsNotARatio) | |
| TEST (TestAspectRatioVocabulary, AChoiceReadsAsTheNumberAndTheName) | |
| TEST_F (TestAspectRatioVocabularyDefinition, AKeyResolvesToTheDefinitionInForce) | |
| TEST_F (TestAspectRatioVocabularyDefinition, ResetGoesBackToTheBuiltInVocabulary) | |
| TEST_F (TestAspectRatioVocabularyDefinition, TheShippedDefinitionParses) | |
| TEST | ( | TestAspectRatioVocabulary | , |
| AChoiceReadsAsTheNumberAndTheName | ) |
An unnamed ratio is a legitimate answer rather than an omission, and reads as the bare number rather than as a number with an empty tail.
| TEST | ( | TestAspectRatioVocabulary | , |
| ADetectedRatioNeverLandsOnANonDetectableEntry | ) |
A measurement at 2.76 is classified against the detectable entries only, so it resolves to 2.40 and is then rejected as too far from it. Declaring 2.76 remains available.
| TEST | ( | TestAspectRatioVocabulary | , |
| DetectionExcludesRatiosItCannotDistinguish | ) |
| TEST | ( | TestAspectRatioVocabulary | , |
| DistanceIsSymmetricAndZeroForEqual | ) |
| TEST | ( | TestAspectRatioVocabulary | , |
| DistanceRejectsNonRatios | ) |
| TEST | ( | TestAspectRatioVocabulary | , |
| EntriesAreAscending | ) |
Nearest() cuts between adjacent entries, so order is a correctness requirement.
| TEST | ( | TestAspectRatioVocabulary | , |
| EveryEntryClassifiesAsItself | ) |
| TEST | ( | TestAspectRatioVocabulary | , |
| EveryEntryIsDeclarable | ) |
A declaration is never second-guessed, so nothing Kodi knows about is withheld from it.
| TEST | ( | TestAspectRatioVocabulary | , |
| EveryEntryRoundTripsThroughItsKey | ) |
A setting and a list control both store the choice as this integer, so an entry that does not come back is an entry nobody can pick.
| TEST | ( | TestAspectRatioVocabulary | , |
| EveryKeyIsDistinct | ) |
Two entries sharing a key would make one of them unreachable from a stored choice.
| TEST | ( | TestAspectRatioVocabulary | , |
| EveryLabelIsTheRatioWrittenOut | ) |
Derived rather than stored, so a definition file cannot put words where every existing consumer - ListItem.VideoAspect, the library, JSON-RPC - expects the number.
| TEST | ( | TestAspectRatioVocabulary | , |
| KeyZeroIsNotARatio | ) |
The declaration list uses zero for "Auto", so nothing may resolve to it.
| TEST | ( | TestAspectRatioVocabulary | , |
| LabelMatchesNearest | ) |
| TEST | ( | TestAspectRatioVocabulary | , |
| MatchAcceptsOffNominalEncodes | ) |
1888x1080 is 1.748, 1.7% from the 1.78 entry, and is a correct encode rather than a measurement error. A tolerance set to the width of a rounding error rejects it.
| TEST | ( | TestAspectRatioVocabulary | , |
| MatchHonoursAnExplicitTolerance | ) |
| TEST | ( | TestAspectRatioVocabulary | , |
| MatchNeverRejectsBetweenTheClosestNeighbours | ) |
2.35 and 2.40 are 2.1% apart, so at the default tolerance there is no gap between them wide enough to fall into. Pinned so that this is a known consequence of the tolerance rather than a surprise to a caller treating a match as confirmation.
| TEST | ( | TestAspectRatioVocabulary | , |
| MatchRejectsImplausibleRatios | ) |
The case Nearest() answers "2.76" to.
| TEST | ( | TestAspectRatioVocabulary | , |
| MatchRejectsRatiosBetweenEntries | ) |
| TEST | ( | TestAspectRatioVocabulary | , |
| NameIsServedBesideTheLabelAndMayBeEmpty | ) |
The two are separate values on purpose: a consumer branches on one and displays the other, and a ratio with no established name must not fall back to the number.
| TEST | ( | TestAspectRatioVocabulary | , |
| NaNAndInfinityAreNotRatios | ) |
| TEST | ( | TestAspectRatioVocabulary | , |
| NearestCutsAtTheGeometricMean | ) |
Probed either side of each cutoff so a change to the table cannot silently move one. These are the same values the classifier is pinned against.
| TEST | ( | TestAspectRatioVocabulary | , |
| NearestNeverRejects | ) |
Anything beyond the widest entry is still classified as it. Match() is the check that rejects; this one deliberately does not.
| TEST | ( | TestAspectRatioVocabulary | , |
| NearestRejectsNonRatios | ) |
| TEST | ( | TestAspectRatioVocabulary | , |
| RatiosThatAreExactFractionsAreHeldAsThemselves | ) |
16:9 is 1.7778, and an entry at the two-decimal nominal would put every full-frame measurement and declaration a couple of pixels inside its own frame. The label and the key still read at two decimals, which is what every consumer stores and displays.
| TEST | ( | TestAspectRatioVocabulary | , |
| ResolveCannotBePulledBeyondTheTolerance | ) |
2.33 is within tolerance of 2.35 alone; a room resting at 2.76 must not drag it to an entry the measurement cannot support.
| TEST | ( | TestAspectRatioVocabulary | , |
| ResolveErrsTowardTheShapeTheRoomRestsAt | ) |
3840x1620 is 2.3704, within tolerance of both 2.35 and 2.40. Which is right depends on the room: erring toward its resting shape opens a mask onto fabric, erring away spills picture onto the wall.
| TEST | ( | TestAspectRatioVocabulary | , |
| ResolveRejectsExactlyAsMatchDoes | ) |
The direction rule chooses between entries a measurement could support; it must never rescue one that supports none.
| TEST | ( | TestAspectRatioVocabulary | , |
| ResolveWithNoRestingShapeIsMatch | ) |
| TEST_F | ( | TestAspectRatioVocabularyDefinition | , |
| ABadDefinitionChangesNothingAtAll | ) |
Rejected after a good entry has already been merged, which is the case that would leave a half-applied vocabulary if the merge were done in place.
| TEST_F | ( | TestAspectRatioVocabularyDefinition | , |
| AKeyResolvesToTheDefinitionInForce | ) |
A ratio a viewer added is choosable, which is the whole point of the key being derived from the vocabulary rather than from a fixed list.
| TEST_F | ( | TestAspectRatioVocabularyDefinition | , |
| AMalformedDocumentIsRejected | ) |
The vocabulary still answers, which is the property everything else depends on.
| TEST_F | ( | TestAspectRatioVocabularyDefinition | , |
| AnAbsentAttributeKeepsWhatTheEntryHad | ) |
The whole point of merging: changing one property must not silently reset the others.
| TEST_F | ( | TestAspectRatioVocabularyDefinition | , |
| AnEntryIsReplacedByValueRatherThanAppended | ) |
| TEST_F | ( | TestAspectRatioVocabularyDefinition | , |
| ANewRatioIsAddedInOrderAndLabelledFromItsValue | ) |
Sorted here rather than demanded of the file, because classification cuts between neighbours and a viewer adding a ratio should not have to know that. Custom delimiter: the name carries brackets, and a plain R"( ... )" would be closed by the )" this one contains.
| TEST_F | ( | TestAspectRatioVocabularyDefinition | , |
| ARatioWithNoKeyOfItsOwnIsRejected | ) |
Key 0 is Auto's, so a ratio rounding to it would be a second Auto in every choice list.
Within float's range, but a hundred times either is beyond an int key
| TEST_F | ( | TestAspectRatioVocabularyDefinition | , |
| AValueMatchesAnEntryAtTwoDecimals | ) |
The built-in 16:9 entry is the exact fraction, and a viewer's file saying 1.78 must change it rather than stand beside it - two entries inside the same hundredth would share a key, leaving one of them unreachable from any stored choice.
| TEST_F | ( | TestAspectRatioVocabularyDefinition | , |
| ResetGoesBackToTheBuiltInVocabulary | ) |
| TEST_F | ( | TestAspectRatioVocabularyDefinition | , |
| TheShippedDefinitionParses | ) |
The file Kodi actually ships, parsed by the code that will parse it at startup.
Load() keeps the built-ins when a document does not parse, and says so only in the log - so a shipped file broken by an edit leaves CI green while every installation runs on a different vocabulary from the one in the tree. Read through the real path rather than a copy, because a fixture copy is exactly what stops describing the shipped file.
| TEST_F | ( | TestAspectRatioVocabularyDefinition | , |
| ToleranceComesFromTheDefinition | ) |