buildverification/autosmoketest/Utils/Src/SmokeTestProperty.cpp
branchRCL_3
changeset 20 493058e57c8c
parent 0 9736f095102e
equal deleted inserted replaced
19:4ca382093dae 20:493058e57c8c
       
     1 // Copyright (c) 2004-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 // This contains CTestProperty
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "SmokeTestProperty.h"
       
    19 
       
    20 // EPOC32 include
       
    21 #include <e32base.h>
       
    22 
       
    23 EXPORT_C CTestProperty::CTestProperty(CTestStep& aTestStep)
       
    24 :	CBase()
       
    25 ,	iTestStep(aTestStep)
       
    26 	{
       
    27 	}
       
    28 
       
    29 EXPORT_C CTestProperty::~CTestProperty()
       
    30 	{
       
    31 	}
       
    32 
       
    33 EXPORT_C TInt CTestProperty::SetPropertyL(const TUid aCategory, const TInt aKey, const TInt aValue)
       
    34 	{
       
    35 	//Define the property, in case it is being used for the first time.
       
    36 	TInt	ret=RProperty::Define(aCategory, aKey, RProperty::EInt);
       
    37 	if ( (ret==KErrNone) || (ret== KErrAlreadyExists) )
       
    38 		{
       
    39 		//Attach to the property so that you can track any chnages to it.
       
    40 		ret=iProperty.Attach(aCategory, aKey);
       
    41 		if ( ret==KErrNone )
       
    42 			{
       
    43 			//Set the new test number and wait until the change is in effect.
       
    44 			TRequestStatus	status;
       
    45 			iProperty.Subscribe(status);
       
    46 			ret=iProperty.Set(aCategory, aKey, aValue);
       
    47 			if ( ret==KErrNone )
       
    48 				{
       
    49 				User::WaitForRequest(status);
       
    50 				ret=status.Int();
       
    51 				if ( ret != KErrNone )
       
    52 					{
       
    53 					iTestStep.INFO_PRINTF2(_L("request complete error=%d"), ret);
       
    54 					}
       
    55 				}
       
    56 			else
       
    57 				{
       
    58 				iTestStep.INFO_PRINTF2(_L("RProperty::Set error=%d"), ret);
       
    59 				}
       
    60 			iProperty.Close();
       
    61 			}
       
    62 		else
       
    63 			{
       
    64 			iTestStep.INFO_PRINTF2(_L("RProperty::Attach error=%d"), ret);
       
    65 			}
       
    66 		}
       
    67 	else
       
    68 		{
       
    69 		iTestStep.INFO_PRINTF2(_L("RProperty::Define error=%d"), ret);
       
    70 		}
       
    71 
       
    72 	return ret;
       
    73 	}
       
    74 
       
    75 EXPORT_C TInt CTestProperty::SetPropertyL(const TUid aCategory, const TInt aKey, const TDesC8& aValue)
       
    76 	{
       
    77 	//Define the property, in case it is being used for the first time.
       
    78 	TInt	ret=RProperty::Define(aCategory, aKey, RProperty::EByteArray);
       
    79 	if ( (ret==KErrNone) || (ret== KErrAlreadyExists) )
       
    80 		{
       
    81 		//Attach to the property so that you can track any chnages to it.
       
    82 		ret=iProperty.Attach(aCategory, aKey);
       
    83 		if ( ret==KErrNone )
       
    84 			{
       
    85 			//Set the new test number and wait until the change is in effect.
       
    86 			TRequestStatus	status;
       
    87 			iProperty.Subscribe(status);
       
    88 			ret=iProperty.Set(aCategory, aKey, aValue);
       
    89 			if ( ret==KErrNone )
       
    90 				{
       
    91 				User::WaitForRequest(status);
       
    92 				ret=status.Int();
       
    93 				}
       
    94 			iProperty.Close();
       
    95 			}
       
    96 		}
       
    97 
       
    98 	return ret;
       
    99 	}
       
   100 
       
   101 EXPORT_C TInt CTestProperty::SetPropertyL(const TUid aCategory, const TInt aKey, const TDesC16& aValue)
       
   102 	{
       
   103 	//Define the property, in case it is being used for the first time.
       
   104 	TInt	ret=RProperty::Define(aCategory, aKey, RProperty::EText);
       
   105 	if ( (ret==KErrNone) || (ret== KErrAlreadyExists) )
       
   106 		{
       
   107 		//Attach to the property so that you can track any chnages to it.
       
   108 		ret=iProperty.Attach(aCategory, aKey);
       
   109 		if ( ret==KErrNone )
       
   110 			{
       
   111 			//Set the new test number and wait until the change is in effect.
       
   112 			TRequestStatus	status;
       
   113 			iProperty.Subscribe(status);
       
   114 			ret=iProperty.Set(aCategory, aKey, aValue);
       
   115 			if ( ret==KErrNone )
       
   116 				{
       
   117 				User::WaitForRequest(status);
       
   118 				ret=status.Int();
       
   119 				}
       
   120 			iProperty.Close();
       
   121 			}
       
   122 		}
       
   123 
       
   124 	return ret;
       
   125 	}
       
   126 
       
   127 EXPORT_C TInt CTestProperty::GetPropertyL(const TUid aCategory, const TInt aKey, TInt& aValue)
       
   128 	{
       
   129 	return RProperty::Get(aCategory, aKey, aValue);
       
   130 	}
       
   131 
       
   132 EXPORT_C TInt CTestProperty::GetPropertyL(const TUid aCategory, const TInt aKey, TDes8& aValue)
       
   133 	{
       
   134 	return RProperty::Get(aCategory, aKey, aValue);
       
   135 	}
       
   136 
       
   137 EXPORT_C TInt CTestProperty::GetPropertyL(const TUid aCategory, const TInt aKey, TDes16& aValue)
       
   138 	{
       
   139 	return RProperty::Get(aCategory, aKey, aValue);
       
   140 	}