[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
|
SOURCES
|
||||||
Tests.cpp
|
Tests.cpp
|
||||||
LocaleConfiguration.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 "Tests.h"
|
||||||
#include "LocaleConfiguration.h"
|
#include "LocaleConfiguration.h"
|
||||||
|
#include "timezonewidget/TimeZoneImage.h"
|
||||||
|
|
||||||
#include "locale/TimeZone.h"
|
#include "locale/TimeZone.h"
|
||||||
|
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
QTEST_GUILESS_MAIN( LocaleTests )
|
QTEST_MAIN( LocaleTests )
|
||||||
|
|
||||||
|
|
||||||
LocaleTests::LocaleTests() {}
|
LocaleTests::LocaleTests() {}
|
||||||
@ -84,6 +85,31 @@ void
|
|||||||
LocaleTests::testTZImages()
|
LocaleTests::testTZImages()
|
||||||
{
|
{
|
||||||
Logger::setupLogLevel( Logger::LOGDEBUG );
|
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;
|
using namespace CalamaresUtils::Locale;
|
||||||
const CStringPairList& regions = TZRegion::fromZoneTab();
|
const CStringPairList& regions = TZRegion::fromZoneTab();
|
||||||
|
|
||||||
|
@ -55,13 +55,6 @@ TimeZoneWidget::TimeZoneWidget( QWidget* parent )
|
|||||||
background = QImage( ":/images/bg.png" );
|
background = QImage( ":/images/bg.png" );
|
||||||
pin = QImage( ":/images/pin.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
|
// Set size
|
||||||
setMinimumSize( background.size() );
|
setMinimumSize( background.size() );
|
||||||
setMaximumSize( background.size() );
|
setMaximumSize( background.size() );
|
||||||
|
Loading…
Reference in New Issue
Block a user