summaryrefslogtreecommitdiff
path: root/tests/unit/CardSideView
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/CardSideView')
-rw-r--r--tests/unit/CardSideView/CardSideView_test.cpp49
-rw-r--r--tests/unit/CardSideView/CardSideView_test.h21
-rw-r--r--tests/unit/CardSideView/csView.pri8
3 files changed, 78 insertions, 0 deletions
diff --git a/tests/unit/CardSideView/CardSideView_test.cpp b/tests/unit/CardSideView/CardSideView_test.cpp
new file mode 100644
index 0000000..9b08dc0
--- /dev/null
+++ b/tests/unit/CardSideView/CardSideView_test.cpp
@@ -0,0 +1,49 @@
+#include <gtest/gtest.h>
+#include <QtCore>
+#include <QtWidgets>
+
+#include "CardSideView_test.h"
+#include "../../common/printQtTypes.h"
+#include "../../../src/dictionary/Card.h"
+#include "../../../src/study/CardSideView.h"
+
+void CardSideViewTest::SetUp()
+ {
+ cardPack.addField(new Field("English", "Normal"));
+ cardPack.addField(new Field("Example", "Example"));
+ cardPack.addField(new Field("Russian", "Normal"));
+ }
+
+TEST_F(CardSideViewTest, getFormattedQuestion)
+ {
+ CardSideView view;
+ view.setPack(&cardPack);
+ view.setQstAnsr("First", QStringList());
+ ASSERT_EQ("<span style=\"font-family:'Times New Roman'; "\
+ "font-size:18pt; font-weight:bold\">First</span>",
+ view.getFormattedText());
+ }
+
+TEST_F(CardSideViewTest, getFormattedAnswer)
+ {
+ CardSideView view(CardSideView::AnsMode);
+ view.setPack(&cardPack);
+ QStringList answers = QStringList() << "First example" << "Pervyj";
+ view.setQstAnsr("First", answers);
+ ASSERT_EQ("<span style=\"font-family:'Times New Roman'; "\
+ "font-size:14pt\"><span style=\"; color:#0000ff\">First</span> example</span><br/><br/>"\
+ "<span style=\"font-family:'Times New Roman'; font-size:18pt; "\
+ "font-weight:bold\">Pervyj</span>",
+ view.getFormattedText());
+ }
+
+TEST_F(CardSideViewTest, getFormattedAnswer_1missing)
+ {
+ CardSideView view(CardSideView::AnsMode);
+ view.setPack(&cardPack);
+ QStringList answers = QStringList() << "" << "Pervyj";
+ view.setQstAnsr("First", answers);
+ ASSERT_EQ("<br/><br/><span style=\"font-family:'Times New Roman'; font-size:18pt; "\
+ "font-weight:bold\">Pervyj</span>",
+ view.getFormattedText());
+ }
diff --git a/tests/unit/CardSideView/CardSideView_test.h b/tests/unit/CardSideView/CardSideView_test.h
new file mode 100644
index 0000000..491ebe4
--- /dev/null
+++ b/tests/unit/CardSideView/CardSideView_test.h
@@ -0,0 +1,21 @@
+#ifndef CARDSIDEVIEW_TEST_H
+#define CARDSIDEVIEW_TEST_H
+
+#include <gtest/gtest.h>
+
+#include "../../mocks/Dictionary_mock.h"
+#include "../../../src/dictionary/CardPack.h"
+
+class CardSideViewTest: public testing::Test
+{
+public:
+ CardSideViewTest():
+ cardPack(&dict) {}
+ void SetUp();
+
+protected:
+ MockDictionary dict;
+ CardPack cardPack;
+};
+
+#endif
diff --git a/tests/unit/CardSideView/csView.pri b/tests/unit/CardSideView/csView.pri
new file mode 100644
index 0000000..6eeae5f
--- /dev/null
+++ b/tests/unit/CardSideView/csView.pri
@@ -0,0 +1,8 @@
+HEADERS += \
+ $$PWD/CardSideView_test.h \
+ $$SRC/study/CardSideView.h
+
+SOURCES += \
+ $$PWD/CardSideView_test.cpp \
+ $$SRC/study/CardSideView.cpp
+ \ No newline at end of file