File indexing completed on 2024-05-19 04:45:43
0001 // SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com> 0002 // SPDX-License-Identifier: BSD-2-Clause OR MIT 0003 0004 // First included header is the public header of the class we are testing; 0005 // this forces the header to be self-contained. 0006 #include "helper.h" 0007 0008 #include <optional> 0009 #include <qcolor.h> 0010 #include <qcontainerfwd.h> 0011 #include <qevent.h> 0012 #include <qglobal.h> 0013 #include <qicon.h> 0014 #include <qimage.h> 0015 #include <qlist.h> 0016 #include <qlocale.h> 0017 #include <qnamespace.h> 0018 #include <qobject.h> 0019 #include <qpair.h> 0020 #include <qpoint.h> 0021 #include <qsize.h> 0022 #include <qspinbox.h> 0023 #include <qstring.h> 0024 #include <qstringliteral.h> 0025 #include <qtest.h> 0026 #include <qtestcase.h> 0027 #include <qwidget.h> 0028 #include <rgbcolorspacefactory.h> 0029 0030 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) 0031 #include <qtmetamacros.h> 0032 #else 0033 #include <qobjectdefs.h> 0034 #endif 0035 0036 // From Qt documentation: 0037 // “Note: This function is not declared in any of Qt's header files. To 0038 // use it in your application, declare the function prototype before 0039 // calling it.” 0040 void qt_set_sequence_auto_mnemonic(bool b); 0041 0042 static void snippet01() 0043 { 0044 int test = 5; 0045 //! [isInUsage] 0046 // Having a variable “int test”: 0047 const bool result = PerceptualColor::isIn(test, 1, 2, 8); 0048 //! [isInUsage] 0049 Q_UNUSED(result) 0050 } 0051 0052 static void snippet02() 0053 { 0054 //! [percentTraditional] 0055 QSpinBox box1; 0056 box1.setSuffix(QStringLiteral("%")); 0057 //! [percentTraditional] 0058 //! [percentImproved] 0059 QSpinBox box2; 0060 QLocale locale; 0061 box2.setSuffix(locale.percent()); 0062 //! [percentImproved] 0063 //! [percentFullyInternationalized] 0064 QSpinBox box3; 0065 const QPair<QString, QString> temp = // 0066 PerceptualColor::getPrefixSuffix(QObject::tr("%1%")); 0067 box3.setPrefix(temp.first); 0068 box3.setSuffix(temp.second); 0069 //! [percentFullyInternationalized] 0070 if (box3.prefix() != QString()) { 0071 throw 0; 0072 } 0073 if (box3.suffix() != QStringLiteral("%")) { 0074 throw 0; 0075 } 0076 } 0077 0078 class EnumTestClass : QObject 0079 { 0080 Q_OBJECT 0081 public: 0082 enum class Normal { value0, value1, value2 }; 0083 Q_ENUM(Normal); 0084 0085 enum class Defined { value0 = 0, value1 = 1, value2 = 2 }; 0086 Q_ENUM(Defined); 0087 0088 enum class Shifted { value0 = 10, value1 = 11, value2 = 12 }; 0089 Q_ENUM(Shifted); 0090 0091 enum class Missing { value0 = 00, value1 = 10, value2 = 20 }; 0092 Q_ENUM(Missing); 0093 0094 enum class DoubledValue { value0 = 0, value1 = 1, value2 = 1 }; 0095 Q_ENUM(DoubledValue); 0096 0097 enum class DoubledKey { value0 = 0, value1 = 1, value2 = value1 }; 0098 Q_ENUM(DoubledKey); 0099 }; 0100 0101 namespace MyNamespace 0102 { 0103 Q_NAMESPACE 0104 0105 enum class NamespaceEnum { value0, value1, value2 }; 0106 Q_ENUM_NS(NamespaceEnum); 0107 } 0108 0109 namespace PerceptualColor 0110 { 0111 0112 class TestHelper : public QObject 0113 { 0114 Q_OBJECT 0115 0116 public: 0117 explicit TestHelper(QObject *parent = nullptr) 0118 : QObject(parent) 0119 { 0120 } 0121 0122 private Q_SLOTS: 0123 0124 void initTestCase() 0125 { 0126 // Called before the first test function is executed 0127 } 0128 0129 void cleanupTestCase() 0130 { 0131 // Called after the last test function was executed 0132 } 0133 0134 void init() 0135 { 0136 // Called before each test function is executed 0137 } 0138 void cleanup() 0139 { 0140 // Called after every test function 0141 } 0142 0143 void testTransparencyBackground() 0144 { 0145 QImage temp = transparencyBackground(1); 0146 QVERIFY2(temp.size().width() > 0, "Width of image is bigger than 0."); 0147 QVERIFY2(temp.size().height() > 0, "Height of image is bigger than 0."); 0148 QVERIFY2(temp.allGray(), "Image is neutral gray."); 0149 } 0150 0151 void testStandardWheelSteps() 0152 { 0153 QWheelEvent temp( // 0154 QPointF(), // pos 0155 QPointF(), // globalPos 0156 QPoint(), // pixelDelta 0157 QPoint(200, 120), // angleDelta 0158 Qt::MouseButton::MiddleButton, // buttons 0159 Qt::KeyboardModifier::NoModifier, // modifiers 0160 Qt::ScrollUpdate, // phase 0161 false // inverted 0162 ); 0163 QCOMPARE(PerceptualColor::standardWheelStepCount(&temp), 1); 0164 } 0165 0166 void testSnippet01() 0167 { 0168 snippet01(); 0169 } 0170 0171 void testSnippet02() 0172 { 0173 snippet02(); 0174 } 0175 0176 void testIsIn() 0177 { 0178 QCOMPARE(isIn(5, 6), false); 0179 QCOMPARE(isIn(5), false); 0180 QCOMPARE(isIn(0), false); 0181 QCOMPARE(isIn(0, 1), false); 0182 QCOMPARE(isIn(5, 6, 5), true); 0183 QCOMPARE(isIn(5, 6, 5, 5), true); 0184 QCOMPARE(isIn(5, 6, 6, 5, 5), true); 0185 QCOMPARE(isIn(0, 6, 6, 5, 5), false); 0186 QCOMPARE(isIn(0, 6, 6, 5, 0, 5), true); 0187 QCOMPARE(isIn(QStringLiteral("0"), // 0188 QStringLiteral("0"), 0189 QStringLiteral("1")), 0190 true); 0191 QCOMPARE(isIn(QStringLiteral("0"), // 0192 QStringLiteral("4"), 0193 QStringLiteral("1")), 0194 false); 0195 } 0196 0197 void testEnumeratorToFullStringNormal() 0198 { 0199 QCOMPARE(enumeratorToFullString(static_cast<EnumTestClass::Normal>(-1)), // 0200 QString()); 0201 QCOMPARE(enumeratorToFullString(EnumTestClass::Normal::value0), // 0202 QStringLiteral("EnumTestClass::Normal::value0(0)")); 0203 QCOMPARE(enumeratorToFullString(EnumTestClass::Normal::value1), // 0204 QStringLiteral("EnumTestClass::Normal::value1(1)")); 0205 QCOMPARE(enumeratorToFullString(EnumTestClass::Normal::value2), // 0206 QStringLiteral("EnumTestClass::Normal::value2(2)")); 0207 QCOMPARE(enumeratorToFullString(static_cast<EnumTestClass::Normal>(3)), // 0208 QString()); 0209 } 0210 0211 void testEnumeratorToFullStringDefined() 0212 { 0213 QCOMPARE(enumeratorToFullString(static_cast<EnumTestClass::Defined>(-1)), // 0214 QString()); 0215 QCOMPARE(enumeratorToFullString(EnumTestClass::Defined::value0), // 0216 QStringLiteral("EnumTestClass::Defined::value0(0)")); 0217 QCOMPARE(enumeratorToFullString(EnumTestClass::Defined::value1), // 0218 QStringLiteral("EnumTestClass::Defined::value1(1)")); 0219 QCOMPARE(enumeratorToFullString(EnumTestClass::Defined::value2), // 0220 QStringLiteral("EnumTestClass::Defined::value2(2)")); 0221 QCOMPARE(enumeratorToFullString(static_cast<EnumTestClass::Defined>(3)), // 0222 QString()); 0223 } 0224 0225 void testEnumeratorToFullStringShifted() 0226 { 0227 QCOMPARE(enumeratorToFullString(static_cast<EnumTestClass::Shifted>(-1)), // 0228 QString()); 0229 QCOMPARE(enumeratorToFullString(static_cast<EnumTestClass::Shifted>(0)), // 0230 QString()); 0231 QCOMPARE(enumeratorToFullString(static_cast<EnumTestClass::Shifted>(1)), // 0232 QString()); 0233 QCOMPARE(enumeratorToFullString(static_cast<EnumTestClass::Shifted>(9)), // 0234 QString()); 0235 QCOMPARE(enumeratorToFullString(EnumTestClass::Shifted::value0), // 0236 QStringLiteral("EnumTestClass::Shifted::value0(10)")); 0237 QCOMPARE(enumeratorToFullString(EnumTestClass::Shifted::value1), // 0238 QStringLiteral("EnumTestClass::Shifted::value1(11)")); 0239 QCOMPARE(enumeratorToFullString(EnumTestClass::Shifted::value2), // 0240 QStringLiteral("EnumTestClass::Shifted::value2(12)")); 0241 QCOMPARE(enumeratorToFullString(static_cast<EnumTestClass::Shifted>(13)), // 0242 QString()); 0243 } 0244 0245 void testEnumeratorToFullStringMissing() 0246 { 0247 QCOMPARE(enumeratorToFullString(static_cast<EnumTestClass::Missing>(-1)), // 0248 QString()); 0249 QCOMPARE(enumeratorToFullString(EnumTestClass::Missing::value0), // 0250 QStringLiteral("EnumTestClass::Missing::value0(0)")); 0251 QCOMPARE(enumeratorToFullString(static_cast<EnumTestClass::Missing>(1)), // 0252 QString()); 0253 QCOMPARE(enumeratorToFullString(static_cast<EnumTestClass::Missing>(9)), // 0254 QString()); 0255 QCOMPARE(enumeratorToFullString(EnumTestClass::Missing::value1), // 0256 QStringLiteral("EnumTestClass::Missing::value1(10)")); 0257 QCOMPARE(enumeratorToFullString(static_cast<EnumTestClass::Missing>(11)), // 0258 QString()); 0259 QCOMPARE(enumeratorToFullString(static_cast<EnumTestClass::Missing>(19)), // 0260 QString()); 0261 QCOMPARE(enumeratorToFullString(EnumTestClass::Missing::value2), // 0262 QStringLiteral("EnumTestClass::Missing::value2(20)")); 0263 QCOMPARE(enumeratorToFullString(static_cast<EnumTestClass::Missing>(21)), // 0264 QString()); 0265 } 0266 0267 void testEnumeratorToFullStringDoubledValue() 0268 { 0269 QCOMPARE(enumeratorToFullString(static_cast<EnumTestClass::DoubledValue>(-1)), // 0270 QString()); 0271 QCOMPARE(enumeratorToFullString(EnumTestClass::DoubledValue::value0), // 0272 QStringLiteral("EnumTestClass::DoubledValue::value0(0)")); 0273 QCOMPARE(enumeratorToFullString(EnumTestClass::DoubledValue::value1), // 0274 QStringLiteral("EnumTestClass::DoubledValue::value1|value2(1)")); 0275 QCOMPARE(enumeratorToFullString(EnumTestClass::DoubledValue::value2), // 0276 QStringLiteral("EnumTestClass::DoubledValue::value1|value2(1)")); 0277 QCOMPARE(enumeratorToFullString(static_cast<EnumTestClass::DoubledValue>(2)), // 0278 QString()); 0279 } 0280 0281 void testEnumeratorToFullStringDoubledKey() 0282 { 0283 QCOMPARE(enumeratorToFullString(static_cast<EnumTestClass::DoubledKey>(-1)), // 0284 QString()); 0285 QCOMPARE(enumeratorToFullString(EnumTestClass::DoubledKey::value0), // 0286 QStringLiteral("EnumTestClass::DoubledKey::value0(0)")); 0287 QCOMPARE(enumeratorToFullString(EnumTestClass::DoubledKey::value1), // 0288 QStringLiteral("EnumTestClass::DoubledKey::value1|value2(1)")); 0289 QCOMPARE(enumeratorToFullString(EnumTestClass::DoubledKey::value2), // 0290 QStringLiteral("EnumTestClass::DoubledKey::value1|value2(1)")); 0291 QCOMPARE(enumeratorToFullString(static_cast<EnumTestClass::DoubledKey>(2)), // 0292 QString()); 0293 } 0294 0295 void testEnumerationToFullString() 0296 { 0297 QCOMPARE(enumerationToFullString<EnumTestClass::DoubledKey>(), // 0298 QStringLiteral("EnumTestClass::DoubledKey")); 0299 QCOMPARE(enumerationToFullString<MyNamespace::NamespaceEnum>(), // 0300 QStringLiteral("MyNamespace::NamespaceEnum")); 0301 } 0302 0303 void testEnumeratorToStringNormal() 0304 { 0305 QCOMPARE(enumeratorToString(static_cast<EnumTestClass::Normal>(-1)), // 0306 QString()); 0307 QCOMPARE(enumeratorToString(EnumTestClass::Normal::value0), // 0308 QStringLiteral("value0(0)")); 0309 QCOMPARE(enumeratorToString(EnumTestClass::Normal::value1), // 0310 QStringLiteral("value1(1)")); 0311 QCOMPARE(enumeratorToString(EnumTestClass::Normal::value2), // 0312 QStringLiteral("value2(2)")); 0313 QCOMPARE(enumeratorToString(static_cast<EnumTestClass::Normal>(3)), // 0314 QString()); 0315 } 0316 0317 void testEnumeratorToStringDefined() 0318 { 0319 QCOMPARE(enumeratorToString(static_cast<EnumTestClass::Defined>(-1)), // 0320 QString()); 0321 QCOMPARE(enumeratorToString(EnumTestClass::Defined::value0), // 0322 QStringLiteral("value0(0)")); 0323 QCOMPARE(enumeratorToString(EnumTestClass::Defined::value1), // 0324 QStringLiteral("value1(1)")); 0325 QCOMPARE(enumeratorToString(EnumTestClass::Defined::value2), // 0326 QStringLiteral("value2(2)")); 0327 QCOMPARE(enumeratorToString(static_cast<EnumTestClass::Defined>(3)), // 0328 QString()); 0329 } 0330 0331 void testEnumeratorToStringShifted() 0332 { 0333 QCOMPARE(enumeratorToString(static_cast<EnumTestClass::Shifted>(-1)), // 0334 QString()); 0335 QCOMPARE(enumeratorToString(static_cast<EnumTestClass::Shifted>(0)), // 0336 QString()); 0337 QCOMPARE(enumeratorToString(static_cast<EnumTestClass::Shifted>(1)), // 0338 QString()); 0339 QCOMPARE(enumeratorToString(static_cast<EnumTestClass::Shifted>(9)), // 0340 QString()); 0341 QCOMPARE(enumeratorToString(EnumTestClass::Shifted::value0), // 0342 QStringLiteral("value0(10)")); 0343 QCOMPARE(enumeratorToString(EnumTestClass::Shifted::value1), // 0344 QStringLiteral("value1(11)")); 0345 QCOMPARE(enumeratorToString(EnumTestClass::Shifted::value2), // 0346 QStringLiteral("value2(12)")); 0347 QCOMPARE(enumeratorToString(static_cast<EnumTestClass::Shifted>(13)), // 0348 QString()); 0349 } 0350 0351 void testEnumeratorToStringMissing() 0352 { 0353 QCOMPARE(enumeratorToString(static_cast<EnumTestClass::Missing>(-1)), // 0354 QString()); 0355 QCOMPARE(enumeratorToString(EnumTestClass::Missing::value0), // 0356 QStringLiteral("value0(0)")); 0357 QCOMPARE(enumeratorToString(static_cast<EnumTestClass::Missing>(1)), // 0358 QString()); 0359 QCOMPARE(enumeratorToString(static_cast<EnumTestClass::Missing>(9)), // 0360 QString()); 0361 QCOMPARE(enumeratorToString(EnumTestClass::Missing::value1), // 0362 QStringLiteral("value1(10)")); 0363 QCOMPARE(enumeratorToString(static_cast<EnumTestClass::Missing>(11)), // 0364 QString()); 0365 QCOMPARE(enumeratorToString(static_cast<EnumTestClass::Missing>(19)), // 0366 QString()); 0367 QCOMPARE(enumeratorToString(EnumTestClass::Missing::value2), // 0368 QStringLiteral("value2(20)")); 0369 QCOMPARE(enumeratorToString(static_cast<EnumTestClass::Missing>(21)), // 0370 QString()); 0371 } 0372 0373 void testEnumeratorToStringDoubledValue() 0374 { 0375 QCOMPARE(enumeratorToString(static_cast<EnumTestClass::DoubledValue>(-1)), // 0376 QString()); 0377 QCOMPARE(enumeratorToString(EnumTestClass::DoubledValue::value0), // 0378 QStringLiteral("value0(0)")); 0379 QCOMPARE(enumeratorToString(EnumTestClass::DoubledValue::value1), // 0380 QStringLiteral("value1|value2(1)")); 0381 QCOMPARE(enumeratorToString(EnumTestClass::DoubledValue::value2), // 0382 QStringLiteral("value1|value2(1)")); 0383 QCOMPARE(enumeratorToString(static_cast<EnumTestClass::DoubledValue>(2)), // 0384 QString()); 0385 } 0386 0387 void testEnumeratorToStringDoubledKey() 0388 { 0389 QCOMPARE(enumeratorToString(static_cast<EnumTestClass::DoubledKey>(-1)), // 0390 QString()); 0391 QCOMPARE(enumeratorToString(EnumTestClass::DoubledKey::value0), // 0392 QStringLiteral("value0(0)")); 0393 QCOMPARE(enumeratorToString(EnumTestClass::DoubledKey::value1), // 0394 QStringLiteral("value1|value2(1)")); 0395 QCOMPARE(enumeratorToString(EnumTestClass::DoubledKey::value2), // 0396 QStringLiteral("value1|value2(1)")); 0397 QCOMPARE(enumeratorToString(static_cast<EnumTestClass::DoubledKey>(2)), // 0398 QString()); 0399 } 0400 0401 void testQIconFromTheme() 0402 { 0403 // Test that this does not crash. 0404 const QIcon icon = qIconFromTheme(QStringList(), // 0405 QStringLiteral("eye-exclamation"), 0406 ColorSchemeType::Light); 0407 Q_UNUSED(icon) 0408 } 0409 0410 void testFromMnemonicToRichTextWithAutoMnemonic() 0411 { 0412 // Make sure to have mnemonics (like Qt::ALT+Qt::Key_X for "E&xit") 0413 // enabled, also on platforms that disable it by default. 0414 qt_set_sequence_auto_mnemonic(true); 0415 QCOMPARE(fromMnemonicToRichText(QString()), // 0416 QString()); 0417 QCOMPARE(fromMnemonicToRichText(QStringLiteral("A")), // 0418 QStringLiteral("A")); 0419 QCOMPARE(fromMnemonicToRichText(QStringLiteral("&A")), // 0420 QStringLiteral("<u>A</u>")); 0421 QCOMPARE(fromMnemonicToRichText(QStringLiteral("x&A")), // 0422 QStringLiteral("x<u>A</u>")); 0423 QCOMPARE(fromMnemonicToRichText(QStringLiteral("&Ax")), // 0424 QStringLiteral("<u>A</u>x")); 0425 QCOMPARE(fromMnemonicToRichText(QStringLiteral("& ")), // 0426 QStringLiteral("<u> </u>")); 0427 QCOMPARE(fromMnemonicToRichText(QStringLiteral("&Ax&A")), // 0428 QStringLiteral("<u>A</u>x<u>A</u>")); 0429 QCOMPARE(fromMnemonicToRichText(QStringLiteral("&&")), // 0430 QStringLiteral("&")); 0431 QCOMPARE(fromMnemonicToRichText(QStringLiteral("&A&&x")), // 0432 QStringLiteral("<u>A</u>&x")); 0433 QCOMPARE(fromMnemonicToRichText(QStringLiteral("&A&&x")), // 0434 QStringLiteral("<u>A</u>&x")); 0435 QCOMPARE(fromMnemonicToRichText(QStringLiteral("T&est && T&es&t")), // 0436 QStringLiteral("T<u>e</u>st & T<u>e</u>s<u>t</u>")); 0437 } 0438 0439 void testFromMnemonicToRichTextWithoutAutoMnemonic() 0440 { 0441 // Make sure to have mnemonics (like Qt::ALT+Qt::Key_X for "E&xit") 0442 // disabled, also on platforms that enable it by default. 0443 qt_set_sequence_auto_mnemonic(false); 0444 QCOMPARE(fromMnemonicToRichText(QString()), // 0445 QString()); 0446 QCOMPARE(fromMnemonicToRichText(QStringLiteral("A")), // 0447 QStringLiteral("A")); 0448 QCOMPARE(fromMnemonicToRichText(QStringLiteral("&A")), // 0449 QStringLiteral("A")); 0450 QCOMPARE(fromMnemonicToRichText(QStringLiteral("x&A")), // 0451 QStringLiteral("xA")); 0452 QCOMPARE(fromMnemonicToRichText(QStringLiteral("&Ax")), // 0453 QStringLiteral("Ax")); 0454 QCOMPARE(fromMnemonicToRichText(QStringLiteral("& ")), // 0455 QStringLiteral(" ")); 0456 QCOMPARE(fromMnemonicToRichText(QStringLiteral("&Ax&A")), // 0457 QStringLiteral("AxA")); 0458 QCOMPARE(fromMnemonicToRichText(QStringLiteral("&&")), // 0459 QStringLiteral("&")); 0460 QCOMPARE(fromMnemonicToRichText(QStringLiteral("&A&&x")), // 0461 QStringLiteral("A&x")); 0462 QCOMPARE(fromMnemonicToRichText(QStringLiteral("&A&&x")), // 0463 QStringLiteral("A&x")); 0464 QCOMPARE(fromMnemonicToRichText(QStringLiteral("T&est && T&es&t")), // 0465 QStringLiteral("Test & Test")); 0466 } 0467 0468 void testGuessColorSchemeTypeFromWidget() 0469 { 0470 QWidget myWidget; 0471 0472 QCOMPARE(guessColorSchemeTypeFromWidget(nullptr).has_value(), false); 0473 0474 myWidget.resize(0, 0); 0475 QCOMPARE(guessColorSchemeTypeFromWidget(&myWidget).has_value(), false); 0476 0477 myWidget.resize(1, 1); 0478 QCOMPARE(guessColorSchemeTypeFromWidget(&myWidget).has_value(), true); 0479 } 0480 0481 void testWcsBasicColors() 0482 { 0483 const auto colors = wcsBasicColors( // 0484 RgbColorSpaceFactory::createSrgb()); 0485 QCOMPARE( 0486 // For test, choose a value that is not in the center neither 0487 // horizontally nor vertically; this might detect mirroring bugs. 0488 colors.value(3, 3), 0489 QColor(0, 112, 50)); 0490 } 0491 0492 void testArray2DConstructor() 0493 { 0494 Array2D<int> test01(1, 2); 0495 Array2D<int> test02(0, 2); 0496 Array2D<int> test03(0, 0); 0497 } 0498 0499 void testArray2DConstructorInit() 0500 { 0501 Array2D<int> test(2, 0502 3, 0503 { 0504 // clang-format off 0505 1, 2, 0506 3, 4, 0507 5, 6, 0508 7 // excess element 0509 // clang-format on 0510 }); 0511 QCOMPARE(test.iCount(), 2); 0512 QCOMPARE(test.jCount(), 3); 0513 QCOMPARE(test.value(0, 0), 1); 0514 QCOMPARE(test.value(1, 0), 2); 0515 QCOMPARE(test.value(0, 1), 3); 0516 QCOMPARE(test.value(1, 1), 4); 0517 QCOMPARE(test.value(0, 2), 5); 0518 QCOMPARE(test.value(1, 2), 6); 0519 // Invalid indices should return default-constructed values, and 0520 // not the excess element. 0521 QCOMPARE(test.value(2, 2), 0); 0522 QCOMPARE(test.value(1, 3), 0); 0523 0524 Array2D<int> testIncompleteInit(2, 0525 3, 0526 { 0527 // clang-format off 0528 1, 2, 0529 3, 4, 0530 5 0531 // clang-format on 0532 }); 0533 // Non-initialized indices should return default-constructed values. 0534 QCOMPARE(testIncompleteInit.value(1, 2), 0); 0535 } 0536 0537 void testArray2DSetValue() 0538 { 0539 Array2D<int> test(2, 3); 0540 QCOMPARE(test.value(1, 2), 0); 0541 test.setValue(1, 2, 10); 0542 QCOMPARE(test.value(1, 2), 10); 0543 test.setValue(1, 2, 20); 0544 QCOMPARE(test.value(1, 2), 20); 0545 } 0546 }; 0547 0548 } // namespace PerceptualColor 0549 0550 QTEST_MAIN(PerceptualColor::TestHelper) 0551 // The following “include” is necessary because we do not use a header file: 0552 #include "testhelper.moc"