apicompatanamdw/bcdrivers/os/lbs/LocAcquisition/src/testpositionquality.cpp
changeset 2 0cb2248d0edc
equal deleted inserted replaced
1:61e9400fe245 2:0cb2248d0edc
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Helper class for TPositionClassTypeBase, TPositionQualityBase 
       
    15 *                & TPositionQuality classes
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // System Includes
       
    21 #include <e32std.h>
       
    22 #include <StifTestModule.h>
       
    23 #include <StifLogger.h>
       
    24 #include <TestScripterInternal.h>
       
    25 #include <StifParser.h>
       
    26 #include <Stiftestinterface.h>
       
    27 #include "testlbslocacquisition.h"
       
    28 
       
    29 #include <StifLogger.h>
       
    30 #include <TestScripterInternal.h>
       
    31 #include <StifTestModule.h>
       
    32 #include <e32des16.h>
       
    33 
       
    34 
       
    35 
       
    36 
       
    37 // User Includes
       
    38 #include "testpositionquality.h"
       
    39 
       
    40 // Constant Declarations
       
    41 
       
    42     
       
    43 // ======== MEMBER FUNCTIONS ========
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // C++ Default Constructor
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 TTestPositionQuality ::TTestPositionQuality (CStifLogger* aLog):iLog(aLog)
       
    50     {
       
    51         
       
    52     }
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // C++ Destructor
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 TTestPositionQuality ::~TTestPositionQuality ()
       
    59     {
       
    60         
       
    61     }
       
    62     
       
    63     
       
    64 // ---------------------------------------------------------------------------
       
    65 // Test case for PositionClassType
       
    66 // ---------------------------------------------------------------------------
       
    67 TInt TTestPositionQuality :: GetPositionClassType()
       
    68     {
       
    69          TPositionQuality pos;
       
    70          TUint32 classType = pos.PositionClassType();
       
    71          return KErrNone;
       
    72     }
       
    73     
       
    74 // ---------------------------------------------------------------------------
       
    75 // Test case for PositionClassSize
       
    76 // ---------------------------------------------------------------------------
       
    77 TInt TTestPositionQuality :: GetPositionClassSize()
       
    78     {
       
    79          TPositionQuality pos;
       
    80          TUint classSize = pos.PositionClassSize();
       
    81          return KErrNone;
       
    82     }
       
    83     
       
    84 // ---------------------------------------------------------------------------
       
    85 // Test case for Compare
       
    86 // ---------------------------------------------------------------------------
       
    87 TInt TTestPositionQuality :: DoCompare()
       
    88 
       
    89     {
       
    90     
       
    91              TPositionQuality posQuality;
       
    92              TPositionQualityItem::TResult aComparison;
       
    93              TInt aHighIndex;
       
    94              aHighIndex = posQuality.HighWaterMark();
       
    95 	         TInt compResult = posQuality.Compare(posQuality,aHighIndex+1,aComparison);
       
    96 	         if(!compResult)
       
    97 	            {
       
    98 	                return KErrNone;
       
    99 	            }
       
   100 	         else
       
   101 	            return compResult;
       
   102             
       
   103             
       
   104     }
       
   105     
       
   106     
       
   107 // ---------------------------------------------------------------------------
       
   108 // Test case for IsDefined
       
   109 // ---------------------------------------------------------------------------
       
   110 TInt TTestPositionQuality :: GetIsDefined()   
       
   111     {
       
   112         TPositionQuality posQuality;
       
   113         TInt elementId = 2;
       
   114         TBool defined = posQuality.IsDefined(elementId);
       
   115         return KErrNone;
       
   116     }
       
   117     
       
   118     
       
   119     
       
   120     
       
   121 // ---------------------------------------------------------------------------
       
   122 // Test case for getting the HighWaterMark
       
   123 // ---------------------------------------------------------------------------
       
   124 TInt TTestPositionQuality ::GetHighWaterMark()
       
   125     {
       
   126         TPositionQuality pos;
       
   127         TInt highWaterMark = pos.HighWaterMark();
       
   128         if(highWaterMark)
       
   129             {
       
   130                 return KErrNone;
       
   131             }
       
   132         else
       
   133             return KErrGeneral;
       
   134         
       
   135     }
       
   136 // ---------------------------------------------------------------------------
       
   137 // Test case for default constructor of TPositionQuality class
       
   138 // ---------------------------------------------------------------------------
       
   139 TInt TTestPositionQuality ::DefaultPositionQuality()
       
   140     {
       
   141         TPositionQuality pos;
       
   142         return KErrNone;
       
   143     }
       
   144     
       
   145 // ---------------------------------------------------------------------------
       
   146 // Test case for setting & gettting the time to first fix
       
   147 // ---------------------------------------------------------------------------
       
   148 TInt TTestPositionQuality ::SetGetTimeToFirstFix(TTimeIntervalMicroSeconds time)
       
   149     {
       
   150        
       
   151         TPositionQuality posquality;
       
   152         posquality.SetTimeToFirstFix(time);
       
   153         TTimeIntervalMicroSeconds time3 = posquality.TimeToFirstFix();
       
   154            if(time3==time) 
       
   155             {
       
   156                                                
       
   157                  return KErrNone;
       
   158                                      
       
   159             }
       
   160                         
       
   161      else
       
   162             return KErrGeneral;
       
   163     }                  
       
   164             
       
   165                  
       
   166 // ---------------------------------------------------------------------------
       
   167 // Test case for setting & gettting the time to next fix
       
   168 // ---------------------------------------------------------------------------
       
   169 TInt TTestPositionQuality ::SetGetTimeToNextFix(TTimeIntervalMicroSeconds time)
       
   170     {
       
   171        
       
   172         TPositionQuality posquality;
       
   173         posquality.SetTimeToNextFix(time);
       
   174         TTimeIntervalMicroSeconds time3 = posquality.TimeToNextFix();
       
   175            if(time3==time) 
       
   176             {
       
   177                                                
       
   178                  return KErrNone;
       
   179                                      
       
   180             }
       
   181                         
       
   182      else
       
   183             return KErrGeneral;
       
   184     }                
       
   185             
       
   186          
       
   187                  
       
   188 // ---------------------------------------------------------------------------
       
   189 // Test case for setting & gettting the horizontal accuracy
       
   190 // ---------------------------------------------------------------------------
       
   191 TInt TTestPositionQuality ::SetGetHorizontalAccuracy(TReal32 haccuracy)
       
   192     {
       
   193        
       
   194         TPositionQuality posquality;
       
   195         posquality.SetHorizontalAccuracy(haccuracy);
       
   196         TReal32 haccuracy1 = posquality.HorizontalAccuracy();
       
   197            if(haccuracy1==haccuracy) 
       
   198             {
       
   199                                                
       
   200                  return KErrNone;
       
   201                                      
       
   202             }
       
   203                         
       
   204      else
       
   205             return KErrGeneral;
       
   206     }                
       
   207             
       
   208             
       
   209                   
       
   210 // ---------------------------------------------------------------------------
       
   211 // Test case for setting & gettting the vertical accuracy
       
   212 // ---------------------------------------------------------------------------
       
   213 TInt TTestPositionQuality ::SetGetVerticalAccuracy(TReal32 vaccuracy)
       
   214     {
       
   215        
       
   216         TPositionQuality posquality;
       
   217         posquality.SetVerticalAccuracy(vaccuracy);
       
   218         TReal32 vaccuracy1 = posquality.VerticalAccuracy();
       
   219            if(vaccuracy1==vaccuracy) 
       
   220             {
       
   221                                                
       
   222                  return KErrNone;
       
   223                                      
       
   224             }
       
   225                         
       
   226      else
       
   227             return KErrGeneral;
       
   228     }        
       
   229     
       
   230     
       
   231 // ---------------------------------------------------------------------------
       
   232 // Test case for setting & gettting the cost indicator
       
   233 // ---------------------------------------------------------------------------
       
   234 TInt TTestPositionQuality :: SetGetCostIndicator(CStifItemParser& aItem)
       
   235     {
       
   236         TInt cost = 0;
       
   237         TPositionQuality pos;
       
   238         
       
   239         TInt err = aItem.GetNextInt(cost);
       
   240         if(!err)
       
   241             {
       
   242                 TPositionQuality::TCostIndicator costInd = TPositionQuality::ECostUnknown;
       
   243                 switch(cost)
       
   244                     {
       
   245                         case 0: costInd = TPositionQuality::ECostUnknown;
       
   246                                 break;
       
   247                         case 1: costInd = TPositionQuality::ECostZero;
       
   248                                 break;
       
   249                         case 2: costInd = TPositionQuality::ECostPossible;
       
   250                                 break;
       
   251                         case 3: costInd = TPositionQuality::ECostCharge;
       
   252                                 break;
       
   253                         default: break;
       
   254                                              
       
   255                     }
       
   256                   pos.SetCostIndicator(costInd);
       
   257                   
       
   258                   TPositionQuality::TCostIndicator costIndicator = pos.CostIndicator();
       
   259                   if(costIndicator==costInd)
       
   260                     {
       
   261                         return KErrNone;
       
   262                     }
       
   263                    else
       
   264                     return KErrGeneral;
       
   265                 
       
   266             }
       
   267          else
       
   268             return KErrGeneral;
       
   269     }
       
   270     
       
   271 // ---------------------------------------------------------------------------
       
   272 // Test case for setting & gettting the power consumption
       
   273 // ---------------------------------------------------------------------------
       
   274   TInt TTestPositionQuality :: SetGetPowerConsumption(CStifItemParser& aItem)
       
   275     {
       
   276         TInt powercons = 0;
       
   277         TPositionQuality pos;
       
   278         
       
   279         TInt err = aItem.GetNextInt(powercons);
       
   280         if(!err)
       
   281             {
       
   282                  TPositionQuality::TPowerConsumption powerconsum1 = TPositionQuality::EPowerUnknown;
       
   283                  switch(powercons)
       
   284                     {
       
   285                     case 0: powerconsum1 = TPositionQuality::EPowerUnknown;
       
   286                             break;
       
   287                     case 1: powerconsum1 = TPositionQuality::EPowerZero;
       
   288                             break;
       
   289                     case 2: powerconsum1 = TPositionQuality::EPowerLow;
       
   290                             break;
       
   291                     case 3: powerconsum1 = TPositionQuality::EPowerMedium;
       
   292                             break;
       
   293                     case 4: powerconsum1 = TPositionQuality::EPowerHigh;
       
   294                             break;
       
   295                     default: break;
       
   296                     
       
   297                     }
       
   298                  pos.SetPowerConsumption(powerconsum1);
       
   299                  
       
   300                  TPositionQuality::TPowerConsumption powerconsum2 = pos.PowerConsumption();
       
   301                  if(powerconsum2==powerconsum1)
       
   302                     {
       
   303                         return KErrNone;
       
   304                     }
       
   305                  else
       
   306                     return KErrGeneral;
       
   307               
       
   308                  
       
   309             }
       
   310             else
       
   311                 return KErrGeneral;
       
   312         
       
   313         
       
   314     }
       
   315     
       
   316     
       
   317     
       
   318 // ---------------------------------------------------------------------------
       
   319 // Test case for constructor of TPositionModuleInfo
       
   320 // ---------------------------------------------------------------------------
       
   321 
       
   322 TInt TTestPositionQuality ::PositionModuleInfoConst()
       
   323     {
       
   324         TPositionModuleInfo pos;
       
   325         return KErrNone;
       
   326     }
       
   327     
       
   328 // ---------------------------------------------------------------------------
       
   329 // Test case for setting & getting ModuleId
       
   330 // ---------------------------------------------------------------------------
       
   331 
       
   332 TInt TTestPositionQuality ::SetGetModuleId()
       
   333     {
       
   334         TPositionModuleId KPositionNullModuleId = {KNullUidValue};
       
   335         TPositionModuleInfo posmodinfo;
       
   336         posmodinfo.SetModuleId(KPositionNullModuleId);
       
   337         TPositionModuleId  KPositionNullModuleId1 = posmodinfo.ModuleId();
       
   338         if(KPositionNullModuleId1==KPositionNullModuleId)
       
   339             {
       
   340                 return KErrNone;
       
   341             }
       
   342         else
       
   343             return KErrGeneral;
       
   344 
       
   345     }
       
   346  
       
   347     
       
   348 // ---------------------------------------------------------------------------
       
   349 // Test case for setting & getting ModuleName 
       
   350 // ---------------------------------------------------------------------------
       
   351 
       
   352 TInt TTestPositionQuality::SetGetModuleName(CStifItemParser& aItem)
       
   353     {
       
   354         TPtrC ptr1;
       
   355         TBuf<200> buf;
       
   356         TInt error = aItem.GetNextString(ptr1);
       
   357         TPositionModuleInfo posmodinfo;
       
   358         posmodinfo.SetModuleName(ptr1);
       
   359         posmodinfo.GetModuleName(buf);
       
   360         if(buf==ptr1)
       
   361             {
       
   362                 return KErrNone;
       
   363             }
       
   364         else
       
   365             return KErrGeneral;
       
   366         
       
   367         
       
   368     }  
       
   369     
       
   370     
       
   371  // ---------------------------------------------------------------------------
       
   372 // Test case for checking if module is available
       
   373 // ---------------------------------------------------------------------------
       
   374  TInt TTestPositionQuality::SetGetIsAvailable(CStifItemParser& aItem)
       
   375     {
       
   376         TInt available = 0;
       
   377         TInt error = aItem.GetNextInt(available);
       
   378         TPositionModuleInfo posmodinfo;
       
   379         if(!error)
       
   380             {
       
   381                 posmodinfo.SetIsAvailable(available);
       
   382                 TBool check = posmodinfo.IsAvailable();
       
   383                 if(check==available)
       
   384                     {
       
   385                         return KErrNone;
       
   386                     }
       
   387                 else
       
   388                     return KErrGeneral;    
       
   389             }
       
   390         else
       
   391             return KErrGeneral;
       
   392         
       
   393     }
       
   394     
       
   395 // ---------------------------------------------------------------------------
       
   396 // Test case for setting & getting TechnologyType
       
   397 // ---------------------------------------------------------------------------
       
   398 TInt TTestPositionQuality :: SetGetTechnologyType(CStifItemParser& aItem)
       
   399     {
       
   400         TInt techType1 = 0;
       
   401         TPositionModuleInfo pos;
       
   402         TInt error = aItem.GetNextInt(techType1);
       
   403         
       
   404         if(!error)
       
   405             {
       
   406                 TPositionModuleInfo::TTechnologyType techType2 = TPositionModuleInfo::ETechnologyUnknown;
       
   407                 switch(techType1)
       
   408                     {
       
   409                         case 0: techType2 = TPositionModuleInfo::ETechnologyUnknown;
       
   410                                 break;
       
   411                         case 1: techType2 = TPositionModuleInfo::ETechnologyTerminal;	
       
   412                                 break;
       
   413                         case 2: techType2 = TPositionModuleInfo::ETechnologyNetwork;
       
   414                                 break;
       
   415                         case 3: techType2 = TPositionModuleInfo::ETechnologyAssisted;
       
   416                                 break;
       
   417                         default:break;
       
   418                         
       
   419                     }
       
   420                  pos.SetTechnologyType(techType2);
       
   421                  TPositionModuleInfo::TTechnologyType techType3 = pos.TechnologyType();
       
   422                  if(techType3==techType2)
       
   423                     {
       
   424                         return KErrNone; 
       
   425                     }
       
   426                  else
       
   427                  return KErrGeneral;  
       
   428             }
       
   429          else
       
   430             return KErrGeneral;
       
   431         
       
   432     }
       
   433 // ---------------------------------------------------------------------------
       
   434 // Test case for setting & getting DeviceLocation
       
   435 // ---------------------------------------------------------------------------
       
   436 TInt TTestPositionQuality :: SetGetDeviceLocation(CStifItemParser& aItem)
       
   437     {
       
   438         TInt devLoc1 = 0;
       
   439         TPositionModuleInfo pos;
       
   440         TInt error = aItem.GetNextInt(devLoc1);
       
   441         
       
   442         if(!error)
       
   443             {
       
   444                 TPositionModuleInfo::TDeviceLocation devLoc2 = TPositionModuleInfo::EDeviceUnknown;
       
   445                 switch(devLoc1)
       
   446                     {
       
   447                         case 0: devLoc2 = TPositionModuleInfo::EDeviceUnknown;
       
   448                                 break;
       
   449                         case 1: devLoc2 = TPositionModuleInfo::EDeviceInternal;	
       
   450                                 break;
       
   451                         case 2: devLoc2 = TPositionModuleInfo::EDeviceExternal;
       
   452                                 break;
       
   453                         
       
   454                         default:break;
       
   455                         
       
   456                     }
       
   457                  pos.SetDeviceLocation(devLoc2);
       
   458                  TPositionModuleInfo::TDeviceLocation devLoc3 = pos.DeviceLocation();
       
   459                  if(devLoc3==devLoc2)
       
   460                     {
       
   461                         return KErrNone;
       
   462                       
       
   463                     }
       
   464                  else
       
   465                     return KErrGeneral;
       
   466                     
       
   467                  
       
   468             }
       
   469          else
       
   470             return KErrGeneral;
       
   471         
       
   472     }
       
   473     
       
   474  // ---------------------------------------------------------------------------
       
   475 // Test case for setting & getting Capabilities
       
   476 // ---------------------------------------------------------------------------
       
   477 TInt TTestPositionQuality :: SetGetCapabilities(CStifItemParser& aItem)
       
   478     {
       
   479         TInt capability1 = 0;
       
   480         TPositionModuleInfo pos;
       
   481         TInt error = aItem.GetNextInt(capability1);
       
   482         
       
   483         if(!error)
       
   484             {
       
   485                 TPositionModuleInfo::TCapabilities capability2 = TPositionModuleInfo::ECapabilityNone;
       
   486                 switch(capability1)
       
   487                     {
       
   488                         case 0: capability2 = TPositionModuleInfo::ECapabilityNone;
       
   489                                 break;
       
   490                         case 1: capability2 = TPositionModuleInfo::ECapabilityHorizontal;	
       
   491                                 break;
       
   492                         case 2: capability2 = TPositionModuleInfo::ECapabilityVertical;
       
   493                                 break;
       
   494                         case 3: capability2 = TPositionModuleInfo::ECapabilitySpeed;
       
   495                                 break;
       
   496                         case 4: capability2 = TPositionModuleInfo::ECapabilityDirection;
       
   497                                 break;
       
   498                         case 5: capability2 = TPositionModuleInfo::ECapabilitySatellite;
       
   499                                 break;
       
   500                         case 6: capability2 = TPositionModuleInfo::ECapabilityCompass ;
       
   501                                 break;
       
   502                         case 7: capability2 = TPositionModuleInfo::ECapabilityNmea ;
       
   503                                 break;
       
   504                         case 8: capability2 = TPositionModuleInfo::ECapabilityAddress ;
       
   505                                 break;
       
   506                         case 9: capability2 = TPositionModuleInfo::ECapabilityBuilding;
       
   507                                 break;
       
   508                         case 10:capability2 = TPositionModuleInfo::ECapabilityMedia ;
       
   509                                 break;
       
   510                         default:break;
       
   511                         
       
   512                     }
       
   513                  pos.SetCapabilities(capability2);
       
   514                  TPositionModuleInfo::TCapabilities capability3 = pos.Capabilities();
       
   515                  if(capability3==capability2)
       
   516                     {
       
   517                         return KErrNone;
       
   518                       
       
   519                     }
       
   520                  else
       
   521                     return KErrGeneral;
       
   522                     
       
   523                  
       
   524             }
       
   525          else
       
   526             return KErrGeneral;
       
   527         
       
   528     }
       
   529     
       
   530     
       
   531  // ---------------------------------------------------------------------------
       
   532 // Test case for setting & getting Classes Supported
       
   533 // ---------------------------------------------------------------------------
       
   534  TInt TTestPositionQuality ::SetGetClassesSupported(TPositionClassFamily posClassType,TUint32 posInfoClasstype)
       
   535     {
       
   536         TPositionModuleInfo posModuleInfo;
       
   537         //TPositionClassFamily posClassType1;
       
   538         posModuleInfo.SetClassesSupported(posClassType,posInfoClasstype);
       
   539         TUint32 getClassType = posModuleInfo.ClassesSupported(posClassType);
       
   540         if(getClassType == 0)
       
   541 		{
       
   542 		_LIT(KErrMsg3,"TPositionModuleInfo::ClassesSupported() returned with :");
       
   543 		TBuf8<80> errMsg3;
       
   544 		errMsg3.Copy(KErrMsg3);
       
   545 		errMsg3.AppendNum(getClassType);
       
   546 		iLog->Log(errMsg3);	
       
   547 		return getClassType;		
       
   548 		}
       
   549 	return KErrNone;
       
   550     }
       
   551     
       
   552  // ---------------------------------------------------------------------------
       
   553 // Test case for setting & getting Version
       
   554 // ---------------------------------------------------------------------------
       
   555     
       
   556     
       
   557     TInt TTestPositionQuality :: SetGetVersion(CStifItemParser& aItem)
       
   558         {
       
   559             TInt major = 0;
       
   560             TInt minor = 0;
       
   561             TInt build = 0;
       
   562             TInt err1 = aItem.GetNextInt(major);
       
   563             TInt err2 = aItem.GetNextInt(minor);
       
   564             TInt err3 = aItem.GetNextInt(build);
       
   565             TPositionModuleInfo posModuleInfo;
       
   566             
       
   567             if(!err1 && !err2 && !err3)
       
   568                 {
       
   569                     TVersion version(major,minor,build);
       
   570                     posModuleInfo.SetVersion(version);
       
   571                     TVersion ver = posModuleInfo.Version();
       
   572                     if((ver.iMajor==major)&&(ver.iMinor==minor)&&(ver.iBuild==build))
       
   573                         {
       
   574                             return KErrNone;
       
   575                         }
       
   576                     else
       
   577                 		return KErrGeneral;
       
   578                 }
       
   579              else
       
   580                 return KErrGeneral;
       
   581         }