|
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 // Supporting application for use by T_StartDocStep.cpp |
|
15 // The implementation of CR PHAR-5NTCWY removes the 256 character limit |
|
16 // on the length of document names. |
|
17 // This application is designed to be started by test code calling |
|
18 // RApaLsSession::StartDocument(const TDesC& aFileName, TThreadId& aId, |
|
19 // TLaunchType aLaunchType=ELaunchNewApp) |
|
20 // passing a document name (first parameter) that is longer than |
|
21 // 256 characters. |
|
22 // The test passes if this application is started with a document name |
|
23 // that is longer than 256 characters. |
|
24 // |
|
25 // |
|
26 |
|
27 /** |
|
28 @file |
|
29 @internalComponent - Internal Symbian test code |
|
30 */ |
|
31 |
|
32 #include <eikenv.h> |
|
33 #include <eikappui.h> |
|
34 #include <eikapp.h> |
|
35 #include <eikdoc.h> |
|
36 |
|
37 #include <eikstart.h> |
|
38 |
|
39 #include "TStartDoc.h" |
|
40 |
|
41 const TUid KUidTStartDocApp = { 0x10004c4d }; |
|
42 |
|
43 enum TStartDocAppPanic |
|
44 { |
|
45 EPanicDocNameCheck1Failed, |
|
46 EPanicDocNameCheck1NotExecuted, |
|
47 EPanicDocNameCheck2Failed, |
|
48 }; |
|
49 |
|
50 void Panic(TStartDocAppPanic aPanic) |
|
51 // |
|
52 // Panic the process with TESTFAILED as the category. |
|
53 // |
|
54 { |
|
55 _LIT(KPanicCategory,"TESTFAILED"); |
|
56 User::Panic(KPanicCategory, aPanic); |
|
57 } |
|
58 |
|
59 |
|
60 // |
|
61 // |
|
62 // CStartDocAppUi |
|
63 // |
|
64 // |
|
65 class CStartDocAppUi : public CEikAppUi |
|
66 { |
|
67 public: |
|
68 void ConstructL(); |
|
69 ~CStartDocAppUi(); |
|
70 public: |
|
71 TBool DocNameCheck1Executed() const; |
|
72 // from CEikAppUi |
|
73 TBool ProcessCommandParametersL(TApaCommand aCommand, TFileName& aDocumentName, const TDesC8& aTail); |
|
74 private: |
|
75 TBool iDocNameCheck1Executed; |
|
76 }; |
|
77 |
|
78 |
|
79 void CStartDocAppUi::ConstructL() |
|
80 { |
|
81 BaseConstructL(ENoAppResourceFile | ENoScreenFurniture); |
|
82 } |
|
83 |
|
84 CStartDocAppUi::~CStartDocAppUi() |
|
85 { |
|
86 } |
|
87 |
|
88 TBool CStartDocAppUi::DocNameCheck1Executed() const |
|
89 { |
|
90 return iDocNameCheck1Executed; |
|
91 } |
|
92 |
|
93 TBool CStartDocAppUi::ProcessCommandParametersL(TApaCommand /*aCommand*/, TFileName& aDocumentName, const TDesC8& /*aTail*/) |
|
94 { |
|
95 if (aDocumentName != KLitLongURL) |
|
96 { |
|
97 Panic(EPanicDocNameCheck1Failed); |
|
98 } |
|
99 iDocNameCheck1Executed = ETrue; |
|
100 return EFalse; // don't try to open the document |
|
101 } |
|
102 |
|
103 |
|
104 // |
|
105 // |
|
106 // CStartDocDocument |
|
107 // |
|
108 // |
|
109 class CStartDocDocument : public CEikDocument |
|
110 { |
|
111 public: |
|
112 static CStartDocDocument* NewL(CEikApplication& aApp); |
|
113 CStartDocDocument(CEikApplication& aApp); |
|
114 void ConstructL(); |
|
115 CFileStore* OpenFileL(TBool aDoOpen,const TDesC& aFilename,RFs& aFs); |
|
116 private: |
|
117 // from CEikDocument |
|
118 CEikAppUi* CreateAppUiL(); |
|
119 }; |
|
120 |
|
121 CStartDocDocument::CStartDocDocument(CEikApplication& aApp) |
|
122 : CEikDocument(aApp) |
|
123 { |
|
124 } |
|
125 |
|
126 CEikAppUi* CStartDocDocument::CreateAppUiL() |
|
127 { |
|
128 return new(ELeave) CStartDocAppUi; |
|
129 } |
|
130 |
|
131 CFileStore* CStartDocDocument::OpenFileL(TBool /*aDoOpen*/,const TDesC& /*aFilename*/,RFs& /*aFs*/) |
|
132 { |
|
133 if (!(static_cast<CStartDocAppUi*>(CEikonEnv::Static()->EikAppUi())->DocNameCheck1Executed())) |
|
134 { |
|
135 Panic(EPanicDocNameCheck1NotExecuted); |
|
136 } |
|
137 /** the process main doc filename should have been set by the framework by the time |
|
138 this function is called, so check it's been sucessfully set to a value that's |
|
139 longer than 256 characters |
|
140 (this tests the new CApaProcess::SetMainDocFileNameL API) |
|
141 */ |
|
142 if (Process()->MainDocFileName() != KLitLongURL) |
|
143 { |
|
144 Panic(EPanicDocNameCheck2Failed); |
|
145 } |
|
146 // by exiting the app here with KTStartDocTestPassed, we ensure the test cannot pass |
|
147 // in cases where something leaves during app startup |
|
148 User::After(10000000); // ensure that the test harness gets a chance to logon to us |
|
149 User::Exit(KTStartDocTestPassed); |
|
150 return NULL; // just to keep the compiler happy |
|
151 } |
|
152 |
|
153 |
|
154 // |
|
155 // |
|
156 // CStartDocApplication |
|
157 // |
|
158 // |
|
159 class CStartDocApplication : public CEikApplication |
|
160 { |
|
161 private: |
|
162 // from CApaApplication |
|
163 CApaDocument* CreateDocumentL(); |
|
164 TUid AppDllUid() const; |
|
165 private: |
|
166 TFileName ResourceFileName() const; |
|
167 private: |
|
168 CApaDocument* CreateDocumentL(CApaProcess* a) { return CEikApplication::CreateDocumentL(a); } |
|
169 // |
|
170 }; |
|
171 |
|
172 CApaDocument* CStartDocApplication::CreateDocumentL() |
|
173 { |
|
174 return new (ELeave) CStartDocDocument(*this); |
|
175 } |
|
176 |
|
177 TUid CStartDocApplication::AppDllUid() const |
|
178 { |
|
179 return KUidTStartDocApp; |
|
180 } |
|
181 |
|
182 TFileName CStartDocApplication::ResourceFileName() const |
|
183 { |
|
184 return TFileName(); // this app doesn't have a resource file |
|
185 } |
|
186 |
|
187 |
|
188 LOCAL_C CApaApplication* NewApplication() |
|
189 { |
|
190 return new CStartDocApplication; |
|
191 } |
|
192 |
|
193 GLDEF_C TInt E32Main() |
|
194 { |
|
195 return EikStart::RunApplication(NewApplication); |
|
196 } |
|
197 |
|
198 |