47
|
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: This class is test case for file manager internal api class.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "fmfiletyperecognizer.h"
|
|
19 |
#include <QtTest/QtTest>
|
|
20 |
#include <QMap>
|
|
21 |
#include <QString>
|
|
22 |
#include <QStringList>
|
|
23 |
|
|
24 |
class TestFmFileTypeRcognizer: public QObject
|
|
25 |
{
|
|
26 |
Q_OBJECT
|
|
27 |
|
|
28 |
private slots:
|
|
29 |
void initTestCase();
|
|
30 |
|
|
31 |
void testFmFileTypeRecognizer(); // test the FmFileTypeRecognizer() constructor.
|
|
32 |
|
|
33 |
void testGetTypeDrive(); // test the getType() function
|
|
34 |
void testGetTypePath();
|
|
35 |
void testGetTypeKnown();
|
|
36 |
void testGetTypeUnKnown();
|
|
37 |
|
|
38 |
void cleanupTestCase(); // Finalize test data
|
|
39 |
};
|
|
40 |
|
|
41 |
/*!
|
|
42 |
\class TestFmFileTypeRcognizer
|
|
43 |
\brief \n
|
|
44 |
class name: FmDriveModel \n
|
|
45 |
class's description: Test the File Manager internal api functions. \n
|
|
46 |
type of test case: unit test\n
|
|
47 |
test cases' number totally: 5 \n
|
|
48 |
*/
|
|
49 |
|
|
50 |
void TestFmFileTypeRcognizer::initTestCase()
|
|
51 |
{
|
|
52 |
}
|
|
53 |
|
|
54 |
/*!
|
|
55 |
Test Case Description:\n
|
|
56 |
1. Fucntion Name: \n
|
|
57 |
FmFileTypeRecognizer(); \n
|
|
58 |
2. Case Descrition: test the constructor function. \n
|
|
59 |
3. Input Parameters: \n
|
|
60 |
<1> no \n
|
|
61 |
4. Expected result: \n
|
|
62 |
<1> no crash \n
|
|
63 |
*/
|
|
64 |
void TestFmFileTypeRcognizer::testFmFileTypeRecognizer()
|
|
65 |
{
|
|
66 |
FmFileTypeRecognizer *testRcognizer = new FmFileTypeRecognizer();
|
|
67 |
}
|
|
68 |
|
|
69 |
/*!
|
|
70 |
Test Case Description:\n
|
|
71 |
1. Fucntion Name: \n
|
|
72 |
FmFileTypeRecognizer::FileType getType( const QString& path ) const ; \n
|
|
73 |
2. Case Descrition: Verify the right file type is returned \n
|
|
74 |
3. Input Parameters: \n
|
|
75 |
<1> path = QString(XX) \n
|
|
76 |
4. Expected result: \n
|
|
77 |
<1> retType = FileTypeDrive \n
|
|
78 |
*/
|
|
79 |
void TestFmFileTypeRcognizer::testGetTypeDrive()
|
|
80 |
{
|
|
81 |
FmFileTypeRecognizer *testRcognizer = new FmFileTypeRecognizer();
|
|
82 |
FmFileTypeRecognizer::FileType retType = testRcognizer->getType( "C:\\" );
|
|
83 |
qDebug() << retType;
|
|
84 |
QVERIFY(retType == FmFileTypeRecognizer::FileTypeDrive);
|
|
85 |
delete testRcognizer;
|
|
86 |
}
|
|
87 |
|
|
88 |
/*!
|
|
89 |
Test Case Description:\n
|
|
90 |
1. Fucntion Name: \n
|
|
91 |
FmFileTypeRecognizer::FileType getType( const QString& path ) const ; \n
|
|
92 |
2. Case Descrition: Verify the right file type is returned \n
|
|
93 |
3. Input Parameters: \n
|
|
94 |
<1> path = QString(XX) \n
|
|
95 |
4. Expected result: \n
|
|
96 |
<1> retType = FileTypeFolder \n
|
|
97 |
*/
|
|
98 |
void TestFmFileTypeRcognizer::testGetTypePath()
|
|
99 |
{
|
|
100 |
FmFileTypeRecognizer *testRcognizer = new FmFileTypeRecognizer();
|
|
101 |
FmFileTypeRecognizer::FileType retType = testRcognizer->getType( Folder_C_Data);
|
|
102 |
qDebug() << retType;
|
|
103 |
QVERIFY(retType == FmFileTypeRecognizer::FileTypeFolder);
|
|
104 |
delete testRcognizer;
|
|
105 |
}
|
|
106 |
|
|
107 |
/*!
|
|
108 |
Test Case Description:\n
|
|
109 |
1. Fucntion Name: \n
|
|
110 |
FmFileTypeRecognizer::FileType getType( const QString& path ) const ; \n
|
|
111 |
2. Case Descrition: Verify the right file type is returned \n
|
|
112 |
3. Input Parameters: \n
|
|
113 |
<1> path = QString(XX) \n
|
|
114 |
4. Expected result: \n
|
|
115 |
<1> return the correct file type \n
|
|
116 |
*/
|
|
117 |
void TestFmFileTypeRcognizer::testGetTypeKnown()
|
|
118 |
{
|
|
119 |
QString path1 = "image.jpg";
|
|
120 |
QString path2 = "Video.rm";
|
|
121 |
QString path3 = "Tone.wav";
|
|
122 |
QString path4 = "Text.doc";
|
|
123 |
QString path5 = "Install.sisx";
|
|
124 |
QString path6 = "Java.jar";
|
|
125 |
QString path7 = "Flash.swf";
|
|
126 |
#ifdef FEATURE_NOT_IMPLEMENTED_TYPERECOG
|
|
127 |
QString pathWidget = "widget.wgz";
|
|
128 |
QString pathWebLink = "abc.lnk";// Need confirm the suffix
|
|
129 |
#endif
|
|
130 |
FmFileTypeRecognizer *testRcognizer = new FmFileTypeRecognizer();
|
|
131 |
|
|
132 |
FmFileTypeRecognizer::FileType retType1 = testRcognizer->getType( path1);
|
|
133 |
QVERIFY(retType1 == FmFileTypeRecognizer::FileTypeImage);
|
|
134 |
|
|
135 |
FmFileTypeRecognizer::FileType retType2 = testRcognizer->getType( path2);
|
|
136 |
// qDebug() << retType1;
|
|
137 |
QVERIFY(retType2 == FmFileTypeRecognizer::FileTypeVideo);
|
|
138 |
|
|
139 |
FmFileTypeRecognizer::FileType retType3 = testRcognizer->getType( path3);
|
|
140 |
QVERIFY(retType3 == FmFileTypeRecognizer::FileTypeTone);
|
|
141 |
|
|
142 |
FmFileTypeRecognizer::FileType retType4 = testRcognizer->getType( path4);
|
|
143 |
QVERIFY(retType4 == FmFileTypeRecognizer::FileTypeText);
|
|
144 |
|
|
145 |
FmFileTypeRecognizer::FileType retType5 = testRcognizer->getType( path5);
|
|
146 |
QVERIFY(retType5 == FmFileTypeRecognizer::FileTypeSisx);
|
|
147 |
|
|
148 |
FmFileTypeRecognizer::FileType retType6 = testRcognizer->getType( path6);
|
|
149 |
QVERIFY(retType6 == FmFileTypeRecognizer::FileTypeJava);
|
|
150 |
|
|
151 |
FmFileTypeRecognizer::FileType retType7 = testRcognizer->getType( path7);
|
|
152 |
QVERIFY(retType7 == FmFileTypeRecognizer::FileTypeFlash);
|
|
153 |
|
|
154 |
#ifdef FEATURE_NOT_IMPLEMENTED_TYPERECOG
|
|
155 |
FmFileTypeRecognizer::FileType retType8 = testRcognizer->getType( pathWidget);
|
|
156 |
// QVERIFY(retType8 == FmFileTypeRecognizer::FileTypeWidget);
|
|
157 |
|
|
158 |
FmFileTypeRecognizer::FileType retType9 = testRcognizer->getType( pathWebLink);
|
|
159 |
// QVERIFY(retType9 == FmFileTypeRecognizer::FileTypeWebLink);
|
|
160 |
#endif
|
|
161 |
delete testRcognizer;
|
|
162 |
}
|
|
163 |
|
|
164 |
/*!
|
|
165 |
Test Case Description:\n
|
|
166 |
1. Fucntion Name: \n
|
|
167 |
FmFileTypeRecognizer::FileType getType( const QString& path ) const ; \n
|
|
168 |
2. Case Descrition: Verify the right file type is returned \n
|
|
169 |
3. Input Parameters: \n
|
|
170 |
<1> path = QString(XX) \n
|
|
171 |
4. Expected result: \n
|
|
172 |
<1> retType = FileTypeUnKnown \n
|
|
173 |
*/
|
|
174 |
void TestFmFileTypeRcognizer::testGetTypeUnKnown()
|
|
175 |
{
|
|
176 |
FmFileTypeRecognizer *testRcognizer = new FmFileTypeRecognizer();
|
|
177 |
|
|
178 |
FmFileTypeRecognizer::FileType retType = testRcognizer->getType( "unknown.unknow");
|
|
179 |
QVERIFY(retType == FmFileTypeRecognizer::FileTypeUnKnown);
|
|
180 |
delete testRcognizer;
|
|
181 |
}
|
|
182 |
|
|
183 |
void TestFmFileTypeRcognizer::cleanupTestCase()
|
|
184 |
{
|
|
185 |
|
|
186 |
}
|
|
187 |
|
|
188 |
QTEST_MAIN(TestFmFileTypeRcognizer)
|
|
189 |
#include "ut_fmfiletyperecognizer.moc"
|