mmappfw_plat/mpx_common_api/tsrc/ui_commontestclass/src/testmpxcollectiontype.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: MPXCollectionType testing implementation (mpxcollectiontype.h)
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <s32mem.h>
       
    20 #include "commontestclass.h"
       
    21 
       
    22 // Begin CMPXCollectionType testing implementation (mpxcollectiontype.h)=======================================
       
    23 // -----------------------------------------------------------------------------
       
    24 // CCommonTestClass::CreateMPXCollectionType()
       
    25 // Returns: Symbian OS errors.
       
    26 // -----------------------------------------------------------------------------
       
    27 TInt CCommonTestClass::CreateMPXCollectionType()
       
    28     {
       
    29 	FTRACE(FPrint(_L("CCommonTestClass::CreateMPXCollectionType testing CMPXCollectionType::CMPXCollectionType() begin")));
       
    30     iLog->Log(_L("CCommonTestClass::CreateMPXCollectionType testing CMPXCollectionType::CMPXCollectionType() begin"));
       
    31     TInt err = KErrNone;
       
    32     if ( iType != NULL)
       
    33         {
       
    34         delete iType;
       
    35         }
       
    36     iType = NULL;
       
    37     TRAP(err , iType = new ( ELeave ) CMPXCollectionType());
       
    38     if ( iType == NULL)
       
    39         {
       
    40         err = KErrNotFound;
       
    41         }
       
    42 	FTRACE(FPrint(_L("CCommonTestClass::CreateMPXCollectionType testing CMPXCollectionType::CMPXCollectionType() end err=%d"), err));
       
    43     iLog->Log(_L("CCommonTestClass::CreateMPXCollectionType testing CMPXCollectionType::CMPXCollectionType() end err=%d"), err);
       
    44 	return err;
       
    45     }
       
    46 // -----------------------------------------------------------------------------
       
    47 // CCommonTestClass::CMPXCollectionTypeDelete()
       
    48 // Returns: Symbian OS errors.
       
    49 // add CMPXCollectionTypeDelete to testmpxcollectiontype.cpp 9/19/2008 1:32
       
    50 // -----------------------------------------------------------------------------  
       
    51 TInt CCommonTestClass::CMPXCollectionTypeDelete(CStifItemParser&)
       
    52     {
       
    53     FTRACE(FPrint(_L("CCommonTestClass::CMPXCollectionTypeDelete testing CMPXCollectionType::~ begin")));
       
    54     iLog->Log(_L("CCommonTestClass::CMPXCollectionTypeDelete testing CMPXCollectionType::~ begin"));
       
    55     TInt err = KErrNone;
       
    56     delete iType;
       
    57     iType = NULL;
       
    58     FTRACE(FPrint(_L("CCommonTestClass::CMPXCollectionTypeDelete testing CMPXCollectionType::~ end err=%d"), err));
       
    59     iLog->Log(_L("CCommonTestClass::CMPXCollectionTypeDelete testing CMPXCollectionType::~ end err=%d"), err);
       
    60     return err;
       
    61     }
       
    62 
       
    63 TInt CCommonTestClass::CreateMPXCollectionTypeWOParam()
       
    64     {
       
    65 	FTRACE(FPrint(_L("CCommonTestClass::CreateMPXCollectionType testing CMPXCollectionType::CMPXCollectionType() begin")));
       
    66     iLog->Log(_L("CCommonTestClass::CreateMPXCollectionType testing CMPXCollectionType::CMPXCollectionType() begin"));
       
    67     TInt err = KErrNone;
       
    68     if ( iType != NULL)
       
    69         {
       
    70         delete iType;
       
    71         }
       
    72     iType = NULL;
       
    73     TRAP(err , iType = new ( ELeave ) CMPXCollectionType());
       
    74     if ( iType == NULL)
       
    75         {
       
    76         err = KErrNotFound;
       
    77         }
       
    78 	FTRACE(FPrint(_L("CCommonTestClass::CreateMPXCollectionType testing CMPXCollectionType::CMPXCollectionType() end err=%d"), err));
       
    79     iLog->Log(_L("CCommonTestClass::CreateMPXCollectionType testing CMPXCollectionType::CMPXCollectionType() end err=%d"), err);
       
    80 	return err;
       
    81     }
       
    82 
       
    83 
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CCommonTestClass::InternalizeMPXCollectionTypeL()
       
    87 // Returns: Symbian OS errors.
       
    88 // -----------------------------------------------------------------------------
       
    89 TInt CCommonTestClass::InternalizeMPXCollectionTypeL()
       
    90     {
       
    91 	FTRACE(FPrint(_L("CCommonTestClass::InternalizeMPXCollectionTypeL testing CMPXCollectionType::InternalizeMPXCollectionTypeL begin")));
       
    92     iLog->Log(_L("CCommonTestClass::InternalizeMPXCollectionTypeL testing CMPXCollectionType::InternalizeMPXCollectionTypeL begin"));
       
    93     TInt err = KErrNone;
       
    94 
       
    95     if ( iType != NULL )
       
    96         {
       
    97     	FTRACE(FPrint(_L("CCommonTestClass::InternalizeMPXCollectionTypeL started Internalize")));
       
    98         iLog->Log(_L("CCommonTestClass::InternalizeMPXCollectionTypeL started Internalize"));
       
    99         CBufBase* buffer = CBufFlat::NewL( 50 );
       
   100         CleanupStack::PushL( buffer );
       
   101         RBufWriteStream writeStream( *buffer );
       
   102         CleanupClosePushL( writeStream );
       
   103         iType->ExternalizeL( writeStream );
       
   104         writeStream.CommitL();
       
   105         buffer->Compress();
       
   106         CleanupStack::PopAndDestroy( &writeStream );
       
   107 
       
   108         RBufReadStream readStream( *buffer );
       
   109         CleanupClosePushL( readStream );                
       
   110         iType = new ( ELeave ) CMPXCollectionType();        
       
   111         iType->InternalizeL( readStream );
       
   112         CleanupStack::PopAndDestroy( &readStream );
       
   113         CleanupStack::PopAndDestroy( buffer );
       
   114         }
       
   115     else
       
   116         {
       
   117         err = KErrBadTestParameter;
       
   118     	FTRACE(FPrint(_L("CCommonTestClass::InternalizeMPXCollectionTypeL Stif test script is wrong.")));
       
   119         iLog->Log(_L("CCommonTestClass::InternalizeMPXCollectionTypeL Stif test script is wrong."));
       
   120         }
       
   121 
       
   122 
       
   123 	FTRACE(FPrint(_L("CCommonTestClass::InternalizeMPXCollectionTypeL testing CMPXCollectionType::InternalizeMPXCollectionTypeL end err=%d"), err));
       
   124     iLog->Log(_L("CCommonTestClass::InternalizeMPXCollectionTypeL testing CMPXCollectionType::InternalizeMPXCollectionTypeL end err=%d"), err);
       
   125 	return err;
       
   126     }
       
   127     
       
   128 // -----------------------------------------------------------------------------
       
   129 // CCommonTestClass::ExternalizeMPXCollectionTypeL()
       
   130 // Returns: Symbian OS errors.
       
   131 // -----------------------------------------------------------------------------
       
   132 TInt CCommonTestClass::ExternalizeMPXCollectionTypeL()
       
   133     {
       
   134 	FTRACE(FPrint(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL testing CMPXCollectionType::ExternalizeMPXCollectionTypeL begin")));
       
   135     iLog->Log(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL testing CMPXCollectionType::ExternalizeMPXCollectionTypeL begin"));
       
   136     TInt err = KErrNone;
       
   137     if ( iType != NULL )
       
   138         {
       
   139     	FTRACE(FPrint(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL started Externalize")));
       
   140         iLog->Log(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL started Externalize"));
       
   141         CBufBase* buffer = CBufFlat::NewL( 50 );
       
   142         CleanupStack::PushL( buffer );
       
   143         RBufWriteStream writeStream( *buffer );
       
   144         CleanupClosePushL( writeStream );
       
   145         iType->ExternalizeL( writeStream );
       
   146         writeStream.CommitL();
       
   147         buffer->Compress();
       
   148         CleanupStack::PopAndDestroy( &writeStream );
       
   149         CleanupStack::PopAndDestroy( buffer ); 
       
   150         }
       
   151     else
       
   152         {
       
   153         err = KErrBadTestParameter;
       
   154     	FTRACE(FPrint(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL Stif test script is wrong.")));
       
   155         iLog->Log(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL Stif test script is wrong."));
       
   156         }
       
   157 	FTRACE(FPrint(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL testing CMPXCollectionType::ExternalizeMPXCollectionTypeL end err=%d"), err));
       
   158     iLog->Log(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL testing CMPXCollectionType::ExternalizeMPXCollectionTypeL end err=%d"), err);
       
   159 	return err;
       
   160     }
       
   161 
       
   162 // -----------------------------------------------------------------------------
       
   163 // CCommonTestClass::CreateMPXCollectionTypeaUid()
       
   164 // Returns: Symbian OS errors.
       
   165 // -----------------------------------------------------------------------------
       
   166 
       
   167 TInt CCommonTestClass::TUidMPXCollectionType()
       
   168     {
       
   169     TUid* uid=new TUid();
       
   170     TUid& aUid=*uid;
       
   171     CDesCArray* aMimeTypes(NULL);
       
   172     CDesCArray* aExtensions(NULL);
       
   173     FTRACE(FPrint(_L("CCommonTestClass::TUidMPXCollectionType testing CMPXCollectionType::CMPXCollectionType() begin")));
       
   174     iLog->Log(_L("CCommonTestClass::TUidMPXCollectionType testing CMPXCollectionType::CMPXCollectionType() begin"));
       
   175     TInt err = KErrNone;
       
   176     if ( iType != NULL)
       
   177         {
       
   178         delete iType;
       
   179         }
       
   180     iType = NULL;
       
   181     TRAP(err , iType = new ( ELeave ) CMPXCollectionType(aUid ,aMimeTypes,aExtensions));
       
   182     if ( iType == NULL)
       
   183         {
       
   184         err = KErrNotFound;
       
   185         }
       
   186       FTRACE(FPrint(_L("CCommonTestClass::TUidMPXCollectionType testing CMPXCollectionType::CMPXCollectionType() end err=%d"), err));
       
   187       iLog->Log(_L("CCommonTestClass::TUidMPXCollectionType testing CMPXCollectionType::CMPXCollectionType() end err=%d"), err);
       
   188       return err;
       
   189     }
       
   190     
       
   191 
       
   192     
       
   193