telephonyprotocols/psdagt/TS_PsdAgt/PsdAgtTestReconnect.cpp
changeset 0 3553901f7fa8
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2001-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 PsdAgt TestCase Test 14.1 - 14.5
       
    15 // 
       
    16 //
       
    17 
       
    18 // EPOC includes
       
    19 #include <e32base.h>
       
    20 #include <in_sock.h>
       
    21 
       
    22 // Test system includes
       
    23 #include "networking/log.h"
       
    24 #include "networking/teststep.h"
       
    25 #include "TestStepPsdAgt.h"
       
    26 #include "TestSuitePsdAgt.h"
       
    27 
       
    28 // COMMDB Database Undo
       
    29 #include "DbUndo.h"
       
    30 
       
    31 // RPacketContext
       
    32 #include <etelpckt.h> 
       
    33 
       
    34 // EPsdStartingConfiguration
       
    35 #include <psdprog.h>
       
    36 
       
    37 // EConnectionOpen
       
    38 #include <connectprog.h>
       
    39 
       
    40 // Class definitions
       
    41 #include "PsdAgtTestReconnect.h"
       
    42 
       
    43 // Test case 14.1
       
    44 enum TVerdict CPsdAgtTest14_1::doPsdAgtTestStepL( void )
       
    45 	{
       
    46 	TRealAgtNotify agtNotify; 
       
    47 
       
    48 	agtNotify.SetTestCase(1401);
       
    49 	// CTestStepPsdAgx base class untilty function
       
    50 	ReConnectL();
       
    51 
       
    52 	return iTestStepResult;
       
    53 	}
       
    54 
       
    55 // Test case 14.2
       
    56 enum TVerdict CPsdAgtTest14_2::doPsdAgtTestStepL( void )
       
    57 	{
       
    58 	TInt err;
       
    59 	TInt stage;
       
    60 	CNifAgentRefN1 *agent;
       
    61 
       
    62 	TRealAgtNotify agtNotify; 
       
    63 	agtNotify.SetTestCase(1402);
       
    64 
       
    65 	// Construct a new Dummy Nifman Instance
       
    66 	Log(_L("Loading DUMMYNIF.DLL"));
       
    67 	agent = CNifAgentRefN1::NewL(this,EFalse);
       
    68 	CleanupStack::PushL(agent);
       
    69 
       
    70 	// Attempt connection
       
    71 	Log(_L("Connecting..."));
       
    72 	agent->Connect();
       
    73 	
       
    74 	// Check for an error code
       
    75 	agent->GetCompletionCode(err);
       
    76 	TESTEL(err==KErrNone,err);
       
    77 
       
    78 	// Check ConnectComplete was reported at the correct stage in the state machine
       
    79 	agent->GetProgressStage(stage);
       
    80 	TESTEL(stage==KConnectionOpen,stage);
       
    81 
       
    82 	Log(_L("Connect Successful"));
       
    83 
       
    84 	DelayL(2000000);
       
    85 
       
    86 	// Attempt connection
       
    87 	Log(_L("ReConnecting..."));
       
    88 	agent->ReConnect();
       
    89 	
       
    90 	// Check for an error code
       
    91 	agent->GetCompletionCode(err);
       
    92 	TESTEL(err==KErrGeneral,err);
       
    93 
       
    94 	// Check ConnectComplete was reported at the correct stage in the state machine
       
    95 	agent->GetProgressStage(stage);
       
    96 	TESTEL(stage==EPsdFinishedActivation,stage);
       
    97 
       
    98 	Log(_L("Reconnect fails as expected"));
       
    99 	
       
   100 	DelayL(2000000);
       
   101 
       
   102 	// Disconnect
       
   103 	Log(_L("Disconnecting..."));
       
   104 	agent->Disconnect();
       
   105 
       
   106 	// Check for an error code
       
   107 	agent->GetCompletionCode(err);
       
   108 	TESTEL(err==KErrNone,err);
       
   109 
       
   110 	Log(_L("Disconnect Successful"));
       
   111 
       
   112 	// Finished with Dummy Nifman so delete it
       
   113 	CleanupStack::PopAndDestroy(agent);
       
   114 	Log(_L("DUMMYNIF.DLL Unloaded"));
       
   115 
       
   116 	return iTestStepResult;
       
   117 	}
       
   118 
       
   119 
       
   120 // Test case 14.3
       
   121 enum TVerdict CPsdAgtTest14_3::doPsdAgtTestStepL( void )
       
   122 	{
       
   123 	TInt err;
       
   124 	TInt stage;
       
   125 	CNifAgentRefN1 *agent;
       
   126 
       
   127 	TRealAgtNotify agtNotify; 
       
   128 	agtNotify.SetTestCase(1403);
       
   129 
       
   130 	// Construct a new Dummy Nifman Instance
       
   131 	Log(_L("Loading DUMMYNIF.DLL"));
       
   132 	agent = CNifAgentRefN1::NewL(this,EFalse);
       
   133 	CleanupStack::PushL(agent);
       
   134 
       
   135 	// Attempt connection
       
   136 	Log(_L("Connecting..."));
       
   137 	agent->Connect();
       
   138 	
       
   139 	// Check for an error code
       
   140 	agent->GetCompletionCode(err);
       
   141 	TESTEL(err==KErrNone,err);
       
   142 
       
   143 	// Check ConnectComplete was reported at the correct stage in the state machine
       
   144 	agent->GetProgressStage(stage);
       
   145 	TESTEL(stage==KConnectionOpen,stage);
       
   146 
       
   147 	Log(_L("Connect Successful"));
       
   148 
       
   149 	DelayL(2000000);
       
   150 
       
   151 	// Attempt connection
       
   152 	Log(_L("ReConnecting..."));
       
   153 	agent->ReConnect();
       
   154 	
       
   155 	// Check for an error code
       
   156 	agent->GetCompletionCode(err);
       
   157 	TESTEL(err==KErrNone,err);
       
   158 
       
   159 	// Check ConnectComplete was reported at the correct stage in the state machine
       
   160 	agent->GetProgressStage(stage);
       
   161 	TESTEL(stage==KConnectionOpen,stage);
       
   162 
       
   163 	Log(_L("ReConnect Successful"));
       
   164 	Log(_L("Waiting for EAgentToNifEventTypeGetDataTransfer event"));
       
   165 
       
   166 	DelayL(2000000);
       
   167 
       
   168 	iStage++;
       
   169 
       
   170 	// Wait for log request to arrive
       
   171 	CActiveScheduler::Start();
       
   172 
       
   173 	DelayL(2000000);
       
   174 
       
   175 	// Disconnect
       
   176 	agent->Disconnect();
       
   177 
       
   178 	// Check for an error code
       
   179 	agent->GetCompletionCode(err);
       
   180 	TESTEL(err==KErrNone,err);
       
   181 
       
   182 	Log(_L("Disconnected"));
       
   183 
       
   184 	// Finished with Dummy Nifman so delete it
       
   185 	CleanupStack::PopAndDestroy(agent);
       
   186 
       
   187 	// GetDataVolumeRequest should only have been called twice
       
   188 	// ie. iStage == 3
       
   189 	TESTL(iStage == 3);
       
   190 	
       
   191 	Log(_L("Check LogDataTransferred values in GENCONN.TXT"));
       
   192 
       
   193 	return iTestStepResult;
       
   194 	}
       
   195 
       
   196 void CPsdAgtTest14_3::PsdAgtGetDataVolumeRequest(TUint32 &aSent, TUint32 &aReceived)
       
   197 	{
       
   198 	// Function should only be called twice
       
   199 	TEST(iStage==1 || iStage == 2);
       
   200 
       
   201 	// First time data volume is requested
       
   202 	if(iStage == 1)
       
   203 		{
       
   204 		iStage++;
       
   205 		aSent = 20;     // Sent size
       
   206 		aReceived = 26; // Rcv size
       
   207 
       
   208 		// Unblock ConnectAndWaitForAsyncronousRequest()
       
   209 		CActiveScheduler::Stop();
       
   210 		}
       
   211 	// Second time data volume is requested during the Disconnect
       
   212 	else if(iStage == 2)
       
   213 		{
       
   214 		iStage++;
       
   215 		aSent = 35;     // Sent size
       
   216 		aReceived = 39; // Rcv size
       
   217 		}
       
   218 	}
       
   219 
       
   220 
       
   221 // Test case 14.4
       
   222 enum TVerdict CPsdAgtTest14_4::doPsdAgtTestStepL( void )
       
   223 	{
       
   224 	TInt err;
       
   225 	TInt stage;
       
   226 	CNifAgentRefN1 *agent;
       
   227 
       
   228 	TRealAgtNotify agtNotify; 
       
   229 	agtNotify.SetTestCase(1404);
       
   230 
       
   231 	// Construct a new Dummy Nifman Instance
       
   232 	Log(_L("Loading DUMMYNIF.DLL"));
       
   233 	agent = CNifAgentRefN1::NewL(this,EFalse);
       
   234 	CleanupStack::PushL(agent);
       
   235 
       
   236 	// Attempt connection
       
   237 	Log(_L("Connecting..."));
       
   238 	agent->Connect();
       
   239 	
       
   240 	// Check for an error code
       
   241 	agent->GetCompletionCode(err);
       
   242 	TESTEL(err==KErrNone,err);
       
   243 
       
   244 	// Check ConnectComplete was reported at the correct stage in the state machine
       
   245 	agent->GetProgressStage(stage);
       
   246 	TESTEL(stage==KConnectionOpen,stage);
       
   247 
       
   248 	Log(_L("Connect Successful"));
       
   249 
       
   250 	DelayL(2000000);
       
   251 
       
   252 	// Attempt connection
       
   253 	Log(_L("ReConnecting..."));
       
   254 	agent->ReConnect();
       
   255 	
       
   256 	// Check for an error code
       
   257 	agent->GetCompletionCode(err);
       
   258 	TESTEL(err==KErrNone,err);
       
   259 
       
   260 	// Check ConnectComplete was reported at the correct stage in the state machine
       
   261 	agent->GetProgressStage(stage);
       
   262 	TESTEL(stage==KConnectionOpen,stage);
       
   263 
       
   264 	Log(_L("ReConnect Successful"));
       
   265 	// Predetermined QoS warning response
       
   266 	iDlgSvr->SetQoSWarnResponse(EFalse);
       
   267 
       
   268 	DelayL(5000000);
       
   269 
       
   270 	// Tell the ETEL layer to send a QOS change to PSDAGX
       
   271 	Log(_L("Notify PSDAGT of Context Config change"));
       
   272 	agtNotify.NotifyAgt(EReduce);
       
   273 
       
   274 	// Block until we receive dialog notification of status change
       
   275 	CActiveScheduler::Start();
       
   276 
       
   277 	DelayL(2000000);
       
   278 
       
   279 	// Tell the ETEL layer to restore QOS and notify PSDAGX
       
   280 	Log(_L("Notify PSDAGT of Restore Context Config"));
       
   281 	agtNotify.NotifyAgt(ERestore);
       
   282 
       
   283 	// Check to make sure a second dialog is not presented
       
   284 	DelayL(5000000);
       
   285 
       
   286 	// Disconnect
       
   287 	Log(_L("Disconnecting..."));
       
   288 	agent->Disconnect();
       
   289 
       
   290 	// Check for an error code
       
   291 	agent->GetCompletionCode(err);
       
   292 	TESTEL(err==KErrNone,err);
       
   293 
       
   294 	Log(_L("Disconnect Successful"));
       
   295 
       
   296 	// Finished with Dummy Nifman so delete it
       
   297 	CleanupStack::PopAndDestroy(agent);
       
   298 	Log(_L("DUMMYNIF.DLL Unloaded"));
       
   299 
       
   300 	return iTestStepResult;
       
   301 	}
       
   302 
       
   303 void CPsdAgtTest14_4::DialogHasAppeared()
       
   304 	{
       
   305 	TEST(iStage==0);
       
   306 	iStage++;
       
   307 
       
   308 	// Unblock the call to doPsdAgtTestStepL();
       
   309 	CActiveScheduler::Stop();
       
   310 	}
       
   311 
       
   312 
       
   313 // Test case 14.5
       
   314 enum TVerdict CPsdAgtTest14_5::doPsdAgtTestStepL( void )
       
   315 	{
       
   316 	TInt err;
       
   317 	TInt stage;
       
   318 	CNifAgentRefN1 *agent;
       
   319 
       
   320 	TRealAgtNotify agtNotify; 
       
   321 	agtNotify.SetTestCase(1405);
       
   322 
       
   323 	// Construct a new Dummy Nifman Instance
       
   324 	Log(_L("Loading DUMMYNIF.DLL"));
       
   325 	agent = CNifAgentRefN1::NewL(this,EFalse);
       
   326 	CleanupStack::PushL(agent);
       
   327 
       
   328 	// Attempt connection
       
   329 	Log(_L("Connecting..."));
       
   330 	agent->Connect();
       
   331 	
       
   332 	// Check for an error code
       
   333 	agent->GetCompletionCode(err);
       
   334 	TESTEL(err==KErrNone,err);
       
   335 
       
   336 	// Check ConnectComplete was reported at the correct stage in the state machine
       
   337 	agent->GetProgressStage(stage);
       
   338 	TESTEL(stage==KConnectionOpen,stage);
       
   339 
       
   340 	Log(_L("Connect Successful"));
       
   341 
       
   342 	DelayL(2000000);
       
   343 
       
   344 	// Attempt connection
       
   345 	Log(_L("Reconnecting..."));
       
   346 	agent->ReConnect();
       
   347 	
       
   348 	// Check for an error code
       
   349 	agent->GetCompletionCode(err);
       
   350 	TESTEL(err==KErrNone,err);
       
   351 
       
   352 	// Check ConnectComplete was reported at the correct stage in the state machine
       
   353 	agent->GetProgressStage(stage);
       
   354 	TESTEL(stage==KConnectionOpen,stage);
       
   355 
       
   356 	Log(_L("Reconnect Successful"));
       
   357 	
       
   358 	// Predetermined QoS warning response
       
   359 	iDlgSvr->SetQoSWarnResponse(EFalse);
       
   360 
       
   361 	DelayL(5000000);
       
   362 
       
   363 	// Tell the ETEL layer to send a QOS change to PSDAGX
       
   364 	Log(_L("Notify PSDAGT of QoS change"));
       
   365 	agtNotify.NotifyAgt(EReduce);
       
   366 
       
   367 	// Block until we receive dialog notification of status change
       
   368 	CActiveScheduler::Start();
       
   369 
       
   370 	DelayL(2000000);
       
   371 
       
   372 	// Tell the ETEL layer to restore QOS and notify PSDAGX
       
   373 	Log(_L("Notify PSDAGT of restore QoS value"));
       
   374 	agtNotify.NotifyAgt(ERestore);
       
   375 
       
   376 	// Check to make sure a second dialog is not presented
       
   377 	DelayL(5000000);
       
   378 
       
   379 	// Disconnect
       
   380 	Log(_L("Disconnecting..."));
       
   381 	agent->Disconnect();
       
   382 
       
   383 	// Check for an error code
       
   384 	agent->GetCompletionCode(err);
       
   385 	TESTEL(err==KErrNone,err);
       
   386 
       
   387 	Log(_L("Disconnect Successful"));
       
   388 
       
   389 	// Finished with Dummy Nifman so delete it
       
   390 	CleanupStack::PopAndDestroy(agent);
       
   391 	Log(_L("DUMMYNIF.DLL Unloaded"));
       
   392 
       
   393 	return iTestStepResult;
       
   394 	}
       
   395 
       
   396 void CPsdAgtTest14_5::DialogHasAppeared()
       
   397 	{
       
   398 	// Only one dialog should be presented
       
   399 	TEST(iStage==0);
       
   400 	iStage++;
       
   401 
       
   402 	// Unblock the call to doPsdAgtTestStepL();
       
   403 	CActiveScheduler::Stop();
       
   404 	}