[locale] Test for pixel-perfect location of Gibraltar and Ceuta

- Can't get Gibraltar (and Ceuta) to be distinguished
This commit is contained in:
Adriaan de Groot 2020-04-16 17:59:12 +02:00
parent 3db901bd09
commit 82ba4be5e7
2 changed files with 47 additions and 0 deletions

View File

@ -215,3 +215,49 @@ LocaleTests::testTZLocations()
}
QCOMPARE( overlapcount, 0 );
}
const CalamaresUtils::Locale::TZZone*
findZone( const QString& name )
{
using namespace CalamaresUtils::Locale;
const CStringPairList& regions = TZRegion::fromZoneTab();
for ( const auto* pr : regions )
{
const TZRegion* region = dynamic_cast< const TZRegion* >( pr );
if ( !region )
{
continue;
}
const auto zones = region->zones();
for ( const auto* pz : zones )
{
const TZZone* zone = dynamic_cast< const TZZone* >( pz );
if ( !zone )
{
continue;
}
if ( zone->zone() == name )
{
return zone;
}
}
}
return nullptr;
}
void
LocaleTests::testSpecificLocations()
{
const auto* gibraltar = findZone( "Gibraltar" );
const auto* ceuta = findZone( "Ceuta" );
QVERIFY( gibraltar );
QVERIFY( ceuta );
auto gpos = TimeZoneImageList::getLocationPosition( gibraltar->longitude(), gibraltar->latitude() );
auto cpos = TimeZoneImageList::getLocationPosition( ceuta->longitude(), ceuta->latitude() );
QVERIFY( gpos != cpos );
QVERIFY( gibraltar->latitude() > ceuta->latitude() );
QVERIFY( gpos.y() < cpos.y() ); // Gibraltar is north of Ceuta
}

View File

@ -39,6 +39,7 @@ private Q_SLOTS:
// Check the TZ images for consistency
void testTZImages(); // No overlaps in images
void testTZLocations(); // No overlaps in locations
void testSpecificLocations();
};
#endif