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

- Can't get Gibraltar (and Ceuta) to be distinguished
main
Adriaan de Groot 5 years ago
parent 3db901bd09
commit 82ba4be5e7

@ -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
}

@ -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

Loading…
Cancel
Save