1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
21 |
21 |
22 #include "tcmd_step_devicesecuritycheck.h" |
22 #include "tcmd_step_devicesecuritycheck.h" |
23 #include "ssmsecuritychecknotifier.h" |
23 #include "ssmsecuritychecknotifier.h" |
24 #include "ssmuiproviderdll.h" |
24 #include "ssmuiproviderdll.h" |
25 #include "ssmcustomcmdfactory.h" |
25 #include "ssmcustomcmdfactory.h" |
|
26 #include <w32std.h> |
|
27 #include <s32file.h> |
|
28 |
|
29 const TUid KPropertyCategory={0x2000D75B}; |
|
30 const TUint32 KMiscPluginPropertyKey = 0x2000E658; |
26 |
31 |
27 CCustomCmdTestDeviceSecurityCheck::~CCustomCmdTestDeviceSecurityCheck() |
32 CCustomCmdTestDeviceSecurityCheck::~CCustomCmdTestDeviceSecurityCheck() |
28 { |
33 { |
29 delete iAsyncStopScheduler; |
34 delete iAsyncStopScheduler; |
30 delete iActiveSchedulerWait; |
35 delete iActiveSchedulerWait; |
42 INFO_PRINTF1(_L("doTestStepPreambleL")); |
47 INFO_PRINTF1(_L("doTestStepPreambleL")); |
43 //Create and install active scheduler |
48 //Create and install active scheduler |
44 iActiveScheduler = new(ELeave) CActiveScheduler; |
49 iActiveScheduler = new(ELeave) CActiveScheduler; |
45 CActiveScheduler::Install (iActiveScheduler); |
50 CActiveScheduler::Install (iActiveScheduler); |
46 iActiveSchedulerWait = new(ELeave) CActiveSchedulerWait; |
51 iActiveSchedulerWait = new(ELeave) CActiveSchedulerWait; |
|
52 TInt err = RProperty::Define(KPropertyCategory, KMiscPluginPropertyKey, RProperty::EInt); |
|
53 TEST(KErrNone == err || KErrAlreadyExists == err); |
|
54 err = RProperty::Set(KPropertyCategory, KMiscPluginPropertyKey, 1); |
|
55 TEST(KErrNone == err); |
47 |
56 |
48 //Needed for calling calback for stopping active scheduler |
57 //Needed for calling calback for stopping active scheduler |
49 iAsyncStopScheduler = new(ELeave) CAsyncCallBack(CActive::EPriorityIdle); |
58 iAsyncStopScheduler = new(ELeave) CAsyncCallBack(CActive::EPriorityIdle); |
50 return CTestStep::doTestStepPreambleL(); |
59 return CTestStep::doTestStepPreambleL(); |
51 } |
60 } |
52 |
61 |
53 TVerdict CCustomCmdTestDeviceSecurityCheck::doTestStepPostambleL() |
62 TVerdict CCustomCmdTestDeviceSecurityCheck::doTestStepPostambleL() |
54 { |
63 { |
|
64 TInt err = RProperty::Delete(KPropertyCategory, KMiscPluginPropertyKey); |
|
65 TEST(KErrNone == err); |
55 return CTestStep::doTestStepPostambleL(); |
66 return CTestStep::doTestStepPostambleL(); |
56 } |
67 } |
57 |
68 |
58 void CCustomCmdTestDeviceSecurityCheck::SimulatePasswordEntry() |
69 void CCustomCmdTestDeviceSecurityCheck::SimulatePasswordEntry() |
59 { |
70 { |
60 //Simulate the key press ,(comma) in to pin notifier dialogue |
71 RWsSession wsSession; |
|
72 TInt err = wsSession.Connect(); |
|
73 TEST(KErrNone == err); |
|
74 |
|
75 const TInt okButtonPos1 = 60; //the position of ok button |
|
76 const TInt okButtonPos2 = 600; //the position of ok button |
|
77 //Simulate the key press ,(comma) in to pin notifier dialogue |
61 TRawEvent eventDown; |
78 TRawEvent eventDown; |
62 TRawEvent eventUp; |
79 TRawEvent eventUp; |
63 |
80 |
64 eventDown.Set(TRawEvent::EKeyDown, EStdKeyComma); |
81 eventDown.Set(TRawEvent::EKeyDown, EStdKeyComma); |
65 UserSvr::AddEvent(eventDown); |
82 UserSvr::AddEvent(eventDown); |
78 |
95 |
79 //Reset it to false as wrong password should be entered only once |
96 //Reset it to false as wrong password should be entered only once |
80 iWrongPwd = EFalse; |
97 iWrongPwd = EFalse; |
81 } |
98 } |
82 |
99 |
83 eventDown.Set(TRawEvent::EKeyDown, EStdKeyEnter); |
100 eventDown.Set(TRawEvent::EButton1Down, okButtonPos1,okButtonPos2); |
84 UserSvr::AddEvent(eventDown); |
101 UserSvr::AddEvent(eventDown); |
85 eventUp.Set(TRawEvent::EKeyUp, EStdKeyEnter); |
102 eventUp.Set(TRawEvent::EButton1Up, okButtonPos1,okButtonPos2); |
86 UserSvr::AddEvent(eventUp); |
103 UserSvr::AddEvent(eventUp); |
87 User::After(100000); |
104 User::After(100000); |
|
105 |
|
106 wsSession.Flush(); |
|
107 wsSession.Close(); |
88 } |
108 } |
89 |
109 |
90 static TInt CallBackL(TAny* aCCustomCmdTestSimSecurityCheck) |
110 static TInt CallBackL(TAny* aCCustomCmdTestSimSecurityCheck) |
91 { |
111 { |
92 //Call back function to stop active scheduler |
112 //Call back function to stop active scheduler |
143 iCustomCmdDevSecurityCheck->iLockInfo.iStatus = RMobilePhone::EStatusLocked; |
163 iCustomCmdDevSecurityCheck->iLockInfo.iStatus = RMobilePhone::EStatusLocked; |
144 iCustomCmdDevSecurityCheck->iLockInfo.iSetting = RMobilePhone::ELockSetEnabled; |
164 iCustomCmdDevSecurityCheck->iLockInfo.iSetting = RMobilePhone::ELockSetEnabled; |
145 |
165 |
146 TestLockPhoneDeviceRespReceivedHelperL(); |
166 TestLockPhoneDeviceRespReceivedHelperL(); |
147 |
167 |
148 #ifdef __WINS__ |
168 INFO_PRINTF3(_L("Result at line %d is %d "),__LINE__ + 1, iRequest.Int()); |
149 INFO_PRINTF3(_L("Result at line %d is %d "),__LINE__ + 1, iRequest.Int()); |
169 TEST(KErrNone == iRequest.Int()); |
150 TEST(KErrNone == iRequest.Int()); |
170 |
151 #else |
|
152 INFO_PRINTF3(_L("Result at line %d is %d "),__LINE__ + 1, iRequest.Int()); |
|
153 TEST(KErrNotSupported == iRequest.Int()); |
|
154 #endif |
|
155 } |
171 } |
156 |
172 |
157 void CCustomCmdTestDeviceSecurityCheck::TestLockPhoneDeviceRespReceived2L() |
173 void CCustomCmdTestDeviceSecurityCheck::TestLockPhoneDeviceRespReceived2L() |
158 { |
174 { |
159 INFO_PRINTF1(_L("TestLockPhoneDeviceRespReceived2L")); |
175 INFO_PRINTF1(_L("TestLockPhoneDeviceRespReceived2L")); |
160 iCustomCmdDevSecurityCheck->iLockInfo.iStatus = RMobilePhone::EStatusLockUnknown; |
176 iCustomCmdDevSecurityCheck->iLockInfo.iStatus = RMobilePhone::EStatusLockUnknown; |
161 |
177 |
162 TestLockPhoneDeviceRespReceivedHelperL(); |
178 TestLockPhoneDeviceRespReceivedHelperL(); |
163 INFO_PRINTF3(_L("Result at line %d is %d "),__LINE__ + 1, iRequest.Int()); |
179 |
164 TEST(KErrNotSupported == iRequest.Int()); |
180 |
165 |
181 #ifdef __WINS__ |
166 /*#ifdef __WINS__ |
182 INFO_PRINTF3(_L("Result at line %d is %d "),__LINE__ + 1, iRequest.Int()); |
167 TEST(KErrNone == iRequest.Int()); |
183 TEST(KErrNotFound == iRequest.Int()); |
168 #else |
184 #else |
169 TEST(KErrNotSupported == iRequest.Int()); |
185 INFO_PRINTF3(_L("Result at line %d is %d "),__LINE__ + 1, iRequest.Int()); |
170 #endif*/ |
186 TEST(KErrNone == iRequest.Int()); |
|
187 #endif |
|
188 INFO_PRINTF1(_L("TestLockPhoneDeviceRespReceived2L")); |
171 } |
189 } |
172 |
190 |
173 void CCustomCmdTestDeviceSecurityCheck::TestLockPhoneDeviceRespReceived3L() |
191 void CCustomCmdTestDeviceSecurityCheck::TestLockPhoneDeviceRespReceived3L() |
174 { |
192 { |
175 INFO_PRINTF1(_L("TestLockPhoneDeviceRespReceived3L")); |
193 INFO_PRINTF1(_L("TestLockPhoneDeviceRespReceived3L")); |
222 TCallBack stop(CallBackL, this); |
240 TCallBack stop(CallBackL, this); |
223 iAsyncStopScheduler->Set(stop); |
241 iAsyncStopScheduler->Set(stop); |
224 iAsyncStopScheduler->CallBack(); |
242 iAsyncStopScheduler->CallBack(); |
225 iActiveSchedulerWait->Start(); |
243 iActiveSchedulerWait->Start(); |
226 |
244 |
227 INFO_PRINTF3(_L("Result at line %d is %d "),__LINE__ + 1, iRequest.Int()); |
245 #ifdef __WINS__ |
228 TEST(KErrNotSupported == iRequest.Int()); |
246 INFO_PRINTF3(_L("Result at line %d is %d "),__LINE__ + 1, iRequest.Int()); |
|
247 TEST(KErrNotFound == iRequest.Int()); |
|
248 #else |
|
249 INFO_PRINTF3(_L("Result at line %d is %d "),__LINE__ + 1, iRequest.Int()); |
|
250 TEST(KErrNone == iRequest.Int()); |
|
251 #endif |
229 } |
252 } |
230 |
253 |
231 void CCustomCmdTestDeviceSecurityCheck::TestLockPhoneToIccRespReceivedHelperL() |
254 void CCustomCmdTestDeviceSecurityCheck::TestLockPhoneToIccRespReceivedHelperL() |
232 { |
255 { |
233 iRequest = KRequestPending; |
256 iRequest = KRequestPending; |