[locale] Test the TZ image loader
- QImage needs Qt5::Gui, so this isn't a guiless-test; it can use the offscreen QPA, though. - Check that the images are all the same size - Debugging / check code removed from timezonewidget
This commit is contained in:
parent
340c462062
commit
3945008956
@ -37,4 +37,9 @@ calamares_add_test(
|
||||
SOURCES
|
||||
Tests.cpp
|
||||
LocaleConfiguration.cpp
|
||||
timezonewidget/TimeZoneImage.cpp
|
||||
DEFINITIONS
|
||||
SOURCE_DIR="${CMAKE_CURRENT_LIST_DIR}/images"
|
||||
LIBRARIES
|
||||
Qt5::Gui
|
||||
)
|
||||
|
@ -19,12 +19,13 @@
|
||||
|
||||
#include "Tests.h"
|
||||
#include "LocaleConfiguration.h"
|
||||
#include "timezonewidget/TimeZoneImage.h"
|
||||
|
||||
#include "locale/TimeZone.h"
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
QTEST_GUILESS_MAIN( LocaleTests )
|
||||
QTEST_MAIN( LocaleTests )
|
||||
|
||||
|
||||
LocaleTests::LocaleTests() {}
|
||||
@ -84,6 +85,31 @@ void
|
||||
LocaleTests::testTZImages()
|
||||
{
|
||||
Logger::setupLogLevel( Logger::LOGDEBUG );
|
||||
|
||||
// Number of zone images
|
||||
//
|
||||
//
|
||||
auto images = TimeZoneImageList::fromDirectory( SOURCE_DIR );
|
||||
QCOMPARE( images.count(), images.zoneCount() );
|
||||
QCOMPARE( images.count(), 38 ); // counted by hand
|
||||
|
||||
// All image sizes consistent
|
||||
//
|
||||
//
|
||||
const QSize windowSize( 780, 340 );
|
||||
{
|
||||
QImage background( SOURCE_DIR "/bg.png" );
|
||||
QVERIFY( !background.isNull() );
|
||||
QCOMPARE( background.size(), windowSize );
|
||||
}
|
||||
for ( const auto& image : images )
|
||||
{
|
||||
QCOMPARE( image.size(), windowSize );
|
||||
}
|
||||
|
||||
// Check zones are uniquely-claimed
|
||||
//
|
||||
//
|
||||
using namespace CalamaresUtils::Locale;
|
||||
const CStringPairList& regions = TZRegion::fromZoneTab();
|
||||
|
||||
|
@ -55,13 +55,6 @@ TimeZoneWidget::TimeZoneWidget( QWidget* parent )
|
||||
background = QImage( ":/images/bg.png" );
|
||||
pin = QImage( ":/images/pin.png" );
|
||||
|
||||
#ifdef DEBUG_TIMEZONES
|
||||
if ( background.size() != QSize( 780, 340 ) )
|
||||
{
|
||||
cWarning() << "Timezone background size mismatch" << background.size();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Set size
|
||||
setMinimumSize( background.size() );
|
||||
setMaximumSize( background.size() );
|
||||
|
Loading…
Reference in New Issue
Block a user