Commit d5ebce9a authored by Laurent Montel's avatar Laurent Montel 😁

Fix function name, fix test as discussed with David

parent 9afa550f
/*
Copyright (c) 2014 Montel Laurent <montel@kde.org>
based on code:
Copyright 2009 Aurélien Gâteau <agateau@kde.org>
Copyright 2009 Kåre Sårs <kare.sars@iki.fi>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright 2009 Aurélien Gâteau <agateau@kde.org>
Copyright 2009 Kåre Sårs <kare.sars@iki.fi>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "splittercollapser.h"
......@@ -244,7 +243,6 @@ SplitterCollapser::SplitterCollapser(QWidget *childWidget, QSplitter *splitter)
}
connect(this, SIGNAL(clicked()), SLOT(slotClicked()));
show();
}
......
/*
Copyright (c) 2014 Montel Laurent <montel@kde.org>
based on code:
Copyright 2009 Aurélien Gâteau <agateau@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright 2009 Aurélien Gâteau <agateau@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SPLITTERCOLLAPSER_H
......
......@@ -51,7 +51,7 @@ SplitterCollapserTest::~SplitterCollapserTest()
}
void SplitterCollapserTest::shouldHasDefaultValue()
void SplitterCollapserTest::shouldHaveDefaultValue()
{
TestSplitter testSplitter;
......@@ -75,46 +75,44 @@ void SplitterCollapserTest::shouldHasDefaultValue()
QVERIFY(splitter);
}
void SplitterCollapserTest::shouldCollapsedWhenClickOnButton()
void SplitterCollapserTest::shouldCollapseWhenClickOnButton()
{
TestSplitter testSplitter;
new PimCommon::SplitterCollapser(testSplitter.edit2, testSplitter.splitter);
PimCommon::SplitterCollapser *splitterCollapser = new PimCommon::SplitterCollapser(testSplitter.edit2, testSplitter.splitter);
testSplitter.show();
QTest::qWaitForWindowShown(&testSplitter);
PimCommon::SplitterCollapser *collapser = qFindChild<PimCommon::SplitterCollapser *>(&testSplitter, QLatin1String("splittercollapser"));
QVERIFY(!collapser->isCollapsed());
QTest::mouseClick(collapser, Qt::LeftButton);
QVERIFY(collapser->isCollapsed());
QVERIFY(!splitterCollapser->isCollapsed());
QTest::mouseClick(splitterCollapser, Qt::LeftButton);
QVERIFY(splitterCollapser->isCollapsed());
QTest::mouseClick(collapser, Qt::LeftButton);
QVERIFY(!collapser->isCollapsed());
QTest::mouseClick(splitterCollapser, Qt::LeftButton);
QVERIFY(!splitterCollapser->isCollapsed());
}
void SplitterCollapserTest::shouldRestoreCorrectPosition()
{
TestSplitter testSplitter;
new PimCommon::SplitterCollapser(testSplitter.edit2, testSplitter.splitter);
PimCommon::SplitterCollapser *splitterCollapser = new PimCommon::SplitterCollapser(testSplitter.edit2, testSplitter.splitter);
testSplitter.show();
QTest::qWaitForWindowShown(&testSplitter);
QVERIFY(testSplitter.isVisible());
PimCommon::SplitterCollapser *collapser = qFindChild<PimCommon::SplitterCollapser *>(&testSplitter, QLatin1String("splittercollapser"));
QVERIFY(!collapser->isCollapsed());
QVERIFY(!splitterCollapser->isCollapsed());
QTextEdit *edit2 = qFindChild<QTextEdit *>(&testSplitter, QLatin1String("edit2"));
int size = edit2->width();
QTest::mouseClick(collapser, Qt::LeftButton);
QVERIFY(collapser->isCollapsed());
QTest::mouseClick(splitterCollapser, Qt::LeftButton);
QVERIFY(splitterCollapser->isCollapsed());
QCOMPARE(edit2->width(), 0);
QTest::mouseClick(collapser, Qt::LeftButton);
QVERIFY(!collapser->isCollapsed());
QTest::mouseClick(splitterCollapser, Qt::LeftButton);
QVERIFY(!splitterCollapser->isCollapsed());
QCOMPARE(edit2->width(), size);
}
......@@ -123,25 +121,24 @@ void SplitterCollapserTest::shouldRestoreCorrectPositionForFirstWidget()
{
TestSplitter testSplitter;
new PimCommon::SplitterCollapser(testSplitter.edit1, testSplitter.splitter);
PimCommon::SplitterCollapser *splitterCollapser = new PimCommon::SplitterCollapser(testSplitter.edit1, testSplitter.splitter);
testSplitter.show();
QTest::qWaitForWindowShown(&testSplitter);
QVERIFY(testSplitter.isVisible());
PimCommon::SplitterCollapser *collapser = qFindChild<PimCommon::SplitterCollapser *>(&testSplitter, QLatin1String("splittercollapser"));
QVERIFY(!collapser->isCollapsed());
QVERIFY(!splitterCollapser->isCollapsed());
QTextEdit *edit1 = qFindChild<QTextEdit *>(&testSplitter, QLatin1String("edit1"));
int size = edit1->width();
QTest::mouseClick(collapser, Qt::LeftButton);
QVERIFY(collapser->isCollapsed());
QTest::mouseClick(splitterCollapser, Qt::LeftButton);
QVERIFY(splitterCollapser->isCollapsed());
QCOMPARE(edit1->width(), 0);
QTest::mouseClick(collapser, Qt::LeftButton);
QVERIFY(!collapser->isCollapsed());
QTest::mouseClick(splitterCollapser, Qt::LeftButton);
QVERIFY(!splitterCollapser->isCollapsed());
QCOMPARE(edit1->width(), size);
}
......@@ -149,25 +146,24 @@ void SplitterCollapserTest::shouldTestVerticalSplitterFirstWidget()
{
TestSplitter testSplitter;
testSplitter.splitter->setOrientation(Qt::Vertical);
new PimCommon::SplitterCollapser(testSplitter.edit1, testSplitter.splitter);
PimCommon::SplitterCollapser *splitterCollapser = new PimCommon::SplitterCollapser(testSplitter.edit1, testSplitter.splitter);
testSplitter.show();
QTest::qWaitForWindowShown(&testSplitter);
QVERIFY(testSplitter.isVisible());
PimCommon::SplitterCollapser *collapser = qFindChild<PimCommon::SplitterCollapser *>(&testSplitter, QLatin1String("splittercollapser"));
QVERIFY(!collapser->isCollapsed());
QVERIFY(!splitterCollapser->isCollapsed());
QTextEdit *edit1 = qFindChild<QTextEdit *>(&testSplitter, QLatin1String("edit1"));
int size = edit1->height();
QTest::mouseClick(collapser, Qt::LeftButton);
QVERIFY(collapser->isCollapsed());
QTest::mouseClick(splitterCollapser, Qt::LeftButton);
QVERIFY(splitterCollapser->isCollapsed());
QCOMPARE(edit1->height(), 0);
QTest::mouseClick(collapser, Qt::LeftButton);
QVERIFY(!collapser->isCollapsed());
QTest::mouseClick(splitterCollapser, Qt::LeftButton);
QVERIFY(!splitterCollapser->isCollapsed());
QCOMPARE(edit1->height(), size);
}
......@@ -176,25 +172,24 @@ void SplitterCollapserTest::shouldTestVerticalSplitterSecondWidget()
{
TestSplitter testSplitter;
testSplitter.splitter->setOrientation(Qt::Vertical);
new PimCommon::SplitterCollapser(testSplitter.edit2, testSplitter.splitter);
PimCommon::SplitterCollapser *splitterCollapser = new PimCommon::SplitterCollapser(testSplitter.edit2, testSplitter.splitter);
testSplitter.show();
QTest::qWaitForWindowShown(&testSplitter);
QVERIFY(testSplitter.isVisible());
PimCommon::SplitterCollapser *collapser = qFindChild<PimCommon::SplitterCollapser *>(&testSplitter, QLatin1String("splittercollapser"));
QVERIFY(!collapser->isCollapsed());
QVERIFY(!splitterCollapser->isCollapsed());
QTextEdit *edit2 = qFindChild<QTextEdit *>(&testSplitter, QLatin1String("edit2"));
int size = edit2->height();
QTest::mouseClick(collapser, Qt::LeftButton);
QVERIFY(collapser->isCollapsed());
QTest::mouseClick(splitterCollapser, Qt::LeftButton);
QVERIFY(splitterCollapser->isCollapsed());
QCOMPARE(edit2->height(), 0);
QTest::mouseClick(collapser, Qt::LeftButton);
QVERIFY(!collapser->isCollapsed());
QTest::mouseClick(splitterCollapser, Qt::LeftButton);
QVERIFY(!splitterCollapser->isCollapsed());
QCOMPARE(edit2->height(), size);
}
......
......@@ -41,8 +41,8 @@ public:
~SplitterCollapserTest();
private Q_SLOTS:
void shouldHasDefaultValue();
void shouldCollapsedWhenClickOnButton();
void shouldHaveDefaultValue();
void shouldCollapseWhenClickOnButton();
void shouldRestoreCorrectPosition();
void shouldRestoreCorrectPositionForFirstWidget();
void shouldTestVerticalSplitterFirstWidget();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment