|
1 // Copyright (c) 2004-2010 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 // test code for INC045441 - Log Engine does not return events in sequence order |
|
15 // |
|
16 // |
|
17 |
|
18 #include <s32file.h> |
|
19 #include <e32math.h> |
|
20 #include <logview.h> |
|
21 #include "t_logutil2.h" |
|
22 |
|
23 RTest TheTest(_L("t_logorderbyid")); |
|
24 |
|
25 _LIT( KTestNumber1, "11111" ); |
|
26 _LIT( KTestNumber2, "22222" ); |
|
27 _LIT( KTestNumber3, "33333" ); |
|
28 |
|
29 /** |
|
30 Add an event to the log engine database. |
|
31 The event ID assigned by logengine is store in gTheId |
|
32 |
|
33 @param aClient |
|
34 @param aNumber The number that the event should contain |
|
35 @return The index for the event added. |
|
36 |
|
37 */ |
|
38 LOCAL_C TInt AddEventL( CLogClient& aClient, CLogEvent& aEvent, CTestActive& aActive, TInt aIndex ) |
|
39 { |
|
40 TInt returnId = KLogNullId; |
|
41 |
|
42 // Reset |
|
43 TTime now; |
|
44 now.UniversalTime(); |
|
45 |
|
46 aEvent.SetContact( aIndex ); |
|
47 |
|
48 // load the event with test values |
|
49 switch (aIndex) |
|
50 { |
|
51 case 1: |
|
52 aEvent.SetNumber( KTestNumber1 ); |
|
53 break; |
|
54 case 2: |
|
55 aEvent.SetNumber( KTestNumber2 ); |
|
56 break; |
|
57 case 3: |
|
58 aEvent.SetNumber( KTestNumber3 ); |
|
59 break; |
|
60 } |
|
61 |
|
62 // add the event to the logeng database |
|
63 aActive.StartL(); |
|
64 aClient.AddEvent( aEvent, aActive.iStatus ); |
|
65 CActiveScheduler::Start(); |
|
66 TEST2(aActive.iStatus.Int(), KErrNone); |
|
67 |
|
68 // check that an ID has been assigned |
|
69 returnId = aEvent.Id(); |
|
70 TEST( returnId != KLogNullId ); |
|
71 TEST( aEvent.Time() >= now ); |
|
72 |
|
73 // return the event id which has been assigned by the |
|
74 // log engine |
|
75 return returnId; |
|
76 } |
|
77 |
|
78 |
|
79 /** |
|
80 Get the event from the log engine database. |
|
81 |
|
82 @param aClient |
|
83 @param aTheId Unique id for the event to be fetch |
|
84 @param aNumber The number that the event should contain |
|
85 */ |
|
86 LOCAL_C void TestGetEventL( CLogClient& aClient, TInt aTheId, TInt aIndex ) |
|
87 |
|
88 { |
|
89 CTestActive* active = new( ELeave )CTestActive(); |
|
90 CleanupStack::PushL( active ); |
|
91 |
|
92 CLogEvent* event = CLogEvent::NewL(); |
|
93 CleanupStack::PushL( event ); |
|
94 |
|
95 event->SetId( aTheId ); |
|
96 |
|
97 active->StartL(); |
|
98 aClient.GetEvent( *event, active->iStatus ); |
|
99 CActiveScheduler::Start(); |
|
100 TEST2(active->iStatus.Int(), KErrNone); |
|
101 |
|
102 // check we got the right one back |
|
103 TEST( event->Contact() == aIndex ); |
|
104 |
|
105 TPtrC eventNumber = event->Number(); |
|
106 |
|
107 TBuf<30> dateString; |
|
108 _LIT( KDateString5, "%-B%:0%J%:1%T%:2%S%:3%+B" ); |
|
109 event->Time().FormatL( dateString, KDateString5 ); |
|
110 TPtrC eventDate = dateString.Ptr(); |
|
111 TheTest.Printf( _L( "Id:%d No:%S Time:%S \n" ), event->Id(), &eventNumber, &eventDate ); |
|
112 |
|
113 CleanupStack::PopAndDestroy( 2 ); // event, active |
|
114 } |
|
115 |
|
116 /** |
|
117 Test code for INC045441 - Log Engine does not return events in sequence order |
|
118 |
|
119 @SYMTestCaseID SYSLIB-LOGENG-CT-1020 |
|
120 @SYMTestCaseDesc Tests for checking the sequence order on events returned by log engine |
|
121 @SYMTestPriority High |
|
122 @SYMTestActions Test for getting the event in order as they were added to the log |
|
123 Check for memory and no error |
|
124 @SYMTestExpectedResults Test must not fail |
|
125 @SYMREQ REQ0000 |
|
126 */ |
|
127 LOCAL_C void TestRecentViewOrderingL( CLogClient& aClient ) |
|
128 // |
|
129 // |
|
130 // |
|
131 { |
|
132 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1020 ")); |
|
133 CLogEvent* event = CLogEvent::NewL(); |
|
134 CleanupStack::PushL(event); |
|
135 |
|
136 CTestActive* active = new( ELeave )CTestActive(); |
|
137 CleanupStack::PushL( active ); |
|
138 |
|
139 CLogViewRecent* view = CLogViewRecent::NewL( aClient ); |
|
140 CleanupStack::PushL( view ); |
|
141 |
|
142 TBuf<KLogMaxDirectionLength> buf; |
|
143 aClient.GetString(buf, R_LOG_DIR_MISSED); |
|
144 |
|
145 event->SetEventType( KLogCallEventTypeUid ); |
|
146 event->SetDirection( buf ); |
|
147 |
|
148 TEST( !view->SetRecentListL( KLogRecentMissedCalls, active->iStatus ) ); |
|
149 TEST( view->CountL() == 0 ); |
|
150 |
|
151 TTime time; |
|
152 TheTest.Next( _L( "add new event 1" ) ); |
|
153 TInt eventId1 = AddEventL( aClient, *event, *active, 1 ); |
|
154 TestGetEventL( aClient, eventId1, 1 ); |
|
155 |
|
156 TheTest.Next( _L( "time plus 10 mins - add new event 2" ) ); |
|
157 time.HomeTime(); |
|
158 TTimeIntervalMinutes timeTravelForward( 10 ); |
|
159 time += timeTravelForward; |
|
160 User::SetHomeTime( time ); |
|
161 TInt eventId2 = AddEventL( aClient, *event, *active, 2 ); |
|
162 TestGetEventL( aClient, eventId2, 2 ); |
|
163 |
|
164 TheTest.Next( _L( "time minus 5 mins - add new event 3" ) ); |
|
165 time.HomeTime(); |
|
166 TTimeIntervalMinutes timeTravelBackward( 5 ); |
|
167 time -= timeTravelBackward; |
|
168 User::SetHomeTime( time ); |
|
169 TInt eventId3 = AddEventL( aClient, *event, *active, 3 ); |
|
170 TestGetEventL( aClient, eventId3, 3 ); |
|
171 |
|
172 TEST( view->CountL() == 3 ); |
|
173 |
|
174 active->StartL(); |
|
175 // Get most recent |
|
176 TEST( view->FirstL( active->iStatus ) ); |
|
177 CActiveScheduler::Start(); |
|
178 TEST2(active->iStatus.Int(), KErrNone); |
|
179 |
|
180 TInt id3 = view->Event().Id(); |
|
181 // Get the one before that |
|
182 active->StartL(); |
|
183 TEST( view->NextL( active->iStatus ) ); |
|
184 CActiveScheduler::Start(); |
|
185 TEST2(active->iStatus.Int(), KErrNone); |
|
186 TInt id2 = view->Event().Id(); |
|
187 |
|
188 // Get the one before that |
|
189 active->StartL(); |
|
190 TEST( view->NextL( active->iStatus ) ); |
|
191 CActiveScheduler::Start(); |
|
192 TEST2(active->iStatus.Int(), KErrNone); |
|
193 TInt id1 = view->Event().Id(); |
|
194 |
|
195 TEST( id1 == eventId1 ); |
|
196 TEST( id2 == eventId2 ); |
|
197 TEST( id3 == eventId3 ); |
|
198 |
|
199 CleanupStack::PopAndDestroy( 3 ); // view, active, event |
|
200 theLog.Write( _L8( "Test 1.1 OK\n" ) ); |
|
201 } |
|
202 |
|
203 |
|
204 |
|
205 void doTestsL() |
|
206 { |
|
207 TestUtils::Initialize(_L("t_logorderbyid")); |
|
208 TestUtils::DeleteDatabaseL(); |
|
209 |
|
210 CLogClient* client = CLogClient::NewL( theFs ); |
|
211 CleanupStack::PushL( client ); |
|
212 |
|
213 CLogChangeNotifier* notifier = CLogChangeNotifier::NewL(); |
|
214 CleanupStack::PushL( notifier ); |
|
215 |
|
216 TheTest.Start( _L( "Recent view sorts by Id not ETime" ) ); |
|
217 TestRecentViewOrderingL( *client ); |
|
218 theLog.Write( _L8( "Test 1 OK\n" ) ); |
|
219 |
|
220 CleanupStack::PopAndDestroy( 2 ); // notifier, client; |
|
221 } |