|
1 // Copyright (c) 2000-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 // This file contains the declaration of the CWapPushBaseMessageTest which implement the stack observer |
|
15 // to allow communication with the stack |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file PUSHTESTS.H |
|
21 */ |
|
22 |
|
23 #ifndef __PUSHTESTS_H__ |
|
24 #define __PUSHTESTS_H__ |
|
25 |
|
26 #include "t_wappush.h" |
|
27 #include "dummywapstack.h" // MDummyWapStackObserver |
|
28 |
|
29 #include <push/pushlog.h> // for test engine Rfs/Cwatcherlog |
|
30 #include "ConnMan.h" // for connection manager |
|
31 |
|
32 #include "testscripts.h" |
|
33 |
|
34 //const TInt KBufferSize = 256; // imitates KReceiveBufferSize from CLWatcher |
|
35 //const TInt KBufferSize = 1024; |
|
36 const TInt KBufferSize = 2048; |
|
37 |
|
38 class MWapPushLog; |
|
39 class CWapPushMsgGen; |
|
40 |
|
41 |
|
42 class MTimeoutCallback |
|
43 { |
|
44 public: |
|
45 virtual void Timeout() = 0; |
|
46 }; |
|
47 |
|
48 class CTestTimer : public CTimer |
|
49 { |
|
50 public: |
|
51 static CTestTimer* NewL(MTimeoutCallback* callback) |
|
52 { |
|
53 CTestTimer* self = new(ELeave) CTestTimer(callback); |
|
54 CleanupStack::PushL(self); |
|
55 self->ConstructL(); // CTimer |
|
56 CActiveScheduler::Add(self); |
|
57 CleanupStack::Pop(); |
|
58 return self; |
|
59 } |
|
60 |
|
61 protected: |
|
62 virtual void RunL() |
|
63 { |
|
64 iCallback->Timeout(); |
|
65 } |
|
66 private: |
|
67 CTestTimer(MTimeoutCallback* callback): CTimer(EPriorityLow), iCallback(callback) |
|
68 {}; |
|
69 |
|
70 MTimeoutCallback* iCallback; |
|
71 }; |
|
72 |
|
73 |
|
74 /** |
|
75 * Derived test case class which implement the stack observer |
|
76 * to allow communication with the stack |
|
77 * |
|
78 * This class has been made abstract to allow different derived classes |
|
79 * to implement creating multiple test messages via PrepareTestMessageL() |
|
80 * and the support of NumberTestCasesToRun() |
|
81 * BOTH must be implimented in any derived class. |
|
82 * ConfirmMessagesSavedL provides confirmation of message storage and |
|
83 * reports on number of messages found in store. |
|
84 */ |
|
85 class CWapPushBaseMessageTest : public CWapPushTest, public MDummyWapStackObserver |
|
86 { |
|
87 public: |
|
88 virtual ~CWapPushBaseMessageTest(); |
|
89 virtual void RunL(); |
|
90 virtual void RunError(); |
|
91 virtual void DoCancel(); |
|
92 |
|
93 /** set the test name for this test case |
|
94 @param void |
|
95 @return string |
|
96 returns test name |
|
97 */ |
|
98 virtual const TDesC& TestName(); |
|
99 |
|
100 virtual void NumberTestCasesToRun() = 0; |
|
101 virtual void PrepareTestMessageL(TInt aCurrentTestCase) = 0; // abstract class now!!! |
|
102 virtual TBool ConfirmMessagesSavedL() = 0; |
|
103 |
|
104 // from MDummyWapStackObserver |
|
105 virtual void DWSOUnitWaitPushL(CDummyWSPCLConn& aDummyCLConn); |
|
106 virtual void DWSOCancelUnitWaitPush(CDummyWSPCLConn& aDummyCLConn); |
|
107 virtual void DWSOServerShutDown(); |
|
108 virtual void DWSOError(const TDesC& aDes, TInt aLineNum); |
|
109 virtual void DWSOConnect(CDummyWSPCOConn& aDummyCOConn); |
|
110 virtual void DWSOGetEvent(CDummyWSPCOConn& aDummyCOConn); |
|
111 virtual void DWSOCancelGetEvent(CDummyWSPCOConn& aDummyCOConn); |
|
112 virtual void DWSOAckTransaction(CDummyWSPCOTrans& aDummyCOTrans); |
|
113 protected: |
|
114 void MoveToNextState(); |
|
115 void CompleteOwnRequest(); |
|
116 |
|
117 void InitialiseMsgService(); |
|
118 |
|
119 protected: |
|
120 enum TState |
|
121 { |
|
122 EInitialisation, |
|
123 EWaitForPush, |
|
124 EFinished |
|
125 }; |
|
126 protected: |
|
127 TState iState; |
|
128 |
|
129 TBuf8<KBufferSize> iBodyBuf; |
|
130 TBuf8<KBufferSize> iHeadersBuf; |
|
131 HBufC8* iBody; |
|
132 HBufC8* iHeaders; |
|
133 CScriptFile* iIniFile; |
|
134 |
|
135 CDummyWapStack* iWapStack; |
|
136 CConnectionManager* iConnMan; |
|
137 TBool iHasMsgBeenCompleted; |
|
138 TBool iHasTestBeenCompleted; |
|
139 |
|
140 TInt iNumberOfTestCases; |
|
141 TInt iCurrentTestCase; |
|
142 |
|
143 }; |
|
144 |
|
145 |
|
146 /** |
|
147 * Script Handler derived test case |
|
148 */ |
|
149 class CWapScriptTest : public CWapPushBaseMessageTest |
|
150 { |
|
151 virtual const TDesC& TestName(); |
|
152 |
|
153 virtual void NumberTestCasesToRun(); |
|
154 |
|
155 virtual void PrepareTestMessageL(TInt aCurrentTestCase); |
|
156 virtual TBool ConfirmMessagesSavedL(); |
|
157 ~CWapScriptTest(); |
|
158 void SetupAddressL(); |
|
159 }; |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 #endif |