notedisplayattributetest.cpp 2.32 KB
Newer Older
1
/*
Laurent Montel's avatar
Laurent Montel committed
2
   SPDX-FileCopyrightText: 2014-2021 Laurent Montel <montel@kde.org>
3

4
   SPDX-License-Identifier: GPL-2.0-or-later
5 6 7
*/

#include "notedisplayattributetest.h"
8 9
#include "notedisplayattribute.h"

10
#include <QFontDatabase>
11 12

#include <QTest>
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

NoteDisplayAttributeTest::NoteDisplayAttributeTest(QObject *parent)
    : QObject(parent)
{
}

NoteDisplayAttributeTest::~NoteDisplayAttributeTest()
{
}

void NoteDisplayAttributeTest::shouldHaveDefaultValue()
{
    NoteShared::NoteDisplayAttribute attribute;
    QVERIFY(attribute.autoIndent());
    QVERIFY(!attribute.keepBelow());
    QVERIFY(!attribute.keepAbove());
    QVERIFY(!attribute.showInTaskbar());
    QVERIFY(!attribute.isHidden());
31
    //@krazy:cond=qenums because everyone expects yellow postit notes
32 33
    QCOMPARE(attribute.backgroundColor(), QColor(Qt::yellow));
    QCOMPARE(attribute.foregroundColor(), QColor(Qt::black));
34
    //@krazy:endcond=qenums
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
    QVERIFY(attribute.rememberDesktop());
    QCOMPARE(attribute.tabSize(), 4);
    QCOMPARE(attribute.font(), QFontDatabase::systemFont(QFontDatabase::GeneralFont));
    QCOMPARE(attribute.titleFont(), QFontDatabase::systemFont(QFontDatabase::TitleFont));
    QCOMPARE(attribute.size(), QSize(300, 300));
    QCOMPARE(attribute.desktop(), -10);
    QCOMPARE(attribute.position(), QPoint(-10000, -10000));
}

void NoteDisplayAttributeTest::shouldEqualWhenCloning()
{
    NoteShared::NoteDisplayAttribute attribute;
    NoteShared::NoteDisplayAttribute *attr2 = attribute.clone();
    QVERIFY(attribute == *attr2);
    delete attr2;

    attribute.setBackgroundColor(QColor("#454545"));
    attribute.setForegroundColor(QColor("#454545"));
    attribute.setSize(QSize(50, 70));
    attribute.setRememberDesktop(false);
    attribute.setTabSize(8);
    attribute.setFont(QFont());
    attribute.setTitleFont(QFont());
    attribute.setDesktop(7);
    attribute.setIsHidden(true);
    attribute.setPosition(QPoint(7, 8));
    attribute.setShowInTaskbar(false);
    attribute.setKeepAbove(false);
    attribute.setKeepBelow(false);
    attribute.setAutoIndent(false);
    attr2 = attribute.clone();
    QVERIFY(attribute == *attr2);
    delete attr2;
}

void NoteDisplayAttributeTest::shouldHaveType()
{
    NoteShared::NoteDisplayAttribute attribute;
    QCOMPARE(attribute.type(), QByteArray("NoteDisplayAttribute"));
}

Laurent Montel's avatar
Laurent Montel committed
76
QTEST_GUILESS_MAIN(NoteDisplayAttributeTest)