telephonyserverplugins/common_tsy/test/integration/src/tsmsmessagingtsytesthelper.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     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 "tsmsmessagingtsytesthelper.h" 
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21 * Constructor
       
    22 */	
       
    23 TSmsMessagingTsyTestHelper::TSmsMessagingTsyTestHelper(CCTSYIntegrationTestSuiteStepBase& aTestStep)
       
    24 			: TTsyTestHelperBase( aTestStep )
       
    25 	{
       
    26 	}
       
    27 /**
       
    28 * Notify reset for RMobileSmsMessaging::NotifyMoSmsBearerChange
       
    29 */	
       
    30 void TSmsMessagingTsyTestHelper::WaitForMobileSmsMessagingNotifyMoSmsBearerChange( 
       
    31 				RMobileSmsMessaging& aMobileSmsMessaging,
       
    32 				TEtelRequestBase& aRequestStatus,
       
    33 				RMobileSmsMessaging::TMobileSmsBearer& aBearer, 
       
    34 				RMobileSmsMessaging::TMobileSmsBearer aExpectedBearer,
       
    35 				TInt aWantedStatus )
       
    36 
       
    37 	{
       
    38 	// Wait for the request to complete	
       
    39 	TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);	
       
    40 	ASSERT_EQUALS(err, KErrNone, _L("RMobileSmsMessaging::NotifyMoSmsBearerChange did not complete"))
       
    41 	
       
    42 	while (	err == KErrNone && aRequestStatus.Int() == KErrNone  	
       
    43 							&& aBearer != aExpectedBearer )
       
    44 		{
       
    45 		// Request has completed with incorrect result. Consume any outstanding
       
    46 		// Repost notification until timeout or we get the right result.
       
    47 		
       
    48 		aMobileSmsMessaging.NotifyMoSmsBearerChange(aRequestStatus, aBearer);
       
    49 		err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);
       
    50 		}
       
    51 		
       
    52 	ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobileSmsMessaging::NotifyMoSmsBearerChange Wrong completion status"))	
       
    53 	ASSERT_EQUALS(aBearer, aExpectedBearer, 
       
    54 				_L("RMobileSmsMessaging::NotifyMoSmsBearerChange Wrong result"))	
       
    55 	
       
    56 	// Cancel request if it is still pending	
       
    57 	if (aRequestStatus.Int() == KRequestPending)	
       
    58 		{
       
    59 		aRequestStatus.Cancel();
       
    60 		}
       
    61 	}
       
    62 
       
    63 		
       
    64 /**
       
    65 * Notify reset for RMobileSmsMessaging::NotifyReceiveModeChange
       
    66 */	
       
    67 void TSmsMessagingTsyTestHelper::WaitForMobileSmsMessagingNotifyReceiveModeChange( 
       
    68 				RMobileSmsMessaging& aMobileSmsMessaging,
       
    69 				TEtelRequestBase& aRequestStatus,
       
    70 				RMobileSmsMessaging::TMobileSmsReceiveMode& aReceiveMode, 
       
    71 				RMobileSmsMessaging::TMobileSmsReceiveMode aExpectedReceiveMode,
       
    72 				TInt aWantedStatus )
       
    73 
       
    74 	{
       
    75 	// Wait for the request to complete	
       
    76 	TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);	
       
    77 	ASSERT_EQUALS(err, KErrNone, _L("RMobileSmsMessaging::NotifyReceiveModeChange did not complete"))
       
    78 	
       
    79 	while (	err == KErrNone && aRequestStatus.Int() == KErrNone  	
       
    80 							&& aReceiveMode != aExpectedReceiveMode )
       
    81 		{
       
    82 		// Request has completed with incorrect result. Consume any outstanding
       
    83 		// Repost notification until timeout or we get the right result.
       
    84 		
       
    85 		aMobileSmsMessaging.NotifyReceiveModeChange(aRequestStatus, aReceiveMode);
       
    86 		err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);
       
    87 		}
       
    88 		
       
    89 	ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobileSmsMessaging::NotifyReceiveModeChange Wrong completion status"))	
       
    90 	ASSERT_EQUALS(aReceiveMode, aExpectedReceiveMode, 
       
    91 				_L("RMobileSmsMessaging::NotifyReceiveModeChange Wrong result"))	
       
    92 	
       
    93 	// Cancel request if it is still pending	
       
    94 	if (aRequestStatus.Int() == KRequestPending)	
       
    95 		{
       
    96 		aRequestStatus.Cancel();
       
    97 		}
       
    98 	}
       
    99 
       
   100 		
       
   101 /**
       
   102 * Notify reset for RMobileSmsMessaging::NotifySmspListChange
       
   103 */	
       
   104 void TSmsMessagingTsyTestHelper::WaitForMobileSmsMessagingNotifySmspListChange( 
       
   105 				TEtelRequestBase& aRequestStatus,
       
   106 				TInt aWantedStatus )
       
   107 
       
   108 	{
       
   109 	// Wait for the request to complete	
       
   110 	TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort);	
       
   111 	ASSERT_EQUALS(err, KErrNone, _L("RMobileSmsMessaging::NotifySmspListChange did not complete"))
       
   112 	ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobileSmsMessaging::NotifySmspListChange Wrong completion status"))		
       
   113 	// Cancel request if it is still pending	
       
   114 	if (aRequestStatus.Int() == KRequestPending)	
       
   115 		{
       
   116 		aRequestStatus.Cancel();
       
   117 		}
       
   118 	}