mmappfw_plat/mpx_common_api/tsrc/ui_commontestclass/src/testmpxpskeywatcher.cpp
changeset 0 a2952bb97e68
equal deleted inserted replaced
-1:000000000000 0:a2952bb97e68
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  MPXPSKeyWatcher testing implementation (mpxcollectiontype.h)
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <s32mem.h>
       
    20 #include "commontestclass.h"
       
    21 
       
    22 // Begin CMPXPSKeyWatcher testing implementation (mpxcollectiontype.h)=======================================
       
    23 // -----------------------------------------------------------------------------
       
    24 // CCommonTestClass::CreateCMPXPSKeyWatcherL()
       
    25 // Returns: Symbian OS errors.
       
    26 // -----------------------------------------------------------------------------
       
    27 TInt CCommonTestClass::CreateCMPXPSKeyWatcherL()
       
    28     {
       
    29 	FTRACE(FPrint(_L("CCommonTestClass::CreateCMPXPSKeyWatcherL testing CMPXPSKeyWatcher::CMPXPSKeyWatcher() begin")));
       
    30     iLog->Log(_L("CCommonTestClass::CreateCMPXPSKeyWatcherL testing CMPXPSKeyWatcher::CMPXPSKeyWatcher() begin"));
       
    31     TInt err = KErrNone;
       
    32     if ( iPSWatcher != NULL)
       
    33         {
       
    34         delete iPSWatcher;
       
    35         }
       
    36     iPSWatcher = NULL;
       
    37     TUid  KMmcEjectAppUid = { 0x101FFAFC };
       
    38     TUint KKeyMmcEjectOperation = 10;
       
    39     iPSWatcher = CMPXPSKeyWatcher::NewL(KMmcEjectAppUid, 
       
    40                                             KKeyMmcEjectOperation,
       
    41                                             this );
       
    42     if ( iPSWatcher == NULL)
       
    43         {
       
    44         err = KErrNotFound;
       
    45         }
       
    46 	FTRACE(FPrint(_L("CCommonTestClass::CreateCMPXPSKeyWatcherL testing CMPXPSKeyWatcher::CMPXPSKeyWatcher() end err=%d"), err));
       
    47     iLog->Log(_L("CCommonTestClass::CreateCMPXPSKeyWatcherL testing CMPXPSKeyWatcher::CMPXPSKeyWatcher() end err=%d"), err);
       
    48 	return err;
       
    49     }
       
    50 
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CCommonTestClass::DeleteCMPXPSKeyWatcherL()
       
    54 // Returns: Symbian OS errors.
       
    55 // -----------------------------------------------------------------------------
       
    56 TInt CCommonTestClass::DeleteCMPXPSKeyWatcherL()
       
    57     {
       
    58 	FTRACE(FPrint(_L("CCommonTestClass::DeleteCMPXPSKeyWatcherL testing CMPXPSKeyWatcherL::~ begin")));
       
    59     iLog->Log(_L("CCommonTestClass::DeleteCMPXPSKeyWatcherL testing CMPXPSKeyWatcherL::~ begin"));
       
    60     TInt err = KErrNone;
       
    61     delete iPSWatcher;
       
    62     iPSWatcher = NULL;
       
    63 	FTRACE(FPrint(_L("CCommonTestClass::DeleteCMPXPSKeyWatcherL testing CMPXPSKeyWatcherL::~ end=%d"), err));
       
    64     iLog->Log(_L("CCommonTestClass::DeleteCMPXPSKeyWatcherL testing CMPXPSKeyWatcherL::~ end=%d"), err);
       
    65 	return err;
       
    66     }
       
    67 
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CCommonTestClass::GetTntValue()
       
    71 // Returns: Symbian OS errors.
       
    72 // -----------------------------------------------------------------------------
       
    73 TInt CCommonTestClass::GetTntValue()
       
    74     {
       
    75 	FTRACE(FPrint(_L("CCommonTestClass::GetTntValue testing CMPXPSKeyWatcher::GetValue begin")));
       
    76     iLog->Log(_L("CCommonTestClass::GetTntValue testing CMPXPSKeyWatcher::GetValue begin"));
       
    77     TInt err = KErrNone;
       
    78 
       
    79     if ( iPSWatcher != NULL )
       
    80         {
       
    81         TInt value;
       
    82         iPSWatcher->GetValue( value );
       
    83     	FTRACE(FPrint(_L("CCommonTestClass::GetTntValue %d"), value));
       
    84         iLog->Log(_L("CCommonTestClass::GetTntValue %d"), value);
       
    85         }
       
    86     else
       
    87         {
       
    88         err = KErrBadTestParameter;
       
    89     	FTRACE(FPrint(_L("CCommonTestClass::GetTntValue Stif test script is wrong.")));
       
    90         iLog->Log(_L("CCommonTestClass::GetTntValue Stif test script is wrong."));
       
    91         }
       
    92 
       
    93 
       
    94 	FTRACE(FPrint(_L("CCommonTestClass::GetTntValue testing CMPXPSKeyWatcher::GetValue end err=%d"), err));
       
    95     iLog->Log(_L("CCommonTestClass::GetTntValue testing CMPXPSKeyWatcher::GetValue end err=%d"), err);
       
    96 	return err;
       
    97     }
       
    98     
       
    99 
       
   100 // -----------------------------------------------------------------------------
       
   101 // CCommonTestClass::GetDes8Value()
       
   102 // Returns: Symbian OS errors.
       
   103 // -----------------------------------------------------------------------------
       
   104 TInt CCommonTestClass::GetDes8Value()
       
   105     {
       
   106 	FTRACE(FPrint(_L("CCommonTestClass::GetDes8Value testing CMPXPSKeyWatcher::GetValue begin")));
       
   107     iLog->Log(_L("CCommonTestClass::GetDes8Value testing CMPXPSKeyWatcher::GetValue begin"));
       
   108     TInt err = KErrNone;
       
   109 
       
   110     if ( iPSWatcher != NULL )
       
   111         {
       
   112         TBuf8<20> value;
       
   113         iPSWatcher->GetValue( value );            
       
   114     	FTRACE(FPrint(_L("CCommonTestClass::GetDes8Value")));
       
   115         iLog->Log(_L("CCommonTestClass::GetDes8Value"));
       
   116         }
       
   117     else
       
   118         {
       
   119         err = KErrBadTestParameter;
       
   120     	FTRACE(FPrint(_L("CCommonTestClass::GetDes8Value Stif test script is wrong.")));
       
   121         iLog->Log(_L("CCommonTestClass::GetDes8Value Stif test script is wrong."));
       
   122         }
       
   123 
       
   124 	FTRACE(FPrint(_L("CCommonTestClass::GetDes8Value testing CMPXPSKeyWatcher::GetValue end err=%d"), err));
       
   125     iLog->Log(_L("CCommonTestClass::GetDes8Value testing CMPXPSKeyWatcher::GetValue end err=%d"), err);
       
   126 	return err;
       
   127     }
       
   128     
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // CCommonTestClass::GetDes8Value()
       
   132 // Returns: Symbian OS errors.
       
   133 // -----------------------------------------------------------------------------
       
   134 TInt CCommonTestClass::GetDes16Value()
       
   135     {
       
   136 	FTRACE(FPrint(_L("CCommonTestClass::GetDes16Value testing CMPXPSKeyWatcher::GetValue begin")));
       
   137     iLog->Log(_L("CCommonTestClass::GetDes16Value testing CMPXPSKeyWatcher::GetValue begin"));
       
   138     TInt err = KErrNone;
       
   139 
       
   140     if ( iPSWatcher != NULL )
       
   141         {
       
   142         TBuf16<20> value;
       
   143         iPSWatcher->GetValue( value );            
       
   144     	FTRACE(FPrint(_L("CCommonTestClass::GetDes16Value")));
       
   145         iLog->Log(_L("CCommonTestClass::GetDes16Value"));
       
   146         }
       
   147     else
       
   148         {
       
   149         err = KErrBadTestParameter;
       
   150     	FTRACE(FPrint(_L("CCommonTestClass::GetDes16Value Stif test script is wrong.")));
       
   151         iLog->Log(_L("CCommonTestClass::GetDes16Value Stif test script is wrong."));
       
   152         }
       
   153 
       
   154 	FTRACE(FPrint(_L("CCommonTestClass::GetDes16Value testing CMPXPSKeyWatcher::GetValue end err=%d"), err));
       
   155     iLog->Log(_L("CCommonTestClass::GetDes16Value testing CMPXPSKeyWatcher::GetValue end err=%d"), err);
       
   156 	return err;
       
   157     }
       
   158 
       
   159 
       
   160 // -----------------------------------------------------------------------------
       
   161 // CCommonTestClass::SetTntValue()
       
   162 // Returns: Symbian OS errors.
       
   163 // -----------------------------------------------------------------------------
       
   164 TInt CCommonTestClass::SetTntValue()
       
   165     {
       
   166 	FTRACE(FPrint(_L("CCommonTestClass::SetTntValue testing CMPXPSKeyWatcher::SetValue begin")));
       
   167     iLog->Log(_L("CCommonTestClass::SetTntValue testing CMPXPSKeyWatcher::SetValue begin"));
       
   168     TInt err = KErrNone;
       
   169 
       
   170     if ( iPSWatcher != NULL )
       
   171         {
       
   172         TInt value = 2;
       
   173         iPSWatcher->SetValue( value );
       
   174     	FTRACE(FPrint(_L("CCommonTestClass::SetTntValue")));
       
   175         iLog->Log(_L("CCommonTestClass::SetTntValue"));
       
   176         }
       
   177     else
       
   178         {
       
   179         err = KErrBadTestParameter;
       
   180     	FTRACE(FPrint(_L("CCommonTestClass::SetTntValue Stif test script is wrong.")));
       
   181         iLog->Log(_L("CCommonTestClass::SetTntValue Stif test script is wrong."));
       
   182         }
       
   183 
       
   184 
       
   185 	FTRACE(FPrint(_L("CCommonTestClass::SetTntValue testing CMPXPSKeyWatcher::SetValue end err=%d"), err));
       
   186     iLog->Log(_L("CCommonTestClass::SetTntValue testing CMPXPSKeyWatcher::SetValue end err=%d"), err);
       
   187 	return err;
       
   188     }
       
   189     
       
   190 
       
   191 // -----------------------------------------------------------------------------
       
   192 // CCommonTestClass::SetDes8Value()
       
   193 // Returns: Symbian OS errors.
       
   194 // -----------------------------------------------------------------------------
       
   195 TInt CCommonTestClass::SetDes8Value()
       
   196     {
       
   197 	FTRACE(FPrint(_L("CCommonTestClass::SetDes8Value testing CMPXPSKeyWatcher::SetValue begin")));
       
   198     iLog->Log(_L("CCommonTestClass::SetDes8Value testing CMPXPSKeyWatcher::SetValue begin"));
       
   199     TInt err = KErrNone;
       
   200 
       
   201     if ( iPSWatcher != NULL )
       
   202         {
       
   203         TBuf8<20> value = _L8("test");
       
   204         iPSWatcher->SetValue( value );            
       
   205     	FTRACE(FPrint(_L("CCommonTestClass::SetDes8Value")));
       
   206         iLog->Log(_L("CCommonTestClass::SetDes8Value"));
       
   207         }
       
   208     else
       
   209         {
       
   210         err = KErrBadTestParameter;
       
   211     	FTRACE(FPrint(_L("CCommonTestClass::SetDes8Value Stif test script is wrong.")));
       
   212         iLog->Log(_L("CCommonTestClass::SetDes8Value Stif test script is wrong."));
       
   213         }
       
   214 
       
   215 	FTRACE(FPrint(_L("CCommonTestClass::SetDes8Value testing CMPXPSKeyWatcher::SetValue end err=%d"), err));
       
   216     iLog->Log(_L("CCommonTestClass::SetDes8Value testing CMPXPSKeyWatcher::SetValue end err=%d"), err);
       
   217 	return err;
       
   218     }
       
   219     
       
   220 
       
   221 // -----------------------------------------------------------------------------
       
   222 // CCommonTestClass::SetDes16Value()
       
   223 // Returns: Symbian OS errors.
       
   224 // -----------------------------------------------------------------------------
       
   225 TInt CCommonTestClass::SetDes16Value()
       
   226     {
       
   227 	FTRACE(FPrint(_L("CCommonTestClass::SetDes16Value testing CMPXPSKeyWatcher::SetValue begin")));
       
   228     iLog->Log(_L("CCommonTestClass::SetDes16Value testing CMPXPSKeyWatcher::SetValue begin"));
       
   229     TInt err = KErrNone;
       
   230 
       
   231     if ( iPSWatcher != NULL )
       
   232         {
       
   233         TBuf16<20> value = _L("test");
       
   234         iPSWatcher->SetValue( value );            
       
   235     	FTRACE(FPrint(_L("CCommonTestClass::SetDes16Value")));
       
   236         iLog->Log(_L("CCommonTestClass::SetDes16Value"));
       
   237         }
       
   238     else
       
   239         {
       
   240         err = KErrBadTestParameter;
       
   241     	FTRACE(FPrint(_L("CCommonTestClass::SetDes16Value Stif test script is wrong.")));
       
   242         iLog->Log(_L("CCommonTestClass::SetDes16Value Stif test script is wrong."));
       
   243         }
       
   244 
       
   245 	FTRACE(FPrint(_L("CCommonTestClass::SetDes16Value testing CMPXPSKeyWatcher::SetValue end err=%d"), err));
       
   246     iLog->Log(_L("CCommonTestClass::SetDes16Value testing CMPXPSKeyWatcher::SetValue end err=%d"), err);
       
   247 	return err;
       
   248     }
       
   249 
       
   250     
       
   251 void CCommonTestClass::HandlePSEvent(TUid /*aUid*/, TInt /*aKey*/)
       
   252     {
       
   253     }