networksecurity/tls/ts_tls/TlsTestSection3.cpp
changeset 0 af10295192d8
child 71 a800ea6cb454
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 // Copyright (c) 2003-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 // This contains TLS test section 3
       
    15 // 
       
    16 //
       
    17 
       
    18 // Test system includes
       
    19 #include "T_TLS_test.h"
       
    20 #include "TlsTestSection3.h"
       
    21 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    22 #include <securesocket_internal.h>
       
    23 #endif
       
    24 
       
    25 GLREF_C void CommInitL();
       
    26 
       
    27 
       
    28 CTlsTestSection3_1::CTlsTestSection3_1()
       
    29 /**
       
    30  * Constructor.
       
    31  * Stores the name of this test case.
       
    32  */
       
    33 {
       
    34 	iTestStepName = _L("tls_TestSection3_1");
       
    35 }
       
    36 
       
    37 
       
    38 CTlsTestSection3_1::~CTlsTestSection3_1()
       
    39 /**
       
    40  * Destructor.
       
    41  */
       
    42 {
       
    43 }
       
    44 
       
    45 
       
    46 TVerdict CTlsTestSection3_1::doTestStepL( )
       
    47 {
       
    48 	Log(_L("SSL Socket options test"));
       
    49 
       
    50 	__UHEAP_MARK;
       
    51 	// assume that everything passed, unless we leave
       
    52 	iTestStepResult = EPass;
       
    53 	TInt error(KErrNone);
       
    54     TInt recvBufSize(-1), sendBufSize(-1);
       
    55 	TInt noDelayEnabled(-1);
       
    56 
       
    57 	// Create an active scheduler
       
    58 	CActiveScheduler* myActiveScheduler = new(ELeave) CActiveScheduler();
       
    59 	CleanupStack::PushL( myActiveScheduler );
       
    60 	CActiveScheduler::Install( myActiveScheduler );
       
    61 
       
    62 	// Connect the socket server
       
    63 	RSocketServ socketServ;
       
    64 	error = socketServ.Connect();
       
    65 	TESTEL(error == KErrNone, error);
       
    66 	CleanupClosePushL(socketServ);
       
    67 
       
    68 	// Open a socket
       
    69 	RSocket socket;
       
    70 	error = socket.Open( socketServ, KAfInet, KSockStream, KProtocolInetTcp );
       
    71 	TESTEL(error == KErrNone, error);
       
    72 	CleanupClosePushL(socket);
       
    73 
       
    74 	Log(_L("Creating a secure socket"));
       
    75 	CSecureSocket* secureSocket = NULL;
       
    76 	secureSocket = CSecureSocket::NewL( socket, KDefCfgProtocol );
       
    77 
       
    78 	// Now do sSetOpt's and GetOpt's at 
       
    79 	Log(_L("Setting KSORecvBuf to 1000"));
       
    80     error = secureSocket->SetOpt(KSORecvBuf, KSOLSocket, 1000);
       
    81     TESTEL(error == KErrNone, error);
       
    82 
       
    83 	Log(_L("Checking KSORecvBuf is set to 1000"));
       
    84     error = secureSocket->GetOpt(KSORecvBuf, KSOLSocket, recvBufSize);
       
    85     TESTEL(error == KErrNone, error);
       
    86     TESTEL(recvBufSize == 1000, recvBufSize);
       
    87 
       
    88     error = secureSocket->GetOpt(KSOSendBuf, KSOLSocket, sendBufSize);
       
    89     TESTEL(error == KErrNone, error);
       
    90 	Log(_L("Read sendbuf size of %d"), sendBufSize);
       
    91 
       
    92 	Log(_L("Read KSoTcpNoDelay of %d"), noDelayEnabled);
       
    93     error = secureSocket->GetOpt(KSoTcpNoDelay, KSolInetTcp, noDelayEnabled);
       
    94     TESTEL(error == KErrNone, error);
       
    95 
       
    96     error = secureSocket->SetOpt(KSoTcpNoDelay, KSolInetTcp, !noDelayEnabled);
       
    97     TESTEL(error == KErrNone, error);
       
    98 
       
    99 	TDialogMode dialogMode = secureSocket->DialogMode();
       
   100 	Log( _L("Dialog mode setting is: %d"), dialogMode );			
       
   101 
       
   102     error = secureSocket->SetDialogMode(EDialogModeUnattended);
       
   103     TESTEL(error == KErrNone, error);
       
   104     TESTL(secureSocket->DialogMode()==EDialogModeUnattended);
       
   105 	Log( _L("Dialog mode setting is: %d"), EDialogModeUnattended );			
       
   106 
       
   107     error = secureSocket->SetDialogMode(dialogMode);
       
   108     TESTEL(error == KErrNone, error);
       
   109     TESTL(secureSocket->DialogMode()==dialogMode);
       
   110 	Log( _L("Dialog mode reset to: %d"), dialogMode );			
       
   111 
       
   112 	secureSocket->Close();
       
   113 	delete secureSocket;
       
   114 	secureSocket = NULL;
       
   115 
       
   116 	CleanupStack::PopAndDestroy(); // socket
       
   117 	CleanupStack::PopAndDestroy(); // socketServ
       
   118 
       
   119 	CActiveScheduler::Install( NULL );
       
   120 	CleanupStack::PopAndDestroy( myActiveScheduler );
       
   121 
       
   122 	// unload the securesocket library
       
   123 	CSecureSocketLibraryLoader::Unload();
       
   124 	
       
   125 	__UHEAP_MARKEND;
       
   126 
       
   127 	return iTestStepResult;
       
   128 }