diff options
author | mio <stigma@disroot.org> | 2025-03-23 23:21:07 +1000 |
---|---|---|
committer | mio <stigma@disroot.org> | 2025-03-23 23:21:07 +1000 |
commit | 07b2986480b5c85d26facaf4d1f03a5d71c06784 (patch) | |
tree | 00c929ba5a0d4af07d769dada5740bfdf07c03ff | |
parent | 81d428dedb2fa9f14ddef3edfa4d68c0d58af528 (diff) | |
download | tdepim-07b2986480b5c85d26facaf4d1f03a5d71c06784.tar.gz tdepim-07b2986480b5c85d26facaf4d1f03a5d71c06784.zip |
akregator/librss: Fix autotest failure
The tests would fail when building packages since TDEIO::Job seems to
depend on either the GUI being active? Perhaps it's more to do with
TDEInstance...
See: https://mirror.git.trinitydesktop.org/gitea/gitea/TDE/tdepim/pulls/152#issuecomment-68688
Signed-off-by: mio <stigma@disroot.org>
-rw-r--r-- | akregator/src/librss/testlibrss.cpp | 51 | ||||
-rw-r--r-- | akregator/src/librss/testlibrss.h | 20 |
2 files changed, 65 insertions, 6 deletions
diff --git a/akregator/src/librss/testlibrss.cpp b/akregator/src/librss/testlibrss.cpp index ed75069d..5e298ea3 100644 --- a/akregator/src/librss/testlibrss.cpp +++ b/akregator/src/librss/testlibrss.cpp @@ -1,6 +1,7 @@ #include "testlibrss.h" #include <tqdatetime.h> +#include <tqfile.h> #include <tdeaboutdata.h> #include <tdecmdlineargs.h> @@ -11,8 +12,48 @@ #include "image.h" #include "enclosure.h" +#include <cstdlib> + using namespace RSS; + +TestRetriever::TestRetriever() + : m_errorCode(0) +{ +} + +TestRetriever::~TestRetriever() +{ +} + +void TestRetriever::retrieveData(const KURL &url) +{ + // Test files are local paths + TQFile file(url.path()); + if (file.open(IO_ReadOnly)) + { + TQStringList lines; + TQTextStream stream(&file); + + while (!stream.atEnd()) + { + lines += stream.readLine(); + } + file.close(); + + TQCString content = lines.join("\n").local8Bit(); + TQByteArray data; + data.duplicate(content, content.length()); + emit dataRetrieved(data, true); + } + else + { + kdError() << "Failed to retrieveData: " << file.errorString() << endl; + m_errorCode = file.status(); + emit dataRetrieved(TQByteArray{}, false); + } +} + static const TDECmdLineOptions options[] = { { "+url", I18N_NOOP("URL of feed"), 0 }, @@ -164,15 +205,15 @@ void Tester::test( const TQString &url ) Loader *loader = Loader::create(); connect( loader, TQ_SIGNAL( loadingComplete( Loader *, Document, Status ) ), this, TQ_SLOT( slotLoadingComplete( Loader *, Document, Status ) ) ); - loader->loadFrom( url, new FileRetriever ); + loader->loadFrom( url, new TestRetriever ); } void Tester::slotLoadingComplete( Loader *loader, Document doc, Status status ) { if (status != Success) { - kdError() << "Failed to load Document " << loader->errorCode() << endl; - tdeApp->exit(1); + kdError() << "Failed to load Document: ec=" << loader->errorCode() << " status=" << status << endl; + exit(1); } switch (doc.version()) @@ -200,7 +241,7 @@ void Tester::slotLoadingComplete( Loader *loader, Document doc, Status status ) break; } kdError() << "Unknown RSS 2.0 document '" << doc.title() << "'" << endl; - tqApp->exit(1); + exit(1); } case RSS::vAtom_1_0: { @@ -213,7 +254,7 @@ void Tester::slotLoadingComplete( Loader *loader, Document doc, Status status ) } } - tdeApp->quit(); + exit(0); } int main( int argc, char **argv ) diff --git a/akregator/src/librss/testlibrss.h b/akregator/src/librss/testlibrss.h index 2a918a5b..fdbccbd1 100644 --- a/akregator/src/librss/testlibrss.h +++ b/akregator/src/librss/testlibrss.h @@ -15,7 +15,7 @@ using RSS::Status; class Tester : public TQObject { TQ_OBJECT - + public: void test( const TQString &url ); @@ -23,4 +23,22 @@ class Tester : public TQObject void slotLoadingComplete( Loader *loader, Document doc, Status status ); }; +class TestRetriever : public RSS::DataRetriever +{ + TQ_OBJECT + +public: + TestRetriever(); + ~TestRetriever() override; + + void retrieveData(const KURL &url) override; + + int errorCode() const override { return m_errorCode; } + + void abort() override { /* no-op */ } + +private: + int m_errorCode; +}; + #endif |