File: MarbleWidgetTest.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 (142 lines) | stat: -rw-r--r-- 3,317 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// SPDX-License-Identifier: LGPL-2.1-or-later
//
// SPDX-FileCopyrightText: 2008 Patrick Spendrin <ps_ml@gmx.de>
//

#include "MarbleWidget.h"
#include "MarbleDirs.h"
#include "TestUtils.h"
#include <QTestEvent>
#include <QtGui>

#include "qtest_widgets.h"
#include "qtestmouse.h"

namespace Marble
{

class MarbleWidgetTest : public QObject
{
    Q_OBJECT

private Q_SLOTS:
    void initTestCase(); // will be called before the first testfunction is executed.
    void cleanupTestCase()
    {
    } // will be called after the last testfunction was executed.
    void init()
    {
    } // will be called before each testfunction is executed.
    void cleanup()
    {
    } // will be called after every testfunction.

    void mouseMove();

    void setMapTheme_data();
    void setMapTheme();

    void switchMapThemes();

    void paintEvent_data();
    void paintEvent();

    void runMultipleWidgets();
};

void MarbleWidgetTest::initTestCase()
{
    MarbleDirs::setMarbleDataPath(DATA_PATH);
    MarbleDirs::setMarblePluginPath(PLUGIN_PATH);
}

void MarbleWidgetTest::mouseMove()
{
    MarbleWidget widget;
    widget.setMapThemeId("earth/srtm/srtm.dgml");

    QTest::mouseMove(&widget);

    QThreadPool::globalInstance()->waitForDone(); // wait for all runners to terminate
}

void MarbleWidgetTest::setMapTheme_data()
{
    QTest::addColumn<QString>("mapThemeId");

    addRow() << "earth/plain/plain.dgml";
    addRow() << "earth/srtm/srtm.dgml";
    addRow() << "earth/openstreetmap/openstreetmap.dgml";
}

void MarbleWidgetTest::setMapTheme()
{
    QFETCH(QString, mapThemeId);

    MarbleWidget widget;

    widget.setMapThemeId(mapThemeId);

    QCOMPARE(widget.mapThemeId(), mapThemeId);

    QThreadPool::globalInstance()->waitForDone(); // wait for all runners to terminate
}

void MarbleWidgetTest::switchMapThemes()
{
    MarbleWidget widget;

    widget.setMapThemeId("earth/plain/plain.dgml");
    QCOMPARE(widget.mapThemeId(), QString("earth/plain/plain.dgml"));

    widget.setMapThemeId("earth/srtm/srtm.dgml");
    QCOMPARE(widget.mapThemeId(), QString("earth/srtm/srtm.dgml"));

    widget.setMapThemeId("earth/openstreetmap/openstreetmap.dgml");
    QCOMPARE(widget.mapThemeId(), QString("earth/openstreetmap/openstreetmap.dgml"));

    widget.setMapThemeId("earth/plain/plain.dgml");
    QCOMPARE(widget.mapThemeId(), QString("earth/plain/plain.dgml"));

    QThreadPool::globalInstance()->waitForDone(); // wait for all runners to terminate
}

void MarbleWidgetTest::paintEvent_data()
{
    QTest::addColumn<QString>("mapThemeId");

    addRow() << "earth/plain/plain.dgml";
    addRow() << "earth/srtm/srtm.dgml";
    addRow() << "earth/openstreetmap/openstreetmap.dgml";
}

void MarbleWidgetTest::paintEvent()
{
    QFETCH(QString, mapThemeId);

    MarbleWidget widget;

    widget.setMapThemeId(mapThemeId);
    widget.resize(200, 200);

    QCOMPARE(widget.mapThemeId(), mapThemeId);

    widget.repaint();

    QThreadPool::globalInstance()->waitForDone(); // wait for all runners to terminate
}

void MarbleWidgetTest::runMultipleWidgets()
{
    MarbleWidget widget1;
    MarbleWidget widget2;

    QCOMPARE(widget1.mapThemeId(), widget2.mapThemeId());
    QThreadPool::globalInstance()->waitForDone();
}

}

QTEST_MAIN(Marble::MarbleWidgetTest)

#include "MarbleWidgetTest.moc"