appfw/apparchitecture/tef/T_StartDocStep.CPP
changeset 0 2e3d3ce01487
child 19 924385140d98
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 "testableapalssession.h"
       
    23 #include "T_StartDocStep.h"
       
    24 #include "TStartDoc.h"
       
    25 
       
    26 /**
       
    27    @SYMTestCaseID T-StartDocStep-TestStartDocL
       
    28   
       
    29    @SYMPREQ PHAR-5NTCWY
       
    30   
       
    31    @SYMTestCaseDesc
       
    32    Checks that document names longer than 256 characters can be started.
       
    33    The test starts a document and checks that the application launched
       
    34    to handle that document is passed the full document name.
       
    35    The test uses the StartDocument overload which does not provide an
       
    36    application UID or mime type, because we want the test to check that
       
    37    the long document name is supported by the data recognizer framework.
       
    38    The test also checks that the data recognizer framework doesn't return
       
    39    an error because it incorrectly assumes the document name is a file name
       
    40    and tries to open the document to read its contents before performing
       
    41    data recognition.
       
    42    In this case, the document name isn't a file name, it's a pretend URL
       
    43   
       
    44    @SYMTestPriority High
       
    45   
       
    46    @SYMTestStatus Implemented
       
    47   
       
    48    @SYMTestActions
       
    49    1. Call RApaLsSession::StartDocument passing a long document name (KLitLongURL).
       
    50    2. StartDocument should cause TStartDocApp.app to be launched, so wait
       
    51       for the application thread to terminate.
       
    52    3. Check the thread has terminated in the way we expected
       
    53   
       
    54    @SYMTestExpectedResults
       
    55    Calling RApaLsSession::StartDocument should cause the apparc server to
       
    56    call CLongUrlRec::DoRecognizeL as part of trying to find the mime type
       
    57    of the document. CLongUrlRec returns a mime type which is associated with
       
    58    TStartDocApp.app, so apparc server starts TStartDocApp.app passing the
       
    59    long document name on the command line.
       
    60    The long document name should eventually be passed through to
       
    61    CStartDocAppUi::ProcessCommandParametersL which will panic with
       
    62    EPanicDocNameCheck1Failed if the document name isn't KLitLongURL.
       
    63    CStartDocDocument::OpenFileL panics with EPanicDocNameCheck1NotExecuted if
       
    64    the document name check in CStartDocAppUi::ProcessCommandParametersL wasn't
       
    65    executed.
       
    66    CStartDocDocument::OpenFileL panics with EPanicDocNameCheck2Failed if
       
    67    the document name returned by CApaProcess::MainDocFileName isn't KLitLongURL.
       
    68   
       
    69    TStartDocApp.app should exit with KTStartDocTestPassed.
       
    70   
       
    71  */
       
    72 void CT_StartDocStep::TestStartDocL(RApaLsSession& aLs)
       
    73 	{
       
    74 	TPtrC longURL(KLitLongURL);
       
    75 	// sanity check to ensure the document name we're going to pass to
       
    76 	// RApaLsSession::StartDocument is longer than the maximum length
       
    77 	// of a file name
       
    78 	TEST(longURL.Length() > KMaxFileName);
       
    79 
       
    80 	TThreadId appThreadId(0U);
       
    81 	// start document, causing TStartDocApp.app to be launched
       
    82 	INFO_PRINTF1(_L("Starting document..."));
       
    83 	TInt ret = aLs.StartDocument(longURL, appThreadId);
       
    84 	TEST(ret == KErrNone);
       
    85 	User::LeaveIfError(ret);
       
    86 
       
    87 	RThread appThread;
       
    88 	User::LeaveIfError(appThread.Open(appThreadId));
       
    89 	TRequestStatus logonRequestStatus;
       
    90 	appThread.Logon(logonRequestStatus);
       
    91 
       
    92 	// wait for TStartDocApp.app to terminate
       
    93 	INFO_PRINTF1(_L("Waiting for application to terminate..."));
       
    94 	User::WaitForRequest(logonRequestStatus);
       
    95 
       
    96 	const TExitType exitType = appThread.ExitType();
       
    97 	const TInt exitReason = appThread.ExitReason();
       
    98 	TExitCategoryName categoryName = appThread.ExitCategory();
       
    99 	appThread.Close();
       
   100 
       
   101 	TBuf<50> msg;
       
   102 	if (exitType == EExitPanic)
       
   103 		{
       
   104 		_LIT(KAppPanicInfo, "Application panic: %S %d");
       
   105 		msg.Format(KAppPanicInfo, &categoryName, exitReason);
       
   106 		}
       
   107 	else
       
   108 		{
       
   109 		_LIT(KAppExitInfo, "Application exited with code %d");
       
   110 		msg.Format(KAppExitInfo, exitReason);
       
   111 		}
       
   112 	INFO_PRINTF1(msg);
       
   113 
       
   114 	TEST(logonRequestStatus == KTStartDocTestPassed);
       
   115 	TEST(exitType == EExitKill);
       
   116 	TEST(exitReason == KTStartDocTestPassed);
       
   117 
       
   118 	//avoid race conditions
       
   119 	User::After(1500000);
       
   120 	}
       
   121 
       
   122 TVerdict CT_StartDocStep::doTestStepL()
       
   123 {
       
   124 	INFO_PRINTF1(_L("Test Started"));
       
   125 	
       
   126 	RTestableApaLsSession ls;
       
   127 	TEST(KErrNone == ls.Connect());
       
   128 	CleanupClosePushL(ls);
       
   129 
       
   130 	//avoid race conditions
       
   131 	User::After(1500000);
       
   132 
       
   133 	// run the test
       
   134 	HEAP_TEST_LS_SESSION(ls, 0, 0, TestStartDocL(ls), NO_CLEANUP);
       
   135 	
       
   136 	CleanupStack::PopAndDestroy(&ls);
       
   137 
       
   138 	INFO_PRINTF1(_L("Test Finished"));
       
   139 
       
   140 	return TestStepResult();
       
   141 }
       
   142 
       
   143