summaryrefslogtreecommitdiffstats
path: root/kio/kfile/tests
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch)
tree5ac38a06f3dde268dc7927dc155896926aaf7012 /kio/kfile/tests
downloadtdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz
tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kio/kfile/tests')
-rw-r--r--kio/kfile/tests/Makefile.am41
-rw-r--r--kio/kfile/tests/kcustommenueditortest.cpp19
-rw-r--r--kio/kfile/tests/kdirselectdialogtest.cpp17
-rw-r--r--kio/kfile/tests/kfdtest.cpp34
-rw-r--r--kio/kfile/tests/kfdtest.h28
-rw-r--r--kio/kfile/tests/kfiletreeviewtest.cpp165
-rw-r--r--kio/kfile/tests/kfiletreeviewtest.h42
-rw-r--r--kio/kfile/tests/kfstest.cpp183
-rw-r--r--kio/kfile/tests/kicondialogtest.cpp19
-rw-r--r--kio/kfile/tests/knotifytest.cpp10
-rw-r--r--kio/kfile/tests/kopenwithtest.cpp67
-rw-r--r--kio/kfile/tests/kurlrequestertest.cpp16
12 files changed, 641 insertions, 0 deletions
diff --git a/kio/kfile/tests/Makefile.am b/kio/kfile/tests/Makefile.am
new file mode 100644
index 000000000..9689f7a27
--- /dev/null
+++ b/kio/kfile/tests/Makefile.am
@@ -0,0 +1,41 @@
+# This file is part of the KDE libraries
+# Copyright (C) 1996-1997 Matthias Kalle Dalheimer (kalle@kde.org)
+# (C) 1997-1998 Stephan Kulow (coolo@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.
+
+INCLUDES = $(all_includes)
+
+AM_LDFLAGS = $(QT_LDFLAGS) $(X_LDFLAGS) $(KDE_RPATH)
+
+check_PROGRAMS = kfstest kurlrequestertest kfiletreeviewtest \
+ kopenwithtest kdirselectdialogtest kicondialogtest \
+ knotifytest kcustommenueditortest
+
+# noinst_HEADERS =
+
+METASOURCES = AUTO
+
+LDADD = $(LIB_KIO)
+kcustommenueditortest_SOURCES = kcustommenueditortest.cpp
+kurlrequestertest_SOURCES = kurlrequestertest.cpp
+kfstest_SOURCES = kfstest.cpp kfdtest.cpp
+kfiletreeviewtest_SOURCES = kfiletreeviewtest.cpp
+kopenwithtest_SOURCES = kopenwithtest.cpp
+kdirselectdialogtest_SOURCES = kdirselectdialogtest.cpp
+kicondialogtest_SOURCES = kicondialogtest.cpp
+knotifytest_SOURCES = knotifytest.cpp
+
diff --git a/kio/kfile/tests/kcustommenueditortest.cpp b/kio/kfile/tests/kcustommenueditortest.cpp
new file mode 100644
index 000000000..532297d0c
--- /dev/null
+++ b/kio/kfile/tests/kcustommenueditortest.cpp
@@ -0,0 +1,19 @@
+#include "kcustommenueditor.h"
+#include <kapplication.h>
+#include <klocale.h>
+#include <kconfig.h>
+
+int main(int argc, char** argv)
+{
+ KLocale::setMainCatalogue("kdelibs");
+ KApplication app(argc, argv, "KCustomMenuEditorTest");
+ KCustomMenuEditor editor(0);
+ KConfig *cfg = new KConfig("kdesktop_custom_menu2");
+ editor.load(cfg);
+ if (editor.exec())
+ {
+ editor.save(cfg);
+ cfg->sync();
+ }
+}
+
diff --git a/kio/kfile/tests/kdirselectdialogtest.cpp b/kio/kfile/tests/kdirselectdialogtest.cpp
new file mode 100644
index 000000000..e2eb52f1b
--- /dev/null
+++ b/kio/kfile/tests/kdirselectdialogtest.cpp
@@ -0,0 +1,17 @@
+#include <kapplication.h>
+#include <kdirselectdialog.h>
+#include <kmessagebox.h>
+#include <kurl.h>
+
+int main( int argc, char **argv )
+{
+ KApplication app(argc, argv, "kdirselectdialogtest");
+
+ KURL u = KDirSelectDialog::selectDirectory( (argc >= 1) ? argv[1] : QString::null );
+ if ( u.isValid() )
+ KMessageBox::information( 0L,
+ QString::fromLatin1("You selected the url: %1")
+ .arg( u.prettyURL() ), "Selected URL" );
+
+ return 0;
+}
diff --git a/kio/kfile/tests/kfdtest.cpp b/kio/kfile/tests/kfdtest.cpp
new file mode 100644
index 000000000..d9341a7ae
--- /dev/null
+++ b/kio/kfile/tests/kfdtest.cpp
@@ -0,0 +1,34 @@
+#include "kfdtest.h"
+
+#include <qstringlist.h>
+#include <kfiledialog.h>
+#include <kapplication.h>
+#include <kmessagebox.h>
+#include <qtimer.h>
+
+KFDTest::KFDTest( const QString& startDir, QObject *parent, const char *name )
+ : QObject( parent, name ),
+ m_startDir( startDir )
+{
+ QTimer::singleShot( 1000, this, SLOT( doit() ));
+}
+
+void KFDTest::doit()
+{
+ KFileDialog *dlg = new KFileDialog( m_startDir, QString::null, 0L,
+ "file dialog", true );
+ dlg->setMode( KFile::File);
+ dlg->setOperationMode( KFileDialog::Saving );
+ QStringList filter;
+ filter << "all/allfiles" << "text/plain";
+ dlg->setMimeFilter( filter, "all/allfiles" );
+
+ if ( dlg->exec() == KDialog::Accepted )
+ {
+ KMessageBox::information(0, QString::fromLatin1("You selected the file: %1").arg( dlg->selectedURL().prettyURL() ));
+ }
+
+// qApp->quit();
+}
+
+#include "kfdtest.moc"
diff --git a/kio/kfile/tests/kfdtest.h b/kio/kfile/tests/kfdtest.h
new file mode 100644
index 000000000..0743bb96c
--- /dev/null
+++ b/kio/kfile/tests/kfdtest.h
@@ -0,0 +1,28 @@
+/****************************************************************************
+** $Id$
+**
+** Copyright (C) 2003 Carsten Pfeiffer <pfeiffer@kde.org>
+**
+****************************************************************************/
+
+#ifndef KFDTEST_H
+#define KFDTEST_H
+
+#include <qobject.h>
+
+class KFDTest : public QObject
+{
+ Q_OBJECT
+
+public:
+ KFDTest( const QString& startDir, QObject *parent = 0, const char *name = 0);
+
+public slots:
+ void doit();
+
+private:
+ QString m_startDir;
+};
+
+
+#endif // KFDTEST_H
diff --git a/kio/kfile/tests/kfiletreeviewtest.cpp b/kio/kfile/tests/kfiletreeviewtest.cpp
new file mode 100644
index 000000000..6a4ea719f
--- /dev/null
+++ b/kio/kfile/tests/kfiletreeviewtest.cpp
@@ -0,0 +1,165 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2001 Klaas Freitag <freitag@suse.de>
+
+ 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 <qdir.h>
+
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <kmainwindow.h>
+#include <kapplication.h>
+#include <kurl.h>
+#include <kdebug.h>
+#include <kstatusbar.h>
+
+#include <kfiletreeview.h>
+#include "kfiletreeviewtest.h"
+
+
+#include "kfiletreeviewtest.moc"
+
+testFrame::testFrame():KMainWindow(0,"Test FileTreeView"),
+ dirOnlyMode(false)
+
+{
+ treeView = new KFileTreeView( this );
+ treeView->setDragEnabled( true );
+ treeView->setAcceptDrops( true );
+ treeView->setDropVisualizer( true );
+
+
+ /* Connect to see the status bar */
+ KStatusBar* sta = statusBar();
+ connect( treeView, SIGNAL( onItem( const QString& )),
+ sta, SLOT( message( const QString& )));
+
+ connect( treeView, SIGNAL( dropped( QWidget*, QDropEvent*, KURL::List& )),
+ this, SLOT( urlsDropped( QWidget*, QDropEvent*, KURL::List& )));
+
+ connect( treeView, SIGNAL( dropped( KURL::List&, KURL& )), this,
+ SLOT( copyURLs( KURL::List&, KURL& )));
+
+ treeView->addColumn( "File" );
+ treeView->addColumn( "ChildCount" );
+ setCentralWidget( treeView );
+ resize( 600, 400 );
+
+ showPath( KURL::fromPathOrURL( QDir::homeDirPath() ));
+}
+
+void testFrame::showPath( const KURL &url )
+{
+ QString fname = "TestBranch"; // url.fileName ();
+ /* try a user icon */
+ KIconLoader *loader = KGlobal::iconLoader();
+ QPixmap pix = loader->loadIcon( "contents2", KIcon::Small );
+ QPixmap pixOpen = loader->loadIcon( "contents", KIcon::Small );
+
+ KFileTreeBranch *nb = treeView->addBranch( url, fname, pix );
+
+ if( nb )
+ {
+ if( dirOnlyMode ) treeView->setDirOnlyMode( nb, true );
+ nb->setOpenPixmap( pixOpen );
+
+ connect( nb, SIGNAL(populateFinished(KFileTreeViewItem*)),
+ this, SLOT(slotPopulateFinished(KFileTreeViewItem*)));
+ connect( nb, SIGNAL( directoryChildCount( KFileTreeViewItem *, int )),
+ this, SLOT( slotSetChildCount( KFileTreeViewItem*, int )));
+ // nb->setChildRecurse(false );
+
+ nb->setOpen(true);
+ }
+
+
+}
+
+void testFrame::urlsDropped( QWidget* , QDropEvent* , KURL::List& list )
+{
+ KURL::List::ConstIterator it = list.begin();
+ for ( ; it != list.end(); ++it ) {
+ kdDebug() << "Url dropped: " << (*it).prettyURL() << endl;
+ }
+}
+
+void testFrame::copyURLs( KURL::List& list, KURL& to )
+{
+ KURL::List::ConstIterator it = list.begin();
+ kdDebug() << "Copy to " << to.prettyURL() << endl;
+ for ( ; it != list.end(); ++it ) {
+ kdDebug() << "Url: " << (*it).prettyURL() << endl;
+ }
+
+}
+
+
+void testFrame::slotPopulateFinished(KFileTreeViewItem *item )
+{
+ if( item )
+ {
+#if 0
+ int cc = item->childCount();
+
+ kdDebug() << "setting column 2 of treeview with count " << cc << endl;
+
+ item->setText( 1, QString::number( cc ));
+#endif
+ }
+ else
+ {
+ kdDebug() << "slotPopFinished for uninitalised item" << endl;
+ }
+}
+
+void testFrame::slotSetChildCount( KFileTreeViewItem *item, int c )
+{
+ if( item )
+ item->setText(1, QString::number( c ));
+}
+
+int main(int argc, char **argv)
+{
+ KApplication a(argc, argv, "kfiletreeviewtest");
+ QString name1;
+ QStringList names;
+
+ QString argv1;
+ testFrame *tf;
+
+ tf = new testFrame();
+ a.setMainWidget( tf );
+
+ if (argc > 1)
+ {
+ for( int i = 1; i < argc; i++ )
+ {
+ argv1 = QString::fromLatin1(argv[i]);
+ kdDebug() << "Opening " << argv1 << endl;
+ if( argv1 == "-d" )
+ tf->setDirOnly();
+ else
+ {
+ KURL u( argv1 );
+ tf->showPath( u );
+ }
+ }
+ }
+ tf->show();
+ int ret = a.exec();
+ return( ret );
+}
diff --git a/kio/kfile/tests/kfiletreeviewtest.h b/kio/kfile/tests/kfiletreeviewtest.h
new file mode 100644
index 000000000..1286e1be2
--- /dev/null
+++ b/kio/kfile/tests/kfiletreeviewtest.h
@@ -0,0 +1,42 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2001 Klaas Freitag <freitag@suse.de>
+
+ 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.
+*/
+
+#ifndef KFILETREEVIEWTEST
+#define KFILETREEVIEWTEST
+
+class testFrame: public KMainWindow
+{
+ Q_OBJECT
+public:
+ testFrame();
+ void showPath( const KURL & );
+ void setDirOnly( ) { dirOnlyMode = true; }
+public slots:
+ void slotPopulateFinished(KFileTreeViewItem *);
+ void slotSetChildCount( KFileTreeViewItem *item, int c );
+
+ void urlsDropped( QWidget*, QDropEvent*, KURL::List& );
+ void copyURLs( KURL::List& list, KURL& to );
+private:
+ KFileTreeView *treeView;
+ bool dirOnlyMode;
+};
+
+
+#endif
diff --git a/kio/kfile/tests/kfstest.cpp b/kio/kfile/tests/kfstest.cpp
new file mode 100644
index 000000000..16d74cb0c
--- /dev/null
+++ b/kio/kfile/tests/kfstest.cpp
@@ -0,0 +1,183 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 1997, 1998 Richard Moore <rich@kde.org>
+ 1998 Stephan Kulow <coolo@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 <unistd.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <qdir.h>
+#include <qlayout.h>
+#include <qstringlist.h>
+#include <qwidget.h>
+
+#include <kfiledialog.h>
+#include <kfileiconview.h>
+#include <kmessagebox.h>
+#include <kconfig.h>
+#include <kapplication.h>
+#include <kurl.h>
+#include <kurlbar.h>
+#include <kdiroperator.h>
+#include <kfile.h>
+#include <kdebug.h>
+#include <kicondialog.h>
+
+#include "kfdtest.h"
+
+int main(int argc, char **argv)
+{
+ KApplication a(argc, argv, "kfstest");
+ QString name1;
+ QStringList names;
+
+ QString argv1;
+ QString startDir;
+ if (argc > 1)
+ argv1 = QString::fromLatin1(argv[1]);
+ if ( argc > 2 )
+ startDir = QString::fromLatin1( argv[2]);
+
+ if (argv1 == QString::fromLatin1("diroperator")) {
+ KDirOperator *op = new KDirOperator(startDir, 0, "operator");
+ op->setViewConfig( KGlobal::config(), "TestGroup" );
+ op->setView(KFile::Simple);
+ op->show();
+ a.setMainWidget(op);
+ a.exec();
+ }
+
+ else if (argv1 == QString::fromLatin1("justone")) {
+ QString name = KFileDialog::getOpenFileName(startDir);
+ qDebug("filename=%s",name.latin1());
+ }
+
+ else if (argv1 == QString::fromLatin1("existingURL")) {
+ KURL url = KFileDialog::getExistingURL();
+ qDebug("URL=%s",url.url().latin1());
+ name1 = url.url();
+ }
+
+ else if (argv1 == QString::fromLatin1("preview")) {
+ KURL u = KFileDialog::getImageOpenURL();
+ qDebug("filename=%s", u.url().latin1());
+ }
+
+ else if (argv1 == QString::fromLatin1("preselect")) {
+ names = KFileDialog::getOpenFileNames(QString::fromLatin1("/etc/passwd"));
+ QStringList::Iterator it = names.begin();
+ while ( it != names.end() ) {
+ qDebug("selected file: %s", (*it).latin1());
+ ++it;
+ }
+ }
+
+ else if (argv1 == QString::fromLatin1("dirs"))
+ name1 = KFileDialog::getExistingDirectory();
+
+ else if (argv1 == QString::fromLatin1("heap")) {
+ KFileDialog *dlg = new KFileDialog( startDir, QString::null, 0L,
+ "file dialog", true );
+ dlg->setMode( KFile::File);
+ dlg->setOperationMode( KFileDialog::Saving );
+ QStringList filter;
+ filter << "all/allfiles" << "text/plain";
+ dlg->setMimeFilter( filter, "all/allfiles" );
+ KURLBar *urlBar = dlg->speedBar();
+ if ( urlBar )
+ {
+ urlBar->insertDynamicItem( KURL("ftp://ftp.kde.org"),
+ QString::fromLatin1("KDE FTP Server") );
+ }
+
+ if ( dlg->exec() == KDialog::Accepted )
+ name1 = dlg->selectedURL().url();
+ }
+
+ else if ( argv1 == QString::fromLatin1("eventloop") )
+ {
+ KFDTest *test = new KFDTest( startDir );
+ return a.exec();
+ }
+
+ else if (argv1 == QString::fromLatin1("save")) {
+ KURL u = KFileDialog::getSaveURL();
+// QString(QDir::homeDirPath() + QString::fromLatin1("/testfile")),
+// QString::null, 0L);
+ name1 = u.url();
+ }
+
+ else if (argv1 == QString::fromLatin1("icon")) {
+ KIconDialog dlg;
+ QString icon = dlg.selectIcon();
+ kdDebug() << icon << endl;
+ }
+
+// else if ( argv1 == QString::fromLatin1("dirselect") ) {
+// KURL url;
+// url.setPath( "/" );
+// KURL selected = KDirSelectDialog::selectDirectory( url );
+// name1 = selected.url();
+// qDebug("*** selected: %s", selected.url().latin1());
+// }
+
+ else {
+ KFileDialog dlg(startDir,
+ QString::fromLatin1("*|All Files\n"
+ "*.lo *.o *.la|All libtool Files"),
+ 0, 0, true);
+// dlg.setFilter( "*.kdevelop" );
+ dlg.setMode( (KFile::Mode) (KFile::Files |
+ KFile::Directory |
+ KFile::ExistingOnly |
+ KFile::LocalOnly) );
+// QStringList filter;
+// filter << "text/plain" << "text/html" << "image/png";
+// dlg.setMimeFilter( filter );
+// KMimeType::List types;
+// types.append( KMimeType::mimeType( "text/plain" ) );
+// types.append( KMimeType::mimeType( "text/html" ) );
+// dlg.setFilterMimeType( "Filetypes:", types, types.first() );
+ if ( dlg.exec() == QDialog::Accepted ) {
+ KURL::List list = dlg.selectedURLs();
+ KURL::List::ConstIterator it = list.begin();
+ qDebug("*** selectedURLs(): ");
+ while ( it != list.end() ) {
+ name1 = (*it).url();
+ qDebug(" -> %s", name1.latin1());
+ ++it;
+ }
+ qDebug("*** selectedFile: %s", dlg.selectedFile().latin1());
+ qDebug("*** selectedURL: %s", dlg.selectedURL().url().latin1());
+ qDebug("*** selectedFiles: ");
+ QStringList l = dlg.selectedFiles();
+ QStringList::Iterator it2 = l.begin();
+ while ( it2 != l.end() ) {
+ qDebug(" -> %s", (*it2).latin1());
+ ++it2;
+ }
+ }
+ }
+
+ if (!(name1.isNull()))
+ KMessageBox::information(0, QString::fromLatin1("You selected the file " ) + name1,
+ QString::fromLatin1("Your Choice"));
+ return 0;
+}
diff --git a/kio/kfile/tests/kicondialogtest.cpp b/kio/kfile/tests/kicondialogtest.cpp
new file mode 100644
index 000000000..23301b752
--- /dev/null
+++ b/kio/kfile/tests/kicondialogtest.cpp
@@ -0,0 +1,19 @@
+#include <kapplication.h>
+#include <kicondialog.h>
+
+int main( int argc, char **argv )
+{
+ KApplication app( argc, argv, "kicondialogtest" );
+
+// KIconDialog::getIcon();
+
+ KIconButton button;
+ app.setMainWidget( &button );
+ button.show();
+
+
+ return app.exec();
+}
+
+/* vim: et sw=4
+ */
diff --git a/kio/kfile/tests/knotifytest.cpp b/kio/kfile/tests/knotifytest.cpp
new file mode 100644
index 000000000..e27893589
--- /dev/null
+++ b/kio/kfile/tests/knotifytest.cpp
@@ -0,0 +1,10 @@
+#include <kapplication.h>
+#include <knotifydialog.h>
+
+int main( int argc, char **argv )
+{
+ KApplication app( argc, argv, "knotifytest" );
+ KNotifyDialog *dlg = new KNotifyDialog();
+ dlg->addApplicationEvents( "kwin" );
+ return dlg->exec();
+}
diff --git a/kio/kfile/tests/kopenwithtest.cpp b/kio/kfile/tests/kopenwithtest.cpp
new file mode 100644
index 000000000..96e18bcc2
--- /dev/null
+++ b/kio/kfile/tests/kopenwithtest.cpp
@@ -0,0 +1,67 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2002 Dirk Mueller <mueller@kde.org>
+ Copyright (C) 2003 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 <kapplication.h>
+#include <qwidget.h>
+#include <qstringlist.h>
+#include <qdir.h>
+#include <kopenwith.h>
+#include <kurl.h>
+#include <kdebug.h>
+
+int main(int argc, char **argv)
+{
+ KApplication app(argc, argv, "kopenwithtest");
+ KURL::List list;
+
+ list += KURL("file:///tmp/testfile.txt");
+
+ // Test with one URL
+ KOpenWithDlg* dlg = new KOpenWithDlg(list, "OpenWith_Text", "OpenWith_Value", 0);
+ if(dlg->exec()) {
+ kdDebug() << "Dialog ended successfully\ntext: " << dlg->text() << endl;
+ }
+ else
+ kdDebug() << "Dialog was canceled." << endl;
+ delete dlg;
+
+ // Test with two URLs
+ list += KURL("http://www.kde.org/index.html");
+ dlg = new KOpenWithDlg(list, "OpenWith_Text", "OpenWith_Value", 0);
+ if(dlg->exec()) {
+ kdDebug() << "Dialog ended successfully\ntext: " << dlg->text() << endl;
+ }
+ else
+ kdDebug() << "Dialog was canceled." << endl;
+ delete dlg;
+
+ // Test with a mimetype
+ QString mimetype = "text/plain";
+ dlg = new KOpenWithDlg( mimetype, "kedit", 0);
+ if(dlg->exec()) {
+ kdDebug() << "Dialog ended successfully\ntext: " << dlg->text() << endl;
+ }
+ else
+ kdDebug() << "Dialog was canceled." << endl;
+ delete dlg;
+
+ return 0;
+}
+
diff --git a/kio/kfile/tests/kurlrequestertest.cpp b/kio/kfile/tests/kurlrequestertest.cpp
new file mode 100644
index 000000000..5601f4922
--- /dev/null
+++ b/kio/kfile/tests/kurlrequestertest.cpp
@@ -0,0 +1,16 @@
+#include <kapplication.h>
+#include <keditlistbox.h>
+#include <kurlrequester.h>
+#include <kurlrequesterdlg.h>
+
+int main( int argc, char **argv )
+{
+ KApplication app( argc, argv, "kurlrequestertest" );
+ KURL url = KURLRequesterDlg::getURL( "ftp://ftp.kde.org" );
+ qDebug( "Selected url: %s", url.url().latin1());
+
+ KURLRequester *req = new KURLRequester();
+ KEditListBox *el = new KEditListBox( QString::fromLatin1("Test"), req->customEditor() );
+ el->show();
+ return app.exec();
+}