1 /* |
|
2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Unit test replacement class for RPhCltUssd |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // |
|
20 // This implementation glues USSD client directly to |
|
21 // USSD Manager class so that the client/server mechanism is |
|
22 // not used. This is practical in unit test environment. |
|
23 // |
|
24 |
|
25 // INCLUDE FILES |
|
26 #include <e32base.h> |
|
27 #include "mphsrvussdmessagesentobserver.h" |
|
28 #include "ut_testenv.h" |
|
29 #include "cphsrvussdmanager.h" |
|
30 #include "rphcltussd.h" |
|
31 |
|
32 |
|
33 // ======================================================================== |
|
34 // GLOBALS |
|
35 // ======================================================================== |
|
36 |
|
37 class TUssdGlueAdapter: public MPhSrvUssdMessageSentObserver |
|
38 { |
|
39 public: |
|
40 void writeAttributes( const TDesC8& aAttributes ) |
|
41 { |
|
42 RMobileUssdMessaging::TMobileUssdAttributesV1Pckg pAttributes( |
|
43 iUssdAttributes ); |
|
44 pAttributes.Copy( aAttributes ); |
|
45 } |
|
46 void Listen( TRequestStatus& aReqStatus ) |
|
47 { |
|
48 aReqStatus = KRequestPending; |
|
49 iPendingStatus = &aReqStatus; |
|
50 } |
|
51 void UssdMessageSentObserverHandleResult( TInt aError ) |
|
52 { |
|
53 // this causes the pending active object to signalled and run |
|
54 User::RequestComplete( iPendingStatus, aError ); |
|
55 } |
|
56 |
|
57 RMobileUssdMessaging::TMobileUssdAttributesV1 iUssdAttributes; |
|
58 TRequestStatus* iPendingStatus; |
|
59 }; |
|
60 |
|
61 TUssdGlueAdapter glueAdapter; |
|
62 |
|
63 |
|
64 |
|
65 // ============================ MEMBER FUNCTIONS =============================== |
|
66 |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 RPhCltUssd::RPhCltUssd() |
|
70 { |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 TInt RPhCltUssd::Open( RPhCltServer& /*aServer*/ ) |
|
75 { |
|
76 return KErrNone; |
|
77 glueAdapter.iPendingStatus = 0; |
|
78 } |
|
79 |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 void RPhCltUssd::Close() |
|
83 { |
|
84 } |
|
85 |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 TInt RPhCltUssd::StartUssdEditor() const |
|
89 { |
|
90 TRAPD( leave, |
|
91 TestEnv::env().ussdManager().RequestStartEditingL() ); |
|
92 return leave; |
|
93 } |
|
94 |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 TInt RPhCltUssd::AppStarting() |
|
98 { |
|
99 TestEnv::env().ussdManager().InformUssdApplicationStarting(); |
|
100 return KErrNone; |
|
101 } |
|
102 |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 TInt RPhCltUssd::AppTerminating( |
|
106 TPhCltUssdAppExitReason aExitReason ) |
|
107 { |
|
108 RMessage2& fakeMessage = TestEnv::env().fakeMessage(); |
|
109 |
|
110 TRAPD( leave, |
|
111 TestEnv::env().ussdManager().InformUssdApplicationTerminatingL( fakeMessage ) ); |
|
112 |
|
113 return leave; |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 TBool RPhCltUssd::AppToForeground() |
|
118 { |
|
119 return TestEnv::env().ussdManager().InformUssdApplicationToForeground(); |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 TInt RPhCltUssd::AppToBackground() |
|
124 { |
|
125 TestEnv::env().ussdManager().InformUssdApplicationToBackground(); |
|
126 return KErrNone; |
|
127 } |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 void RPhCltUssd::SendUssd( |
|
131 TRequestStatus& aReqStatus, |
|
132 const TDesC8& aMsgData, |
|
133 const TDesC8& aMsgAttribute ) |
|
134 { |
|
135 glueAdapter.Listen( aReqStatus ); |
|
136 glueAdapter.writeAttributes( aMsgAttribute ); |
|
137 |
|
138 TRAPD( leave, TestEnv::env().ussdManager().SendUssdL( |
|
139 aMsgData, glueAdapter.iUssdAttributes, glueAdapter ) ); |
|
140 if ( leave != KErrNone ) |
|
141 { |
|
142 glueAdapter.UssdMessageSentObserverHandleResult( leave ); |
|
143 } |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 void RPhCltUssd::CancelSend() |
|
148 { |
|
149 TestEnv::env().ussdManager().SendUssdCancel(); |
|
150 } |
|
151 |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 void RPhCltUssd::StartSAT( |
|
155 TRequestStatus& aStatus , |
|
156 TDes& /*aReceiveMessage*/, |
|
157 TPckg< TUint >& /*aShowNotesAndDcs*/ ) |
|
158 { |
|
159 RMessage2& fakeMessage = TestEnv::env().fakeMessage(); |
|
160 |
|
161 TestEnv::env().ussdManager().InformStartSAT( fakeMessage ); |
|
162 |
|
163 TRequestStatus* reqStatus = &aStatus; |
|
164 User::RequestComplete( reqStatus, KErrNone ); |
|
165 } |
|
166 |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 void RPhCltUssd::StopSAT() |
|
170 { |
|
171 TestEnv::env().ussdManager().InformStopSAT(); |
|
172 } |
|
173 |
|
174 |
|
175 // End of File |
|