1
// vim: set tabstop=4 shiftwidth=4 expandtab:
3
Gwenview: an image viewer
4
Copyright 2011 Aurélien Gâteau <agateau@kde.org>
6
This program is free software; you can redistribute it and/or
7
modify it under the terms of the GNU General Public License
8
as published by the Free Software Foundation; either version 2
9
of the License, or (at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA.
22
#include "slidecontainerautotest.moc"
25
#include <lib/slidecontainer.h>
28
#include <qtest_kde.h>
33
#include <QVBoxLayout>
35
QTEST_KDEMAIN(SlideContainerAutoTest, GUI)
37
using namespace Gwenview;
39
struct TestWindow : public QWidget {
40
explicit TestWindow(QWidget* parent = 0)
42
, mContainer(new SlideContainer)
46
mMainWidget = new QTextEdit();
47
QVBoxLayout* layout = new QVBoxLayout(this);
48
layout->setSpacing(0);
50
layout->addWidget(mMainWidget);
51
layout->addWidget(mContainer);
56
mContent = new QTextEdit;
57
mContent->setFixedSize(100, 40);
58
mContainer->setContent(mContent);
61
SlideContainer* mContainer;
66
void SlideContainerAutoTest::testInit()
68
// Even with content, a SlideContainer should be invisible until slideIn()
74
QCOMPARE(window.mMainWidget->height(), window.height());
77
void SlideContainerAutoTest::testSlideIn()
82
window.mContainer->slideIn();
83
while (window.mContainer->slideHeight() != window.mContent->height()) {
86
QCOMPARE(window.mContainer->height(), window.mContent->height());
89
void SlideContainerAutoTest::testSlideOut()
94
window.mContainer->slideIn();
95
while (window.mContainer->slideHeight() != window.mContent->height()) {
98
window.mContainer->slideOut();
99
while (window.mContainer->slideHeight() != 0) {
102
QCOMPARE(window.mContainer->height(), 0);
105
void SlideContainerAutoTest::testSlideInDeleteSlideOut()
107
// If content is deleted while visible, slideOut() should still produce an
112
window.mContainer->slideIn();
113
while (window.mContainer->slideHeight() != window.mContent->height()) {
116
window.mContent->deleteLater();
117
window.mContainer->slideOut();
118
while (window.mContainer->slideHeight() != 0) {
121
QCOMPARE(window.mContainer->height(), 0);
124
void SlideContainerAutoTest::testHiddenContentResize()
126
// Resizing content should not trigger a slide if it is not visible.
129
QTest::qWaitForWindowShown(&window);
131
window.mContent->show();
132
window.mContent->setFixedSize(150, 80);
134
QCOMPARE(window.mContainer->height(), 0);
b'\\ No newline at end of file'