┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2012-04-21 21:28:16 +0200
committerPeter Penz <[email protected]>2012-04-21 21:32:42 +0200
commitae4d11d918938fd9087f2035dac247969c1f2313 (patch)
tree0303667797c81814b46b9ed5ed20b48ef31f2d71 /src/tests
parent47d7cdffdd2d2c04067a5088eaeff67add53dde3 (diff)
Prepare view-engine for non-KFileItem usecase
Up to now the view-engine only provided a model-implementation that supports file-items. The view-engine always had been designed to be able to work with any kind of model, so now a KStandardItemModel is available. The plan is to convert the places panel to the new view-engine. It should be no problem to fix this until the feature freeze - in the worst case the places-panel code could be reverted while still keeping the KStandardItemModel changes.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/kfileitemmodeltest.cpp24
-rw-r--r--src/tests/kitemlistcontrollertest.cpp27
2 files changed, 21 insertions, 30 deletions
diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp
index 9eee50d44..7b56957d4 100644
--- a/src/tests/kfileitemmodeltest.cpp
+++ b/src/tests/kfileitemmodeltest.cpp
@@ -114,13 +114,13 @@ void KFileItemModelTest::testDefaultRoles()
{
const QSet<QByteArray> roles = m_model->roles();
QCOMPARE(roles.count(), 2);
- QVERIFY(roles.contains("name"));
+ QVERIFY(roles.contains("text"));
QVERIFY(roles.contains("isDir"));
}
void KFileItemModelTest::testDefaultSortRole()
{
- QCOMPARE(m_model->sortRole(), QByteArray("name"));
+ QCOMPARE(m_model->sortRole(), QByteArray("text"));
QStringList files;
files << "c.txt" << "a.txt" << "b.txt";
@@ -131,9 +131,9 @@ void KFileItemModelTest::testDefaultSortRole()
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
QCOMPARE(m_model->count(), 3);
- QCOMPARE(m_model->data(0)["name"].toString(), QString("a.txt"));
- QCOMPARE(m_model->data(1)["name"].toString(), QString("b.txt"));
- QCOMPARE(m_model->data(2)["name"].toString(), QString("c.txt"));
+ QCOMPARE(m_model->data(0)["text"].toString(), QString("a.txt"));
+ QCOMPARE(m_model->data(1)["text"].toString(), QString("b.txt"));
+ QCOMPARE(m_model->data(2)["text"].toString(), QString("c.txt"));
}
void KFileItemModelTest::testDefaultGroupedSorting()
@@ -269,7 +269,7 @@ void KFileItemModelTest::testSetDataWithModifiedSortRole()
// Changing the value of a sort-role must result in
// a reordering of the items.
- QCOMPARE(m_model->sortRole(), QByteArray("name"));
+ QCOMPARE(m_model->sortRole(), QByteArray("text"));
QStringList files;
files << "a.txt" << "b.txt" << "c.txt";
@@ -572,7 +572,7 @@ void KFileItemModelTest::testSorting()
QDateTime now = QDateTime::currentDateTime();
QSet<QByteArray> roles;
- roles.insert("name");
+ roles.insert("text");
roles.insert("isExpanded");
roles.insert("isExpandable");
roles.insert("expandedParentsCount");
@@ -601,7 +601,7 @@ void KFileItemModelTest::testSorting()
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
// Default: Sort by Name, ascending
- QCOMPARE(m_model->sortRole(), QByteArray("name"));
+ QCOMPARE(m_model->sortRole(), QByteArray("text"));
QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder);
QVERIFY(m_model->sortDirectoriesFirst());
QVERIFY(!m_model->showHiddenFiles());
@@ -611,7 +611,7 @@ void KFileItemModelTest::testSorting()
// Sort by Name, ascending, 'Sort Folders First' disabled
m_model->setSortDirectoriesFirst(false);
- QCOMPARE(m_model->sortRole(), QByteArray("name"));
+ QCOMPARE(m_model->sortRole(), QByteArray("text"));
QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder);
QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c" << "c-1" << "c-2" << "c-3" << "d" << "e");
QCOMPARE(spyItemsMoved.count(), 1);
@@ -620,7 +620,7 @@ void KFileItemModelTest::testSorting()
// Sort by Name, descending
m_model->setSortDirectoriesFirst(true);
m_model->setSortOrder(Qt::DescendingOrder);
- QCOMPARE(m_model->sortRole(), QByteArray("name"));
+ QCOMPARE(m_model->sortRole(), QByteArray("text"));
QCOMPARE(m_model->sortOrder(), Qt::DescendingOrder);
QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "e" << "d" << "b" << "a");
QCOMPARE(spyItemsMoved.count(), 2);
@@ -654,7 +654,7 @@ void KFileItemModelTest::testSorting()
QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 2 << 4 << 5 << 3 << 0 << 1 << 6 << 7);
// Sort by Name, ascending, 'Sort Folders First' disabled
- m_model->setSortRole("name");
+ m_model->setSortRole("text");
QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder);
QVERIFY(!m_model->sortDirectoriesFirst());
QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c" << "c-1" << "c-2" << "c-3" << "d" << "e");
@@ -800,7 +800,7 @@ QStringList KFileItemModelTest::itemsInModel() const
{
QStringList items;
for (int i = 0; i < m_model->count(); i++) {
- items << m_model->data(i).value("name").toString();
+ items << m_model->data(i).value("text").toString();
}
return items;
}
diff --git a/src/tests/kitemlistcontrollertest.cpp b/src/tests/kitemlistcontrollertest.cpp
index 3b67e7b50..47b2b8b75 100644
--- a/src/tests/kitemlistcontrollertest.cpp
+++ b/src/tests/kitemlistcontrollertest.cpp
@@ -33,7 +33,7 @@ namespace {
const int DefaultTimeout = 2000;
};
-Q_DECLARE_METATYPE(KFileItemListView::Layout);
+Q_DECLARE_METATYPE(KFileItemListView::ItemLayout);
Q_DECLARE_METATYPE(Qt::Orientation);
Q_DECLARE_METATYPE(KItemListController::SelectionBehavior);
Q_DECLARE_METATYPE(QSet<int>);
@@ -79,15 +79,13 @@ void KItemListControllerTest::initTestCase()
m_testDir = new TestDir();
m_model = new KFileItemModel();
- m_container = new KItemListContainer();
+ m_view = new KFileItemListView();
+ m_controller = new KItemListController(m_model, m_view, this);
+ m_container = new KItemListContainer(m_controller);
m_controller = m_container->controller();
m_controller->setSelectionBehavior(KItemListController::MultiSelection);
m_selectionManager = m_controller->selectionManager();
- m_view = new KFileItemListView();
- m_controller->setView(m_view);
- m_controller->setModel(m_model);
-
QStringList files;
files
<< "a1" << "a2" << "a3"
@@ -106,15 +104,8 @@ void KItemListControllerTest::initTestCase()
void KItemListControllerTest::cleanupTestCase()
{
- delete m_view;
- m_view = 0;
-
delete m_container;
m_container = 0;
- m_controller = 0;
-
- delete m_model;
- m_model = 0;
delete m_testDir;
m_testDir = 0;
@@ -187,15 +178,15 @@ Q_DECLARE_METATYPE(QList<keyPressViewStatePair>);
*/
void KItemListControllerTest::testKeyboardNavigation_data()
{
- QTest::addColumn<KFileItemListView::Layout>("layout");
+ QTest::addColumn<KFileItemListView::ItemLayout>("layout");
QTest::addColumn<Qt::Orientation>("scrollOrientation");
QTest::addColumn<int>("columnCount");
QTest::addColumn<KItemListController::SelectionBehavior>("selectionBehavior");
QTest::addColumn<bool>("groupingEnabled");
QTest::addColumn<QList<QPair<KeyPress, ViewState> > >("testList");
- QList<KFileItemListView::Layout> layoutList;
- QHash<KFileItemListView::Layout, QString> layoutNames;
+ QList<KFileItemListView::ItemLayout> layoutList;
+ QHash<KFileItemListView::ItemLayout, QString> layoutNames;
layoutList.append(KFileItemListView::IconsLayout);
layoutNames[KFileItemListView::IconsLayout] = "Icons";
layoutList.append(KFileItemListView::CompactLayout);
@@ -219,7 +210,7 @@ void KItemListControllerTest::testKeyboardNavigation_data()
groupingEnabledList.append(true);
groupingEnabledNames[true] = "grouping enabled";
- foreach (KFileItemListView::Layout layout, layoutList) {
+ foreach (KFileItemListView::ItemLayout layout, layoutList) {
// The following settings depend on the layout.
// Note that 'columns' are actually 'rows' in
// Compact layout.
@@ -443,7 +434,7 @@ void KItemListControllerTest::testKeyboardNavigation_data()
*/
void KItemListControllerTest::testKeyboardNavigation()
{
- QFETCH(KFileItemListView::Layout, layout);
+ QFETCH(KFileItemListView::ItemLayout, layout);
QFETCH(Qt::Orientation, scrollOrientation);
QFETCH(int, columnCount);
QFETCH(KItemListController::SelectionBehavior, selectionBehavior);