resourcemgmt/hwresourcesmgr/test/multiclient/hwrmtests/hwrmtests.cpp
changeset 0 4e1aa6a622a0
child 41 c87e5f80c17d
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2007-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 "hwrmtests.h"
       
    17 #include <e32cons.h>
       
    18 
       
    19 _LIT(KDirectoryPath, "C:\\logs\\");
       
    20 _LIT(KLogFile,"C:\\logs\\hwrmtests.log");
       
    21 _LIT8(KCrLf,"\r\n");
       
    22 _LIT8(KRTest,"RTEST:");
       
    23 
       
    24 CHwrmTests* CHwrmTests::NewL(CConsoleBase& aConsole)
       
    25 	{
       
    26 	CHwrmTests* self = NewLC(aConsole);
       
    27 	CleanupStack::Pop(self);
       
    28 	return self;
       
    29 	}
       
    30 
       
    31 CHwrmTests* CHwrmTests::NewLC(CConsoleBase& aConsole)
       
    32 	{
       
    33 	CHwrmTests* self = new (ELeave) CHwrmTests(aConsole);
       
    34 	CleanupStack::PushL(self);
       
    35 	self->ConstructL();
       
    36 	return self;
       
    37 	}
       
    38 
       
    39 CHwrmTests::CHwrmTests(CConsoleBase& aConsole)
       
    40 :	iConsole(aConsole)
       
    41 	{
       
    42 	}
       
    43 		
       
    44 void CHwrmTests::ConstructL()
       
    45 	{
       
    46 	User::LeaveIfError(iFs.Connect());
       
    47     
       
    48     //If c:\logs folder is not created, create it.
       
    49     const TInt err = iFs.MkDirAll(KDirectoryPath);
       
    50     if(err != KErrNone && err != KErrAlreadyExists)
       
    51         {
       
    52         User::Leave(err);
       
    53         }
       
    54     
       
    55 	iLogStream.Replace(iFs,KLogFile,EFileWrite | EFileShareReadersOrWriters | EFileStreamText);
       
    56 
       
    57 	iTestController = CHwrmTestCaseController::NewL(*this);
       
    58 	}
       
    59 	
       
    60 CHwrmTests::~CHwrmTests()
       
    61 	{
       
    62 	delete iTestController;
       
    63 	iLogStream.Close();
       
    64 	iFs.Close();
       
    65 	}
       
    66 
       
    67 void CHwrmTests::RunTests()
       
    68 	{
       
    69 //	__UHEAP_MARK;
       
    70 	RunBasicTests_SDK();
       
    71 //	__UHEAP_MARKEND;
       
    72 	
       
    73 //	__UHEAP_MARK;
       
    74 	RunBasicTests_Extended();
       
    75 //	__UHEAP_MARKEND;
       
    76 
       
    77 //	__UHEAP_MARK;
       
    78 	RunBasicTests_Enhanced();
       
    79 //	__UHEAP_MARKEND;
       
    80 
       
    81 
       
    82 //	__UHEAP_MARK;
       
    83 	RunVibraTests();
       
    84 //	__UHEAP_MARKEND;
       
    85 	
       
    86 //	__UHEAP_MARK;
       
    87 	RunInvalidParamTests();
       
    88 //	__UHEAP_MARKEND;
       
    89 	
       
    90 //	__UHEAP_MARK;
       
    91 	RunWaitChargingNotifyTests();
       
    92 //	__UHEAP_MARKEND;
       
    93 	}
       
    94 
       
    95 void CHwrmTests::RunBasicTests_SDK()
       
    96 	{
       
    97 	InfoAndLogMessage(_L("*** Starting Basic Tests (using SDK API) ***"));
       
    98 	iTestController->RunBasicTestCases(EHWRMApiTypeSAPI);
       
    99 	InfoAndLogMessage(_L("*** Finished Basic tests (using SDK API) ***"));
       
   100 	}
       
   101 	
       
   102 void CHwrmTests::RunBasicTests_Extended()
       
   103 	{
       
   104 	InfoAndLogMessage(_L("*** Starting Basic Tests (using Extended API) ***"));
       
   105 	iTestController->RunBasicTestCases(EHWRMApiTypeXAPI);
       
   106 	InfoAndLogMessage(_L("*** Finished Basic Tests (using Extended API) ***"));
       
   107 	}
       
   108 
       
   109 void CHwrmTests::RunBasicTests_Enhanced()
       
   110 	{
       
   111 	InfoAndLogMessage(_L("*** Starting Basic Tests (using Enhanced API) ***"));
       
   112 	iTestController->RunBasicTestCases(EHWRMApiTypeEAPI);
       
   113 	InfoAndLogMessage(_L("*** Finished Basic Tests (using Enhanced API) ***"));
       
   114 	}
       
   115 
       
   116 	
       
   117 void CHwrmTests::RunVibraTests()
       
   118 	{
       
   119 	InfoAndLogMessage(_L("*** Starting Malicious Vibra Tests ***"));
       
   120 	iTestController->RunTestCases( EMaliciousVibraTest );
       
   121 	InfoAndLogMessage(_L("*** Finished Malicious Vibra Tests ***"));
       
   122 	}
       
   123 	
       
   124 void CHwrmTests::RunInvalidParamTests()
       
   125 	{
       
   126 	InfoAndLogMessage(_L("*** Starting Invalid Parameter Tests ***"));
       
   127 	iTestController->RunTestCases(ERepeatInvalidParamsTest);
       
   128 	InfoAndLogMessage(_L("*** Finished Invalid Parameter Tests ***"));
       
   129 	}
       
   130 	
       
   131 void CHwrmTests::RunWaitChargingNotifyTests()
       
   132 	{
       
   133 	InfoAndLogMessage(_L("*** Starting Wait Charging Notifications Tests ***"));
       
   134 	iTestController->RunTestCases( EWaitForChargingNotify );
       
   135 	InfoAndLogMessage(_L("*** Finished Wait Charging Notifications Tests ***"));
       
   136 	}
       
   137 	
       
   138 void CHwrmTests::InfoMessage(const TDesC& aMessage)
       
   139 	{
       
   140 	iConsole.Printf(aMessage);
       
   141 	iConsole.Printf(_L("\r\n"));
       
   142 	}
       
   143 	
       
   144 void CHwrmTests::LogMessage(const TDesC& aMessage)
       
   145 	{
       
   146 	TRAP_IGNORE(DoLogMessageL(aMessage));
       
   147 	}
       
   148 
       
   149 void CHwrmTests::DoLogMessageL(const TDesC& aMessage)	
       
   150 	{
       
   151 //	__UHEAP_MARK;	
       
   152 	HBufC8* buf = HBufC8::NewLC(aMessage.Length());
       
   153 	buf->Des().Copy(aMessage);
       
   154 	iLogStream.WriteL(KRTest);
       
   155 	iLogStream.WriteL(*buf);
       
   156 	iLogStream.WriteL(KCrLf);
       
   157 	iLogStream.CommitL();
       
   158 	CleanupStack::PopAndDestroy(buf);
       
   159 //	__UHEAP_MARKEND;
       
   160 	}
       
   161 
       
   162 void CHwrmTests::DebugMessage(const TDesC& /*aMessage*/)
       
   163 	{
       
   164 	}
       
   165 
       
   166 void CHwrmTests::InfoAndLogMessage(const TDesC& aMessage)
       
   167 	{
       
   168 	LogMessage(aMessage);
       
   169 	InfoMessage(aMessage);
       
   170 	}