|
1 // Copyright (c) 2006-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 // RTestableApaLsSession is used to make it possible to heap test a RApaLsSession |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalComponent - Internal Symbian test code |
|
23 */ |
|
24 |
|
25 |
|
26 |
|
27 #include "testableapalssession.h" |
|
28 #include "../apserv/APSCLSV.H" |
|
29 |
|
30 |
|
31 /** |
|
32 Connects to the server and makes sure that recognizers are loaded on demand, |
|
33 for heap check reasons. |
|
34 Use this only when you don't want to wait for the app list to be populated. |
|
35 */ |
|
36 TInt RTestableApaLsSession::ConnectWithoutWaitingForListPopulation() |
|
37 { |
|
38 TInt err = RApaLsSession::Connect(); |
|
39 if(err == KErrNone) |
|
40 err = SetLoadRecognizersOnDemand(ETrue); |
|
41 return err; |
|
42 } |
|
43 |
|
44 /** |
|
45 Connects to the server and makes sure that recognizers are loaded on demand, |
|
46 for heap check reasons. |
|
47 It also makes sure that the app list is populated before continuing. |
|
48 */ |
|
49 TInt RTestableApaLsSession::Connect() |
|
50 { |
|
51 const TInt err = ConnectWithoutWaitingForListPopulation(); |
|
52 if(err != KErrNone) |
|
53 return err; |
|
54 |
|
55 TRequestStatus requeststatus; |
|
56 RegisterListPopulationCompleteObserver(requeststatus); |
|
57 User::WaitForRequest(requeststatus); |
|
58 |
|
59 return requeststatus.Int(); |
|
60 } |
|
61 |
|
62 /** |
|
63 Makes a __UHEAP_MARK on the server. |
|
64 */ |
|
65 TInt RTestableApaLsSession::HeapMark() const |
|
66 { |
|
67 return SendReceive(EDebugHeapMark, TIpcArgs(TIpcArgs::ENothing)); |
|
68 } |
|
69 |
|
70 /** |
|
71 Makes a __UHEAP_MARKEND on the server. |
|
72 */ |
|
73 TInt RTestableApaLsSession::HeapMarkEnd() const |
|
74 { |
|
75 return HeapMarkEnd(0); |
|
76 } |
|
77 |
|
78 /** |
|
79 Makes a __UHEAP_MARKENDC(aCount) on the server. |
|
80 */ |
|
81 TInt RTestableApaLsSession::HeapMarkEnd(TInt aCount) const |
|
82 { |
|
83 return SendReceive(EDebugHeapMarkEnd, TIpcArgs(aCount)); |
|
84 } |
|
85 |
|
86 /** |
|
87 Makes a __UHEAP_FAILNEXT on the server. |
|
88 */ |
|
89 TInt RTestableApaLsSession::HeapFailNext(TInt aCount) const |
|
90 { |
|
91 return SendReceive(EDebugHeapFailNext, TIpcArgs(aCount)); |
|
92 } |
|
93 |
|
94 /** |
|
95 Clears the app info array which is created on the server when calling |
|
96 GetAllApps() and similar methods. |
|
97 */ |
|
98 TInt RTestableApaLsSession::ClearAppInfoArray() const |
|
99 { |
|
100 return SendReceive(EDebugClearAppInfoArray, TIpcArgs(TIpcArgs::ENothing)); |
|
101 } |
|
102 |
|
103 /** |
|
104 Flushes the recognition cache. |
|
105 */ |
|
106 TInt RTestableApaLsSession::FlushRecognitionCache() const |
|
107 { |
|
108 return SendReceive(EDebugFlushRecognitionCache, TIpcArgs(TIpcArgs::ENothing)); |
|
109 } |
|
110 |
|
111 /** |
|
112 Sets whether or not the recognizers should be loaded on demand. |
|
113 */ |
|
114 TInt RTestableApaLsSession::SetLoadRecognizersOnDemand(TBool aLoadRecognizersOnDemand) const |
|
115 { |
|
116 return SendReceive(EDebugSetLoadRecognizersOnDemand, TIpcArgs(aLoadRecognizersOnDemand)); |
|
117 } |
|
118 |
|
119 /** |
|
120 When recognizers are loaded on demand a timer is used to do the actual unloading. |
|
121 Use this method to perform this unloading synchronously instead of waiting for |
|
122 the timer to go off. |
|
123 */ |
|
124 TInt RTestableApaLsSession::PerformOutstandingRecognizerUnloading() const |
|
125 { |
|
126 return SendReceive(EDebugPerformOutstandingRecognizerUnloading, TIpcArgs(TIpcArgs::ENothing)); |
|
127 } |
|
128 |
|
129 /** |
|
130 Deletes RApaLsSession's iExtension for heap checking purposes. |
|
131 |
|
132 A result is that outstanding asynchronous file recognitions are cancelled. |
|
133 */ |
|
134 void RTestableApaLsSession::DeleteExtension() |
|
135 { |
|
136 //this allows us to delete RApaLsSession's iExtension for heap check reasons |
|
137 //RApaLsSession is able to cope with a missing iExtension and must remain able to do so |
|
138 //since it's a R-class (i.e. no ConstructL() or equal where it can create it) |
|
139 //RApaLsSession recreates iExtension when needed |
|
140 //this assumes that iExtension pointer is at the end of the RApaLsSession object |
|
141 CBase** RApaLsSession_iExtension = (CBase**)((TInt)this + sizeof(RApaLsSession) - sizeof(CBase*)); |
|
142 delete *RApaLsSession_iExtension; |
|
143 *(RApaLsSession_iExtension) = NULL; |
|
144 } |
|
145 |
|
146 /** |
|
147 Waits for the type store to be updated by calling @c NotifyOnDataMappingChange() |
|
148 */ |
|
149 TInt RTestableApaLsSession::WaitForTypeStoreUpdate() |
|
150 { |
|
151 TRequestStatus status; |
|
152 NotifyOnDataMappingChange(status); |
|
153 User::WaitForRequest(status); |
|
154 return status.Int(); |
|
155 } |
|
156 |
|
157 /** |
|
158 Inserts an update object into the list of updates to perform that will fail during the commit stage |
|
159 */ |
|
160 TInt RTestableApaLsSession::AddFailingNonNativeApplicationsUpdate() |
|
161 { |
|
162 return SendReceive(EDebugAddFailingNonNativeApplicationsUpdate, TIpcArgs()); |
|
163 } |
|
164 |
|
165 /** |
|
166 Inserts an update object into the list of updates to perform that will Panic during the commit stage |
|
167 */ |
|
168 TInt RTestableApaLsSession::AddPanicingNonNativeApplicationsUpdate() |
|
169 { |
|
170 return SendReceive(EDebugAddPanicingNonNativeApplicationsUpdate, TIpcArgs()); |
|
171 } |
|
172 |
|
173 /** |
|
174 Inserts an update object into the list of updates to perform that will Panic if the system tries to |
|
175 roll it back, e.g. because an update further down the list failed. |
|
176 */ |
|
177 TInt RTestableApaLsSession::AddRollbackPanicingNonNativeApplicationsUpdate() |
|
178 { |
|
179 return SendReceive(EDebugAddRollbackPanicingNonNativeApplicationsUpdate, TIpcArgs()); |
|
180 } |