apicompatanamdw/bcdrivers/os/lbs/LocAcquisition/src/testpositionmodule.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 TPositionModuleStatus,TPositionModuleStatusEventBase
       
    15 *                 TPositionModuleStatusEvent TPositionUpdateOptionsBase &
       
    16 *                TPositionUpdateOptions classes
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // System Includes
       
    22 
       
    23 
       
    24 // User Includes
       
    25 #include "testpositionmodule.h"
       
    26 #include <e32std.h>
       
    27 
       
    28 // Constant Declarations
       
    29 
       
    30     
       
    31 // ======== MEMBER FUNCTIONS ========
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // C++ Default Constructor
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 TTestPositionModule ::TTestPositionModule (CStifLogger* aLog):iLog(aLog)
       
    38     {
       
    39         
       
    40     }
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // C++ Destructor
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 TTestPositionModule ::~TTestPositionModule ()
       
    47     {
       
    48         
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // Test case for default constructor of TPositionModuleStatusBase
       
    53 // ---------------------------------------------------------------------------
       
    54 
       
    55 TInt TTestPositionModule ::DefaultPositionModuleStatus()
       
    56     {
       
    57         TPositionModuleStatus pos;
       
    58         return KErrNone;
       
    59     }
       
    60 // ---------------------------------------------------------------------------
       
    61 // Test case for setting & getting Device Status
       
    62 // ---------------------------------------------------------------------------
       
    63 TInt TTestPositionModule ::SetGetDeviceStatus(CStifItemParser& aItem)
       
    64     {
       
    65         TInt deviceStatus = 0;
       
    66         TInt error = aItem.GetNextInt(deviceStatus);
       
    67         TPositionModuleStatus modStatus;
       
    68 	    TPositionModuleStatus::TDeviceStatus dStatus = TPositionModuleStatus::EDeviceUnknown;
       
    69 	    if(!error)
       
    70 	        {
       
    71 	            switch(deviceStatus)
       
    72 	                {
       
    73 	                case 0: dStatus = TPositionModuleStatus::EDeviceUnknown;
       
    74 	                        break;
       
    75 	                case 1: dStatus = TPositionModuleStatus::EDeviceDisabled;
       
    76 	                        break;
       
    77 	                case 2: dStatus =  TPositionModuleStatus::EDeviceInactive;
       
    78 	                        break;
       
    79 	                case 3: dStatus = TPositionModuleStatus::EDeviceInitialising;
       
    80 	                        break;
       
    81 	                case 4: dStatus = TPositionModuleStatus::EDeviceStandBy;
       
    82 	                        break;
       
    83 	                case 5: dStatus = TPositionModuleStatus::EDeviceReady;
       
    84 	                        break;
       
    85 	                case 6: dStatus = TPositionModuleStatus:: EDeviceActive;
       
    86 	                        break;
       
    87 	                default:break;
       
    88 	                }
       
    89 	                modStatus.SetDeviceStatus(dStatus);
       
    90 	                TPositionModuleStatus::TDeviceStatus dStatus1 = modStatus.DeviceStatus();
       
    91 	                if(dStatus1==dStatus)
       
    92 	                    {
       
    93 	                        return KErrNone;
       
    94 	                    }
       
    95 	                else
       
    96 	                    return KErrGeneral;
       
    97 	        
       
    98 	        }
       
    99 	        
       
   100 	     else
       
   101 	                    return KErrGeneral;
       
   102         
       
   103         
       
   104     }
       
   105  
       
   106 // ---------------------------------------------------------------------------
       
   107 // Test case for setting & getting TDataQualityStatus
       
   108 // ---------------------------------------------------------------------------
       
   109 TInt TTestPositionModule ::SetGetDataQualityStatus(CStifItemParser& aItem)
       
   110     {
       
   111         TInt dataQualityStatus = 0;
       
   112         TInt error = aItem.GetNextInt(dataQualityStatus);
       
   113         TPositionModuleStatus modStatus;
       
   114 	    TPositionModuleStatus::TDataQualityStatus dQualityStatus = TPositionModuleStatus::EDataQualityUnknown;
       
   115 	    if(!error)
       
   116 	        {
       
   117 	            switch(dataQualityStatus)
       
   118 	                {
       
   119 	                case 0: dQualityStatus = TPositionModuleStatus::EDataQualityUnknown;
       
   120 	                        break;
       
   121 	                case 1: dQualityStatus = TPositionModuleStatus::EDataQualityLoss;
       
   122 	                        break;
       
   123 	                case 2: dQualityStatus =  TPositionModuleStatus::EDataQualityPartial;
       
   124 	                        break;
       
   125 	                case 3: dQualityStatus = TPositionModuleStatus::EDataQualityNormal;
       
   126 	                        break;
       
   127 	               
       
   128 	                default:break;
       
   129 	                }
       
   130 	                modStatus.SetDataQualityStatus(dQualityStatus);
       
   131 	                TPositionModuleStatus::TDataQualityStatus dQualityStatus1 = modStatus.DataQualityStatus();
       
   132 	                if(dQualityStatus1==dQualityStatus)
       
   133 	                    {
       
   134 	                        return KErrNone;
       
   135 	                    }
       
   136 	                else
       
   137 	                    return KErrGeneral;
       
   138 	        
       
   139 	        }
       
   140 	        
       
   141 	     else
       
   142 	                    return KErrGeneral;
       
   143         
       
   144         
       
   145     }
       
   146     
       
   147     
       
   148     
       
   149  // ---------------------------------------------------------------------------
       
   150 // Test case for setting & getting Requested Events
       
   151 // ---------------------------------------------------------------------------
       
   152 TInt TTestPositionModule ::SetGetRequestedEvents(CStifItemParser& aItem)
       
   153     {
       
   154         TInt reqEvents = 0;
       
   155         TInt error = aItem.GetNextInt(reqEvents);
       
   156         TPositionModuleStatusEvent modStatusEvent;
       
   157 	    TPositionModuleStatusEventBase::TModuleEvent modEvent = TPositionModuleStatusEventBase::EEventNone;
       
   158 	    if(!error)
       
   159 	        {
       
   160 	            switch(reqEvents)
       
   161 	                {
       
   162 	                case 0: modEvent = TPositionModuleStatusEventBase::EEventNone;
       
   163 	                        break;
       
   164 	                case 1: modEvent = TPositionModuleStatusEventBase::EEventDeviceStatus;
       
   165 	                        break;
       
   166 	                case 2: modEvent =  TPositionModuleStatusEventBase::EEventDataQualityStatus;
       
   167 	                        break;
       
   168 	                case 3: modEvent = TPositionModuleStatusEventBase::EEventSystemModuleEvent;
       
   169 	                        break;
       
   170 	                case 4: modEvent = TPositionModuleStatusEventBase::EEventAll;
       
   171 	                        break;
       
   172 	               
       
   173 	                default:break;
       
   174 	                }
       
   175 	                modStatusEvent.SetRequestedEvents(modEvent);
       
   176 	               TPositionModuleStatusEventBase::TModuleEvent modEvent1 = modStatusEvent.RequestedEvents();
       
   177 	                if(modEvent1==modEvent)
       
   178 	                    {
       
   179 	                        return KErrNone;
       
   180 	                    }
       
   181 	                else
       
   182 	                    return KErrGeneral;
       
   183 	        
       
   184 	        }
       
   185 	        
       
   186 	     else
       
   187 	                    return KErrGeneral;
       
   188         
       
   189         
       
   190     }
       
   191     
       
   192     
       
   193     
       
   194 // ---------------------------------------------------------------------------
       
   195 // Test case for setting & getting ModuleId 
       
   196 // ---------------------------------------------------------------------------
       
   197 
       
   198 TInt TTestPositionModule::SetGetModuleId()
       
   199     {
       
   200         TPositionModuleId KPositionNullModuleId = {KNullUidValue};
       
   201         TPositionModuleStatusEvent modStatusEvent;
       
   202         modStatusEvent.SetModuleId(KPositionNullModuleId);
       
   203         TPositionModuleId  KPositionNullModuleId1 = modStatusEvent.ModuleId();
       
   204         if(KPositionNullModuleId1==KPositionNullModuleId)
       
   205             {
       
   206                 return KErrNone;
       
   207             }
       
   208         else
       
   209             return KErrGeneral;
       
   210 
       
   211     }
       
   212 
       
   213 
       
   214  // ---------------------------------------------------------------------------
       
   215 // Test case for setting & getting Occurred Events
       
   216 // ---------------------------------------------------------------------------
       
   217 TInt TTestPositionModule ::SetGetOccurredEvents(CStifItemParser& aItem)
       
   218     {
       
   219         TInt occEvents = 0;
       
   220         TInt error = aItem.GetNextInt(occEvents);
       
   221         TPositionModuleStatusEvent modStatusEvent;
       
   222 	    TPositionModuleStatusEventBase::TModuleEvent modEvent = TPositionModuleStatusEventBase::EEventNone;
       
   223 	    if(!error)
       
   224 	        {
       
   225 	            switch(occEvents)
       
   226 	                {
       
   227 	                case 0: modEvent = TPositionModuleStatusEventBase::EEventNone;
       
   228 	                        break;
       
   229 	                case 1: modEvent = TPositionModuleStatusEventBase::EEventDeviceStatus;
       
   230 	                        break;
       
   231 	                case 2: modEvent =  TPositionModuleStatusEventBase::EEventDataQualityStatus;
       
   232 	                        break;
       
   233 	                case 3: modEvent = TPositionModuleStatusEventBase::EEventSystemModuleEvent;
       
   234 	                        break;
       
   235 	                case 4: modEvent = TPositionModuleStatusEventBase::EEventAll;
       
   236 	                        break;
       
   237 	               
       
   238 	                default:break;
       
   239 	                }
       
   240 	                modStatusEvent.SetOccurredEvents(modEvent);
       
   241 	               TPositionModuleStatusEventBase::TModuleEvent modEvent1 = modStatusEvent.OccurredEvents();
       
   242 	                if(modEvent1==modEvent)
       
   243 	                    {
       
   244 	                        return KErrNone;
       
   245 	                    }
       
   246 	                else
       
   247 	                    return KErrGeneral;
       
   248 	        
       
   249 	        }
       
   250 	        
       
   251 	     else
       
   252 	                    return KErrGeneral;
       
   253         
       
   254         
       
   255     }
       
   256     
       
   257 
       
   258  // ---------------------------------------------------------------------------
       
   259 // Test case for setting & getting System Module Events
       
   260 // ---------------------------------------------------------------------------
       
   261 TInt TTestPositionModule ::SetGetSystemModuleEvents(CStifItemParser& aItem)
       
   262     {
       
   263         TInt sysEvents = 0;
       
   264         TInt error = aItem.GetNextInt(sysEvents);
       
   265         TPositionModuleStatusEvent modStatusEvent;
       
   266 	    TPositionModuleStatusEventBase::TSystemModuleEvent modEvent = TPositionModuleStatusEventBase::ESystemUnknown;
       
   267 	    if(!error)
       
   268 	        {
       
   269 	            switch(sysEvents)
       
   270 	                {
       
   271 	                case 0: modEvent = TPositionModuleStatusEventBase::ESystemUnknown;
       
   272 	                        break;
       
   273 	                case 1: modEvent = TPositionModuleStatusEventBase::ESystemError;
       
   274 	                        break;
       
   275 	                case 2: modEvent =  TPositionModuleStatusEventBase::ESystemModuleInstalled;
       
   276 	                        break;
       
   277 	                case 3: modEvent = TPositionModuleStatusEventBase::ESystemModuleRemoved;
       
   278 	                        break;
       
   279 	                
       
   280 	                default:break;
       
   281 	                }
       
   282 	                modStatusEvent.SetSystemModuleEvent(modEvent);
       
   283 	               TPositionModuleStatusEventBase::TSystemModuleEvent modEvent1 = modStatusEvent.SystemModuleEvent();
       
   284 	                if(modEvent1==modEvent)
       
   285 	                    {
       
   286 	                        return KErrNone;
       
   287 	                    }
       
   288 	                else
       
   289 	                    return KErrGeneral;
       
   290 	        
       
   291 	        }
       
   292 	        
       
   293 	     else
       
   294 	                    return KErrGeneral;
       
   295         
       
   296         
       
   297     }
       
   298     
       
   299     
       
   300     
       
   301 // ---------------------------------------------------------------------------
       
   302 // Test case for default constructor of TPositionModuleStatusEvent 
       
   303 // ---------------------------------------------------------------------------
       
   304 TInt  TTestPositionModule :: DefaultPositionModuleStatusEvent()
       
   305     {
       
   306         TPositionModuleStatusEvent posModStatus;
       
   307         return KErrNone;
       
   308     }
       
   309     
       
   310     
       
   311     
       
   312    
       
   313  // ---------------------------------------------------------------------------
       
   314 // Test case for constructor with events as arguments
       
   315 // ---------------------------------------------------------------------------
       
   316 TInt TTestPositionModule ::PositionModuleStatusEvent1(CStifItemParser& aItem)
       
   317     {
       
   318         TInt reqEvents = 0;
       
   319         TInt error = aItem.GetNextInt(reqEvents);
       
   320         
       
   321 	    TPositionModuleStatusEventBase::TModuleEvent modEvent = TPositionModuleStatusEventBase::EEventNone;
       
   322 	    if(!error)
       
   323 	        {
       
   324 	            switch(reqEvents)
       
   325 	                {
       
   326 	                case 0: modEvent = TPositionModuleStatusEventBase::EEventNone;
       
   327 	                        break;
       
   328 	                case 1: modEvent = TPositionModuleStatusEventBase::EEventDeviceStatus;
       
   329 	                        break;
       
   330 	                case 2: modEvent =  TPositionModuleStatusEventBase::EEventDataQualityStatus;
       
   331 	                        break;
       
   332 	                case 3: modEvent = TPositionModuleStatusEventBase::EEventSystemModuleEvent;
       
   333 	                        break;
       
   334 	                case 4: modEvent = TPositionModuleStatusEventBase::EEventAll;
       
   335 	                        break;
       
   336 	               
       
   337 	                default:break;
       
   338 	                }
       
   339 	                TPositionModuleStatusEvent modStatusEvent(modEvent);
       
   340 	               TPositionModuleStatusEventBase::TModuleEvent modEvent1 = modStatusEvent.RequestedEvents();
       
   341 	                if(modEvent1==modEvent)
       
   342 	                    {
       
   343 	                        return KErrNone;
       
   344 	                    }
       
   345 	                else
       
   346 	                    return KErrGeneral;
       
   347 	        
       
   348 	        }
       
   349 	        
       
   350 	     else
       
   351 	                    return KErrGeneral;
       
   352         
       
   353         
       
   354     }
       
   355     
       
   356     
       
   357  // ---------------------------------------------------------------------------
       
   358 //Test case for setting & getting ModuleStatus
       
   359 // ---------------------------------------------------------------------------
       
   360 TInt TTestPositionModule ::SetGetModuleStatus(CStifItemParser& aItem)
       
   361     {
       
   362         TInt deviceStatus = 0;
       
   363         TInt error1 = aItem.GetNextInt(deviceStatus);
       
   364         TInt dataQualityStatus = 0;
       
   365         TInt error2 = aItem.GetNextInt(dataQualityStatus);
       
   366         TPositionModuleStatus modStatus1;
       
   367         TPositionModuleStatus modStatus2;
       
   368 
       
   369 	    TPositionModuleStatus::TDeviceStatus dStatus = TPositionModuleStatus::EDeviceUnknown;
       
   370 	    TPositionModuleStatus::TDataQualityStatus dQualityStatus = TPositionModuleStatus::EDataQualityUnknown;
       
   371 	    TPositionModuleStatusEvent posModStatusEvent;
       
   372 	                
       
   373 	    if(!error1 && !error2)
       
   374 	        {
       
   375 	            switch(deviceStatus)
       
   376 	                {
       
   377 	                case 0: dStatus = TPositionModuleStatus::EDeviceUnknown;
       
   378 	                        break;
       
   379 	                case 1: dStatus = TPositionModuleStatus::EDeviceDisabled;
       
   380 	                        break;
       
   381 	                case 2: dStatus =  TPositionModuleStatus::EDeviceInactive;
       
   382 	                        break;
       
   383 	                case 3: dStatus = TPositionModuleStatus::EDeviceInitialising;
       
   384 	                        break;
       
   385 	                case 4: dStatus = TPositionModuleStatus::EDeviceStandBy;
       
   386 	                        break;
       
   387 	                case 5: dStatus = TPositionModuleStatus::EDeviceReady;
       
   388 	                        break;
       
   389 	                case 6: dStatus = TPositionModuleStatus:: EDeviceActive;
       
   390 	                        break;
       
   391 	                default:break;
       
   392 	                }
       
   393 	                modStatus1.SetDeviceStatus(dStatus);
       
   394 	            switch(dataQualityStatus)
       
   395 	                {
       
   396 	                case 0: dQualityStatus = TPositionModuleStatus::EDataQualityUnknown;
       
   397 	                        break;
       
   398 	                case 1: dQualityStatus = TPositionModuleStatus::EDataQualityLoss;
       
   399 	                        break;
       
   400 	                case 2: dQualityStatus =  TPositionModuleStatus::EDataQualityPartial;
       
   401 	                        break;
       
   402 	                case 3: dQualityStatus = TPositionModuleStatus::EDataQualityNormal;
       
   403 	                        break;
       
   404 	               
       
   405 	                default:break;
       
   406 	                }
       
   407 	                modStatus1.SetDataQualityStatus(dQualityStatus);
       
   408 	                posModStatusEvent.SetModuleStatus(modStatus1);
       
   409 	                posModStatusEvent.GetModuleStatus(modStatus2);
       
   410 	                if(modStatus1.DeviceStatus()==modStatus2.DeviceStatus() &&
       
   411 	                   modStatus1.DataQualityStatus()==modStatus2.DataQualityStatus())
       
   412 	                    {
       
   413 	                        return KErrNone;
       
   414 	                    }
       
   415 	                else
       
   416 	                    return KErrGeneral;
       
   417 	        }
       
   418 	        else
       
   419 	            return KErrGeneral;
       
   420 	                
       
   421 	             
       
   422     }
       
   423     
       
   424     
       
   425  // ---------------------------------------------------------------------------
       
   426 //Test case for setting & getting UpdateInterval
       
   427 // ---------------------------------------------------------------------------
       
   428 
       
   429 TInt TTestPositionModule ::SetGetUpdateInterval(TTimeIntervalMicroSeconds aInterval)
       
   430     {
       
   431         TPositionUpdateOptions posUpdate;
       
   432         posUpdate.SetUpdateInterval(aInterval);
       
   433         TTimeIntervalMicroSeconds updateInterval = posUpdate.UpdateInterval();
       
   434         if(aInterval==updateInterval)
       
   435             {
       
   436                 return KErrNone;
       
   437             }
       
   438          else
       
   439             return KErrGeneral;
       
   440         
       
   441     }
       
   442     
       
   443     
       
   444  // ---------------------------------------------------------------------------
       
   445 //Test case for setting & getting UpdateTimeOut
       
   446 // ---------------------------------------------------------------------------
       
   447 
       
   448 TInt TTestPositionModule ::SetGetUpdateTimeOut(TTimeIntervalMicroSeconds aTimeOut)
       
   449     {
       
   450         TPositionUpdateOptions posUpdate;
       
   451         posUpdate.SetUpdateTimeOut(aTimeOut);
       
   452         TTimeIntervalMicroSeconds updateTimeOut = posUpdate.UpdateTimeOut();
       
   453         if(aTimeOut==updateTimeOut)
       
   454             {
       
   455                 return KErrNone;
       
   456             }
       
   457          else
       
   458             return KErrGeneral;
       
   459         
       
   460     }
       
   461     
       
   462     
       
   463  // ---------------------------------------------------------------------------
       
   464 //Test case for setting & getting MaxUpdateAge
       
   465 // ---------------------------------------------------------------------------
       
   466 
       
   467 TInt TTestPositionModule ::SetGetMaxUpdateAge(TTimeIntervalMicroSeconds aMaxAge)
       
   468     {
       
   469         TPositionUpdateOptions posUpdate;
       
   470         posUpdate.SetMaxUpdateAge(aMaxAge);
       
   471         TTimeIntervalMicroSeconds maxUpdateAge = posUpdate.MaxUpdateAge();
       
   472         if(aMaxAge==maxUpdateAge)
       
   473             {
       
   474                 return KErrNone;
       
   475             }
       
   476          else
       
   477             return KErrGeneral;
       
   478         
       
   479     }
       
   480     
       
   481 // ---------------------------------------------------------------------------
       
   482 //Test case for default constructor of TpositionUpdateOptions
       
   483 // ---------------------------------------------------------------------------
       
   484 TInt TTestPositionModule ::DefaultPosUpdateOptions()
       
   485     {
       
   486         TPositionUpdateOptions posUpdate;
       
   487         return KErrNone;
       
   488     }
       
   489     
       
   490     
       
   491 // ---------------------------------------------------------------------------
       
   492 //Test case for constructor of TPositionUpdateOptions with arguments
       
   493 // ---------------------------------------------------------------------------
       
   494 TInt TTestPositionModule ::PosUpdateOptions1()
       
   495     {
       
   496         TTimeIntervalMicroSeconds interval(1000);
       
   497         TPositionUpdateOptions posUpdate(interval);
       
   498         if(posUpdate.UpdateInterval()==interval &&
       
   499            posUpdate.UpdateTimeOut()==0 &&
       
   500            posUpdate.MaxUpdateAge()==0 &&
       
   501            posUpdate.AcceptPartialUpdates()==EFalse)
       
   502             {
       
   503                 return KErrNone;
       
   504             }
       
   505          else
       
   506             return KErrGeneral;
       
   507         
       
   508     }
       
   509         
       
   510 // ---------------------------------------------------------------------------
       
   511 //Test case for checking if partial updates are allowed
       
   512 // ---------------------------------------------------------------------------
       
   513 TInt TTestPositionModule ::SetGetPartialUpdates(CStifItemParser& aItem)
       
   514     {
       
   515         TInt acceptPartialUpdate = 0;
       
   516         TInt error = aItem.GetNextInt(acceptPartialUpdate);
       
   517         TPositionUpdateOptions posUpdate;
       
   518         if(!error)
       
   519             {
       
   520                 posUpdate.SetAcceptPartialUpdates(acceptPartialUpdate);
       
   521                 TBool check = posUpdate.AcceptPartialUpdates();
       
   522                 if(check==acceptPartialUpdate)
       
   523                     {
       
   524                         return KErrNone;
       
   525                     }
       
   526                 else
       
   527                     return KErrGeneral;
       
   528             }
       
   529          else
       
   530             return KErrGeneral;
       
   531     }