271
|
1 |
// Copyright (c) 1995-2010 Nokia Corporation and/or its subsidiary(-ies).
|
0
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// e32test\buffer\t_versio.cpp
|
|
15 |
// Overview:
|
|
16 |
// Test the version information class.
|
|
17 |
// API Information:
|
|
18 |
// TVersion.
|
|
19 |
// Details:
|
|
20 |
// - Test the version name for different versions as expected.
|
|
21 |
// - Compare the major, minor, build version number of current version and
|
|
22 |
// specified version and verify that error message is popped when version
|
|
23 |
// is not supported.
|
|
24 |
// Platforms/Drives/Compatibility:
|
|
25 |
// All
|
|
26 |
// Assumptions/Requirement/Pre-requisites:
|
|
27 |
// Failures and causes:
|
|
28 |
// Base Port information:
|
|
29 |
//
|
|
30 |
//
|
|
31 |
|
|
32 |
#include <e32test.h>
|
271
|
33 |
#include "d_version.h"
|
0
|
34 |
|
|
35 |
class RTvTest : public RTest
|
|
36 |
{
|
|
37 |
public:
|
|
38 |
RTvTest();
|
|
39 |
void TestName();
|
|
40 |
void TestQVS();
|
|
41 |
void Start(const TDesC &aHeading) {Printf(aHeading);Push();}
|
271
|
42 |
TInt LoadDeviceDriver();
|
|
43 |
TInt UnloadDeviceDriver();
|
0
|
44 |
private:
|
|
45 |
TBool QVS(TInt i,TInt j);
|
271
|
46 |
public:
|
|
47 |
RVersionTest gLdd;
|
0
|
48 |
private:
|
|
49 |
TVersion* iTV[KNumTVersions];
|
|
50 |
TVersion iDefTV; // tests default constructor
|
|
51 |
};
|
|
52 |
|
|
53 |
LOCAL_D const TText* Names[]=
|
|
54 |
{
|
|
55 |
_S("0.00(0)"),
|
|
56 |
_S("0.00(0)"),
|
|
57 |
_S("0.00(1)"),
|
|
58 |
_S("0.00(999)"),
|
|
59 |
_S("0.01(0)"),
|
|
60 |
_S("0.01(1)"),
|
|
61 |
_S("0.01(999)"),
|
|
62 |
_S("0.99(0)"),
|
|
63 |
_S("0.99(1)"),
|
|
64 |
_S("0.99(999)"),
|
|
65 |
_S("1.00(0)"),
|
|
66 |
_S("1.00(1)"),
|
|
67 |
_S("1.00(999)"),
|
|
68 |
_S("1.01(0)"),
|
|
69 |
_S("1.01(1)"),
|
|
70 |
_S("1.01(999)"),
|
|
71 |
_S("1.99(0)"),
|
|
72 |
_S("1.99(1)"),
|
|
73 |
_S("1.99(999)"),
|
|
74 |
_S("99.00(0)"),
|
|
75 |
_S("99.00(1)"),
|
|
76 |
_S("99.00(999)"),
|
|
77 |
_S("99.01(0)"),
|
|
78 |
_S("99.01(1)"),
|
|
79 |
_S("99.01(999)"),
|
|
80 |
_S("99.99(0)"),
|
|
81 |
_S("99.99(1)"),
|
|
82 |
_S("99.99(999)")
|
|
83 |
};
|
|
84 |
|
271
|
85 |
TInt RTvTest::LoadDeviceDriver()
|
|
86 |
//
|
|
87 |
// Load device driver for kernel side test
|
|
88 |
//
|
|
89 |
{
|
|
90 |
TInt r=KErrNone;
|
|
91 |
r=User::LoadLogicalDevice(KVersionTestLddName);
|
|
92 |
if(r!=KErrNone)
|
|
93 |
{
|
|
94 |
return r;
|
|
95 |
}
|
|
96 |
r=gLdd.Open();
|
|
97 |
return r;
|
|
98 |
}
|
|
99 |
|
|
100 |
TInt RTvTest::UnloadDeviceDriver()
|
|
101 |
//
|
|
102 |
// Unload device driver
|
|
103 |
//
|
|
104 |
{
|
|
105 |
TInt r=KErrNone;
|
|
106 |
gLdd.Close();
|
|
107 |
|
|
108 |
r = User::FreeLogicalDevice(KVersionTestLddName);
|
|
109 |
if(r!=KErrNone)
|
|
110 |
{
|
|
111 |
return r;
|
|
112 |
}
|
|
113 |
User::After(100000);
|
|
114 |
return r;
|
|
115 |
}
|
|
116 |
|
0
|
117 |
RTvTest::RTvTest()
|
|
118 |
//
|
|
119 |
// Constructor
|
|
120 |
//
|
|
121 |
: RTest(_L("T_VERSIO"))
|
|
122 |
{
|
|
123 |
|
|
124 |
iTV[0]=&iDefTV;
|
|
125 |
TInt i=1;
|
|
126 |
TInt major=0;
|
|
127 |
FOREVER
|
|
128 |
{
|
|
129 |
TInt minor=0;
|
|
130 |
FOREVER
|
|
131 |
{
|
|
132 |
TInt build=0;
|
|
133 |
FOREVER
|
|
134 |
{
|
|
135 |
iTV[i++]=new TVersion(major,minor,build);
|
|
136 |
if (build==999)
|
|
137 |
break;
|
|
138 |
build=(build==1? 999: 1);
|
|
139 |
}
|
|
140 |
if (minor==99)
|
|
141 |
break;
|
|
142 |
minor=(minor==1? 99: 1);
|
|
143 |
}
|
|
144 |
if (major==99)
|
|
145 |
break;
|
|
146 |
major=(major==1? 99: 1);
|
|
147 |
}
|
|
148 |
}
|
|
149 |
|
|
150 |
void RTvTest::TestName()
|
|
151 |
//
|
|
152 |
// Test the version name
|
|
153 |
//
|
|
154 |
{
|
271
|
155 |
Next(_L("Testing TVersion::Name()"));
|
0
|
156 |
for (TInt i=0; i<KNumTVersions; i++)
|
|
157 |
{
|
|
158 |
TPtrC Name=(TPtrC)Names[i];
|
|
159 |
if (iTV[i]->Name().Compare(Name))
|
|
160 |
Panic(Name);
|
|
161 |
}
|
|
162 |
}
|
|
163 |
|
|
164 |
TBool RTvTest::QVS(TInt aCurrent,TInt aRequested)
|
|
165 |
//
|
|
166 |
// An independent calculation of what QueryVersionSupported should return
|
|
167 |
//
|
|
168 |
{
|
|
169 |
if (aCurrent)
|
|
170 |
aCurrent--;
|
|
171 |
if (aRequested)
|
|
172 |
aRequested--;
|
|
173 |
aCurrent/=3;
|
|
174 |
aRequested/=3;
|
|
175 |
return(aCurrent>=aRequested);
|
|
176 |
}
|
|
177 |
|
|
178 |
void RTvTest::TestQVS()
|
|
179 |
//
|
|
180 |
// Check QueryVersionSupported()
|
|
181 |
//
|
|
182 |
{
|
271
|
183 |
Next(_L("Testing User::QueryVersionSupported()"));
|
0
|
184 |
for (TInt i=0; i<KNumTVersions; i++)
|
|
185 |
{
|
|
186 |
for (TInt j=0; j<KNumTVersions; j++)
|
|
187 |
{
|
|
188 |
if (User::QueryVersionSupported(*iTV[i],*iTV[j])!=QVS(i,j))
|
|
189 |
Panic(_L("Query version supported failed"));
|
|
190 |
}
|
|
191 |
}
|
|
192 |
}
|
|
193 |
|
|
194 |
GLDEF_C TInt E32Main()
|
|
195 |
//
|
|
196 |
// Test TVersion class.
|
|
197 |
//
|
|
198 |
{
|
|
199 |
RTvTest test;
|
|
200 |
test.Title();
|
|
201 |
test.Start(_L("Testing TVersion\n"));
|
271
|
202 |
|
|
203 |
test.LoadDeviceDriver();
|
|
204 |
|
|
205 |
test.Printf(_L("Testing kernel side TVersion::Name()"));
|
|
206 |
TInt r = test.gLdd.VersionTestName();
|
|
207 |
test(r==KErrNone);
|
|
208 |
|
|
209 |
test.Printf(_L("Testing Kern::QueryVersionSupported()"));
|
|
210 |
test.gLdd.VersionTestQVS();
|
|
211 |
|
|
212 |
test.UnloadDeviceDriver();
|
|
213 |
|
0
|
214 |
test.TestName();
|
|
215 |
test.TestQVS();
|
|
216 |
test.Printf(_L("TVersion passed testing\n"));
|
|
217 |
test.End();
|
|
218 |
return(0);
|
|
219 |
}
|
|
220 |
|