|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file ConfirmSocketDataTransferStep.cpp |
|
18 */ |
|
19 |
|
20 #include "Sockets.TestSteps.h" |
|
21 |
|
22 CConfirmSocketDataTransferStep::CConfirmSocketDataTransferStep(CCEsockTestBase*& aEsockTest) |
|
23 : CTe_EsockStepBase(aEsockTest) |
|
24 { |
|
25 SetTestStepName(KConfirmSocketDataTransferStep); |
|
26 } |
|
27 |
|
28 TInt CConfirmSocketDataTransferStep::ConfigureFromIni() |
|
29 { |
|
30 iParams.Reset(); |
|
31 |
|
32 // Read in appropriate fields |
|
33 if((GetStringFromConfig(iSection, KTe_Name, iParams.iSocketCheckName) != 1) |
|
34 || (iParams.iSocketCheckName.Length() == 0)) |
|
35 { |
|
36 INFO_PRINTF1(_L("Couldn't find appropriate field in config file")); |
|
37 return KErrNotFound; |
|
38 } |
|
39 |
|
40 // Fetch the name of the socket |
|
41 if (GetStringFromConfig(iSection, KTe_SocketName, iParams.iSocketName) != 1) |
|
42 { |
|
43 INFO_PRINTF2(_L("%S: Associated socket name missing."), &iParams.iSocketCheckName); |
|
44 return KErrNotFound; |
|
45 } |
|
46 |
|
47 // Perhaps we are supposed to find an errored socket |
|
48 GetBoolFromConfig(iSection, KErrorExpected, iParams.iErrorExpected); |
|
49 |
|
50 TPtrC dataTransform; |
|
51 |
|
52 // Also fetch the type of transformation we should do on the data |
|
53 if (!iParams.iErrorExpected && (GetStringFromConfig(iSection, KSocketDataCheckTransformType, dataTransform) != 1)) |
|
54 { |
|
55 INFO_PRINTF2(_L("%S: Associated data transformation type missing."), &iParams.iSocketCheckName); |
|
56 return KErrNotFound; |
|
57 } |
|
58 |
|
59 if(dataTransform.Length() != 0) |
|
60 { |
|
61 // Decode the transform type |
|
62 if(dataTransform.Compare(_L("none"))) |
|
63 iParams.iTransformType = ETransformDataNone; |
|
64 else if (dataTransform.Compare(_L("xor"))) |
|
65 iParams.iTransformType = ETransformDataXor; |
|
66 else if (dataTransform.Compare(_L("one"))) |
|
67 iParams.iTransformType = ETransformDataAddOne; |
|
68 else if (dataTransform.Compare(_L("two"))) |
|
69 iParams.iTransformType = ETransfromDataAddTwo; |
|
70 else |
|
71 { |
|
72 INFO_PRINTF2(_L("%S: Associated data transformation type missing."), &iParams.iSocketCheckName); |
|
73 return KErrNotFound; |
|
74 } |
|
75 } |
|
76 |
|
77 // All ok if we got this far |
|
78 return KErrNone; |
|
79 } |
|
80 |
|
81 TVerdict CConfirmSocketDataTransferStep::doSingleTestStep() |
|
82 { |
|
83 #ifdef __1060_TESTCODE__ |
|
84 // Call the esock library function to do this check for us |
|
85 TInt error = iEsockTest->SendAndReceiveDataAndVerifyL(iParams); |
|
86 |
|
87 if (error != KErrNone) |
|
88 { |
|
89 INFO_PRINTF2(_L("Data on socket was not as expected (%S)."), &iParams.iSocketCheckName); |
|
90 INFO_PRINTF2(_L("Error: %d."), error); |
|
91 SetTestStepResult(EFail); |
|
92 } |
|
93 #endif |
|
94 |
|
95 return TestStepResult(); |
|
96 } |
|
97 |
|
98 |
|
99 |