diff --git a/src/widgets/filterwidget.ui b/src/widgets/filterwidget.ui
index 77156816..f3626375 100644
--- a/src/widgets/filterwidget.ui
+++ b/src/widgets/filterwidget.ui
@@ -1,133 +1,148 @@
FilterWidget
0
0
400
300
Form
0
0
0
0
-
-
Filter...
-
true
+
+ true
+
-
0
0
0
0
-
-
+
+ Sort in ascending order
+
true
true
+
+ true
+
sortOrderGroup
-
+
+ Sort in descending order
+
true
+
+ true
+
sortOrderGroup
extensionButton
toggled(bool)
extension
setVisible(bool)
381
82
375
165
diff --git a/tests/units/widgets/filterwidgettest.cpp b/tests/units/widgets/filterwidgettest.cpp
index b198c307..baefec35 100644
--- a/tests/units/widgets/filterwidgettest.cpp
+++ b/tests/units/widgets/filterwidgettest.cpp
@@ -1,181 +1,184 @@
/* This file is part of Zanshin
Copyright 2014 Kevin Ottens
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) 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 14 of version 3 of the license.
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
-#include
#include
#include
+#include
#include "widgets/filterwidget.h"
#include "presentation/artifactfilterproxymodel.h"
class FilterWidgetTest : public QObject
{
Q_OBJECT
private slots:
void shouldHaveDefaultState()
{
Widgets::FilterWidget filter;
QVERIFY(filter.proxyModel());
QVERIFY(!filter.proxyModel()->sourceModel());
QCOMPARE(filter.proxyModel()->filterRegExp(), QRegExp());
QCOMPARE(filter.proxyModel()->sortOrder(), Qt::AscendingOrder);
QCOMPARE(filter.proxyModel()->sortType(), Presentation::ArtifactFilterProxyModel::TitleSort);
QLineEdit *filterEdit = filter.findChild(QStringLiteral("filterEdit"));
QVERIFY(filterEdit);
QVERIFY(filterEdit->isVisibleTo(&filter));
QVERIFY(filterEdit->text().isEmpty());
QCOMPARE(filterEdit->placeholderText(), tr("Filter..."));
- QAbstractButton *extensionButton = filter.findChild(QStringLiteral("extensionButton"));
+ auto extensionButton = filter.findChild(QStringLiteral("extensionButton"));
QVERIFY(extensionButton);
QVERIFY(extensionButton->isVisibleTo(&filter));
QVERIFY(!extensionButton->isChecked());
QCOMPARE(extensionButton->icon(), QIcon::fromTheme(QStringLiteral("arrow-down-double")));
+ QVERIFY(extensionButton->autoRaise());
QComboBox *sortTypeCombo = filter.findChild(QStringLiteral("sortTypeCombo"));
QVERIFY(sortTypeCombo);
QVERIFY(!sortTypeCombo->isVisibleTo(&filter));
QCOMPARE(sortTypeCombo->currentIndex(), 0);
- QAbstractButton *ascendingButton = filter.findChild(QStringLiteral("ascendingButton"));
+ auto ascendingButton = filter.findChild(QStringLiteral("ascendingButton"));
QVERIFY(ascendingButton);
QVERIFY(!ascendingButton->isVisibleTo(&filter));
QVERIFY(ascendingButton->isChecked());
QCOMPARE(ascendingButton->icon(), QIcon::fromTheme(QStringLiteral("arrow-up")));
+ QVERIFY(ascendingButton->autoRaise());
- QAbstractButton *descendingButton = filter.findChild(QStringLiteral("descendingButton"));
+ auto descendingButton = filter.findChild(QStringLiteral("descendingButton"));
QVERIFY(descendingButton);
QVERIFY(!descendingButton->isVisibleTo(&filter));
QVERIFY(!descendingButton->isChecked());
QCOMPARE(descendingButton->icon(), QIcon::fromTheme(QStringLiteral("arrow-down")));
+ QVERIFY(descendingButton->autoRaise());
}
void shouldChangeAppliedFilter()
{
// GIVEN
Widgets::FilterWidget filter;
QLineEdit *filterEdit = filter.findChild(QStringLiteral("filterEdit"));
QVERIFY(filterEdit);
// WHEN
QTest::keyClicks(filterEdit, QStringLiteral("find me"));
// THEN
QCOMPARE(filter.proxyModel()->filterRegExp().pattern(), QStringLiteral("find me"));
}
void shouldShowExtension()
{
// GIVEN
Widgets::FilterWidget filter;
QAbstractButton *extensionButton = filter.findChild(QStringLiteral("extensionButton"));
QVERIFY(extensionButton);
QComboBox *sortTypeCombo = filter.findChild(QStringLiteral("sortTypeCombo"));
QVERIFY(sortTypeCombo);
QAbstractButton *ascendingButton = filter.findChild(QStringLiteral("ascendingButton"));
QVERIFY(ascendingButton);
QAbstractButton *descendingButton = filter.findChild(QStringLiteral("descendingButton"));
QVERIFY(descendingButton);
// WHEN
extensionButton->click();
// THEN
QVERIFY(extensionButton->isChecked());
QVERIFY(sortTypeCombo->isVisibleTo(&filter));
QVERIFY(descendingButton->isVisibleTo(&filter));
QVERIFY(descendingButton->isVisibleTo(&filter));
// WHEN
extensionButton->click();
// THEN
QVERIFY(!extensionButton->isChecked());
QVERIFY(!sortTypeCombo->isVisibleTo(&filter));
QVERIFY(!descendingButton->isVisibleTo(&filter));
QVERIFY(!descendingButton->isVisibleTo(&filter));
}
void shouldChangeSortType()
{
// GIVEN
Widgets::FilterWidget filter;
QComboBox *sortTypeCombo = filter.findChild(QStringLiteral("sortTypeCombo"));
QVERIFY(sortTypeCombo);
// WHEN
sortTypeCombo->setCurrentIndex(1);
// THEN
QCOMPARE(filter.proxyModel()->sortType(), Presentation::ArtifactFilterProxyModel::DateSort);
// WHEN
sortTypeCombo->setCurrentIndex(0);
// THEN
QCOMPARE(filter.proxyModel()->sortType(), Presentation::ArtifactFilterProxyModel::TitleSort);
}
void shouldChangeSortOrder()
{
// GIVEN
Widgets::FilterWidget filter;
QAbstractButton *ascendingButton = filter.findChild(QStringLiteral("ascendingButton"));
QVERIFY(ascendingButton);
QAbstractButton *descendingButton = filter.findChild(QStringLiteral("descendingButton"));
QVERIFY(descendingButton);
// WHEN
descendingButton->click();
// THEN
QVERIFY(!ascendingButton->isChecked());
QVERIFY(descendingButton->isChecked());
QCOMPARE(filter.proxyModel()->sortOrder(), Qt::DescendingOrder);
// WHEN
ascendingButton->click();
// THEN
QVERIFY(ascendingButton->isChecked());
QVERIFY(!descendingButton->isChecked());
QCOMPARE(filter.proxyModel()->sortOrder(), Qt::AscendingOrder);
}
};
ZANSHIN_TEST_MAIN(FilterWidgetTest)
#include "filterwidgettest.moc"