messagingappbase/smsmtm/test/src/t_smsinit.cpp
changeset 25 84d9eb65b26f
parent 23 238255e8b033
child 27 e4592d119491
child 37 518b245aa84c
child 79 2981cb3aa489
equal deleted inserted replaced
23:238255e8b033 25:84d9eb65b26f
     1 // Copyright (c) 1999-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 #include <e32test.h>
       
    17 #include <e32std.h>
       
    18 #include "t_smsinit.h"
       
    19 
       
    20 RTest test(_L("T_SmsInit Testrig"));
       
    21 CTrapCleanup* theCleanup;
       
    22 
       
    23 LOCAL_C void doMainL()
       
    24 	{
       
    25 	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
       
    26 	CleanupStack::PushL(scheduler);
       
    27 	CActiveScheduler::Install( scheduler );
       
    28 
       
    29 	CSmsInit* SmsTest = CSmsInit::NewL(test, ETuCreateTestDirectories);
       
    30 	CleanupStack::PushL(SmsTest);
       
    31 
       
    32 	SmsTest->StartL();
       
    33 
       
    34 	CleanupStack::PopAndDestroy(2); //SmsTest, scheduler
       
    35 	}
       
    36 
       
    37 GLDEF_C TInt E32Main()
       
    38 	{	
       
    39 	__UHEAP_MARK;
       
    40 	test.Start(_L("Setup"));
       
    41 	theCleanup = CTrapCleanup::New();
       
    42 	TRAPD(ret,doMainL());		
       
    43 	test(ret==KErrNone);
       
    44 	delete theCleanup;	
       
    45 	test.Console()->SetPos(0, 13);
       
    46 	test.End();
       
    47 	test.Close();
       
    48 	__UHEAP_MARKEND;
       
    49 	return(KErrNone);
       
    50 	}
       
    51 
       
    52 CSmsInit::CSmsInit()
       
    53 : CSmsTestBase()
       
    54 	{
       
    55 	}
       
    56 
       
    57 void CSmsInit::ConstructL(RTest& aTest, TUint aCreationFlags)
       
    58 	{
       
    59 	iSmsTest = CSmsTestUtils::NewL(aTest, aCreationFlags);
       
    60 	}
       
    61 
       
    62 void CSmsInit::ShowMenuL()
       
    63 	{
       
    64 	iSmsTest->ResetMenu();
       
    65 
       
    66 	iSmsTest->AppendToMenuL(_L("Create SMS MTM Dat File"));
       
    67 	iSmsTest->AppendToMenuL(_L("Install SMS MTM Group"));
       
    68 	iSmsTest->AppendToMenuL(_L("Both of the Above (Create Dat File and Install MTM Group)"));
       
    69 	iSmsTest->AppendToMenuL(_L("Replace/Create Sms Service"));
       
    70 	iSmsTest->AppendToMenuL(_L("All of the Above"));
       
    71 
       
    72 	TInt result = iSmsTest->DisplayMenu(_L("SMS Initialisation"));
       
    73 
       
    74 	if (result <= 0)
       
    75 		return;
       
    76 
       
    77 	if (result == 1 || result == 3 || result == 5)
       
    78 		{
       
    79 		iSmsTest->Printf(_L("Creating SMS MTM Dat File\n"));
       
    80 		iSmsTest->CreateServerMtmRegsL();
       
    81 		}
       
    82 
       
    83 	if (result != 1)
       
    84 		{
       
    85 		iSmsTest->Printf(_L("Going Client Side\n"));
       
    86 		iSmsTest->GoClientSideL();
       
    87 		}
       
    88 
       
    89 	if (result != 1 && result != 4)
       
    90 		{
       
    91 		iSmsTest->Printf(_L("Installing SMS MTM Group\n"));
       
    92 		iSmsTest->InstallMtmGroupsL();
       
    93 		}
       
    94 
       
    95 	if (result == 4 || result == 5)
       
    96 		{
       
    97 		iSmsTest->Printf(_L("Replacing/Creating Sms Service\n"));
       
    98 		iSmsTest->DeleteServicesL();
       
    99 		iSmsTest->CreateServicesL();
       
   100 		}
       
   101 
       
   102 	iSmsTest->Test().Printf(_L("\nPress any key to continue..."));
       
   103 	iSmsTest->Test().Getch();
       
   104 
       
   105 	ShowMenuL();
       
   106 	}
       
   107 
       
   108 CSmsInit::~CSmsInit()
       
   109 	{
       
   110 	}
       
   111 
       
   112 CSmsInit* CSmsInit::NewL(RTest& aTest, TUint aCreationFlags)
       
   113 	{
       
   114 	CSmsInit* self = new (ELeave) CSmsInit();
       
   115 	CleanupStack::PushL(self);
       
   116 
       
   117 	self->ConstructL(aTest, aCreationFlags);
       
   118 
       
   119 	CleanupStack::Pop();
       
   120 	return self;
       
   121 	}