Example #1
0
void TestMain::RunTests()
{
	PrepareTest();
	Test1();
	TeardownTest();

	PrepareTest();
	Test2();
	TeardownTest();

	PrepareTest();
	Test3();
	TeardownTest();
}
// ---------------------------------------------------------------------------
// CStunTurnTests::DoRunInterfaceTestsL
// 
// ---------------------------------------------------------------------------
//
void CStunTurnTests::DoRunStunTurnTestsL()
    {
    TInt err( KErrNone );
    
    iConsole.Printf( _L("Create session test") );
    RDebug::Print( _L("\n\nNAT_TEST_START: Create session") );
    //__UHEAP_MARK; 
    TRAP( err, TestCreateSessionL() );
    //__UHEAP_MARKEND;
    RDebug::Print( _L("\nNAT_TEST_STOP: Create session, ERR: %d"), err );
    PrintTestResult( err );
    
    err = KErrNone;
    RDebug::Print( _L("\n\nNAT_TEST_START: Create stream") );
    iConsole.Printf( _L("Create stream test") );
    __UHEAP_MARK;
    TRAP( err, TestCreateStreamL() );
    RDebug::Print( _L("\nNAT_TEST_STOP: Create stream, ERR: %d"), err );
    PrintTestResult( err );
    __UHEAP_MARKEND;
   
    err = KErrNone;
    RDebug::Print( _L("\n\nNAT_TEST_START: Create wrapper") );
    iConsole.Printf( _L("Create wrapper test") );
    __UHEAP_MARK;
    TRAP( err, TestCreateWrapperL() ); 
    RDebug::Print( _L("\nNAT_TEST_STOP: Create wrapper, ERR: %d"), err );
    PrintTestResult( err );
    __UHEAP_MARKEND;
    
    err = KErrNone;
    RDebug::Print( _L("\n\nNAT_TEST_START: Set incoming Address to wrapper") );
    iConsole.Printf( _L("Set Incoming Address to wrapper test") );
    __UHEAP_MARK;
    TRAP( err, SetupTestL() );
    if ( !err )
        {
        __UHEAP_MARK;
        TRAP( err, TestSetIncomingAddrL() );
        __UHEAP_MARKEND;
        TeardownTest();
        }
    else
        {
        RDebug::Print( _L("\nTEST PRINT: Setup fails, ERR: %d"), err );
        }
    RDebug::Print( _L("\nNAT_TEST_STOP: Set incoming Address to wrapper, ERR: %d"), err );
    PrintTestResult( err );
    __UHEAP_MARKEND;
    
    err = KErrNone;
    RDebug::Print( _L("\n\nNAT_TEST_START: Outgoing address") );
    iConsole.Printf( _L("Get outgoing address from wrapper test") );
    __UHEAP_MARK;
    TRAP( err, SetupTestL() );
    if ( !err )
        {
        __UHEAP_MARK;
        TRAP( err, TestOutgoingAddrL() );
        __UHEAP_MARKEND;
        TeardownTest();
        }
    else
        {
        RDebug::Print( _L("\nTEST PRINT: Setup fails, ERR: %d"), err );
        }
    RDebug::Print( _L("\nNAT_TEST_STOP: Outgoing address, ERR: %d"), err );
    PrintTestResult( err );
    __UHEAP_MARKEND;
    
    err = KErrNone;
    RDebug::Print( _L("\n\nNAT_TEST_START: Fetch candidate") );
    iConsole.Printf( _L("Fetch Candidate test") );
    __UHEAP_MARK;
    TRAP( err, TestFetchCandidateL() );
    RDebug::Print( _L("\nNAT_TEST_STOP: Fetch candidate, ERR: %d"), err );
    PrintTestResult( err );
    __UHEAP_MARKEND;
    
    err = KErrNone;
    RDebug::Print( _L("\n\nNAT_TEST_START: Fetch candidate: wrong server address") );
    iConsole.Printf( _L("Fetch Candidate wrong server address test") );
    __UHEAP_MARK;
    TRAP( err, SetupWrongServerAddressTestL() );
    if ( !err )
        {
        __UHEAP_MARK;
        TRAP( err, TestFetchCandidateL() );
        __UHEAP_MARKEND;
        }
    else
        {
        RDebug::Print( _L("\nTEST PRINT: Setup fails, ERR: %d"), err );
        } 
    TeardownWrongServerAddressTest();
    RDebug::Print( _L("\nNAT_TEST_STOP: Fetch candidate wrong server address, ERR: %d"), err );
    PrintTestResult( err );
    __UHEAP_MARKEND;
    
    
    err = KErrNone;
    RDebug::Print( _L("\n\nNAT_TEST_START: Set sending status ") );
    iConsole.Printf( _L("Set Sending Status test") );
    __UHEAP_MARK;
    TRAP( err, SetupTest2L() );
    if ( !err )
        {
        __UHEAP_MARK;
         if ( KProtocolInetUdp == iProtocol )
            {
            TRAP( err, TestSetSendingStatusUDPL() );
            }
        else
            {
            TRAP( err, TestSetSendingStatusTCPL() );
            }
        __UHEAP_MARKEND;
        }
    else
        {
        RDebug::Print( _L("\nTEST PRINT: Setup fails, ERR: %d"), err );
        }
    TeardownTest();
    RDebug::Print( _L("\nNAT_TEST_STOP: Set sending status, ERR: %d"), err );
    PrintTestResult( err );
    __UHEAP_MARKEND;
  
    err = KErrNone;
    RDebug::Print( _L("\n\nNAT_TEST_START: Set receiving status") );
    iConsole.Printf( _L("Set Receiving Status test") );
    __UHEAP_MARK;
    TRAP( err, SetupTest2L() );
    if ( !err )
        {
        __UHEAP_MARK;
        if ( KProtocolInetUdp == iProtocol )
            {
            TRAP( err, TestSetReceivingStatusUDPL() );
            }
        else
            {
            TRAP( err, TestSetReceivingStatusTCPL() );
            }
        __UHEAP_MARKEND;
        TeardownTest();
        }
    else
        {
        RDebug::Print( _L("\nTEST PRINT: Setup fails, ERR: %d"), err );
        }
    
    RDebug::Print( _L("\nNAT_TEST_STOP: Set receiving status, ERR: %d"), err );
    PrintTestResult( err );
    __UHEAP_MARKEND;
    }