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