datacommsserver/esockserver/test/TE_RConnectionSuite/src/TE_RConnectionCMM.cpp
changeset 25 e53adc4c49de
parent 1 21d2ab05f085
equal deleted inserted replaced
22:592244873960 25:e53adc4c49de
    23 #include <ss_std.h>
    23 #include <ss_std.h>
    24 #include <comms-infras/nifprvar.h>
    24 #include <comms-infras/nifprvar.h>
    25 #include <nifman.h>
    25 #include <nifman.h>
    26 #include <inet6err.h>
    26 #include <inet6err.h>
    27 #include <in6_opt.h>
    27 #include <in6_opt.h>
       
    28 
    28 
    29 
    29 /**
    30 /**
    30  * Subconnection Management API extensions
    31  * Subconnection Management API extensions
    31  * 
    32  * 
    32  * - 400 EnumerateSubConnections(TUint& aCount);
    33  * - 400 EnumerateSubConnections(TUint& aCount);
  7267 	CleanupStack::PopAndDestroy();
  7268 	CleanupStack::PopAndDestroy();
  7268     return TestStepResult();
  7269     return TestStepResult();
  7269 } // TE_RConnectionTest319
  7270 } // TE_RConnectionTest319
  7270 
  7271 
  7271 
  7272 
       
  7273 
       
  7274 enum TVerdict TE_RConnectionTest481::doTestStepL(void)
       
  7275 /**
       
  7276  * Test 481
       
  7277  * Test DataSentNotificationRequest() cancellation
       
  7278  * Added for defect ou1cimx1#305124.
       
  7279  * Tests that cancellation of the request does indeed cancel the request
       
  7280  * Defect summary: was the case that the first cancel cancelled the request but left
       
  7281  * a notification structure in existence. The second cancel would see the structure
       
  7282  * and think that the cancellation had already been done leaving the request outstanding.
       
  7283  * @return enum TVerdict Indicates status of test run. See INFO_PRINTF1.h for possible values
       
  7284  */
       
  7285 {
       
  7286     TInt err;
       
  7287     TRequestStatus status1;
       
  7288 
       
  7289     RSocketServ ss;
       
  7290     err = OpenSocketServer(ss);
       
  7291     TESTEL(KErrNone == err, err);
       
  7292     CleanupClosePushL(ss);
       
  7293 
       
  7294     //********** connection creation ***********
       
  7295     RConnection conn1;
       
  7296     err = OpenConnection(conn1, ss);
       
  7297     TESTEL(KErrNone == err, err);
       
  7298     CleanupClosePushL(conn1);
       
  7299 
       
  7300     // start the dummynif
       
  7301     err = StartConnectionWithOverrides(conn1, iDummyNifLongTimeoutIap);
       
  7302     TESTEL(KErrNone == err, err);
       
  7303     err = conn1.SetOpt(KCOLProvider, KConnDisableTimers, ETrue);
       
  7304     TESTEL(KErrNone == err, err);
       
  7305 
       
  7306     RSocket sock1;
       
  7307     err = OpenUdpSocketExplicitL(sock1, ss, conn1);
       
  7308     TESTEL(KErrNone == err, err);
       
  7309     CleanupClosePushL(sock1);
       
  7310 
       
  7311     INFO_PRINTF1(_L("First DataSentNotificationRequest"));
       
  7312     // Request DataSentNotificationRequest
       
  7313     TUint volume1(0); 
       
  7314     TPckg<TUint> volume1Des(volume1);
       
  7315     TUint threshold1(KLowThresholdSize);
       
  7316     conn1.DataSentNotificationRequest(threshold1, volume1Des, status1);
       
  7317 
       
  7318     // Send some data but not enough to trigger the notification 
       
  7319     TUint currentVol(0);
       
  7320     while (currentVol < threshold1 / 2)
       
  7321         {
       
  7322         err = TestUdpDataPathL(sock1, iDummyNifSendAddr, KSmallBufferLength);
       
  7323         TESTEL(KErrNone == err, err);
       
  7324         TESTEL(KRequestPending == status1.Int(), status1.Int());
       
  7325         currentVol += KSmallBufferUdpTestPacketSize;
       
  7326         }
       
  7327 
       
  7328     INFO_PRINTF1(_L("First DataSentNotificationRequest still outstanding (as expected) - now cancelling"));
       
  7329 
       
  7330     // Cancel the request and expect the completion
       
  7331     conn1.DataSentNotificationCancel();
       
  7332     User::WaitForRequest(status1);
       
  7333     TESTEL(status1.Int() == KErrCancel, status1.Int());
       
  7334 
       
  7335     INFO_PRINTF1(_L("First DataSentNotificationRequest completed with KErrCancel"));
       
  7336     
       
  7337     // The first cancellation has worked, repeat the above steps for the second cancellation
       
  7338     INFO_PRINTF1(_L("Second DataSentNotificationRequest"));
       
  7339     conn1.DataSentNotificationRequest(threshold1, volume1Des, status1);
       
  7340 
       
  7341     // NOTE: It is a deliberate that no data is transfered this time.
       
  7342 	//       Transmitting data and crossing the threshold for the first (cancelled) notification
       
  7343 	//       would cause the object to be cleaned up and therefore mask this issue
       
  7344     
       
  7345     // Cancel the request and expect the completion
       
  7346     conn1.DataSentNotificationCancel();
       
  7347     User::WaitForRequest(status1);
       
  7348     TESTEL(status1.Int() == KErrCancel, status1.Int());
       
  7349     INFO_PRINTF1(_L("Second DataSentNotificationRequest completed with KErrCancel"));
       
  7350     
       
  7351     // NOTE: Reaching here successfully does NOT mean the test has passed. If the data monitoring structures
       
  7352     //       have been left behind esock will panic when the connection is stopped  
       
  7353     
       
  7354     
       
  7355     //********** turn the idle timers back on now we are finished ***********
       
  7356     err = conn1.SetOpt(KCOLProvider, KConnDisableTimers, EFalse);
       
  7357     TESTEL(KErrNone == err, err);
       
  7358 
       
  7359     //********** clean up ***********
       
  7360     DestroyUdpSocket(sock1);
       
  7361     CleanupStack::Pop(&sock1);
       
  7362 
       
  7363     err = conn1.Stop();
       
  7364     TESTEL(KErrNone == err, err);
       
  7365 
       
  7366     CloseConnection(conn1);
       
  7367     CleanupStack::Pop(&conn1);
       
  7368 
       
  7369     CloseSocketServer(ss);
       
  7370     CleanupStack::Pop(&ss);
       
  7371 
       
  7372     return TestStepResult();
       
  7373 
       
  7374 } // TE_RConnectionTest481
       
  7375 
       
  7376 
       
  7377 
       
  7378 enum TVerdict TE_RConnectionTest482::doTestStepL(void)
       
  7379 /**
       
  7380  * Test 482
       
  7381  * Test DataReceivedNotificationRequest() cancellation
       
  7382  * Added for defect ou1cimx1#305124.
       
  7383  * Tests that cancellation of the request does indeed cancel the request
       
  7384  * Defect summary: was the case that the first cancel cancelled the request but left
       
  7385  * a notification structure in existence. The second cancel would see the structure
       
  7386  * and think that the cancellation had already been done leaving the request outstanding.
       
  7387  * @return enum TVerdict Indicates status of test run. See INFO_PRINTF1.h for possible values
       
  7388  */
       
  7389 {
       
  7390     TInt err;
       
  7391     TRequestStatus status1;
       
  7392 
       
  7393     RSocketServ ss;
       
  7394     err = OpenSocketServer(ss);
       
  7395     TESTEL(KErrNone == err, err);
       
  7396     CleanupClosePushL(ss);
       
  7397 
       
  7398     //********** connection creation ***********
       
  7399     RConnection conn1;
       
  7400     err = OpenConnection(conn1, ss);
       
  7401     TESTEL(KErrNone == err, err);
       
  7402     CleanupClosePushL(conn1);
       
  7403 
       
  7404     // start the dummynif
       
  7405     err = StartConnectionWithOverrides(conn1, iDummyNifLongTimeoutIap);
       
  7406     TESTEL(KErrNone == err, err);
       
  7407     err = conn1.SetOpt(KCOLProvider, KConnDisableTimers, ETrue);
       
  7408     TESTEL(KErrNone == err, err);
       
  7409 
       
  7410     RSocket sock1;
       
  7411     err = OpenUdpSocketExplicitL(sock1, ss, conn1);
       
  7412     TESTEL(KErrNone == err, err);
       
  7413     CleanupClosePushL(sock1);
       
  7414 
       
  7415     INFO_PRINTF1(_L("First DataReceivedNotificationRequest"));
       
  7416     // Request DataSentNotificationRequest
       
  7417     TUint volume1(0); 
       
  7418     TPckg<TUint> volume1Des(volume1);
       
  7419     TUint threshold1(KLowThresholdSize);
       
  7420     conn1.DataReceivedNotificationRequest(threshold1, volume1Des, status1);
       
  7421 
       
  7422     // Send some data but not enough to trigger the notification 
       
  7423     TUint currentVol(0);
       
  7424     while (currentVol < threshold1 / 2)
       
  7425         {
       
  7426         err = TestUdpDataPathL(sock1, iDummyNifSendAddr, KSmallBufferLength);
       
  7427         TESTEL(KErrNone == err, err);
       
  7428         TESTEL(KRequestPending == status1.Int(), status1.Int());
       
  7429         currentVol += KSmallBufferUdpTestPacketSize;
       
  7430         }
       
  7431 
       
  7432     INFO_PRINTF1(_L("First DataReceivedNotificationRequest still outstanding (as expected) - now cancelling"));
       
  7433 
       
  7434     // Cancel the request and expect the completion
       
  7435     conn1.DataReceivedNotificationCancel();
       
  7436     User::WaitForRequest(status1);
       
  7437     TESTEL(status1.Int() == KErrCancel, status1.Int());
       
  7438 
       
  7439     INFO_PRINTF1(_L("First DataReceivedNotificationRequest completed with KErrCancel"));
       
  7440     
       
  7441     // The first cancellation has worked, repeat the above steps for the second cancellation
       
  7442     INFO_PRINTF1(_L("Second DataReceivedNotificationRequest"));
       
  7443     conn1.DataReceivedNotificationRequest(threshold1, volume1Des, status1);
       
  7444 
       
  7445     // NOTE: It is a deliberate that no data is transfered this time.
       
  7446 	//       Transmitting data and crossing the threshold for the first (cancelled) notification
       
  7447 	//       would cause the object to be cleaned up and therefore mask this issue
       
  7448     
       
  7449     // Cancel the request and expect the completion
       
  7450     conn1.DataReceivedNotificationCancel();
       
  7451     User::WaitForRequest(status1);
       
  7452     TESTEL(status1.Int() == KErrCancel, status1.Int());
       
  7453     INFO_PRINTF1(_L("Second DataReceivedNotificationRequest completed with KErrCancel"));
       
  7454 
       
  7455     // NOTE: Reaching here successfully does NOT mean the test has passed. If the data monitoring structures
       
  7456     //       have been left behind esock will panic when the connection is stopped  
       
  7457 
       
  7458     
       
  7459     //********** turn the idle timers back on now we are finished ***********
       
  7460     err = conn1.SetOpt(KCOLProvider, KConnDisableTimers, EFalse);
       
  7461     TESTEL(KErrNone == err, err);
       
  7462 
       
  7463     //********** clean up ***********
       
  7464     DestroyUdpSocket(sock1);
       
  7465     CleanupStack::Pop(&sock1);
       
  7466 
       
  7467     err = conn1.Stop();
       
  7468     TESTEL(KErrNone == err, err);
       
  7469 
       
  7470     CloseConnection(conn1);
       
  7471     CleanupStack::Pop(&conn1);
       
  7472 
       
  7473     CloseSocketServer(ss);
       
  7474     CleanupStack::Pop(&ss);
       
  7475 
       
  7476     return TestStepResult();
       
  7477 
       
  7478 } // TE_RConnectionTest482
       
  7479 
       
  7480 
       
  7481 
       
  7482 enum TVerdict TE_RConnectionTest483::doTestStepL(void)
       
  7483 /**
       
  7484  * Test 483
       
  7485  * Test DataSentNotificationRequest() cancellation
       
  7486  * Added for defect ou1cimx1#305124.
       
  7487  * Tests that cancellation of the request does indeed cancel the request
       
  7488  * Defect summary: If the state described in Test481 occurs, it would have been possible to
       
  7489  * request more than one DataSentNotificationRequest per RConnection. This should not be possible.
       
  7490  * @return enum TVerdict Indicates status of test run. See INFO_PRINTF1.h for possible values
       
  7491  */
       
  7492 {
       
  7493     TInt err;
       
  7494     TRequestStatus status1;
       
  7495 
       
  7496     RSocketServ ss;
       
  7497     err = OpenSocketServer(ss);
       
  7498     TESTEL(KErrNone == err, err);
       
  7499     CleanupClosePushL(ss);
       
  7500 
       
  7501     //********** connection creation ***********
       
  7502     RConnection conn1;
       
  7503     err = OpenConnection(conn1, ss);
       
  7504     TESTEL(KErrNone == err, err);
       
  7505     CleanupClosePushL(conn1);
       
  7506 
       
  7507     // start the dummynif
       
  7508     err = StartConnectionWithOverrides(conn1, iDummyNifLongTimeoutIap);
       
  7509     TESTEL(KErrNone == err, err);
       
  7510     err = conn1.SetOpt(KCOLProvider, KConnDisableTimers, ETrue);
       
  7511     TESTEL(KErrNone == err, err);
       
  7512 
       
  7513     RSocket sock1;
       
  7514     err = OpenUdpSocketExplicitL(sock1, ss, conn1);
       
  7515     TESTEL(KErrNone == err, err);
       
  7516     CleanupClosePushL(sock1);
       
  7517 
       
  7518     INFO_PRINTF1(_L("First DataSentNotificationRequest"));
       
  7519     // Request DataSentNotificationRequest
       
  7520     TUint volume1(0); 
       
  7521     TPckg<TUint> volume1Des(volume1);
       
  7522     TUint threshold1(KLowThresholdSize);
       
  7523     conn1.DataSentNotificationRequest(threshold1, volume1Des, status1);
       
  7524 
       
  7525     // Send some data but not enough to trigger the notification 
       
  7526     TUint currentVol(0);
       
  7527     while (currentVol < threshold1 / 2)
       
  7528         {
       
  7529         err = TestUdpDataPathL(sock1, iDummyNifSendAddr, KSmallBufferLength);
       
  7530         TESTEL(KErrNone == err, err);
       
  7531         TESTEL(KRequestPending == status1.Int(), status1.Int());
       
  7532         currentVol += KSmallBufferUdpTestPacketSize;
       
  7533         }
       
  7534 
       
  7535     INFO_PRINTF1(_L("First DataSentNotificationRequest still outstanding (as expected) - now cancelling"));
       
  7536 
       
  7537     // Cancel the request and expect the completion
       
  7538     conn1.DataSentNotificationCancel();
       
  7539     User::WaitForRequest(status1);
       
  7540     TESTEL(status1.Int() == KErrCancel, status1.Int());
       
  7541 
       
  7542     INFO_PRINTF1(_L("First DataSentNotificationRequest completed with KErrCancel"));
       
  7543     
       
  7544     // The first cancellation has worked, repeat the above steps for the second cancellation
       
  7545     INFO_PRINTF1(_L("Second DataSentNotificationRequest"));
       
  7546     conn1.DataSentNotificationRequest(threshold1, volume1Des, status1);
       
  7547 
       
  7548     // NOTE: It is a deliberate that no data is transfered this time.
       
  7549 	//       Transmitting data and crossing the threshold for the first (cancelled) notification
       
  7550 	//       would cause the object to be cleaned up and therefore mask this issue
       
  7551     
       
  7552     // Cancel the request and expect the completion
       
  7553     conn1.DataSentNotificationCancel();
       
  7554     User::WaitForRequest(status1);
       
  7555     TESTEL(status1.Int() == KErrCancel, status1.Int());
       
  7556     INFO_PRINTF1(_L("Second DataSentNotificationRequest completed with KErrCancel"));
       
  7557     
       
  7558     
       
  7559     INFO_PRINTF1(_L("Third DataSentNotificationRequest"));
       
  7560     conn1.DataSentNotificationRequest(threshold1, volume1Des, status1);
       
  7561     
       
  7562 
       
  7563     INFO_PRINTF1(_L("Fourth DataSentNotificationRequest"));
       
  7564     TRequestStatus status2;
       
  7565     conn1.DataSentNotificationRequest(threshold1, volume1Des, status2);
       
  7566     TBool requestCompleted = WaitForRequestOrTimeOutL(status2, KOneSecondDelay);
       
  7567     TESTL(requestCompleted);
       
  7568     TESTEL(status2.Int() == KErrInUse, status2.Int());
       
  7569     INFO_PRINTF1(_L("Fourth DataSentNotificationRequest failed with KErrInUse as expected"));
       
  7570     
       
  7571     conn1.DataSentNotificationCancel();
       
  7572     User::WaitForRequest(status1);
       
  7573     TESTEL(status1.Int() == KErrCancel, status1.Int());
       
  7574     INFO_PRINTF1(_L("Third DataSentNotificationRequest completed with KErrCancel"));
       
  7575     
       
  7576     //********** turn the idle timers back on now we are finished ***********
       
  7577     err = conn1.SetOpt(KCOLProvider, KConnDisableTimers, EFalse);
       
  7578     TESTEL(KErrNone == err, err);
       
  7579 
       
  7580     //********** clean up ***********
       
  7581     DestroyUdpSocket(sock1);
       
  7582     CleanupStack::Pop(&sock1);
       
  7583 
       
  7584     err = conn1.Stop();
       
  7585     TESTEL(KErrNone == err, err);
       
  7586 
       
  7587     CloseConnection(conn1);
       
  7588     CleanupStack::Pop(&conn1);
       
  7589 
       
  7590     CloseSocketServer(ss);
       
  7591     CleanupStack::Pop(&ss);
       
  7592 
       
  7593     return TestStepResult();
       
  7594 
       
  7595 } // TE_RConnectionTest483
       
  7596 
       
  7597 
       
  7598 enum TVerdict TE_RConnectionTest484::doTestStepL(void)
       
  7599 /**
       
  7600  * Test 484
       
  7601  * Test DataReceivedNotificationRequest() cancellation
       
  7602  * Added for defect ou1cimx1#305124.
       
  7603  * Tests that cancellation of the request does indeed cancel the request
       
  7604  * Defect summary: If the state described in Test482 occurs, it would have been possible to
       
  7605  * request more than one DataReceivedNotificationRequest per RConnection. This should not be possible.
       
  7606  * @return enum TVerdict Indicates status of test run. See INFO_PRINTF1.h for possible values
       
  7607  */
       
  7608 {
       
  7609     TInt err;
       
  7610     TRequestStatus status1;
       
  7611 
       
  7612     RSocketServ ss;
       
  7613     err = OpenSocketServer(ss);
       
  7614     TESTEL(KErrNone == err, err);
       
  7615     CleanupClosePushL(ss);
       
  7616 
       
  7617     //********** connection creation ***********
       
  7618     RConnection conn1;
       
  7619     err = OpenConnection(conn1, ss);
       
  7620     TESTEL(KErrNone == err, err);
       
  7621     CleanupClosePushL(conn1);
       
  7622 
       
  7623     // start the dummynif
       
  7624     err = StartConnectionWithOverrides(conn1, iDummyNifLongTimeoutIap);
       
  7625     TESTEL(KErrNone == err, err);
       
  7626     err = conn1.SetOpt(KCOLProvider, KConnDisableTimers, ETrue);
       
  7627     TESTEL(KErrNone == err, err);
       
  7628 
       
  7629     RSocket sock1;
       
  7630     err = OpenUdpSocketExplicitL(sock1, ss, conn1);
       
  7631     TESTEL(KErrNone == err, err);
       
  7632     CleanupClosePushL(sock1);
       
  7633 
       
  7634     INFO_PRINTF1(_L("First DataReceivedNotificationRequest"));
       
  7635     // Request DataReceivedNotificationRequest
       
  7636     TUint volume1(0); 
       
  7637     TPckg<TUint> volume1Des(volume1);
       
  7638     TUint threshold1(KLowThresholdSize);
       
  7639     conn1.DataReceivedNotificationRequest(threshold1, volume1Des, status1);
       
  7640 
       
  7641     // Send some data but not enough to trigger the notification 
       
  7642     TUint currentVol(0);
       
  7643     while (currentVol < threshold1 / 2)
       
  7644         {
       
  7645         err = TestUdpDataPathL(sock1, iDummyNifSendAddr, KSmallBufferLength);
       
  7646         TESTEL(KErrNone == err, err);
       
  7647         TESTEL(KRequestPending == status1.Int(), status1.Int());
       
  7648         currentVol += KSmallBufferUdpTestPacketSize;
       
  7649         }
       
  7650 
       
  7651     INFO_PRINTF1(_L("First DataReceivedNotificationRequest still outstanding (as expected) - now cancelling"));
       
  7652 
       
  7653     // Cancel the request and expect the completion
       
  7654     conn1.DataReceivedNotificationCancel();
       
  7655     User::WaitForRequest(status1);
       
  7656     TESTEL(status1.Int() == KErrCancel, status1.Int());
       
  7657 
       
  7658     INFO_PRINTF1(_L("First DataReceivedNotificationRequest completed with KErrCancel"));
       
  7659     
       
  7660     // The first cancellation has worked, repeat the above steps for the second cancellation
       
  7661     INFO_PRINTF1(_L("Second DataReceivedNotificationRequest"));
       
  7662     conn1.DataReceivedNotificationRequest(threshold1, volume1Des, status1);
       
  7663 
       
  7664     // NOTE: It is a deliberate that no data is transfered this time.
       
  7665 	//       Transmitting data and crossing the threshold for the first (cancelled) notification
       
  7666 	//       would cause the object to be cleaned up and therefore mask this issue
       
  7667     
       
  7668     // Cancel the request and expect the completion
       
  7669     conn1.DataReceivedNotificationCancel();
       
  7670     User::WaitForRequest(status1);
       
  7671     TESTEL(status1.Int() == KErrCancel, status1.Int());
       
  7672     INFO_PRINTF1(_L("Second DataReceivedNotificationRequest completed with KErrCancel"));
       
  7673     
       
  7674     
       
  7675     INFO_PRINTF1(_L("Third DataReceivedNotificationRequest"));
       
  7676     conn1.DataReceivedNotificationRequest(threshold1, volume1Des, status1);
       
  7677 
       
  7678     INFO_PRINTF1(_L("Fourth DataReceivedNotificationRequest"));
       
  7679     TRequestStatus status2;
       
  7680     conn1.DataReceivedNotificationRequest(threshold1, volume1Des, status2);
       
  7681     TBool requestCompleted = WaitForRequestOrTimeOutL(status2, KOneSecondDelay);
       
  7682     TESTL(requestCompleted);
       
  7683     TESTEL(status2.Int() == KErrInUse, status2.Int());
       
  7684     INFO_PRINTF1(_L("Fourth DataReceivedNotificationRequest failed with KErrInUse as expected"));
       
  7685     
       
  7686     conn1.DataReceivedNotificationCancel();
       
  7687     User::WaitForRequest(status1);
       
  7688     TESTEL(status1.Int() == KErrCancel, status1.Int());
       
  7689     INFO_PRINTF1(_L("Third DataReceivedNotificationRequest completed with KErrCancel"));
       
  7690     
       
  7691     //********** turn the idle timers back on now we are finished ***********
       
  7692     err = conn1.SetOpt(KCOLProvider, KConnDisableTimers, EFalse);
       
  7693     TESTEL(KErrNone == err, err);
       
  7694 
       
  7695     //********** clean up ***********
       
  7696     DestroyUdpSocket(sock1);
       
  7697     CleanupStack::Pop(&sock1);
       
  7698 
       
  7699     err = conn1.Stop();
       
  7700     TESTEL(KErrNone == err, err);
       
  7701 
       
  7702     CloseConnection(conn1);
       
  7703     CleanupStack::Pop(&conn1);
       
  7704 
       
  7705     CloseSocketServer(ss);
       
  7706     CleanupStack::Pop(&ss);
       
  7707 
       
  7708     return TestStepResult();
       
  7709 
       
  7710 } // TE_RConnectionTest484
       
  7711 
       
  7712 
  7272 // EOF TE_RConnectionCMM.cpp
  7713 // EOF TE_RConnectionCMM.cpp
  7273 
  7714