summaryrefslogtreecommitdiffstats
path: root/tdeio/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tdeio/tests')
-rw-r--r--tdeio/tests/CMakeLists.txt40
-rw-r--r--tdeio/tests/dataprotocoltest.cpp4
-rw-r--r--tdeio/tests/getalltest.cpp2
-rw-r--r--tdeio/tests/jobtest.cpp2
-rw-r--r--tdeio/tests/kacltest.cpp2
-rw-r--r--tdeio/tests/kdcopcheck.cpp6
-rw-r--r--tdeio/tests/kdefaultprogresstest.cpp2
-rw-r--r--tdeio/tests/kdirlistertest.cpp2
-rw-r--r--tdeio/tests/kmimetypetest.cpp21
-rw-r--r--tdeio/tests/kprotocolinfotest.cpp2
-rw-r--r--tdeio/tests/kruntest.cpp16
-rw-r--r--tdeio/tests/kscantest.cpp4
-rw-r--r--tdeio/tests/kurifiltertest.cpp14
-rw-r--r--tdeio/tests/kurlcompletiontest.cpp2
-rw-r--r--tdeio/tests/netaccesstest.cpp2
-rw-r--r--tdeio/tests/previewtest.cpp2
-rw-r--r--tdeio/tests/tdeioslavetest.cpp2
-rw-r--r--tdeio/tests/tdesycocatest.cpp6
-rw-r--r--tdeio/tests/tdesycocaupdatetest.cpp2
19 files changed, 92 insertions, 41 deletions
diff --git a/tdeio/tests/CMakeLists.txt b/tdeio/tests/CMakeLists.txt
index a9f6bd4ef..b8b9a411a 100644
--- a/tdeio/tests/CMakeLists.txt
+++ b/tdeio/tests/CMakeLists.txt
@@ -11,8 +11,14 @@
include_directories(
${TQT_INCLUDE_DIRS}
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_SOURCE_DIR}/dcop
${CMAKE_BINARY_DIR}/tdecore
${CMAKE_SOURCE_DIR}/tdecore
+ ${CMAKE_SOURCE_DIR}/tdeui
+ ${CMAKE_SOURCE_DIR}/tdeio
+ ${CMAKE_SOURCE_DIR}/tdeio/tdefile
${CMAKE_SOURCE_DIR}/tdeio/tdeio
)
@@ -34,3 +40,37 @@ tde_add_executable( ${target}
LINK tdeio-shared
DESTINATION ${BIN_INSTALL_DIR}
)
+
+
+##### check and test ##############################
+
+# Force assertions to work
+add_definitions( -UNDEBUG )
+
+set( CHECKS
+ getalltest jobtest kdcopcheck kdefaultprogresstest kdirlistertest
+ kdirwatchtest kfiltertest kionetrctest kiopassdlgtest kmfitest kmimefromext
+ kmimemagictest kpropsdlgtest kprotocolinfotest kruntest kscantest kshredtest
+ ktartest kurifiltertest kurlcompletiontest kziptest metatest netaccesstest
+ previewtest speed tdeioslavetest tdesycocatest tdesycocaupdatetest
+)
+
+foreach( _check ${CHECKS} )
+ tde_add_check_executable( ${_check} AUTOMOC LINK tdeio-shared )
+endforeach( )
+
+# NOTE some apps here are suitable to be run as tests but not included due to
+# following reasons:
+# - jobtest may fail if run on an unusual system configuration
+# and requires GUI
+# - kprotocolinfotest tries to connect to network and requires running DCOP
+# - kurifiltertest requires network access and GUI
+# - tdesycocatest requires installed tdebase and GUI
+
+set( TESTS dataprotocoltest kacltest kmimetypetest )
+
+foreach( _check ${TESTS} )
+ tde_add_check_executable( ${_check} AUTOMOC LINK tdeio-shared TEST)
+endforeach( )
+
+# TODO add kdirwatchunittest
diff --git a/tdeio/tests/dataprotocoltest.cpp b/tdeio/tests/dataprotocoltest.cpp
index e9af8574d..2cdcf36d4 100644
--- a/tdeio/tests/dataprotocoltest.cpp
+++ b/tdeio/tests/dataprotocoltest.cpp
@@ -21,7 +21,9 @@
#include <tqcstring.h>
#include <tqstring.h>
-#include <iostream.h>
+#include <iostream>
+
+using namespace std;
class KURL;
diff --git a/tdeio/tests/getalltest.cpp b/tdeio/tests/getalltest.cpp
index 37f9b1ab2..96d39c3c2 100644
--- a/tdeio/tests/getalltest.cpp
+++ b/tdeio/tests/getalltest.cpp
@@ -7,7 +7,7 @@
int main(int argc, char *argv[])
{
- TDEApplication k(argc,argv,"getalltest",false/*noGUI*/); // KMessageBox needs KApp for makeStdCaption
+ TDEApplication k(argc,argv,"getalltest",false/*nostyle*/,false/*noGUI*/); // KMessageBox needs KApp for makeStdCaption
//for (int i = 0 ; i < 2 ; ++i ) { // test twice to see if they got deleted
kdDebug() << "All services" << endl;
diff --git a/tdeio/tests/jobtest.cpp b/tdeio/tests/jobtest.cpp
index 076bc250d..7df3ff3f0 100644
--- a/tdeio/tests/jobtest.cpp
+++ b/tdeio/tests/jobtest.cpp
@@ -200,7 +200,7 @@ void JobTest::get()
kapp->eventLoop()->enterLoop();
assert( m_result == 0 ); // no error
assert( m_data.size() == 11 );
- assert( TQCString( m_data ) == "Hello world" );
+ assert( memcmp (m_data, "Hello world", m_data.size()) == 0 ); // m_data is not null-terminated
}
void JobTest::slotGetResult( TDEIO::Job* job )
diff --git a/tdeio/tests/kacltest.cpp b/tdeio/tests/kacltest.cpp
index 50d3bc25a..94aa31f9f 100644
--- a/tdeio/tests/kacltest.cpp
+++ b/tdeio/tests/kacltest.cpp
@@ -69,7 +69,7 @@ int main(int argc, char *argv[])
{
TDEApplication::disableAutoDcopRegistration();
TDECmdLineArgs::init(argc,argv,"kacltest", 0, 0, 0, 0);
- TDEApplication app;
+ TDEApplication app(/*styles=*/false, /*gui=*/false);
KACLTest test;
test.setup();
diff --git a/tdeio/tests/kdcopcheck.cpp b/tdeio/tests/kdcopcheck.cpp
index 5f1ad611a..e99de7e79 100644
--- a/tdeio/tests/kdcopcheck.cpp
+++ b/tdeio/tests/kdcopcheck.cpp
@@ -90,14 +90,14 @@ int TestService::exec()
int main(int argc, char *argv[])
{
- putenv("IGNORE_SYCOCA_VERSION=true");
- TDEApplication k(argc,argv,"whatever",false/*noGUI*/); // KMessageBox needs KApp for makeStdCaption
+ setenv("IGNORE_SYCOCA_VERSION", "true", true);
+ TDEApplication k(argc,argv,"whatever",false/*nostyle*/,false/*noGUI*/); // KMessageBox needs KApp for makeStdCaption
k.dcopClient()->setNotifications(true);
KService::List list = KService::allServices();
- tqWarning("I found %d services.", list.count());
+ tqWarning("I found %ld services.", list.count());
int i = 0;
for(KService::List::ConstIterator it = list.begin(); it != list.end(); ++it)
{
diff --git a/tdeio/tests/kdefaultprogresstest.cpp b/tdeio/tests/kdefaultprogresstest.cpp
index 7f1bad6a4..b3f778772 100644
--- a/tdeio/tests/kdefaultprogresstest.cpp
+++ b/tdeio/tests/kdefaultprogresstest.cpp
@@ -7,7 +7,7 @@ using namespace TDEIO;
int main(int argc, char **argv)
{
- TDEApplication app(argc, argv, "kdefaultprogresstest");
+ TDEApplication app(argc, argv, "kdefaultprogresstest",true,true);
DefaultProgress* dlg = new DefaultProgress();
KURL src("http://this.host.doesn't.exist/this/dir/neither/andthisfileneither");
diff --git a/tdeio/tests/kdirlistertest.cpp b/tdeio/tests/kdirlistertest.cpp
index aaba5400a..b1208f41d 100644
--- a/tdeio/tests/kdirlistertest.cpp
+++ b/tdeio/tests/kdirlistertest.cpp
@@ -151,7 +151,7 @@ void KDirListerTest::completed()
int main ( int argc, char *argv[] )
{
- TDEApplication app( argc, argv, "kdirlistertest" );
+ TDEApplication app( argc, argv, "kdirlistertest", true /*styles*/ );
KDirListerTest *test = new KDirListerTest( 0 );
test->show();
diff --git a/tdeio/tests/kmimetypetest.cpp b/tdeio/tests/kmimetypetest.cpp
index 5d963c81c..631521c8a 100644
--- a/tdeio/tests/kmimetypetest.cpp
+++ b/tdeio/tests/kmimetypetest.cpp
@@ -36,6 +36,17 @@ static void checkIcon( const KURL& url, const TQString& expectedIcon )
}
}
+static void checkExtention( const TQString& fileName, const TQString& expectedExtention ) {
+ TQString ext;
+ KMimeType::diagnoseFileName(fileName, ext);
+ if ( ext == expectedExtention) {
+ tqDebug("extension of %s is '%s: OK'", fileName.latin1(), ext.latin1());
+ } else {
+ tqDebug("extension of %s is '%s, expected %s!'", fileName.latin1(), ext.latin1(), expectedExtention.latin1());
+ exit(1);
+ }
+}
+
int main( int argc, char** argv )
{
TDEInstance blah("kmimetypetest");
@@ -63,14 +74,8 @@ int main( int argc, char** argv )
checkIcon( "trash:/foo/", "folder" );
}
- TQString pdf;
- KMimeType::diagnoseFileName("foo.pdf", pdf);
- tqDebug("extension: '%s'", pdf.latin1());
- assert(pdf == TQString("*.pdf"));
- TQString ps;
- KMimeType::diagnoseFileName("foo.ps", ps);
- tqDebug("extension: '%s'", ps.latin1());
- assert(ps == TQString("*.ps"));
+ checkExtention(TQString::fromLatin1("foo.pdf"), TQString::fromLatin1("*.pdf"));
+ checkExtention(TQString::fromLatin1("foo.ps"), TQString::fromLatin1("*.ps"));
return 0;
}
diff --git a/tdeio/tests/kprotocolinfotest.cpp b/tdeio/tests/kprotocolinfotest.cpp
index 9b5242d65..d951f3696 100644
--- a/tdeio/tests/kprotocolinfotest.cpp
+++ b/tdeio/tests/kprotocolinfotest.cpp
@@ -30,7 +30,7 @@ int main(int argc, char **argv) {
"1.0");
TDECmdLineArgs::init(argc, argv, &aboutData);
- TDEApplication app;
+ TDEApplication app(/*styles=*/false, /*gui=*/false);
KURL url;
url.setPath("/tmp");
diff --git a/tdeio/tests/kruntest.cpp b/tdeio/tests/kruntest.cpp
index f2065f8b8..7562b488a 100644
--- a/tdeio/tests/kruntest.cpp
+++ b/tdeio/tests/kruntest.cpp
@@ -121,7 +121,7 @@ void checkPDE(const KService &service, const KURL::List &urls, bool hs, bool tf,
int main(int argc, char **argv)
{
- TDEApplication app( argc, argv, "kruntest", true /* it _has_ a GUI ! */);
+ TDEApplication app( argc, argv, "kruntest", true /*styles*/, true /* it _has_ a GUI ! */);
// First some non-interactive tests
checkBN( "/usr/bin/ls", true, "ls");
@@ -164,16 +164,16 @@ int main(int argc, char **argv)
for (int te = 0; te < 2; te++)
for (int ex = 0; ex < 2; ex++) {
int fd = creat("kruntest.desktop", 0666);
- FILE *f;
+ FILE *f;
if (fd < 0) abort();
- f = KDE_fdopen(fd, "w");
+ f = KDE_fdopen(fd, "w");
fprintf(f, "[Desktop Entry]\n"
- "Type=Application\n"
- "Name=just_a_test\n"
- "Icon=~/icon.png\n"
- "%s\n%s\n%s\n",execs[ex],terms[te],sus[su]);
+ "Type=Application\n"
+ "Name=just_a_test\n"
+ "Icon=~/icon.png\n"
+ "%s\n%s\n%s\n",execs[ex],terms[te],sus[su]);
close(fd);
- fclose(f);
+ fclose(f);
KService s(TQDir::currentDirPath() + "/kruntest.desktop");
unlink("kruntest.desktop");
checkPDE( s, l0, hs, false, rslts[ex+te*2+su*4+hs*8]);
diff --git a/tdeio/tests/kscantest.cpp b/tdeio/tests/kscantest.cpp
index d37f2eb97..f28635c1c 100644
--- a/tdeio/tests/kscantest.cpp
+++ b/tdeio/tests/kscantest.cpp
@@ -3,11 +3,11 @@
int main( int argc, char **argv )
{
- TDEApplication app( argc, argv, "kscantest" );
+ TDEApplication app( argc, argv, "kscantest", true, true );
KScanDialog *dlg = KScanDialog::getScanDialog();
if ( !dlg ) {
tqDebug("*** EEK, no Scan-service available, aborting!");
- return 0;
+ return EXIT_FAILURE;
}
dlg->show();
diff --git a/tdeio/tests/kurifiltertest.cpp b/tdeio/tests/kurifiltertest.cpp
index 5cc79bd82..d9f6cdf87 100644
--- a/tdeio/tests/kurifiltertest.cpp
+++ b/tdeio/tests/kurifiltertest.cpp
@@ -155,14 +155,14 @@ int main(int argc, char **argv)
{
// Ensure that user configuration doesn't change the results of those tests
// TDEHOME needs to be writable though, for a tdesycoca database
- setenv( "TDEHOME", TQFile::encodeName( TQDir::homeDirPath() + "/.tde-kurifiltertest" ), true );
+ setenv( "TDEHOME", TQFile::encodeName( TQDir::currentDirPath() + "/.tde-kurifiltertest" ), true );
setenv( "TDE_FORK_SLAVES", "yes", true ); // simpler, for the final cleanup
TDEAboutData aboutData(appName, programName, version, description);
TDECmdLineArgs::init(argc, argv, &aboutData);
TDECmdLineArgs::addCmdLineOptions( options );
- TDEApplication app;
+ TDEApplication app; // it _is_ GUI app
app.disableAutoDcopRegistration();
// Allow testing of the search engine using both delimiters...
@@ -294,7 +294,9 @@ int main(int argc, char **argv)
filter( "$SOMEVAR/tdelibs/tdeio", 0, KURIFilterData::ERROR ); // note: this dir doesn't exist...
filter( "$ETC/passwd", "/etc/passwd", KURIFilterData::LOCAL_FILE );
- filter( "$QTDIR/doc/html/functions.html#s", TQCString("file://")+qtdir+"/doc/html/functions.html#s", KURIFilterData::LOCAL_FILE );
+ if( !qtdir.isEmpty() ) {
+ filter( "$QTDIR/doc/html/functions.html#s", TQCString("file://")+qtdir+"/doc/html/functions.html#s", KURIFilterData::LOCAL_FILE );
+ }
filter( "http://www.kde.org/$USER", "http://www.kde.org/$USER", KURIFilterData::NET_PROTOCOL ); // no expansion
// Assume the default (~/.trinity) if
@@ -333,13 +335,15 @@ int main(int argc, char **argv)
// the shortURI filter will return the string
// itself if the requested environment variable
// is not already set.
- filter( "$QTDIR", 0, KURIFilterData::LOCAL_DIR, "tdeshorturifilter" ); //use specific filter.
+ if( !qtdir.isEmpty() ) {
+ filter( "$QTDIR", 0, KURIFilterData::LOCAL_DIR, "tdeshorturifilter" ); //use specific filter.
+ }
filter( "$HOME", home, KURIFilterData::LOCAL_DIR, "tdeshorturifilter" ); //use specific filter.
TQCString sc;
filter( sc.sprintf("gg%cfoo bar",delimiter), "http://www.google.com/search?q=foo+bar&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL );
- filter( sc.sprintf("bug%c55798", delimiter), "http://bugs.kde.org/show_bug.cgi?id=55798", KURIFilterData::NET_PROTOCOL );
+ filter( sc.sprintf("bug%c55798", delimiter), "http://bugs.pearsoncomputing.net/show_bug.cgi?id=55798", KURIFilterData::NET_PROTOCOL );
filter( sc.sprintf("gg%cC++", delimiter), "http://www.google.com/search?q=C%2B%2B&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL );
filter( sc.sprintf("ya%cfoo bar was here", delimiter), 0, -1 ); // this triggers default search, i.e. google
diff --git a/tdeio/tests/kurlcompletiontest.cpp b/tdeio/tests/kurlcompletiontest.cpp
index 7d479d156..fada144d5 100644
--- a/tdeio/tests/kurlcompletiontest.cpp
+++ b/tdeio/tests/kurlcompletiontest.cpp
@@ -166,7 +166,7 @@ int main( int argc, char **argv )
{
TDEApplication::disableAutoDcopRegistration();
TDECmdLineArgs::init(argc,argv,"kurlcompletiontest", 0, 0, 0, 0);
- TDEApplication app;
+ TDEApplication app(/*styles=*/false, /*gui=*/false);
{
KURLCompletionTest test;
diff --git a/tdeio/tests/netaccesstest.cpp b/tdeio/tests/netaccesstest.cpp
index b9b0ffab7..12404945b 100644
--- a/tdeio/tests/netaccesstest.cpp
+++ b/tdeio/tests/netaccesstest.cpp
@@ -24,7 +24,7 @@
int main(int argc, char **argv)
{
- TDEApplication app( argc, argv, "netaccesstest", true /* it _has_ a GUI ! */);
+ TDEApplication app( argc, argv, "netaccesstest", true /*styles*/, true /* it _has_ a GUI ! */);
KURL srcURL( "ftp://ftp.kde.org/pub/kde/README" );
KURL tmpURL( "file:/tmp/netaccesstest_README" );
diff --git a/tdeio/tests/previewtest.cpp b/tdeio/tests/previewtest.cpp
index 6d0cd78b2..3237f0180 100644
--- a/tdeio/tests/previewtest.cpp
+++ b/tdeio/tests/previewtest.cpp
@@ -55,7 +55,7 @@ void PreviewTest::slotFailed()
int main(int argc, char **argv)
{
- TDEApplication app(argc, argv, "previewtest");
+ TDEApplication app(argc, argv, "previewtest", true, true);
PreviewTest *w = new PreviewTest;
w->show();
app.setMainWidget(w);
diff --git a/tdeio/tests/tdeioslavetest.cpp b/tdeio/tests/tdeioslavetest.cpp
index 3cc22d8e2..4d52eab2e 100644
--- a/tdeio/tests/tdeioslavetest.cpp
+++ b/tdeio/tests/tdeioslavetest.cpp
@@ -452,7 +452,7 @@ void KioslaveTest::slotDataReq(TDEIO::Job*, TQByteArray &data)
"Hello world\n",
"This is a test file\n",
"You can safely delete it.\n",
- "BIG\n",
+ "BIG\n",
0
};
const char *fileData = fileDataArray[putBuffer++];
diff --git a/tdeio/tests/tdesycocatest.cpp b/tdeio/tests/tdesycocatest.cpp
index 67b6b55ba..f21402405 100644
--- a/tdeio/tests/tdesycocatest.cpp
+++ b/tdeio/tests/tdesycocatest.cpp
@@ -43,7 +43,7 @@ bool check(TQString txt, TQString a, TQString b)
kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "ok" << endl;
}
else {
- kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "KO !" << endl
+ kdError() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "KO !" << endl
;
exit(1);
}
@@ -52,7 +52,7 @@ bool check(TQString txt, TQString a, TQString b)
void debug(TQString txt)
{
- fprintf(stderr, "%s\n", txt.ascii());
+ fprintf(stderr, "%s\n", txt.utf8().data());
}
void debug(const char *txt)
@@ -67,7 +67,7 @@ void debug(const char *format, const char *txt)
int main(int argc, char *argv[])
{
- TDEApplication k(argc,argv,"whatever",false/*noGUI*/); // KMessageBox needs KApp for makeStdCaption
+ TDEApplication k(argc,argv,"whatever",true); // KMessageBox needs KApp for makeStdCaption
TQCString instname = "kword";
TQString desktopPath = TQString::fromLatin1( "Office/%1.desktop" ).arg( instname );
diff --git a/tdeio/tests/tdesycocaupdatetest.cpp b/tdeio/tests/tdesycocaupdatetest.cpp
index 48a195a00..5b390efa6 100644
--- a/tdeio/tests/tdesycocaupdatetest.cpp
+++ b/tdeio/tests/tdesycocaupdatetest.cpp
@@ -4,7 +4,7 @@
int main(int argc, char *argv[])
{
- TDEApplication k(argc,argv,"whatever"); // KMessageBox needs KApp for makeStdCaption
+ TDEApplication k(argc,argv,"whatever",true,true); // KMessageBox needs KApp for makeStdCaption
KService::rebuildKSycoca(0);
return 0;