kerneltest/e32test/buffer/t_versio.cpp
changeset 271 dc268b18d709
parent 0 a41df078684a
equal deleted inserted replaced
269:d57b86b1867a 271:dc268b18d709
     1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1995-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    28 // Base Port information:
    28 // Base Port information:
    29 // 
    29 // 
    30 //
    30 //
    31 
    31 
    32 #include <e32test.h>
    32 #include <e32test.h>
    33 
    33 #include "d_version.h"
    34 const TInt KNumTVersions=1+3*3*3;
       
    35 
    34 
    36 class RTvTest : public RTest
    35 class RTvTest : public RTest
    37     {
    36     {
    38 public:
    37 public:
    39     RTvTest();
    38     RTvTest();
    40     void TestName();
    39     void TestName();
    41     void TestQVS();
    40     void TestQVS();
    42     void Start(const TDesC &aHeading) {Printf(aHeading);Push();}
    41     void Start(const TDesC &aHeading) {Printf(aHeading);Push();}
       
    42     TInt LoadDeviceDriver();
       
    43     TInt UnloadDeviceDriver();
    43 private:
    44 private:
    44     TBool QVS(TInt i,TInt j);
    45     TBool QVS(TInt i,TInt j);
       
    46 public:
       
    47     RVersionTest gLdd;
    45 private:
    48 private:
    46     TVersion* iTV[KNumTVersions];
    49     TVersion* iTV[KNumTVersions];
    47     TVersion iDefTV;     // tests default constructor
    50     TVersion iDefTV;     // tests default constructor
    48     };
    51     };
    49 
    52 
    77     _S("99.99(0)"),
    80     _S("99.99(0)"),
    78     _S("99.99(1)"),
    81     _S("99.99(1)"),
    79     _S("99.99(999)")
    82     _S("99.99(999)")
    80     };
    83     };
    81 
    84 
       
    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 
    82 RTvTest::RTvTest()
   117 RTvTest::RTvTest()
    83 //
   118 //
    84 // Constructor
   119 // Constructor
    85 //
   120 //
    86     : RTest(_L("T_VERSIO"))
   121     : RTest(_L("T_VERSIO"))
   115 void RTvTest::TestName()
   150 void RTvTest::TestName()
   116 //
   151 //
   117 // Test the version name
   152 // Test the version name
   118 //
   153 //
   119     {
   154     {
   120  
   155  	Next(_L("Testing TVersion::Name()"));
   121 	Next(_L("Testing TVersion::Name()"));
       
   122     for (TInt i=0; i<KNumTVersions; i++)
   156     for (TInt i=0; i<KNumTVersions; i++)
   123         {
   157         {
   124         TPtrC Name=(TPtrC)Names[i];
   158         TPtrC Name=(TPtrC)Names[i];
   125         if (iTV[i]->Name().Compare(Name))
   159         if (iTV[i]->Name().Compare(Name))
   126             Panic(Name);
   160             Panic(Name);
   130 TBool RTvTest::QVS(TInt aCurrent,TInt aRequested)
   164 TBool RTvTest::QVS(TInt aCurrent,TInt aRequested)
   131 //
   165 //
   132 // An independent calculation of what QueryVersionSupported should return
   166 // An independent calculation of what QueryVersionSupported should return
   133 //
   167 //
   134     {
   168     {
   135 
       
   136     if (aCurrent)
   169     if (aCurrent)
   137         aCurrent--;
   170         aCurrent--;
   138     if (aRequested)
   171     if (aRequested)
   139         aRequested--;
   172         aRequested--;
   140     aCurrent/=3;
   173     aCurrent/=3;
   145 void RTvTest::TestQVS()
   178 void RTvTest::TestQVS()
   146 //
   179 //
   147 // Check QueryVersionSupported()
   180 // Check QueryVersionSupported()
   148 //
   181 //
   149     {
   182     {
   150  
   183     Next(_L("Testing User::QueryVersionSupported()"));
   151    Next(_L("Testing User::QueryVersionSupported()"));
       
   152     for (TInt i=0; i<KNumTVersions; i++)
   184     for (TInt i=0; i<KNumTVersions; i++)
   153         {
   185         {
   154         for (TInt j=0; j<KNumTVersions; j++)
   186         for (TInt j=0; j<KNumTVersions; j++)
   155             {
   187             {
   156             if (User::QueryVersionSupported(*iTV[i],*iTV[j])!=QVS(i,j))
   188             if (User::QueryVersionSupported(*iTV[i],*iTV[j])!=QVS(i,j))
   162 GLDEF_C TInt E32Main()
   194 GLDEF_C TInt E32Main()
   163 //
   195 //
   164 // Test TVersion class.
   196 // Test TVersion class.
   165 //
   197 //
   166     {
   198     {
   167 
       
   168     RTvTest test;
   199     RTvTest test;
   169 	test.Title();
   200 	test.Title();
   170 	test.Start(_L("Testing TVersion\n"));
   201 	test.Start(_L("Testing TVersion\n"));
       
   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 	
   171     test.TestName();
   214     test.TestName();
   172     test.TestQVS();
   215     test.TestQVS();
   173     test.Printf(_L("TVersion passed testing\n"));
   216     test.Printf(_L("TVersion passed testing\n"));
   174 	test.End();
   217 	test.End();
   175 	return(0);
   218 	return(0);
   176     }
   219     }
   177 
   220 
   178