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