os/ossrv/lowlevellibsandfws/pluginfw/Framework/RegistrarTest/RegistrarTransitionValidation.inl
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // The implementation of the validation classes for the CRegistar tests.
    15 // 
    16 //
    17 
    18 // ______________________________________________________________________________
    19 //
    20 inline TRegistrar_Ctor_TransitionValidator::TRegistrar_Ctor_TransitionValidator(CUnitTestContext& aUTContext)
    21 :TTransitionValidator(aUTContext)
    22 	{
    23 	// Do nothing
    24 	}
    25 
    26 inline TBool TRegistrar_Ctor_TransitionValidator::ValidatePreConditions()
    27 	{
    28 	return ETrue;
    29 	}
    30 
    31 inline TBool TRegistrar_Ctor_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
    32 	{
    33 	if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistrar_UnitTestContext&,iUTContext).iRegistrar))
    34 		return EFalse;
    35 	return ETrue;
    36 	}
    37 
    38 // ______________________________________________________________________________
    39 //
    40 inline TRegistrar_Dtor_TransitionValidator::TRegistrar_Dtor_TransitionValidator(CUnitTestContext& aUTContext)
    41 :TTransitionValidator(aUTContext)
    42 	{
    43 	// Do nothing
    44 	}
    45 
    46 inline TBool TRegistrar_Dtor_TransitionValidator::ValidatePreConditions()
    47 	{
    48 	if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistrar_UnitTestContext&,iUTContext).iRegistrar))
    49 		return EFalse;
    50 	return ETrue;
    51 	}
    52 
    53 inline TBool TRegistrar_Dtor_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
    54 	{
    55 	return ETrue;
    56 	}
    57 
    58 // ______________________________________________________________________________
    59 //
    60 inline TRegistrar_Default_TransitionValidator::TRegistrar_Default_TransitionValidator(CUnitTestContext& aUTContext)
    61 :TTransitionValidator(aUTContext)
    62 	{
    63 	// Do nothing
    64 	}
    65 
    66 inline TBool TRegistrar_Default_TransitionValidator::ValidatePreConditions()
    67 	{
    68 	if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistrar_UnitTestContext&,iUTContext).iRegistrar))
    69 		return EFalse;
    70 	return ETrue;
    71 	}
    72 
    73 inline TBool TRegistrar_Default_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
    74 	{
    75 	if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistrar_UnitTestContext&,iUTContext).iRegistrar))
    76 		return EFalse;
    77 	return ETrue;
    78 	}
    79 
    80 // ______________________________________________________________________________
    81 //
    82 inline TRegistrar_RegisterDiscoveryL_TransitionValidator::TRegistrar_RegisterDiscoveryL_TransitionValidator(CUnitTestContext& aUTContext)
    83 :TTransitionValidator(aUTContext)
    84 	{
    85 	// Do nothing
    86 	}
    87 
    88 inline TBool TRegistrar_RegisterDiscoveryL_TransitionValidator::ValidatePreConditions()
    89 	{
    90 	// Only pre condition is that object is constructed
    91 	if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistrar_UnitTestContext&,iUTContext).iRegistrar))
    92 		return EFalse;
    93 	return ETrue;
    94 	}
    95 
    96 inline TBool TRegistrar_RegisterDiscoveryL_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
    97 	{
    98 	if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistrar_UnitTestContext&, iUTContext).iRegistrar))
    99 		return EFalse;
   100 	return ETrue;
   101 	}
   102 
   103 // ______________________________________________________________________________
   104 //
   105 inline TRegistrar_DriveRemoved_TransitionValidator::TRegistrar_DriveRemoved_TransitionValidator(CUnitTestContext& aUTContext)
   106 :TTransitionValidator(aUTContext)
   107 	{
   108 	// Do nothing
   109 	}
   110 
   111 inline TBool TRegistrar_DriveRemoved_TransitionValidator::ValidatePreConditions()
   112 	{
   113 	if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistrar_UnitTestContext&,iUTContext).iRegistrar))
   114 		return EFalse;
   115 	return ETrue;
   116 	}
   117 
   118 inline TBool TRegistrar_DriveRemoved_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
   119 	{
   120 	//Do a list implementations and check that we get a list unavailable error
   121 	CRegistrar_UnitTestContext& context = REINTERPRET_CAST(CRegistrar_UnitTestContext&, iUTContext);
   122 
   123 	TRAPD(error, context.iRegistryData.ListImplementationsL(context.iInterfaceUid));
   124 	if(error != KEComErrNoInterfaceIdentified)
   125 		{
   126 		return EFalse;
   127 		}
   128 
   129 	if(iUTContext.StateAccessor().InvariantTest(context.iRegistrar))
   130 		return EFalse;
   131 	return ETrue;
   132 	}
   133 
   134 // ______________________________________________________________________________
   135 //
   136 inline TRegistrar_CheckRegWhileDiscovering_TransitionValidator::TRegistrar_CheckRegWhileDiscovering_TransitionValidator(CUnitTestContext& aUTContext)
   137 :TTransitionValidator(aUTContext)
   138 	{
   139 	// Do nothing
   140 	}
   141 
   142 inline TBool TRegistrar_CheckRegWhileDiscovering_TransitionValidator::ValidatePreConditions()
   143 	{
   144 	if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistrar_UnitTestContext&,iUTContext).iRegistrar))
   145 		return EFalse;
   146 	return ETrue;
   147 	}
   148 
   149 inline TBool TRegistrar_CheckRegWhileDiscovering_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
   150 	{
   151 	//Do a list implementations and check that we get a list unavailable error
   152 	CRegistrar_UnitTestContext& context = REINTERPRET_CAST(CRegistrar_UnitTestContext&, iUTContext);
   153 
   154 	TRAPD(error, context.iRegistryData.ListImplementationsL(context.iInterfaceUid));
   155 	if(error != KEComErrListCurrentlyUnavailable)
   156 		{
   157 		_LIT(KCheckRegLeaveMessage, "In PostCondition - ListImplementationsL left with %d (expected KEComErrListCurrentlyUnavailable)");
   158 		context.DataLogger().LogInformationWithParameters(KCheckRegLeaveMessage, error);
   159 		return EFalse;
   160 		}
   161 
   162 	if(iUTContext.StateAccessor().InvariantTest(context.iRegistrar))
   163 		return EFalse;
   164 	return ETrue;
   165 	}
   166 
   167 // ______________________________________________________________________________
   168 //
   169 inline TRegistrar_NewLHasContent_TransitionValidator::TRegistrar_NewLHasContent_TransitionValidator(CUnitTestContext& aUTContext)
   170 :TTransitionValidator(aUTContext)
   171 	{
   172 	// Do nothing
   173 	}
   174 
   175 inline TBool TRegistrar_NewLHasContent_TransitionValidator::ValidatePreConditions()
   176 	{
   177 	return ETrue;
   178 	}
   179 
   180 inline TBool TRegistrar_NewLHasContent_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
   181 	{
   182 	// If this validation fails it is probably because there are no registered 
   183 	// interfaces.  This is most likely because the idx file is not valid.
   184 
   185 	CRegistrar_UnitTestContext& context = REINTERPRET_CAST(CRegistrar_UnitTestContext&, iUTContext);
   186 
   187 	TRAPD(error, context.iRegistryData.ListImplementationsL(context.iInterfaceUid));
   188 	if(error == KEComErrNoInterfaceIdentified)
   189 		{
   190 		// Then the index hasn't been rebuilt so
   191 		return EFalse;
   192 		}
   193 
   194 	if(iUTContext.StateAccessor().InvariantTest(context.iRegistrar))
   195 		return EFalse;
   196 	return ETrue;
   197 	}
   198