diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2019-12-28 10:16:55 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-12-29 12:31:43 -0800 |
commit | 9be028659edb24d188c9b8996dfb597009c2a34b (patch) | |
tree | ad23446c49de5ef098bcf0d331572a96a12d827c /tests/testqPrefLog.cpp | |
parent | 7046bb4f82e8c63a12d85ac8e22e83b346747e9c (diff) | |
download | subsurface-9be028659edb24d188c9b8996dfb597009c2a34b.tar.gz |
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>
Diffstat (limited to 'tests/testqPrefLog.cpp')
-rw-r--r-- | tests/testqPrefLog.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/tests/testqPrefLog.cpp b/tests/testqPrefLog.cpp index 73895f278..0abd703be 100644 --- a/tests/testqPrefLog.cpp +++ b/tests/testqPrefLog.cpp @@ -151,6 +151,14 @@ void TestQPrefLog::test_oldPreferences() 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 spy2(qPrefLog::instance(), &qPrefLog::default_file_behaviorChanged); QSignalSpy spy3(qPrefLog::instance(), &qPrefLog::use_default_fileChanged); @@ -158,19 +166,15 @@ void TestQPrefLog::test_signals() QSignalSpy spy5(qPrefLog::instance(), &qPrefLog::extraEnvironmentalDefaultChanged); 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(false); - qPrefLog::set_extraEnvironmentalDefault(false); - + qPrefLog::set_default_filename("new base02"); prefs.default_file_behavior = NO_DEFAULT_FILE; qPrefLog::set_default_file_behavior(LOCAL_DEFAULT_FILE); prefs.use_default_file = true; qPrefLog::set_use_default_file(false); + prefs.show_average_depth = false; + qPrefLog::set_show_average_depth(true); prefs.extraEnvironmentalDefault = true; qPrefLog::set_extraEnvironmentalDefault(false); - prefs.show_average_depth = true; - qPrefLog::set_show_average_depth(false); QCOMPARE(spy1.count(), 1); QCOMPARE(spy2.count(), 1); @@ -178,11 +182,11 @@ void TestQPrefLog::test_signals() QCOMPARE(spy4.count(), 1); QCOMPARE(spy5.count(), 1); - QVERIFY(spy1.takeFirst().at(0).toBool() == false); - QVERIFY(spy2.takeFirst().at(0).toBool() == false); - QVERIFY(spy2.takeFirst().at(0).toBool() == false); - QVERIFY(spy4.takeFirst().at(0).toBool() == false); - QVERIFY(spy5.takeFirst().at(0).toBool() == false); + QVERIFY(spy1.takeFirst().at(0).toBool() == true); // text was changed, so value is true + QVERIFY(spy2.takeFirst().at(0).toInt() == (int)LOCAL_DEFAULT_FILE); + QVERIFY(spy3.takeFirst().at(0).toBool() == false); // boolean value last changed to + QVERIFY(spy4.takeFirst().at(0).toBool() == true); // -"- + QVERIFY(spy5.takeFirst().at(0).toBool() == false); // -"- } |