Esempio n. 1
0
void KonqMimeDataTest::testCut()
{
    QMimeData* mimeData = new QMimeData;

    KUrl localURL1( "file:///tmp/Mat%C3%A9riel" );
    KUrl localURL2( "file:///tmp" );
    KUrl::List localURLs; localURLs << localURL1 << localURL2;

    KonqMimeData::populateMimeData( mimeData, KUrl::List(), localURLs, true /*cut*/ );

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

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

    delete mimeData;
}
Esempio n. 2
0
void KIOPasteTest::testCut()
{
    QMimeData *mimeData = new QMimeData;

    QUrl localURL1(QStringLiteral("file:///tmp/Mat%C3%A9riel"));
    QUrl localURL2(QStringLiteral("file:///tmp"));
    QList<QUrl> localURLs; localURLs << localURL1 << localURL2;

    KUrlMimeData::setUrls(QList<QUrl>(), localURLs, mimeData);
    KIO::setClipboardDataCut(mimeData, true);

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

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

    delete mimeData;
}