filehandling/fileconverterfw/Tef/TLoadEcomCnvStep.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 2005-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 // The following test case is used to test the ecom style converter plugin and test the list and converter APIs
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent - Internal Symbian test code
       
    21 */
       
    22 
       
    23 #include <e32std.h>
       
    24 #include <e32cons.h>
       
    25 #include <s32file.h>
       
    26 #include <e32test.h>
       
    27 #include <ecom/ecom.h>
       
    28 
       
    29 #include <concnf.h>
       
    30 #include <conlist.h>
       
    31 #include "TLoadEcomCnvStep.h"
       
    32 #include "TTestEcomConverter.hrh"
       
    33 
       
    34  
       
    35 /**
       
    36   Auxiliary Fn for TestCaseID TLoadEcomCnvStep-ExecuteL
       
    37   Construct CCnaConverterList object and call ConvFromListL & ConvToListL
       
    38   
       
    39 */
       
    40 void CTLoadEComCnvStep::TestListsL()
       
    41 	{
       
    42 	TDataType dataType;
       
    43 	CCnaConverterList* list=CCnaConverterList::NewLC();
       
    44 	list->UpdateL();
       
    45 	CArrayFixFlat<SConverterInfo>* info;
       
    46 	info= new(ELeave) CArrayFixFlat<SConverterInfo>(5);
       
    47 
       
    48 	CleanupStack::PushL(info);
       
    49 
       
    50 	list->ConvFromListL(mimeEngEpoc32CPlaintext,info);
       
    51 	TInt count =info->Count();
       
    52 	INFO_PRINTF1(_L("Test from list\n"));
       
    53 	for (TInt i=0;i<count;i++)
       
    54 		{
       
    55 		INFO_PRINTF1((*info)[i].iTranslation);
       
    56 		INFO_PRINTF2(_L(" uid= %d \n"),(*info)[i].iUid);
       
    57 		if(list->MimeTypeFrom(dataType,(*info)[i])==KErrNone)
       
    58 			{
       
    59 			TPtrC mimeType(dataType.Des());
       
    60 			INFO_PRINTF2(_L(" mimeType= %S \n\n"),&mimeType);
       
    61 			}
       
    62 		else
       
    63 			{
       
    64 			INFO_PRINTF2(_L("***** ERROR: MimeTypeFrom returned KErrNotFound\n\n"),i);
       
    65 			}
       
    66 		}
       
    67 	info->Reset();
       
    68 	list->ConvToListL(mimeFrenchxyzzyFrot,info);
       
    69 	count =info->Count();
       
    70 	INFO_PRINTF1(_L("Test to list\n"));
       
    71 	for (TInt j=0;j<count;j++)
       
    72 		{
       
    73 		INFO_PRINTF1((*info)[j].iTranslation);
       
    74 		INFO_PRINTF2(_L(" uid= %d \n"),(*info)[j].iUid);
       
    75 		if(list->MimeTypeTo(dataType,(*info)[j])==KErrNone)
       
    76 			{
       
    77 			TPtrC mimeType(dataType.Des());
       
    78 			INFO_PRINTF2(_L(" mimeType= %S \n\n"),&mimeType);
       
    79 			}
       
    80 		else
       
    81 			{
       
    82 			INFO_PRINTF2(_L("***** ERROR: MimeTypeTo returned KErrNotFound\n\n"),j);
       
    83 			}
       
    84 		}
       
    85 	CleanupStack::PopAndDestroy(2);
       
    86 
       
    87 	}
       
    88 
       
    89  /**
       
    90    @SYMTestCaseID		TLoadEcomCnvStep-ExecuteL
       
    91   
       
    92    @SYMPREQ				REQ2689		
       
    93   
       
    94    @SYMTestCaseDesc 	Construct CCnaConverterList object and get the converter by uid as well as mime style
       
    95   
       
    96    @SYMTestPriority 	High
       
    97   
       
    98    @SYMTestStatus 		Implemented
       
    99    
       
   100    @SYMTestActions  
       
   101    To construct CCnaConverterList object and get the instance of the converter passing the relevant UID\n
       
   102    Using the list object its following APIs are tested
       
   103    API Calls:\n		
       
   104    CCnaConverterList::NewLC();
       
   105    CCnaConverterList::NewConverterL(TUid aUid);
       
   106    CCnaConverterList::Count();
       
   107    CCnaConverterList::ConvFromL(const TDataType& aMimeType);
       
   108    CCnaConverterList::ConvToL(const TDataType& aMimeType);
       
   109    CCnaConverterList::ConverterL(const TDataType& aFrom,const TDataType& aTo);
       
   110    CTestEcomConverter::ConvertL(const TFileName& aSourceFile, const TFileName& aTargetFile, 
       
   111 								MConverterUiObserver* aObserver=NULL);
       
   112    @SYMTestExpectedResults Test should complete without any panic.
       
   113    
       
   114  */
       
   115 void CTLoadEComCnvStep::ExecuteL()
       
   116 	{
       
   117 	TUid uid;
       
   118 	uid.iUid=KTestEcomConvImplementationUid;
       
   119 	CCnaConverterList* list=CCnaConverterList::NewLC();
       
   120 	list->UpdateL();
       
   121 	INFO_PRINTF2(_L("Number of converters found %d\n"),list->Count());
       
   122 	CConverterBase* conv=list->NewConverterL(uid);
       
   123 	CleanupStack::PushL(conv);
       
   124 	conv->ConvertL(_L("file1"), _L("File2"));
       
   125 	INFO_PRINTF1(_L("Converter by uid\n"));
       
   126 	CleanupStack::PopAndDestroy(); // conv
       
   127 	TUid fromUid=list->ConvFromL(mimeEngEpoc32CPlaintext);
       
   128 	INFO_PRINTF2(_L(" ConvFromUid= %d \n"),fromUid);
       
   129 	TUid toUid=list->ConvToL(mimeFrenchxyzzyFrot);
       
   130 	INFO_PRINTF2(_L(" ConvToUid= %d \n"),toUid);
       
   131 	TUid converterUid=list->ConverterL(mimeEngEpoc32CPlaintext,mimeFrenchxyzzyFrot);
       
   132 	INFO_PRINTF2(_L(" ConvterterUid= %d \n"),converterUid);
       
   133 	conv=list->NewConverterL(fromUid);
       
   134 	CleanupStack::PushL(conv);
       
   135 	conv->ConvertL(_L("file1"), _L("file2"));
       
   136 	INFO_PRINTF1(_L("Converter by mime type\n"));
       
   137 	CleanupStack::Pop(); // conv
       
   138 	delete conv;
       
   139 	CleanupStack::PopAndDestroy(); // list
       
   140 	INFO_PRINTF1(_L("Destroyed converter list\n"));
       
   141 	TestListsL();
       
   142 	}
       
   143 
       
   144 CTLoadEComCnvStep::CTLoadEComCnvStep()
       
   145 /**
       
   146    Constructor
       
   147  */
       
   148 	{
       
   149 	// Call base class method to set up the human readable name for logging
       
   150 	SetTestStepName(KTLoadEComCnvStep);
       
   151 	}
       
   152 
       
   153 CTLoadEComCnvStep::~CTLoadEComCnvStep()
       
   154 	{
       
   155 	}
       
   156 
       
   157 TVerdict CTLoadEComCnvStep::doTestStepL()
       
   158     {
       
   159 	INFO_PRINTF1(_L("Test Started"));
       
   160 	__UHEAP_MARK; // mark heap state
       
   161 	
       
   162 	mimeEngEpoc32CPlaintext = TDataType(_L8("foo/bar"));
       
   163 	mimeFrenchxyzzyFrot = TDataType(_L8("xyzzy/frot"));
       
   164 	
       
   165 
       
   166 	TRAPD(error,ExecuteL()); // do most stuff under cleanup stack
       
   167 	TEST(error == KErrNone);
       
   168 	REComSession::FinalClose(); 
       
   169 	
       
   170 	__UHEAP_MARKEND; // check no memory leak
       
   171 	
       
   172 	INFO_PRINTF1(_L("Test Finished"));
       
   173 	
       
   174 	return TestStepResult();
       
   175     }