kerneltest/e32test/device/d_lddturnaroundtimertest.cpp
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2006-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 the License "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 // e32test\device\d_lddturnaoundtimertest.cpp
       
    15 // LDD for getting the timer count & ticks for testing turnaround timer implementation.
       
    16 // 
       
    17 //
       
    18 
       
    19 #include <kernel/kernel.h>
       
    20 #include "d_lddturnaroundtimertest.h"
       
    21 
       
    22 class DTest1;
       
    23 class DTestFactory : public DLogicalDevice
       
    24 //
       
    25 // Test LDD factory
       
    26 //
       
    27 	{
       
    28 public:
       
    29 	DTestFactory();
       
    30 	virtual TInt Install(); 					//overriding pure virtual
       
    31 	virtual void GetCaps(TDes8& aDes) const;	//overriding pure virtual
       
    32 	virtual TInt Create(DLogicalChannelBase*& aChannel); 	//overriding pure virtual
       
    33 	};
       
    34 
       
    35 class DTest1 : public DLogicalChannelBase
       
    36 //
       
    37 // Test logical channel
       
    38 //
       
    39 	{
       
    40 public:
       
    41 	virtual ~DTest1();
       
    42 protected:
       
    43 	virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
       
    44 	virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
       
    45 	};
       
    46 
       
    47 
       
    48 
       
    49 DECLARE_STANDARD_LDD()
       
    50 	{
       
    51 	return new DTestFactory;
       
    52 	}
       
    53 
       
    54 //
       
    55 // Constructor
       
    56 //
       
    57 DTestFactory::DTestFactory()
       
    58 	{
       
    59 
       
    60 	}
       
    61 
       
    62 TInt DTestFactory::Create(DLogicalChannelBase*& aChannel)
       
    63 	{
       
    64 //
       
    65 // Create new channel
       
    66 //
       
    67 	aChannel=new DTest1;
       
    68 	return aChannel?KErrNone:KErrNoMemory;
       
    69 	}
       
    70 
       
    71 TInt DTestFactory::Install()
       
    72 //
       
    73 // Install the LDD - overriding pure virtual
       
    74 //
       
    75 	{
       
    76 	return SetName(&KLddName);
       
    77 	}
       
    78 
       
    79 void DTestFactory::GetCaps(TDes8& /*aDes*/) const
       
    80 //
       
    81 // Get capabilities - overriding pure virtual
       
    82 //
       
    83 	{
       
    84 	}
       
    85 
       
    86 TInt DTest1::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
       
    87 //
       
    88 // Create channel
       
    89 //
       
    90 	{
       
    91 	return KErrNone;
       
    92 	}
       
    93 
       
    94 DTest1::~DTest1()
       
    95 //
       
    96 // Destructor
       
    97 //
       
    98 	{
       
    99 	}
       
   100 
       
   101 TInt DTest1::Request(TInt aReqNo, TAny* a1, TAny* /*a2*/)
       
   102 	{
       
   103 //
       
   104 // Get the timer tick count & ticks
       
   105 //
       
   106     TUint temp = 0;
       
   107 	switch(aReqNo)
       
   108 		{
       
   109 		case (RLddTest1::EGET_TIMERTICKS):
       
   110 			{
       
   111 			kumemget32(&temp, a1, sizeof(temp));
       
   112 			temp = NKern::TimerTicks(temp);
       
   113 			kumemput(a1, &temp, sizeof(temp));
       
   114 			return KErrNone;
       
   115 			}
       
   116 		case (RLddTest1::EGET_TIMERTICKCOUNT):
       
   117 			{
       
   118 			temp = NKern::TickCount();
       
   119        		kumemput(a1, &temp, sizeof(temp));
       
   120 			return KErrNone;
       
   121 			}
       
   122 		}
       
   123 	return KErrNone;	
       
   124 }