datacommsserver/networkingdialogapi/TE_Dialog/src/TestPCTDialog.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     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 //
       
    15 
       
    16 /**
       
    17  @file TestPCTDialog.cpp
       
    18 */
       
    19 
       
    20 //Symbian OS Headers
       
    21 #include <c32comm.h>
       
    22 #include <agentdialog.h>
       
    23 
       
    24 //Test Framework Header
       
    25 #include <test/testexecutelog.h>
       
    26 
       
    27 //Test Step Header
       
    28 #include "TestPCTDialog.h"
       
    29 
       
    30 
       
    31 CTestPCTDialog::~CTestPCTDialog()
       
    32 /**
       
    33  * Destructor
       
    34  */
       
    35 	{
       
    36 	}
       
    37 
       
    38 CTestPCTDialog::CTestPCTDialog()
       
    39 /**
       
    40  * Constructor
       
    41  */
       
    42 	{
       
    43 	SetTestStepName(KTestPCTDialog);
       
    44 	}
       
    45 
       
    46 
       
    47 TVerdict CTestPCTDialog::doTestStepL()
       
    48 	{
       
    49 
       
    50  	// When bootstrapping C32 we have to avoid the PhBkSyncServer being started, since
       
    51  	// it needs a different CommDB
       
    52  	_LIT(KPhbkSyncCMI, "phbsync.cmi");
       
    53     TInt ret = StartC32WithCMISuppressions(KPhbkSyncCMI);
       
    54 	if ((ret != KErrNone) && (ret != KErrAlreadyExists))
       
    55 		INFO_PRINTF2(_L("error is : %d \n"), ret);
       
    56 	else	
       
    57 		INFO_PRINTF1(_L("Started C32\n"));
       
    58 
       
    59 	RGenConAgentDialogServer dlgSv;
       
    60 	TRAP_IGNORE(dlgSv.Connect());
       
    61 	INFO_PRINTF1(_L("Connected Dialog Server\n"));
       
    62 
       
    63 	TRequestStatus status;
       
    64 
       
    65 	INFO_PRINTF1(_L("Testing the PCT\n")); 
       
    66 	dlgSv.OpenPct();
       
    67 	TRequestStatus destroyStatus;
       
    68 	dlgSv.DestroyPctNotification(destroyStatus);
       
    69 	INFO_PRINTF1(_L("Requested destroy notification\n"));	
       
    70 	TBuf<256> writeBuffer=_L("Welcome to Ann's ISP");
       
    71 	dlgSv.WritePct(writeBuffer);
       
    72 	writeBuffer=_L("Login:");
       
    73 	dlgSv.WritePct(writeBuffer);
       
    74 	TBuf<256> readBuffer=_L("UserName");
       
    75 	dlgSv.ReadPct(readBuffer,status);
       
    76 	User::WaitForRequest(status);
       
    77 	ret=status.Int();
       
    78 	INFO_PRINTF2(_L("Read from PCT completed with code = %d\n"),ret);
       
    79 	checkPctError(dlgSv,ret);
       
    80 	INFO_PRINTF2(_L("Read from PCT = %S\n"),&readBuffer);
       
    81 	writeBuffer=_L("Password:");
       
    82 	dlgSv.WritePct(writeBuffer);
       
    83 	readBuffer=_L("PassWord");
       
    84 	dlgSv.ReadPct(readBuffer,status);
       
    85 	User::WaitForRequest(status);
       
    86 	ret=status.Int();
       
    87 	INFO_PRINTF2(_L("Read from PCT completed with code = %d\n"),ret);
       
    88 	checkPctError(dlgSv,ret);
       
    89 	INFO_PRINTF2(_L("Read from PCT = %S\n"),&readBuffer);
       
    90 	writeBuffer=_L("Login correct!");
       
    91 	dlgSv.WritePct(writeBuffer);
       
    92 	User::After(2*1000000);	
       
    93 	dlgSv.CancelDestroyPctNotification();
       
    94 	User::WaitForRequest(destroyStatus);
       
    95 	
       
    96 	if ((destroyStatus.Int()==KErrCancel))
       
    97 		INFO_PRINTF2(_L("error is : %d \n"), destroyStatus.Int());
       
    98 
       
    99 	dlgSv.ClosePct();
       
   100 	dlgSv.Close();
       
   101 
       
   102 	return TestStepResult();
       
   103 	}
       
   104 
       
   105 
       
   106 void CTestPCTDialog::checkError(RGenConAgentDialogServer& aDlgSvr, TInt aError)
       
   107 	{
       
   108 	if (aError!=KErrNone && aError!=KErrCancel)
       
   109 		aDlgSvr.Close();
       
   110 
       
   111 	if ((aError!=KErrNone) && (aError!=KErrCancel))
       
   112 		INFO_PRINTF2(_L("Error is : %d \n"), aError);
       
   113 	}
       
   114 
       
   115 void CTestPCTDialog::checkPctError(RGenConAgentDialogServer& aDlgSvr, TInt aError)
       
   116 	{
       
   117 	if (aError!=KErrNone)
       
   118 		{
       
   119 		aDlgSvr.ClosePct();
       
   120 		TRequestStatus destroyStatus;
       
   121 		User::WaitForRequest(destroyStatus);
       
   122 		aDlgSvr.Close();
       
   123 		}
       
   124 
       
   125 	TEST(aError==KErrNone);
       
   126 	}	
       
   127 
       
   128 
       
   129