mmsengine/mmssettings/test/inc/T_MmsSettings.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 // Copyright (c) 2004-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 //
       
    15 
       
    16 #ifndef __T_MMSSETTINGS_H__
       
    17 #define __T_MMSSETTINGS_H__
       
    18 
       
    19 #include <e32base.h>
       
    20 #include "msvtestutilsbase.h"
       
    21 #include <mtclreg.h>
       
    22 #include <msvids.h>
       
    23 #include <msvuids.h>
       
    24 #include <msvapi.h>
       
    25 #include <e32uid.h>
       
    26 #include <msvruids.h>
       
    27 
       
    28 
       
    29 // to be defined by test harness
       
    30 GLREF_D RTest test; 
       
    31 GLREF_D void doTestsL();
       
    32 
       
    33 // forward declarations
       
    34 class CMMSTestUtils;
       
    35 
       
    36 // globals
       
    37 TInt SchedulerError;
       
    38 CMMSTestUtils* theUtils = NULL;
       
    39 CTrapCleanup* theCleanup = NULL;
       
    40 
       
    41 
       
    42 TInt theErr;
       
    43 #define REPORT_IF_ERROR(a) {theErr=a; if (theErr) test(0);}
       
    44 
       
    45 //**********************************
       
    46 // CTestScheduler
       
    47 //**********************************
       
    48 
       
    49 class CTestScheduler : public CActiveScheduler
       
    50 	{
       
    51 public:
       
    52 	void Error (TInt aError) const;
       
    53 	};
       
    54 
       
    55 void CTestScheduler::Error( TInt anError ) const
       
    56 	{
       
    57 	SchedulerError = anError;
       
    58 	}
       
    59 
       
    60 //**********************************
       
    61 // CSendTestUtils
       
    62 //**********************************
       
    63 
       
    64 class CMMSTestUtils : public CTestUtils
       
    65 	{
       
    66 public:
       
    67 	static CMMSTestUtils* NewL(RTest& aTest);
       
    68 protected:
       
    69 	CMMSTestUtils(RTest& aTest);
       
    70 public:
       
    71 	void Panic(TInt aPanic);
       
    72 	void Start(const TDesC& aDes);
       
    73 	void Complete();
       
    74 
       
    75 private:
       
    76 	TInt iTestNum;
       
    77 	};
       
    78 
       
    79 CMMSTestUtils* CMMSTestUtils::NewL(RTest& aTest)
       
    80 	{
       
    81 	CMMSTestUtils* self = new(ELeave)CMMSTestUtils(aTest);
       
    82 	CleanupStack::PushL(self);
       
    83 	self->ConstructL();
       
    84 	CleanupStack::Pop(self);
       
    85 	return self;
       
    86 	}
       
    87 
       
    88 CMMSTestUtils::CMMSTestUtils(RTest& aTest) :
       
    89 	CTestUtils(aTest)
       
    90 	{
       
    91 	}
       
    92 
       
    93 void CMMSTestUtils::Panic(TInt)
       
    94 	{
       
    95 	test(EFalse);
       
    96 	}
       
    97 
       
    98 void CMMSTestUtils::Start(const TDesC& aDes)
       
    99 	{
       
   100 	if (iTestNum == 0)
       
   101 		{
       
   102 		test.Start(aDes);
       
   103 		}
       
   104 	else
       
   105 		{
       
   106 		test.Next(aDes);
       
   107 		}
       
   108 
       
   109 	TestStart(++iTestNum, aDes);
       
   110 	}
       
   111 
       
   112 void CMMSTestUtils::Complete()
       
   113 	{
       
   114 	TestFinish(iTestNum, KErrNone);
       
   115 	}
       
   116 
       
   117 //**********************************
       
   118 // Global
       
   119 //**********************************
       
   120 
       
   121 void SetupSchedulerL()
       
   122 	{
       
   123 	CActiveScheduler::Install(new(ELeave)CTestScheduler);
       
   124 	}
       
   125 
       
   126 void CloseScheduler(TInt aRet)
       
   127 	{
       
   128 	if (theUtils)
       
   129 		{
       
   130 		if (!aRet)
       
   131 			{
       
   132 			theUtils->TestHarnessCompleted();
       
   133 			}
       
   134 		else
       
   135 			{
       
   136 			theUtils->TestHarnessFailed(aRet);
       
   137 			}
       
   138 		}
       
   139 	test(aRet == KErrNone);
       
   140 
       
   141 	delete CActiveScheduler::Current();
       
   142 	}
       
   143 
       
   144 void doMainL()
       
   145 	{
       
   146 	SetupSchedulerL();
       
   147 
       
   148 	// MMS Settings test utils
       
   149 	theUtils = CMMSTestUtils::NewL(test);
       
   150 
       
   151   	// do the tests
       
   152 	doTestsL();
       
   153 	}
       
   154 
       
   155 GLDEF_C TInt E32Main()
       
   156 	{
       
   157 	__UHEAP_MARK;
       
   158 	theCleanup=CTrapCleanup::New();
       
   159 	TRAPD(ret,doMainL());		
       
   160 	test(ret == KErrNone);
       
   161 	CloseScheduler(ret);
       
   162 	delete theUtils;
       
   163 	delete theCleanup;	
       
   164 	test.Console()->SetPos(0, 13);
       
   165 	test.End();
       
   166 	test.Close();
       
   167 	__UHEAP_MARKEND;
       
   168 	return(KErrNone);
       
   169 	}
       
   170 
       
   171 #endif