|
1 // Copyright (c) 2007-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 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #include <eikstart.h> |
|
23 #include <eikapp.h> |
|
24 #include "ssmtestappsucessfulafterretry.h" |
|
25 #include "ssmtestapps.h" |
|
26 |
|
27 |
|
28 /** |
|
29 Standard DLL entry point function. |
|
30 Creates and returns an instance of the CApaApplication-derived class. |
|
31 @return an instance of the CApaApplication-derived class |
|
32 */ |
|
33 TInt E32Main() |
|
34 { |
|
35 return EikStart::RunApplication(CTestFAndFApplication::NewApplication); |
|
36 } |
|
37 |
|
38 CTestFAndFApplication::CTestFAndFApplication() |
|
39 { |
|
40 } |
|
41 |
|
42 CTestFAndFApplication::~CTestFAndFApplication() |
|
43 { |
|
44 } |
|
45 |
|
46 /** |
|
47 @return The application's UID |
|
48 */ |
|
49 TUid CTestFAndFApplication::AppDllUid() const |
|
50 { |
|
51 const TUid dll = {KTestAppForFAndFUid}; |
|
52 return dll; |
|
53 } |
|
54 |
|
55 /** |
|
56 @return CTestFAndFApplication or NULL if KErrNoMemory |
|
57 */ |
|
58 CApaApplication* CTestFAndFApplication::NewApplication() |
|
59 { |
|
60 // As the framework has at this point not started up enough, and therefore the TRAP-harness and |
|
61 // exception handlers aren’t available yet, this factory function is a non-leaving function and |
|
62 // can't use the new(Eleave) operator. |
|
63 return new CTestFAndFApplication(); |
|
64 } |
|
65 |
|
66 /** |
|
67 Called by the UI framework at application start-up to create an instance of the document class. |
|
68 @leave KErrNoMemory |
|
69 @return A CTestFAndFDocument |
|
70 */ |
|
71 CApaDocument* CTestFAndFApplication::CreateDocumentL() |
|
72 { |
|
73 return CTestFAndFDocument::NewL(*this); |
|
74 } |
|
75 |
|
76 CTestFAndFDocument::CTestFAndFDocument(CEikApplication& aApp) : CEikDocument(aApp) |
|
77 { |
|
78 } |
|
79 |
|
80 CTestFAndFDocument::~CTestFAndFDocument() |
|
81 { |
|
82 } |
|
83 |
|
84 /** |
|
85 Factory function for this class |
|
86 @return a new CEndTaskTestDocument instance. |
|
87 */ |
|
88 CTestFAndFDocument* CTestFAndFDocument::NewL(CEikApplication& aApp) |
|
89 { |
|
90 return new(ELeave) CTestFAndFDocument(aApp); |
|
91 } |
|
92 |
|
93 |
|
94 |
|
95 /** |
|
96 Called by the UI framework to construct the application UI class. |
|
97 Note that the app UI's ConstructL() is called by the UI framework. |
|
98 */ |
|
99 CEikAppUi* CTestFAndFDocument::CreateAppUiL() |
|
100 { |
|
101 return new(ELeave) CTestFAndFAppUi(); |
|
102 } |
|
103 |
|
104 |
|
105 |
|
106 CTestFAndFAppUi::CTestFAndFAppUi() |
|
107 { |
|
108 } |
|
109 |
|
110 |
|
111 |
|
112 CTestFAndFAppUi::~CTestFAndFAppUi() |
|
113 { |
|
114 } |
|
115 |
|
116 |
|
117 |
|
118 void CTestFAndFAppUi::ConstructL() |
|
119 { |
|
120 // Complete the UI framework's construction of the App UI. |
|
121 BaseConstructL(CEikAppUi::ENoAppResourceFile); |
|
122 |
|
123 RFs fs; |
|
124 RFileReadStream readStream; |
|
125 RFileWriteStream writeStream; |
|
126 |
|
127 CleanupClosePushL(fs); |
|
128 CleanupClosePushL(readStream); |
|
129 CleanupClosePushL(writeStream); |
|
130 |
|
131 User::LeaveIfError(fs.Connect()); |
|
132 User::LeaveIfError(readStream.Open(fs, KFileForFAndF, EFileRead)); |
|
133 |
|
134 TInt retryCount = readStream.ReadInt8L(); |
|
135 TInt failCount = readStream.ReadInt8L(); |
|
136 TInt delayRequired = readStream.ReadInt8L(); |
|
137 readStream.Close(); |
|
138 |
|
139 if(0 == failCount) |
|
140 { |
|
141 RProcess::Rendezvous(KErrNone); |
|
142 } |
|
143 else |
|
144 { |
|
145 User::LeaveIfError(writeStream.Open(fs, KFileForFAndF, EFileWrite)); |
|
146 |
|
147 writeStream.WriteInt8L(retryCount+1); |
|
148 writeStream.WriteInt8L(--failCount); |
|
149 writeStream.CommitL(); |
|
150 writeStream.Close(); |
|
151 |
|
152 // This delay is required for testing the absolute timeout of startsafe, this is just |
|
153 // random time delay been used. |
|
154 if(delayRequired) |
|
155 User::After(500000); |
|
156 |
|
157 |
|
158 // StartSafe will restart the process |
|
159 RProcess::Rendezvous(KErrGeneral); |
|
160 } |
|
161 CleanupStack::PopAndDestroy(3, &fs); |
|
162 } |
|
163 |
|
164 |