appfw/apparchitecture/tef/T_WindowChainingStep.CPP
changeset 0 2e3d3ce01487
child 29 6a787171e1de
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 2005-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
       
    18  @internalComponent - Internal Symbian test code 
       
    19 */
       
    20 
       
    21 
       
    22 #include <apgcli.h>
       
    23 #include "T_WindowChainingStep.h"
       
    24 #include "TWindowChaining.h"
       
    25 #include <apacmdln.h>
       
    26 
       
    27 /**
       
    28    @SYMTestCaseID TODO
       
    29   
       
    30    @SYMPREQ DEFECT 053778 - Window Chaining
       
    31   
       
    32    @SYMTestCaseDesc
       
    33    Stuff
       
    34   
       
    35    @SYMTestPriority High
       
    36   
       
    37    @SYMTestStatus Implemented
       
    38   
       
    39    @SYMTestActions
       
    40    1. Create a child ui application (t_winchainlaunch.exe)
       
    41    2. From t_winchainlaunch.exe, connect a child application (t_winchainchild.exe) with
       
    42       a specific ordinal
       
    43    3. Send message to child application from launching application
       
    44    4. When message is received by child application, check they share the same ordinal
       
    45    5. Child application reports back to launch application the result of the test
       
    46    6. Launch application quits with the test result as an exit code
       
    47   
       
    48    @SYMTestExpectedResults
       
    49    Window group ordinals should be the same.  
       
    50    t_winchainlaunch.exe should exit with KTWindowChainingTestPassed.
       
    51   
       
    52  */
       
    53 void CT_WindowChainingStep::TestWindowChainingL()
       
    54 	{
       
    55 
       
    56 	TThreadId appThreadId(0U);
       
    57 
       
    58 	RApaLsSession ls;
       
    59 	CleanupClosePushL(ls);
       
    60 	TInt ret = ls.Connect();
       
    61 	TEST(ret == KErrNone);
       
    62 	
       
    63 	CApaCommandLine* cmdLine=CApaCommandLine::NewLC();
       
    64     
       
    65 	cmdLine->SetExecutableNameL(KWinChainChildAppFileName);
       
    66 	cmdLine->SetCommandL(EApaCommandOpen);
       
    67 
       
    68 	// start document, causing GuiBaseChildApp.exe to be launched
       
    69 	INFO_PRINTF1(_L("Launching Child Application"));
       
    70 
       
    71 	// start child application
       
    72 	ret = ls.StartApp(*cmdLine, appThreadId);
       
    73 	TEST(ret == KErrNone);
       
    74 	User::LeaveIfError(ret);
       
    75 	CleanupStack::PopAndDestroy(2);  // ls and cmdLine
       
    76 	
       
    77 	RThread appThread;
       
    78 	User::LeaveIfError(appThread.Open(appThreadId));
       
    79 	
       
    80 	TRequestStatus logonRequestStatus;
       
    81 	appThread.Logon(logonRequestStatus);
       
    82 
       
    83 	// wait for t_windowchainLaunch.exe to terminate
       
    84 	INFO_PRINTF1(_L("Waiting for application to terminate..."));
       
    85 	User::WaitForRequest(logonRequestStatus);
       
    86 
       
    87 	const TExitType exitType = appThread.ExitType();
       
    88 	const TInt exitReason = appThread.ExitReason();
       
    89 	TExitCategoryName categoryName = appThread.ExitCategory();
       
    90 	appThread.Close();
       
    91 
       
    92 	TBuf<50> msg;
       
    93 	if (exitType == EExitPanic)
       
    94 		{
       
    95 		_LIT(KAppPanicInfo, "Application panic: %S %d");
       
    96 		msg.Format(KAppPanicInfo, &categoryName, exitReason);
       
    97 		}
       
    98 	else
       
    99 		{
       
   100 		_LIT(KAppExitInfo, "Application exited with code %d");
       
   101 		msg.Format(KAppExitInfo, exitReason);
       
   102 		}
       
   103 	INFO_PRINTF1(msg);
       
   104 
       
   105 	TEST(logonRequestStatus == KTWindowChainingTestPassed);
       
   106 	TEST(exitType == EExitKill);
       
   107 	TEST(exitReason == KTWindowChainingTestPassed);
       
   108 	
       
   109 	if (exitReason == KTWindowChainingTestPassed)
       
   110 		SetTestStepResult(EPass);
       
   111 	else
       
   112 		SetTestStepResult(EFail);
       
   113 	}
       
   114 	
       
   115 TVerdict CT_WindowChainingStep::doTestStepL()
       
   116 {
       
   117 	__UHEAP_MARK;
       
   118 		
       
   119 	INFO_PRINTF1(_L("Test Started"));
       
   120 
       
   121 	// run the test
       
   122 	TRAPD(err, TestWindowChainingL());
       
   123 	INFO_PRINTF2(_L("  test completes with %d"), err);
       
   124 	TEST(err == KErrNone);
       
   125 
       
   126 	INFO_PRINTF1(_L("Test Finished"));
       
   127 		
       
   128 	__UHEAP_MARKEND;
       
   129 	return TestStepResult();
       
   130 }
       
   131 
       
   132