diff options
Diffstat (limited to 'tests/unit/CardSideView/CardSideView_test.cpp')
-rw-r--r-- | tests/unit/CardSideView/CardSideView_test.cpp | 49 |
1 files changed, 49 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()); + } |