supl/locationomasuplpostester/epos_comasuplpostestermodulecfg/src/epos_comasuplmsgfilereadertest.cpp
changeset 0 667063e416a2
equal deleted inserted replaced
-1:000000000000 0:667063e416a2
       
     1 /*
       
     2 * Copyright (c) 2005-2006 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:  Tests Reading of message file.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <ecom/ecom.h>
       
    19 #include <ecom/implementationinformation.h>
       
    20 #include <epos_comasuplpospayload.h>
       
    21 
       
    22 #include "epos_comasuplmsgfilereadertest.h"
       
    23 #include "epos_comasuplmessagefilereader.h"
       
    24 #include "epos_comasuplpostesterlogger.h"
       
    25 #include "epos_comasupltesthandler.h"
       
    26 #include "epos_comasuplpossessioncreationtest.h"
       
    27 
       
    28 #include "epos_comasuplposhandlerbase.h"
       
    29 #include "epos_comasuplpossessionbase.h"
       
    30 
       
    31 // ---------------------------------------------------------------------------
       
    32 // Named constructor
       
    33 // ---------------------------------------------------------------------------
       
    34 //
       
    35 COMASuplMsgFileReaderTest* COMASuplMsgFileReaderTest::NewL(
       
    36 							TFileName& aMsgFile
       
    37 							, COMASuplPosTesterCategory* aCallBack)
       
    38 	{
       
    39 	COMASuplMsgFileReaderTest* self =
       
    40 						 new(ELeave)COMASuplMsgFileReaderTest(aCallBack);
       
    41 	CleanupStack::PushL(self);
       
    42 	self->ConstructL(aMsgFile);
       
    43 	CleanupStack::Pop(self);
       
    44 	return self;
       
    45 	}
       
    46 
       
    47 COMASuplMsgFileReaderTest::COMASuplMsgFileReaderTest(
       
    48 										COMASuplPosTesterCategory* aCallBack)
       
    49 										:COMASuplPosTesterCategory(aCallBack)
       
    50 										
       
    51 	{
       
    52 	iNextInSeq = EPosSessionTestComplete;
       
    53 	}
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // Second phase constructor
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 void COMASuplMsgFileReaderTest::ConstructL(TFileName& aMsgFile)
       
    60 	{
       
    61 	CActiveScheduler::Add(this);
       
    62 	iMsgFileName.Copy(aMsgFile);
       
    63 	}
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // Destructor
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 COMASuplMsgFileReaderTest::~COMASuplMsgFileReaderTest()
       
    70 	{
       
    71 	Cancel();
       
    72 	if(iMsgInfoList)
       
    73 		{
       
    74 		iMsgInfoList->ResetAndDestroy();
       
    75 		delete iMsgInfoList;
       
    76 		}
       
    77 	
       
    78 	delete iMsgFileReader;
       
    79 	}
       
    80 
       
    81 void COMASuplMsgFileReaderTest::InitializeL(COMASuplTestHandler* aTestHandler
       
    82 								, COMASuplPosTesterLogger& aLogger
       
    83 								, TInt aTestNo)
       
    84 	{
       
    85 	iTestHandler = aTestHandler;
       
    86 	iLogger = &aLogger;
       
    87 	iTestNo = aTestNo;
       
    88 	}
       
    89 // ---------------------------------------------------------------------------
       
    90 // This function is called by test handler. It is entry point of execution
       
    91 // of a test case.
       
    92 // ---------------------------------------------------------------------------
       
    93 //
       
    94 void COMASuplMsgFileReaderTest::StartTestingL()
       
    95 	{
       
    96 	if(iCallBack)
       
    97 		{
       
    98 		iLogger->WriteTestHeader(KMessageReaderTest, iTestNo);
       
    99 		}
       
   100 	iNextInSeq = EStartTest;
       
   101 	__ASSERT_ALWAYS(!IsActive(),User::Panic(KPanicSetActive, KErrAlreadyExists));
       
   102 	DummyRequest(iStatus);
       
   103 	SetActive();
       
   104 	}
       
   105 
       
   106 // ---------------------------------------------------------------------------
       
   107 // Handles an active object's request completion event.
       
   108 // ---------------------------------------------------------------------------
       
   109 //
       
   110 void COMASuplMsgFileReaderTest::RunL()
       
   111 	{
       
   112 	switch(iNextInSeq)
       
   113 		{
       
   114 		case EStartTest:
       
   115 			{
       
   116 			iMsgFileReader = COMASuplMessageFileReader::NewL(iMsgFileName, iLogger);
       
   117 			iInfo++; //info about message file name
       
   118 			iMsgInfoList = NULL;
       
   119 			iMsgInfoList = &(iMsgFileReader->GetMessageListL());
       
   120 			TestingComplete(KMessageReaderTestComplete);
       
   121 			break;
       
   122 			}
       
   123 		}
       
   124 	}
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // Implements cancellation of an outstanding request.
       
   128 // ---------------------------------------------------------------------------
       
   129 //
       
   130 void COMASuplMsgFileReaderTest::DoCancel()
       
   131 	{
       
   132 	}
       
   133 
       
   134 // ---------------------------------------------------------------------------
       
   135 // Handles a leave occurring in the request completion event handler RunL().
       
   136 // ---------------------------------------------------------------------------
       
   137 //
       
   138 TInt COMASuplMsgFileReaderTest::RunError(TInt /*aError*/)
       
   139 	{
       
   140 	iError++;//Leave in file reader is to be counted.
       
   141 	TestingAborted(KMessageReaderTestAborted);
       
   142 	return KErrNone;
       
   143 	}