|
1 // Copyright (c) 2004-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 // T_LOGSERVCRASH.CPP |
|
15 // This tests the fix implemented for DEF047320 |
|
16 // |
|
17 // |
|
18 |
|
19 #include <s32file.h> |
|
20 #include <e32math.h> |
|
21 |
|
22 #include "TEST.H" |
|
23 #include <logview.h> |
|
24 |
|
25 #undef test //there is a "test" macro which hides "RTest test" declaration. |
|
26 |
|
27 RTest test(_L("Log Event Test Harness")); |
|
28 |
|
29 const TInt KTestEventNum = 10; |
|
30 const TLogDurationType KTestDurationType1 = 1; |
|
31 const TLogDuration KTestDuration1 = 0x1234; |
|
32 const TLogFlags KTestFlags1 = 0x5; |
|
33 const TLogLink KTestLink1 = 0x1234; |
|
34 |
|
35 _LIT(KTestRemoteParty1, "Remote Party"); |
|
36 _LIT(KTestDirection1, "Direction"); |
|
37 _LIT(KTestStatus1, "Status"); |
|
38 _LIT(KTestSubject1, "Subject"); |
|
39 _LIT(KTestNumber1, "TheNumber"); |
|
40 _LIT8(KTestData1, "ABCDEFGH"); |
|
41 |
|
42 TBool TheMatchingIsEnabled = EFalse; |
|
43 |
|
44 |
|
45 #define SERVER_NAME _L("LogServ*") |
|
46 |
|
47 /** |
|
48 @SYMTestCaseID SYSLIB-LOGENG-CT-1021 |
|
49 @SYMTestCaseDesc Tests for killing the server |
|
50 Tests for RProcess::Kill(),RThread::Kill() function |
|
51 @SYMTestPriority High |
|
52 @SYMTestActions If EKA2 find the process and kill it, for EKA1 find thread and kill it |
|
53 @SYMTestExpectedResults Test must not fail |
|
54 @SYMREQ REQ0000 |
|
55 */ |
|
56 LOCAL_C void TestKillServerL() |
|
57 { |
|
58 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1021 Before Killing Server ")); |
|
59 User::After(2000000); |
|
60 |
|
61 // for EKA2 find process and Kill |
|
62 // Note: this needs CAPABILITY PowerMgmt |
|
63 TFindProcess findProcess(SERVER_NAME); |
|
64 TFullName result; |
|
65 LEAVE_IF_ERROR( findProcess.Next(result) ); |
|
66 |
|
67 RProcess server; |
|
68 LEAVE_IF_ERROR( server.Open(findProcess, EOwnerProcess) ); |
|
69 server.Kill(0); |
|
70 |
|
71 test.Next(_L("Server is Killed")); |
|
72 User::After(2000000); |
|
73 } |
|
74 |
|
75 /** |
|
76 @SYMTestCaseID SYSLIB-LOGENG-CT-1022 |
|
77 @SYMTestCaseDesc Tests for operations on log database |
|
78 @SYMTestPriority High |
|
79 @SYMTestActions Check by add new event,change the event,and get event and check for integrity of data |
|
80 @SYMTestExpectedResults Test must not fail |
|
81 @SYMREQ REQ0000 |
|
82 */ |
|
83 LOCAL_C void TestEventViewL(CLogClient& aClient) |
|
84 { |
|
85 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1022 ")); |
|
86 CTestActive* active = new(ELeave)CTestActive(); |
|
87 CleanupStack::PushL(active); |
|
88 |
|
89 CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC(); |
|
90 changeObs->SetActive(); |
|
91 |
|
92 CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs); |
|
93 CleanupStack::PushL(view); |
|
94 |
|
95 CLogEvent* event; |
|
96 TLogId id; |
|
97 TTime now; |
|
98 now.UniversalTime(); |
|
99 TInt count; |
|
100 |
|
101 for(count = 0; count < KTestEventNum; count++) |
|
102 { |
|
103 event = CLogEvent::NewL(); |
|
104 CleanupStack::PushL(event); |
|
105 event->SetEventType(KLogCallEventTypeUid); |
|
106 |
|
107 //User::After(Math::Random() % 100000); |
|
108 User::After(1000000); |
|
109 active->StartL(); |
|
110 aClient.AddEvent(*event, active->iStatus); |
|
111 CActiveScheduler::Start(); |
|
112 |
|
113 TEST2(active->iStatus.Int(), KErrNone); |
|
114 TEST(event->EventType() == KLogCallEventTypeUid); |
|
115 TEST(event->Description().Length() > 0); |
|
116 TEST(event->Time() >= now); |
|
117 |
|
118 now = event->Time(); |
|
119 id = event->Id(); |
|
120 |
|
121 event->SetRemoteParty(KTestRemoteParty1); |
|
122 event->SetDirection(KTestDirection1); |
|
123 event->SetDurationType(KTestDurationType1); |
|
124 event->SetDuration(KTestDuration1); |
|
125 event->SetStatus(KTestStatus1); |
|
126 event->SetSubject(KTestSubject1); |
|
127 event->SetNumber(KTestNumber1); |
|
128 event->SetLink(KTestLink1); |
|
129 event->SetDataL(KTestData1); |
|
130 event->SetFlags(KTestFlags1); |
|
131 event->SetContact((TLogContactItemId) count+1); |
|
132 |
|
133 User::After(Math::Random() % 100000); |
|
134 active->StartL(); |
|
135 aClient.ChangeEvent(*event, active->iStatus); |
|
136 CActiveScheduler::Start(); |
|
137 |
|
138 TEST2(active->iStatus.Int(), KErrNone); |
|
139 TEST(event->EventType() == KLogCallEventTypeUid); |
|
140 TEST(event->RemoteParty() == KTestRemoteParty1); |
|
141 TEST(event->Direction() == KTestDirection1); |
|
142 TEST(event->DurationType() == KTestDurationType1); |
|
143 TEST(event->Duration() == KTestDuration1); |
|
144 TEST(event->Status() == KTestStatus1); |
|
145 TEST(event->Subject() == KTestSubject1); |
|
146 TEST(event->Number() == KTestNumber1); |
|
147 TEST(event->Link() == KTestLink1); |
|
148 TEST(event->Data() == KTestData1); |
|
149 TLogFlags eventFlags; |
|
150 if(TheMatchingIsEnabled) |
|
151 { |
|
152 eventFlags=KTestFlags1|KLogEventContactSearched; |
|
153 } |
|
154 else |
|
155 { |
|
156 eventFlags=KTestFlags1; |
|
157 } |
|
158 TEST(event->Flags() == eventFlags); |
|
159 TEST(event->Contact()==(TLogContactItemId) count+1); |
|
160 |
|
161 CleanupStack::PopAndDestroy(); // event; |
|
162 |
|
163 event = CLogEvent::NewL(); |
|
164 CleanupStack::PushL(event); |
|
165 |
|
166 event->SetId(id); |
|
167 active->StartL(); |
|
168 aClient.GetEvent(*event, active->iStatus); |
|
169 CActiveScheduler::Start(); |
|
170 |
|
171 TEST2(active->iStatus.Int(), KErrNone); |
|
172 TEST(event->EventType() == KLogCallEventTypeUid); |
|
173 TEST(event->RemoteParty() == KTestRemoteParty1); |
|
174 TEST(event->Direction() == KTestDirection1); |
|
175 TEST(event->DurationType() == KTestDurationType1); |
|
176 TEST(event->Duration() == KTestDuration1); |
|
177 TEST(event->Status() == KTestStatus1); |
|
178 TEST(event->Subject() == KTestSubject1); |
|
179 TEST(event->Number() == KTestNumber1); |
|
180 TEST(event->Link() == KTestLink1); |
|
181 TEST(event->Data() == KTestData1); |
|
182 TEST(event->Flags() == eventFlags); |
|
183 TEST(event->Contact()==(TLogContactItemId) count+1); |
|
184 CleanupStack::PopAndDestroy(); // event; |
|
185 } |
|
186 |
|
187 CleanupStack::PopAndDestroy(3, active); // Delete view, changeObs, active |
|
188 } |
|
189 |
|
190 /** |
|
191 This code tests that the log engine will restart automatically |
|
192 by killing the Log engine server and then checking that |
|
193 a test event can be added. |
|
194 Details can be found in DEF047320 |
|
195 |
|
196 */ |
|
197 void doTestsL() |
|
198 { |
|
199 TheMatchingIsEnabled = TestUtils::MatchingEnabledL(); |
|
200 |
|
201 // test 0 adds an event |
|
202 TestUtils::Initialize(_L("T_LOGSERVERCRASH")); |
|
203 TestUtils::DeleteDatabaseL(); |
|
204 |
|
205 CLogClient* client = CLogClient::NewL(theFs); |
|
206 CleanupStack::PushL(client); |
|
207 |
|
208 CLogChangeNotifier* notifier = CLogChangeNotifier::NewL(); |
|
209 CleanupStack::PushL(notifier); |
|
210 |
|
211 test.Start(_L("Event View With No Filter: Before Killing Sever")); |
|
212 test.Next(_L("Test Add Event")); |
|
213 TestEventViewL(*client); |
|
214 theLog.Write(_L8("Test 0 OK\n")); |
|
215 |
|
216 // Test 1 stops the server |
|
217 test.Next(_L("Test Kill Server")); |
|
218 TestKillServerL(); |
|
219 theLog.Write(_L8("Test 1 OK\n")); |
|
220 |
|
221 // Test 2 checks the server is going again |
|
222 test.Start(_L("Event View With No Filter : After Killing Sever")); |
|
223 test.Next(_L("Test Add Event")); |
|
224 TestEventViewL(*client); |
|
225 theLog.Write(_L8("Test 2 OK\n")); |
|
226 |
|
227 test.End(); |
|
228 CleanupStack::PopAndDestroy(2); |
|
229 } |