|
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: |
|
13 * |
|
14 * Description: |
|
15 * test application for qt control panel public apis. |
|
16 */ |
|
17 #include "ut_cputility.h" |
|
18 #include "cputility.h" |
|
19 |
|
20 #include <QtTest/QtTest> |
|
21 |
|
22 /*! |
|
23 \class TestCpUtility |
|
24 \brief This class is used for the unit test for class CpUtility.\n |
|
25 CpUtility class is an utility class to provide functionalities about drive and dir related processing.\n |
|
26 This unit test is supported by QTest.\n |
|
27 There are total 6 test cases in this unit.\n |
|
28 */ |
|
29 |
|
30 void TestCpUtility::initTestCase() |
|
31 { |
|
32 } |
|
33 |
|
34 void TestCpUtility::cleanupTestCase() |
|
35 { |
|
36 QCoreApplication::processEvents(); |
|
37 } |
|
38 |
|
39 /*! |
|
40 * Test Case Description:\n |
|
41 * 1. Fucntion Name: \n |
|
42 static CpUtility::drives();\n |
|
43 |
|
44 2. Function Descrition: \n |
|
45 Get and store driver letter into QStringList object, using QDir::drives().\n |
|
46 3. Input Parameters: none.\n |
|
47 |
|
48 4. Expected result: \n |
|
49 case run without verify failed.\n |
|
50 */ |
|
51 void TestCpUtility::testDrivesOnce() |
|
52 { |
|
53 QStringList strListDrives = CpUtility::drives(); |
|
54 QVERIFY(!strListDrives.isEmpty()); |
|
55 |
|
56 verifyDrivesList(strListDrives); |
|
57 } |
|
58 |
|
59 /*! |
|
60 * Test Case Description:\n |
|
61 * 1. Fucntion Name: \n |
|
62 static CpUtility::drives();\n |
|
63 |
|
64 2. Function Descrition: \n |
|
65 Get and store driver letter into QStringList object, using QDir::drives().\n |
|
66 3. Input Parameters: none.\n |
|
67 |
|
68 4. Expected result: \n |
|
69 case run without verify failed.\n |
|
70 */ |
|
71 void TestCpUtility::testDrivesRepeatTwice() |
|
72 { |
|
73 QStringList strListDrives1 = CpUtility::drives(); |
|
74 QVERIFY(!strListDrives1.isEmpty()); |
|
75 |
|
76 verifyDrivesList(strListDrives1); |
|
77 |
|
78 QStringList strListDrives2 = CpUtility::drives(); |
|
79 QVERIFY(!strListDrives2.isEmpty()); |
|
80 |
|
81 verifyDrivesList(strListDrives2); |
|
82 } |
|
83 |
|
84 /*! |
|
85 * Test Case Description:\n |
|
86 * 1. Fucntion Name: \n |
|
87 static CpUtility::pluginDirectories();\n |
|
88 |
|
89 2. Function Descrition: \n |
|
90 Get and store plugin directories into QStringList object.\n |
|
91 3. Input Parameters: none.\n |
|
92 |
|
93 4. Expected result: \n |
|
94 case run without verify failed.\n |
|
95 */ |
|
96 void TestCpUtility::testPluginDirectoriesOnce() |
|
97 { |
|
98 QStringList strListDirs = CpUtility::pluginDirectories(); |
|
99 QVERIFY(!strListDirs.isEmpty()); |
|
100 |
|
101 verifyDirectoriesList(strListDirs); |
|
102 } |
|
103 |
|
104 /*! |
|
105 * Test Case Description:\n |
|
106 * 1. Fucntion Name: \n |
|
107 static CpUtility::pluginDirectories();\n |
|
108 |
|
109 2. Function Descrition: \n |
|
110 Get and store plugin directories into QStringList object.\n |
|
111 3. Input Parameters: none.\n |
|
112 |
|
113 4. Expected result: \n |
|
114 case run without verify failed.\n |
|
115 */ |
|
116 void TestCpUtility::testPluginDirectoriesRepeatTwice() |
|
117 { |
|
118 QStringList strListDirs1 = CpUtility::pluginDirectories(); |
|
119 QVERIFY(!strListDirs1.isEmpty()); |
|
120 |
|
121 verifyDirectoriesList(strListDirs1); |
|
122 |
|
123 QStringList strListDirs2 = CpUtility::pluginDirectories(); |
|
124 QVERIFY(!strListDirs2.isEmpty()); |
|
125 |
|
126 verifyDirectoriesList(strListDirs2); |
|
127 } |
|
128 |
|
129 /*! |
|
130 * Test Case Description:\n |
|
131 * 1. Fucntion Name: \n |
|
132 static CpUtility::configFileDirectories();\n |
|
133 |
|
134 2. Function Descrition: \n |
|
135 Get and store cpcfg file directories into QStringList object.\n |
|
136 3. Input Parameters: none.\n |
|
137 |
|
138 4. Expected result: \n |
|
139 case run without verify failed.\n |
|
140 */ |
|
141 void TestCpUtility::testConfigFileDirectoriesOnce() |
|
142 { |
|
143 QStringList strListConfigDirs = CpUtility::configFileDirectories(); |
|
144 QVERIFY(!strListConfigDirs.isEmpty()); |
|
145 |
|
146 verifyConfigFileDirectories(strListConfigDirs); |
|
147 } |
|
148 |
|
149 /*! |
|
150 * Test Case Description:\n |
|
151 * 1. Fucntion Name: \n |
|
152 static CpUtility::configFileDirectories();\n |
|
153 |
|
154 2. Function Descrition: \n |
|
155 Get and store cpcfg file directories into QStringList object.\n |
|
156 3. Input Parameters: none.\n |
|
157 |
|
158 4. Expected result: \n |
|
159 case run without verify failed.\n |
|
160 */ |
|
161 void TestCpUtility::testConfigFileDirectoriesRepeatTwice() |
|
162 { |
|
163 QStringList strListConfigDirs1 = CpUtility::configFileDirectories(); |
|
164 QVERIFY(!strListConfigDirs1.isEmpty()); |
|
165 |
|
166 verifyConfigFileDirectories(strListConfigDirs1); |
|
167 |
|
168 QStringList strListConfigDirs2 = CpUtility::configFileDirectories(); |
|
169 QVERIFY(!strListConfigDirs2.isEmpty()); |
|
170 |
|
171 verifyConfigFileDirectories(strListConfigDirs2); |
|
172 } |
|
173 |
|
174 void TestCpUtility::verifyDrivesList(const QStringList &strList) |
|
175 { |
|
176 QVERIFY( strList.contains("C:", Qt::CaseInsensitive) ); |
|
177 QVERIFY( strList.contains("Z:", Qt::CaseInsensitive) ); |
|
178 } |
|
179 |
|
180 void TestCpUtility::verifyDirectoriesList(const QStringList &strList) |
|
181 { |
|
182 QVERIFY( strList.contains(QString("C:/resource/qt/plugins/controlpanel") + QDir::separator(), Qt::CaseInsensitive)); |
|
183 } |
|
184 |
|
185 void TestCpUtility::verifyConfigFileDirectories(const QStringList &strList) |
|
186 { |
|
187 QVERIFY( strList.contains(QString("C:/resource/qt/plugins/controlpanel/config") + QDir::separator(), Qt::CaseInsensitive)); |
|
188 } |
|
189 |
|
190 QTEST_APPLESS_MAIN(TestCpUtility) |