mmappfw_plat/mpx_common_api/tsrc/ui_commontestclass/src/testmpxparameter.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:  MPXParameter testing implementation (mpxparameter.h)
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <s32mem.h>
       
    20 #include "commontestclass.h"
       
    21 
       
    22 #define KMPXPluginTypePlaybackUid           0x101FFCA0
       
    23 
       
    24 // Begin CMPXParameter testing implementation (mpxparameter.h)=======================================
       
    25 // -----------------------------------------------------------------------------
       
    26 // CCommonTestClass::CreateMPXParameterL()
       
    27 // Returns: Symbian OS errors.
       
    28 // -----------------------------------------------------------------------------
       
    29 TInt CCommonTestClass::CreateMPXParameter()
       
    30     {
       
    31 	FTRACE(FPrint(_L("CCommonTestClass::CreateMPXParameterL testing CMPXParameter::CMPXParameter() begin")));
       
    32     iLog->Log(_L("CCommonTestClass::CreateMPXParameterL testing CMPXParameter::CMPXParameter() begin"));
       
    33     TInt err = KErrNone;
       
    34     if ( iParameter != NULL)
       
    35         {
       
    36         delete iParameter;
       
    37         }
       
    38     iParameter = NULL;
       
    39     TRAP(err , iParameter = new ( ELeave ) CMPXParameter());
       
    40     if ( iParameter == NULL)
       
    41         {
       
    42         err = KErrNotFound;
       
    43         }
       
    44 	FTRACE(FPrint(_L("CCommonTestClass::CreateMPXParameterL testing CMPXParameter::CMPXParameter() end err=%d"), err));
       
    45     iLog->Log(_L("CCommonTestClass::CreateMPXParameterL testing CMPXParameter::CMPXParameter() end err=%d"), err);
       
    46 	return err;
       
    47     }
       
    48 
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // CCommonTestClass::DeleteMPXParameterL()
       
    52 // Returns: Symbian OS errors.
       
    53 // -----------------------------------------------------------------------------
       
    54 TInt CCommonTestClass::DeleteMPXParameter()
       
    55     {
       
    56 	FTRACE(FPrint(_L("CCommonTestClass::DeleteMPXParameterL testing CMPXParameter::~ begin")));
       
    57     iLog->Log(_L("CCommonTestClass::DeleteMPXParameterL testing CMPXParameter::~ begin"));
       
    58     TInt err = KErrNone;
       
    59     delete iParameter;
       
    60     iParameter = NULL;
       
    61 	FTRACE(FPrint(_L("CCommonTestClass::DeleteMPXParameterL testing CMPXParameter::~ end err=%d"), err));
       
    62     iLog->Log(_L("CCommonTestClass::DeleteMPXParameterL testing CMPXParameter::~ end err=%d"), err);
       
    63 	return err;
       
    64     }
       
    65 
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CCommonTestClass::InternalizeMPXParameterL()
       
    69 // Returns: Symbian OS errors.
       
    70 // -----------------------------------------------------------------------------
       
    71 TInt CCommonTestClass::InternalizeMPXParameterL()
       
    72     {
       
    73 	FTRACE(FPrint(_L("CCommonTestClass::InternalizeMPXParameterL testing CMPXParameter::InternalizeMPXParameterL begin")));
       
    74     iLog->Log(_L("CCommonTestClass::InternalizeMPXParameterL testing CMPXParameter::InternalizeMPXParameterL begin"));
       
    75     TInt err = KErrNone;
       
    76 
       
    77     if ( iParameter != NULL )
       
    78         {
       
    79     	FTRACE(FPrint(_L("CCommonTestClass::InternalizeMPXParameterL started Internalize")));
       
    80         iLog->Log(_L("CCommonTestClass::InternalizeMPXParameterL started Internalize"));
       
    81         CBufBase* buffer = CBufFlat::NewL( 50 );
       
    82         CleanupStack::PushL( buffer );
       
    83         RBufWriteStream writeStream( *buffer );
       
    84         CleanupClosePushL( writeStream );
       
    85         iParameter->ExternalizeL( writeStream );
       
    86         writeStream.CommitL();
       
    87         buffer->Compress();
       
    88         CleanupStack::PopAndDestroy( &writeStream );
       
    89 
       
    90         RBufReadStream readStream( *buffer );
       
    91         CleanupClosePushL( readStream );                
       
    92         iParameter = new ( ELeave ) CMPXParameter();        
       
    93         iParameter->InternalizeL( readStream );
       
    94         CleanupStack::PopAndDestroy( &readStream );
       
    95         CleanupStack::PopAndDestroy( buffer );
       
    96         }
       
    97     else
       
    98         {
       
    99         err = KErrBadTestParameter;
       
   100     	FTRACE(FPrint(_L("CCommonTestClass::InternalizeMPXParameterL Stif test script is wrong.")));
       
   101         iLog->Log(_L("CCommonTestClass::InternalizeMPXParameterL Stif test script is wrong."));
       
   102         }
       
   103 
       
   104 
       
   105 	FTRACE(FPrint(_L("CCommonTestClass::InternalizeMPXParameterL testing CMPXParameter::InternalizeMPXParameterL end err=%d"), err));
       
   106     iLog->Log(_L("CCommonTestClass::InternalizeMPXParameterL testing CMPXParameter::InternalizeMPXParameterL end err=%d"), err);
       
   107 	return err;
       
   108     }
       
   109     
       
   110 // -----------------------------------------------------------------------------
       
   111 // CCommonTestClass::ExternalizeMPXParameterL()
       
   112 // Returns: Symbian OS errors.
       
   113 // -----------------------------------------------------------------------------
       
   114 TInt CCommonTestClass::ExternalizeMPXParameterL()
       
   115     {
       
   116 	FTRACE(FPrint(_L("CCommonTestClass::ExternalizeMPXParameterL testing CMPXParameter::ExternalizeMPXParameterL begin")));
       
   117     iLog->Log(_L("CCommonTestClass::ExternalizeMPXParameterL testing CMPXParameter::ExternalizeMPXParameterL begin"));
       
   118     TInt err = KErrNone;
       
   119     if ( iParameter != NULL )
       
   120         {
       
   121         iParameter->iType.iUid = KMPXPluginTypePlaybackUid;
       
   122         iParameter->iCmdForward = EMPXCmdFwdNone;
       
   123     
       
   124     	FTRACE(FPrint(_L("CCommonTestClass::ExternalizeMPXParameterL started Externalize")));
       
   125         iLog->Log(_L("CCommonTestClass::ExternalizeMPXParameterL started Externalize"));
       
   126         CBufBase* buffer = CBufFlat::NewL( 50 );
       
   127         CleanupStack::PushL( buffer );
       
   128         RBufWriteStream writeStream( *buffer );
       
   129         CleanupClosePushL( writeStream );
       
   130         iParameter->ExternalizeL( writeStream );
       
   131         writeStream.CommitL();
       
   132         buffer->Compress();
       
   133         CleanupStack::PopAndDestroy( &writeStream );
       
   134         CleanupStack::PopAndDestroy( buffer ); 
       
   135         }
       
   136     else
       
   137         {
       
   138         err = KErrBadTestParameter;
       
   139     	FTRACE(FPrint(_L("CCommonTestClass::ExternalizeMPXParameterL Stif test script is wrong.")));
       
   140         iLog->Log(_L("CCommonTestClass::ExternalizeMPXParameterL Stif test script is wrong."));
       
   141         }
       
   142 	FTRACE(FPrint(_L("CCommonTestClass::ExternalizeMPXParameterL testing CMPXParameter::ExternalizeMPXParameterL end err=%d"), err));
       
   143     iLog->Log(_L("CCommonTestClass::ExternalizeMPXParameterL testing CMPXParameter::ExternalizeMPXParameterL end err=%d"), err);
       
   144 	return err;
       
   145     }
       
   146 
       
   147 
       
   148     
       
   149