1 #include <QtTest/QtTest> 2 #include "cell.h" 3 4 #if defined(Q_OS_WIN) && defined(USE_STATIC_QT) 5 #include <QtPlugin> 6 Q_IMPORT_PLUGIN (QWindowsIntegrationPlugin); 7 #endif 8 9 class Test: public QObject 10 { 11 Q_OBJECT 12 private slots: cellDefault()13 void cellDefault() { 14 Cell c; 15 QCOMPARE(c.GetCharacter(), uint(' ')); 16 // Default colors are invalid 17 QCOMPARE(c.GetForegroundColor(), QColor()); 18 QCOMPARE(c.GetBackgroundColor(), QColor()); 19 QCOMPARE(c.GetSpecialColor(), QColor()); 20 QVERIFY(!c.GetForegroundColor().isValid()); 21 QVERIFY(!c.GetBackgroundColor().isValid()); 22 QVERIFY(!c.GetSpecialColor().isValid()); 23 24 QBENCHMARK { 25 Cell c; 26 } 27 } 28 cellValue()29 void cellValue() { 30 QBENCHMARK { 31 Cell c('z', Qt::black, Qt::white, QColor(), 32 false, false, false, false, false); 33 } 34 } cellValueRgb()35 void cellValueRgb() { 36 QBENCHMARK { 37 Cell c('z', QRgb(33), QRgb(66), QColor(), 38 false, false, false, false, false); 39 } 40 } 41 cellWidth()42 void cellWidth() { 43 Cell c; 44 QCOMPARE(c.IsDoubleWidth(), false); 45 c.SetCharacter(27721); 46 QCOMPARE(c.IsDoubleWidth(), true); 47 } 48 cellBg()49 void cellBg() { 50 Cell c0; 51 Cell c1 = Cell{ QColor::Invalid }; 52 QCOMPARE(c0, c1); 53 54 Cell c2 = Cell{ QColor{ Qt::red } }; 55 QCOMPARE(c2.GetBackgroundColor(), QColor{ Qt::red }); 56 } 57 }; 58 59 QTEST_MAIN(Test) 60 #include "test_cell.moc" 61