Commit 27fb7629 authored by Laurent Montel's avatar Laurent Montel 😁

Test enable status change and perStripe change

Test Plan: compile + launch autotest

Reviewers: hein

Reviewed By: hein

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D8517
parent ab3adc2a
......@@ -7,6 +7,7 @@ include_directories("..";${include_directories})
ecm_add_tests(
foldermodeltest.cpp
positionertest.cpp
viewpropertiesmenutest.cpp
LINK_LIBRARIES Qt5::Test folderplugin
)
......
......@@ -226,6 +226,9 @@ void FolderModelTest::tst_defaultValues()
QCOMPARE(folderModel.sortMode(), 0);
QCOMPARE(folderModel.filterMode(), (int)FolderModel::NoFilter);
QVERIFY(folderModel.newMenu());
QCOMPARE(folderModel.filterCaseSensitivity(), Qt::CaseInsensitive);
QVERIFY(folderModel.dynamicSortFilter());
QVERIFY(folderModel.isSortLocaleAware());
}
void FolderModelTest::tst_actionMenu()
......
......@@ -160,7 +160,7 @@ void PositionerTest::tst_reset()
m_positioner->reset();
QSignalSpy s(m_positioner, &Positioner::positionsChanged);
s.wait(500);
QCOMPARE(s.count(), 1);
checkPositions(3);
for (int i = 0; i < m_positioner->rowCount(); i++) {
......@@ -177,6 +177,38 @@ void PositionerTest::tst_defaultValues()
QVERIFY(positioner.positions().isEmpty());
}
void PositionerTest::tst_changeEnabledStatus()
{
Positioner positioner;
QVERIFY(!positioner.enabled());
QSignalSpy s(&positioner, &Positioner::enabledChanged);
positioner.setEnabled(true);
QCOMPARE(s.count(), 1);
positioner.setEnabled(false);
QCOMPARE(s.count(), 2);
//No change
positioner.setEnabled(false);
QCOMPARE(s.count(), 2);
}
void PositionerTest::tst_changePerStripe()
{
Positioner positioner;
QCOMPARE(positioner.perStripe(), 0);
QSignalSpy s(&positioner, &Positioner::perStripeChanged);
positioner.setPerStripe(1);
QCOMPARE(s.count(), 1);
//No change
positioner.setPerStripe(1);
QCOMPARE(s.count(), 1);
positioner.setPerStripe(4);
QCOMPARE(s.count(), 2);
}
void PositionerTest::checkPositions(int perStripe)
{
QSignalSpy s(m_positioner, &Positioner::positionsChanged);
......
......@@ -50,6 +50,8 @@ private Q_SLOTS:
void tst_isBlank();
void tst_reset();
void tst_defaultValues();
void tst_changeEnabledStatus();
void tst_changePerStripe();
private:
void checkPositions(int perStripe);
......
/***************************************************************************
* Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company *
* <info@kdab.com> *
* Author: Laurent Montel <laurent.montel@kdab.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#include "viewpropertiesmenutest.h"
#include "viewpropertiesmenu.h"
#include <QTest>
QTEST_MAIN(ViewPropertiesMenuTest)
void ViewPropertiesMenuTest::shouldHaveDefaultValues()
{
ViewPropertiesMenu m;
QVERIFY(m.menu());
QVERIFY(m.showLayoutActions());
QVERIFY(m.showLockAction());
QVERIFY(m.showIconSizeActions());
QVERIFY(!m.locked());
QVERIFY(!m.sortDesc());
QVERIFY(!m.sortDirsFirst());
}
/***************************************************************************
* Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company *
* <info@kdab.com> *
* Author: Laurent Montel <laurent.montel@kdab.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#ifndef VIEWPROPERTIESMENUTEST_H
#define VIEWPROPERTIESMENUTEST_H
#include <QObject>
class ViewPropertiesMenuTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void shouldHaveDefaultValues();
};
#endif // VIEWPROPERTIESMENUTEST_H
......@@ -21,12 +21,12 @@
#define VIEWPROPERTIESMENU_H
#include <QObject>
#include "folderplugin_private_export.h"
class QAction;
class QActionGroup;
class QMenu;
class ViewPropertiesMenu : public QObject
class FOLDERPLUGIN_TESTS_EXPORT ViewPropertiesMenu : public QObject
{
Q_OBJECT
......
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