commsfwutils/commsbufs/mbufgobblerlayer/te_mbufgobbler/src/te_mbufgobblertest.cpp
branchRCL_3
changeset 84 486e9e9c45a7
parent 76 576874e13a2c
child 85 7c25be0307fe
equal deleted inserted replaced
76:576874e13a2c 84:486e9e9c45a7
     1 // Copyright (c) 2010 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 //  Test steps
       
    15 //
       
    16 
       
    17 /**
       
    18  @file
       
    19  @internalComponent
       
    20 */
       
    21 
       
    22 
       
    23 #include <stdlib.h>
       
    24 #include <string.h>
       
    25 //#include <profiler.h>
       
    26 #include <test/testexecutelog.h>
       
    27 #include <in_sock.h>
       
    28 #include "te_mbufgobblertest.h"
       
    29 #include "mbufgobblertestflags.h"
       
    30 
       
    31 
       
    32 CMbufGobblerStartupTest::CMbufGobblerStartupTest(CMbufGobblerTestServer* /*aOwner*/)
       
    33 	{
       
    34 	SetTestStepName(KTestMbufGobblerStartupTest);
       
    35 	}
       
    36 
       
    37 CMbufGobblerStartupTest::~CMbufGobblerStartupTest()
       
    38 	{
       
    39 	}
       
    40     
       
    41 TVerdict CMbufGobblerStartupTest::doTestStepL()
       
    42 	{
       
    43 #ifdef _DEBUG
       
    44     SetTestStepResult( EFail );    
       
    45     
       
    46     User::LeaveIfError(MbufGobblerTestFlags::ActivateTestFlags());
       
    47 
       
    48 	INFO_PRINTF1(_L("  .. opening socket server.."));
       
    49 	RSocketServ sockServ;
       
    50     User::LeaveIfError(sockServ.Connect());
       
    51     CleanupClosePushL(sockServ);
       
    52     
       
    53 	INFO_PRINTF1(_L("  .. opening connection.."));
       
    54 	RConnection conn;
       
    55     User::LeaveIfError(conn.Open(sockServ));
       
    56     CleanupClosePushL(conn);
       
    57     User::LeaveIfError(conn.Start()); // start default connection (defined in commsdat)
       
    58     
       
    59 	INFO_PRINTF1(_L("Checking Tier up.."));
       
    60     TInt result = MbufGobblerTestFlags::GetResult(MbufGobblerTestFlags::KTierUp);
       
    61     User::LeaveIfError(result);
       
    62 	INFO_PRINTF2(_L("Tier started ok [%d]."),result);
       
    63     
       
    64 	INFO_PRINTF1(_L("Checking MCPr up.."));
       
    65     result = MbufGobblerTestFlags::GetResult(MbufGobblerTestFlags::KMCPrUp);
       
    66     User::LeaveIfError(result);
       
    67 	INFO_PRINTF2(_L("MCPr started ok [%d]."),result);
       
    68 
       
    69 	INFO_PRINTF1(_L("Checking CPr up.."));
       
    70     result = MbufGobblerTestFlags::GetResult(MbufGobblerTestFlags::KCPrUp);
       
    71     User::LeaveIfError(result);
       
    72 	INFO_PRINTF2(_L("CPr started ok [%d]."),result);
       
    73 
       
    74 	INFO_PRINTF1(_L("Checking SCPr up.."));
       
    75     result = MbufGobblerTestFlags::GetResult(MbufGobblerTestFlags::KSCPrUp);
       
    76     User::LeaveIfError(result);
       
    77 	INFO_PRINTF2(_L("SCPr started ok [%d]."),result);
       
    78 
       
    79 	INFO_PRINTF1(_L("Checking Binder up.."));
       
    80     result = MbufGobblerTestFlags::GetResult(MbufGobblerTestFlags::KBind);
       
    81     User::LeaveIfError(result);
       
    82 	INFO_PRINTF2(_L("Binder up ok [%d]."),result);
       
    83 
       
    84 	INFO_PRINTF1(_L("  .. opening socket.."));
       
    85     RSocket sock;
       
    86 	User::LeaveIfError(sock.Open(sockServ,KAfInet,KSockDatagram,KProtocolInetUdp,conn));
       
    87     CleanupClosePushL(sock);
       
    88 	
       
    89 	INFO_PRINTF1(_L("  .. sending a packet.."));
       
    90 	TBuf8<128> pkt;
       
    91 	pkt.SetLength(128);
       
    92 	TInetAddr dest;
       
    93 	dest.Input(_L("11.22.33.44"));
       
    94 	dest.SetPort(100);
       
    95 	TRequestStatus status;
       
    96 	sock.SendTo(pkt,dest,0,status);
       
    97 	User::WaitForRequest(status);
       
    98 	User::LeaveIfError(status.Int());
       
    99 	
       
   100 	INFO_PRINTF1(_L("Checking Send occurred.."));
       
   101     result = MbufGobblerTestFlags::GetResult(MbufGobblerTestFlags::KBinderSend);
       
   102     User::LeaveIfError(result);
       
   103 	INFO_PRINTF2(_L("Send occurred ok [%d]."),result);
       
   104 
       
   105 	INFO_PRINTF1(_L("Checking Receive occurred.."));
       
   106     result = MbufGobblerTestFlags::GetResult(MbufGobblerTestFlags::KBinderReceive);
       
   107     User::LeaveIfError(result);
       
   108 	INFO_PRINTF2(_L("Receive occurred ok [%d]."),result);
       
   109 
       
   110 	// Remove this call if its high capability requirement is a problem
       
   111 	INFO_PRINTF1(_L("  .. stopping connection.."));
       
   112 	User::LeaveIfError(conn.Stop());
       
   113 	
       
   114     CleanupStack::Pop(); // RSocket close
       
   115     CleanupStack::Pop(); // RConnection close
       
   116     CleanupStack::Pop(); // RSocketServ close
       
   117 
       
   118 	// return success / failure
       
   119     SetTestStepResult( EPass );
       
   120 #else // _DEBUG
       
   121     SetTestStepResult( EPass );    
       
   122 	INFO_PRINTF1(_L("  .. results for this component only useful in UDEB mode."));
       
   123 #endif    
       
   124 	return TestStepResult();
       
   125 	}
       
   126