33
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0""
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors: XENT-MV
|
|
13 |
*
|
|
14 |
* Description: unit tests for the CpThemePreview class from themeplugin
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <QtTest/QtTest>
|
|
19 |
|
|
20 |
#include <restricted/hbthemeservices_r.h>
|
|
21 |
#include <QList>
|
|
22 |
#include <QStringList>
|
|
23 |
#include <QPair>
|
|
24 |
#include "cpthemeutil.h"
|
|
25 |
#include "cpthemeinfo.h"
|
|
26 |
|
|
27 |
class TestCpThemeUtil : public QObject
|
|
28 |
{
|
|
29 |
Q_OBJECT
|
|
30 |
|
|
31 |
private slots:
|
|
32 |
|
|
33 |
void testMultiple();
|
|
34 |
void testAvailableThemes();
|
|
35 |
void testThemeDirectories();
|
|
36 |
|
|
37 |
};
|
|
38 |
|
|
39 |
void TestCpThemeUtil::testMultiple()
|
|
40 |
{
|
|
41 |
QList<QPair<QString, QString> > themes = HbThemeServices::availableThemes();
|
|
42 |
|
|
43 |
QPair<QString, QString> pair;
|
|
44 |
|
|
45 |
pair = themes.at(0);
|
|
46 |
|
|
47 |
QString name = pair.first;
|
|
48 |
QString themePath = pair.second;
|
|
49 |
|
|
50 |
QList<CpThemeInfo> themeList = CpThemeUtil::buildThemeList();
|
|
51 |
|
|
52 |
QCOMPARE(name, themeList.at(0).name());
|
|
53 |
QCOMPARE(themePath, themeList.at(0).itemData());
|
|
54 |
|
|
55 |
CpThemeInfo *themeInfo = CpThemeUtil::buildThemeInfo(themePath, name);
|
|
56 |
QCOMPARE(name, themeInfo->name());
|
|
57 |
QCOMPARE(themePath, themeInfo->itemData());
|
|
58 |
|
|
59 |
|
|
60 |
//null test, making sure no crash happens.
|
|
61 |
QString defaultThemePath = CpThemeUtil::defaultTheme();
|
|
62 |
|
|
63 |
delete themeInfo;
|
|
64 |
themeInfo = 0;
|
|
65 |
|
|
66 |
}
|
|
67 |
void TestCpThemeUtil::testAvailableThemes()
|
|
68 |
{
|
|
69 |
QList<QPair<QString, QString> > themes = HbThemeServices::availableThemes();
|
|
70 |
QList<QPair<QString, QString> > utilThemes = CpThemeUtil::availableThemes();
|
|
71 |
|
|
72 |
for(int i = 0; i < themes.size(); i++) {
|
|
73 |
QPair<QString, QString>pair1;
|
|
74 |
QPair<QString, QString>pair2;
|
|
75 |
|
|
76 |
pair1 = themes.at(i);
|
|
77 |
pair2 = utilThemes.at(i);
|
|
78 |
QCOMPARE(pair1.first, pair2.first);
|
|
79 |
QCOMPARE(pair1.second, pair2.second);
|
|
80 |
}
|
|
81 |
}
|
|
82 |
|
|
83 |
void TestCpThemeUtil::testThemeDirectories()
|
|
84 |
{
|
|
85 |
QList<CpThemeInfo> themeList = CpThemeUtil::buildThemeList();
|
|
86 |
QStringList themeDirs = CpThemeUtil::themeDirectories(themeList);
|
|
87 |
QVERIFY(themeList.size() > 0 && themeDirs.size() > 0);
|
|
88 |
}
|
|
89 |
|
|
90 |
QTEST_MAIN(TestCpThemeUtil)
|
|
91 |
#include "unittest_cpthemeutil.moc"
|
|
92 |
|