2 * Copyright (C) 2007 Benjamin C. Meyer
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include <QtTest/QtTest>
20 #include <QtGui/QtGui>
23 #include "qfilesystemmodel_p.h"
25 class ViewTest
: public QObject
35 void ViewTest::empty()
38 QCOMPARE(QModelIndex(), view
.rootIndex());
39 QCOMPARE(View::Icon
, view
.currentMode());
40 QCOMPARE(0, ((int)view
.currentView()));
41 QVERIFY(view
.history
!= 0);
42 view
.setCurrentMode(View::List
);
44 view
.setRootIndex(QModelIndex());
51 QFileSystemModel model
;
52 view
.createViews(&model
);
54 QCOMPARE(View::Icon
, view
.currentMode());
55 view
.setCurrentMode(View::List
);
56 QCOMPARE(View::List
, view
.currentMode());
57 view
.setCurrentMode(View::Column
);
58 QCOMPARE(View::Column
, view
.currentMode());
59 view
.setCurrentMode(View::Icon
);
60 QCOMPARE(View::Icon
, view
.currentMode());
63 void ViewTest::rootIndex()
65 qRegisterMetaType
<QModelIndex
>("QModelIndex");
67 QFileSystemModel model
;
68 view
.createViews(&model
);
70 QSignalSpy
spy(&view
, SIGNAL(currentFolderChanged(const QModelIndex
&)));
71 QModelIndex home
= model
.index(QDir::homePath());
72 view
.setRootIndex(home
);
73 QCOMPARE(view
.rootIndex(), home
);
74 QCOMPARE(spy
.count(), 1);
78 #include "viewtest.moc"