File indexing completed on 2024-11-10 06:35:20
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2006-2007 Torsten Rahn <tackat@kde.org> 0004 // SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org> 0005 // SPDX-FileCopyrightText: 2007 Tim Sutton <tim@linfiniti.com> 0006 // 0007 0008 #include <QApplication> 0009 #include "MarbleDirs.h" 0010 #include "MarbleWidget.h" 0011 0012 #include <QtGui> //needed because this is a gui test 0013 #include <QtCore> 0014 #include <QElapsedTimer> 0015 #include <QTest> 0016 0017 namespace Marble 0018 { 0019 0020 class MarbleWidgetSpeedTest: public QObject 0021 { 0022 Q_OBJECT 0023 private Q_SLOTS: 0024 void timeTest(); 0025 void initTestCase();// will be called before the first testfunction is executed. 0026 void cleanupTestCase();// will be called after the last testfunction was executed. 0027 void init(){};// will be called before each testfunction is executed. 0028 void cleanup(){};// will be called after every testfunction. 0029 private: 0030 MarbleWidget *m_marbleWidget; 0031 }; 0032 0033 void MarbleWidgetSpeedTest::initTestCase() 0034 { 0035 MarbleDirs::setMarbleDataPath( DATA_PATH ); 0036 MarbleDirs::setMarblePluginPath( PLUGIN_PATH ); 0037 m_marbleWidget = new MarbleWidget(); 0038 m_marbleWidget->show(); 0039 } 0040 void MarbleWidgetSpeedTest::cleanupTestCase() 0041 { 0042 delete m_marbleWidget; 0043 } 0044 void MarbleWidgetSpeedTest::timeTest() 0045 { 0046 m_marbleWidget->setMapThemeId( "plain/plain.dgml" ); 0047 m_marbleWidget->setZoom( 1500 ); 0048 // m_marbleWidget->resize( 800, 600 ); 0049 0050 QElapsedTimer t; 0051 //m_marbleWidget->setMapTheme( "plain/plain.dgml" ); 0052 //m_marbleWidget->setMapTheme( "bluemarble/bluemarble.dgml" ); 0053 0054 /* 0055 m_marbleWidget->setShowGrid( false ); 0056 m_marbleWidget->setShowPlaces( false ); 0057 m_marbleWidget->setShowBorders( false ); 0058 m_marbleWidget->setShowRivers( false ); 0059 m_marbleWidget->setShowLakes( false ); 0060 */ 0061 0062 t.start(); 0063 0064 for ( int j = 0; j < 10; ++j ) { 0065 for ( int k = 0; k < 10; ++k ) { 0066 m_marbleWidget->moveRight(); 0067 QCoreApplication::flush(); 0068 } 0069 for ( int k = 0; k < 10; ++k ) { 0070 m_marbleWidget->moveLeft(); 0071 QCoreApplication::flush(); 0072 } 0073 } 0074 0075 //required maximum elapsed time for test to pass 0076 QVERIFY(t.elapsed() < 10); 0077 //required frames per second for test to pass 0078 //redundant with above really but I leave it in 0079 //for now... 0080 unsigned int fps = (uint)( 200.0*1000.0/(double)(t.elapsed()) ); 0081 QVERIFY(fps > 10); 0082 0083 } 0084 0085 } 0086 0087 //QTEST_MAIN(MarbleWidgetSpeedTest) 0088 int main( int argc, char ** argv ) 0089 { 0090 QApplication app( argc, argv ); 0091 Marble::MarbleWidgetSpeedTest speedTest; 0092 QTest::qExec( &speedTest ); 0093 return 0; 0094 } 0095 0096 #include "MarbleWidgetSpeedTest.moc"