|
1 // Copyright (c) 1997-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 // Implementation of the stub class for the Discoverer tests |
|
15 // |
|
16 // |
|
17 |
|
18 #ifndef __DISCOVEREROBSERVERSTUB_H__ |
|
19 #define __DISCOVEREROBSERVERSTUB_H__ |
|
20 |
|
21 #include "DiscovererObserver.h" |
|
22 #include "DiscovererStateAccessor.h" |
|
23 #include "DiscovererTransitions.h" |
|
24 |
|
25 // ______________________________________________________________________________ |
|
26 // |
|
27 /** |
|
28 @internalComponent |
|
29 @since 7.0 |
|
30 This class is intended to provide the stub functionality of the |
|
31 CDiscoverers observer class. The methods will be used to log the |
|
32 calls that CDiscoverer is making to its observer. |
|
33 Note that the calls do not return any error codes, and so there |
|
34 is no requirement to repeat a transition, exercising the various |
|
35 control paths of the stub caller. |
|
36 RegisterDiscoveryL, and DriveReinstatedL can leave however, |
|
37 and there will be a repeat call on the transition that call |
|
38 these stub methods to exercise the alternative |
|
39 control paths of the caller. |
|
40 In the actual ECom implementation MDiscovererObserver is inherited |
|
41 privately but this causes problems with casting the stub so it is |
|
42 public here. |
|
43 */ |
|
44 class CObserverStub : public CBase, public MDiscovererObserver |
|
45 { |
|
46 public: |
|
47 /** |
|
48 @fn CObserverStub* NewL(CUnitTest& aOwner, CDiscoverer_UnitTestContext& aContext) |
|
49 Intended Usage : Standardised safe construction which leaves nothing the cleanup stack. |
|
50 Error Condition : Leaves with the error code. |
|
51 @leave KErrNoMemory. |
|
52 @since 7.0 |
|
53 @param CUnitTest& aOwner" " |
|
54 @return CObserverStub* |
|
55 @pre None |
|
56 @post CObserverStub is fully constructed and initialised. |
|
57 */ |
|
58 static CObserverStub* NewL(CUnitTest& aOwner, CDiscoverer_UnitTestContext& aContext); |
|
59 |
|
60 /** |
|
61 @fn CObserverStub* NewLC(CUnitTest& aOwner, CDiscoverer_UnitTestContext& aContext) |
|
62 Intended Usage : Standardised safe construction which leaves CObserverStub* upon the cleanup stack. |
|
63 Error Condition : Leaves with the error code. |
|
64 @leave KErrNoMemory. |
|
65 @since 7.0 |
|
66 @param CUnitTest& aOwner" " |
|
67 @return CObserverStub* |
|
68 @pre None |
|
69 @post CObserverStub is fully constructed and initialised, and remains on the cleanup stack. |
|
70 */ |
|
71 static CObserverStub* NewLC(CUnitTest& aOwner, CDiscoverer_UnitTestContext& aContext); |
|
72 |
|
73 /** |
|
74 @fn CObserverStub::~CObserverStub() |
|
75 Intended Usage : Default Destructor |
|
76 @since 7.0 |
|
77 @pre CObserverStub is fully constructed |
|
78 @post CObserverStub is fully destroyed |
|
79 */ |
|
80 virtual ~CObserverStub(); |
|
81 |
|
82 // Observer methods requiring overload |
|
83 /** |
|
84 @fn DiscoveriesBegin() |
|
85 Intended Usage : Overload of the MDiscovererObserver callback method. |
|
86 to signal that a discovery session is starting. |
|
87 Error Condition : None. |
|
88 @since 7.0 |
|
89 @return None. |
|
90 @pre The MDiscovererObserver must be fully constructed, and |
|
91 capable of accepting discoveries for registration. |
|
92 @post Discovery start is noted, and any appropriate action |
|
93 for the observer is completed. |
|
94 */ |
|
95 virtual void DiscoveriesBegin(); |
|
96 |
|
97 /** |
|
98 @fn RegisterDiscoveryL(const TEntry& aDirEntry) |
|
99 Intended Usage : Overload of the MDiscovererObserver callback method. |
|
100 to register a discovery. |
|
101 Error Condition : Depends upon the implementation class. |
|
102 @leave Implementation class dependent. @see CRegistrar. |
|
103 @since 7.0 |
|
104 @param aDirEntry A reference to the Discovered directory entry. |
|
105 @return None. |
|
106 @pre The MDiscovererObserver must be fully constructed, and |
|
107 capable of accepting discoveries for registration. |
|
108 @post Discovery is registered. |
|
109 */ |
|
110 virtual void RegisterDiscoveryL(const TEntry& aDirEntry); |
|
111 |
|
112 /** |
|
113 @fn DiscoveriesComplete(TBool aSuccessful) |
|
114 Intended Usage : Overload of the MDiscovererObserver callback method. |
|
115 to signal that a discovery session is complete. |
|
116 Error Condition : None. |
|
117 @since 7.0 |
|
118 @param aSuccessful ETrue indicates the scan completed successfully, |
|
119 EFalse, that the scan was only partial. |
|
120 @return None. |
|
121 @pre The MDiscovererObserver must be fully constructed, and |
|
122 capable of accepting discoveries for registration. |
|
123 @post Discovery completion is noted, and any appropriate action |
|
124 for the observer is completed. |
|
125 */ |
|
126 virtual void DiscoveriesComplete(TBool aSuccessful); |
|
127 |
|
128 /** |
|
129 @fn DriveRemovedL(TDriveUnit aDrive) |
|
130 Intended Usage :Overload of the MDiscovererObserver callback method. |
|
131 to notify the observer that a drive letter |
|
132 is no longer available for use. |
|
133 Error Condition : None. |
|
134 @since 7.0 : |
|
135 @param aDrive The drive identifier. |
|
136 @pre The MDiscovererObserver must be fully constructed, and |
|
137 capable of accepting discoveries for registration. |
|
138 @post Drive removal is noted, and any appropriate action |
|
139 for the observer is completed. |
|
140 E.g. The registered implementation groupings |
|
141 stored upon the specified drive are no |
|
142 longer available for use. |
|
143 */ |
|
144 virtual void DriveRemovedL(TDriveUnit aDrive); |
|
145 |
|
146 /** |
|
147 @fn DriveReinstatedL(TDriveUnit aDrive) |
|
148 Intended Usage :Overload of the MDiscovererObserver callback method. |
|
149 to notify the observer that a drive letter |
|
150 has become available for use. |
|
151 Error Condition : None. |
|
152 @since 7.0 : |
|
153 @param aDrive The drive identifier. |
|
154 @pre The MDiscovererObserver must be fully constructed, and |
|
155 capable of accepting discoveries for registration. |
|
156 @post Drive removal is noted, and any appropriate action |
|
157 for the observer is completed. |
|
158 E.g. The registered implementation groupings |
|
159 stored upon the specified drive are again |
|
160 made available for use. |
|
161 */ |
|
162 virtual void DriveReinstatedL(TDriveUnit aDrive); |
|
163 |
|
164 /** |
|
165 @fn NotifiedWithErrorCode(TInt aError) |
|
166 Intended Usage :Overload of the MDiscovererObserver callback method. |
|
167 The notification that the notifier has been activated |
|
168 with an error status code. The observer should instruct |
|
169 the notification object how to proceed. |
|
170 Error Condition : None. |
|
171 @since 7.0 : |
|
172 @param aError The error value recieved by the notifier. |
|
173 @return ETrue for ignore error, EFalse otherwise. |
|
174 @pre CRegistrar is fully constructed. |
|
175 @post The status code should be used by the observer to instruct |
|
176 the notifier to cease recieving notifications or not. |
|
177 */ |
|
178 virtual TBool NotifiedWithErrorCode(TInt aError); |
|
179 |
|
180 private: |
|
181 /** |
|
182 @fn CObserverStub::CObserverStub(CUnitTest& aOwner, CDiscoverer_UnitTestContext& aContext) |
|
183 Intended Usage : Default Constructor : usable only by derived classes |
|
184 @since 7.0 |
|
185 @param CUnitTest& A reference to the owning CUnitTest |
|
186 @return None |
|
187 @pre None |
|
188 @post CObserverStub is fully constructed |
|
189 */ |
|
190 CObserverStub(CUnitTest& aOwner, CDiscoverer_UnitTestContext& aContext); |
|
191 |
|
192 /** |
|
193 @fn void CObserverStub::ConstructL() |
|
194 Intended Usage : Completes the safe construction of the CObserverStub object |
|
195 Error Condition : Leaves with the error code. |
|
196 @leave KErrNoMemory. |
|
197 @since 7.0 |
|
198 @return None |
|
199 @pre CObserverStub is fully constructed |
|
200 @post CObserverStub is fully initialised |
|
201 */ |
|
202 void ConstructL(); |
|
203 |
|
204 // Attributes / Properties |
|
205 private: |
|
206 /** A reference to the owning CUnitTest */ |
|
207 CUnitTest& iOwner; |
|
208 /** A reference to the Unit Test context object */ |
|
209 CDiscoverer_UnitTestContext& iContext; |
|
210 }; // End of CObserverStub definition |
|
211 |
|
212 |
|
213 #endif // __DISCOVEREROBSERVERSTUB_H__ |