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