void KonqMimeDataTest::testPopulate()
{
    QMimeData* mimeData = new QMimeData;

    // Those URLs don't have to exist.
    KUrl mediaURL( "media:/hda1/tmp/Mat%C3%A9riel" );
    KUrl localURL( "file:///tmp/Mat%C3%A9riel" );
    //KUrl::List kdeURLs; kdeURLs << mediaURL;
    //KUrl::List mostLocalURLs; mostLocalURLs << localURL;

    KonqMimeData::populateMimeData( mimeData, mediaURL, localURL );

    QVERIFY( KUrl::List::canDecode( mimeData ) );
    const KUrl::List lst = KUrl::List::fromMimeData( mimeData );
    QCOMPARE( lst.count(), 1 );
    QCOMPARE( lst[0].url(), mediaURL.url() );

    const bool isCut = KonqMimeData::decodeIsCutSelection( mimeData );
    QVERIFY( !isCut );

    delete mimeData;
}
Exemple #2
0
void KIOPasteTest::testPopulate()
{
    QMimeData *mimeData = new QMimeData;

    // Those URLs don't have to exist.
    QUrl mediaURL(QStringLiteral("media:/hda1/tmp/Mat%C3%A9riel"));
    QUrl localURL(QStringLiteral("file:///tmp/Mat%C3%A9riel"));
    QList<QUrl> kdeURLs; kdeURLs << mediaURL;
    QList<QUrl> mostLocalURLs; mostLocalURLs << localURL;

    KUrlMimeData::setUrls(kdeURLs, mostLocalURLs, mimeData);

    QVERIFY(mimeData->hasUrls());
    const QList<QUrl> lst = KUrlMimeData::urlsFromMimeData(mimeData);
    QCOMPARE(lst.count(), 1);
    QCOMPARE(lst[0].url(), mediaURL.url());

    const bool isCut = KIO::isClipboardDataCut(mimeData);
    QVERIFY(!isCut);

    delete mimeData;
}