mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
tests: fix TestQPrefLog
There were several issues with these tests, including checking the value argument against bool values even if the underlying preference isn't bool. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
7046bb4f82
commit
9be028659e
2 changed files with 25 additions and 21 deletions
|
@ -24,15 +24,15 @@ void qPrefLog::set_default_file_behavior(enum def_file_behavior value)
|
||||||
if (value != prefs.default_file_behavior ||
|
if (value != prefs.default_file_behavior ||
|
||||||
prefs.default_file_behavior != UNDEFINED_DEFAULT_FILE) {
|
prefs.default_file_behavior != UNDEFINED_DEFAULT_FILE) {
|
||||||
|
|
||||||
if (value == UNDEFINED_DEFAULT_FILE) {
|
if (value == UNDEFINED_DEFAULT_FILE) {
|
||||||
// undefined, so check if there's a filename set and
|
// undefined, so check if there's a filename set and
|
||||||
// use that, otherwise go with no default file
|
// use that, otherwise go with no default file
|
||||||
prefs.default_file_behavior = QString(prefs.default_filename).isEmpty() ? NO_DEFAULT_FILE : LOCAL_DEFAULT_FILE;
|
prefs.default_file_behavior = QString(prefs.default_filename).isEmpty() ? NO_DEFAULT_FILE : LOCAL_DEFAULT_FILE;
|
||||||
} else {
|
} else {
|
||||||
prefs.default_file_behavior = value;
|
prefs.default_file_behavior = value;
|
||||||
}
|
}
|
||||||
disk_default_file_behavior(true);
|
disk_default_file_behavior(true);
|
||||||
emit instance()->default_file_behaviorChanged(value);
|
emit instance()->default_file_behaviorChanged(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void qPrefLog::disk_default_file_behavior(bool doSync)
|
void qPrefLog::disk_default_file_behavior(bool doSync)
|
||||||
|
|
|
@ -151,6 +151,14 @@ void TestQPrefLog::test_oldPreferences()
|
||||||
|
|
||||||
void TestQPrefLog::test_signals()
|
void TestQPrefLog::test_signals()
|
||||||
{
|
{
|
||||||
|
// create known baseline
|
||||||
|
qPrefLog::set_default_filename("new base01");
|
||||||
|
qPrefLog::set_default_file_behavior(LOCAL_DEFAULT_FILE);
|
||||||
|
qPrefLog::set_use_default_file(false);
|
||||||
|
qPrefLog::set_show_average_depth(true);
|
||||||
|
qPrefLog::set_extraEnvironmentalDefault(false);
|
||||||
|
|
||||||
|
// start checking signals
|
||||||
QSignalSpy spy1(qPrefLog::instance(), &qPrefLog::default_filenameChanged);
|
QSignalSpy spy1(qPrefLog::instance(), &qPrefLog::default_filenameChanged);
|
||||||
QSignalSpy spy2(qPrefLog::instance(), &qPrefLog::default_file_behaviorChanged);
|
QSignalSpy spy2(qPrefLog::instance(), &qPrefLog::default_file_behaviorChanged);
|
||||||
QSignalSpy spy3(qPrefLog::instance(), &qPrefLog::use_default_fileChanged);
|
QSignalSpy spy3(qPrefLog::instance(), &qPrefLog::use_default_fileChanged);
|
||||||
|
@ -158,19 +166,15 @@ void TestQPrefLog::test_signals()
|
||||||
QSignalSpy spy5(qPrefLog::instance(), &qPrefLog::extraEnvironmentalDefaultChanged);
|
QSignalSpy spy5(qPrefLog::instance(), &qPrefLog::extraEnvironmentalDefaultChanged);
|
||||||
|
|
||||||
qPrefLog::set_default_filename("new base01");
|
qPrefLog::set_default_filename("new base01");
|
||||||
qPrefLog::set_default_file_behavior(LOCAL_DEFAULT_FILE);
|
qPrefLog::set_default_filename("new base02");
|
||||||
qPrefLog::set_use_default_file(false);
|
|
||||||
qPrefLog::set_show_average_depth(false);
|
|
||||||
qPrefLog::set_extraEnvironmentalDefault(false);
|
|
||||||
|
|
||||||
prefs.default_file_behavior = NO_DEFAULT_FILE;
|
prefs.default_file_behavior = NO_DEFAULT_FILE;
|
||||||
qPrefLog::set_default_file_behavior(LOCAL_DEFAULT_FILE);
|
qPrefLog::set_default_file_behavior(LOCAL_DEFAULT_FILE);
|
||||||
prefs.use_default_file = true;
|
prefs.use_default_file = true;
|
||||||
qPrefLog::set_use_default_file(false);
|
qPrefLog::set_use_default_file(false);
|
||||||
|
prefs.show_average_depth = false;
|
||||||
|
qPrefLog::set_show_average_depth(true);
|
||||||
prefs.extraEnvironmentalDefault = true;
|
prefs.extraEnvironmentalDefault = true;
|
||||||
qPrefLog::set_extraEnvironmentalDefault(false);
|
qPrefLog::set_extraEnvironmentalDefault(false);
|
||||||
prefs.show_average_depth = true;
|
|
||||||
qPrefLog::set_show_average_depth(false);
|
|
||||||
|
|
||||||
QCOMPARE(spy1.count(), 1);
|
QCOMPARE(spy1.count(), 1);
|
||||||
QCOMPARE(spy2.count(), 1);
|
QCOMPARE(spy2.count(), 1);
|
||||||
|
@ -178,11 +182,11 @@ void TestQPrefLog::test_signals()
|
||||||
QCOMPARE(spy4.count(), 1);
|
QCOMPARE(spy4.count(), 1);
|
||||||
QCOMPARE(spy5.count(), 1);
|
QCOMPARE(spy5.count(), 1);
|
||||||
|
|
||||||
QVERIFY(spy1.takeFirst().at(0).toBool() == false);
|
QVERIFY(spy1.takeFirst().at(0).toBool() == true); // text was changed, so value is true
|
||||||
QVERIFY(spy2.takeFirst().at(0).toBool() == false);
|
QVERIFY(spy2.takeFirst().at(0).toInt() == (int)LOCAL_DEFAULT_FILE);
|
||||||
QVERIFY(spy2.takeFirst().at(0).toBool() == false);
|
QVERIFY(spy3.takeFirst().at(0).toBool() == false); // boolean value last changed to
|
||||||
QVERIFY(spy4.takeFirst().at(0).toBool() == false);
|
QVERIFY(spy4.takeFirst().at(0).toBool() == true); // -"-
|
||||||
QVERIFY(spy5.takeFirst().at(0).toBool() == false);
|
QVERIFY(spy5.takeFirst().at(0).toBool() == false); // -"-
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue