sysstatemgmt/systemstatereferenceplugins/test/tclayer/src/ssmcmnwrapper.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2008-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 // Contains wrapper helper functions for test code to control the test wrappers 
       
    15 // TSsmStateTransition, TSsmState and RSsmStateManager wrapper methods
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @test
       
    22  @internalComponent - Internal Symbian test code 
       
    23 */
       
    24 
       
    25 #include <ssm/ssmstatetransition.h>
       
    26 #include <test/testexecutestepbase.h>
       
    27 
       
    28 #include "ssmcmnwrapper.h"
       
    29 
       
    30 /*
       
    31  * RSsmStateManager test wrapper functions
       
    32  */
       
    33 
       
    34 TInt RSsmStateManager::Connect()
       
    35 	{
       
    36 	TInt ret = SsmCmnWrapper::SsmStateManagerNextConnectReturn();
       
    37 	if (ret == KErrNone)
       
    38 		{
       
    39 		// Will return success so need to connect the session
       
    40 		// Use an RMutex as the handle to ensure that we are wrapping any uses of the handle
       
    41 		// i.e. attempting to SendAndReceive() on an RMutex will panic
       
    42 		RMutex tempMutex;
       
    43 		ret = tempMutex.CreateLocal();
       
    44 		if(ret != KErrNone)
       
    45 			{
       
    46 			// return the error, the test will fail as it's an unexpected result
       
    47 			}
       
    48 		else
       
    49 			{
       
    50 			// Transfer ownership of tempMutex's handle to this RSsmStateManager
       
    51 			SetHandle(tempMutex.Handle());
       
    52 			// Set the test framework value
       
    53 			SsmCmnWrapper::SetSsmStateManagerHandle(tempMutex.Handle());
       
    54 			}
       
    55 		// Don't close tempMutex before retuning as RSsmStateManager now owns the handle
       
    56 		}
       
    57 	return ret;
       
    58 	}
       
    59 
       
    60 TInt RSsmStateManager::RequestStateTransition(TSsmStateTransition aTransition)
       
    61 	{
       
    62 	TInt ret = SsmCmnWrapper::GetSsmStateManagerNextStateRequestReturn();
       
    63 	if(ret == KErrNone)
       
    64 		{
       
    65 		SsmCmnWrapper::SetLastStateTransition(aTransition);
       
    66 		}
       
    67 	return ret;
       
    68 	}
       
    69 
       
    70 TInt RSsmStateManager::RequestSwpChange(TSsmSwp aSwp)
       
    71 	{
       
    72 	TInt ret = SsmCmnWrapper::GetSsmStateManagerNextSwpRequestReturn();
       
    73 	if(ret == KErrNone)
       
    74 		{
       
    75 		SsmCmnWrapper::SetLastSwpTransition(aSwp);
       
    76 		}
       
    77 	return ret;
       
    78 	}
       
    79 
       
    80 /**
       
    81  * Sets the value that should be returned by RSsmStateManager::Connect()
       
    82  * 
       
    83  * @test
       
    84  * @internalComponent
       
    85  */
       
    86 void SsmCmnWrapper::SetSsmStateManagerNextConnectReturn(TInt aRet)
       
    87 	{
       
    88 	iSsmStateManagerNextConnectReturn = aRet;
       
    89 	}
       
    90 
       
    91 /**
       
    92  * Gets the value that should be returned by RSsmStateManager::Connect()
       
    93  * 
       
    94  * @test
       
    95  * @internalComponent
       
    96  */
       
    97 TInt SsmCmnWrapper::SsmStateManagerNextConnectReturn()
       
    98 	{
       
    99 	return iSsmStateManagerNextConnectReturn;
       
   100 	}
       
   101 
       
   102 /**
       
   103  * Sets the value of the test handle for RSsmStateManager
       
   104  * 
       
   105  * @test
       
   106  * @internalComponent
       
   107  */
       
   108 void SsmCmnWrapper::SetSsmStateManagerHandle(TInt aHandle)
       
   109 	{
       
   110 	iSsmStateManagerHandle = aHandle;
       
   111 	}
       
   112 
       
   113 
       
   114 /**
       
   115  * Gets the value of the test handle for RSsmStateManager
       
   116  * 
       
   117  * @test
       
   118  * @internalComponent
       
   119  */
       
   120 TInt SsmCmnWrapper::SsmStateManagerHandle()
       
   121 	{
       
   122 	return iSsmStateManagerHandle;
       
   123 	}
       
   124 
       
   125 /**
       
   126  * Gets the value that should be returned by RSsmStateManager::RequestStateTransition()
       
   127  * 
       
   128  * @test
       
   129  * @internalComponent
       
   130  */
       
   131 TInt SsmCmnWrapper::GetSsmStateManagerNextStateRequestReturn()
       
   132 	{
       
   133 	return iSsmStateManagerNextRequestReturn;
       
   134 	}
       
   135 
       
   136 /**
       
   137  * Sets the value that should be returned by RSsmStateManager::RequestStateTransition()
       
   138  * 
       
   139  * @test
       
   140  * @internalComponent
       
   141  */
       
   142 void SsmCmnWrapper::SetSsmStateManagerNextStateRequestReturn(TInt aRet)
       
   143 	{
       
   144 	iSsmStateManagerNextRequestReturn = aRet;
       
   145 	}
       
   146 
       
   147 /**
       
   148  * Sets the value of the last state transition for the test handle for RSsmStateManager
       
   149  * 
       
   150  * @test
       
   151  * @internalComponent
       
   152  */
       
   153 void SsmCmnWrapper::SetLastStateTransition(TSsmStateTransition& aTransition)
       
   154 	{
       
   155 	iSsmStateManagerStateTransition = aTransition;
       
   156 	}
       
   157 	
       
   158 /**
       
   159  * Gets the last main state value request of the test handle for RSsmStateManager
       
   160  * 
       
   161  * @test
       
   162  * @internalComponent
       
   163  */
       
   164 TUint16 SsmCmnWrapper::GetLastMainStateRequest()
       
   165 	{
       
   166 	return iSsmStateManagerStateTransition.State().MainState();
       
   167 	}
       
   168 
       
   169 /**
       
   170  * Gets the last sub state value request of the test handle for RSsmStateManager
       
   171  * 
       
   172  * @test
       
   173  * @internalComponent
       
   174  */
       
   175 TUint16 SsmCmnWrapper::GetLastSubStateRequest()
       
   176 	{
       
   177 	return iSsmStateManagerStateTransition.State().SubState();
       
   178 	}
       
   179 
       
   180 /**
       
   181  * Gets the last reason value request of the test handle for RSsmStateManager
       
   182  * 
       
   183  * @test
       
   184  * @internalComponent
       
   185  */
       
   186 TInt SsmCmnWrapper::GetLastReasonRequest()
       
   187 	{
       
   188 	return iSsmStateManagerStateTransition.Reason();
       
   189 	}
       
   190 	
       
   191 /**
       
   192  * Gets the return value for the next SWP transition requested
       
   193  * 
       
   194  * @test
       
   195  * @internalComponent
       
   196  */
       
   197 TInt SsmCmnWrapper::GetSsmStateManagerNextSwpRequestReturn()
       
   198 	{
       
   199 	return iSsmStateManagerNextSwpRequestReturn;
       
   200 	}
       
   201 
       
   202 /**
       
   203  * Sets the return value for the next SWP transition requested
       
   204  * 
       
   205  * @test
       
   206  * @internalComponent
       
   207  */
       
   208 void SsmCmnWrapper::SetSsmStateManagerNextSwpRequestReturn(TInt aRet)
       
   209 	{
       
   210 	iSsmStateManagerNextSwpRequestReturn = aRet;
       
   211 	}
       
   212 
       
   213 /**
       
   214  * Sets the last SWP transition requested
       
   215  * 
       
   216  * @test
       
   217  * @internalComponent
       
   218  */
       
   219 void SsmCmnWrapper::SetLastSwpTransition(TSsmSwp& aSwp)
       
   220 	{
       
   221 	iSsmStateManagerSwpTransition = aSwp;
       
   222 	}
       
   223 
       
   224 /**
       
   225  * Gets the last SWP transition requested
       
   226  * 
       
   227  * @test
       
   228  * @internalComponent
       
   229  */
       
   230 TSsmSwp SsmCmnWrapper::GetLastSwpTransition()
       
   231 	{
       
   232 	return iSsmStateManagerSwpTransition;
       
   233 	}
       
   234 
       
   235 /**
       
   236  * Holds the value to be returned by calls to RSsmStateManager::RequestSwpTransition()
       
   237  * 
       
   238  * @test
       
   239  * @internalComponent
       
   240  */
       
   241 TInt SsmCmnWrapper::iSsmStateManagerNextSwpRequestReturn = KErrNone;
       
   242 
       
   243 /**
       
   244  * Holds the value used in the last SWP transition request
       
   245  * 
       
   246  * @test
       
   247  * @internalComponent
       
   248  */
       
   249 TSsmSwp SsmCmnWrapper::iSsmStateManagerSwpTransition(0,0);
       
   250 
       
   251 /**
       
   252  * Holds the value to be returned by calls to RSsmStateManager::Connect()
       
   253  * 
       
   254  * @test
       
   255  * @internalComponent
       
   256  */
       
   257 TInt SsmCmnWrapper::iSsmStateManagerNextConnectReturn = KErrNone;
       
   258 
       
   259 /**
       
   260  * Holds the value of the test handle for RSsmStateManager
       
   261  * 
       
   262  * @test
       
   263  * @internalComponent
       
   264  */
       
   265 TInt SsmCmnWrapper::iSsmStateManagerHandle = KNullHandle;
       
   266 
       
   267 /**
       
   268  * Holds the value of the last transition requested
       
   269  * 
       
   270  * @test
       
   271  * @internalComponent
       
   272  */ 
       
   273 TSsmStateTransition SsmCmnWrapper::iSsmStateManagerStateTransition;
       
   274 
       
   275 /**
       
   276  * Holds the value to be returned by calls to RSsmStateManager::RequestStateTransition()
       
   277  * 
       
   278  * @test
       
   279  * @internalComponent
       
   280  */
       
   281 TInt SsmCmnWrapper::iSsmStateManagerNextRequestReturn = KErrNone;