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