diff options
author | Miguel Gómez <magomez@igalia.com> | 2010-12-02 15:04:30 +0100 |
---|---|---|
committer | Adrian Yanes <ext-adrian.yanes@nokia.com> | 2010-12-03 13:55:50 +0000 |
commit | 8139d3856ead6a6c9348ac124eb6c007c2488403 (patch) | |
tree | 8d559563783ab5c471740988dbf01447e5c50aed /tests | |
parent | ad9e65f8378963d8910245c0b27df70c9540c832 (diff) |
Changes: new test cases for MTheme, MStyleSheetParser, MScalableImage
RevBy: Adrian Yanes
Details:
Add unit tests for MTheme::addPixmapDirectory() and MTheme::clearPixmapDirectories().
Added test case for MStyleSheetParser::setBinaryFileDirectory()
Added test for MScalableImage::enableOptimizedRendering()
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ft_mscalableimage/ft_mscalableimage.cpp | 8 | ||||
-rw-r--r-- | tests/ft_mscalableimage/ft_mscalableimage.h | 2 | ||||
-rw-r--r-- | tests/ft_mstylesheetparser/ft_mstylesheetparser.cpp | 20 | ||||
-rw-r--r-- | tests/ft_mstylesheetparser/ft_mstylesheetparser.h | 1 | ||||
-rw-r--r-- | tests/ut_mtheme/ut_mtheme.cpp | 53 | ||||
-rw-r--r-- | tests/ut_mtheme/ut_mtheme.h | 3 |
6 files changed, 87 insertions, 0 deletions
diff --git a/tests/ft_mscalableimage/ft_mscalableimage.cpp b/tests/ft_mscalableimage/ft_mscalableimage.cpp index 96ce3ca8..8fdb2c86 100644 --- a/tests/ft_mscalableimage/ft_mscalableimage.cpp +++ b/tests/ft_mscalableimage/ft_mscalableimage.cpp @@ -196,5 +196,13 @@ void Ft_MScalableImage::verifyResult(const QImage& image, const QSize& paintSize QCOMPARE(isImageBlockColor(image, QRect(BLOCK_SIZE, BLOCK_SIZE, center_width, center_height), COLOR_CENTER), true); } +void Ft_MScalableImage::testEnableOptimizedRendering() +{ + /* the method does nothing, not even storing the value. These calls are just + to cheat the coverage tools */ + m_subject->enableOptimizedRendering(true); + m_subject->enableOptimizedRendering(false); +} + QTEST_APPLESS_MAIN(Ft_MScalableImage) diff --git a/tests/ft_mscalableimage/ft_mscalableimage.h b/tests/ft_mscalableimage/ft_mscalableimage.h index 53bba5bb..1ea8419a 100644 --- a/tests/ft_mscalableimage/ft_mscalableimage.h +++ b/tests/ft_mscalableimage/ft_mscalableimage.h @@ -40,6 +40,8 @@ private slots: void test_draw_scalable9(); void test_draw_scalable1(); + void testEnableOptimizedRendering(); + private: void verifyResult(const QImage& image, const QSize& paintSize); class MScalableImage *m_subject; diff --git a/tests/ft_mstylesheetparser/ft_mstylesheetparser.cpp b/tests/ft_mstylesheetparser/ft_mstylesheetparser.cpp index cfc5faec..d7d555d5 100644 --- a/tests/ft_mstylesheetparser/ft_mstylesheetparser.cpp +++ b/tests/ft_mstylesheetparser/ft_mstylesheetparser.cpp @@ -723,4 +723,24 @@ void Ft_MStyleSheetParser::test_binary_speed() qDebug() << "Total reading time:" << TOTAL_TIME << "microseconds (" << TOTAL_TIME / 1000000.0 << "seconds)"; } +void Ft_MStyleSheetParser::test_set_binary_file_directory() +{ + MStyleSheetParser parser; + QString binaryPath = qApp->applicationDirPath(); + QString cssPath = qApp->applicationDirPath() + QDir::separator() + "ft_mstylesheetparser_test.css"; + + parser.setBinaryFileGenerationEnabled(true); + parser.setBinaryFileDirectory(binaryPath); + parser.load(cssPath); + + QString binaryFilename = cssPath; + binaryFilename.replace(QLatin1Char('_'), "__"); + binaryFilename.replace(QLatin1Char('/'), "_."); + + /* Check that binary file was created in the right dir */ + QVERIFY(QFile::exists(binaryPath + QDir::separator() + binaryFilename)); + + /* remove the created file */ + QFile::remove(binaryPath + QDir::separator() + binaryFilename); +} QTEST_APPLESS_MAIN(Ft_MStyleSheetParser) diff --git a/tests/ft_mstylesheetparser/ft_mstylesheetparser.h b/tests/ft_mstylesheetparser/ft_mstylesheetparser.h index f85b964e..4685d9f8 100644 --- a/tests/ft_mstylesheetparser/ft_mstylesheetparser.h +++ b/tests/ft_mstylesheetparser/ft_mstylesheetparser.h @@ -47,6 +47,7 @@ private slots: void test_binary_equality(); void test_parser_speed(); void test_binary_speed(); + void test_set_binary_file_directory(); /*void test_inheritance(); void test_objectnames(); diff --git a/tests/ut_mtheme/ut_mtheme.cpp b/tests/ut_mtheme/ut_mtheme.cpp index ffd21774..1783d4d4 100644 --- a/tests/ut_mtheme/ut_mtheme.cpp +++ b/tests/ut_mtheme/ut_mtheme.cpp @@ -450,4 +450,57 @@ void Ut_MTheme::waitForPendingThemeRequests() } } +void Ut_MTheme::testAddPixmapDirectory() { + + const QPixmap *invalid; + const QPixmap *valid; + QString pixmapId="ut_mtheme"; + QSize validPixmapSize(20,20); + QSize invalidPixmapSize(50,50); + + /* Request a pixmap not available. This will return the 50x50 red pixmap */ + invalid = m_theme->pixmap(pixmapId, validPixmapSize); + QVERIFY(invalid->size() == invalidPixmapSize); + m_theme->releasePixmap(invalid); + m_theme->cleanupGarbage(); + + /* Add current directory so the pixmap can be found */ + m_theme->addPixmapDirectory(qApp->applicationDirPath()); + + /* And then request the pixmap again, which will return the right one */ + valid = m_theme->pixmap(pixmapId, validPixmapSize); + QVERIFY(valid->size() == validPixmapSize); + m_theme->releasePixmap(valid); + m_theme->cleanupGarbage(); + QCOMPARE(cachedIconCount(), 0); + QVERIFY(!isIconCached(pixmapId, QSize())); +} + +void Ut_MTheme::testClearPixmapDirectories() { + + const QPixmap *invalid; + const QPixmap *valid; + QSize validPixmapSize(20,20); + QSize invalidPixmapSize(50,50); + QString pixmapId="ut_mtheme"; + + /* Add current dir to the list */ + m_theme->addPixmapDirectory(qApp->applicationDirPath()); + + /* Request a pixmap available */ + valid = m_theme->pixmap(pixmapId, validPixmapSize); + QVERIFY(valid->size() == validPixmapSize); + m_theme->releasePixmap(valid); + m_theme->cleanupGarbage(); + + /* clear pixmap directories */ + m_theme->clearPixmapDirectories(); + + /* And request it again to get the invalid pixmap */ + invalid = m_theme->pixmap(pixmapId, validPixmapSize); + QVERIFY(invalid->size() == invalidPixmapSize); + m_theme->releasePixmap(invalid); + m_theme->cleanupGarbage(); +} + QTEST_APPLESS_MAIN(Ut_MTheme) diff --git a/tests/ut_mtheme/ut_mtheme.h b/tests/ut_mtheme/ut_mtheme.h index ca22fd89..8faf819c 100644 --- a/tests/ut_mtheme/ut_mtheme.h +++ b/tests/ut_mtheme/ut_mtheme.h @@ -52,6 +52,9 @@ private slots: void testScalableImage(); void testView(); + void testAddPixmapDirectory(); + void testClearPixmapDirectories(); + private: /** * @return True, if the given icon has been cached in the theme daemon. |