File: MarbleWidgetSpeedTest.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 (95 lines) | stat: -rw-r--r-- 2,652 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
// SPDX-License-Identifier: LGPL-2.1-or-later
//
// SPDX-FileCopyrightText: 2006-2007 Torsten Rahn <tackat@kde.org>
// SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org>
// SPDX-FileCopyrightText: 2007 Tim Sutton <tim@linfiniti.com>
//

#include "MarbleDirs.h"
#include "MarbleWidget.h"
#include <QApplication>

#include <QElapsedTimer>
#include <QTest>
#include <QtCore>
#include <QtGui> //needed because this is a gui test

namespace Marble
{

class MarbleWidgetSpeedTest : public QObject
{
    Q_OBJECT
private Q_SLOTS:
    void timeTest();
    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.
private:
    MarbleWidget *m_marbleWidget;
};

void MarbleWidgetSpeedTest::initTestCase()
{
    MarbleDirs::setMarbleDataPath(DATA_PATH);
    MarbleDirs::setMarblePluginPath(PLUGIN_PATH);
    m_marbleWidget = new MarbleWidget();
    m_marbleWidget->show();
}
void MarbleWidgetSpeedTest::cleanupTestCase()
{
    delete m_marbleWidget;
}
void MarbleWidgetSpeedTest::timeTest()
{
    m_marbleWidget->setMapThemeId("plain/plain.dgml");
    m_marbleWidget->setZoom(1500);
    //    m_marbleWidget->resize( 800, 600 );

    QElapsedTimer t;
    // m_marbleWidget->setMapTheme( "plain/plain.dgml" );
    // m_marbleWidget->setMapTheme( "bluemarble/bluemarble.dgml" );

    /*
        m_marbleWidget->setShowGrid( false );
        m_marbleWidget->setShowPlaces( false );
        m_marbleWidget->setShowBorders( false );
        m_marbleWidget->setShowRivers( false );
        m_marbleWidget->setShowLakes( false );
    */

    t.start();

    for (int j = 0; j < 10; ++j) {
        for (int k = 0; k < 10; ++k) {
            m_marbleWidget->moveRight();
            QCoreApplication::sendPostedEvents();
        }
        for (int k = 0; k < 10; ++k) {
            m_marbleWidget->moveLeft();
            QCoreApplication::sendPostedEvents();
        }
    }

    // required maximum elapsed time for test to pass
    QVERIFY(t.elapsed() < 10);
    // required frames per second for test to pass
    // redundant with above really but I leave it in
    // for now...
    auto fps = (uint)(200.0 * 1000.0 / (double)(t.elapsed()));
    QVERIFY(fps > 10);
}

}

// QTEST_MAIN(MarbleWidgetSpeedTest)
int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    Marble::MarbleWidgetSpeedTest speedTest;
    QTest::qExec(&speedTest);
    return 0;
}

#include "MarbleWidgetSpeedTest.moc"