kerneltest/e32test/hcr/t_hcr.cpp
changeset 90 947f0dc9f7a8
parent 39 5d2844f35677
child 257 3e88ff8f41d5
child 291 206a6eaaeb71
equal deleted inserted replaced
52:2d65c2f76d7b 90:947f0dc9f7a8
   145 				}
   145 				}
   146 			case ETypeBinData:
   146 			case ETypeBinData:
   147 				{
   147 				{
   148 				TBuf8<KMaxSettingLength> dval;
   148 				TBuf8<KMaxSettingLength> dval;
   149 				TUint8* pval;
   149 				TUint8* pval;
   150 				pval = (TUint8*) User::Alloc(setting->iName.iLen);
   150 				TUint16 maxLen = setting->iName.iLen == 0 ? (TUint16)4: setting->iName.iLen; 
       
   151 				
       
   152 				pval = (TUint8*) User::Alloc(maxLen);
   151 				test_NotNull(pval);
   153 				test_NotNull(pval);
   152 				//
   154 				//
   153 				r = HcrSimTest.GetData(id, dval);
   155 				r = HcrSimTest.GetData(id, dval);
   154 				test_KErrNone(r);
   156 				test_KErrNone(r);
   155 				//
   157 				//
   156 				TUint16 actuallength;
   158 				TUint16 actuallength;
   157 				r = HcrSimTest.GetData(id, setting->iName.iLen, pval, actuallength);
   159 				r = HcrSimTest.GetData(id, maxLen, pval, actuallength);
   158 				test_KErrNone(r);
   160 				test_KErrNone(r);
   159 				//
   161 				//
   160 				test_Equal(0, Mem::Compare(
   162 				if(setting->iName.iLen > 0)
   161 						setting->iValue.iPtr.iData, setting->iName.iLen,
   163 				    {
   162 						pval, actuallength));
   164                     test_Equal(0, Mem::Compare(
   163 				test_Equal(0, Mem::Compare(
   165 				        setting->iValue.iPtr.iData, setting->iName.iLen,
   164 						setting->iValue.iPtr.iData, setting->iName.iLen,
   166 				        pval, actuallength));
   165 						dval.Ptr(), dval.Length()));
   167                     test_Equal(0, Mem::Compare(
       
   168 				        setting->iValue.iPtr.iData, setting->iName.iLen,
       
   169 				        dval.Ptr(), dval.Length()));
       
   170 				    }
   166 				User::Free(pval);
   171 				User::Free(pval);
   167 				break;
   172 				break;
   168 				}
   173 				}
   169 			case ETypeText8:
   174 			case ETypeText8:
   170 				{
   175 				{
   171 				TBuf8<KMaxSettingLength> dval;
   176 				TBuf8<KMaxSettingLength> dval;
   172 				TText8* pval;
   177 				TText8* pval;
   173 				pval = (TText8*) User::Alloc(setting->iName.iLen);
   178 				TUint16 maxLen = setting->iName.iLen == 0 ? (TUint16)4: setting->iName.iLen;
       
   179 				
       
   180 				pval = (TText8*) User::Alloc(maxLen);
   174 				test_NotNull(pval);
   181 				test_NotNull(pval);
   175 				//
   182 				//
   176 				r = HcrSimTest.GetString(id, dval);
   183 				r = HcrSimTest.GetString(id, dval);
   177 				test_KErrNone(r);
   184 				test_KErrNone(r);
   178 				//
   185 				//
   179 				TUint16 actuallength;
   186 				TUint16 actuallength;
   180 				r = HcrSimTest.GetString(id, setting->iName.iLen, pval, actuallength);
   187 				r = HcrSimTest.GetString(id, maxLen, pval, actuallength);
   181 				test_KErrNone(r);
   188 				test_KErrNone(r);
   182 				//
   189 
   183 				test_Equal(0, Mem::Compare(
   190 				if(setting->iName.iLen > 0)
   184 						setting->iValue.iPtr.iString8, setting->iName.iLen,
   191 				    {
   185 						pval, actuallength));
   192                     test_Equal(0, Mem::Compare(
   186 				test_Equal(0, Mem::Compare(
   193 				        setting->iValue.iPtr.iString8, setting->iName.iLen,
   187 						setting->iValue.iPtr.iString8, setting->iName.iLen,
   194 				        pval, actuallength));
   188 						dval.Ptr(), dval.Length()));
   195                     test_Equal(0, Mem::Compare(
       
   196 				        setting->iValue.iPtr.iString8, setting->iName.iLen,
       
   197 				        dval.Ptr(), dval.Length()));
       
   198 				    }
   189 				User::Free(pval);
   199 				User::Free(pval);
   190 				break;
   200 				break;
   191 				}
   201 				}
   192 			case ETypeArrayInt32:
   202 			case ETypeArrayInt32:
   193 				{
   203 				{
   194 				TInt32* pval;
   204 				TInt32* pval;
   195 				pval = (TInt32*) User::Alloc(setting->iName.iLen);
   205 				TUint16 maxLen = setting->iName.iLen == 0 ? (TUint16)4: setting->iName.iLen;
       
   206 				pval = (TInt32*) User::Alloc(maxLen);
   196 				test_NotNull(pval);
   207 				test_NotNull(pval);
   197 				//
   208 				//
   198 				TUint16 actuallength;
   209 				TUint16 actuallength;
   199 				r = HcrSimTest.GetArray(id, setting->iName.iLen, pval, actuallength);
   210 				r = HcrSimTest.GetArray(id, maxLen, pval, actuallength);
   200 				test_KErrNone(r);
   211 				test_KErrNone(r);
   201 				//
   212 
   202 				test_Equal(setting->iName.iLen, actuallength);
   213 				test_Equal(setting->iName.iLen, actuallength);
   203 				TInt32* pexpected = setting->iValue.iPtr.iArrayInt32;
   214 				TInt32* pexpected = setting->iValue.iPtr.iArrayInt32;
   204 				TUint i;
   215 				TUint i;
   205 				for (i = 0; i < setting->iName.iLen / sizeof(TInt32); i++)
   216 				for (i = 0; i < setting->iName.iLen / sizeof(TInt32); i++)
   206 					{
   217 					{
   210 				break;
   221 				break;
   211 				}
   222 				}
   212 			case ETypeArrayUInt32:
   223 			case ETypeArrayUInt32:
   213 				{
   224 				{
   214 				TUint32* pval;
   225 				TUint32* pval;
   215 				pval = (TUint32*) User::Alloc(setting->iName.iLen);
   226 				TUint16 maxLen = setting->iName.iLen == 0 ? (TUint16)4: setting->iName.iLen;
       
   227 				pval = (TUint32*) User::Alloc(maxLen);
   216 				test_NotNull(pval);
   228 				test_NotNull(pval);
   217 				//
   229 				//
   218 				TUint16 actuallength;
   230 				TUint16 actuallength;
   219 				r = HcrSimTest.GetArray(id, setting->iName.iLen, pval, actuallength);
   231 				r = HcrSimTest.GetArray(id, maxLen, pval, actuallength);
   220 				test_KErrNone(r);
   232 				test_KErrNone(r);
       
   233 				
   221 				//
   234 				//
   222 				test_Equal(setting->iName.iLen, actuallength);
   235 				test_Equal(setting->iName.iLen, actuallength);
   223 				TUint32* pexpected = setting->iValue.iPtr.iArrayUInt32;
   236 				TUint32* pexpected = setting->iValue.iPtr.iArrayUInt32;
   224 				TUint i;
   237 				TUint i;
   225 				for (i = 0; i < setting->iName.iLen / sizeof(TUint32); i++)
   238 				for (i = 0; i < setting->iName.iLen / sizeof(TUint32); i++)
   424 			{
   437 			{
   425 			TUint64 val;
   438 			TUint64 val;
   426 			r = HcrSimTest.GetUInt(id, val);
   439 			r = HcrSimTest.GetUInt(id, val);
   427 			test_Equal(KErrArgument, r);
   440 			test_Equal(KErrArgument, r);
   428 			}
   441 			}
   429 		}
   442 
       
   443 		
       
   444 		
       
   445 		if(setting->iName.iType == ETypeBinData)
       
   446 		    {
       
   447 		    TUint8* valBuf;
       
   448 		    TUint8* nullBuf = NULL;
       
   449 
       
   450 		    
       
   451 		    //
       
   452 		    TUint16 actuallength;
       
   453 
       
   454 		    TSettingId id(setting->iName.iId.iCat, setting->iName.iId.iKey);
       
   455 		    valBuf = (TUint8*) User::Alloc(KMaxSettingLength);
       
   456 		    test_NotNull(valBuf);
       
   457 
       
   458 		    //MaxLength = 0
       
   459 		    r = HcrSimTest.GetData(id, 0, valBuf, actuallength);
       
   460 		    test_Equal(KErrArgument, r);
       
   461 
       
   462 		    //buffer is not provided
       
   463 		    r = HcrSimTest.GetData(id, KMaxSettingLength, nullBuf, actuallength);
       
   464 		    test_Equal(KErrArgument, r);
       
   465 		    
       
   466 		    //neither buffer is provided nor MaxLength is not zero 
       
   467 		    r = HcrSimTest.GetData(id, 0, nullBuf, actuallength);
       
   468 		    test_Equal(KErrArgument, r);
       
   469 
       
   470 
       
   471 		    //descriptor MaxLength is zero
       
   472 		    //Default constructor sets the MaxLength to zero, so we don't need to call Create(0)
       
   473 		    //We also don't need to call Close() for this buffer as well.
       
   474 		    RBuf8 nullDes;
       
   475 		    r = HcrSimTest.GetData(id, nullDes);
       
   476 		    test_Equal(KErrArgument, r);
       
   477 
       
   478 		    //
       
   479 		    User::Free(valBuf);
       
   480 		    }
       
   481 
       
   482 		
       
   483 		if(setting->iName.iType == ETypeText8)
       
   484 		    {
       
   485 		    TUint8* valBuf;
       
   486 		    TUint8* nullBuf = NULL;
       
   487 		    //
       
   488 		    TUint16 actuallength;
       
   489 
       
   490 		    TSettingId id(setting->iName.iId.iCat, setting->iName.iId.iKey);
       
   491 		    valBuf = (TUint8*) User::Alloc(KMaxSettingLength);
       
   492 		    test_NotNull(valBuf);
       
   493 
       
   494 		    //MaxLength = 0
       
   495 		    r = HcrSimTest.GetString(id, 0, valBuf, actuallength);
       
   496 		    test_Equal(KErrArgument, r);
       
   497 
       
   498 		    //buffer is not provided
       
   499 		    r = HcrSimTest.GetString(id, KMaxSettingLength, nullBuf, actuallength);
       
   500 		    test_Equal(KErrArgument, r);
       
   501 		    
       
   502 		    //neither buffer is not provided nor the aMaxLen is not non-zero
       
   503 		    r = HcrSimTest.GetString(id, 0, nullBuf, actuallength);
       
   504 		    test_Equal(KErrArgument, r);
       
   505 
       
   506 
       
   507 		    //descriptor MaxLength is zero
       
   508 		    //Default constructor sets the MaxLength to zero, so we don't need to call Create(0)
       
   509 		    //We also don't need to call Close() for this buffer as well.
       
   510 		    RBuf8 nullDesc;
       
   511 		    r = HcrSimTest.GetString(id, nullDesc);
       
   512 		    test_Equal(KErrArgument, r);
       
   513 		    //
       
   514 		    User::Free(valBuf);
       
   515 		    }
       
   516 
       
   517 		if(setting->iName.iType == ETypeArrayInt32)
       
   518 		    {
       
   519 		    TInt32* valBuf;
       
   520 		    TInt32* nullBuf = NULL;
       
   521 		    valBuf = (TInt32*)User::Alloc(4*KMaxSettingLength);
       
   522 		    test_NotNull(valBuf);
       
   523 
       
   524 		    TUint16 actuallength;
       
   525 		    TSettingId id(setting->iName.iId.iCat, setting->iName.iId.iKey);
       
   526 
       
   527 		    //MaxLength = 0
       
   528 		    r = HcrSimTest.GetArray(id, 0, valBuf, actuallength);
       
   529 		    test_Equal(KErrArgument, r);
       
   530 
       
   531 		    //buffer is not provided
       
   532 		    r = HcrSimTest.GetArray(id, KMaxSettingLength, nullBuf, actuallength);
       
   533 		    test_Equal(KErrArgument, r);
       
   534 		    
       
   535 		    //neither buffer is not provided nor aMaxLen is not non-zero
       
   536 		    r = HcrSimTest.GetArray(id, 0, nullBuf, actuallength);
       
   537 		    test_Equal(KErrArgument, r);
       
   538 
       
   539 
       
   540 		    User::Free(valBuf);
       
   541 		    }
       
   542 
       
   543 		if(setting->iName.iType == ETypeArrayUInt32)
       
   544 		    {
       
   545 		    TUint32* valBuf;
       
   546 		    TUint32* nullBuf = NULL;
       
   547 		    valBuf = (TUint32*)User::Alloc(4*KMaxSettingLength);
       
   548 		    test_NotNull(valBuf);
       
   549 
       
   550 		    TUint16 actuallength;
       
   551 		    TSettingId id(setting->iName.iId.iCat, setting->iName.iId.iKey);
       
   552 
       
   553 		    //MaxLength = 0
       
   554 		    r = HcrSimTest.GetArray(id, 0, valBuf, actuallength);
       
   555 		    test_Equal(KErrArgument, r);
       
   556 
       
   557 		    //buffer is not provided
       
   558 		    r = HcrSimTest.GetArray(id, KMaxSettingLength,nullBuf, actuallength);
       
   559 		    test_Equal(KErrArgument, r);
       
   560 		    
       
   561 		    //neither buffer is not provided nor aMaxLen is not non-zero
       
   562 		    r = HcrSimTest.GetArray(id, 0, nullBuf, actuallength);
       
   563 		    test_Equal(KErrArgument, r);
       
   564 
       
   565 
       
   566 		    User::Free(valBuf);
       
   567 		    }
       
   568 
       
   569 		}
       
   570 
   430 	}
   571 	}
   431 
   572 
   432 void HcrSimSettingProperties(SSettingC* aRepository, TUint aNumberOfSettings)
   573 void HcrSimSettingProperties(SSettingC* aRepository, TUint aNumberOfSettings)
   433 	{
   574 	{
   434 	test.Next(_L("SettingProperties"));
   575 	test.Next(_L("SettingProperties"));
   812 		}
   953 		}
   813 	User::Free(ids);
   954 	User::Free(ids);
   814 	User::Free(vals);
   955 	User::Free(vals);
   815 	User::Free(types);
   956 	User::Free(types);
   816 	User::Free(errs);
   957 	User::Free(errs);
       
   958 
       
   959 	
       
   960 #ifdef _DEBUG
       
   961 	test.Next(_L("Multiple Get on all settings, aIds[] is not ordered"));
       
   962 	    nosettings = 0;
       
   963 	    for (setting = aRepository; setting < aRepository + aNumberOfSettings; setting++)
       
   964 	        {
       
   965 	        if (setting->iName.iType < 0x00010000)
       
   966 	            {
       
   967 	            nosettings++;
       
   968 	            }
       
   969 	        }
       
   970 	    test_Compare(2, <, nosettings);
       
   971 	    
       
   972 	    ids = (SSettingId*) User::Alloc(sizeof(SSettingId) * nosettings);
       
   973 	    test_NotNull(ids);
       
   974 	    vals = (TInt32*) User::Alloc(sizeof(TInt32) * nosettings);
       
   975 	    test_NotNull(vals);
       
   976 	    types = (TSettingType*) User::Alloc(sizeof(TSettingType) * nosettings);
       
   977 	    test_NotNull(types);
       
   978 	    errs = (TInt*) User::Alloc(sizeof(TInt) * nosettings);
       
   979 	    test_NotNull(errs);
       
   980 	    
       
   981 	    n = 0;
       
   982 
       
   983 	    for (setting = aRepository; setting < aRepository + aNumberOfSettings; setting++)
       
   984 	        {
       
   985 	        if (setting->iName.iType < 0x00010000)
       
   986 	            {
       
   987 	            ids[n].iCat = setting->iName.iId.iCat;
       
   988 	            ids[n].iKey = setting->iName.iId.iKey;
       
   989 	            n++;
       
   990 	            }
       
   991 	        }
       
   992 	    test_Equal(nosettings, n);
       
   993 	    
       
   994 	    //Swap two neigbours elements in the middle of the user array
       
   995 	    HCR::SSettingId tmpSet;
       
   996 	    TUint swappedIndex = (n >> 1) - 1;
       
   997 	    //Make a copy of one of the swaped element
       
   998 	    tmpSet.iCat = ids[swappedIndex].iCat;
       
   999 	    tmpSet.iKey = ids[swappedIndex].iKey;
       
  1000 	    
       
  1001 	    //Initialized that element with the values of the next one
       
  1002 	    ids[swappedIndex].iCat = ids[swappedIndex + 1].iCat;
       
  1003 	    ids[swappedIndex].iKey = ids[swappedIndex + 1].iKey;
       
  1004 	    
       
  1005 	    //Write back data from the temproary element
       
  1006 	    ids[swappedIndex + 1].iCat = tmpSet.iCat;
       
  1007 	    ids[swappedIndex + 1].iKey = tmpSet.iKey;
       
  1008 
       
  1009 	    r = HcrSimTest.GetWordSettings(nosettings, ids, vals, types, errs);
       
  1010 
       
  1011 	    //HCR returns KErrArgument because ids array was not properly ordered
       
  1012 	    test_Equal(KErrArgument, r);
       
  1013 
       
  1014 	    User::Free(ids);
       
  1015 	    User::Free(vals);
       
  1016 	    User::Free(types);
       
  1017 	    User::Free(errs);
       
  1018 #endif
       
  1019 	
   817 
  1020 
   818 	test.Next(_L("Multiple Get on a large setting"));
  1021 	test.Next(_L("Multiple Get on a large setting"));
   819 	if (largesetting.iKey)
  1022 	if (largesetting.iKey)
   820 		{
  1023 		{
   821 		TInt32 value;
  1024 		TInt32 value;
  2428 		test_KErrNone(r);
  2631 		test_KErrNone(r);
  2429 		}
  2632 		}
  2430 	test.End();
  2633 	test.End();
  2431 	}
  2634 	}
  2432 
  2635 
       
  2636 void HcrCatRecodsExampleTest(const TDesC& aDriver)
       
  2637     {
       
  2638     using namespace HCR;
       
  2639 
       
  2640    
       
  2641     test.Start(_L("HCR Record Structured Category Test"));
       
  2642     test.Next(_L("Load HCR Test driver"));
       
  2643     
       
  2644     test.Printf(_L("%S\n"), &aDriver);
       
  2645     TInt r;
       
  2646     
       
  2647     _LIT8(KTestCatRecordsRepos, "filerepos_cds.dat");
       
  2648 
       
  2649     r = User::LoadLogicalDevice(aDriver);
       
  2650     if (r == KErrAlreadyExists)
       
  2651         {
       
  2652         test.Printf(_L("Unload Device Driver and load it again\n"));
       
  2653         r = User::FreeLogicalDevice(aDriver);
       
  2654         test_KErrNone(r);
       
  2655         r = User::LoadLogicalDevice(aDriver);
       
  2656         test_KErrNone(r);
       
  2657         }
       
  2658     else
       
  2659         {
       
  2660         test_KErrNone(r);
       
  2661         }
       
  2662 
       
  2663     test.Next(_L("Open test channel"));
       
  2664     r = HcrSimTest.Open(aDriver);
       
  2665     test_KErrNone(r);
       
  2666 
       
  2667     test.Next(_L("Initialise HCR"));
       
  2668     //r = HcrSimTest.InitExtension();
       
  2669     // *** The NULL Repository ***
       
  2670     r = HcrSimTest.InitExtension(ETestNullRepository);
       
  2671     test_KErrNone(r);
       
  2672 
       
  2673     test.Next(_L("Load Test File repository"));
       
  2674     r = HcrSimTest.SwitchRepository(KTestCatRecordsRepos, HCRInternal::ECoreRepos);
       
  2675     test_KErrNone(r);
       
  2676     r = HcrSimTest.CheckIntegrity();
       
  2677     test_KErrNone(r);
       
  2678 
       
  2679 
       
  2680 
       
  2681     struct TAccelCaps
       
  2682         {
       
  2683         TUint32 iManufactureId;
       
  2684         TUint16 iDeviceId;
       
  2685         char* iDevName;
       
  2686         TUint16 iDataRate;
       
  2687         TUint16 iResolution;
       
  2688         TUint16 iScale;
       
  2689         };
       
  2690 
       
  2691     const TInt KCapsField_Manufacturer = 1;
       
  2692     const TInt KCapsField_Device = 2;
       
  2693     const TInt KCapsField_Name = 3;
       
  2694     const TInt KCapsField_DataRate = 4;
       
  2695     const TInt KCapsField_Resolution = 5;
       
  2696     const TInt KCapsField_Scale = 6;
       
  2697 
       
  2698     const TInt KMaxNumAccelerateDevices = 2;
       
  2699     const TInt KNumElementsInRow = 6;
       
  2700 
       
  2701     const TInt KKiSemiIndex = 0;
       
  2702     const TInt KSpecCo4gIndex = 1;
       
  2703     char KKiSemiIncDevName[] = "KI Semi Inc 8g Accelerometer";
       
  2704     const TUint16 KKiSemiIncDevNameLength = sizeof(KKiSemiIncDevName) - 1;
       
  2705     char KSpecCo4gDevName[] = "SPE Co 4g Accelerometer";
       
  2706     const TUint16 KSpecCo4gDevNameLength = sizeof(KSpecCo4gDevName) - 1;
       
  2707 
       
  2708     TAccelCaps* capsStructs = new TAccelCaps[KMaxNumAccelerateDevices];
       
  2709 
       
  2710     test_NotNull(capsStructs);
       
  2711 
       
  2712     //Initialisation with the sample data
       
  2713     //KI SemiInc 8g
       
  2714     capsStructs[KKiSemiIndex].iManufactureId = 0x12003335;
       
  2715     capsStructs[KKiSemiIndex].iDeviceId = 0x2001;
       
  2716     capsStructs[KKiSemiIndex].iDevName = KKiSemiIncDevName; 
       
  2717     capsStructs[KKiSemiIndex].iDataRate = 20;
       
  2718     capsStructs[KKiSemiIndex].iResolution = 8;
       
  2719     capsStructs[KKiSemiIndex].iScale = 8;
       
  2720     //SPE Co 4g
       
  2721     capsStructs[KSpecCo4gIndex].iManufactureId = 0x72103301;
       
  2722     capsStructs[KSpecCo4gIndex].iDeviceId = 0x0012;
       
  2723     capsStructs[KSpecCo4gIndex].iDevName = KSpecCo4gDevName; 
       
  2724     capsStructs[KSpecCo4gIndex].iDataRate = 50;
       
  2725     capsStructs[KSpecCo4gIndex].iResolution = 16;
       
  2726     capsStructs[KSpecCo4gIndex].iScale = 4;
       
  2727 
       
  2728     
       
  2729     //Setting the value
       
  2730     TUint32 mask = 0x0000ffff;
       
  2731     const TUint32 KKiSemiPattern = 0x00010000u;
       
  2732     const TUint32 KSpecCo4gPattern = 0x00020000u;
       
  2733     const HCR::TCategoryUid category = 0x00000001u;
       
  2734 
       
  2735     //SettingId container, it's used further down in the retrieve operations
       
  2736     HCR::TSettingId setId(category,0);
       
  2737     
       
  2738     //Test Repository elements Ids data
       
  2739     HCR::SSettingId repIds[KMaxNumAccelerateDevices][KNumElementsInRow] =
       
  2740             {
       
  2741                     {
       
  2742                             {0x01, 65537}, {0x01, 65538}, {0x01, 65539},
       
  2743                             {0x01, 65540}, {0x01, 65541}, {0x01, 65542}
       
  2744                     },
       
  2745                     {
       
  2746                             {0x01, 131073}, {0x01, 131074}, {0x01, 131075},
       
  2747                             {0x01, 131076}, {0x01, 131077}, {0x01, 131078}
       
  2748                     }
       
  2749             };
       
  2750     
       
  2751 
       
  2752 
       
  2753     HCR::TElementId* ids = new TElementId[KNumElementsInRow];
       
  2754     test_NotNull(ids);
       
  2755     HCR::TSettingType* types = new TSettingType[KNumElementsInRow];
       
  2756     test_NotNull(types);
       
  2757     TUint16* lengths = new TUint16[KNumElementsInRow];
       
  2758     test_NotNull(lengths);
       
  2759 
       
  2760     //------------------------------------------------------------------
       
  2761     //Retrieve "ManufactureId" (column request) values for all devices
       
  2762     //------------------------------------------------------------------
       
  2763     r = HcrSimTest.FindSettings(category, KMaxNumAccelerateDevices, mask, 
       
  2764             KCapsField_Manufacturer, ids, types, lengths);
       
  2765     //Assert against the error
       
  2766     test_Compare(r,>=,0);
       
  2767 
       
  2768     //Check the number of elements
       
  2769     test_Equal(KMaxNumAccelerateDevices, r);
       
  2770 
       
  2771     // Check the ids, lengths and types
       
  2772     test_Equal(repIds[KKiSemiIndex][KCapsField_Manufacturer - 1].iKey, ids[KKiSemiIndex]);
       
  2773     test_Equal(HCR::ETypeUInt32, types[KKiSemiIndex]);
       
  2774     test_Equal(0,lengths[KKiSemiIndex]);
       
  2775     
       
  2776 
       
  2777     // Check the ids, lengths and types
       
  2778     test_Equal(repIds[KSpecCo4gIndex][KCapsField_Manufacturer - 1].iKey, ids[KSpecCo4gIndex]);
       
  2779     test_Equal(HCR::ETypeUInt32, types[KSpecCo4gIndex]);
       
  2780     test_Equal(0,lengths[KSpecCo4gIndex]);
       
  2781 
       
  2782     
       
  2783     //----------------------------
       
  2784     //Get all ManufactureId values
       
  2785     //----------------------------
       
  2786     TUint32 manufId;
       
  2787     //KiSemi
       
  2788     setId.iKey = ids[KKiSemiIndex];
       
  2789     r = HcrSimTest.GetUInt(setId,  manufId);
       
  2790     test_KErrNone(r);
       
  2791     test_Equal(capsStructs[KKiSemiIndex].iManufactureId,  manufId);
       
  2792   
       
  2793     //SpecCo 
       
  2794     setId.iKey = ids[KSpecCo4gIndex];
       
  2795     r = HcrSimTest.GetUInt(setId,  manufId);
       
  2796     test_KErrNone(r);
       
  2797     test_Equal(capsStructs[KSpecCo4gIndex].iManufactureId,  manufId);
       
  2798     
       
  2799     
       
  2800     
       
  2801     //------------------------------------------------------------------
       
  2802     //Retrieve "DeviceId" (column request) values for all devices
       
  2803     //------------------------------------------------------------------
       
  2804     r = HcrSimTest.FindSettings(category, KMaxNumAccelerateDevices, mask, 
       
  2805             KCapsField_Device, ids, types, lengths);
       
  2806     //Assert against the error
       
  2807     test_Compare(r,>=,0);
       
  2808 
       
  2809     //Check the number of elements
       
  2810     test_Equal(KMaxNumAccelerateDevices, r);
       
  2811 
       
  2812     // Check the ids, lengths and types
       
  2813     test_Equal(repIds[KKiSemiIndex][KCapsField_Device - 1].iKey, ids[KKiSemiIndex]);
       
  2814     test_Equal(HCR::ETypeUInt16, types[KKiSemiIndex]);
       
  2815     test_Equal(0,lengths[KKiSemiIndex]);
       
  2816 
       
  2817     // Check the ids, lengths and types
       
  2818     test_Equal(repIds[KSpecCo4gIndex][KCapsField_Device - 1].iKey, ids[KSpecCo4gIndex]);
       
  2819     test_Equal(HCR::ETypeUInt16, types[KSpecCo4gIndex]);
       
  2820     test_Equal(0,lengths[KSpecCo4gIndex]);
       
  2821 
       
  2822     
       
  2823     //----------------------------
       
  2824     //Get all DeviceId values
       
  2825     //----------------------------
       
  2826     TUint16 devId;
       
  2827 
       
  2828     //KiSemi
       
  2829     setId.iKey = ids[KKiSemiIndex];
       
  2830     r = HcrSimTest.GetUInt(setId,  devId);
       
  2831     test_KErrNone(r);
       
  2832     test_Equal(capsStructs[KKiSemiIndex].iDeviceId,  devId);
       
  2833   
       
  2834     //SpecCo 
       
  2835     setId.iKey = ids[KSpecCo4gIndex];
       
  2836     r = HcrSimTest.GetUInt(setId, devId);
       
  2837     test_KErrNone(r);
       
  2838     test_Equal(capsStructs[KSpecCo4gIndex].iDeviceId,  devId);
       
  2839 
       
  2840 
       
  2841     
       
  2842     //------------------------------------------------------------------
       
  2843     //Retrieve "DeviceName" (column request) values for all devices
       
  2844     //------------------------------------------------------------------
       
  2845     r = HcrSimTest.FindSettings(category, KMaxNumAccelerateDevices, mask, 
       
  2846             KCapsField_Name, ids, types, lengths);
       
  2847     
       
  2848     //Assert against the error
       
  2849     test_Compare(r,>=,0);
       
  2850 
       
  2851     //Check the number of elements
       
  2852     test_Equal(KMaxNumAccelerateDevices, r);
       
  2853 
       
  2854     // Check the ids, lengths and types
       
  2855     test_Equal(repIds[KKiSemiIndex][KCapsField_Name - 1].iKey, ids[KKiSemiIndex]);
       
  2856     test_Equal(HCR::ETypeText8, types[KKiSemiIndex]);
       
  2857     test_Equal(KKiSemiIncDevNameLength,lengths[KKiSemiIndex]);
       
  2858 
       
  2859     // Check the ids, lengths and types
       
  2860     test_Equal(repIds[KSpecCo4gIndex][KCapsField_Name - 1].iKey, ids[KSpecCo4gIndex]);
       
  2861     test_Equal(HCR::ETypeText8, types[KSpecCo4gIndex]);
       
  2862     test_Equal(KSpecCo4gDevNameLength,lengths[KSpecCo4gIndex]);
       
  2863 
       
  2864 
       
  2865     //----------------------------
       
  2866     //Get all DeviceName values
       
  2867     //----------------------------
       
  2868     TUint16 len;
       
  2869     
       
  2870     //KiSemi
       
  2871     TText8* nameKiSemi = new TText8[KKiSemiIncDevNameLength];
       
  2872     test_NotNull(nameKiSemi);
       
  2873     
       
  2874     setId.iKey = ids[KKiSemiIndex];
       
  2875     r = HcrSimTest.GetString(setId, KKiSemiIncDevNameLength, 
       
  2876             nameKiSemi, len);
       
  2877     test_KErrNone(r);
       
  2878     r = memcompare((unsigned char*)capsStructs[KKiSemiIndex].iDevName, (int)KKiSemiIncDevNameLength,
       
  2879             nameKiSemi, (int)KKiSemiIncDevNameLength);
       
  2880     test_KErrNone(r);
       
  2881 
       
  2882     //SpecCo 
       
  2883     TText8* nameSpecCo = new TText8[KSpecCo4gDevNameLength];
       
  2884     test_NotNull(nameSpecCo);
       
  2885     
       
  2886     setId.iKey = ids[KSpecCo4gIndex];
       
  2887     r = HcrSimTest.GetString(setId, KSpecCo4gDevNameLength, 
       
  2888             nameSpecCo, len);
       
  2889     test_KErrNone(r);
       
  2890     r = memcompare((unsigned char*)capsStructs[KSpecCo4gIndex].iDevName, 
       
  2891             (int)KSpecCo4gDevNameLength, nameSpecCo, (int)KSpecCo4gDevNameLength);
       
  2892     test_KErrNone(r);
       
  2893 
       
  2894     
       
  2895     
       
  2896     //------------------------------------------------------------------
       
  2897     //Retrieve "DataRate" (column request) values for all devices
       
  2898     //------------------------------------------------------------------
       
  2899     r = HcrSimTest.FindSettings(category, KMaxNumAccelerateDevices, mask, 
       
  2900             KCapsField_DataRate, ids, types, lengths);
       
  2901     //Assert against the error
       
  2902     test_Compare(r,>=,0);
       
  2903 
       
  2904     //Check the number of elements
       
  2905     test_Equal(KMaxNumAccelerateDevices, r);
       
  2906 
       
  2907     // Check the ids, lengths and types
       
  2908     test_Equal(repIds[KKiSemiIndex][KCapsField_DataRate - 1].iKey, ids[KKiSemiIndex]);
       
  2909     test_Equal(HCR::ETypeUInt16, types[KKiSemiIndex]);
       
  2910     test_Equal(0,lengths[KKiSemiIndex]);
       
  2911 
       
  2912     // Check the ids, lengths and types
       
  2913     test_Equal(repIds[KSpecCo4gIndex][KCapsField_DataRate - 1].iKey, ids[KSpecCo4gIndex]);
       
  2914     test_Equal(HCR::ETypeUInt16, types[KSpecCo4gIndex]);
       
  2915     test_Equal(0,lengths[KSpecCo4gIndex]);
       
  2916 
       
  2917 
       
  2918     //----------------------------
       
  2919     //Get all DataRate values
       
  2920     //----------------------------
       
  2921     TUint16 dataRate;
       
  2922 
       
  2923     //KiSemi
       
  2924     setId.iKey = ids[KKiSemiIndex];
       
  2925     r = HcrSimTest.GetUInt(setId,  dataRate);
       
  2926     test_KErrNone(r);
       
  2927     test_Equal(capsStructs[KKiSemiIndex].iDataRate, dataRate);
       
  2928 
       
  2929     //SpecCo 
       
  2930     setId.iKey = ids[KSpecCo4gIndex];
       
  2931     r = HcrSimTest.GetUInt(setId, dataRate);
       
  2932     test_KErrNone(r);
       
  2933     test_Equal(capsStructs[KSpecCo4gIndex].iDataRate,  dataRate);
       
  2934 
       
  2935     
       
  2936     //------------------------------------------------------------------
       
  2937     //Retrieve "Resolution" (column request) values for all devices
       
  2938     //------------------------------------------------------------------
       
  2939     r = HcrSimTest.FindSettings(category, KMaxNumAccelerateDevices, mask, 
       
  2940             KCapsField_Resolution, ids, types, lengths);
       
  2941     //Assert against the error
       
  2942     test_Compare(r,>=,0);
       
  2943 
       
  2944     //Check the number of elements
       
  2945     test_Equal(KMaxNumAccelerateDevices, r);
       
  2946 
       
  2947     // Check the ids, lengths and types
       
  2948     test_Equal(repIds[KKiSemiIndex][KCapsField_Resolution - 1].iKey, ids[KKiSemiIndex]);
       
  2949     test_Equal(HCR::ETypeUInt16, types[KKiSemiIndex]);
       
  2950     test_Equal(0,lengths[KKiSemiIndex]);
       
  2951 
       
  2952     // Check the ids, lengths and types
       
  2953     test_Equal(repIds[KSpecCo4gIndex][KCapsField_Resolution - 1].iKey, ids[KSpecCo4gIndex]);
       
  2954     test_Equal(HCR::ETypeUInt16, types[KSpecCo4gIndex]);
       
  2955     test_Equal(0,lengths[KSpecCo4gIndex]);
       
  2956 
       
  2957 
       
  2958     //----------------------------
       
  2959     //Get all "Resolution" values
       
  2960     //----------------------------
       
  2961     TUint16 resolution;
       
  2962 
       
  2963     //KiSemi
       
  2964     setId.iKey = ids[KKiSemiIndex];
       
  2965     r = HcrSimTest.GetUInt(setId,  resolution);
       
  2966     test_KErrNone(r);
       
  2967     test_Equal(capsStructs[KKiSemiIndex].iResolution, resolution);
       
  2968 
       
  2969     //SpecCo 
       
  2970     setId.iKey = ids[KSpecCo4gIndex];
       
  2971     r = HcrSimTest.GetUInt(setId, resolution);
       
  2972     test_KErrNone(r);
       
  2973     test_Equal(capsStructs[KSpecCo4gIndex].iResolution, resolution);
       
  2974 
       
  2975 
       
  2976     //------------------------------------------------------------------
       
  2977     //Retrieve "Scale" (column request) values for all devices
       
  2978     //------------------------------------------------------------------
       
  2979     r = HcrSimTest.FindSettings(category, KMaxNumAccelerateDevices, mask, 
       
  2980             KCapsField_Scale, ids, types, lengths);
       
  2981     //Assert against the error
       
  2982     test_Compare(r,>=,0);
       
  2983 
       
  2984     //Check the number of elements
       
  2985     test_Equal(KMaxNumAccelerateDevices, r);
       
  2986 
       
  2987     // Check the ids, lengths and types
       
  2988     test_Equal(repIds[KKiSemiIndex][KCapsField_Scale - 1].iKey, ids[KKiSemiIndex]);
       
  2989     test_Equal(HCR::ETypeUInt16, types[KKiSemiIndex]);
       
  2990     test_Equal(0,lengths[KKiSemiIndex]);
       
  2991 
       
  2992     // Check the ids, lengths and types
       
  2993     test_Equal(repIds[KSpecCo4gIndex][KCapsField_Scale - 1].iKey, ids[KSpecCo4gIndex]);
       
  2994     test_Equal(HCR::ETypeUInt16, types[KSpecCo4gIndex]);
       
  2995     test_Equal(0,lengths[KSpecCo4gIndex]);
       
  2996 
       
  2997 
       
  2998     //----------------------------
       
  2999     //Get all "Scale" values
       
  3000     //----------------------------
       
  3001     TUint16 scale;
       
  3002 
       
  3003     //KiSemi
       
  3004     setId.iKey = ids[KKiSemiIndex];
       
  3005     r = HcrSimTest.GetUInt(setId,  scale);
       
  3006     test_KErrNone(r);
       
  3007     test_Equal(capsStructs[KKiSemiIndex].iScale, scale);
       
  3008 
       
  3009     //SpecCo 
       
  3010     setId.iKey = ids[KSpecCo4gIndex];
       
  3011     r = HcrSimTest.GetUInt(setId, scale);
       
  3012     test_KErrNone(r);
       
  3013     test_Equal(capsStructs[KSpecCo4gIndex].iScale, scale);
       
  3014     
       
  3015     
       
  3016     
       
  3017     //-----------------------------------------------------------------------
       
  3018     //Read a complete row data for the single device
       
  3019     //-----------------------------------------------------------------------
       
  3020     mask = 0xffff0000; //retrive a row
       
  3021     
       
  3022     //------------------------
       
  3023     //KiSemi
       
  3024     //------------------------
       
  3025     r = HcrSimTest.FindSettings(category, KNumElementsInRow, mask, 
       
  3026             KKiSemiPattern, ids, types, lengths);
       
  3027     //Assert against the error
       
  3028     test_Compare(r,>=,0);
       
  3029     
       
  3030     //Assert the number of found elements
       
  3031     test_Equal(KNumElementsInRow, r);
       
  3032     
       
  3033     //Check the ManufactureId
       
  3034     setId.iKey = ids[KCapsField_Manufacturer-1];
       
  3035     r = HcrSimTest.GetUInt(setId,  manufId);
       
  3036     test_KErrNone(r);
       
  3037     test_Equal(capsStructs[KKiSemiIndex].iManufactureId,  manufId);
       
  3038     
       
  3039     //Check the DeviceId
       
  3040     setId.iKey = ids[KCapsField_Device-1];
       
  3041     r = HcrSimTest.GetUInt(setId,  devId);
       
  3042     test_KErrNone(r);
       
  3043     test_Equal(capsStructs[KKiSemiIndex].iDeviceId,  devId);
       
  3044     
       
  3045     //Check the DeviceName
       
  3046     setId.iKey = ids[KCapsField_Name-1];
       
  3047     r = HcrSimTest.GetString(setId, KKiSemiIncDevNameLength, 
       
  3048             nameKiSemi, len);
       
  3049     test_KErrNone(r);
       
  3050     r = memcompare((unsigned char*)capsStructs[KKiSemiIndex].iDevName,
       
  3051         (int)KKiSemiIncDevNameLength, nameKiSemi, (int)KKiSemiIncDevNameLength);
       
  3052     test_KErrNone(r);
       
  3053     
       
  3054     //Check the DataRate
       
  3055     setId.iKey = ids[KCapsField_DataRate-1];
       
  3056     r = HcrSimTest.GetUInt(setId,  dataRate);
       
  3057     test_KErrNone(r);
       
  3058     test_Equal(capsStructs[KKiSemiIndex].iDataRate, dataRate);
       
  3059 
       
  3060     
       
  3061     //Check the Resolution
       
  3062     setId.iKey = ids[KCapsField_Resolution-1];
       
  3063     r = HcrSimTest.GetUInt(setId,  resolution);
       
  3064     test_KErrNone(r);
       
  3065     test_Equal(capsStructs[KKiSemiIndex].iResolution, resolution);
       
  3066 
       
  3067     //------------------------
       
  3068     //SpecCo
       
  3069     //------------------------
       
  3070     r = HcrSimTest.FindSettings(category, KNumElementsInRow, mask, 
       
  3071             KSpecCo4gPattern, ids, types, lengths);
       
  3072     //Assert against the error
       
  3073     test_Compare(r,>=,0);
       
  3074 
       
  3075     //Assert the number of found elements
       
  3076     test_Equal(KNumElementsInRow, r);
       
  3077 
       
  3078     //Check the ManufactureId
       
  3079     setId.iKey = ids[KCapsField_Manufacturer-1];
       
  3080     r = HcrSimTest.GetUInt(setId,  manufId);
       
  3081     test_KErrNone(r);
       
  3082     test_Equal(capsStructs[KSpecCo4gIndex].iManufactureId,  manufId);
       
  3083 
       
  3084     //Check the DeviceId
       
  3085     setId.iKey = ids[KCapsField_Device-1];
       
  3086     r = HcrSimTest.GetUInt(setId,  devId);
       
  3087     test_KErrNone(r);
       
  3088     test_Equal(capsStructs[KSpecCo4gIndex].iDeviceId,  devId);
       
  3089 
       
  3090     //Check the DeviceName
       
  3091     setId.iKey = ids[KCapsField_Name-1];
       
  3092     r = HcrSimTest.GetString(setId, KSpecCo4gDevNameLength, 
       
  3093             nameSpecCo, len);
       
  3094     test_KErrNone(r);
       
  3095     r = memcompare((unsigned char*)capsStructs[KSpecCo4gIndex].iDevName,
       
  3096           (int)KSpecCo4gDevNameLength, nameSpecCo, (int)KSpecCo4gDevNameLength);
       
  3097     test_KErrNone(r);
       
  3098 
       
  3099     //Check the DataRate
       
  3100     setId.iKey = ids[KCapsField_DataRate-1];
       
  3101     r = HcrSimTest.GetUInt(setId,  dataRate);
       
  3102     test_KErrNone(r);
       
  3103     test_Equal(capsStructs[KSpecCo4gIndex].iDataRate, dataRate);
       
  3104 
       
  3105     //Check the Resolution
       
  3106     setId.iKey = ids[KCapsField_Resolution-1];
       
  3107     r = HcrSimTest.GetUInt(setId,  resolution);
       
  3108     test_KErrNone(r);
       
  3109     test_Equal(capsStructs[KSpecCo4gIndex].iResolution, resolution);
       
  3110 
       
  3111 
       
  3112     //Deallocate allocated resources
       
  3113     delete[] ids;
       
  3114     delete[] types;
       
  3115     delete[] lengths;
       
  3116     
       
  3117     delete[] nameKiSemi;
       
  3118     delete[] nameSpecCo;
       
  3119     
       
  3120     delete[] capsStructs;
       
  3121     
       
  3122 
       
  3123     HcrSimTest.Close();
       
  3124     r = User::FreeLogicalDevice(aDriver);
       
  3125     test_KErrNone(r);
       
  3126     test.End();
       
  3127     }
       
  3128     
       
  3129 
  2433 void HcrSimBenchmarkTests(const TDesC& aDriver)
  3130 void HcrSimBenchmarkTests(const TDesC& aDriver)
  2434 	{
  3131 	{
  2435 	test.Next(_L("Simulated HCR Benchmark"));
  3132 	test.Next(_L("Simulated HCR Benchmark"));
  2436 	test.Start(_L("Initialisation"));
  3133 	test.Start(_L("Initialisation"));
  2437 	test.Printf(_L("%S\n"), &aDriver);
  3134 	test.Printf(_L("%S\n"), &aDriver);
  2637 	HcrRealTests(KTestHcrRealClient);
  3334 	HcrRealTests(KTestHcrRealClient);
  2638 	HcrPslTests(KTestHcrSimOwn);
  3335 	HcrPslTests(KTestHcrSimOwn);
  2639 	HcrPslTests(KTestHcrSimClient);
  3336 	HcrPslTests(KTestHcrSimClient);
  2640 	HcrSimTests(KTestHcrSimOwn);
  3337 	HcrSimTests(KTestHcrSimOwn);
  2641 	HcrSimTests(KTestHcrSimClient);
  3338 	HcrSimTests(KTestHcrSimClient);
  2642 
  3339 	
       
  3340 	HcrCatRecodsExampleTest(KTestHcrSimOwn);
       
  3341 	HcrCatRecodsExampleTest(KTestHcrSimClient);
  2643 
  3342 
  2644 	//Benchmark tests
  3343 	//Benchmark tests
  2645 	HcrSimBenchmarkTests(KTestHcrSimOwn);
  3344 	HcrSimBenchmarkTests(KTestHcrSimOwn);
  2646 	HcrSimBenchmarkTests(KTestHcrSimClient);
  3345 	HcrSimBenchmarkTests(KTestHcrSimClient);
  2647 	HcrRealBenchmarkTests(KTestHcrRealOwn);
  3346 	HcrRealBenchmarkTests(KTestHcrRealOwn);