tdeio: add tests

Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
(cherry picked from commit ed74769bfa)
pull/16/head
Alexander Golubev 8 years ago committed by Slávek Banko
parent de48b4a218
commit 86921d65c5

@ -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}/tdecore
${CMAKE_SOURCE_DIR}/tdecore
${CMAKE_SOURCE_DIR}/tdeui
${CMAKE_SOURCE_DIR}/tdeio
${CMAKE_SOURCE_DIR}/tdeio/tdefile
${CMAKE_SOURCE_DIR}/tdeio/tdeio
${CMAKE_BINARY_DIR}/tdeio/tdefile
)
link_directories(
${TDECORE_LIBRARY_DIRS}
)
tde_add_check_executable( kurlrequestertest LINK tdeio-shared )
tde_add_check_executable( kopenwithtest LINK tdeio-shared )
tde_add_check_executable( kdirselectdialogtest LINK tdeio-shared )
tde_add_check_executable( kicondialogtest LINK tdeio-shared )
tde_add_check_executable( kcustommenueditortest LINK tdeio-shared )
tde_add_check_executable( tdefilenotifytest LINK tdeio-shared )
tde_add_check_executable( tdefiletreeviewtest AUTOMOC LINK tdeio-shared )
tde_add_check_executable( kfstest AUTOMOC
SOURCES kfstest.cpp kfdtest.cpp LINK tdeio-shared )

@ -6,7 +6,7 @@
int main(int argc, char** argv)
{
TDELocale::setMainCatalogue("tdelibs");
TDEApplication app(argc, argv, "KCustomMenuEditorTest");
TDEApplication app(argc, argv, "KCustomMenuEditorTest", true);
KCustomMenuEditor editor(0);
TDEConfig *cfg = new TDEConfig("kdesktop_custom_menu2");
editor.load(cfg);

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

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

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

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

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

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

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

@ -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}/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

@ -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[])
{
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;

@ -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 )

@ -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();

@ -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)
{

@ -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");

@ -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();

@ -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;
}

@ -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");

@ -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]);

@ -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();

@ -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

@ -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;

@ -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" );

@ -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);

@ -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++];

@ -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 );

@ -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;

Loading…
Cancel
Save