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