Changeset View
Changeset View
Standalone View
Standalone View
autotests/kfileplacesmodeltest.cpp
Show First 20 Lines • Show All 172 Lines • ▼ Show 20 Line(s) | 172 | { | |||
---|---|---|---|---|---|
173 | QCOMPARE(m_places->rowCount(), 4); // when the xbel file is empty, KFilePlacesModel fills it with 4 default items | 173 | QCOMPARE(m_places->rowCount(), 4); // when the xbel file is empty, KFilePlacesModel fills it with 4 default items | ||
174 | QCoreApplication::processEvents(); // Devices have a delayed loading | 174 | QCoreApplication::processEvents(); // Devices have a delayed loading | ||
175 | QCOMPARE(m_places->rowCount(), 9); | 175 | QCOMPARE(m_places->rowCount(), 9); | ||
176 | } | 176 | } | ||
177 | 177 | | |||
178 | static const QStringList initialListOfUrls() | 178 | static const QStringList initialListOfUrls() | ||
179 | { | 179 | { | ||
180 | return QStringList() << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | 180 | return QStringList() << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | ||
181 | << QStringLiteral("/media/nfs") << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom") << QStringLiteral("/foreign"); | 181 | << QStringLiteral("/media/nfs") << QStringLiteral("/foreign") | ||
182 | << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom"); | ||||
mwolff: the changed list of remote urls that is repeated below could be put into another helper… | |||||
done already in https://phabricator.kde.org/D8366 I see, ignore this mwolff: done already in https://phabricator.kde.org/D8366 I see, ignore this | |||||
182 | } | 183 | } | ||
183 | 184 | | |||
184 | void KFilePlacesModelTest::testInitialList() | 185 | void KFilePlacesModelTest::testInitialList() | ||
185 | { | 186 | { | ||
186 | const QStringList urls = initialListOfUrls(); | 187 | const QStringList urls = initialListOfUrls(); | ||
187 | CHECK_PLACES_URLS(urls); | 188 | CHECK_PLACES_URLS(urls); | ||
188 | } | 189 | } | ||
189 | 190 | | |||
▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Line(s) | 322 | { | |||
334 | while (!root.next(last).isNull()) { | 335 | while (!root.next(last).isNull()) { | ||
335 | last = root.next(last); | 336 | last = root.next(last); | ||
336 | } | 337 | } | ||
337 | root.moveBookmark(remote, last); | 338 | root.moveBookmark(remote, last); | ||
338 | bookmarkManager->emitChanged(root); | 339 | bookmarkManager->emitChanged(root); | ||
339 | 340 | | |||
340 | QStringList urls; | 341 | QStringList urls; | ||
341 | urls << QDir::homePath() << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") << QStringLiteral("remote:/") | 342 | urls << QDir::homePath() << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") << QStringLiteral("remote:/") | ||
342 | << QStringLiteral("/media/nfs") << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom") << QStringLiteral("/foreign"); | 343 | << QStringLiteral("/media/nfs") << QStringLiteral("/foreign") | ||
344 | << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom"); | ||||
343 | 345 | | |||
344 | CHECK_PLACES_URLS(urls); | 346 | CHECK_PLACES_URLS(urls); | ||
345 | QCOMPARE(spy_inserted.count(), 1); | 347 | QCOMPARE(spy_inserted.count(), 1); | ||
346 | args = spy_inserted.takeFirst(); | 348 | args = spy_inserted.takeFirst(); | ||
347 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | 349 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | ||
348 | QCOMPARE(args.at(1).toInt(), 3); | 350 | QCOMPARE(args.at(1).toInt(), 3); | ||
349 | QCOMPARE(args.at(2).toInt(), 3); | 351 | QCOMPARE(args.at(2).toInt(), 3); | ||
350 | QCOMPARE(spy_removed.count(), 1); | 352 | QCOMPARE(spy_removed.count(), 1); | ||
351 | args = spy_removed.takeFirst(); | 353 | args = spy_removed.takeFirst(); | ||
352 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | 354 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | ||
353 | QCOMPARE(args.at(1).toInt(), 1); | 355 | QCOMPARE(args.at(1).toInt(), 1); | ||
354 | QCOMPARE(args.at(2).toInt(), 1); | 356 | QCOMPARE(args.at(2).toInt(), 1); | ||
355 | 357 | | |||
356 | // Move the remote at the beginning of the list | 358 | // Move the remote at the beginning of the list | ||
357 | root.moveBookmark(remote, KBookmark()); | 359 | root.moveBookmark(remote, KBookmark()); | ||
358 | bookmarkManager->emitChanged(root); | 360 | bookmarkManager->emitChanged(root); | ||
359 | 361 | | |||
360 | urls.clear(); | 362 | urls.clear(); | ||
361 | urls << QStringLiteral("remote:/") << QDir::homePath() << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | 363 | urls << QStringLiteral("remote:/") << QDir::homePath() << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | ||
362 | << QStringLiteral("/media/nfs") << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom") << QStringLiteral("/foreign"); | 364 | << QStringLiteral("/media/nfs") << QStringLiteral("/foreign") | ||
365 | << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom"); | ||||
363 | 366 | | |||
364 | CHECK_PLACES_URLS(urls); | 367 | CHECK_PLACES_URLS(urls); | ||
365 | QCOMPARE(spy_inserted.count(), 1); | 368 | QCOMPARE(spy_inserted.count(), 1); | ||
366 | args = spy_inserted.takeFirst(); | 369 | args = spy_inserted.takeFirst(); | ||
367 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | 370 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | ||
368 | QCOMPARE(args.at(1).toInt(), 0); | 371 | QCOMPARE(args.at(1).toInt(), 0); | ||
369 | QCOMPARE(args.at(2).toInt(), 0); | 372 | QCOMPARE(args.at(2).toInt(), 0); | ||
370 | QCOMPARE(spy_removed.count(), 1); | 373 | QCOMPARE(spy_removed.count(), 1); | ||
371 | args = spy_removed.takeFirst(); | 374 | args = spy_removed.takeFirst(); | ||
372 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | 375 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | ||
373 | QCOMPARE(args.at(1).toInt(), 4); | 376 | QCOMPARE(args.at(1).toInt(), 4); | ||
374 | QCOMPARE(args.at(2).toInt(), 4); | 377 | QCOMPARE(args.at(2).toInt(), 4); | ||
375 | 378 | | |||
376 | // Move the remote in the list (at its original place) | 379 | // Move the remote in the list (at its original place) | ||
377 | root.moveBookmark(remote, before_remote); | 380 | root.moveBookmark(remote, before_remote); | ||
378 | bookmarkManager->emitChanged(root); | 381 | bookmarkManager->emitChanged(root); | ||
379 | urls.clear(); | 382 | urls.clear(); | ||
380 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | 383 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | ||
381 | << QStringLiteral("/media/nfs") << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom") << QStringLiteral("/foreign"); | 384 | << QStringLiteral("/media/nfs") << QStringLiteral("/foreign") | ||
385 | << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom"); | ||||
382 | CHECK_PLACES_URLS(urls); | 386 | CHECK_PLACES_URLS(urls); | ||
383 | QCOMPARE(spy_inserted.count(), 1); | 387 | QCOMPARE(spy_inserted.count(), 1); | ||
384 | args = spy_inserted.takeFirst(); | 388 | args = spy_inserted.takeFirst(); | ||
385 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | 389 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | ||
386 | QCOMPARE(args.at(1).toInt(), 1); | 390 | QCOMPARE(args.at(1).toInt(), 1); | ||
387 | QCOMPARE(args.at(2).toInt(), 1); | 391 | QCOMPARE(args.at(2).toInt(), 1); | ||
388 | QCOMPARE(spy_removed.count(), 1); | 392 | QCOMPARE(spy_removed.count(), 1); | ||
389 | args = spy_removed.takeFirst(); | 393 | args = spy_removed.takeFirst(); | ||
Show All 15 Lines | 400 | { | |||
405 | // Move the remote at the end of the places list | 409 | // Move the remote at the end of the places list | ||
406 | QModelIndexList indexes; | 410 | QModelIndexList indexes; | ||
407 | indexes << m_places->index(1, 0); | 411 | indexes << m_places->index(1, 0); | ||
408 | QMimeData *mimeData = m_places->mimeData(indexes); | 412 | QMimeData *mimeData = m_places->mimeData(indexes); | ||
409 | QVERIFY(m_places->dropMimeData(mimeData, Qt::MoveAction, 4, 0, QModelIndex())); | 413 | QVERIFY(m_places->dropMimeData(mimeData, Qt::MoveAction, 4, 0, QModelIndex())); | ||
410 | 414 | | |||
411 | QStringList urls; | 415 | QStringList urls; | ||
412 | urls << QDir::homePath() << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") << QStringLiteral("remote:/") | 416 | urls << QDir::homePath() << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") << QStringLiteral("remote:/") | ||
413 | << QStringLiteral("/media/nfs") << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom") << QStringLiteral("/foreign"); | 417 | << QStringLiteral("/media/nfs") << QStringLiteral("/foreign") | ||
418 | << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom"); | ||||
414 | CHECK_PLACES_URLS(urls); | 419 | CHECK_PLACES_URLS(urls); | ||
415 | QCOMPARE(spy_inserted.count(), 0); | 420 | QCOMPARE(spy_inserted.count(), 0); | ||
416 | QCOMPARE(spy_removed.count(), 0); | 421 | QCOMPARE(spy_removed.count(), 0); | ||
417 | QCOMPARE(spy_moved.count(), 1); | 422 | QCOMPARE(spy_moved.count(), 1); | ||
418 | args = spy_moved.takeFirst(); | 423 | args = spy_moved.takeFirst(); | ||
419 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | 424 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | ||
420 | QCOMPARE(args.at(1).toInt(), 1); | 425 | QCOMPARE(args.at(1).toInt(), 1); | ||
421 | QCOMPARE(args.at(2).toInt(), 1); | 426 | QCOMPARE(args.at(2).toInt(), 1); | ||
422 | QCOMPARE(args.at(3).toModelIndex(), QModelIndex()); | 427 | QCOMPARE(args.at(3).toModelIndex(), QModelIndex()); | ||
423 | QCOMPARE(args.at(4).toInt(), 4); | 428 | QCOMPARE(args.at(4).toInt(), 4); | ||
424 | 429 | | |||
425 | // Move the remote at the beginning of the list | 430 | // Move the remote at the beginning of the list | ||
426 | indexes.clear(); | 431 | indexes.clear(); | ||
427 | indexes << m_places->index(3, 0); | 432 | indexes << m_places->index(3, 0); | ||
428 | mimeData = m_places->mimeData(indexes); | 433 | mimeData = m_places->mimeData(indexes); | ||
429 | QVERIFY(m_places->dropMimeData(mimeData, Qt::MoveAction, 0, 0, QModelIndex())); | 434 | QVERIFY(m_places->dropMimeData(mimeData, Qt::MoveAction, 0, 0, QModelIndex())); | ||
430 | 435 | | |||
431 | urls.clear(); | 436 | urls.clear(); | ||
432 | urls << QStringLiteral("remote:/") << QDir::homePath() << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | 437 | urls << QStringLiteral("remote:/") << QDir::homePath() << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | ||
433 | << QStringLiteral("/media/nfs") << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom") << QStringLiteral("/foreign"); | 438 | << QStringLiteral("/media/nfs") << QStringLiteral("/foreign") | ||
439 | << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom"); | ||||
434 | CHECK_PLACES_URLS(urls); | 440 | CHECK_PLACES_URLS(urls); | ||
435 | QCOMPARE(spy_inserted.count(), 0); | 441 | QCOMPARE(spy_inserted.count(), 0); | ||
436 | QCOMPARE(spy_removed.count(), 0); | 442 | QCOMPARE(spy_removed.count(), 0); | ||
437 | QCOMPARE(spy_moved.count(), 1); | 443 | QCOMPARE(spy_moved.count(), 1); | ||
438 | args = spy_moved.takeFirst(); | 444 | args = spy_moved.takeFirst(); | ||
439 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | 445 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | ||
440 | QCOMPARE(args.at(1).toInt(), 3); | 446 | QCOMPARE(args.at(1).toInt(), 3); | ||
441 | QCOMPARE(args.at(2).toInt(), 3); | 447 | QCOMPARE(args.at(2).toInt(), 3); | ||
442 | QCOMPARE(args.at(3).toModelIndex(), QModelIndex()); | 448 | QCOMPARE(args.at(3).toModelIndex(), QModelIndex()); | ||
443 | QCOMPARE(args.at(4).toInt(), 0); | 449 | QCOMPARE(args.at(4).toInt(), 0); | ||
444 | 450 | | |||
445 | // Move the remote in the list (at its original place) | 451 | // Move the remote in the list (at its original place) | ||
446 | indexes.clear(); | 452 | indexes.clear(); | ||
447 | indexes << m_places->index(0, 0); | 453 | indexes << m_places->index(0, 0); | ||
448 | mimeData = m_places->mimeData(indexes); | 454 | mimeData = m_places->mimeData(indexes); | ||
449 | QVERIFY(m_places->dropMimeData(mimeData, Qt::MoveAction, 2, 0, QModelIndex())); | 455 | QVERIFY(m_places->dropMimeData(mimeData, Qt::MoveAction, 2, 0, QModelIndex())); | ||
450 | 456 | | |||
451 | urls.clear(); | 457 | urls.clear(); | ||
452 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | 458 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | ||
453 | << QStringLiteral("/media/nfs") << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom") << QStringLiteral("/foreign"); | 459 | << QStringLiteral("/media/nfs") << QStringLiteral("/foreign") | ||
460 | << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom"); | ||||
454 | CHECK_PLACES_URLS(urls); | 461 | CHECK_PLACES_URLS(urls); | ||
455 | QCOMPARE(spy_inserted.count(), 0); | 462 | QCOMPARE(spy_inserted.count(), 0); | ||
456 | QCOMPARE(spy_removed.count(), 0); | 463 | QCOMPARE(spy_removed.count(), 0); | ||
457 | QCOMPARE(spy_moved.count(), 1); | 464 | QCOMPARE(spy_moved.count(), 1); | ||
458 | args = spy_moved.takeFirst(); | 465 | args = spy_moved.takeFirst(); | ||
459 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | 466 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | ||
460 | QCOMPARE(args.at(1).toInt(), 0); | 467 | QCOMPARE(args.at(1).toInt(), 0); | ||
461 | QCOMPARE(args.at(2).toInt(), 0); | 468 | QCOMPARE(args.at(2).toInt(), 0); | ||
Show All 17 Lines | 484 | { | |||
479 | QSignalSpy spy_inserted(m_places, SIGNAL(rowsInserted(QModelIndex,int,int))); | 486 | QSignalSpy spy_inserted(m_places, SIGNAL(rowsInserted(QModelIndex,int,int))); | ||
480 | QSignalSpy spy_removed(m_places, SIGNAL(rowsRemoved(QModelIndex,int,int))); | 487 | QSignalSpy spy_removed(m_places, SIGNAL(rowsRemoved(QModelIndex,int,int))); | ||
481 | QSignalSpy spy_changed(m_places, SIGNAL(dataChanged(QModelIndex,QModelIndex))); | 488 | QSignalSpy spy_changed(m_places, SIGNAL(dataChanged(QModelIndex,QModelIndex))); | ||
482 | 489 | | |||
483 | m_places->addPlace(QStringLiteral("Foo"), QUrl::fromLocalFile(QStringLiteral("/home/foo"))); | 490 | m_places->addPlace(QStringLiteral("Foo"), QUrl::fromLocalFile(QStringLiteral("/home/foo"))); | ||
484 | 491 | | |||
485 | QStringList urls; | 492 | QStringList urls; | ||
486 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") << QStringLiteral("/home/foo") | 493 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") << QStringLiteral("/home/foo") | ||
487 | << QStringLiteral("/media/nfs") << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom") << QStringLiteral("/foreign"); | 494 | << QStringLiteral("/media/nfs") << QStringLiteral("/foreign") | ||
495 | << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom"); | ||||
488 | 496 | | |||
489 | CHECK_PLACES_URLS(urls); | 497 | CHECK_PLACES_URLS(urls); | ||
490 | QCOMPARE(spy_inserted.count(), 1); | 498 | QCOMPARE(spy_inserted.count(), 1); | ||
491 | args = spy_inserted.takeFirst(); | 499 | args = spy_inserted.takeFirst(); | ||
492 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | 500 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | ||
493 | QCOMPARE(args.at(1).toInt(), 4); | 501 | QCOMPARE(args.at(1).toInt(), 4); | ||
494 | QCOMPARE(args.at(2).toInt(), 4); | 502 | QCOMPARE(args.at(2).toInt(), 4); | ||
495 | QCOMPARE(spy_removed.count(), 0); | 503 | QCOMPARE(spy_removed.count(), 0); | ||
496 | 504 | | |||
497 | KBookmarkManager *bookmarkManager = KBookmarkManager::managerForFile(bookmarksFile(), QStringLiteral("kfilePlaces")); | 505 | KBookmarkManager *bookmarkManager = KBookmarkManager::managerForFile(bookmarksFile(), QStringLiteral("kfilePlaces")); | ||
498 | KBookmarkGroup root = bookmarkManager->root(); | 506 | KBookmarkGroup root = bookmarkManager->root(); | ||
499 | KBookmark before_trash = m_places->bookmarkForIndex(m_places->index(2, 0)); | 507 | KBookmark before_trash = m_places->bookmarkForIndex(m_places->index(2, 0)); | ||
500 | KBookmark foo = m_places->bookmarkForIndex(m_places->index(4, 0)); | 508 | KBookmark foo = m_places->bookmarkForIndex(m_places->index(4, 0)); | ||
501 | 509 | | |||
502 | root.moveBookmark(foo, before_trash); | 510 | root.moveBookmark(foo, before_trash); | ||
503 | bookmarkManager->emitChanged(root); | 511 | bookmarkManager->emitChanged(root); | ||
504 | 512 | | |||
505 | urls.clear(); | 513 | urls.clear(); | ||
506 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("/home/foo") | 514 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("/home/foo") << QStringLiteral("trash:/") | ||
507 | << QStringLiteral("trash:/") << QStringLiteral("/media/nfs") << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom") << QStringLiteral("/foreign"); | 515 | << QStringLiteral("/media/nfs") << QStringLiteral("/foreign") | ||
516 | << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom"); | ||||
508 | CHECK_PLACES_URLS(urls); | 517 | CHECK_PLACES_URLS(urls); | ||
509 | QCOMPARE(spy_inserted.count(), 1); | 518 | QCOMPARE(spy_inserted.count(), 1); | ||
510 | args = spy_inserted.takeFirst(); | 519 | args = spy_inserted.takeFirst(); | ||
511 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | 520 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | ||
512 | QCOMPARE(args.at(1).toInt(), 4); | 521 | QCOMPARE(args.at(1).toInt(), 4); | ||
513 | QCOMPARE(args.at(2).toInt(), 4); | 522 | QCOMPARE(args.at(2).toInt(), 4); | ||
514 | QCOMPARE(spy_removed.count(), 1); | 523 | QCOMPARE(spy_removed.count(), 1); | ||
515 | args = spy_removed.takeFirst(); | 524 | args = spy_removed.takeFirst(); | ||
516 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | 525 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | ||
517 | QCOMPARE(args.at(1).toInt(), 3); | 526 | QCOMPARE(args.at(1).toInt(), 3); | ||
518 | QCOMPARE(args.at(2).toInt(), 3); | 527 | QCOMPARE(args.at(2).toInt(), 3); | ||
519 | 528 | | |||
520 | m_places->editPlace(m_places->index(3, 0), QStringLiteral("Foo"), QUrl::fromLocalFile(QStringLiteral("/mnt/foo"))); | 529 | m_places->editPlace(m_places->index(3, 0), QStringLiteral("Foo"), QUrl::fromLocalFile(QStringLiteral("/mnt/foo"))); | ||
521 | 530 | | |||
522 | urls.clear(); | 531 | urls.clear(); | ||
523 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("/mnt/foo") | 532 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("/mnt/foo") << QStringLiteral("trash:/") | ||
524 | << QStringLiteral("trash:/") << QStringLiteral("/media/nfs") << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom") << QStringLiteral("/foreign"); | 533 | << QStringLiteral("/media/nfs") << QStringLiteral("/foreign") | ||
534 | << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom"); | ||||
525 | CHECK_PLACES_URLS(urls); | 535 | CHECK_PLACES_URLS(urls); | ||
526 | QCOMPARE(spy_inserted.count(), 0); | 536 | QCOMPARE(spy_inserted.count(), 0); | ||
527 | QCOMPARE(spy_removed.count(), 0); | 537 | QCOMPARE(spy_removed.count(), 0); | ||
528 | QCOMPARE(spy_changed.count(), 1); | 538 | QCOMPARE(spy_changed.count(), 1); | ||
529 | args = spy_changed.takeFirst(); | 539 | args = spy_changed.takeFirst(); | ||
530 | QCOMPARE(args.at(0).toModelIndex(), m_places->index(3, 0)); | 540 | QCOMPARE(args.at(0).toModelIndex(), m_places->index(3, 0)); | ||
531 | QCOMPARE(args.at(1).toModelIndex(), m_places->index(3, 0)); | 541 | QCOMPARE(args.at(1).toModelIndex(), m_places->index(3, 0)); | ||
532 | 542 | | |||
533 | foo = m_places->bookmarkForIndex(m_places->index(3, 0)); | 543 | foo = m_places->bookmarkForIndex(m_places->index(3, 0)); | ||
534 | foo.setFullText(QStringLiteral("Bar")); | 544 | foo.setFullText(QStringLiteral("Bar")); | ||
535 | bookmarkManager->notifyCompleteChange(QString()); | 545 | bookmarkManager->notifyCompleteChange(QString()); | ||
536 | 546 | | |||
537 | urls.clear(); | 547 | urls.clear(); | ||
538 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("/mnt/foo") | 548 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("/mnt/foo") << QStringLiteral("trash:/") | ||
539 | << QStringLiteral("trash:/") << QStringLiteral("/media/nfs") << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom") << QStringLiteral("/foreign"); | 549 | << QStringLiteral("/media/nfs") << QStringLiteral("/foreign") | ||
550 | << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom"); | ||||
540 | CHECK_PLACES_URLS(urls); | 551 | CHECK_PLACES_URLS(urls); | ||
541 | QCOMPARE(spy_inserted.count(), 0); | 552 | QCOMPARE(spy_inserted.count(), 0); | ||
542 | QCOMPARE(spy_removed.count(), 0); | 553 | QCOMPARE(spy_removed.count(), 0); | ||
543 | QCOMPARE(spy_changed.count(), 10); | 554 | QCOMPARE(spy_changed.count(), 10); | ||
544 | args = spy_changed[3]; | 555 | args = spy_changed[3]; | ||
545 | QCOMPARE(args.at(0).toModelIndex(), m_places->index(3, 0)); | 556 | QCOMPARE(args.at(0).toModelIndex(), m_places->index(3, 0)); | ||
546 | QCOMPARE(args.at(1).toModelIndex(), m_places->index(3, 0)); | 557 | QCOMPARE(args.at(1).toModelIndex(), m_places->index(3, 0)); | ||
547 | spy_changed.clear(); | 558 | spy_changed.clear(); | ||
548 | 559 | | |||
549 | m_places->removePlace(m_places->index(3, 0)); | 560 | m_places->removePlace(m_places->index(3, 0)); | ||
550 | 561 | | |||
551 | urls.clear(); | 562 | urls.clear(); | ||
552 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | 563 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | ||
553 | << QStringLiteral("/media/nfs") << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom") << QStringLiteral("/foreign"); | 564 | << QStringLiteral("/media/nfs") << QStringLiteral("/foreign") | ||
565 | << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom"); | ||||
554 | CHECK_PLACES_URLS(urls); | 566 | CHECK_PLACES_URLS(urls); | ||
555 | QCOMPARE(spy_inserted.count(), 0); | 567 | QCOMPARE(spy_inserted.count(), 0); | ||
556 | QCOMPARE(spy_removed.count(), 1); | 568 | QCOMPARE(spy_removed.count(), 1); | ||
557 | args = spy_removed.takeFirst(); | 569 | args = spy_removed.takeFirst(); | ||
558 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | 570 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | ||
559 | QCOMPARE(args.at(1).toInt(), 3); | 571 | QCOMPARE(args.at(1).toInt(), 3); | ||
560 | QCOMPARE(args.at(2).toInt(), 3); | 572 | QCOMPARE(args.at(2).toInt(), 3); | ||
561 | 573 | | |||
562 | m_places->addPlace(QStringLiteral("Foo"), QUrl::fromLocalFile(QStringLiteral("/home/foo")), QString(), QString(), m_places->index(1, 0)); | 574 | m_places->addPlace(QStringLiteral("Foo"), QUrl::fromLocalFile(QStringLiteral("/home/foo")), QString(), QString(), m_places->index(1, 0)); | ||
563 | 575 | | |||
564 | urls.clear(); | 576 | urls.clear(); | ||
565 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral("/home/foo") << QStringLiteral(KDE_ROOT_PATH) | 577 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral("/home/foo") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | ||
566 | << QStringLiteral("trash:/") << QStringLiteral("/media/nfs") << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom") << QStringLiteral("/foreign"); | 578 | << QStringLiteral("/media/nfs") << QStringLiteral("/foreign") | ||
567 | 579 | << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom"); | |||
568 | CHECK_PLACES_URLS(urls); | 580 | CHECK_PLACES_URLS(urls); | ||
569 | QCOMPARE(spy_inserted.count(), 1); | 581 | QCOMPARE(spy_inserted.count(), 1); | ||
570 | args = spy_inserted.takeFirst(); | 582 | args = spy_inserted.takeFirst(); | ||
571 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | 583 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | ||
572 | QCOMPARE(args.at(1).toInt(), 2); | 584 | QCOMPARE(args.at(1).toInt(), 2); | ||
573 | QCOMPARE(args.at(2).toInt(), 2); | 585 | QCOMPARE(args.at(2).toInt(), 2); | ||
574 | QCOMPARE(spy_removed.count(), 0); | 586 | QCOMPARE(spy_removed.count(), 0); | ||
575 | 587 | | |||
576 | m_places->removePlace(m_places->index(2, 0)); | 588 | m_places->removePlace(m_places->index(2, 0)); | ||
577 | } | 589 | } | ||
578 | 590 | | |||
579 | void KFilePlacesModelTest::testDevicePlugging() | 591 | void KFilePlacesModelTest::testDevicePlugging() | ||
580 | { | 592 | { | ||
581 | QList<QVariant> args; | 593 | QList<QVariant> args; | ||
582 | QSignalSpy spy_inserted(m_places, SIGNAL(rowsInserted(QModelIndex,int,int))); | 594 | QSignalSpy spy_inserted(m_places, SIGNAL(rowsInserted(QModelIndex,int,int))); | ||
583 | QSignalSpy spy_removed(m_places, SIGNAL(rowsRemoved(QModelIndex,int,int))); | 595 | QSignalSpy spy_removed(m_places, SIGNAL(rowsRemoved(QModelIndex,int,int))); | ||
584 | 596 | | |||
585 | fakeManager()->call(QStringLiteral("unplug"), "/org/kde/solid/fakehw/volume_part1_size_993284096"); | 597 | fakeManager()->call(QStringLiteral("unplug"), "/org/kde/solid/fakehw/volume_part1_size_993284096"); | ||
586 | 598 | | |||
587 | QStringList urls; | 599 | QStringList urls; | ||
588 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | 600 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | ||
589 | << QStringLiteral("/media/nfs") << QStringLiteral("/media/floppy0") << QStringLiteral("/media/cdrom") << QStringLiteral("/foreign"); | 601 | << QStringLiteral("/media/nfs") << QStringLiteral("/foreign") | ||
602 | << QStringLiteral("/media/floppy0") << QStringLiteral("/media/cdrom"); | ||||
590 | CHECK_PLACES_URLS(urls); | 603 | CHECK_PLACES_URLS(urls); | ||
591 | QCOMPARE(spy_inserted.count(), 0); | 604 | QCOMPARE(spy_inserted.count(), 0); | ||
592 | QCOMPARE(spy_removed.count(), 1); | 605 | QCOMPARE(spy_removed.count(), 1); | ||
593 | args = spy_removed.takeFirst(); | 606 | args = spy_removed.takeFirst(); | ||
594 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | 607 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | ||
595 | QCOMPARE(args.at(1).toInt(), 6); | 608 | QCOMPARE(args.at(1).toInt(), 7); | ||
596 | QCOMPARE(args.at(2).toInt(), 6); | 609 | QCOMPARE(args.at(2).toInt(), 7); | ||
597 | 610 | | |||
598 | fakeManager()->call(QStringLiteral("plug"), "/org/kde/solid/fakehw/volume_part1_size_993284096"); | 611 | fakeManager()->call(QStringLiteral("plug"), "/org/kde/solid/fakehw/volume_part1_size_993284096"); | ||
599 | 612 | | |||
600 | urls.clear(); | 613 | urls.clear(); | ||
601 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | 614 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | ||
602 | << QStringLiteral("/media/nfs") << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom") << QStringLiteral("/foreign"); | 615 | << QStringLiteral("/media/nfs") << QStringLiteral("/foreign") | ||
616 | << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom"); | ||||
603 | CHECK_PLACES_URLS(urls); | 617 | CHECK_PLACES_URLS(urls); | ||
604 | QCOMPARE(spy_inserted.count(), 1); | 618 | QCOMPARE(spy_inserted.count(), 1); | ||
605 | args = spy_inserted.takeFirst(); | 619 | args = spy_inserted.takeFirst(); | ||
606 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | 620 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | ||
607 | QCOMPARE(args.at(1).toInt(), 6); | 621 | QCOMPARE(args.at(1).toInt(), 7); | ||
608 | QCOMPARE(args.at(2).toInt(), 6); | 622 | QCOMPARE(args.at(2).toInt(), 7); | ||
609 | QCOMPARE(spy_removed.count(), 0); | 623 | QCOMPARE(spy_removed.count(), 0); | ||
610 | 624 | | |||
611 | // Move the device in the list, and check that it memorizes the position across plug/unplug | 625 | // Move the device in the list, and check that it memorizes the position across plug/unplug | ||
612 | 626 | | |||
613 | KBookmarkManager *bookmarkManager = KBookmarkManager::managerForFile(bookmarksFile(), QStringLiteral("kfilePlaces")); | 627 | KBookmarkManager *bookmarkManager = KBookmarkManager::managerForFile(bookmarksFile(), QStringLiteral("kfilePlaces")); | ||
614 | KBookmarkGroup root = bookmarkManager->root(); | 628 | KBookmarkGroup root = bookmarkManager->root(); | ||
615 | KBookmark before_nfs = m_places->bookmarkForIndex(m_places->index(3, 0)); | 629 | KBookmark before_floppy; | ||
630 | | ||||
616 | KBookmark device = root.first(); // The device we'll move is the 7th bookmark | 631 | KBookmark device = root.first(); // The device we'll move is the 7th bookmark | ||
617 | for (int i = 0; i < 6; i++) { | 632 | for (int i = 0; i < 6; i++) { | ||
633 | if (i == 3) { | ||||
634 | // store item before to be able to move it back to original position | ||||
635 | device = before_floppy = root.next(device); | ||||
636 | } else { | ||||
618 | device = root.next(device); | 637 | device = root.next(device); | ||
619 | } | 638 | } | ||
639 | } | ||||
620 | 640 | | |||
621 | root.moveBookmark(device, before_nfs); | 641 | root.moveBookmark(device, before_floppy); | ||
622 | bookmarkManager->emitChanged(root); | 642 | bookmarkManager->emitChanged(root); | ||
623 | 643 | | |||
624 | urls.clear(); | 644 | urls.clear(); | ||
625 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | 645 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | ||
626 | << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/nfs") << QStringLiteral("/media/floppy0") << QStringLiteral("/media/cdrom") << QStringLiteral("/foreign"); | 646 | << QStringLiteral("/media/nfs") << QStringLiteral("/foreign") | ||
647 | << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/floppy0") << QStringLiteral("/media/cdrom"); | ||||
627 | CHECK_PLACES_URLS(urls); | 648 | CHECK_PLACES_URLS(urls); | ||
628 | QCOMPARE(spy_inserted.count(), 1); | 649 | QCOMPARE(spy_inserted.count(), 1); | ||
629 | args = spy_inserted.takeFirst(); | 650 | args = spy_inserted.takeFirst(); | ||
630 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | 651 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | ||
631 | QCOMPARE(args.at(1).toInt(), 4); | 652 | QCOMPARE(args.at(1).toInt(), 7); | ||
632 | QCOMPARE(args.at(2).toInt(), 4); | 653 | QCOMPARE(args.at(2).toInt(), 7); | ||
633 | QCOMPARE(spy_removed.count(), 1); | 654 | QCOMPARE(spy_removed.count(), 1); | ||
634 | args = spy_removed.takeFirst(); | 655 | args = spy_removed.takeFirst(); | ||
635 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | 656 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | ||
636 | QCOMPARE(args.at(1).toInt(), 7); | 657 | QCOMPARE(args.at(1).toInt(), 6); | ||
637 | QCOMPARE(args.at(2).toInt(), 7); | 658 | QCOMPARE(args.at(2).toInt(), 6); | ||
638 | 659 | | |||
639 | fakeManager()->call(QStringLiteral("unplug"), "/org/kde/solid/fakehw/volume_part1_size_993284096"); | 660 | fakeManager()->call(QStringLiteral("unplug"), "/org/kde/solid/fakehw/volume_part1_size_993284096"); | ||
640 | 661 | | |||
641 | urls.clear(); | 662 | urls.clear(); | ||
642 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) | 663 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | ||
643 | << QStringLiteral("trash:/") << QStringLiteral("/media/nfs") << QStringLiteral("/media/floppy0") << QStringLiteral("/media/cdrom") << QStringLiteral("/foreign"); | 664 | << QStringLiteral("/media/nfs") << QStringLiteral("/foreign") | ||
665 | << QStringLiteral("/media/floppy0") << QStringLiteral("/media/cdrom"); | ||||
644 | CHECK_PLACES_URLS(urls); | 666 | CHECK_PLACES_URLS(urls); | ||
645 | QCOMPARE(spy_inserted.count(), 0); | 667 | QCOMPARE(spy_inserted.count(), 0); | ||
646 | QCOMPARE(spy_removed.count(), 1); | 668 | QCOMPARE(spy_removed.count(), 1); | ||
647 | args = spy_removed.takeFirst(); | 669 | args = spy_removed.takeFirst(); | ||
648 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | 670 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | ||
649 | QCOMPARE(args.at(1).toInt(), 4); | 671 | QCOMPARE(args.at(1).toInt(), 6); | ||
650 | QCOMPARE(args.at(2).toInt(), 4); | 672 | QCOMPARE(args.at(2).toInt(), 6); | ||
651 | 673 | | |||
652 | fakeManager()->call(QStringLiteral("plug"), "/org/kde/solid/fakehw/volume_part1_size_993284096"); | 674 | fakeManager()->call(QStringLiteral("plug"), "/org/kde/solid/fakehw/volume_part1_size_993284096"); | ||
653 | 675 | | |||
654 | urls.clear(); | 676 | urls.clear(); | ||
655 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | 677 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | ||
656 | << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/nfs") << QStringLiteral("/media/floppy0") << QStringLiteral("/media/cdrom") << QStringLiteral("/foreign"); | 678 | << QStringLiteral("/media/nfs") << QStringLiteral("/foreign") << QStringLiteral("/media/XO-Y4") | ||
679 | << QStringLiteral("/media/floppy0") << QStringLiteral("/media/cdrom"); | ||||
657 | CHECK_PLACES_URLS(urls); | 680 | CHECK_PLACES_URLS(urls); | ||
658 | QCOMPARE(spy_inserted.count(), 1); | 681 | QCOMPARE(spy_inserted.count(), 1); | ||
659 | args = spy_inserted.takeFirst(); | 682 | args = spy_inserted.takeFirst(); | ||
660 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | 683 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | ||
661 | QCOMPARE(args.at(1).toInt(), 4); | 684 | QCOMPARE(args.at(1).toInt(), 6); | ||
662 | QCOMPARE(args.at(2).toInt(), 4); | 685 | QCOMPARE(args.at(2).toInt(), 6); | ||
663 | QCOMPARE(spy_removed.count(), 0); | 686 | QCOMPARE(spy_removed.count(), 0); | ||
664 | 687 | | |||
665 | KBookmark seventh = root.first(); | 688 | KBookmark seventh = root.first(); | ||
666 | for (int i = 0; i < 6; i++) { | 689 | for (int i = 0; i < 6; i++) { | ||
667 | seventh = root.next(seventh); | 690 | seventh = root.next(seventh); | ||
668 | } | 691 | } | ||
669 | root.moveBookmark(device, seventh); | 692 | root.moveBookmark(device, seventh); | ||
670 | bookmarkManager->emitChanged(root); | 693 | bookmarkManager->emitChanged(root); | ||
671 | 694 | | |||
672 | urls.clear(); | 695 | urls.clear(); | ||
673 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | 696 | urls << QDir::homePath() << QStringLiteral("remote:/") << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/") | ||
674 | << QStringLiteral("/media/nfs") << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom") << QStringLiteral("/foreign"); | 697 | << QStringLiteral("/media/nfs") << QStringLiteral("/foreign") | ||
698 | << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom"); | ||||
675 | CHECK_PLACES_URLS(urls); | 699 | CHECK_PLACES_URLS(urls); | ||
676 | QCOMPARE(spy_inserted.count(), 1); | 700 | QCOMPARE(spy_inserted.count(), 1); | ||
677 | args = spy_inserted.takeFirst(); | 701 | args = spy_inserted.takeFirst(); | ||
678 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | 702 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | ||
679 | QCOMPARE(args.at(1).toInt(), 6); | 703 | QCOMPARE(args.at(1).toInt(), 7); | ||
680 | QCOMPARE(args.at(2).toInt(), 6); | 704 | QCOMPARE(args.at(2).toInt(), 7); | ||
681 | QCOMPARE(spy_removed.count(), 1); | 705 | QCOMPARE(spy_removed.count(), 1); | ||
682 | args = spy_removed.takeFirst(); | 706 | args = spy_removed.takeFirst(); | ||
683 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | 707 | QCOMPARE(args.at(0).toModelIndex(), QModelIndex()); | ||
684 | QCOMPARE(args.at(1).toInt(), 4); | 708 | QCOMPARE(args.at(1).toInt(), 6); | ||
685 | QCOMPARE(args.at(2).toInt(), 4); | 709 | QCOMPARE(args.at(2).toInt(), 6); | ||
686 | } | 710 | } | ||
687 | 711 | | |||
688 | void KFilePlacesModelTest::testDeviceSetupTeardown() | 712 | void KFilePlacesModelTest::testDeviceSetupTeardown() | ||
689 | { | 713 | { | ||
690 | QList<QVariant> args; | 714 | QList<QVariant> args; | ||
691 | QSignalSpy spy_changed(m_places, SIGNAL(dataChanged(QModelIndex,QModelIndex))); | 715 | QSignalSpy spy_changed(m_places, SIGNAL(dataChanged(QModelIndex,QModelIndex))); | ||
692 | 716 | | |||
693 | fakeDevice(QStringLiteral("/org/kde/solid/fakehw/volume_part1_size_993284096/StorageAccess"))->call(QStringLiteral("teardown")); | 717 | fakeDevice(QStringLiteral("/org/kde/solid/fakehw/volume_part1_size_993284096/StorageAccess"))->call(QStringLiteral("teardown")); | ||
694 | 718 | | |||
695 | QCOMPARE(spy_changed.count(), 1); | 719 | QCOMPARE(spy_changed.count(), 1); | ||
696 | args = spy_changed.takeFirst(); | 720 | args = spy_changed.takeFirst(); | ||
697 | QCOMPARE(args.at(0).toModelIndex().row(), 6); | 721 | QCOMPARE(args.at(0).toModelIndex().row(), 7); | ||
698 | QCOMPARE(args.at(1).toModelIndex().row(), 6); | 722 | QCOMPARE(args.at(1).toModelIndex().row(), 7); | ||
699 | 723 | | |||
700 | fakeDevice(QStringLiteral("/org/kde/solid/fakehw/volume_part1_size_993284096/StorageAccess"))->call(QStringLiteral("setup")); | 724 | fakeDevice(QStringLiteral("/org/kde/solid/fakehw/volume_part1_size_993284096/StorageAccess"))->call(QStringLiteral("setup")); | ||
701 | 725 | | |||
702 | QCOMPARE(spy_changed.count(), 1); | 726 | QCOMPARE(spy_changed.count(), 1); | ||
703 | args = spy_changed.takeFirst(); | 727 | args = spy_changed.takeFirst(); | ||
704 | QCOMPARE(args.at(0).toModelIndex().row(), 6); | 728 | QCOMPARE(args.at(0).toModelIndex().row(), 7); | ||
705 | QCOMPARE(args.at(1).toModelIndex().row(), 6); | 729 | QCOMPARE(args.at(1).toModelIndex().row(), 7); | ||
706 | } | 730 | } | ||
707 | 731 | | |||
708 | void KFilePlacesModelTest::testEnableBaloo() | 732 | void KFilePlacesModelTest::testEnableBaloo() | ||
709 | { | 733 | { | ||
710 | KConfig config(QStringLiteral("baloofilerc")); | 734 | KConfig config(QStringLiteral("baloofilerc")); | ||
711 | KConfigGroup basicSettings = config.group("Basic Settings"); | 735 | KConfigGroup basicSettings = config.group("Basic Settings"); | ||
712 | basicSettings.writeEntry("Indexing-Enabled", true); | 736 | basicSettings.writeEntry("Indexing-Enabled", true); | ||
713 | config.sync(); | 737 | config.sync(); | ||
Show All 22 Lines |
the changed list of remote urls that is repeated below could be put into another helper function