Merge branch 'issue-1374'
This is just updating tests, not fixing things.
This commit is contained in:
commit
1f3046dcca
@ -25,12 +25,14 @@
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include <set>
|
||||
|
||||
QTEST_MAIN( LocaleTests )
|
||||
|
||||
|
||||
LocaleTests::LocaleTests() { }
|
||||
LocaleTests::LocaleTests() {}
|
||||
|
||||
LocaleTests::~LocaleTests() { }
|
||||
LocaleTests::~LocaleTests() {}
|
||||
|
||||
void
|
||||
LocaleTests::initTestCase()
|
||||
@ -150,3 +152,119 @@ LocaleTests::testTZImages()
|
||||
QEXPECT_FAIL("", "TZ Images not yet all fixed", Continue);
|
||||
QCOMPARE( overlapcount, 0 );
|
||||
}
|
||||
|
||||
bool
|
||||
operator<( const QPoint& l, const QPoint& r )
|
||||
{
|
||||
if ( l.x() < r.x() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if ( l.x() > r.x() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return l.y() < r.y();
|
||||
}
|
||||
|
||||
void
|
||||
listAll( const QPoint& p, const CalamaresUtils::Locale::CStringPairList& zones )
|
||||
{
|
||||
using namespace CalamaresUtils::Locale;
|
||||
for ( const auto* pz : zones )
|
||||
{
|
||||
const TZZone* zone = dynamic_cast< const TZZone* >( pz );
|
||||
if ( p == TimeZoneImageList::getLocationPosition( zone->longitude(), zone->latitude() ) )
|
||||
{
|
||||
cError() << Logger::SubEntry << zone->zone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LocaleTests::testTZLocations()
|
||||
{
|
||||
using namespace CalamaresUtils::Locale;
|
||||
const CStringPairList& regions = TZRegion::fromZoneTab();
|
||||
|
||||
int overlapcount = 0;
|
||||
for ( const auto* pr : regions )
|
||||
{
|
||||
const TZRegion* region = dynamic_cast< const TZRegion* >( pr );
|
||||
QVERIFY( region );
|
||||
|
||||
Logger::setupLogLevel( Logger::LOGDEBUG );
|
||||
cDebug() << "Region" << region->region() << "zones #" << region->zones().count();
|
||||
Logger::setupLogLevel( Logger::LOGERROR );
|
||||
|
||||
std::set< QPoint > occupied;
|
||||
|
||||
const auto zones = region->zones();
|
||||
QVERIFY( zones.count() > 0 );
|
||||
for ( const auto* pz : zones )
|
||||
{
|
||||
const TZZone* zone = dynamic_cast< const TZZone* >( pz );
|
||||
QVERIFY( zone );
|
||||
|
||||
auto pos = TimeZoneImageList::getLocationPosition( zone->longitude(), zone->latitude() );
|
||||
if ( occupied.find( pos ) != occupied.end() )
|
||||
{
|
||||
cError() << "Zone" << zone->zone() << "occupies same spot as ..";
|
||||
listAll( pos, zones );
|
||||
overlapcount++;
|
||||
}
|
||||
occupied.insert( pos );
|
||||
}
|
||||
}
|
||||
|
||||
QEXPECT_FAIL("", "TZ Images contain pixel-overlaps", Continue);
|
||||
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() );
|
||||
QEXPECT_FAIL("", "Gibraltar and Ceuta are really close", Continue);
|
||||
QVERIFY( gpos != cpos );
|
||||
QVERIFY( gibraltar->latitude() > ceuta->latitude() );
|
||||
QEXPECT_FAIL("", "Gibraltar and Ceuta are really close", Continue);
|
||||
QVERIFY( gpos.y() < cpos.y() ); // Gibraltar is north of Ceuta
|
||||
}
|
||||
|
@ -37,7 +37,9 @@ private Q_SLOTS:
|
||||
void testSplitLocaleConfiguration();
|
||||
|
||||
// Check the TZ images for consistency
|
||||
void testTZImages();
|
||||
void testTZImages(); // No overlaps in images
|
||||
void testTZLocations(); // No overlaps in locations
|
||||
void testSpecificLocations();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user