00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00035 #include "MainTestStep.h"
00036 #include "Te_ThreadClientServerTestSuiteDefs.h"
00037
00038
00039 _LIT(KTestCaseId, "tc_id");
00040 _LIT8(KTestData, "abcdefghijklmnopqrstuvwxyz");
00041
00045 CMainTestStep::~CMainTestStep()
00046 {
00047 }
00051 CMainTestStep::CMainTestStep(CTe_ThreadClientServerTestSuite& aParent)
00052 :CTe_ThreadClientServerTestSuiteStepBase(aParent)
00053 {
00054
00055
00056
00057 SetTestStepName(KMainTestStep);
00058 }
00065 TVerdict CMainTestStep::doTestStepL()
00066 {
00067 if (TestStepResult()==EPass)
00068 {
00069
00070 TInt id;
00071 if (!GetIntFromConfig(ConfigSection(),KTestCaseId,id))
00072 {
00073 User::Panic(_L("Cannot fetch test case id value from ini file"), 1);
00074 }
00075
00076 RThreadClient& client = iParent.Handler();
00077 if (id != 6)
00078 {
00079
00080 CleanupClosePushL(client);
00081 User::LeaveIfError(client.Connect());
00082 INFO_PRINTF1(_L("Connected to Thread Server"));
00083 }
00084
00085
00086 TInt r;
00087 TRequestStatus status;
00088
00089 switch (id)
00090 {
00091 case 1:
00092 {
00093
00094
00095
00096 _LIT(KSampleDriverLddFileName,"DRIVER1_LDD");
00097 _LIT(KSampleDriverPddFileName,"DRIVER1_PDD");
00098 INFO_PRINTF1(_L("Trying to load the same device driver Pdd"));
00099 r = User::LoadPhysicalDevice(KSampleDriverPddFileName);
00100 INFO_PRINTF3(_L("Expect Error %d : Receive Error %d"), KErrAlreadyExists,r);
00101 if (r!= KErrAlreadyExists)
00102 {
00103 SetTestStepResult(EFail);
00104 break;
00105 }
00106
00107 INFO_PRINTF1(_L("Trying to load the same device driver Ldd"));
00108 r = User::LoadLogicalDevice(KSampleDriverLddFileName);
00109 INFO_PRINTF3(_L("Expect Error %d : Receive Error %d"), KErrAlreadyExists,r);
00110 if (r!= KErrAlreadyExists)
00111 {
00112 SetTestStepResult(EFail);
00113 }
00114 }
00115 break;
00116
00117 case 2:
00118 {
00119
00120
00121 User::LeaveIfError(client.OpenDriver());
00122 INFO_PRINTF1(_L("Device Driver Opened"));
00123
00124 INFO_PRINTF1(_L("Sending Data 1"));
00125 client.Send(KTestData,status);
00126 User::WaitForRequest(status);
00127 INFO_PRINTF3(_L("Expect Error %d : Receive Error %d"), KErrNone,status.Int());
00128 if (status.Int()!=KErrNone)
00129 {
00130 SetTestStepResult(EFail);
00131 }
00132 }
00133 break;
00134
00135 case 3:
00136 {
00137
00138
00139 User::LeaveIfError(client.OpenDriver());
00140 INFO_PRINTF1(_L("Device Driver Opened"));
00141
00142 INFO_PRINTF1(_L("Sending Data 2"));
00143 client.Send(KTestData,status);
00144 INFO_PRINTF1(_L("Cancel Sending Data 2"));
00145 client.SendCancel();
00146 User::WaitForRequest(status);
00147 INFO_PRINTF3(_L("Expect Error %d : Receive Error %d"), KErrCancel,status.Int());
00148 if (status!=KErrCancel)
00149 {
00150 SetTestStepResult(EFail);
00151 }
00152 }
00153 break;
00154
00155 case 4:
00156 {
00157
00158
00159 User::LeaveIfError(client.OpenDriver());
00160 INFO_PRINTF1(_L("Device Driver Opened"));
00161
00162 INFO_PRINTF1(_L("Sending Data 3"));
00163 client.Send(KTestData,status);
00164
00165 TRequestStatus status2;
00166 INFO_PRINTF1(_L("Sending Data 4"));
00167 client.Send(KTestData,status2);
00168
00169 User::WaitForRequest(status);
00170 INFO_PRINTF1(_L("Finished Sending Data 3"));
00171 INFO_PRINTF3(_L("Expect Error %d : Receive Error %d"), KErrNone,status.Int());
00172 if (status!=KErrNone)
00173 {
00174 SetTestStepResult(EFail);
00175 }
00176 User::WaitForRequest(status2);
00177 INFO_PRINTF1(_L("Finished Sending Data 4"));
00178 INFO_PRINTF3(_L("Expect Error %d : Receive Error %d"), KErrNone,status2.Int());
00179 if (status2!=KErrNone)
00180 {
00181 SetTestStepResult(EFail);
00182 }
00183 }
00184 break;
00185
00186 case 5:
00187 {
00188
00189
00190 r = client.LoadDeviceDriver();
00191 if (r!=KErrNone)
00192 {
00193 INFO_PRINTF2(_L("Loading Device Driver Finished with error %d"), r);
00194 SetTestStepResult(EFail);
00195 break;
00196 }
00197 INFO_PRINTF1(_L("Device Driver Loaded"));
00198
00199 r = client.UnloadDeviceDriver();
00200 if (r!=KErrNone)
00201 {
00202 INFO_PRINTF2(_L("Unloading Device Driver Finished with error %d"), r);
00203 SetTestStepResult(EFail);
00204 break;
00205 }
00206 INFO_PRINTF1(_L("Device Driver Unloaded"));
00207 }
00208 break;
00209
00210 case 6:
00211 {
00212
00213
00214
00215
00216 RThreadClient anotherClient;
00217 CleanupClosePushL(anotherClient);
00218 INFO_PRINTF1(_L("trying to connect to server"));
00219 r = anotherClient.Connect();
00220 INFO_PRINTF2(_L("Connected to Process Server with error %d"), r);
00221 if (KErrNone!=r)
00222 {
00223 SetTestStepResult(EFail);
00224 }
00225 CleanupStack::PopAndDestroy(&anotherClient);
00226 INFO_PRINTF1(_L("Close Handle to ThreadServer"));
00227 }
00228 break;
00229
00230 default:
00231 User::Panic(_L("Unregonised Test Case IDs"), 1);
00232 }
00233
00234 if (id != 6)
00235 {
00236 CleanupStack::PopAndDestroy(&client);
00237 INFO_PRINTF1(_L("Close Handle to ThreadServer"));
00238 }
00239
00240
00241
00242 }
00243 return TestStepResult();
00244 }
00245
00246
00247
00248
00249