1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
/*
SPDX-FileCopyrightText: 2016 Elvis Angelaccio <elvis.angelaccio@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "testtimedisplay.h"
#include "timedisplay.h"
#include "digitdisplay.h"
#include <QGroupBox>
#include <KColorScheme>
void TestTimeDisplay::testDefaultWidget()
{
TimeDisplay timeDisplay;
const auto groupBoxes = timeDisplay.findChildren<QGroupBox*>();
QCOMPARE(groupBoxes.size(), 4);
for (auto group : groupBoxes) {
QCOMPARE(group->findChildren<DigitDisplay*>().size(), 1);
QVERIFY(!group->title().isEmpty());
}
}
void TestTimeDisplay::testSetBackgroundColor()
{
KColorScheme scheme {QPalette::Active};
const auto color = scheme.foreground(KColorScheme::NegativeText).color();
TimeDisplay timeDisplay;
timeDisplay.setBackgroundColor(color);
const auto groupBoxes = timeDisplay.findChildren<QGroupBox*>();
for (auto group : groupBoxes) {
QCOMPARE(group->palette().color(group->backgroundRole()), color);
}
}
void TestTimeDisplay::testSetTextColor()
{
KColorScheme scheme {QPalette::Active};
const auto color = scheme.foreground(KColorScheme::NegativeText).color();
TimeDisplay timeDisplay;
timeDisplay.setTextColor(color);
const auto groupBoxes = timeDisplay.findChildren<QGroupBox*>();
for (auto group : groupBoxes) {
QCOMPARE(group->palette().color(group->foregroundRole()), color);
}
}
QTEST_MAIN(TestTimeDisplay)
|