]>
cloud.milkyroute.net Git - dolphin.git/blob - src/tests/dolphindetailsviewtest.cpp
1 /***************************************************************************
2 * Copyright (C) 2010 by Frank Reininghaus (frank78ac@googlemail.com) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (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 *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #include <qtest_kde.h>
24 #include "views/dolphindetailsview.h"
25 #include "views/dolphinview.h"
26 #include "views/dolphinmodel.h"
27 #include "views/dolphindirlister.h"
28 #include "views/dolphinsortfilterproxymodel.h"
29 #include "views/zoomlevelinfo.h"
33 #include <QtCore/QDir>
37 class DolphinDetailsViewTest
: public TestBase
45 void bug234600_overlappingIconsWhenZooming();
49 void DolphinDetailsViewTest::initTestCase()
51 // add time stamps to find origin of test failures due to timeout at
52 // http://my.cdash.org/index.php?project=kdebase&date=
53 qputenv("KDE_DEBUG_TIMESTAMP", QByteArray("1"));
57 * When the icon size is changed, we have to make sure that the maximumSize given
58 * to KFileItemDelegate for rendering each item is updated correctly. If this is not
59 * done, the visualRects are clipped by the incorrect maximum size, and the icons
62 * https://bugs.kde.org/show_bug.cgi?id=234600
65 void DolphinDetailsViewTest::bug234600_overlappingIconsWhenZooming()
68 files
<< "a" << "b" << "c" << "d";
71 m_view
->setMode(DolphinView::DetailsView
);
72 DolphinDetailsView
* detailsView
= qobject_cast
<DolphinDetailsView
*>(itemView());
74 m_view
->resize(400, 400);
76 QTest::qWaitForWindowShown(m_view
);
78 // We have to make sure that the view has loaded the directory before we start the test.
79 // TODO: This will be needed frequently. Maybe move to TestHelper.
80 kDebug() << "Reloading view and waiting for the finishedPathLoading(const KUrl&) signal...";
81 QSignalSpy
finished(m_view
, SIGNAL(finishedPathLoading(const KUrl
&)));
83 while (finished
.count() != 1) {
86 kDebug() << "...signal received, continuing";
88 QModelIndex index0
= detailsView
->model()->index(0, 0);
89 detailsView
->setCurrentIndex(index0
);
90 QCOMPARE(detailsView
->currentIndex(), index0
);
92 // Setting the zoom level to the minimum value and triggering DolphinDetailsView::currentChanged(...)
93 // should make sure that the bug is triggered.
94 int zoomLevel
= ZoomLevelInfo::minimumLevel();
95 m_view
->setZoomLevel(zoomLevel
);
97 QModelIndex index1
= detailsView
->model()->index(1, 0);
98 detailsView
->setCurrentIndex(index1
);
99 QCOMPARE(detailsView
->currentIndex(), index1
);
101 kDebug() << "Now checking zoom levels...";
103 // Increase the zoom level successively to the maximum.
104 while(zoomLevel
< ZoomLevelInfo::maximumLevel()) {
106 kDebug() << "Testing zoom level" << zoomLevel
;
107 m_view
->setZoomLevel(zoomLevel
);
109 //Check for each zoom level that the height of each item is at least the icon size.
110 QVERIFY(detailsView
->visualRect(index1
).height() >= ZoomLevelInfo::iconSizeForZoomLevel(zoomLevel
));
115 kDebug() << "Cleaning up test directory...";
120 QTEST_KDEMAIN(DolphinDetailsViewTest
, GUI
)
122 #include "dolphindetailsviewtest.moc"