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