summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Habacker <[email protected]>2015-06-21 15:25:58 +0200
committerRalf Habacker <[email protected]>2015-06-21 15:25:58 +0200
commit0625d575363c09eea34aba377b27f5bde966dc98 (patch)
treea37f1e8be36c29db78e0aaebacef5b2c39918aed
parentb06201589b90f4ff81fa742057873b775e9d3f33 (diff)
Add unit test for class OptionState.
-rw-r--r--unittests/CMakeLists.txt7
-rw-r--r--unittests/TEST_optionstate.cpp36
-rw-r--r--unittests/TEST_optionstate.h15
3 files changed, 58 insertions, 0 deletions
diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt
index f794954..4f72fb5 100644
--- a/unittests/CMakeLists.txt
+++ b/unittests/CMakeLists.txt
@@ -98,6 +98,13 @@ ecm_add_test(
TEST_NAME TEST_pythonwriter
)
+ecm_add_test(
+ TEST_optionstate.cpp
+ testbase.cpp
+ LINK_LIBRARIES ${LIBS}
+ TEST_NAME TEST_optionstate
+)
+
set(TEST_umlroledialog_SRCS
TEST_umlroledialog.cpp
)
diff --git a/unittests/TEST_optionstate.cpp b/unittests/TEST_optionstate.cpp
new file mode 100644
index 0000000..f03ab08
--- /dev/null
+++ b/unittests/TEST_optionstate.cpp
@@ -0,0 +1,36 @@
+#include "TEST_optionstate.h"
+
+#include "optionstate.h"
+
+void TEST_optionstate::test_create()
+{
+ Settings::OptionState options;
+ QCOMPARE(options.classState.showAtts, false);
+ QCOMPARE(options.classState.showOps, false);
+ QCOMPARE(options.uiState.useFillColor, false);
+
+ QScopedPointer<Settings::OptionState> optionsA(new Settings::OptionState);
+ QCOMPARE(optionsA->classState.showAtts, false);
+ QCOMPARE(optionsA->classState.showOps, false);
+ QCOMPARE(optionsA->uiState.useFillColor, false);
+}
+
+void TEST_optionstate::test_saveAndLoad()
+{
+ Settings::OptionState options;
+ options.classState.showAtts = true;
+ options.classState.showOps = true;
+ options.uiState.useFillColor = true;
+
+ QDomDocument doc;
+ QDomElement element = doc.createElement(QLatin1String("test"));
+ Settings::saveToXMI(element, options);
+
+ Settings::OptionState optionsB;
+ QCOMPARE(Settings::loadFromXMI(element, optionsB), true);
+ QCOMPARE(optionsB.classState.showAtts, true);
+ QCOMPARE(optionsB.classState.showOps, true);
+ QCOMPARE(optionsB.uiState.useFillColor, true);
+}
+
+QTEST_MAIN(TEST_optionstate)
diff --git a/unittests/TEST_optionstate.h b/unittests/TEST_optionstate.h
new file mode 100644
index 0000000..5fc7708
--- /dev/null
+++ b/unittests/TEST_optionstate.h
@@ -0,0 +1,15 @@
+#ifndef TEST_OPTIONSTATE_H
+#define TEST_OPTIONSTATE_H
+
+#include "testbase.h"
+
+class TEST_optionstate : public TestBase
+{
+ Q_OBJECT
+
+private slots:
+ void test_create();
+ void test_saveAndLoad();
+};
+
+#endif // TEST_OPTIONSTATE_H