kdecore: remove bogus kmimetype_nomimetypes test

the test is for the worse case scenario, i.e. what if /etc/passwd is
missing? in that case the system is borked and should be fixed, that's
not a problem Katana will (or should) solve nor workaround tho

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-12-01 05:50:08 +02:00
parent eb94c30c11
commit c5cf1cc960
2 changed files with 0 additions and 76 deletions

View file

@ -54,7 +54,6 @@ KDECORE_UNIT_TESTS(
kconfigafterkglobaltest2
ksycocathreadtest
qcoreapptest
kmimetype_nomimetypes
kunitconversiontest
kdevicedatabasetest
kdebugtest

View file

@ -1,75 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2011 David Faure <faure@kde.org>
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 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.
*/
#include <QtCore/QCoreApplication>
#include <QtCore/QtGlobal>
#include <kcomponentdata.h>
#include <kmimetype.h>
#include <kmessage.h>
#include <kglobal.h>
#include <kdebug.h>
class KTestMessageHandler : public KMessageHandler
{
public:
virtual void message(KMessage::MessageType type, const QString &text, const QString &caption)
{
Q_UNUSED(type);
Q_UNUSED(caption);
m_messages.append(text);
}
QStringList m_messages;
};
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
// Test what happens when there are no mimetypes installed.
::setenv("XDG_DATA_DIRS", "/doesnotexist", 1);
KComponentData cData("foo");
KTestMessageHandler* msgHandler = new KTestMessageHandler;
KMessage::setMessageHandler(msgHandler);
KMimeType::Ptr s0 = KMimeType::mimeType("application/x-zerosize");
Q_ASSERT(!s0);
if (s0) {
qFatal("application/x-zerosize should NOT be found, otherwise this test is bogus!");
return 1;
}
KMimeType::Ptr mime = KMimeType::findByUrl(KUrl("/"));
Q_ASSERT(mime);
Q_ASSERT(mime->name() == "application/octet-stream");
if (!mime) {
qFatal("application/octet-stream should be found, otherwise this test is bogus!");
return 2;
}
qDebug() << mime->name();
Q_ASSERT(msgHandler->m_messages.count() > 0);
return 0;
}