File indexing completed on 2024-09-08 12:12:08
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2012 Bernhard Beschow <bbeschow@cs.tu-berlin.de> 0004 // 0005 0006 0007 #include "MarbleModel.h" 0008 #include "PluginManager.h" 0009 #include "AbstractDataPlugin.h" 0010 0011 #include <QMetaType> 0012 #include <QTest> 0013 0014 Q_DECLARE_METATYPE( const Marble::AbstractDataPlugin * ) 0015 0016 namespace Marble 0017 { 0018 0019 class AbstractDataPluginTest : public QObject 0020 { 0021 Q_OBJECT 0022 0023 private Q_SLOTS: 0024 void initialize_data(); 0025 void initialize(); 0026 0027 private: 0028 MarbleModel m_model; 0029 }; 0030 0031 void AbstractDataPluginTest::initialize_data() 0032 { 0033 QTest::addColumn<const AbstractDataPlugin *>( "factory" ); 0034 0035 foreach ( const RenderPlugin *plugin, m_model.pluginManager()->renderPlugins() ) { 0036 const AbstractDataPlugin *const dataPlugin = qobject_cast<const AbstractDataPlugin *>( plugin ); 0037 if ( !dataPlugin ) 0038 continue; 0039 0040 QTest::newRow(plugin->nameId().toLatin1().constData()) << dataPlugin; 0041 } 0042 } 0043 0044 void AbstractDataPluginTest::initialize() 0045 { 0046 QFETCH( const AbstractDataPlugin *, factory ); 0047 0048 RenderPlugin *const instance = factory->newInstance( &m_model ); 0049 AbstractDataPlugin *const dataInstance = qobject_cast<AbstractDataPlugin *>( instance ); 0050 0051 QVERIFY( dataInstance != nullptr ); 0052 QVERIFY( dataInstance->model() == nullptr ); 0053 0054 dataInstance->initialize(); 0055 0056 QVERIFY( dataInstance->model() != nullptr ); 0057 } 0058 0059 } 0060 0061 QTEST_MAIN( Marble::AbstractDataPluginTest ) 0062 0063 #include "AbstractDataPluginTest.moc"