-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathposteditortest.cpp
61 lines (45 loc) · 2.1 KB
/
posteditortest.cpp
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
50
51
52
53
54
55
56
57
58
59
60
61
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: LGPL-2.1-or-later
#include <QtTest/QtTest>
#include "account/accountmanager.h"
#include "autotests/mockaccount.h"
#include "editor/posteditorbackend.h"
class PostEditorTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase()
{
AccountManager::instance().setTestMode(true);
account = new MockAccount();
AccountManager::instance().addAccount(account);
}
void loadDataTest()
{
PostEditorBackend backend;
backend.setAccount(account);
QCOMPARE(backend.account(), account);
QCOMPARE(backend.charactersLeft(), 500);
const QString status{QStringLiteral("Hello, world!")};
backend.setStatus(status);
QCOMPARE(backend.status(), status);
QCOMPARE(backend.charactersLeft(), 487);
const QString longStatus{QStringLiteral(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Duis ultricies lacus "
"sed turpis tincidunt. Vestibulum lectus mauris ultrices eros. Tristique senectus et netus et malesuada fames ac turpis. Fringilla ut morbi "
"tincidunt augue interdum. Ullamcorper dignissim cras tincidunt lobortis feugiat vivamus at augue eget. Sociis natoque penatibus et magnis dis. Et "
"odio pellentesque diam volutpat commodo. Ligula ullamcorper malesuada proin libero. Curabitur gravida arcu ac tortor dignissim.")};
backend.setStatus(longStatus);
QCOMPARE(backend.charactersLeft(), -57);
const QString urlStatus{QStringLiteral("Lorem ipsum dolor sit amet, https://www.google.com/")};
backend.setStatus(urlStatus);
QCOMPARE(backend.charactersLeft(), 449);
const QString twoUrlStatus{QStringLiteral("https://www.google.com/https://www.google.com/")};
backend.setStatus(twoUrlStatus);
QCOMPARE(backend.charactersLeft(), 477);
}
private:
MockAccount *account = nullptr;
};
QTEST_MAIN(PostEditorTest)
#include "posteditortest.moc"