[locale] Add test for Config initialization
- needs some massaging because Config otherwise depends on ModuleManager which is a UI class (for the Reasons), but we already have a BUILD_AS_TEST define for that purpose. - demonstrate a nullptr deref.
This commit is contained in:
parent
04e53be934
commit
b36ad4c7f4
@ -36,7 +36,9 @@ calamares_add_test(
|
|||||||
localetest
|
localetest
|
||||||
SOURCES
|
SOURCES
|
||||||
Tests.cpp
|
Tests.cpp
|
||||||
|
Config.cpp
|
||||||
LocaleConfiguration.cpp
|
LocaleConfiguration.cpp
|
||||||
|
SetTimezoneJob.cpp
|
||||||
timezonewidget/TimeZoneImage.cpp
|
timezonewidget/TimeZoneImage.cpp
|
||||||
DEFINITIONS
|
DEFINITIONS
|
||||||
SOURCE_DIR="${CMAKE_CURRENT_LIST_DIR}/images"
|
SOURCE_DIR="${CMAKE_CURRENT_LIST_DIR}/images"
|
||||||
|
@ -436,11 +436,13 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
getStartingTimezone( configurationMap, m_startingTimezone );
|
getStartingTimezone( configurationMap, m_startingTimezone );
|
||||||
getGeoIP( configurationMap, m_geoip );
|
getGeoIP( configurationMap, m_geoip );
|
||||||
|
|
||||||
|
#ifndef BUILD_AS_TEST
|
||||||
if ( m_geoip && m_geoip->isValid() )
|
if ( m_geoip && m_geoip->isValid() )
|
||||||
{
|
{
|
||||||
connect(
|
connect(
|
||||||
Calamares::ModuleManager::instance(), &Calamares::ModuleManager::modulesLoaded, this, &Config::startGeoIP );
|
Calamares::ModuleManager::instance(), &Calamares::ModuleManager::modulesLoaded, this, &Config::startGeoIP );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Calamares::JobList
|
Calamares::JobList
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
#include "LocaleConfiguration.h"
|
#include "LocaleConfiguration.h"
|
||||||
#include "timezonewidget/TimeZoneImage.h"
|
#include "timezonewidget/TimeZoneImage.h"
|
||||||
|
|
||||||
@ -45,6 +45,9 @@ private Q_SLOTS:
|
|||||||
void testTZImages(); // No overlaps in images
|
void testTZImages(); // No overlaps in images
|
||||||
void testTZLocations(); // No overlaps in locations
|
void testTZLocations(); // No overlaps in locations
|
||||||
void testSpecificLocations();
|
void testSpecificLocations();
|
||||||
|
|
||||||
|
// Check the Config loading
|
||||||
|
void testConfigInitialization();
|
||||||
};
|
};
|
||||||
|
|
||||||
QTEST_MAIN( LocaleTests )
|
QTEST_MAIN( LocaleTests )
|
||||||
@ -251,6 +254,16 @@ LocaleTests::testSpecificLocations()
|
|||||||
QVERIFY( gpos.y() < cpos.y() ); // Gibraltar is north of Ceuta
|
QVERIFY( gpos.y() < cpos.y() ); // Gibraltar is north of Ceuta
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
LocaleTests::testConfigInitialization()
|
||||||
|
{
|
||||||
|
Config c;
|
||||||
|
|
||||||
|
QVERIFY( !c.currentLocation() );
|
||||||
|
QVERIFY( !c.currentLocationStatus().isEmpty() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#include "utils/moc-warnings.h"
|
#include "utils/moc-warnings.h"
|
||||||
|
|
||||||
#include "Tests.moc"
|
#include "Tests.moc"
|
||||||
|
Loading…
Reference in New Issue
Block a user