File indexing completed on 2024-05-19 16:51:55
0001 /* 0002 Copyright (C) 2016 by Elvis Angelaccio <elvis.angelaccio@kde.org> 0003 0004 This file is part of Kronometer. 0005 0006 Kronometer is free software: you can redistribute it and/or modify 0007 it under the terms of the GNU General Public License as published by 0008 the Free Software Foundation, either version 2 of the License, or 0009 (at your option) any later version. 0010 0011 Kronometer is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 GNU General Public License for more details. 0015 0016 You should have received a copy of the GNU General Public License 0017 along with Kronometer. If not, see <http://www.gnu.org/licenses/>. 0018 */ 0019 0020 #include "testtimedisplay.h" 0021 #include "timedisplay.h" 0022 0023 #include "digitdisplay.h" 0024 0025 #include <QGroupBox> 0026 0027 #include <KColorScheme> 0028 0029 void TestTimeDisplay::testDefaultWidget() 0030 { 0031 TimeDisplay timeDisplay; 0032 0033 const auto groupBoxes = timeDisplay.findChildren<QGroupBox*>(); 0034 QCOMPARE(groupBoxes.size(), 4); 0035 0036 for (auto group : groupBoxes) { 0037 QCOMPARE(group->findChildren<DigitDisplay*>().size(), 1); 0038 QVERIFY(!group->title().isEmpty()); 0039 } 0040 } 0041 0042 void TestTimeDisplay::testSetBackgroundColor() 0043 { 0044 KColorScheme scheme {QPalette::Active}; 0045 const auto color = scheme.foreground(KColorScheme::NegativeText).color(); 0046 0047 TimeDisplay timeDisplay; 0048 timeDisplay.setBackgroundColor(color); 0049 0050 const auto groupBoxes = timeDisplay.findChildren<QGroupBox*>(); 0051 for (auto group : groupBoxes) { 0052 QCOMPARE(group->palette().color(group->backgroundRole()), color); 0053 } 0054 } 0055 0056 void TestTimeDisplay::testSetTextColor() 0057 { 0058 KColorScheme scheme {QPalette::Active}; 0059 const auto color = scheme.foreground(KColorScheme::NegativeText).color(); 0060 0061 TimeDisplay timeDisplay; 0062 timeDisplay.setTextColor(color); 0063 0064 const auto groupBoxes = timeDisplay.findChildren<QGroupBox*>(); 0065 for (auto group : groupBoxes) { 0066 QCOMPARE(group->palette().color(group->foregroundRole()), color); 0067 } 0068 } 0069 0070 QTEST_MAIN(TestTimeDisplay)