|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "authtrustedui.h" |
|
20 |
|
21 _LIT(KAuthTrustedUISecName, "Auth TrustedUI APIs test"); |
|
22 |
|
23 using namespace AuthServer; |
|
24 |
|
25 class CRegActive : public CActive |
|
26 { |
|
27 public: |
|
28 CRegActive(RAuthMgrClient& aClient, CIdentity*& aResult) : |
|
29 CActive(EPriorityNormal), |
|
30 iFirstTime(true), |
|
31 iClient(aClient), |
|
32 iResult(aResult), |
|
33 iErr(KErrNone) |
|
34 { |
|
35 CActiveScheduler::Add(this); |
|
36 } |
|
37 |
|
38 void doReg() |
|
39 { |
|
40 SetActive(); |
|
41 iClient.RegisterIdentityL(iResult, KAuthTrustedUISecName, iStatus); |
|
42 } |
|
43 |
|
44 void DoCancel() |
|
45 { |
|
46 } |
|
47 |
|
48 void RunL() |
|
49 { |
|
50 iErr = iStatus.Int(); |
|
51 CActiveScheduler::Stop(); |
|
52 } |
|
53 |
|
54 TInt RunError(TInt aError) |
|
55 { |
|
56 iErr = aError; |
|
57 CActiveScheduler::Stop(); |
|
58 return KErrNone; |
|
59 } |
|
60 |
|
61 TBool iFirstTime; |
|
62 RAuthMgrClient& iClient; |
|
63 CIdentity*& iResult; |
|
64 TInt iErr; |
|
65 }; |
|
66 |
|
67 |
|
68 CAuthTrustedUISecTest* CAuthTrustedUISecTest::NewL() |
|
69 { |
|
70 CAuthTrustedUISecTest* self=new(ELeave) CAuthTrustedUISecTest(); |
|
71 CleanupStack::PushL(self); |
|
72 self->ConstructL(); |
|
73 CleanupStack::Pop(self); |
|
74 return self; |
|
75 } |
|
76 |
|
77 CAuthTrustedUISecTest::CAuthTrustedUISecTest() |
|
78 { |
|
79 SetCapabilityRequired(ECapabilityTrustedUI); |
|
80 } |
|
81 |
|
82 void CAuthTrustedUISecTest::ConstructL() |
|
83 { |
|
84 SetNameL(KAuthTrustedUISecName); |
|
85 } |
|
86 |
|
87 void CAuthTrustedUISecTest::RunTestL() |
|
88 { |
|
89 TInt err(0); |
|
90 |
|
91 TRAP(err, DoTestL()); |
|
92 CheckFailL(err, _L("AuthServer::RegisterIdentityL().")); |
|
93 } |
|
94 |
|
95 void CAuthTrustedUISecTest::DoTestL() |
|
96 { |
|
97 AuthServer::RAuthMgrClient authMgrClient; |
|
98 User::LeaveIfError(authMgrClient.Connect()); |
|
99 CleanupClosePushL(authMgrClient); |
|
100 |
|
101 CActiveScheduler* sched = NULL; |
|
102 sched = new(ELeave) CActiveScheduler; |
|
103 CleanupStack::PushL(sched); |
|
104 CActiveScheduler::Install(sched); |
|
105 |
|
106 CIdentity* identity = 0; |
|
107 CRegActive active(authMgrClient, identity); |
|
108 active.doReg(); |
|
109 CActiveScheduler::Start(); |
|
110 |
|
111 CleanupStack::PopAndDestroy(2, &authMgrClient); |
|
112 User::LeaveIfError(active.iErr); |
|
113 } |
|
114 |