tdeio: add tests

Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
(cherry picked from commit ed74769bfa)
v3.5.13-sru
Alexander Golubev 8 years ago committed by Slávek Banko
parent a6435d8bbc
commit 933dc8a3f8

@ -9,6 +9,8 @@
#
#################################################
add_subdirectory( tests )
include_directories(
${TQT_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}

@ -0,0 +1,40 @@
#################################################
#
# (C) 2016 Alexander Golubev
# fatzer2 (AT) gmail.com
#
# Improvements and feedback are welcome
#
# This file is released under GPL >= 2
#
#################################################
include_directories(
${TQT_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/dcop
${CMAKE_BINARY_DIR}/kdecore
${CMAKE_SOURCE_DIR}/kdecore
${CMAKE_SOURCE_DIR}/kdeui
${CMAKE_SOURCE_DIR}/kio
${CMAKE_SOURCE_DIR}/kio/kfile
${CMAKE_SOURCE_DIR}/kio/kio
${CMAKE_BINARY_DIR}/kio/kfile
)
link_directories(
${TDECORE_LIBRARY_DIRS}
)
tde_add_check_executable( kurlrequestertest LINK kio-shared )
tde_add_check_executable( kopenwithtest LINK kio-shared )
tde_add_check_executable( kdirselectdialogtest LINK kio-shared )
tde_add_check_executable( kicondialogtest LINK kio-shared )
tde_add_check_executable( kcustommenueditortest LINK kio-shared )
tde_add_check_executable( kfilenotifytest LINK kio-shared )
tde_add_check_executable( kfiletreeviewtest AUTOMOC LINK kio-shared )
tde_add_check_executable( kfstest AUTOMOC
SOURCES kfstest.cpp kfdtest.cpp LINK kio-shared )

@ -6,7 +6,7 @@
int main(int argc, char** argv)
{
KLocale::setMainCatalogue("kdelibs");
KApplication app(argc, argv, "KCustomMenuEditorTest");
KApplication app(argc, argv, "KCustomMenuEditorTest", true);
KCustomMenuEditor editor(0);
KConfig *cfg = new KConfig("kdesktop_custom_menu2");
editor.load(cfg);

@ -5,7 +5,7 @@
int main( int argc, char **argv )
{
KApplication app(argc, argv, "kdirselectdialogtest");
KApplication app(argc, argv, "kdirselectdialogtest", true);
KURL u = KDirSelectDialog::selectDirectory( (argc >= 1) ? argv[1] : TQString::null );
if ( u.isValid() )

@ -3,7 +3,7 @@
int main( int argc, char **argv )
{
KApplication app( argc, argv, "knotifytest" );
KApplication app( argc, argv, "knotifytest", true );
KNotifyDialog *dlg = new KNotifyDialog();
dlg->addApplicationEvents( "kwin" );
return dlg->exec();

@ -134,7 +134,7 @@ void testFrame::slotSetChildCount( KFileTreeViewItem *item, int c )
int main(int argc, char **argv)
{
KApplication a(argc, argv, "kfiletreeviewtest");
KApplication a(argc, argv, "kfiletreeviewtest", true);
TQString name1;
TQStringList names;

@ -44,7 +44,7 @@
int main(int argc, char **argv)
{
KApplication a(argc, argv, "kfstest");
KApplication a(argc, argv, "kfstest", true);
TQString name1;
TQStringList names;

@ -3,7 +3,7 @@
int main( int argc, char **argv )
{
KApplication app( argc, argv, "kicondialogtest" );
KApplication app( argc, argv, "kicondialogtest", true );
// KIconDialog::getIcon();

@ -28,7 +28,7 @@
int main(int argc, char **argv)
{
KApplication app(argc, argv, "kopenwithtest");
KApplication app(argc, argv, "kopenwithtest", true);
KURL::List list;
list += KURL("file:///tmp/testfile.txt");

@ -5,7 +5,7 @@
int main( int argc, char **argv )
{
KApplication app( argc, argv, "kurlrequestertest" );
KApplication app( argc, argv, "kurlrequestertest", true );
KURL url = KURLRequesterDlg::getURL( "ftp://ftp.kde.org" );
qDebug( "Selected url: %s", url.url().latin1());

@ -33,7 +33,7 @@
# include <stdlib.h>
#endif
#ifdef TESTKIO
# include <iostream.h>
# include <iostream>
#endif
#if !defined(DATAKIOSLAVE) && !defined(TESTKIO)

@ -11,8 +11,14 @@
include_directories(
${TQT_INCLUDE_DIRS}
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/dcop
${CMAKE_BINARY_DIR}/kdecore
${CMAKE_SOURCE_DIR}/kdecore
${CMAKE_SOURCE_DIR}/kdeui
${CMAKE_SOURCE_DIR}/kio
${CMAKE_SOURCE_DIR}/kio/kfile
${CMAKE_SOURCE_DIR}/kio/kio
)
@ -34,3 +40,37 @@ tde_add_executable( ${target}
LINK kio-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 kioslavetest ksycocatest ksycocaupdatetest
)
foreach( _check ${CHECKS} )
tde_add_check_executable( ${_check} AUTOMOC LINK kio-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
# - ksycocatest requires installed kdebase and GUI
set( TESTS dataprotocoltest kacltest kmimetypetest )
foreach( _check ${TESTS} )
tde_add_check_executable( ${_check} AUTOMOC LINK kio-shared TEST)
endforeach( )
# TODO add kdirwatchunittest

@ -21,7 +21,9 @@
#include <tqcstring.h>
#include <tqstring.h>
#include <iostream.h>
#include <iostream>
using namespace std;
class KURL;

@ -7,7 +7,7 @@
int main(int argc, char *argv[])
{
KApplication k(argc,argv,"getalltest",false/*noGUI*/); // KMessageBox needs KApp for makeStdCaption
KApplication 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;

@ -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( KIO::Job* job )

@ -69,7 +69,7 @@ int main(int argc, char *argv[])
{
KApplication::disableAutoDcopRegistration();
KCmdLineArgs::init(argc,argv,"kacltest", 0, 0, 0, 0);
KApplication app;
KApplication app(/*styles=*/false, /*gui=*/false);
KACLTest test;
test.setup();

@ -90,14 +90,14 @@ int TestService::exec()
int main(int argc, char *argv[])
{
putenv("IGNORE_SYCOCA_VERSION=true");
KApplication k(argc,argv,"whatever",false/*noGUI*/); // KMessageBox needs KApp for makeStdCaption
setenv("IGNORE_SYCOCA_VERSION", "true", true);
KApplication k(argc,argv,"whatever",false/*nostyle*/,false/*noGUI*/); // KMessageBox needs KApp for makeStdCaption
k.dcopClient()->setNotifications(true);
KService::List list = KService::allServices();
qWarning("I found %d services.", list.count());
qWarning("I found %ld services.", list.count());
int i = 0;
for(KService::List::ConstIterator it = list.begin(); it != list.end(); ++it)
{

@ -7,7 +7,7 @@ using namespace KIO;
int main(int argc, char **argv)
{
KApplication app(argc, argv, "kdefaultprogresstest");
KApplication app(argc, argv, "kdefaultprogresstest",true,true);
DefaultProgress* dlg = new DefaultProgress();
KURL src("http://this.host.doesn't.exist/this/dir/neither/andthisfileneither");

@ -151,7 +151,7 @@ void KDirListerTest::completed()
int main ( int argc, char *argv[] )
{
KApplication app( argc, argv, "kdirlistertest" );
KApplication app( argc, argv, "kdirlistertest", true /*styles*/ );
KDirListerTest *test = new KDirListerTest( 0 );
test->show();

@ -452,7 +452,7 @@ void KioslaveTest::slotDataReq(KIO::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++];

@ -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) {
qDebug("extension of %s is '%s: OK'", fileName.latin1(), ext.latin1());
} else {
qDebug("extension of %s is '%s, expected %s!'", fileName.latin1(), ext.latin1(), expectedExtention.latin1());
exit(1);
}
}
int main( int argc, char** argv )
{
KInstance blah("kmimetypetest");
@ -63,14 +74,8 @@ int main( int argc, char** argv )
checkIcon( "trash:/foo/", "folder" );
}
TQString pdf;
KMimeType::diagnoseFileName("foo.pdf", pdf);
qDebug("extension: '%s'", pdf.latin1());
assert(pdf == TQString("*.pdf"));
TQString ps;
KMimeType::diagnoseFileName("foo.ps", ps);
qDebug("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;
}

@ -30,7 +30,7 @@ int main(int argc, char **argv) {
"1.0");
KCmdLineArgs::init(argc, argv, &aboutData);
KApplication app;
KApplication app(/*styles=*/false, /*gui=*/false);
KURL url;
url.setPath("/tmp");

@ -121,7 +121,7 @@ void checkPDE(const KService &service, const KURL::List &urls, bool hs, bool tf,
int main(int argc, char **argv)
{
KApplication app( argc, argv, "kruntest", true /* it _has_ a GUI ! */);
KApplication 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]);

@ -3,11 +3,11 @@
int main( int argc, char **argv )
{
KApplication app( argc, argv, "kscantest" );
KApplication app( argc, argv, "kscantest", true, true );
KScanDialog *dlg = KScanDialog::getScanDialog();
if ( !dlg ) {
qDebug("*** EEK, no Scan-service available, aborting!");
return 0;
return EXIT_FAILURE;
}
dlg->show();

@ -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[])
{
KApplication k(argc,argv,"whatever",false/*noGUI*/); // KMessageBox needs KApp for makeStdCaption
KApplication k(argc,argv,"whatever",true); // KMessageBox needs KApp for makeStdCaption
TQCString instname = "kword";
TQString desktopPath = TQString::fromLatin1( "Office/%1.desktop" ).arg( instname );

@ -4,7 +4,7 @@
int main(int argc, char *argv[])
{
KApplication k(argc,argv,"whatever"); // KMessageBox needs KApp for makeStdCaption
KApplication k(argc,argv,"whatever",true,true); // KMessageBox needs KApp for makeStdCaption
KService::rebuildKSycoca(0);
return 0;

@ -155,14 +155,14 @@ int main(int argc, char **argv)
{
// Ensure that user configuration doesn't change the results of those tests
// KDEHOME needs to be writable though, for a ksycoca database
setenv( "KDEHOME", TQFile::encodeName( TQDir::homeDirPath() + "/.kde-kurifiltertest" ), true );
setenv( "KDEHOME", TQFile::encodeName( TQDir::currentDirPath() + "/.kde-kurifiltertest" ), true );
setenv( "KDE_FORK_SLAVES", "yes", true ); // simpler, for the final cleanup
KAboutData aboutData(appName, programName, version, description);
KCmdLineArgs::init(argc, argv, &aboutData);
KCmdLineArgs::addCmdLineOptions( options );
KApplication app;
KApplication 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/kdelibs/kio", 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, "kshorturifilter" ); //use specific filter.
if( !qtdir.isEmpty() ) {
filter( "$QTDIR", 0, KURIFilterData::LOCAL_DIR, "kshorturifilter" ); //use specific filter.
}
filter( "$HOME", home, KURIFilterData::LOCAL_DIR, "kshorturifilter" ); //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

@ -166,7 +166,7 @@ int main( int argc, char **argv )
{
KApplication::disableAutoDcopRegistration();
KCmdLineArgs::init(argc,argv,"kurlcompletiontest", 0, 0, 0, 0);
KApplication app;
KApplication app(/*styles=*/false, /*gui=*/false);
{
KURLCompletionTest test;

@ -24,7 +24,7 @@
int main(int argc, char **argv)
{
KApplication app( argc, argv, "netaccesstest", true /* it _has_ a GUI ! */);
KApplication 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" );

@ -55,7 +55,7 @@ void PreviewTest::slotFailed()
int main(int argc, char **argv)
{
KApplication app(argc, argv, "previewtest");
KApplication app(argc, argv, "previewtest", true, true);
PreviewTest *w = new PreviewTest;
w->show();
app.setMainWidget(w);

Loading…
Cancel
Save