summaryrefslogtreecommitdiff
path: root/tests/unit/CardSideView/CardSideView_test.cpp
blob: 9b08dc0754699d60c4091fcf4e28959749b37d90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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());
    }