Changeset View
Changeset View
Standalone View
Standalone View
src/tests/placesitemmodeltest.cpp
Show First 20 Lines • Show All 78 Lines • ▼ Show 20 Line(s) | 60 | private slots: | |||
---|---|---|---|---|---|
79 | void testEditAfterCreation(); | 79 | void testEditAfterCreation(); | ||
80 | void testEditMetadata(); | 80 | void testEditMetadata(); | ||
81 | void testRefresh(); | 81 | void testRefresh(); | ||
82 | void testIcons_data(); | 82 | void testIcons_data(); | ||
83 | void testIcons(); | 83 | void testIcons(); | ||
84 | void testDragAndDrop(); | 84 | void testDragAndDrop(); | ||
85 | void testHideDevices(); | 85 | void testHideDevices(); | ||
86 | void testDuplicatedEntries(); | 86 | void testDuplicatedEntries(); | ||
87 | void renameAfterCreation(); | ||||
87 | 88 | | |||
88 | private: | 89 | private: | ||
89 | PlacesItemModel* m_model; | 90 | PlacesItemModel* m_model; | ||
90 | QSet<int> m_tobeRemoved; | 91 | QSet<int> m_tobeRemoved; | ||
91 | QMap<QString, QDBusInterface *> m_interfacesMap; | 92 | QMap<QString, QDBusInterface *> m_interfacesMap; | ||
92 | 93 | | |||
93 | void setBalooEnabled(bool enabled); | 94 | void setBalooEnabled(bool enabled); | ||
94 | int indexOf(const QUrl &url); | 95 | int indexOf(const QUrl &url); | ||
▲ Show 20 Lines • Show All 708 Lines • ▼ Show 20 Line(s) | 794 | { | |||
803 | bookmarkManager->emitChanged(bookmarkManager->root()); | 804 | bookmarkManager->emitChanged(bookmarkManager->root()); | ||
804 | 805 | | |||
805 | PlacesItemModel *newModel = new PlacesItemModel(); | 806 | PlacesItemModel *newModel = new PlacesItemModel(); | ||
806 | QTRY_COMPARE(placesUrls(newModel).count(QStringLiteral("search:/videos")), 1); | 807 | QTRY_COMPARE(placesUrls(newModel).count(QStringLiteral("search:/videos")), 1); | ||
807 | QTRY_COMPARE(urls, placesUrls(newModel)); | 808 | QTRY_COMPARE(urls, placesUrls(newModel)); | ||
808 | delete newModel; | 809 | delete newModel; | ||
809 | } | 810 | } | ||
810 | 811 | | |||
812 | void PlacesItemModelTest::renameAfterCreation() | ||||
813 | { | ||||
814 | const QUrl tempUrl = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::TempLocation)); | ||||
815 | QStringList urls = initialUrls(); | ||||
816 | PlacesItemModel *model = new PlacesItemModel(); | ||||
817 | | ||||
818 | CHECK_PLACES_URLS(urls); | ||||
819 | QTRY_COMPARE(model->count(), m_model->count()); | ||||
820 | | ||||
821 | // create a new place | ||||
822 | createPlaceItem(QStringLiteral("Temporary Dir"), tempUrl, QString()); | ||||
823 | urls.insert(3, tempUrl.toLocalFile()); | ||||
824 | | ||||
825 | // make sure that the new item will be removed later | ||||
826 | removePlaceAfter(3); | ||||
827 | | ||||
828 | CHECK_PLACES_URLS(urls); | ||||
829 | QCOMPARE(model->count(), m_model->count()); | ||||
830 | | ||||
831 | | ||||
832 | // modify place text | ||||
833 | QSignalSpy changedSpy(m_model, &PlacesItemModel::itemsChanged); | ||||
834 | | ||||
835 | PlacesItem *item = m_model->placesItem(3); | ||||
836 | item->setText(QStringLiteral("New Temporary Dir")); | ||||
837 | item->setUrl(item->url()); | ||||
838 | item->setIcon(item->icon()); | ||||
839 | m_model->refresh(); | ||||
840 | | ||||
841 | QTRY_COMPARE(changedSpy.count(), 1); | ||||
842 | | ||||
843 | // check if the place was modified in both models | ||||
844 | QTRY_COMPARE(m_model->placesItem(3)->text(), QStringLiteral("New Temporary Dir")); | ||||
845 | QTRY_COMPARE(model->placesItem(3)->text(), QStringLiteral("New Temporary Dir")); | ||||
846 | } | ||||
michaelh: This warning will be more helpful when you make clear who is the emitter. | |||||
847 | | ||||
811 | QTEST_MAIN(PlacesItemModelTest) | 848 | QTEST_MAIN(PlacesItemModelTest) | ||
812 | 849 | | |||
813 | #include "placesitemmodeltest.moc" | 850 | #include "placesitemmodeltest.moc" |
This warning will be more helpful when you make clear who is the emitter.