File indexing completed on 2025-04-27 10:01:36
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2012 Bernhard Beschow <bbeschow@cs.tu-berlin.de> 0004 // 0005 0006 #include <QSignalSpy> 0007 0008 #include "BookmarkManager.h" 0009 #include "GeoDataFolder.h" 0010 #include "GeoDataTreeModel.h" 0011 #include "TestUtils.h" 0012 0013 namespace Marble 0014 { 0015 0016 class BookmarkManagerTest : public QObject 0017 { 0018 Q_OBJECT 0019 0020 private Q_SLOTS: 0021 void construct(); 0022 0023 void loadFile_data(); 0024 void loadFile(); 0025 }; 0026 0027 void BookmarkManagerTest::construct() 0028 { 0029 GeoDataTreeModel model; 0030 0031 QCOMPARE( model.rowCount(), 0 ); 0032 0033 { 0034 const BookmarkManager manager( &model ); 0035 0036 QCOMPARE( model.rowCount(), 1 ); 0037 0038 QVERIFY( manager.document() != nullptr ); 0039 QCOMPARE( manager.folders().count(), 1 ); 0040 QCOMPARE( manager.folders().first()->size(), 0 ); 0041 QCOMPARE( manager.showBookmarks(), true ); 0042 0043 // FIXME this method returns random results (depending on the username and the existence of the bookmarks file) 0044 // QCOMPARE( manager.bookmarkFile(), QString() ); 0045 0046 QCOMPARE( model.rowCount(), 1 ); 0047 } 0048 0049 QCOMPARE( model.rowCount(), 0 ); 0050 } 0051 0052 void BookmarkManagerTest::loadFile_data() 0053 { 0054 QTest::addColumn<QString>( "relativePath" ); 0055 QTest::addColumn<bool>( "expected" ); 0056 0057 addRow() << QString() << false; 0058 addRow() << QString( "lsdkrfuweqofn.kml" ) << false; // non-existing file 0059 0060 // FIXME This will create an empty KML file called "LICENSE.txt" under MarbleDirs::localPath(). 0061 // addRow() << QString( "LICENSE.txt" ) << true; // file exists in MarbleDirs::systemPath() 0062 } 0063 0064 void BookmarkManagerTest::loadFile() 0065 { 0066 QFETCH( QString, relativePath ); 0067 QFETCH( bool, expected ); 0068 0069 GeoDataTreeModel model; 0070 BookmarkManager manager( &model ); 0071 0072 QVERIFY( model.rowCount() == 1 ); 0073 0074 const bool fileLoaded = manager.loadFile( relativePath ); 0075 0076 QCOMPARE( fileLoaded, expected ); 0077 QVERIFY( manager.document() != nullptr ); 0078 0079 QCOMPARE( model.rowCount(), 1 ); 0080 } 0081 0082 } 0083 0084 QTEST_MAIN( Marble::BookmarkManagerTest ) 0085 0086 #include "BookmarkManagerTest.moc"