/** Retrieves daylight property for various time zones in OOM conditions */ void CTestTZServer::OOMDaylightSavingL() { RTz tz; CleanupClosePushL(tz); User::LeaveIfError(tz.Connect()); tz.SetAutoUpdateBehaviorL(RTz::ETZAutoDSTUpdateOn); CTzId* tzId = NULL; TRAPD(err1,tzId = tz.GetTimeZoneIdL()); //the current system time zone TESTL ( err1 == KErrNone ); CleanupStack::PushL(tzId); TBool isDaylightOn = EFalse; iFailAt = 0; for ( ;; ) { StartHeapCheck(iFailAt); TRAPD(err, isDaylightOn = tz.IsDaylightSavingOnL(*tzId)); //daylight property for current system time zone if ( err == KErrNone ) { __UHEAP_RESET; INFO_PRINTF1(_L("OOM testing of IsDaylightSavingOnL()) Api is done")); break; } if ( ErrorProcess(err) ) { EndHeapCheck(); } else { break; } } iField.Zero(); iField.Append(KDaylightSaving); GetBoolFromConfig(ConfigSection(),iField,iDaylightSaving); //gets expected daylight property //compares expected daylight property with actual daylight property TESTL(iDaylightSaving == isDaylightOn); CleanupStack::PopAndDestroy(tzId); CleanupStack::PopAndDestroy(&tz); }
void CTzUserDataTest::TestTimeZoneRulesL(TTest aWhatToTest) { ResetTzUserDataL(); test.Next(_L("Time Zone Rules")); RTz tz; User::LeaveIfError(tz.Connect()); CleanupClosePushL(tz); tz.SetAutoUpdateBehaviorL(RTz::ETZAutoDSTUpdateOn); iUserData = CTzUserData::NewL(tz); test.Next(_L("Create user-defined Time Zone")); // Offset 60 There is no DST test.Printf(_L("Offset 60 There is no DST\n")); CreateTzAndCheckL(60, 60, tz, aWhatToTest); // Offset - 60 There is no DST test.Printf(_L("Offset -60 There is no DST\n")); CreateTzAndCheckL(-60, -60, tz, aWhatToTest); // Offset 60 There is DST of 60 CreateTzAndCheckL(60, 120, tz, aWhatToTest); // Offset - 60 There is DST of 60 test.Printf(_L("Offset - 60 There is DST of 60\n")); CreateTzAndCheckL(-60, 0, tz, aWhatToTest); // Create user time zone based on London TZ rules test.Printf(_L("Create User Tz Based On London Rule\n")); CreateUserTzBasedOnLondonRuleL(tz, aWhatToTest); // Create user time zone based on Shanghai TZ rules test.Printf(_L("Create User Tz Based On Shanghai Rule\n")); CreateUserTzBasedOnShanghaiRuleL(tz, aWhatToTest); delete iUserData; iUserData= NULL; CleanupStack::PopAndDestroy(&tz); ResetTzUserDataL(); }
/** Retrives offsets for various numeric ids in OOM conditions */ void CTestTZServer::OOMGetOffsetTZIdsL() { RArray<TPtrC> numericIdsList; CleanupClosePushL(numericIdsList); TPtrC numericids; GetStringFromConfig(ConfigSection(), KNumericIds, numericids); TokenizeStringL(numericids, numericIdsList); //retrieve numeric ids to obtain their offsets RArray<TInt> tzIds; CleanupClosePushL(tzIds); for (TInt i = 0; i < numericIdsList.Count(); i++) { TLex lex(numericIdsList[i]); TInt numericId; User::LeaveIfError(lex.Val(numericId)); tzIds.Append(numericId); } RTz tz; CleanupClosePushL(tz); User::LeaveIfError(tz.Connect()); tz.SetAutoUpdateBehaviorL(RTz::ETZAutoDSTUpdateOn); RArray<TInt> offsets; CleanupClosePushL(offsets); iFailAt = 1; for ( ;; ) { StartHeapCheck(iFailAt); offsets.Reset(); TRAPD(err,tz.GetOffsetsForTimeZoneIdsL(tzIds,offsets)); if ( err == KErrNone ) { __UHEAP_RESET; INFO_PRINTF1(_L("OOM testing of GetOffsetsForTimeZoneIdsL Api is done")); break; } if ( ErrorProcess(err) ) { EndHeapCheck(); } else { break; } } RArray<TPtrC> expectedOffsetList; CleanupClosePushL(expectedOffsetList); TPtrC expectedOffsets; GetStringFromConfig(ConfigSection(), KOffset, expectedOffsets); TokenizeStringL(expectedOffsets, expectedOffsetList); //gets the expected offsets for the specified numeric ids RArray<TInt> expectedOffsetsList; CleanupClosePushL(expectedOffsetsList); for (TInt i = 0; i < expectedOffsetList.Count(); i++) { TLex lex(expectedOffsetList[i]); TInt offset; User::LeaveIfError(lex.Val(offset)); expectedOffsetsList.Append(offset); } //compares the expected offsets for the numeric ids with the actual retrieved offsets TESTL(expectedOffsetsList.Count() == offsets.Count()); for (TInt x = 0; x < expectedOffsetsList.Count(); x++) { INFO_PRINTF2(_L("tzid : %d"),tzIds[x]); } for (TInt x = 0; x < expectedOffsetsList.Count(); x++) { INFO_PRINTF2(_L("actual : %d"),offsets[x]); } for (TInt x = 0; x < expectedOffsetsList.Count(); x++) { TESTL(expectedOffsetsList[x] == offsets[x]); } CleanupStack::PopAndDestroy(&expectedOffsetsList); CleanupStack::PopAndDestroy(&expectedOffsetList); CleanupStack::PopAndDestroy(&offsets); CleanupStack::PopAndDestroy(&tz); CleanupStack::PopAndDestroy(&tzIds); CleanupStack::PopAndDestroy(&numericIdsList); }