sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: //
sl@0: 
sl@0: /**
sl@0:  @file
sl@0:  @test
sl@0:  @internalComponent - Internal Symbian test code 
sl@0: */
sl@0: 
sl@0: 
sl@0: #include <e32uid.h>
sl@0: #include <f32file.h>
sl@0: #include <bautils.h>
sl@0: #include <apmrec.h>
sl@0: #include <ecom/ecom.h>
sl@0: #include "T_MimeStep.h"
sl@0: 
sl@0: 
sl@0: //
sl@0: _LIT8(KTextPlainData,"text/plain");
sl@0: _LIT(KTextFile,"z:\\system\\data\\emime\\testrec.text");
sl@0: _LIT(KTxtFile,"z:\\system\\data\\emime\\testrec.txt");
sl@0: _LIT(KWordFile,"z:\\system\\data\\emime\\word.doc");
sl@0: _LIT(KLeavingRecognizer,"TLEAVINGRECOGNIZER");
sl@0: 
sl@0: const TUid KWordAppUid={0x10003A64};
sl@0: 
sl@0: const TUid KLeavingRecogniserUid={0x1d1F75EB};
sl@0: const TUid KTestEcomDataRecognizerUid={0x101F7DA1};
sl@0: const TInt KTestDataRecognizerError=-420;  // some random number for test error code
sl@0: _LIT(KDeceptiveRecognizerToken, "c:\\test\\appfwk\\emime\\deceptive_recognizer.token");
sl@0: //
sl@0: 
sl@0: /* Construction of CTestDataRecognitionType Object*/
sl@0: 
sl@0: CTestDataRecognizerType* CTestDataRecognizerType::NewDataRecogTypeL(RFs &aIfs)
sl@0: 	{
sl@0: 	CTestDataRecognizerType *dataRecogTypeObj=new(ELeave)CTestDataRecognizerType(aIfs);
sl@0: 	CleanupStack::PushL(dataRecogTypeObj);
sl@0: 	CleanupStack::Pop(dataRecogTypeObj);
sl@0: 	return dataRecogTypeObj;
sl@0: 	
sl@0: 	}
sl@0: /* Constructor*/
sl@0: 	
sl@0: CTestDataRecognizerType::CTestDataRecognizerType (RFs &aIfs)
sl@0: 			:CApaDataRecognizer(aIfs)
sl@0: 	{
sl@0: 	
sl@0: 	
sl@0: 	}
sl@0: 
sl@0: CTestDataRecognizerType::~CTestDataRecognizerType()
sl@0: 	{
sl@0: 	
sl@0: 	}
sl@0: /**
sl@0:   Auxiliary Fn for Test Case ID T-MimeStep-testScanningMimeTheRecognizerL
sl@0:  
sl@0:   This method is used to verify the functionality of Locking and Unlocking the recognizer 
sl@0:   with the UID of the recognizer .Whenever the Recognizer is Locked the return value of 
sl@0:   Locked() function should be a value greater than zero. And When the recognizer is tried to
sl@0:   Unload , the unloading operation would fail with return code KErrLocked.
sl@0:   When the recognizer is in Unlocked condition the return value of Locked() is zero.
sl@0:   And Function to Unload the Recognizer is called again after unlocking the recognizer , and the 
sl@0:   Recognizer is unloaded without any Error.And the return code will be KErrNone.
sl@0: 
sl@0:   This method is also used to verify the return values of Mimetype() and Confidence(), 
sl@0:   When the recognizer is not added . And hence the values are default when the 
sl@0:   Recognizers are not added.
sl@0:   
sl@0: */
sl@0: void CT_MimeStep::ChkLockAndUnlockL(RFs &aIfs)
sl@0: 	{
sl@0: 	
sl@0: 	CTestDataRecognizerType *testLockAndUnLock=CTestDataRecognizerType::NewDataRecogTypeL(aIfs);
sl@0: 	CleanupStack::PushL(testLockAndUnLock);
sl@0: 	TRAPD(ret,testLockAndUnLock->AddDataL(iData));
sl@0: 	INFO_PRINTF2(_L("Val of AddDataL  %d"), ret);
sl@0: 		
sl@0: 	TInt valBeforeLock=iData->Locked();
sl@0: 	INFO_PRINTF2(_L("Val of Lock Before %d"), valBeforeLock);
sl@0: 	TEST(valBeforeLock==0);
sl@0: 
sl@0: 	iData->Lock();	
sl@0: 	TInt valAfterLock=iData->Locked();
sl@0: 	INFO_PRINTF2(_L("Val of Lock %d"), valAfterLock);
sl@0: 	TEST(valAfterLock > 0);
sl@0: 
sl@0: 	TInt remDataAfterLock=testLockAndUnLock->RemoveData(iData);
sl@0: 	TEST(remDataAfterLock==KErrLocked);
sl@0: 	INFO_PRINTF2(_L("Val of remDataAfterLock %d"), remDataAfterLock);
sl@0: 
sl@0: 	TRAP(ret,testLockAndUnLock->UpdateDataTypesL());
sl@0: 	TEST(ret==KErrNone);
sl@0: 
sl@0: 	iData->Unlock();
sl@0: 	TInt valAfterUnlock=iData->Locked();
sl@0: 	INFO_PRINTF2(_L("Val of Loc k %d"), valAfterUnlock);
sl@0: 	TEST(valAfterUnlock==0);
sl@0: 
sl@0: 	TInt remDataAfterUnLock=testLockAndUnLock->RemoveData(iData);
sl@0: 	TEST(remDataAfterUnLock==KErrNone);
sl@0: 	INFO_PRINTF2(_L("Val of remDataAfterLock %d"), remDataAfterUnLock);
sl@0: 
sl@0: 
sl@0: 	CleanupStack::PopAndDestroy(testLockAndUnLock);
sl@0: 	}
sl@0: /**
sl@0:   Auxiliary Fn for Test Case ID T-MimeStep-testScanningMimeTheRecognizerL 
sl@0:   
sl@0:   This method is  used to verify the return values of Mimetype() and Confidence(), 
sl@0:   When the recognizer is not added . And hence the values are default when the 
sl@0:   Recognizers are not added. */
sl@0:   
sl@0:   
sl@0: void CT_MimeStep::ChkConfAndMimeL(RFs &aIfs,const TUid &aUid)
sl@0: {
sl@0: 	CTestDataRecognizerType *confAndMimeDataRec=CTestDataRecognizerType::NewDataRecogTypeL(aIfs);
sl@0: 	CleanupStack::PushL(confAndMimeDataRec);
sl@0: 	TRAPD(ret,iData=CApaDataRecognizerType::CreateDataRecognizerL(aUid));
sl@0: 	TEST(ret==KErrNone);
sl@0: 	TDataType dataType= iData->MimeType();
sl@0: 	TInt confidenceVal=iData->Confidence();
sl@0: 	TEST(dataType.Uid().iUid==0);
sl@0: 	TEST(confidenceVal==0);
sl@0: 	INFO_PRINTF2(_L("Val of confidence  %d"), confidenceVal);
sl@0: 	//New tests
sl@0: 	TInt bufSize = iData->PreferredBufSize();
sl@0: 	TEST(bufSize==0);
sl@0: 	INFO_PRINTF2(_L("Val of Preferred buffer size  %d"), bufSize);
sl@0: 	INFO_PRINTF1(_L("Testing default constructor of TDataTypeWithPriority"));
sl@0: 	TDataTypeWithPriority dataTypeWithPriority = TDataTypeWithPriority();
sl@0: 	CleanupStack::PopAndDestroy(confAndMimeDataRec);	
sl@0: }
sl@0: 
sl@0: 
sl@0: /**
sl@0:   Auxiliary Fn for Test Case ID T-MimeStep-testScanningMimeTheRecognizerL
sl@0:  
sl@0:   This function checks a return value, and prints it in an Error return value.
sl@0:   
sl@0: */
sl@0: void CT_MimeStep::DoTest(TInt aReturnValue)
sl@0: 	{
sl@0: 	if (aReturnValue!=KErrNone)
sl@0: INFO_PRINTF2(_L("\nError: %D\n"),aReturnValue);
sl@0: 	TEST(aReturnValue==KErrNone);
sl@0: 	}
sl@0: 
sl@0: 
sl@0: /**
sl@0:   Auxiliary Fn for Test Case ID T-MimeStep-testScanningMimeTheRecognizerL
sl@0:  
sl@0:   This function checks the integrity of a Recognizer.
sl@0:   
sl@0: */
sl@0: void CT_MimeStep::testRecognizer(const CApaScanningDataRecognizer::TRecognizer& aRec)
sl@0: 	{
sl@0: 	_LIT(KRecText,"RECTXT");
sl@0: 	_LIT(KRecWeb,"RECWEB");
sl@0: 	_LIT(KRecApp2,"RECAPP2");
sl@0: 	_LIT(KRecJar,"RECJAR");
sl@0: 	_LIT(KBookMarkRec,"EBOOKMARKREC");
sl@0: 	_LIT(KRecMda,"RECMDA");
sl@0: 	_LIT(KRecOffice,"RECOFFICE");
sl@0: 	_LIT(KRecWap,"RECWAP");
sl@0: 	_LIT(KRVersit,"RVERSIT");
sl@0: 	_LIT(KWebUrlRec,"WEBURLREC");
sl@0: 	_LIT(TTestEcomDataRec,"TTESTECOMDATAREC");
sl@0: 		
sl@0: 	if (aRec.iUid.iUid==0x100012FB)
sl@0: 		{
sl@0: 		TEST(aRec.iDrive==25);
sl@0: 		TEST(aRec.Name().CompareF(KRecText)==0);
sl@0: 		}
sl@0: 	else if (aRec.iUid.iUid==0x10001315)
sl@0: 		{
sl@0: 		TEST(aRec.iDrive==25);
sl@0: 		TEST(aRec.Name().CompareF(KRecWeb)==0);
sl@0: 		}
sl@0: 	else if (aRec.iUid.iUid==0x1000415F)
sl@0: 		{
sl@0: 		TEST(aRec.iDrive==25);
sl@0: 		TEST(aRec.Name().CompareF(KRecApp2)==0);
sl@0: 		}
sl@0: 	else if (aRec.iUid.iUid==0x1000967A)
sl@0: 		{
sl@0: 		TEST(aRec.iDrive==25);
sl@0: 		TEST(aRec.Name().CompareF(KRecJar)==0);
sl@0: 		}
sl@0: 	else if (aRec.iUid.iUid==0x10008ED4)
sl@0: 		{
sl@0: 		TEST(aRec.iDrive==25);
sl@0: 		TEST(aRec.Name().CompareF(KBookMarkRec)==0);
sl@0: 		}
sl@0: 	else if (aRec.iUid.iUid==0x10005617)
sl@0: 		{
sl@0: 		TEST(aRec.iDrive==25);
sl@0: 		TEST(aRec.Name().CompareF(KRecMda)==0);
sl@0: 		}
sl@0: 	else if (aRec.iUid.iUid==0x10008A2F)
sl@0: 		{
sl@0: 		TEST(aRec.iDrive==25);
sl@0: 		TEST(aRec.Name().CompareF(KRecOffice)==0);
sl@0: 		}
sl@0: 	else if (aRec.iUid.iUid==0x1000515E)
sl@0: 		{
sl@0: 		TEST(aRec.iDrive==25);
sl@0: 		TEST(aRec.Name().CompareF(KRecWap)==0);
sl@0: 		}
sl@0: 	else if (aRec.iUid.iUid==0x100047EB)
sl@0: 		{
sl@0: 		TEST(aRec.iDrive==25);
sl@0: 		TEST(aRec.Name().CompareF(KRVersit)==0);
sl@0: 		}
sl@0: 	else if (aRec.iUid.iUid==0x100064DE)
sl@0: 		{
sl@0: 		TEST(aRec.iDrive==25);
sl@0: 		TEST(aRec.Name().CompareF(KWebUrlRec)==0);
sl@0: 		}
sl@0: 	else if (aRec.iUid==KLeavingRecogniserUid)
sl@0: 		{
sl@0: INFO_PRINTF1(_L("Testing a recogniser(TLEAVINGRECOGNIZER) with >12 chars length"));
sl@0: 		TEST(aRec.iDrive==25);
sl@0: 		TEST(aRec.Name().CompareF(KLeavingRecognizer)==0);
sl@0: 		}
sl@0: 	else if(aRec.iUid.iUid==0x101F7DA0)
sl@0: 		{
sl@0: 		TEST(aRec.Name().CompareF(KRecText)==0);
sl@0: 		}
sl@0: 	else if(aRec.iUid.iUid==0x101F7D9F)
sl@0: 		{
sl@0: 		TEST(aRec.Name().CompareF(KRecApp2)==0);
sl@0: 		}
sl@0: 	else if(aRec.iUid==KTestEcomDataRecognizerUid)
sl@0: 		{
sl@0: INFO_PRINTF1(_L("Testing the presence of ecom style TTESTECOMDATAREC recognizer"));
sl@0: 		TEST(aRec.Name().CompareF(TTestEcomDataRec)==0);
sl@0: 		}
sl@0: 	}
sl@0: 
sl@0: 
sl@0:  /**
sl@0:    @SYMTestCaseID		T-MimeStep-testScanningMimeTheRecognizerL
sl@0:   
sl@0:    @SYMPREQ			
sl@0:   
sl@0:    @SYMTestCaseDesc 	Tests the Scanning File-Recognizer
sl@0:   
sl@0:    @SYMTestPriority 	High
sl@0:   
sl@0:    @SYMTestStatus 		Implemented
sl@0:    
sl@0:    @SYMTestActions  	The test verifies the Scannig File-Recognizer by testing
sl@0:    the getter and setter functions. It creates a temporal list of recognizers to
sl@0:    check the getter function, and then goes through the whole list of recognizers 
sl@0:    testing each one.\n
sl@0:    Also, the setter function is checked, by adding a recognizer that's already
sl@0:    added, and adding one that doesn't exist, and verifying that correct return 
sl@0:    value. Finally, it is checked if specific recognizers are loaded or not.\n
sl@0:    This test Also checks for the functionality of the Locking and Unlocking 
sl@0:    Mechanism of the recognizer and checks that the When the recognizers are not 
sl@0:    added in CAPARecognizertype class , The properties of the Recognizer will be 
sl@0:    the defaulted.
sl@0:    API Calls:\n
sl@0:    CApaScanningDataRecognizer::NewL(RFs& aFs) \n
sl@0:    CApaScanningDataRecognizer::TRecognizer(HBufC* aName) \n
sl@0:    CApaScanningDataRecognizer::RecognizerListLC() \n
sl@0:    CApaScanningDataRecognizer::RecognizerCount() \n
sl@0:    CApaScanningDataRecognizer::UpdateCounter() const \n
sl@0:    CApaScanningDataRecognizer::SetRecognizerL() \n
sl@0:    CApaScanningDataRecognizer::SetEcomRecognizerL() \n
sl@0:    CApaDataRecognizerType::MimeType() \n
sl@0:    CApaDataRecognizerType::Confidence() \n
sl@0:    CApaDataRecognizerType::Lock() \n
sl@0:    CApaDataRecognizerType::Unlock() \n
sl@0:    @SYMTestExpectedResults Test should complete without any panic.
sl@0:    
sl@0:  */
sl@0: void CT_MimeStep::testScanningMimeTheRecognizerL()
sl@0: 	{
sl@0: INFO_PRINTF1(_L("Testing the Scanning File-Recognizer"));
sl@0: 	//
sl@0: 	// construct - this scans for TheRecognizer plug-ins
sl@0: 	TRAPD(ret, iRecognizer=CApaScanningDataRecognizer::NewL(iFs) );
sl@0: 		DoTest(ret);
sl@0: 		TEST(iRecognizer->RecognizerCount()>=3);
sl@0: 		TEST(iRecognizer->UpdateCounter()>=3);
sl@0: 	//
sl@0: INFO_PRINTF1(_L("Testing the getter and setter functions"));
sl@0: 	//
sl@0: 	// check the getter function
sl@0: 	CApaScanningDataRecognizer::CRecognizerArray* tempListOfRecognizers = iRecognizer->RecognizerListLC();
sl@0: 	TInt listCount = tempListOfRecognizers->Count();
sl@0: 
sl@0: 	for (TInt ii=0;ii<listCount;ii++)
sl@0: 		{
sl@0: 		testRecognizer((*tempListOfRecognizers)[ii]);
sl@0: 		}
sl@0: 
sl@0: 	CleanupStack::PopAndDestroy(1); // tmpListOfRecogniszers
sl@0: 	
sl@0: 	//New test
sl@0: 	INFO_PRINTF1(_L("Testing index([]) operator"));
sl@0: 	const CApaScanningDataRecognizer::TRecognizer& testDataRecognizer=(*iRecognizer)[0];
sl@0: 	TUid uid1 =  testDataRecognizer.iUid;
sl@0: 	TUid uid2 = ((*iRecognizer)[0]).iUid;
sl@0: 	TEST(uid1==uid2);
sl@0: //for testing ecom style plugin
sl@0: INFO_PRINTF1(_L("Testing the ecom style TTESTECOMDATAREC recognizer is loaded or not"));
sl@0: 	CApaScanningDataRecognizer::TRecognizer testEcomDataRecognizer;
sl@0: 	testEcomDataRecognizer.iUid=KTestEcomDataRecognizerUid;
sl@0: 	testEcomDataRecognizer.iDrive=25;
sl@0: 	TRAP(ret,iRecognizer->SetEcomRecognizerL(testEcomDataRecognizer));
sl@0: 		TEST(ret==KErrNone);
sl@0: // for testing Lock() ,Unlock of the recognizers.		
sl@0: INFO_PRINTF1(_L("Test Confidence and MimeType APIs of CApaDataRecognizerType "));
sl@0: 	TRAP(ret,ChkConfAndMimeL(iFs,testEcomDataRecognizer.iUid));
sl@0: 		TEST(ret==KErrNone);
sl@0: 			
sl@0: INFO_PRINTF1(_L("Test Lock And Unlock APIs of CApaDataRecognizerType "));
sl@0: 	TRAP(ret,ChkLockAndUnlockL(iFs));
sl@0: 		TEST(ret==KErrNone);
sl@0: 
sl@0: INFO_PRINTF1(_L("Testing the TECOMLEAVINGRECOGNIZER recogniser is loaded or not"));
sl@0: 	CApaScanningDataRecognizer::TRecognizer ecomLeavingRecognizer;
sl@0: 	ecomLeavingRecognizer.iUid.iUid = 0x10203630;
sl@0: 	ecomLeavingRecognizer.iDrive = 25;
sl@0: 	TRAP(ret,iRecognizer->SetEcomRecognizerL(ecomLeavingRecognizer));
sl@0: 		TEST(ret==KErrNone);
sl@0: 		TEST(iRecognizer->UpdateCounter()>=3);
sl@0: 	}
sl@0: 
sl@0: 
sl@0:  /**
sl@0:    @SYMTestCaseID		T-MimeStep-testTDataTypeL
sl@0:   
sl@0:    @SYMPREQ			
sl@0:   
sl@0:    @SYMTestCaseDesc 	Test TDataType structure by creating new automatic variables
sl@0:   
sl@0:    @SYMTestPriority 	High
sl@0:   
sl@0:    @SYMTestStatus 		Implemented
sl@0:    
sl@0:    @SYMTestActions  	The test creates new TDataType automatic variables. 
sl@0:    It creates a first TDataType using the constructor taking a UID. The data 
sl@0:    type must be  a native Symbian data type, with an associated UID equal 
sl@0:    to the original UID from which the UID was constructed.\n
sl@0:    A second TDataType is created using a pointer descriptor to the data 
sl@0:    type previously created. Also, the data type must be a native Symbian data 
sl@0:    type, with the same associated UID than the previously data type created.\n
sl@0:    API Calls:\n
sl@0:    TDataType::TDataType() \n
sl@0:    TDataType::TDataType(const TDesC8& aDataType) \n
sl@0:    TDataType::IsNative() \n
sl@0:    TDataType::Uid() \n
sl@0:   
sl@0:    @SYMTestExpectedResults Test should complete without any panic.
sl@0:   
sl@0:  */
sl@0: void CT_MimeStep::testTDataTypeL()
sl@0: // check TDataType constructors
sl@0: 	{
sl@0: 	TUid uid={0x12345678};
sl@0: 	TDataType dataType(uid);
sl@0: 	TEST(dataType.IsNative());
sl@0: 	TEST(dataType.Uid()==uid);
sl@0: 	TDataType secondType(dataType.Des8());
sl@0: 	TEST(secondType==dataType);
sl@0: 	TEST(secondType.IsNative());
sl@0: 	TEST(secondType.Uid()==uid);
sl@0: 	}
sl@0: 
sl@0: 
sl@0:  /**
sl@0:    @SYMTestCaseID		T-MimeStep-testRecognizersL
sl@0:   
sl@0:    @SYMPREQ			
sl@0:   
sl@0:    @SYMTestCaseDesc 	Tests file recognizers using RecognizerL function
sl@0:   
sl@0:    @SYMTestPriority 	High
sl@0:   
sl@0:    @SYMTestStatus 		Implemented
sl@0:    
sl@0:    @SYMTestActions  	The test uses the RecognizeL function to recognize the
sl@0:    data type of the data in the files, corresponding to three types of file formats:\n
sl@0:    (1) .text file, containing plain text. The recognized data type must be 
sl@0:    equal to a plain text TDataType. When no TDataType is defined, the error must 
sl@0:    be propagated accordingly.\n
sl@0:    (2) .txt file, containing plain text. The recognized data type must be equal to
sl@0:    a plain text TDataType.\n
sl@0:    (3) Word file (.doc format). The recognized data type must be equal to
sl@0:    a word file TDataType.\n
sl@0:    API Calls:\n	
sl@0:    CApaScanningDataRecognizer::RecognizeL(const TDesC& aName, const TDesC8& aBuffer)\n
sl@0:    
sl@0:    @SYMTestExpectedResults Test should complete without any panic.
sl@0:    
sl@0:  */
sl@0: void CT_MimeStep::testRecognizersL()
sl@0: 	{
sl@0: 	//
sl@0: 	// do other stuff...
sl@0: 	
sl@0: INFO_PRINTF1(_L("Testing the text file recognizer"));
sl@0: 	CArrayFixFlat<TDataType>* array=new(ELeave) CArrayFixFlat<TDataType>(5);
sl@0: 	CleanupStack::PushL(array);
sl@0: 	iRecognizer->DataTypeL(*array);
sl@0: 
sl@0: 	TInt minNumDataTypes = 1;	// txt/plain
sl@0: 	minNumDataTypes++;			// dodgy/app
sl@0: 
sl@0: 	TEST(array->Count()>=minNumDataTypes);
sl@0: 	CleanupStack::PopAndDestroy(); // array
sl@0: 	// I don't know what order these will be in - I can't test them
sl@0: 
sl@0: 	TInt bufSize=iRecognizer->PreferredBufSize();
sl@0: 	HBufC8* buf=HBufC8::NewLC(bufSize);
sl@0: 	RFile rfile;
sl@0: 	TInt err=rfile.Open(iFs,KTextFile,EFileShareReadersOnly);
sl@0: 	TEST(err==KErrNone);
sl@0: 	TPtr8 des=buf->Des();
sl@0: 	if (err==KErrNone)
sl@0: 		{
sl@0: 		err=rfile.Read(des);
sl@0: 		if (err!=KErrNone)
sl@0: 			des.SetLength(0);
sl@0: 		}
sl@0: 	rfile.Close();
sl@0: 	TDataType textplain(KTextPlainData);
sl@0: 	// recognizes the plain text
sl@0: 	TEST(iRecognizer->RecognizeL(KTextFile, des).iDataType==textplain);
sl@0: 	// test by passing a empty file name
sl@0: 	TEST(iRecognizer->RecognizeL(TPtrC(), des).iDataType==textplain);
sl@0: 
sl@0: 	//Test the propagation of error (leave) occured in a recognizer, 
sl@0: 	//if there is no probable data type matched.
sl@0: 	// There is a V1 version and a V2 (ECom) version of this recognizer.
sl@0: 	INFO_PRINTF1(_L("Propagates error if a recognizer leaves with no probable data type found"));
sl@0: 	TDataType dataType;
sl@0: 	des.SetLength(0);
sl@0: 	TRAPD(ret,dataType=iRecognizer->RecognizeL(KTextFile, des).iDataType);
sl@0: 	TEST(dataType==TDataType());
sl@0: 	INFO_PRINTF2(_L("Propagated error:%d, it should should be equal to KTestDataRecognizerError(-420)"), ret);
sl@0: 	TEST(ret==KTestDataRecognizerError);
sl@0: 
sl@0: 	err=rfile.Open(iFs,KTxtFile,EFileShareReadersOnly);
sl@0: 	TEST(err==KErrNone);
sl@0: 	des=buf->Des();
sl@0: 	if (err==KErrNone)
sl@0: 		{
sl@0: 		err=rfile.Read(des);
sl@0: 		if (err!=KErrNone)
sl@0: 			des.SetLength(0);
sl@0: 		}
sl@0: 	rfile.Close();
sl@0: 	
sl@0: 	TRAP(ret,dataType=iRecognizer->RecognizeL(KTxtFile, des).iDataType);
sl@0: 	TEST(dataType==textplain);
sl@0: 	TEST(err==KErrNone);
sl@0: 	
sl@0: 	des.SetLength(0);
sl@0: 	TRAP(ret,dataType=iRecognizer->RecognizeL(KTxtFile, des).iDataType);
sl@0: 	TEST(dataType==textplain);
sl@0: 	TEST(err==KErrNone);
sl@0: 
sl@0: 	INFO_PRINTF1(_L("Testing the EIKON app recognizer"));
sl@0: 	des.SetLength(0);
sl@0: 	err=rfile.Open(iFs,KWordFile,EFileShareReadersOnly);
sl@0: 	TEST(err==KErrNone);
sl@0: 	des=buf->Des();
sl@0: 	if (err==KErrNone)
sl@0: 		{
sl@0: 		err=rfile.Read(des);
sl@0: 		if (err!=KErrNone)
sl@0: 			des.SetLength(0);
sl@0: 		}
sl@0: 
sl@0: 	rfile.Close();
sl@0: 	TRAP(ret,dataType=iRecognizer->RecognizeL(KWordFile, des).iDataType);
sl@0: 		TEST(dataType==TDataType(KWordAppUid));
sl@0: 		TEST(err==KErrNone);
sl@0: 	CleanupStack::PopAndDestroy(buf); // buf
sl@0: 
sl@0: 	delete iRecognizer;
sl@0: 	}
sl@0: 
sl@0: CT_MimeStep::~CT_MimeStep()
sl@0: /**
sl@0:    Destructor
sl@0:  */
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: CT_MimeStep::CT_MimeStep()
sl@0: /**
sl@0:    Constructor
sl@0:  */
sl@0: 	{
sl@0: 	// Call base class method to set up the human readable name for logging
sl@0: 	SetTestStepName(KT_MimeStep);
sl@0: 	}
sl@0: 
sl@0: 
sl@0: TVerdict CT_MimeStep::doTestStepL()
sl@0: 	{
sl@0: 	INFO_PRINTF1(_L("Test Started - Testing the APMIME dll"));
sl@0: 	
sl@0: 	// set up the directory structure
sl@0: 	User::LeaveIfError(iFs.Connect());
sl@0: 	
sl@0: 
sl@0: 	INFO_PRINTF1(_L("Create token file for deceptive leaving recognizer activation"));
sl@0: 	RFile file;
sl@0: 	CleanupClosePushL(file);
sl@0: 	TInt r = iFs.MkDirAll(KDeceptiveRecognizerToken);
sl@0: 	TEST(r == KErrNone || r == KErrAlreadyExists);
sl@0: 	TEST(file.Create(iFs, KDeceptiveRecognizerToken, EFileWrite|EFileShareExclusive) == KErrNone);
sl@0: 	CleanupStack::PopAndDestroy(&file);
sl@0: 
sl@0: 	// run the testcode (inside an alloc heaven harness)
sl@0:  	__UHEAP_MARK;
sl@0: 
sl@0: 	CActiveScheduler* pS=new(ELeave) CActiveScheduler;
sl@0: 	TEST(pS!=NULL);
sl@0: 	CActiveScheduler::Install(pS);
sl@0: 	TRAP(r,CT_MimeStep::testScanningMimeTheRecognizerL());
sl@0: 	TEST(r==KErrNone);
sl@0: 	TRAP(r,CT_MimeStep::testRecognizersL());
sl@0: 	TEST(r==KErrNone);
sl@0: 	TRAP(r,CT_MimeStep::testTDataTypeL());
sl@0: 	TEST(r==KErrNone);
sl@0: 
sl@0: 	delete pS;
sl@0: 	REComSession::FinalClose();
sl@0: 	__UHEAP_MARKEND;
sl@0: 	
sl@0: 
sl@0: 	// Removes token file for deceptive leaving recognizer
sl@0: 	INFO_PRINTF1(_L("Remove token file for deceptive leaving recognizer deactivation"));
sl@0: 	TEST(iFs.Delete(KDeceptiveRecognizerToken) == KErrNone);
sl@0: 	
sl@0: 	iFs.Close();
sl@0: 
sl@0: 	INFO_PRINTF1(_L("Test Finished"));
sl@0: 	return TestStepResult();
sl@0: 	}
sl@0: 
sl@0: