]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Merge remote-tracking branch 'origin/KDE/4.10'
authorFrank Reininghaus <frank78ac@googlemail.com>
Sun, 27 Jan 2013 14:25:47 +0000 (15:25 +0100)
committerFrank Reininghaus <frank78ac@googlemail.com>
Sun, 27 Jan 2013 14:25:47 +0000 (15:25 +0100)
Conflicts:
dolphin/src/tests/kfileitemmodeltest.cpp

1  2 
src/tests/kfileitemmodeltest.cpp

index 3fc2b7c9ae0429c8c964ad9eb7267e68977a515a,65368b75baf3addb2aa330ecf0fa172a6d5a26d3..d0f2e1eaaf3c4b52d1c4489ccef7f5b3ddc5d540
@@@ -72,12 -72,12 +72,11 @@@ private slots
      void testExpandItems();
      void testExpandParentItems();
      void testSorting();
      void testIndexForKeyboardSearch();
      void testNameFilter();
+     void testEmptyPath();
  
  private:
 -    bool isModelConsistent() const;
      QStringList itemsInModel() const;
  
  private:
@@@ -773,6 -773,54 +772,31 @@@ void KFileItemModelTest::testNameFilter
      QCOMPARE(m_model->count(), 5);
  }
  
 -bool KFileItemModelTest::isModelConsistent() const
 -{
 -    if (m_model->m_items.count() != m_model->m_itemData.count()) {
 -        return false;
 -    }
 -
 -    for (int i = 0; i < m_model->count(); ++i) {
 -        const KFileItem item = m_model->fileItem(i);
 -        if (item.isNull()) {
 -            qWarning() << "Item" << i << "is null";
 -            return false;
 -        }
 -
 -        const int itemIndex = m_model->index(item);
 -        if (itemIndex != i) {
 -            qWarning() << "Item" << i << "has a wrong index:" << itemIndex;
 -            return false;
 -        }
 -    }
 -
 -    return true;
 -}
 -
+ /**
+  * Verifies that we do not crash when adding a KFileItem with an empty path.
+  * Before this issue was fixed, KFileItemModel::expandedParentsCountCompare()
+  * tried to always read the first character of the path, even if the path is empty.
+  */
+ void KFileItemModelTest::testEmptyPath()
+ {
+     QSet<QByteArray> roles;
+     roles.insert("text");
+     roles.insert("isExpanded");
+     roles.insert("isExpandable");
+     roles.insert("expandedParentsCount");
+     m_model->setRoles(roles);
+     const KUrl emptyUrl;
+     QVERIFY(emptyUrl.path().isEmpty());
+     
+     const KUrl url("file:///test/");
+     
+     KFileItemList items;
+     items << KFileItem(emptyUrl, QString(), KFileItem::Unknown) << KFileItem(url, QString(), KFileItem::Unknown);
+     m_model->slotNewItems(items);
+     m_model->slotCompleted();
+ }
  QStringList KFileItemModelTest::itemsInModel() const
  {
      QStringList items;