appfw/apparchitecture/tef/T_AutoMMCReaderOpen.cpp
author William Roberts <williamr@symbian.org>
Fri, 23 Apr 2010 14:37:17 +0100
branchRCL_3
changeset 22 c82a39b81a38
parent 0 2e3d3ce01487
permissions -rw-r--r--
Rework addition of Symbian splash screen to reduce the source impact (uses SVG from Bug 2414) Notes: by using the OPTION SOURCEDIR parameter in the mifconv extension instructions, I can arrange to use the same source file name in sfimage, without having to export over the original Nokia file. This means that the name inside splashscreen.mbg is the same, which removes the need for the conditional compilation in SplashScreen.cpp, and gets rid of sf_splashscreen.mmp.

// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
// This is a defect fix for the following defect	
// INC040672 - MMC Card door open causes wrong mime type instead of error code	
// This test is fully automated and performs the following task
// Tests to access a file which is on MMC and the MMC card is removed at the time of access.
// 
//

/**
 @file
 @internalComponent - Internal Symbian test code
*/

#include "testableapalssession.h"
#include "T_AutoMMCReaderOpen.h"

const TInt KDirLength = 5; // No need of length more than this , hence length is 5

CTestAutoMMCReaderStep::~CTestAutoMMCReaderStep()
	{
	}

CTestAutoMMCReaderStep::CTestAutoMMCReaderStep()
	{
	SetTestStepName(KTestAutoMMCReaderOpenStep);
	}

TVerdict CTestAutoMMCReaderStep::doTestStepPreambleL()
/**
   @return - TVerdict code
   Override of base class virtual
 */
	{
	SetTestStepResult(EPass);
	return TestStepResult();
	}

TVerdict CTestAutoMMCReaderStep::doTestStepPostambleL()
/**
   @return - TVerdict code
   Override of base class virtual
 */
	{
	return TestStepResult();
	}

TVerdict CTestAutoMMCReaderStep::doTestStepL()
	{
	INFO_PRINTF1(_L("Testing Apparch...T_AutoMMCReaderOpen"));
		
	OpenMMCCardReaderDrive();
	INFO_PRINTF1(_L("\nT_AutoMMCReaderOpen Completed."));
	return TestStepResult();
	}

void CTestAutoMMCReaderStep::OpenMMCCardReaderDrive()
	{
	INFO_PRINTF1(_L("Testing fix for INC040672 - MMC Card door open causes wrong mime type instead of error code"));
	
	_LIT(KValidFileName, "ValidFileName.jpg");
		
	RFs fs;
	TInt ret = fs.Connect();
	TEST(ret == KErrNone);
	RTestableApaLsSession ls;
	ret = ls.Connect();
	TEST(ret == KErrNone);
		
//	The following steps are to reproduce the removal of MMC card
// 	Loop through drive letters Y -> D to access a file on that drive (any filename)
//	Find a drive letter that returns KErrNotReady , 
//	setup a valid filename with that drive. 

	for (TInt drive = EDriveY; drive >= EDriveD ; drive--)
		{
		TDriveUnit driveUnit(drive);	
		TDriveName driveName = driveUnit.Name();

		TBuf<KDirLength> bufDirName(driveName);
		bufDirName.Append(_L("\\"));
		
		ret = fs.MkDirAll(bufDirName);
		if (ret == KErrNotReady)
			{
			TFileName bufValidFileName(bufDirName);
			bufValidFileName.Append(KValidFileName);
			TDataType dataType;
			TUid uid = KNullUid;
			
			HEAP_TEST_LS_SESSION(ls, 0, 0, ret = ls.AppForDocument(bufValidFileName, uid, dataType), NO_CLEANUP);
			TEST(ret == KErrNotReady);
			TEST(uid == KNullUid);
			TEST(dataType == TDataType());
			break;
			}
		}
	TEST(ret == KErrNotReady);
	ls.Close();
	fs.Close();
	}