localisation/apparchitecture/tef/T_File1Step.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     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 the License "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Tests CApaScanningFileRecognizer APIs.
       
    15 // 
       
    16 //
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  @file
       
    22  @internalComponent - Internal Symbian test code
       
    23 */
       
    24 
       
    25 #include <e32uid.h>
       
    26 #include <f32file.h>
       
    27 #include <fbs.h>
       
    28 #include <apadef.h>
       
    29 #include <apfrec.h>
       
    30 #include <apfctlf.h>
       
    31 #include <apgctl.h>
       
    32 #include <ecom.h>
       
    33 
       
    34 #include "tstapp.h"
       
    35 #include "T_File1Step.h"
       
    36 
       
    37 //
       
    38 #if !defined(__E32TEST_H__)
       
    39 #include <e32test.h>
       
    40 #endif
       
    41 
       
    42 const TUid KTestEcomFileRecognizerUid={0x101F7D8C};
       
    43 
       
    44 void CT_File1Step::setup()
       
    45 	{
       
    46 #if defined(__EPOC32__)
       
    47 	TFullName filePath=_L("c:\\docs\\tstapp.doc");
       
    48 	TFullName tempPath=_L("c:\\system\\temp\\");
       
    49 	// if we're on the rack create the directories we need
       
    50 	TParse parser;
       
    51 	parser.Set(filePath,NULL,NULL);
       
    52 	iFs.MkDirAll(parser.DriveAndPath());
       
    53 	parser.Set(tempPath,NULL,NULL);
       
    54 	iFs.MkDirAll(parser.DriveAndPath());
       
    55 #endif
       
    56 	}
       
    57 
       
    58 /**
       
    59    @SYMTestCaseID T-FileStep-testScanningFileTheRecognizerL
       
    60   
       
    61    @SYMPREQ
       
    62   
       
    63    @SYMTestCaseDesc 
       
    64    
       
    65    @SYMTestPriority High 
       
    66   
       
    67    @SYMTestStatus Implemented
       
    68    
       
    69    @SYMTestActions The method creates a scanning file recognizer object and observes whether
       
    70    return values from RecognizerCount() and UpdateCounter() match with the
       
    71    expected results. The setter function SetRecognizerL() is also tested with a recognizer
       
    72    that doesn't exist to check if it would return KErrNotFound.\n
       
    73    API Calls:\n	
       
    74    CApaScanningFileRecognizer::NewL(RFs& aFs, MApaAppStarter* aAppStarter)\n
       
    75    CApaScanningFileRecognizer::RecognizerCount()\n
       
    76    CApaScanningFileRecognizer::UpdateCounter()\n
       
    77    CApaScanningFileRecognizer::SetRecognizerL(const TRecognizer& aRecognizer)\n
       
    78    
       
    79    @SYMTestExpectedResults Test checks results against expected values.
       
    80     
       
    81  */
       
    82 void CT_File1Step::testScanningFileTheRecognizerL()
       
    83 	{
       
    84 	INFO_PRINTF1(_L("Testing the Scanning File-Recognizer"));
       
    85 	//
       
    86 	CActiveScheduler* scheduler = new(ELeave) CActiveScheduler();
       
    87 	CleanupStack::PushL(scheduler);
       
    88 	CActiveScheduler::Install(scheduler);
       
    89 	//
       
    90 	// construct - this scans for iRecognizer plug-ins
       
    91 	TRAPD(ret, iRecognizer=CApaScanningFileRecognizer::NewL(iFs,NULL));
       
    92 	TEST(ret==KErrNone);
       
    93 	// 06/09/99 SimonC: following tests updated as they'll fail when run with a baseline build
       
    94 	TEST(iRecognizer->RecognizerCount()>=2);
       
    95 	TEST(iRecognizer->UpdateCounter()>=2);
       
    96 
       
    97 	//for testing ecom style plugin
       
    98 	INFO_PRINTF1(_L("Testing the ecom style TTESTECOMFILEREC recognizer is loaded or not"));
       
    99 	CApaScanningFileRecognizer::TRecognizer testEcomFileRec;
       
   100 	testEcomFileRec.iUid=KTestEcomFileRecognizerUid;
       
   101 	testEcomFileRec.iDrive=25;
       
   102 	TRAP(ret,iRecognizer->SetEcomRecognizerL(testEcomFileRec));
       
   103 	TEST(ret==KErrNone);
       
   104 	TEST(iRecognizer->UpdateCounter()>=2);
       
   105 
       
   106 	INFO_PRINTF1(_L("Wait a couple of seconds to stop dlls closing too early...")); // stop the dll's being closed too early
       
   107 	User::After(2000000);
       
   108 	
       
   109 	delete iRecognizer;
       
   110 	CleanupStack::PopAndDestroy(scheduler);
       
   111 	}
       
   112 
       
   113 CT_File1Step::~CT_File1Step()
       
   114 /**
       
   115    Destructor
       
   116  */
       
   117 	{
       
   118 	}
       
   119 
       
   120 CT_File1Step::CT_File1Step()
       
   121 /**
       
   122    Constructor
       
   123  */
       
   124 	{
       
   125 	// Call base class method to set up the human readable name for logging
       
   126 	SetTestStepName(KT_File1Step);
       
   127 	}
       
   128 
       
   129 TVerdict CT_File1Step::doTestStepPreambleL()
       
   130 /**
       
   131    @return - TVerdict code
       
   132    Override of base class virtual
       
   133  */
       
   134 	{
       
   135 	SetTestStepResult(EPass);
       
   136 	return TestStepResult();
       
   137 	}
       
   138 
       
   139 TVerdict CT_File1Step::doTestStepPostambleL()
       
   140 /**
       
   141    @return - TVerdict code
       
   142    Override of base class virtual
       
   143  */
       
   144 	{
       
   145 	return TestStepResult();
       
   146 	}
       
   147 
       
   148 TVerdict CT_File1Step::doTestStepL()
       
   149 /**
       
   150   @return - TVerdict code
       
   151   Override of base class virtual
       
   152 */
       
   153 	{
       
   154 	INFO_PRINTF1(_L("Testing the APFILE dll..."));
       
   155 	//
       
   156 	// set up the directory structure
       
   157 	iFs.Connect();
       
   158 	setup();
       
   159 	//
       
   160 	// run the testcode (inside an alloc heaven harness)
       
   161 
       
   162  	__UHEAP_MARK;
       
   163 	TRAPD(r,testScanningFileTheRecognizerL());
       
   164 	TEST(r==KErrNone);
       
   165 	REComSession::FinalClose();	
       
   166 	__UHEAP_MARKEND;
       
   167 
       
   168 	iFs.Close();
       
   169 
       
   170 	INFO_PRINTF1(_L("Test completed!"));
       
   171 	return TestStepResult();
       
   172 	}