From 38b588531cdba2c261b915551ffb2efa445033bb Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 17 Mar 2009 18:04:40 -0400 Subject: Add tests for unsetting options and the value list --- sigscript/test/TestConfig.cpp | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'sigscript/test/TestConfig.cpp') diff --git a/sigscript/test/TestConfig.cpp b/sigscript/test/TestConfig.cpp index d332e6b8..64b858d2 100644 --- a/sigscript/test/TestConfig.cpp +++ b/sigscript/test/TestConfig.cpp @@ -101,6 +101,7 @@ void TestConfig::testSetOptions() m_config->setOptions("op2", Config::Hidden); m_config->setOptions("op3", Config::ReadOnly); m_config->setOptions("op4", Config::Temporary); + m_config->setOptions("op1", Config::Deleted); QCOMPARE(changeSpy.count(), 4); @@ -140,11 +141,50 @@ void TestConfig::testClean() void TestConfig::testUnsetOptions() { - QSignalSpy changeSpy(m_config, SIGNAL(optionsChanged(QString, Sigscript::Config::Options))); + QSignalSpy changeSpy(m_config, SIGNAL(valueChanged(QString, QVariant))); + QSignalSpy optChangeSpy(m_config, SIGNAL(optionsChanged(QString, Sigscript::Config::Options))); + + QCOMPARE(m_config->unsetOptions("blag", Config::Hidden), false); + QCOMPARE(m_config->unsetOptions("op3", Config::ReadOnly), true); + + QCOMPARE(m_config->setValue("op3", 30), true); + QCOMPARE(m_config->value("op3").toInt(), 30); + + QCOMPARE(changeSpy.count(), 1); + QCOMPARE(optChangeSpy.count(), 1); } void TestConfig::testValueList() { + QStringList values = m_config->values(false); + qSort(values); + QStringList list; + list << "bar" << "baz" << "op1" << "op3"; + + QEXPECT_FAIL("", "Waiting for clean to work", Continue); + QCOMPARE(values, list); + + Config* subConfig = new Config(m_config); + + subConfig->addValue("blag", 20); + subConfig->removeValue("baz", true); + + values = subConfig->values(false); + qSort(values); + list.clear(); + list << "blag"; + + QCOMPARE(values, list); + + values = subConfig->values(true); + qSort(values); + list.clear(); + list << "bar" << "blag" << "op1" << "op3"; + qSort(list); + + QCOMPARE(values, list); + + delete subConfig; } void TestConfig::testOptionsRead() -- cgit