1017 } |
1017 } |
1018 |
1018 |
1019 |
1019 |
1020 // Get options |
1020 // Get options |
1021 //------------ |
1021 //------------ |
1022 |
|
1023 CSocketGetOptionStep::CSocketGetOptionStep(CCEsockTestBase*& aEsockTest) |
|
1024 : CTe_EsockStepBase(aEsockTest) |
|
1025 { |
|
1026 SetTestStepName(KSocketGetOptionStep); |
|
1027 } |
|
1028 |
|
1029 _LIT(KOptionName, "OptionName"); |
1022 _LIT(KOptionName, "OptionName"); |
1030 _LIT(KOptionLevel, "OptionLevel"); |
1023 _LIT(KOptionLevel, "OptionLevel"); |
|
1024 |
|
1025 CSocketGetOptionStep::CSocketGetOptionStep(CCEsockTestBase*& aEsockTest) |
|
1026 : CTe_EsockStepBase(aEsockTest) |
|
1027 { |
|
1028 SetTestStepName(KSocketGetOptionStep); |
|
1029 } |
|
1030 |
1031 _LIT(KExpectedOptionText, "ExpectedOptionText"); |
1031 _LIT(KExpectedOptionText, "ExpectedOptionText"); |
1032 _LIT(KExpectedOptionValue, "ExpectedOptionValue"); |
1032 _LIT(KExpectedOptionValue, "ExpectedOptionValue"); |
1033 |
1033 |
1034 TInt CSocketGetOptionStep::ConfigureFromIni() |
1034 TInt CSocketGetOptionStep::ConfigureFromIni() |
1035 { |
1035 { |
1138 |
1138 |
1139 // Return the result |
1139 // Return the result |
1140 return TestStepResult(); |
1140 return TestStepResult(); |
1141 } |
1141 } |
1142 |
1142 |
1143 |
1143 // Set options |
|
1144 //------------ |
|
1145 |
|
1146 CSocketSetOptionStep::CSocketSetOptionStep(CCEsockTestBase*& aEsockTest) |
|
1147 : CTe_EsockStepBase(aEsockTest) |
|
1148 { |
|
1149 SetTestStepName(KSocketSetOptionStep); |
|
1150 } |
|
1151 |
|
1152 _LIT(KOptionToSetText, "OptionToSetText"); |
|
1153 _LIT(KOptionToSetValue, "OptionToSetValue"); |
|
1154 |
|
1155 TInt CSocketSetOptionStep::ConfigureFromIni() |
|
1156 { |
|
1157 // Reset the parameters and read in necessary fields |
|
1158 iParams.Reset(); |
|
1159 |
|
1160 // Socket to apply it to |
|
1161 if((GetStringFromConfig(iSection, KTe_SocketName, iParams.iSocketName) != 1) |
|
1162 || (iParams.iSocketName.Length() == 0)) |
|
1163 { |
|
1164 INFO_PRINTF3(KErrString_MissingConfigFileField, &iSection, &KTe_SocketName); |
|
1165 return KErrNotFound; |
|
1166 } |
|
1167 |
|
1168 // Option "name" |
|
1169 if (GetIntFromConfig(iSection, KOptionName, iParams.iOptionName) != 1) |
|
1170 { |
|
1171 INFO_PRINTF3(KErrString_MissingConfigFileField, &iSection, &KOptionName); |
|
1172 return KErrNotFound; |
|
1173 } |
|
1174 |
|
1175 // Option level |
|
1176 if (GetIntFromConfig(iSection, KOptionLevel, iParams.iOptionLevel) != 1) |
|
1177 { |
|
1178 INFO_PRINTF1(_L("Option level not specified: defaulting to KLevelUnspecified")); |
|
1179 iParams.iOptionLevel = KLevelUnspecified; |
|
1180 } |
|
1181 |
|
1182 // Input text to be set |
|
1183 if(GetStringFromConfig(iSection, KOptionToSetText, iParams.iOptionToSetText) == 1) |
|
1184 { |
|
1185 iParams.iTextSet = ETrue; |
|
1186 } |
|
1187 |
|
1188 // Input value to be set |
|
1189 if(GetIntFromConfig(iSection, KOptionToSetValue, iParams.iOptionToSetValue) == 1) |
|
1190 { |
|
1191 iParams.iValueSet = ETrue; |
|
1192 } |
|
1193 |
|
1194 // Checks on config values |
|
1195 if(iParams.iValueSet && iParams.iTextSet) |
|
1196 { |
|
1197 INFO_PRINTF1(_L("Can be only value or text expected. Not both")); |
|
1198 return KErrCorrupt; |
|
1199 } |
|
1200 |
|
1201 if(!iParams.iValueSet && !iParams.iTextSet) |
|
1202 { |
|
1203 INFO_PRINTF1(_L("Must have value or text expected.")); |
|
1204 return KErrCorrupt; |
|
1205 } |
|
1206 |
|
1207 // All ok if we got this far |
|
1208 return KErrNone; |
|
1209 } |
|
1210 |
|
1211 TVerdict CSocketSetOptionStep::doSingleTestStep() |
|
1212 { |
|
1213 TRequestStatus requestStatus; |
|
1214 |
|
1215 TBuf8<256> inputBuffer; |
|
1216 inputBuffer.Copy(iParams.iOptionToSetText); |
|
1217 TInt inputValue = iParams.iOptionToSetValue; |
|
1218 TInt error; |
|
1219 |
|
1220 if(iParams.iTextSet) |
|
1221 { |
|
1222 error = iEsockTest->SetOptSocket(iParams, inputBuffer); |
|
1223 } |
|
1224 else |
|
1225 { |
|
1226 error = iEsockTest->SetOptSocket(iParams, inputValue); |
|
1227 } |
|
1228 |
|
1229 if (error != KErrNone) |
|
1230 { |
|
1231 INFO_PRINTF3(_L("Socket set option error. socket:%S, error:%d"), &iParams.iSocketName, error); |
|
1232 SetTestStepError(error); |
|
1233 return EFail; |
|
1234 } |
|
1235 |
|
1236 if(iParams.iTextSet) |
|
1237 { |
|
1238 // Convert the output to wide chars |
|
1239 TBuf<256> inputConvertedToWideChars; |
|
1240 CnvUtfConverter::ConvertToUnicodeFromUtf8(inputConvertedToWideChars, inputBuffer); |
|
1241 |
|
1242 // Log what was returned |
|
1243 INFO_PRINTF2(_L("Socket set with opt text. value:%S"), &inputConvertedToWideChars); |
|
1244 INFO_PRINTF2(_L("Text set by user. value:%S"), &iParams.iOptionToSetText); |
|
1245 |
|
1246 // Validate the output with that expected |
|
1247 TVerdict verdict = (inputConvertedToWideChars == iParams.iOptionToSetText) ? EPass : EFail; |
|
1248 SetTestStepResult(verdict); |
|
1249 } |
|
1250 else |
|
1251 { |
|
1252 // Log what was returned |
|
1253 INFO_PRINTF2(_L("Socket returned get opt value. value:%d"), inputValue); |
|
1254 INFO_PRINTF2(_L("Value set by user. value:%d"), iParams.iOptionToSetValue); |
|
1255 |
|
1256 // Validate the output with that expected |
|
1257 TVerdict verdict = (inputValue == iParams.iOptionToSetValue) ? EPass : EFail; |
|
1258 SetTestStepResult(verdict); |
|
1259 } |
|
1260 |
|
1261 // Return the result |
|
1262 return TestStepResult(); |
|
1263 } |
1144 |
1264 |
1145 // Socket protocol description |
1265 // Socket protocol description |
1146 //---------------------------- |
1266 //---------------------------- |
1147 CSocketProtocolDescriptionStep::CSocketProtocolDescriptionStep(CCEsockTestBase*& aEsockTest) |
1267 CSocketProtocolDescriptionStep::CSocketProtocolDescriptionStep(CCEsockTestBase*& aEsockTest) |
1148 : CTe_EsockStepBase(aEsockTest) |
1268 : CTe_EsockStepBase(aEsockTest) |