File indexing completed on 2025-07-13 05:18:28
0001 /* 0002 SPDX-FileCopyrightText: 2016 Elvis Angelaccio <elvis.angelaccio@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "testtimedisplay.h" 0008 #include "timedisplay.h" 0009 0010 #include "digitdisplay.h" 0011 0012 #include <QGroupBox> 0013 0014 #include <KColorScheme> 0015 0016 void TestTimeDisplay::testDefaultWidget() 0017 { 0018 TimeDisplay timeDisplay; 0019 0020 const auto groupBoxes = timeDisplay.findChildren<QGroupBox*>(); 0021 QCOMPARE(groupBoxes.size(), 4); 0022 0023 for (auto group : groupBoxes) { 0024 QCOMPARE(group->findChildren<DigitDisplay*>().size(), 1); 0025 QVERIFY(!group->title().isEmpty()); 0026 } 0027 } 0028 0029 void TestTimeDisplay::testSetBackgroundColor() 0030 { 0031 KColorScheme scheme {QPalette::Active}; 0032 const auto color = scheme.foreground(KColorScheme::NegativeText).color(); 0033 0034 TimeDisplay timeDisplay; 0035 timeDisplay.setBackgroundColor(color); 0036 0037 const auto groupBoxes = timeDisplay.findChildren<QGroupBox*>(); 0038 for (auto group : groupBoxes) { 0039 QCOMPARE(group->palette().color(group->backgroundRole()), color); 0040 } 0041 } 0042 0043 void TestTimeDisplay::testSetTextColor() 0044 { 0045 KColorScheme scheme {QPalette::Active}; 0046 const auto color = scheme.foreground(KColorScheme::NegativeText).color(); 0047 0048 TimeDisplay timeDisplay; 0049 timeDisplay.setTextColor(color); 0050 0051 const auto groupBoxes = timeDisplay.findChildren<QGroupBox*>(); 0052 for (auto group : groupBoxes) { 0053 QCOMPARE(group->palette().color(group->foregroundRole()), color); 0054 } 0055 } 0056 0057 QTEST_MAIN(TestTimeDisplay) 0058 0059 #include "moc_testtimedisplay.cpp"