1 /* This file is part of KDE
2 Copyright (c) 2005-2006 David Faure <faure@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #include <qtest_kde.h>
25 #include <kapplication.h>
26 #include <kcmdlineargs.h>
27 #include <konqmimedata.h>
28 #include "konqmimedatatest.h"
30 #include "konqmimedatatest.moc"
32 QTEST_KDEMAIN( KonqMimeDataTest
, NoGUI
)
34 void KonqMimeDataTest::testPopulate()
36 QMimeData
* mimeData
= new QMimeData
;
38 // Those URLs don't have to exist.
39 KUrl
mediaURL( "media:/hda1/tmp/Mat%C3%A9riel" );
40 KUrl
localURL( "file:///tmp/Mat%C3%A9riel" );
41 //KUrl::List kdeURLs; kdeURLs << mediaURL;
42 //KUrl::List mostLocalURLs; mostLocalURLs << localURL;
44 KonqMimeData::populateMimeData( mimeData
, mediaURL
, localURL
);
46 QVERIFY( KUrl::List::canDecode( mimeData
) );
47 const KUrl::List lst
= KUrl::List::fromMimeData( mimeData
);
48 QCOMPARE( lst
.count(), 1 );
49 QCOMPARE( lst
[0].url(), mediaURL
.url() );
51 const bool isCut
= KonqMimeData::decodeIsCutSelection( mimeData
);
57 void KonqMimeDataTest::testCut()
59 QMimeData
* mimeData
= new QMimeData
;
61 KUrl
localURL1( "file:///tmp/Mat%C3%A9riel" );
62 KUrl
localURL2( "file:///tmp" );
63 KUrl::List localURLs
; localURLs
<< localURL1
<< localURL2
;
65 KonqMimeData::populateMimeData( mimeData
, KUrl::List(), localURLs
, true /*cut*/ );
67 QVERIFY( KUrl::List::canDecode( mimeData
) );
68 const KUrl::List lst
= KUrl::List::fromMimeData( mimeData
);
69 QCOMPARE( lst
.count(), 2 );
70 QCOMPARE( lst
[0].url(), localURL1
.url() );
71 QCOMPARE( lst
[1].url(), localURL2
.url() );
73 const bool isCut
= KonqMimeData::decodeIsCutSelection( mimeData
);