|
1 // Copyright (c) 2007-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 // A test wrapper over the CSuplWdpWatcher class. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 @prototype |
|
22 */ |
|
23 |
|
24 #include <wapmessage.h> |
|
25 |
|
26 #include "Te_WatcherLog.h" |
|
27 #include "Te_WapBoundDatagramService.h" |
|
28 |
|
29 |
|
30 #define CWatcherLog CTe_WatcherLog |
|
31 #define TWatcherParams TTe_WatcherParams |
|
32 #define CLbsSuplPush CTe_LbsSuplPush |
|
33 #define CWapBoundDatagramService CTe_WapBoundDatagramService |
|
34 |
|
35 |
|
36 #include "Te_SuplWdpWatcher.h" |
|
37 |
|
38 TBool CTe_LbsSuplWdpWatcher::iEnableAsserts = ETrue; |
|
39 |
|
40 /** Redefines the ASSERT_DEBUG macro to be able to turn ot onn/off at run-time. */ |
|
41 #undef __ASSERT_DEBUG |
|
42 #define __ASSERT_DEBUG(c,p) (void)((c || !CTe_LbsSuplWdpWatcher::AssertsEnabled()) ||(p,0)) |
|
43 |
|
44 |
|
45 #include "LbsSuplWdpWatcher.cpp" |
|
46 |
|
47 |
|
48 /** |
|
49 Static factory method for creating an instance of the CLbsSuplWdpWatcher class and |
|
50 leaving it on the cleanup stack. |
|
51 |
|
52 @param aWatcherLog [In] A pointer on the test watcher log simulator. |
|
53 |
|
54 @return An instance of the class. The calling application becomes the |
|
55 owner of the returned instance and is responsible its disposal. |
|
56 |
|
57 @leave If a error happens, it leaves with one of the system error codes. |
|
58 */ |
|
59 CLbsSuplWdpWatcher* CLbsSuplWdpWatcher::NewLC(CTe_WatcherLog* aWatcherLog) |
|
60 { |
|
61 __ASSERT_ALWAYS(aWatcherLog!=0, User::Invariant()); |
|
62 //Two lines below - to avoid a false Leavescan error |
|
63 CLbsSuplWdpWatcher* self= new CLbsSuplWdpWatcher(CActive::EPriorityStandard, *aWatcherLog); |
|
64 User::LeaveIfNull(self); //A false Leavescan error because of the __ASSERT_DEBUG redefinition above |
|
65 self->iLocalPort = KSuplSmsTriggerWdpPort+1; |
|
66 CleanupStack::PushL(self); |
|
67 self->ConstructL(); |
|
68 return self; |
|
69 |
|
70 } |
|
71 |
|
72 /** |
|
73 Checks that the object in one of the possible states and check that the internal state of the object |
|
74 is in the agreement with the state it is currently in. |
|
75 |
|
76 @param aPossibleStates [In] The bitmask of the possible states. |
|
77 |
|
78 @leave If the object is not in one of the possible states or the internal state of the object |
|
79 is not in the agreement with the state it is currently in, this method will leave with error |
|
80 code KErrGeneral. |
|
81 |
|
82 @see CLbsSuplWdpWatcher::TState |
|
83 */ |
|
84 void CLbsSuplWdpWatcher::CheckStateL(TInt aPossibleStates) |
|
85 { |
|
86 |
|
87 if((iState & aPossibleStates)==0) |
|
88 { |
|
89 User::Leave(KErrGeneral); |
|
90 } |
|
91 |
|
92 if(EFalse==IsAdded() || !iTimer || iTruncated) |
|
93 { |
|
94 User::Leave(KErrGeneral); |
|
95 } |
|
96 |
|
97 switch(iState) |
|
98 { |
|
99 case EDisconnected: |
|
100 if(IsActive() || EFalse==iTimer->IsActive() || iData.MaxLength()>0 || iWdpConn) |
|
101 { |
|
102 User::Leave(KErrGeneral); |
|
103 } |
|
104 break; |
|
105 case EAwaitingDataSize: |
|
106 case EAwaitingData: |
|
107 if(EFalse==IsActive() || iTimer->IsActive() || !iWdpConn) |
|
108 { |
|
109 User::Leave(KErrGeneral); |
|
110 } |
|
111 |
|
112 if(iState==EAwaitingDataSize) |
|
113 { |
|
114 if(iData.MaxLength()>0) |
|
115 { |
|
116 User::Leave(KErrGeneral); |
|
117 } |
|
118 } |
|
119 else //EAwaitingData |
|
120 { |
|
121 if(iDataSize==0 || iData.MaxLength()<iDataSize) |
|
122 { |
|
123 User::Leave(KErrGeneral); |
|
124 } |
|
125 } |
|
126 break; |
|
127 default: |
|
128 __ASSERT_ALWAYS(0, User::Invariant()); |
|
129 break; |
|
130 } |
|
131 } |
|
132 |