Changeset View
Changeset View
Standalone View
Standalone View
autotests/kdirlistertest.cpp
Show First 20 Lines • Show All 241 Lines • ▼ Show 20 Line(s) | 215 | { | |||
---|---|---|---|---|---|
242 | 242 | | |||
243 | const QUrl itemUrl = QUrl::fromLocalFile(path + fileName); | 243 | const QUrl itemUrl = QUrl::fromLocalFile(path + fileName); | ||
244 | KFileItem itemForUrl = KDirLister::cachedItemForUrl(itemUrl); | 244 | KFileItem itemForUrl = KDirLister::cachedItemForUrl(itemUrl); | ||
245 | QVERIFY(!itemForUrl.isNull()); | 245 | QVERIFY(!itemForUrl.isNull()); | ||
246 | QCOMPARE(itemForUrl.url().toString(), itemUrl.toString()); | 246 | QCOMPARE(itemForUrl.url().toString(), itemUrl.toString()); | ||
247 | QCOMPARE(itemForUrl.entry().stringValue(KIO::UDSEntry::UDS_NAME), fileName); | 247 | QCOMPARE(itemForUrl.entry().stringValue(KIO::UDSEntry::UDS_NAME), fileName); | ||
248 | } | 248 | } | ||
249 | 249 | | |||
250 | void KDirListerTest::benchFindByUrl() | ||||
251 | { | ||||
252 | // The time used should be in the order of O(100*log2(100)) | ||||
253 | const QString path = m_tempDir.path() + '/'; | ||||
254 | QBENCHMARK { | ||||
255 | for (int i = 100; i > 0; i--) { | ||||
256 | KFileItem cachedItem = m_dirLister.findByUrl(QUrl::fromLocalFile(path + QString("toplevelfile_new_%1").arg(i))); | ||||
257 | QVERIFY(!cachedItem.isNull()); | ||||
258 | } | ||||
259 | } | ||||
260 | } | ||||
261 | | ||||
250 | void KDirListerTest::testNewItemByCopy() | 262 | void KDirListerTest::testNewItemByCopy() | ||
251 | { | 263 | { | ||
252 | // This test creates a file using KIO::copyAs, like knewmenu.cpp does. | 264 | // This test creates a file using KIO::copyAs, like knewmenu.cpp does. | ||
253 | // Useful for testing #192185, i.e. whether we catch the kdirwatch event and avoid | 265 | // Useful for testing #192185, i.e. whether we catch the kdirwatch event and avoid | ||
254 | // a KFileItem::refresh(). | 266 | // a KFileItem::refresh(). | ||
255 | const int origItemCount = m_items.count(); | 267 | const int origItemCount = m_items.count(); | ||
256 | const QString path = m_tempDir.path() + '/'; | 268 | const QString path = m_tempDir.path() + '/'; | ||
257 | connect(&m_dirLister, &KCoreDirLister::newItems, this, &KDirListerTest::slotNewItems); | 269 | connect(&m_dirLister, &KCoreDirLister::newItems, this, &KDirListerTest::slotNewItems); | ||
▲ Show 20 Lines • Show All 1098 Lines • Show Last 20 Lines |