mmappfw_plat/mpx_common_api/tsrc/ui_commontestclass/src/testcenrepwatcher.cpp
changeset 0 a2952bb97e68
child 1 7f2202662322
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:  MPXCenRepWatcher testing implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <mpxprivatecrkeys.h>
       
    20 #include <mpxcenrepobserver.h>
       
    21 #include <mpxcenrepwatcher.h>
       
    22 
       
    23 #include "commontestclass.h"
       
    24 
       
    25 // Begin CMPXCenRepWatcher testing implementation (mpxcenrepwatcher.h)=======================================
       
    26 // -----------------------------------------------------------------------------
       
    27 // CCommonTestClass::CreateCenRepWatcherL()
       
    28 // Returns: Symbian OS errors.
       
    29 // -----------------------------------------------------------------------------
       
    30 TInt CCommonTestClass::CreateCenRepWatcherL()
       
    31     {
       
    32 	FTRACE(FPrint(_L("CCommonTestClass::CreateCenRepWatcherL testing CMPXCenRepWatcher::NewL begin")));
       
    33     iLog->Log(_L("CCommonTestClass::CreateCenRepWatcherL testing CMPXCenRepWatcher::NewL begin"));
       
    34     TInt err = KErrNone;
       
    35     if ( iCenRepWatcher != NULL)
       
    36         {
       
    37         delete iCenRepWatcher;
       
    38         }
       
    39     iCenRepWatcher = NULL;
       
    40     iCenRepWatcher = CMPXCenRepWatcher::NewL(KCRUidMPXSettings, 
       
    41                                              KMPXPlaybackRepeatMode, 
       
    42                                              this);
       
    43     if ( iCenRepWatcher == NULL)
       
    44         {
       
    45         err = KErrNotFound;
       
    46         }
       
    47 	FTRACE(FPrint(_L("CCommonTestClass::CreateCenRepWatcherL testing CMPXCenRepWatcher::NewL end err=%d"), err));
       
    48     iLog->Log(_L("CCommonTestClass::CreateCenRepWatcherL testing CMPXCenRepWatcher::NewL end err=%d"), err);
       
    49 	return err;
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CCommonTestClass::DeleteCenRepWatcherL()
       
    54 // Returns: Symbian OS errors.
       
    55 // -----------------------------------------------------------------------------
       
    56 TInt CCommonTestClass::DeleteCenRepWatcherL()
       
    57     {
       
    58 	FTRACE(FPrint(_L("CCommonTestClass::DeleteCenRepWatcherL testing CMPXCenRepWatcher::~ begin")));
       
    59     iLog->Log(_L("CCommonTestClass::DeleteCenRepWatcherL testing CMPXCenRepWatcher::~ begin"));
       
    60     TInt err = KErrNone;
       
    61     delete iCenRepWatcher;
       
    62     iCenRepWatcher = NULL;
       
    63 	FTRACE(FPrint(_L("CCommonTestClass::DeleteCenRepWatcherL testing CMPXCenRepWatcher::~ end err=%d"), err));
       
    64     iLog->Log(_L("CCommonTestClass::DeleteCenRepWatcherL testing CMPXCenRepWatcher::~ end err=%d"), err);
       
    65 	return err;
       
    66     }
       
    67 
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CCommonTestClass::HandleSettingChange()
       
    71 // Returns: None
       
    72 // -----------------------------------------------------------------------------
       
    73 void CCommonTestClass::HandleSettingChange(const TUid& /*aRepositoryUid*/,
       
    74                                          TUint32 /*aSettingId*/)
       
    75     {
       
    76     }
       
    77 
       
    78 
       
    79 TInt CCommonTestClass::CenRepCurrentValueL( CStifItemParser& aItem )
       
    80     {
       
    81 	FTRACE(FPrint(_L("CCommonTestClass::CenRepCurrentValueL testing CMPXCenRepWatcher::CurrentValueL begin")));
       
    82     iLog->Log(_L("CCommonTestClass::CenRepCurrentValueL testing CMPXCenRepWatcher::CurrentValueL begin"));
       
    83     TInt mode = 0;
       
    84     TRAPD(err, mode = iCenRepWatcher->CurrentValueL());
       
    85 
       
    86 	FTRACE(FPrint(_L("CCommonTestClass::CenRepCurrentValueL current value = %d"), mode ));
       
    87     iLog->Log(_L("CCommonTestClass::CenRepCurrentValueL current value = %d"), mode );
       
    88 
       
    89 	TPtrC checkType;
       
    90 	TPtrC operand;
       
    91 	TInt  expectedvalue;
       
    92 
       
    93 	if ( ( KErrNone == err) &&
       
    94 	        (KErrNone == aItem.GetNextString(checkType) ) &&
       
    95         	(KErrNone == aItem.GetNextString(operand) ) &&
       
    96         	(KErrNone ==  aItem.GetNextInt(expectedvalue) ) )
       
    97     	{
       
    98 		if (( operand == KTagCompareEqual) && 
       
    99 		    ( checkType == KTagvalue ) )
       
   100     		{
       
   101 			if ( mode == expectedvalue )
       
   102 			    {
       
   103 			    err = KErrNone;
       
   104             	FTRACE(FPrint(_L("CCommonTestClass::CenRepCurrentValueL current value matches expectation")));
       
   105                 iLog->Log(_L("CCommonTestClass::CenRepCurrentValueL current value matches expectation"));
       
   106 			    }
       
   107 			else
       
   108 			    {
       
   109 			    err = KErrGeneral;
       
   110             	FTRACE(FPrint(_L("CCommonTestClass::CenRepCurrentValueL current value does not matche expectation")));
       
   111                 iLog->Log(_L("CCommonTestClass::CenRepCurrentValueL current value does not matche expectation"));
       
   112 			    }
       
   113 	    	}
       
   114 	    else
       
   115 	        {
       
   116             err = KErrBadTestParameter;
       
   117         	FTRACE(FPrint(_L("CCommonTestClass::CenRepCurrentValueL Stif test script is wrong.")));
       
   118             iLog->Log(_L("CCommonTestClass::CenRepCurrentValueL Stif test script is wrong."));
       
   119 	        }
       
   120     	}
       
   121     else
       
   122         {
       
   123         err = KErrBadTestParameter;
       
   124     	FTRACE(FPrint(_L("CCommonTestClass::CenRepCurrentValueL Stif test script is wrong.")));
       
   125         iLog->Log(_L("CCommonTestClass::CenRepCurrentValueL Stif test script is wrong."));
       
   126         }
       
   127 
       
   128 
       
   129 	FTRACE(FPrint(_L("CCommonTestClass::CenRepCurrentValueL testing CMPXCenRepWatcher::CurrentValueL end=%d"), err));
       
   130     iLog->Log(_L("CCommonTestClass::CenRepCurrentValueL testing CMPXCenRepWatcher::CurrentValueL end=%d"), err);
       
   131 
       
   132     return err;
       
   133     }
       
   134 
       
   135 
       
   136 TInt CCommonTestClass::CenRepSetValueL( CStifItemParser& aItem )
       
   137     {
       
   138 	FTRACE(FPrint(_L("CCommonTestClass::CenRepSetValueL testing CMPXCenRepWatcher::SetValueL begin")));
       
   139     iLog->Log(_L("CCommonTestClass::CenRepSetValueL testing CMPXCenRepWatcher::SetValueL begin"));
       
   140 
       
   141     TInt mode = 0;
       
   142     TRAPD(err, mode = iCenRepWatcher->CurrentValueL());
       
   143 
       
   144 	FTRACE(FPrint(_L("CCommonTestClass::CenRepSetValueL current value = %d"), mode ));
       
   145     iLog->Log(_L("CCommonTestClass::CenRepSetValueL current value = %d"), mode );
       
   146 
       
   147 	TInt newValue;
       
   148     if ( !aItem.GetNextInt(newValue) )
       
   149         {
       
   150         TRAP(err, iCenRepWatcher->SetValueL(newValue));
       
   151         
       
   152         if ( ( mode = iCenRepWatcher->CurrentValueL()) != newValue )
       
   153             {
       
   154             err = KErrGeneral;
       
   155             }
       
   156     
       
   157     	FTRACE(FPrint(_L("CCommonTestClass::CenRepSetValueL after setting value = %d"), mode ));
       
   158         iLog->Log(_L("CCommonTestClass::CenRepSetValueL after setting value = %d"), mode );
       
   159         }
       
   160     else
       
   161         {
       
   162     	FTRACE(FPrint(_L("CCommonTestClass::CenRepSetValueL failed reading parameter from STIF")));
       
   163         iLog->Log(_L("CCommonTestClass::CenRepSetValueL failed reading parameter from STIF"));
       
   164         err = KErrBadTestParameter;
       
   165         }
       
   166     
       
   167 	FTRACE(FPrint(_L("CCommonTestClass::CenRepSetValueL testing CMPXCenRepWatcher::CenRepSetValueL~ end=%d"), err));
       
   168     iLog->Log(_L("CCommonTestClass::CenRepSetValueL testing CMPXCenRepWatcher::CenRepSetValueL end=%d"), err);
       
   169     return err;
       
   170     }
       
   171 
       
   172 // end of CMPXCenRepWatcher (mpxcenrepwatcher.h =============================================
       
   173     
       
   174