File: GeoDataTreeModelTest.cpp

package info (click to toggle)
marble 4%3A25.08.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 159,996 kB
  • sloc: cpp: 191,890; xml: 39,908; ansic: 7,204; python: 2,190; sh: 1,187; makefile: 235; perl: 218; ruby: 97; java: 66
file content (75 lines) | stat: -rw-r--r-- 1,861 bytes parent folder | download | duplicates (2)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// SPDX-License-Identifier: LGPL-2.1-or-later
//
// SPDX-FileCopyrightText: 2014 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
//

#include <QTest>

#include "GeoDataTreeModel.h"

#include "GeoDataDocument.h"
#include "GeoDataPlacemark.h"

namespace Marble
{

class GeoDataTreeModelTest : public QObject
{
    Q_OBJECT

private Q_SLOTS:
    void defaultConstructor();
    void setRootDocument();
    void addDocument();
};

void GeoDataTreeModelTest::defaultConstructor()
{
    const GeoDataTreeModel model;

    QCOMPARE(model.rowCount(), 0);
    QCOMPARE(model.columnCount(), 4);

    QCOMPARE(model.headerData(0, Qt::Horizontal, Qt::DisplayRole), QVariant(tr("Name")));
    QCOMPARE(model.headerData(1, Qt::Horizontal, Qt::DisplayRole), QVariant(tr("Type")));
    QCOMPARE(model.headerData(2, Qt::Horizontal, Qt::DisplayRole), QVariant(tr("Popularity")));
    QCOMPARE(model.headerData(3, Qt::Horizontal, Qt::DisplayRole), QVariant(tr("PopIndex", "Popularity index")));

    QCOMPARE(model.index(0, 0), QModelIndex());
    QCOMPARE(model.index(nullptr), QModelIndex());
    QCOMPARE(model.parent(QModelIndex()), QModelIndex());
    QCOMPARE(model.data(QModelIndex(), Qt::DisplayRole), QVariant());
    QCOMPARE(model.flags(QModelIndex()), Qt::NoItemFlags);

    QVERIFY(const_cast<GeoDataTreeModel *>(&model)->rootDocument() != nullptr);
}

void GeoDataTreeModelTest::setRootDocument()
{
    GeoDataDocument document;

    {
        GeoDataTreeModel model;

        model.setRootDocument(&document);
        // ~GeoDataTreeModel() shouldn't delete document
    }
}

void GeoDataTreeModelTest::addDocument()
{
    {
        auto document = new GeoDataDocument;

        GeoDataTreeModel model;

        model.addDocument(document);
        QCOMPARE(model.rowCount(), 1);
    }
}

}

QTEST_MAIN(Marble::GeoDataTreeModelTest)

#include "GeoDataTreeModelTest.moc"