748
|
1 |
// Copyright (c) 2006-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 the License "Symbian Foundation License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// @file ctlbsstepclearlog.cpp
|
|
15 |
// This is the class implementation to clear the log file
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
/**
|
|
22 |
@file
|
|
23 |
@internalTechnology
|
|
24 |
@test
|
|
25 |
*/
|
|
26 |
|
|
27 |
#include "ctlbsstepclearlog.h"
|
|
28 |
|
|
29 |
|
|
30 |
CT_LbsStep_ClearLog::CT_LbsStep_ClearLog(CT_LbsServer& aParent) : CT_LbsStep(aParent)
|
|
31 |
{
|
|
32 |
SetTestStepName(KLbsStep_ClearLog);
|
|
33 |
}
|
|
34 |
|
|
35 |
/**
|
|
36 |
Static Constructor
|
|
37 |
*/
|
|
38 |
CT_LbsStep_ClearLog* CT_LbsStep_ClearLog::New(CT_LbsServer& aParent)
|
|
39 |
{
|
|
40 |
return new CT_LbsStep_ClearLog(aParent);
|
|
41 |
// Note the lack of ELeave.
|
|
42 |
// This means that having insufficient memory will return NULL;
|
|
43 |
}
|
|
44 |
|
|
45 |
|
|
46 |
/**
|
|
47 |
@pre
|
|
48 |
@return Test verdict
|
|
49 |
@post Log file cleared
|
|
50 |
*/
|
|
51 |
|
|
52 |
TVerdict CT_LbsStep_ClearLog::doTestStepL()
|
|
53 |
{
|
|
54 |
SetTestStepResult(EPass);
|
|
55 |
|
|
56 |
// Create necessary variables for Log reading
|
|
57 |
RFs theFs;
|
|
58 |
CLogClient* client;
|
|
59 |
CLogViewEvent* view;
|
|
60 |
CT_LbsAsyncWaiter* activeWaiter;
|
|
61 |
|
|
62 |
// Initialise variables
|
|
63 |
TInt ErrorCode = theFs.Connect();
|
|
64 |
if(ErrorCode)
|
|
65 |
{
|
|
66 |
INFO_PRINTF1(_L("\t Error: Open FileServer failed."));
|
|
67 |
SetTestStepResult(EFail);
|
|
68 |
}
|
|
69 |
|
|
70 |
|
|
71 |
client = CLogClient::NewL(theFs, CActive::EPriorityStandard);
|
|
72 |
view = CLogViewEvent::NewL(*client, CActive::EPriorityStandard);
|
|
73 |
activeWaiter = CT_LbsAsyncWaiter::NewL(); // NEW activeWaiter
|
|
74 |
|
|
75 |
|
|
76 |
// Setup a time in the future, before which all events will be deleted
|
|
77 |
_LIT(KDateCorrect1,"20900101:");
|
|
78 |
TTime time;
|
|
79 |
TBuf <10> theDate(KDateCorrect1);
|
|
80 |
TInt err=time.Set(theDate);
|
|
81 |
|
|
82 |
// Ensure time has been set correctly
|
|
83 |
if(err != KErrNone)
|
|
84 |
{
|
|
85 |
INFO_PRINTF1(_L("Failed to set time"));
|
|
86 |
}
|
|
87 |
|
|
88 |
if(err == KErrGeneral)
|
|
89 |
{
|
|
90 |
INFO_PRINTF1(_L("Time syntax is incorrect"));
|
|
91 |
}
|
|
92 |
|
|
93 |
// Set the filter to view ALL logs
|
|
94 |
CLogFilter* filter = CLogFilter::NewL(); // NEW FILTER
|
|
95 |
CleanupStack::PushL(filter);
|
|
96 |
TBool res = view->SetFilterL(*filter, activeWaiter->iStatus);
|
|
97 |
if (res == EFalse)
|
|
98 |
{
|
|
99 |
INFO_PRINTF1(_L("\t No such events to filter in the view."));
|
|
100 |
client->Cancel();
|
|
101 |
}
|
|
102 |
else
|
|
103 |
{
|
|
104 |
// else If there are logs, flush them
|
|
105 |
|
|
106 |
// Cancel outstanding requests
|
|
107 |
client->Cancel();
|
|
108 |
activeWaiter->StartAndWait();
|
|
109 |
if (activeWaiter->iStatus != KErrNone)
|
|
110 |
{
|
|
111 |
INFO_PRINTF2(_L("\t Error: Cancel returned error %d."),activeWaiter->iStatus.Int());
|
|
112 |
SetTestStepResult(EFail);
|
|
113 |
}
|
|
114 |
|
|
115 |
// Clear ALL logs
|
|
116 |
client->ClearLog(time, activeWaiter->iStatus);
|
|
117 |
activeWaiter->StartAndWait();
|
|
118 |
if (activeWaiter->iStatus != KErrNone)
|
|
119 |
{
|
|
120 |
INFO_PRINTF2(_L("\t Error: Clear log returned error %d."),activeWaiter->iStatus.Int());
|
|
121 |
SetTestStepResult(EFail);
|
|
122 |
}
|
|
123 |
|
|
124 |
//Confirm log is cleared
|
|
125 |
if(view->CountL() != 0)
|
|
126 |
{
|
|
127 |
INFO_PRINTF2(_L("<FONT><B>ERROR: Log still has %d entries</B></FONT>"),view->CountL());
|
|
128 |
SetTestStepResult(EFail);
|
|
129 |
}
|
|
130 |
|
|
131 |
}
|
|
132 |
|
|
133 |
CleanupStack::PopAndDestroy(filter);
|
|
134 |
|
|
135 |
// Cleanup everything
|
|
136 |
view->Cancel();
|
|
137 |
client->Cancel();
|
|
138 |
|
|
139 |
delete view;
|
|
140 |
delete client;
|
|
141 |
theFs.Close();
|
|
142 |
delete activeWaiter;
|
|
143 |
|
|
144 |
return TestStepResult();
|
|
145 |
}
|