diff -r a5692c68d772 -r 593f946f4fec controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemeutil/unittest_cpthemeutil.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/controlpanelplugins/themeplugin/tsrc/unit/unittest_cpthemeutil/unittest_cpthemeutil.cpp Wed Sep 29 10:09:58 2010 +0800 @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: XENT-MV +* +* Description: unit tests for the CpThemePreview class from themeplugin +* +*/ + +#include + +#include +#include +#include +#include +#include "cpthemeutil.h" +#include "cpthemeinfo.h" + +class TestCpThemeUtil : public QObject +{ + Q_OBJECT + +private slots: + + void testMultiple(); + void testAvailableThemes(); + void testThemeDirectories(); + +}; + +void TestCpThemeUtil::testMultiple() +{ + QList > themes = HbThemeServices::availableThemes(); + + QPair pair; + + pair = themes.at(0); + + QString name = pair.first; + QString themePath = pair.second; + + QList themeList = CpThemeUtil::buildThemeList(); + + QCOMPARE(name, themeList.at(0).name()); + QCOMPARE(themePath, themeList.at(0).itemData()); + + CpThemeInfo *themeInfo = CpThemeUtil::buildThemeInfo(themePath, name); + QCOMPARE(name, themeInfo->name()); + QCOMPARE(themePath, themeInfo->itemData()); + + + //null test, making sure no crash happens. + QString defaultThemePath = CpThemeUtil::defaultTheme(); + + delete themeInfo; + themeInfo = 0; + +} +void TestCpThemeUtil::testAvailableThemes() +{ + QList > themes = HbThemeServices::availableThemes(); + QList > utilThemes = CpThemeUtil::availableThemes(); + + for(int i = 0; i < themes.size(); i++) { + QPairpair1; + QPairpair2; + + pair1 = themes.at(i); + pair2 = utilThemes.at(i); + QCOMPARE(pair1.first, pair2.first); + QCOMPARE(pair1.second, pair2.second); + } +} + +void TestCpThemeUtil::testThemeDirectories() +{ + QList themeList = CpThemeUtil::buildThemeList(); + QStringList themeDirs = CpThemeUtil::themeDirectories(themeList); + QVERIFY(themeList.size() > 0 && themeDirs.size() > 0); +} + +QTEST_MAIN(TestCpThemeUtil) +#include "unittest_cpthemeutil.moc" +