|
1 /* |
|
2 * Copyright (c) 2006-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 * CTestStep derived implementation |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "tAuthSvrStep.h" |
|
21 |
|
22 #include "authserver/authclient.h" |
|
23 #include "authserver/authmgrclient.h" |
|
24 |
|
25 using namespace AuthServer; |
|
26 |
|
27 //==================================================================================================== |
|
28 CTSetAuthPrefs::CTSetAuthPrefs(CTAuthSvrServer& aParent): iParent(aParent) |
|
29 /** |
|
30 Constructor |
|
31 */ |
|
32 { |
|
33 // Call base class method to set up the human readable name for logging |
|
34 SetTestStepName(KTSetPrefs); |
|
35 } |
|
36 |
|
37 CTSetAuthPrefs::~CTSetAuthPrefs() |
|
38 /** |
|
39 Destructor |
|
40 */ |
|
41 {} |
|
42 |
|
43 TVerdict CTSetAuthPrefs::doTestStepPreambleL() |
|
44 /** |
|
45 @return - TVerdict code |
|
46 Override of base class virtual |
|
47 */ |
|
48 { |
|
49 //Call the parent class preamble, setting up the file server, etc |
|
50 CTStepActSch::doTestStepPreambleL(); |
|
51 |
|
52 return TestStepResult(); |
|
53 } |
|
54 |
|
55 TVerdict CTSetAuthPrefs::doTestStepL() |
|
56 /** |
|
57 @return - TVerdict code |
|
58 Override of base class pure virtual |
|
59 |
|
60 */ |
|
61 { |
|
62 //If any test step leaves or panics, the test step thread won't exit, further calls are made. |
|
63 // but the html log is updatead, so that subsequent failures could be traced here if necessary. |
|
64 if (TestStepResult() != EPass) |
|
65 { |
|
66 ERR_PRINTF1(_L("There was an error in a previous test step")); |
|
67 return TestStepResult(); |
|
68 } |
|
69 |
|
70 SetTestStepResult(EPass); |
|
71 |
|
72 __UHEAP_MARK; // Check for memory leaks |
|
73 |
|
74 //----------------------------------------------------------------------------------------------------- |
|
75 InitAuthServerFromFileL(); // Set things like 'iSupportsDefaultData' and 'DefaultPlugin' |
|
76 |
|
77 //Connect to the AuthServer |
|
78 AuthServer::RAuthMgrClient authMgrClient; |
|
79 TInt connectVal = authMgrClient.Connect(); |
|
80 if (KErrNotFound == connectVal) |
|
81 { |
|
82 //Retry after a delay |
|
83 TTimeIntervalMicroSeconds32 timeInterval = 2000; //2 Milliseconds |
|
84 User::After(timeInterval); |
|
85 connectVal = authMgrClient.Connect(); |
|
86 } |
|
87 if (KErrNone != connectVal) |
|
88 { |
|
89 ERR_PRINTF2(_L("Unable to start a session or other connection error. Err = %d"), connectVal); |
|
90 User::LeaveIfError(connectVal); |
|
91 } |
|
92 |
|
93 CleanupClosePushL(authMgrClient); |
|
94 |
|
95 AuthServer::RAuthClient authClient; |
|
96 |
|
97 connectVal = authClient.Connect(); |
|
98 if (KErrNotFound == connectVal) |
|
99 { |
|
100 //Retry after a delay |
|
101 TTimeIntervalMicroSeconds32 timeInterval = 2000; //2 Milliseconds |
|
102 User::After(timeInterval); |
|
103 connectVal = authClient.Connect(); |
|
104 } |
|
105 if (KErrNone != connectVal) |
|
106 { |
|
107 ERR_PRINTF2(_L("Unable to start a session or other connection error. Err = %d"), connectVal); |
|
108 User::LeaveIfError(connectVal); |
|
109 } |
|
110 |
|
111 CleanupClosePushL(authClient); |
|
112 //----------------------------------------------------------------------------------------------------- |
|
113 TRAPD(res2, SetAuthPrefsL(authMgrClient, authClient) ); |
|
114 if(KErrNone != res2) |
|
115 { |
|
116 ERR_PRINTF2(_L("SetAuthPrefsL() performed a Leave with code %d"), res2 ); |
|
117 SetTestStepError(res2); |
|
118 SetTestStepResult(EFail); |
|
119 } |
|
120 |
|
121 CleanupStack::PopAndDestroy(2,&authMgrClient); // authClient, authMgrClient |
|
122 //Garbage collect the last previously destroyed implementation |
|
123 // and close the REComSession if no longer in use |
|
124 REComSession::FinalClose(); |
|
125 __UHEAP_MARKEND; |
|
126 return TestStepResult(); |
|
127 } |
|
128 |
|
129 |
|
130 TVerdict CTSetAuthPrefs::doTestStepPostambleL() |
|
131 /** |
|
132 @return - TVerdict code |
|
133 Override of base class virtual |
|
134 */ |
|
135 { |
|
136 //Call the parent postamble, releasing the file handle, etc |
|
137 CTStepActSch::doTestStepPostambleL(); |
|
138 return TestStepResult(); |
|
139 } |
|
140 |
|
141 |
|
142 void CTSetAuthPrefs::SetAuthPrefsL (AuthServer::RAuthMgrClient& aAuthMgrClient, |
|
143 AuthServer::RAuthClient& aAuthClient) |
|
144 { |
|
145 TInt plugin = KUnknownPluginId; |
|
146 |
|
147 TBool done = EFalse; |
|
148 |
|
149 if (GetHexFromConfig(ConfigSection(),KDefauthPrefsTag, plugin)) |
|
150 { |
|
151 aAuthMgrClient.SetPreferredTypePluginL(EAuthDefault, plugin); |
|
152 if(aAuthClient.PreferredTypePluginL(EAuthDefault) == plugin) |
|
153 { |
|
154 done = ETrue; |
|
155 } |
|
156 } |
|
157 if (GetHexFromConfig(ConfigSection(),KKnowledgePrefsTag, plugin)) |
|
158 { |
|
159 aAuthMgrClient.SetPreferredTypePluginL(EAuthKnowledge, plugin); |
|
160 if(aAuthClient.PreferredTypePluginL(EAuthKnowledge) == plugin) |
|
161 { |
|
162 done = ETrue; |
|
163 } |
|
164 } |
|
165 if (GetHexFromConfig(ConfigSection(),KBiometricPrefsTag, plugin)) |
|
166 { |
|
167 aAuthMgrClient.SetPreferredTypePluginL(EAuthBiometric, plugin); |
|
168 if(aAuthClient.PreferredTypePluginL(EAuthBiometric) == plugin) |
|
169 { |
|
170 done = ETrue; |
|
171 } |
|
172 } |
|
173 if (GetHexFromConfig(ConfigSection(),KTokenPrefsTag, plugin)) |
|
174 { |
|
175 aAuthMgrClient.SetPreferredTypePluginL(EAuthToken, plugin); |
|
176 if(aAuthClient.PreferredTypePluginL(EAuthToken) == plugin) |
|
177 { |
|
178 done = ETrue; |
|
179 } |
|
180 } |
|
181 |
|
182 if (!done) |
|
183 { |
|
184 INFO_PRINTF1(_L("missing parameters in the ini file!")); |
|
185 SetTestStepResult(EFail); |
|
186 } |
|
187 } |