kio: test KDirLister::openUrl()

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-07-01 07:14:12 +03:00
parent ce3c7b0195
commit 3849efb2b0
4 changed files with 47 additions and 61 deletions

View file

@ -1,52 +1,48 @@
/* This file is part of the KDE project
Copyright (C) 2007 David Faure <faure@kde.org>
/* This file is part of the KDE libraries
Copyright (C) 2023 Ivailo Monev <xakepa10@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2, as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "kdirlistertest.h"
#include <ktemporaryfile.h>
#include <kdirnotify.h>
#include <kdirlister.h>
#include "kdebug.h"
#include <qtest_kde.h>
#include "kiotesthelper.h"
QTEST_KDEMAIN(KDirListerTest, NoGUI)
#include <kdebug.h>
#include "kiotesthelper.h"
#include <kio/deletejob.h>
#include <kdirwatch.h>
#include <kio/job.h>
#include <kio/copyjob.h>
void KDirListerTest::initTestCase()
{
// Must be done before the QSignalSpys connect
qRegisterMetaType<KUrl>();
qRegisterMetaType<KFileItem>();
qRegisterMetaType<KFileItemList>();
m_tempDir = new KTempDir();
m_dirLister = new KDirLister();
qDebug() << Q_FUNC_INFO << m_tempDir->name();
}
void KDirListerTest::cleanup()
void KDirListerTest::cleanupTestCase()
{
delete m_dirLister;
m_dirLister = nullptr;
delete m_tempDir;
m_tempDir = nullptr;
}
void KDirListerTest::testOpenUrl()
{
// TODO:
m_dirLister->openUrl(KUrl(m_tempDir->name()));
QTest::kWaitForSignal(m_dirLister, SIGNAL(completed()), 5000);
}
#include "moc_kdirlistertest.cpp"

View file

@ -1,46 +1,39 @@
/* This file is part of the KDE project
Copyright (C) 2007 David Faure <faure@kde.org>
/* This file is part of the KDE libraries
Copyright (C) 2023 Ivailo Monev <xakepa10@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2, as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KDIRLISTERTEST_H
#define KDIRLISTERTEST_H
#include <QSignalSpy>
#include <QObject>
#include <QEventLoop>
#include <QDateTime>
#include <QTimer>
#include <ktempdir.h>
#include <kdirlister.h>
Q_DECLARE_METATYPE(KFileItemList)
#include "ktempdir.h"
#include "kdirlister.h"
class KDirListerTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void cleanup();
void cleanupTestCase();
void testOpenUrl();
private:
KTempDir m_tempDir;
KTempDir* m_tempDir;
KDirLister* m_dirLister;
};
#endif
#endif // KDIRLISTERTEST_H

View file

@ -35,12 +35,9 @@
QTEST_KDEMAIN(KDirModelTest, NoGUI)
Q_DECLARE_METATYPE(KFileItemList)
void KDirModelTest::initTestCase()
{
qRegisterMetaType<QModelIndex>("QModelIndex");
qRegisterMetaType<KFileItemList>("KFileItemList");
m_tempDir = new KTempDir();
m_dirModel = new KDirModel();

View file

@ -34,8 +34,8 @@ private Q_SLOTS:
void testIndexForItem();
private:
KDirModel* m_dirModel;
KTempDir* m_tempDir;
KDirModel* m_dirModel;
};
#endif // KDIRMODELTEST_H