202 RDisplayChannel::TPostCount& aPostCount, |
205 RDisplayChannel::TPostCount& aPostCount, |
203 RDisplayChannel::TBufferFormat aBufferFormat, |
206 RDisplayChannel::TBufferFormat aBufferFormat, |
204 RDisplayChannel::TDisplayRotation aRotation, TInt aStep); |
207 RDisplayChannel::TDisplayRotation aRotation, TInt aStep); |
205 void GetHalDisplayInfo(); |
208 void GetHalDisplayInfo(); |
206 void CheckSecondHandle(); |
209 void CheckSecondHandle(); |
|
210 void TestBufferTransitions(); |
207 |
211 |
208 private: |
212 private: |
209 RDisplayChannel iDisp; /// handle to display channel device driver |
213 RDisplayChannel iDisp; /// handle to display channel device driver |
210 TVersion iVersion; /// version number of disp channel driver interface |
214 TVersion iVersion; /// version number of disp channel driver interface |
211 THalDisplayInfo iHalInfo; /// info about legacy buffer from HAL |
215 THalDisplayInfo iHalInfo; /// info about legacy buffer from HAL |
280 @param aScreenId the screen number to run the test on |
284 @param aScreenId the screen number to run the test on |
281 */ |
285 */ |
282 : CActive(EPriorityStandard), iScreenId(aScreenId) |
286 : CActive(EPriorityStandard), iScreenId(aScreenId) |
283 { |
287 { |
284 TVersion versionRequired = iDisp.VersionRequired(); |
288 TVersion versionRequired = iDisp.VersionRequired(); |
285 test.Printf(_L("Opening display channel for screen %d. Test compiled against version %d.%d.%d\n"), |
289 test.Printf(_L("*** Opening display channel for screen %d. Test compiled against version %d.%d.%d ***\n"), |
286 iScreenId, versionRequired.iMajor, versionRequired.iMinor, versionRequired.iBuild); |
290 iScreenId, versionRequired.iMajor, versionRequired.iMinor, versionRequired.iBuild); |
287 TInt err = iDisp.Open(iScreenId); |
291 TInt err = iDisp.Open(iScreenId); |
288 test_KErrNone(err); |
292 test_KErrNone(err); |
289 |
293 |
290 test.Printf(_L("Successfully opened display channel for screen %d\n"), iScreenId); |
294 test.Printf(_L("Successfully opened display channel for screen %d\n"), iScreenId); |
345 { |
349 { |
346 test.Next(_L("Test GetDisplayInfo")); |
350 test.Next(_L("Test GetDisplayInfo")); |
347 TPckgBuf<RDisplayChannel::TDisplayInfo> infoPkg; |
351 TPckgBuf<RDisplayChannel::TDisplayInfo> infoPkg; |
348 |
352 |
349 test_KErrNone(iDisp.GetDisplayInfo(infoPkg)); |
353 test_KErrNone(iDisp.GetDisplayInfo(infoPkg)); |
|
354 |
|
355 // This test only works with 24 and 32 BPP displays and crashes otherwise. Test for this and display |
|
356 // a nice human readable message rather than just crashing |
|
357 if ((infoPkg().iBitsPerPixel != 24) && (infoPkg().iBitsPerPixel != 32)) |
|
358 { |
|
359 TBuf<256> message; |
|
360 |
|
361 message.Format(_L("*** Error! %d bits per pixel displays are not supported. ***\n*** Please configure your ROM to use 24 or 32 bits per pixel. ***\n"), infoPkg().iBitsPerPixel); |
|
362 test.Printf(message); |
|
363 |
|
364 // And fail the test for the benefit of automated ONB tests |
|
365 test_Equal(infoPkg().iBitsPerPixel, 24); |
|
366 } |
350 |
367 |
351 test_Compare(infoPkg().iBitsPerPixel, >=, 1); |
368 test_Compare(infoPkg().iBitsPerPixel, >=, 1); |
352 test_Compare(infoPkg().iAvailableRotations, !=, 0); |
369 test_Compare(infoPkg().iAvailableRotations, !=, 0); |
353 |
370 |
354 // check for invalid rotations i.e. those not defined by TRotation |
371 // check for invalid rotations i.e. those not defined by TRotation |
684 test_KErrNone(iDisp.GetBufferFormat(actualBufferFormat)); |
701 test_KErrNone(iDisp.GetBufferFormat(actualBufferFormat)); |
685 } |
702 } |
686 else |
703 else |
687 { |
704 { |
688 // buffer format not switched in v1.1 so test just validates post / wait for post |
705 // buffer format not switched in v1.1 so test just validates post / wait for post |
|
706 TPckgBuf<RDisplayChannel::TDisplayInfo> infoPkg; |
|
707 test_KErrNone(iDisp.GetDisplayInfo(infoPkg)); |
|
708 |
|
709 err = iDisp.SetRotation(aRotation, configChanged); |
|
710 TInt expectedErr = KErrNone; |
|
711 if ((!IsValidRotation(aRotation)) || ((infoPkg().iAvailableRotations & aRotation) == 0)) |
|
712 { |
|
713 expectedErr = KErrArgument; |
|
714 } |
|
715 test(err == expectedErr); |
|
716 |
689 actualBufferFormat = aBufferFormat; |
717 actualBufferFormat = aBufferFormat; |
690 test_KErrNone(iDisp.SetRotation(aRotation, configChanged)); |
|
691 } |
718 } |
692 |
719 |
693 // Get the composition buffer index |
720 // Get the composition buffer index |
694 TUint bufferIndex; |
721 TUint bufferIndex; |
695 TRequestStatus status; |
722 TRequestStatus status; |
1117 test(IsValidRotation(currentRotation)); |
1144 test(IsValidRotation(currentRotation)); |
1118 |
1145 |
1119 TBool displayConfigChanged = EFalse; |
1146 TBool displayConfigChanged = EFalse; |
1120 TInt err = iDisp.SetRotation(aNewRotation, displayConfigChanged); |
1147 TInt err = iDisp.SetRotation(aNewRotation, displayConfigChanged); |
1121 TInt expectedErr = KErrNone; |
1148 TInt expectedErr = KErrNone; |
1122 if (! IsValidRotation(aNewRotation)) |
1149 if ((!IsValidRotation(aNewRotation)) || ((aSupported & aNewRotation) == 0)) |
1123 { |
1150 { |
1124 expectedErr = KErrArgument; |
1151 expectedErr = KErrArgument; |
1125 } |
|
1126 else if ((aSupported & aNewRotation) == 0) |
|
1127 { |
|
1128 expectedErr = KErrNotSupported; |
|
1129 } |
1152 } |
1130 test(err == expectedErr); |
1153 test(err == expectedErr); |
1131 |
1154 |
1132 // Check whether the rotation should / shouldn't have changed |
1155 // Check whether the rotation should / shouldn't have changed |
1133 test (iDisp.CurrentRotation() == (err == KErrNone ? aNewRotation : currentRotation)); |
1156 test (iDisp.CurrentRotation() == (err == KErrNone ? aNewRotation : currentRotation)); |
1177 TInt intDummy; |
1200 TInt intDummy; |
1178 TInt err; |
1201 TInt err; |
1179 TBuf8<256> buf; |
1202 TBuf8<256> buf; |
1180 TSize size; |
1203 TSize size; |
1181 |
1204 |
1182 #ifdef __WINS__ // Unknown requests panic on H4 implementation |
1205 test.Printf(_L("Testing display change APIs\n")); |
1183 test.Printf(_L("Testing display change APIs")); |
|
1184 iDisp.NotifyOnDisplayChangeCancel(); |
1206 iDisp.NotifyOnDisplayChangeCancel(); |
1185 TRequestStatus status; |
1207 TRequestStatus status; |
1186 iDisp.NotifyOnDisplayChange(status); |
1208 iDisp.NotifyOnDisplayChange(status); |
1187 test(status == KErrNotSupported); |
1209 test(status == KErrNotSupported); |
1188 #endif |
|
1189 |
1210 |
1190 err = iDisp.NumberOfResolutions(); |
1211 err = iDisp.NumberOfResolutions(); |
1191 test(err == KErrNotSupported); |
1212 test(err == KErrNotSupported); |
1192 |
1213 |
1193 err = iDisp.GetResolutions(buf, intDummy); |
1214 err = iDisp.GetResolutions(buf, intDummy); |
1223 /** |
1244 /** |
1224 Opens a second RDisplayChannel. |
1245 Opens a second RDisplayChannel. |
1225 The driver may not support this but must not crash. |
1246 The driver may not support this but must not crash. |
1226 */ |
1247 */ |
1227 { |
1248 { |
1228 test.Next(_L("Open a second handle\n")); |
1249 test.Next(_L("Open a second handle")); |
1229 #ifdef __WINS__ |
|
1230 // This crashes on H4 |
|
1231 RDisplayChannel disp2; |
1250 RDisplayChannel disp2; |
1232 TInt err = disp2.Open(iScreenId); |
1251 TInt err = disp2.Open(iScreenId); |
|
1252 test(err == KErrNone || err == KErrInUse); |
|
1253 disp2.Close(); |
|
1254 } |
|
1255 |
|
1256 void CDisplayChannelTest::TestBufferTransitions() |
|
1257 /** |
|
1258 Because different buffer types (ie. composition, legacy and user) complete differently, we must test |
|
1259 switching between those different types of buffers to ensure that this is taken into account. |
|
1260 */ |
|
1261 { |
|
1262 // The support code required for this test exists only in the separated GCE display LDD, not in the |
|
1263 // legacy monolithic WINSCW LDD |
|
1264 #if defined(_DEBUG) && !defined(__WINS__) |
|
1265 test.Next(_L("Test transitions between buffer types")); |
|
1266 |
|
1267 TPckgBuf<RDisplayChannel::TDisplayInfo> displayInfo; |
|
1268 test_KErrNone(iDisp.GetDisplayInfo(displayInfo)); |
|
1269 |
|
1270 RChunk chunk; |
|
1271 RDisplayChannel::TBufferFormat bufferFormat(TSize(iHalInfo.iXPixels, iHalInfo.iYPixels), displayInfo().iPixelFormat); |
|
1272 |
|
1273 test.Next(_L("Get the LDD to create a user buffer")); |
|
1274 TInt err = iDisp.CreateUserBuffer(bufferFormat, chunk); |
1233 test_KErrNone(err); |
1275 test_KErrNone(err); |
1234 disp2.Close(); |
1276 |
1235 #endif |
1277 test.Next(_L("Register a user buffer")); |
|
1278 RDisplayChannel::TBufferId bufferId; |
|
1279 err = iDisp.RegisterUserBuffer(bufferId, chunk, 0); |
|
1280 test_KErrNone(err); |
|
1281 |
|
1282 test.Next(_L("Post a user buffer")); |
|
1283 TRequestStatus status; |
|
1284 RDisplayChannel::TPostCount postCount; |
|
1285 iDisp.PostUserBuffer(bufferId, status, NULL, postCount); |
|
1286 iDisp.PostLegacyBuffer(NULL, postCount); |
|
1287 |
|
1288 test.Printf(_L("Waiting for user buffer\n")); |
|
1289 User::WaitForRequest(status); |
|
1290 test(status.Int() == KErrNone || status.Int() == KErrCancel); |
|
1291 test.Printf(_L("Waiting for legacy buffer\n")); |
|
1292 iDisp.WaitForPost(postCount, status); |
|
1293 User::WaitForRequest(status); |
|
1294 test_KErrNone(status.Int()); |
|
1295 |
|
1296 test.Printf(_L("Getting composition buffer\n")); |
|
1297 TUint bufferIndex; |
|
1298 iDisp.GetCompositionBuffer(bufferIndex, status); |
|
1299 User::WaitForRequest(status); |
|
1300 test_KErrNone(status.Int()); |
|
1301 |
|
1302 iDisp.PostUserBuffer(bufferId, status, NULL, postCount); |
|
1303 iDisp.PostCompositionBuffer(NULL, postCount); |
|
1304 |
|
1305 test.Printf(_L("Waiting for user buffer\n")); |
|
1306 User::WaitForRequest(status); |
|
1307 test(status.Int() == KErrNone || status.Int() == KErrCancel); |
|
1308 test.Printf(_L("Waiting for composition buffer\n")); |
|
1309 iDisp.WaitForPost(postCount, status); |
|
1310 User::WaitForRequest(status); |
|
1311 test_KErrNone(status.Int()); |
|
1312 |
|
1313 test.Printf(_L("Deregistering user buffers\n")); |
|
1314 err = iDisp.DeregisterUserBuffer(bufferId); |
|
1315 test_KErrNone(err); |
|
1316 |
|
1317 test.Printf(_L("Done, closing shared chunk\n")); |
|
1318 chunk.Close(); |
|
1319 #endif // defined(_DEBUG) && !defined(__WINS__) |
1236 } |
1320 } |
1237 |
1321 |
1238 void CDisplayChannelTest::Start() |
1322 void CDisplayChannelTest::Start() |
1239 /** |
1323 /** |
1240 Run all of the test cases |
1324 Run all of the test cases |
1376 _LIT(KLdd, "display0.ldd"); |
1465 _LIT(KLdd, "display0.ldd"); |
1377 test.Printf(_L("Loading logical %S\n"), &KLdd); |
1466 test.Printf(_L("Loading logical %S\n"), &KLdd); |
1378 TInt err = User::LoadLogicalDevice(KLdd); |
1467 TInt err = User::LoadLogicalDevice(KLdd); |
1379 test(err == KErrNone || err == KErrAlreadyExists || err == KErrNotFound); |
1468 test(err == KErrNone || err == KErrAlreadyExists || err == KErrNotFound); |
1380 |
1469 |
|
1470 // Only test for kenel memory leaks for non WINSCW builds as the WINSCW LDD is obsolete and would |
|
1471 // take forever to debug |
|
1472 #ifndef __WINS__ |
|
1473 __KHEAP_MARK; |
|
1474 #endif // ! __WINS__ |
|
1475 |
1381 if (err == KErrNone || err == KErrAlreadyExists) |
1476 if (err == KErrNone || err == KErrAlreadyExists) |
1382 { |
1477 { |
1383 TInt numberOfScreens; |
1478 TInt numberOfScreens; |
1384 User::LeaveIfError(HAL::Get(HAL::EDisplayNumberOfScreens, numberOfScreens)); |
1479 User::LeaveIfError(HAL::Get(HAL::EDisplayNumberOfScreens, numberOfScreens)); |
1385 for (TInt screenNum = 0; screenNum < numberOfScreens; ++screenNum) |
1480 for (TInt screenNum = 0; screenNum < numberOfScreens; ++screenNum) |