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
|
// SPDX-License-Identifier: LGPL-2.1-or-later
//
// SPDX-FileCopyrightText: 2012 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
//
#include <QSignalSpy>
#include "BookmarkManager.h"
#include "GeoDataFolder.h"
#include "GeoDataTreeModel.h"
#include "TestUtils.h"
namespace Marble
{
class BookmarkManagerTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void construct();
void loadFile_data();
void loadFile();
};
void BookmarkManagerTest::construct()
{
GeoDataTreeModel model;
QCOMPARE(model.rowCount(), 0);
{
const BookmarkManager manager(&model);
QCOMPARE(model.rowCount(), 1);
QVERIFY(manager.document() != nullptr);
QCOMPARE(manager.folders().count(), 1);
QCOMPARE(manager.folders().first()->size(), 0);
QCOMPARE(manager.showBookmarks(), true);
// FIXME this method returns random results (depending on the username and the existence of the bookmarks file)
// QCOMPARE( manager.bookmarkFile(), QString() );
QCOMPARE(model.rowCount(), 1);
}
QCOMPARE(model.rowCount(), 0);
}
void BookmarkManagerTest::loadFile_data()
{
QTest::addColumn<QString>("relativePath");
QTest::addColumn<bool>("expected");
addRow() << QString() << false;
addRow() << QString("lsdkrfuweqofn.kml") << false; // non-existing file
// FIXME This will create an empty KML file called "LICENSE.txt" under MarbleDirs::localPath().
// addRow() << QString( "LICENSE.txt" ) << true; // file exists in MarbleDirs::systemPath()
}
void BookmarkManagerTest::loadFile()
{
QFETCH(QString, relativePath);
QFETCH(bool, expected);
GeoDataTreeModel model;
BookmarkManager manager(&model);
QVERIFY(model.rowCount() == 1);
const bool fileLoaded = manager.loadFile(relativePath);
QCOMPARE(fileLoaded, expected);
QVERIFY(manager.document() != nullptr);
QCOMPARE(model.rowCount(), 1);
}
}
QTEST_MAIN(Marble::BookmarkManagerTest)
#include "BookmarkManagerTest.moc"
|