5
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: ?Description
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#include "tsysinfogeneraltests.h"
|
|
21 |
#include "sysinfoservice.h"
|
|
22 |
#include "tuseractivitynotifier.h"
|
|
23 |
#include "entitykeys.h"
|
|
24 |
#include "watchtimer.h"
|
|
25 |
#include <e32std.h>
|
|
26 |
|
|
27 |
using namespace SysInfo;
|
|
28 |
|
|
29 |
CTestUserActivity* CTestUserActivity::NewL(CStifLogger* aLog,TInt aTimeOut,Test_Type aType)
|
|
30 |
{
|
|
31 |
CTestUserActivity* self = new(ELeave) CTestUserActivity(aLog,aTimeOut,aType);
|
|
32 |
self->ConstructL();
|
|
33 |
return self;
|
|
34 |
}
|
|
35 |
|
|
36 |
CTestUserActivity::~CTestUserActivity()
|
|
37 |
{
|
|
38 |
Cancel();
|
|
39 |
if(iWaitSchedular->IsStarted())
|
|
40 |
iWaitSchedular->AsyncStop();
|
|
41 |
|
|
42 |
delete iTimer;
|
|
43 |
delete iSysInfoService;
|
|
44 |
delete iWaitSchedular;
|
|
45 |
}
|
|
46 |
|
|
47 |
void CTestUserActivity::ConstructL()
|
|
48 |
{
|
|
49 |
iSysInfoService = CSysInfoService::NewL();
|
|
50 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait();
|
|
51 |
iTimer = CWatchTimer::NewL(EPriorityNormal,this);
|
|
52 |
CActiveScheduler::Add(this);
|
|
53 |
}
|
|
54 |
|
|
55 |
CTestUserActivity::CTestUserActivity(CStifLogger* aLog,TInt aTimeOut,
|
|
56 |
Test_Type aType) :
|
|
57 |
CActive(EPriorityStandard),
|
|
58 |
iLog(aLog),
|
|
59 |
iInactivityTimeOut(aTimeOut),
|
|
60 |
iTestType(aType)
|
|
61 |
{
|
|
62 |
}
|
|
63 |
|
|
64 |
void CTestUserActivity::DoCancel()
|
|
65 |
{
|
|
66 |
}
|
|
67 |
|
|
68 |
void CTestUserActivity::RunL()
|
|
69 |
{
|
|
70 |
TestFuncL();
|
|
71 |
}
|
|
72 |
|
|
73 |
void CTestUserActivity::Start()
|
|
74 |
{
|
|
75 |
SetActive();
|
|
76 |
TRequestStatus* temp = &iStatus;
|
|
77 |
User::RequestComplete(temp, KErrNone);
|
|
78 |
iWaitSchedular->Start();
|
|
79 |
}
|
|
80 |
|
|
81 |
TInt CTestUserActivity::Result()
|
|
82 |
{
|
|
83 |
return iResult;
|
|
84 |
}
|
|
85 |
|
|
86 |
void CTestUserActivity::TestFuncL()
|
|
87 |
{
|
|
88 |
const TInt OneSec(1000000);
|
|
89 |
iTimer->After(OneSec*iInactivityTimeOut*30);
|
|
90 |
CStatus* inactivitytime = CStatus::NewL(iInactivityTimeOut);
|
|
91 |
CleanupStack::PushL(inactivitytime);
|
|
92 |
iSysInfoService->GetNotificationL(KDisplay,KUserInactivity,1,this,inactivitytime);
|
|
93 |
CleanupStack::PopAndDestroy(inactivitytime);
|
|
94 |
}
|
|
95 |
|
|
96 |
|
|
97 |
void CTestUserActivity::HandleResponseL(const TDesC& aEntity,const TDesC& aKey,
|
|
98 |
CSysData* aOutput, TInt32 aTransID, TSysRequest::TRequestType aType, TInt aError)
|
|
99 |
{
|
|
100 |
delete iTimer;
|
|
101 |
iTimer = NULL;
|
|
102 |
|
|
103 |
TInt status(0);
|
|
104 |
|
|
105 |
if( !(aEntity.Compare(KDisplay) || aKey.Compare(KUserInactivity)) )
|
|
106 |
{
|
|
107 |
if(!aError)
|
|
108 |
{
|
|
109 |
if(!(aTransID == 1))
|
|
110 |
{
|
|
111 |
iLog->Log(_L("Incorrect TransactionID: %d"),aTransID);
|
|
112 |
iResult = FAIL;
|
|
113 |
}
|
|
114 |
|
|
115 |
iLog->Log(_L("UserActivity/Inactivity Notification.."));
|
|
116 |
status = ((CStatus*)aOutput)->Status();
|
|
117 |
if(status)
|
|
118 |
iLog->Log(_L("User Inactivity Detected.."));
|
|
119 |
else
|
|
120 |
iLog->Log(_L("User Activity Detected.."));
|
|
121 |
iResult |= PASS;
|
|
122 |
delete aOutput;
|
|
123 |
}
|
|
124 |
else
|
|
125 |
{
|
|
126 |
iLog->Log(_L("Error Set in callback.."));
|
|
127 |
iResult |= FAIL;
|
|
128 |
}
|
|
129 |
}
|
|
130 |
|
|
131 |
if (ETESTACTIVITY == iTestType)
|
|
132 |
{
|
|
133 |
if(status)
|
|
134 |
{
|
|
135 |
iLog->Log(_L("Waiting for user activity"));
|
|
136 |
return;
|
|
137 |
}
|
|
138 |
else
|
|
139 |
{
|
|
140 |
iLog->Log(_L("User Activity Detected.."));
|
|
141 |
}
|
|
142 |
iResult |= PASS;
|
|
143 |
}
|
|
144 |
|
|
145 |
iResult |= PASS;
|
|
146 |
|
|
147 |
iWaitSchedular->AsyncStop();
|
|
148 |
}
|
|
149 |
|
|
150 |
void CTestUserActivity::HandleTimeOut()
|
|
151 |
{
|
|
152 |
iLog->Log(_L("TimeOut reached. Inactivity not detected.."));
|
|
153 |
iSysInfoService->Cancel(1);
|
|
154 |
iResult = FAIL;
|
|
155 |
iWaitSchedular->AsyncStop();
|
|
156 |
}
|
|
157 |
|