1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/TOOM.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1624 @@
1.4 +// Copyright (c) 1996-2010 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Out of memory tests
1.18 +//
1.19 +//
1.20 +
1.21 +/**
1.22 + @file
1.23 + @test
1.24 + @internalComponent - Internal Symbian test code
1.25 +*/
1.26 +
1.27 +
1.28 +#include "TOOM.H"
1.29 +
1.30 +
1.31 +typedef COomFailBase *(*COmmCreate)(CTOom *aTest);
1.32 +
1.33 +COomFailBase *CreateOomConnect(CTOom *aTest)
1.34 + {return(new(ELeave) COomConnect(aTest));}
1.35 +
1.36 +COomFailBase *CreateOomWindow(CTOom *aTest)
1.37 + {return(new(ELeave) COomWindow(aTest));}
1.38 +
1.39 +COomFailBase *CreateOomWindowGroup(CTOom *aTest)
1.40 + {return(new(ELeave) COomWindowGroup(aTest));}
1.41 +
1.42 +COomFailBase *CreateOomBackedUpWindow(CTOom *aTest)
1.43 + {return(new(ELeave) COomBackedUpWindow(aTest));}
1.44 +
1.45 +COomFailBase *CreateOomBackupResize(CTOom *aTest)
1.46 + {return(new(ELeave) COomBackupResize(aTest));}
1.47 +
1.48 +COomFailBase *CreateOomBlankWindow(CTOom *aTest)
1.49 + {return(new(ELeave) COomBlankWindow(aTest));}
1.50 +
1.51 +COomFailBase *CreateOomGc(CTOom *aTest)
1.52 + {return(new(ELeave) COomGc(aTest));}
1.53 +
1.54 +COomFailBase *CreateOomScreenDevice(CTOom *aTest)
1.55 + {return(new(ELeave) COomScreenDevice(aTest));}
1.56 +
1.57 +COomFailBase *CreateOomPointerBuffer(CTOom *aTest)
1.58 + {return(new(ELeave) COomPointerBuffer(aTest));}
1.59 +
1.60 +COomFailBase *CreateOomPolygon(CTOom *aTest)
1.61 + {return(new(ELeave) COomPolygon(aTest));}
1.62 +
1.63 +COomFailBase *CreateOomPriorityKey(CTOom *aTest)
1.64 + {return(new(ELeave) COomPriorityKey(aTest));}
1.65 +
1.66 +COomFailBase *CreateOomCaptureKey(CTOom *aTest)
1.67 + {return(new(ELeave) COomCaptureKey(aTest));}
1.68 +
1.69 +COomFailBase *CreateOomCaptureKeyUpDown(CTOom *aTest)
1.70 + {return(new(ELeave) COomCaptureKeyUpDown(aTest));}
1.71 +
1.72 +COomFailBase *CreateOomLongKeyCapture(CTOom *aTest)
1.73 + {return(new(ELeave) COomLongKeyCapture(aTest));}
1.74 +
1.75 +COomFailBase *CreateOomHotKey(CTOom *aTest)
1.76 + {return(new(ELeave) COomHotKey(aTest));}
1.77 +
1.78 +COomFailBase *CreateOomGroupName(CTOom *aTest)
1.79 + {return(new(ELeave) COomGroupName(aTest));}
1.80 +
1.81 +COomFailBase *CreateOomMessageSend(CTOom *aTest)
1.82 + {return(new(ELeave) COomMessageSend(aTest));}
1.83 +
1.84 +COomFailBase *CreateOomMessageFetch(CTOom *aTest)
1.85 + {return(new(ELeave) COomMessageFetch(aTest));}
1.86 +
1.87 +COomFailBase *CreateOomSprite(CTOom *aTest)
1.88 + {return(new(ELeave) COomSprite(aTest));}
1.89 +
1.90 +COomFailBase *CreateOomPointerCursor(CTOom *aTest)
1.91 + {return(new(ELeave) COomPointerCursor(aTest));}
1.92 +
1.93 +COomFailBase *CreateOomCopyScreen(CTOom *aTest)
1.94 + {return(new(ELeave) COomCopyScreen(aTest));}
1.95 +
1.96 +COomFailBase *CreateOomRequestEvents(CTOom *aTest)
1.97 + {return(new(ELeave) COomRequestEvents(aTest));}
1.98 +
1.99 +COomFailBase *CreateOomCustomTextCursor(CTOom *aTest)
1.100 + {return(new(ELeave) COomCustomTextCursor(aTest));}
1.101 +
1.102 +COomFailBase *CreateOomTranspWindow(CTOom *aTest)
1.103 + {return(new(ELeave) COomTranspWindow(aTest));}
1.104 +
1.105 +COomFailBase *CreateOomObscuredWindow(CTOom *aTest)
1.106 + {return(new(ELeave) COomObscuredWindow(aTest));}
1.107 +
1.108 +COmmCreate CreateOomFailTest[]={
1.109 + CreateOomConnect,
1.110 + CreateOomWindow,
1.111 + CreateOomWindowGroup,
1.112 + CreateOomBackedUpWindow,
1.113 + CreateOomBackupResize,
1.114 + CreateOomBlankWindow,
1.115 + CreateOomGc,
1.116 + CreateOomScreenDevice,
1.117 + CreateOomPointerBuffer,
1.118 + CreateOomPolygon,
1.119 + CreateOomPriorityKey,
1.120 + CreateOomCaptureKey,
1.121 + CreateOomCaptureKeyUpDown,
1.122 + CreateOomLongKeyCapture,
1.123 + CreateOomHotKey,
1.124 + CreateOomGroupName,
1.125 + CreateOomSprite,
1.126 + CreateOomPointerCursor,
1.127 + CreateOomCopyScreen,
1.128 + CreateOomRequestEvents,
1.129 + CreateOomMessageSend,
1.130 + CreateOomMessageFetch,
1.131 + CreateOomCustomTextCursor,
1.132 + CreateOomTranspWindow,
1.133 + CreateOomObscuredWindow,
1.134 + };
1.135 +
1.136 +//
1.137 +// Individual out of memory test classes //
1.138 +//
1.139 +
1.140 +COomFailBase::COomFailBase(CTOom *aTest) : iTest(aTest)
1.141 + {}
1.142 +
1.143 +void COomFailBase::ConstructL()
1.144 + {
1.145 + iTest->INFO_PRINTF1(TestName());
1.146 + }
1.147 +
1.148 +void COomFailBase::PreFail()
1.149 + {}
1.150 +
1.151 +void COomFailBase::ClearUpL()
1.152 + {}
1.153 +
1.154 +void COomFailBase::Flush()
1.155 + {
1.156 + iWs.Flush();
1.157 + }
1.158 +
1.159 +COomConnect::COomConnect(CTOom *aTest) : COomFailBase(aTest)
1.160 + {}
1.161 +
1.162 +TOomTestName COomConnect::TestName()
1.163 + {
1.164 + return(_L("Connect"));
1.165 + }
1.166 +
1.167 +/** Creates a wserv session, connects and creates CWsScreenDevice object
1.168 +*/
1.169 +TInt COomConnect::Fail()
1.170 + {
1.171 + TInt err = iWs.Connect();
1.172 + if (err!=KErrNone)
1.173 + return err;
1.174 +
1.175 + TRAP(err, iDummyScreen = new (ELeave) CWsScreenDevice(iWs));
1.176 + if (err!=KErrNone)
1.177 + {
1.178 + iWs.Close();
1.179 + return err;
1.180 + }
1.181 +
1.182 + if ((err=iDummyScreen->Construct(iTest->ScreenNumber()))!=KErrNone)
1.183 + {
1.184 + delete iDummyScreen;
1.185 + iDummyScreen = NULL;
1.186 + iWs.Close();
1.187 + return err;
1.188 + }
1.189 +
1.190 + return err;
1.191 + }
1.192 +
1.193 +void COomConnect::ClearUpL()
1.194 + {
1.195 + if (iDummyScreen)
1.196 + {
1.197 + delete iDummyScreen;
1.198 + iDummyScreen = NULL;
1.199 + }
1.200 + iWs.Close();
1.201 + }
1.202 +
1.203 +//
1.204 +
1.205 +COomSetup::COomSetup(CTOom *aTest) : COomFailBase(aTest)
1.206 + {}
1.207 +
1.208 +void COomSetup::ConstructL()
1.209 + {
1.210 + COomFailBase::ConstructL();
1.211 + User::LeaveIfError(iWs.Connect());
1.212 + iDummyScreen = new (ELeave) CWsScreenDevice(iWs);
1.213 + User::LeaveIfError(iDummyScreen->Construct(iTest->ScreenNumber()));
1.214 +
1.215 + iWinGroup=RWindowGroup(iWs);
1.216 + iWinGroup.Construct(556);
1.217 + iWinGroup.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
1.218 + }
1.219 +
1.220 +COomSetup::~COomSetup()
1.221 + {
1.222 + iWinGroup.Close();
1.223 + delete iDummyScreen;
1.224 + iDummyScreen = NULL;
1.225 +
1.226 + iTest->TEST(iWs.ResourceCount()==0);
1.227 + if (iWs.ResourceCount()!=0)
1.228 + iTest->INFO_PRINTF3(_L("iWs.ResourceCount() return value - Expected: %d, Actual: %d"), 0, iWs.ResourceCount());
1.229 +
1.230 + iWs.Close();
1.231 + }
1.232 +
1.233 +//
1.234 +
1.235 +COomWindowGroup::COomWindowGroup(CTOom *aTest) : COomSetup(aTest)
1.236 + {}
1.237 +
1.238 +TOomTestName COomWindowGroup::TestName()
1.239 + {
1.240 + return(_L("Window Group"));
1.241 + }
1.242 +
1.243 +/** Creates a RWindowGroup object
1.244 +*/
1.245 +TInt COomWindowGroup::Fail()
1.246 + {
1.247 + iFailWinGroup=RWindowGroup(iWs);
1.248 + return(iFailWinGroup.Construct(987));
1.249 + }
1.250 +
1.251 +void COomWindowGroup::ClearUpL()
1.252 + {
1.253 + iFailWinGroup.Close();
1.254 + }
1.255 +
1.256 +//
1.257 +
1.258 +COomWindow::COomWindow(CTOom *aTest) : COomSetup(aTest)
1.259 + {}
1.260 +
1.261 +TOomTestName COomWindow::TestName()
1.262 + {
1.263 + return(_L("Window"));
1.264 + }
1.265 +
1.266 +/** Creates a RWindow object
1.267 +*/
1.268 +TInt COomWindow::Fail()
1.269 + {
1.270 + iFailWin=RWindow(iWs);
1.271 + return(iFailWin.Construct(iWinGroup,11));
1.272 + }
1.273 +
1.274 +void COomWindow::ClearUpL()
1.275 + {
1.276 + iFailWin.Close();
1.277 + }
1.278 +
1.279 +//
1.280 +
1.281 +COomBackedUpWindow::COomBackedUpWindow(CTOom *aTest) : COomSetup(aTest)
1.282 + {}
1.283 +
1.284 +TOomTestName COomBackedUpWindow::TestName()
1.285 + {
1.286 + return(_L("Backed up window"));
1.287 + }
1.288 +
1.289 +/** Creates a RBackedUpWindow object
1.290 +*/
1.291 +TInt COomBackedUpWindow::Fail()
1.292 + {
1.293 + iFailWin=RBackedUpWindow(iWs);
1.294 + return(iFailWin.Construct(iWinGroup,EGray16,22));
1.295 + }
1.296 +
1.297 +void COomBackedUpWindow::ClearUpL()
1.298 + {
1.299 + iFailWin.Close();
1.300 + }
1.301 +
1.302 +//
1.303 +
1.304 +COomBackupResize::COomBackupResize(CTOom *aTest) : COomSetup(aTest)
1.305 + {}
1.306 +
1.307 +COomBackupResize::~COomBackupResize()
1.308 + {
1.309 + iFailWin.Close();
1.310 + }
1.311 +
1.312 +TOomTestName COomBackupResize::TestName()
1.313 + {
1.314 + return(_L("Resize backed up window"));
1.315 + }
1.316 +
1.317 +void COomBackupResize::ConstructL()
1.318 + {
1.319 + COomSetup::ConstructL();
1.320 + iFailWin=RBackedUpWindow(iWs);
1.321 + User::LeaveIfError(iFailWin.Construct(iWinGroup,EGray16,33));
1.322 + User::LeaveIfError(iFailWin.SetSizeErr(TSize(10,10)));
1.323 + iFailWin.Activate();
1.324 + }
1.325 +
1.326 +/** Sets the size of previously created backed-up window
1.327 +*/
1.328 +TInt COomBackupResize::Fail()
1.329 + {
1.330 + return(iFailWin.SetSizeErr(TSize(100,100)));
1.331 + }
1.332 +
1.333 +void COomBackupResize::ClearUpL()
1.334 +//Virtual fn declared in CoomFailBase. This is the only one that can leave, I think, but one is enough
1.335 + {
1.336 + User::LeaveIfError(iFailWin.SetSizeErr(TSize(10,10)));
1.337 + }
1.338 +
1.339 +//
1.340 +
1.341 +COomBlankWindow::COomBlankWindow(CTOom *aTest) : COomSetup(aTest)
1.342 + {}
1.343 +
1.344 +TOomTestName COomBlankWindow::TestName()
1.345 + {
1.346 + return(_L("Blank window"));
1.347 + }
1.348 +
1.349 +/** Creates a RBlankWindow object
1.350 +*/
1.351 +TInt COomBlankWindow::Fail()
1.352 + {
1.353 + iFailWin=RBlankWindow(iWs);
1.354 + return(iFailWin.Construct(iWinGroup,44));
1.355 + }
1.356 +
1.357 +void COomBlankWindow::ClearUpL()
1.358 + {
1.359 + iFailWin.Close();
1.360 + }
1.361 +
1.362 +//
1.363 +
1.364 +COomPointerBuffer::COomPointerBuffer(CTOom *aTest) : COomSetup(aTest)
1.365 + {}
1.366 +
1.367 +COomPointerBuffer::~COomPointerBuffer()
1.368 + {
1.369 + iFailWin.Close();
1.370 + }
1.371 +
1.372 +TOomTestName COomPointerBuffer::TestName()
1.373 + {
1.374 + return(_L("Pointer buffer"));
1.375 + }
1.376 +
1.377 +void COomPointerBuffer::ConstructL()
1.378 + {
1.379 + COomSetup::ConstructL();
1.380 + iFailWin=RBackedUpWindow(iWs);
1.381 + User::LeaveIfError(iFailWin.Construct(iWinGroup,EGray16,55));
1.382 + User::LeaveIfError(iFailWin.SetSizeErr(TSize(10,10)));
1.383 + iFailWin.Activate();
1.384 + }
1.385 +
1.386 +/** Allocates a buffer for storing pointer movements for previously created backed-up window
1.387 +*/
1.388 +TInt COomPointerBuffer::Fail()
1.389 + {
1.390 + return(iFailWin.AllocPointerMoveBuffer(10,0));
1.391 + }
1.392 +
1.393 +void COomPointerBuffer::ClearUpL()
1.394 + {
1.395 + iFailWin.FreePointerMoveBuffer();
1.396 + }
1.397 +
1.398 +//
1.399 +
1.400 +COomPriorityKey::COomPriorityKey(CTOom *aTest) : COomSetup(aTest)
1.401 + {}
1.402 +
1.403 +COomPriorityKey::~COomPriorityKey()
1.404 + {
1.405 + }
1.406 +
1.407 +TOomTestName COomPriorityKey::TestName()
1.408 + {
1.409 + return(_L("Priority key"));
1.410 + }
1.411 +
1.412 +void COomPriorityKey::ConstructL()
1.413 + {
1.414 + COomSetup::ConstructL();
1.415 + }
1.416 +
1.417 +/** Adds a priority key for a previously created window group
1.418 +*/
1.419 +TInt COomPriorityKey::Fail()
1.420 + {
1.421 + return(iWinGroup.AddPriorityKey(1,0,0));
1.422 + }
1.423 +
1.424 +void COomPriorityKey::ClearUpL()
1.425 + {
1.426 + iWinGroup.RemovePriorityKey(1,0,0);
1.427 + }
1.428 +
1.429 +//
1.430 +
1.431 +COomCaptureKeyBase::COomCaptureKeyBase(CTOom *aTest) : COomSetup(aTest)
1.432 + {}
1.433 +
1.434 +COomCaptureKeyBase::~COomCaptureKeyBase()
1.435 + {}
1.436 +
1.437 +void COomCaptureKeyBase::ConstructL()
1.438 + {
1.439 + COomSetup::ConstructL();
1.440 + }
1.441 +
1.442 +COomCaptureKey::COomCaptureKey(CTOom *aTest) : COomCaptureKeyBase(aTest)
1.443 + {}
1.444 +
1.445 +COomCaptureKey::~COomCaptureKey()
1.446 + {
1.447 + }
1.448 +
1.449 +TOomTestName COomCaptureKey::TestName()
1.450 + {
1.451 + return(_L("Capture key"));
1.452 + }
1.453 +
1.454 +/** Requests a capture keys for a previously created window group
1.455 +*/
1.456 +TInt COomCaptureKey::Fail()
1.457 + {
1.458 + for (iIndex=0;iIndex<(TInt)(sizeof(iCapKey)/sizeof(iCapKey[0]));iIndex++)
1.459 + {
1.460 + TInt ret=iWinGroup.CaptureKey('a',0,0);
1.461 + if (ret<0)
1.462 + return(ret);
1.463 + iCapKey[iIndex]=ret;
1.464 + }
1.465 + return(KErrNone);
1.466 + }
1.467 +
1.468 +void COomCaptureKey::ClearUpL()
1.469 + {
1.470 + for (TInt index=0;index<iIndex;index++)
1.471 + iWinGroup.CancelCaptureKey(iCapKey[index]);
1.472 + }
1.473 +
1.474 +//
1.475 +
1.476 +COomCaptureKeyUpDown::COomCaptureKeyUpDown(CTOom *aTest) : COomCaptureKeyBase(aTest)
1.477 + {}
1.478 +
1.479 +COomCaptureKeyUpDown::~COomCaptureKeyUpDown()
1.480 + {
1.481 + }
1.482 +
1.483 +TOomTestName COomCaptureKeyUpDown::TestName()
1.484 + {
1.485 + return(_L("Capture up/down keys"));
1.486 + }
1.487 +
1.488 +/** Requests the capture of key-up and key-down events for a previously created window group
1.489 +*/
1.490 +TInt COomCaptureKeyUpDown::Fail()
1.491 + {
1.492 + for (iIndex=0;iIndex<(TInt)(sizeof(iCapKey)/sizeof(iCapKey[0]));iIndex++)
1.493 + {
1.494 + TInt ret=iWinGroup.CaptureKeyUpAndDowns('a',0,0);
1.495 + if (ret<0)
1.496 + return(ret);
1.497 + iCapKey[iIndex]=ret;
1.498 + }
1.499 + return(KErrNone);
1.500 + }
1.501 +
1.502 +void COomCaptureKeyUpDown::ClearUpL()
1.503 + {
1.504 + for (TInt index=0;index<iIndex;index++)
1.505 + iWinGroup.CancelCaptureKeyUpAndDowns(iCapKey[index]);
1.506 + }
1.507 +
1.508 +//
1.509 +
1.510 +COomLongKeyCapture::COomLongKeyCapture(CTOom *aTest) : COomCaptureKeyBase(aTest)
1.511 + {}
1.512 +
1.513 +COomLongKeyCapture::~COomLongKeyCapture()
1.514 + {
1.515 + }
1.516 +
1.517 +TOomTestName COomLongKeyCapture::TestName()
1.518 + {
1.519 + _LIT(KLongKeyCapTestName, "Long key capture");
1.520 + return KLongKeyCapTestName();
1.521 + }
1.522 +
1.523 +/**
1.524 +Requests capture of long key events for a previously created window group
1.525 +*/
1.526 +TInt COomLongKeyCapture::Fail()
1.527 + {
1.528 + for (iIndex=0; iIndex < KNumCapKeyRequest; iIndex++)
1.529 + {
1.530 + TInt ret=iWinGroup.CaptureLongKey(' ','a',0,0,2,ELongCaptureNormal);
1.531 + if (ret<0)
1.532 + return(ret);
1.533 + iCapKey[iIndex]=ret;
1.534 + }
1.535 + return(KErrNone);
1.536 + }
1.537 +
1.538 +void COomLongKeyCapture::ClearUpL()
1.539 + {
1.540 + for (TInt index=0;index<iIndex;index++)
1.541 + iWinGroup.CancelCaptureLongKey(iCapKey[index]);
1.542 + }
1.543 +
1.544 +//
1.545 +
1.546 +COomHotKey::COomHotKey(CTOom *aTest) : COomSetup(aTest)
1.547 + {}
1.548 +
1.549 +COomHotKey::~COomHotKey()
1.550 + {
1.551 + }
1.552 +
1.553 +TOomTestName COomHotKey::TestName()
1.554 + {
1.555 + return(_L("hot keys"));
1.556 + }
1.557 +
1.558 +void COomHotKey::ConstructL()
1.559 + {
1.560 + COomSetup::ConstructL();
1.561 + }
1.562 +
1.563 +/** Sets hot key for the session.
1.564 +*/
1.565 +TInt COomHotKey::Fail()
1.566 + {
1.567 + return(iWs.SetHotKey(EHotKeyEnableLogging,'a',0,0));
1.568 + }
1.569 +
1.570 +void COomHotKey::ClearUpL()
1.571 + {
1.572 + iWs.RestoreDefaultHotKey(EHotKeyEnableLogging);
1.573 + }
1.574 +
1.575 +//
1.576 +
1.577 +COomGroupName::COomGroupName(CTOom *aTest) : COomSetup(aTest)
1.578 + {}
1.579 +
1.580 +COomGroupName::~COomGroupName()
1.581 + {
1.582 + }
1.583 +
1.584 +TOomTestName COomGroupName::TestName()
1.585 + {
1.586 + return(_L("Group name"));
1.587 + }
1.588 +
1.589 +void COomGroupName::ConstructL()
1.590 + {
1.591 + COomSetup::ConstructL();
1.592 + }
1.593 +
1.594 +/** Sets the window group's name.
1.595 +*/
1.596 +TInt COomGroupName::Fail()
1.597 + {
1.598 + return(iWinGroup.SetName(_L("A Name")));
1.599 + }
1.600 +
1.601 +void COomGroupName::ClearUpL()
1.602 + {
1.603 + iWinGroup.SetName(_L(""));
1.604 + }
1.605 +
1.606 +//
1.607 +
1.608 +COomMessageSend::COomMessageSend(CTOom *aTest) : COomSetup(aTest)
1.609 + {}
1.610 +
1.611 +COomMessageSend::~COomMessageSend()
1.612 + {
1.613 + }
1.614 +
1.615 +TOomTestName COomMessageSend::TestName()
1.616 + {
1.617 + return(_L("MessageSend"));
1.618 + }
1.619 +
1.620 +void COomMessageSend::ConstructL()
1.621 + {
1.622 + COomSetup::ConstructL();
1.623 + }
1.624 +
1.625 +void COomMessageSend::PreFail()
1.626 + {
1.627 + iWinGroup2=RWindowGroup(iWs);
1.628 + iWinGroup2.Construct(557);
1.629 + iWinGroup2.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
1.630 + }
1.631 +
1.632 +/** Sends a message to another window group
1.633 +*/
1.634 +TInt COomMessageSend::Fail()
1.635 + {
1.636 + TBuf8<0x20> params(_L8("SomeParams"));
1.637 + return(iWs.SendMessageToWindowGroup(iWinGroup2.Identifier(),TUid::Uid(123),params));
1.638 + }
1.639 +
1.640 +void COomMessageSend::ClearUpL()
1.641 + {
1.642 + iWinGroup2.Close();
1.643 + }
1.644 +
1.645 +//
1.646 +
1.647 +COomMessageFetch::COomMessageFetch(CTOom *aTest) : COomSetup(aTest)
1.648 + {}
1.649 +
1.650 +COomMessageFetch::~COomMessageFetch()
1.651 + {
1.652 + }
1.653 +
1.654 +TOomTestName COomMessageFetch::TestName()
1.655 + {
1.656 + return(_L("MessageFetch"));
1.657 + }
1.658 +
1.659 +void COomMessageFetch::ConstructL()
1.660 + {
1.661 + COomSetup::ConstructL();
1.662 + }
1.663 +
1.664 +#define CLIENT_HANDLE 555
1.665 +#define UID_VALUE 123
1.666 +#define MESSAGE_LEN 0x20
1.667 +void COomMessageFetch::PreFail()
1.668 + {
1.669 + iWinGroup2=RWindowGroup(iWs);
1.670 + iWinGroup2.Construct(CLIENT_HANDLE);
1.671 + iWinGroup2.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
1.672 + TBuf8<MESSAGE_LEN> params(_L8("SomeParams"));
1.673 + TBool retVal = iWs.SendMessageToWindowGroup(iWinGroup2.Identifier(),TUid::Uid(UID_VALUE),params);
1.674 + iTest->TEST(retVal==KErrNone);
1.675 + if (retVal!=KErrNone)
1.676 + iTest->INFO_PRINTF3(_L("iWs.SendMessageToWindowGroup() return value - Expected: %d, Actual: %d"), KErrNone, retVal);
1.677 + }
1.678 +
1.679 +/** Fetches a message
1.680 +*/
1.681 +TInt COomMessageFetch::Fail()
1.682 + {
1.683 + TWsEvent event;
1.684 + TPtr8 ptr(NULL,0);
1.685 + TUid uid;
1.686 + event.SetType(EEventMessageReady);
1.687 + event.SetHandle(CLIENT_HANDLE);
1.688 + event.SetTimeNow();
1.689 + SEventMessageReady& eventMessageReady=*(SEventMessageReady*)event.EventData();
1.690 + eventMessageReady.iWindowGroupIdentifier=iWinGroup2.Identifier();
1.691 + eventMessageReady.iMessageUid=TUid::Uid(UID_VALUE);
1.692 + eventMessageReady.iMessageParametersSize=MESSAGE_LEN;
1.693 + TInt ret=TheClient->iWs.FetchMessage(uid,ptr,event);
1.694 + if (ret==KErrNone)
1.695 + User::Free((TAny *)ptr.Ptr());
1.696 + return(ret);
1.697 + }
1.698 +
1.699 +void COomMessageFetch::ClearUpL()
1.700 + {
1.701 + iWinGroup2.Close();
1.702 + }
1.703 +
1.704 +//
1.705 +
1.706 +COomRequestEvents::COomRequestEvents(CTOom *aTest) : COomSetup(aTest)
1.707 + {}
1.708 +
1.709 +COomRequestEvents::~COomRequestEvents()
1.710 + {
1.711 + }
1.712 +
1.713 +TOomTestName COomRequestEvents::TestName()
1.714 + {
1.715 + return(_L("Request events"));
1.716 + }
1.717 +
1.718 +void COomRequestEvents::ConstructL()
1.719 + {
1.720 + COomSetup::ConstructL();
1.721 + }
1.722 +
1.723 +/** Enables window group change events and modifier change events
1.724 +*/
1.725 +TInt COomRequestEvents::Fail()
1.726 + {
1.727 + TInt err;
1.728 + if ((err=iWinGroup.EnableOnEvents())==KErrNone)
1.729 + if ((err=iWinGroup.EnableGroupChangeEvents())==KErrNone)
1.730 + err=iWinGroup.EnableModifierChangedEvents(EModifierCapsLock,EEventControlAlways);
1.731 + return(err);
1.732 + }
1.733 +
1.734 +void COomRequestEvents::ClearUpL()
1.735 + {
1.736 + iWinGroup.DisableOnEvents();
1.737 + iWinGroup.DisableGroupChangeEvents();
1.738 + iWinGroup.DisableModifierChangedEvents();
1.739 + }
1.740 +
1.741 +//
1.742 +
1.743 +COomCopyScreen::COomCopyScreen(CTOom *aTest) : COomSetup(aTest)
1.744 + {}
1.745 +
1.746 +TOomTestName COomCopyScreen::TestName()
1.747 + {
1.748 + return(_L("Copy screen"));
1.749 + }
1.750 +
1.751 +COomCopyScreen::~COomCopyScreen()
1.752 + {
1.753 + delete iScrDev;
1.754 + delete iBitmap;
1.755 + }
1.756 +
1.757 +void COomCopyScreen::ConstructL()
1.758 + {
1.759 + COomSetup::ConstructL();
1.760 + iScrDev=new(ELeave) CWsScreenDevice(iWs);
1.761 + User::LeaveIfError(iScrDev->Construct(iTest->ScreenNumber()));
1.762 + iBitmap=new(ELeave) CFbsBitmap();
1.763 + User::LeaveIfError(iBitmap->Create(TSize(100,100),EGray4));
1.764 + }
1.765 +
1.766 +/** Copies screen to bitmap
1.767 +*/
1.768 +TInt COomCopyScreen::Fail()
1.769 + {
1.770 + TInt ret=iScrDev->CopyScreenToBitmap(iBitmap);
1.771 + if (ret==KErrNone)
1.772 + ret=iScrDev->CopyScreenToBitmap(iBitmap,TRect(10,10,50,50));
1.773 + return(ret);
1.774 + }
1.775 +
1.776 +void COomCopyScreen::ClearUpL()
1.777 + {
1.778 + }
1.779 +
1.780 +//
1.781 +
1.782 +COomSpriteBase::COomSpriteBase(CTOom *aTest) : COomSetup(aTest)
1.783 + {}
1.784 +
1.785 +COomSpriteBase::~COomSpriteBase()
1.786 + {
1.787 + iWin.Close();
1.788 + delete iBitmap;
1.789 + delete iMask;
1.790 + delete iBitmap2;
1.791 + delete iMask2;
1.792 + }
1.793 +
1.794 +void COomSpriteBase::ConstructL()
1.795 + {
1.796 + COomSetup::ConstructL();
1.797 + iWin=RWindow(iWs);
1.798 + User::LeaveIfError(iWin.Construct(iWinGroup,33));
1.799 + User::LeaveIfError(iWin.SetSizeErr(TSize(100,100)));
1.800 + iWin.Activate();
1.801 + iBitmap=new(ELeave) CFbsBitmap();
1.802 + User::LeaveIfError(iBitmap->Create(TSize(10,10),EGray4));
1.803 + iBitmap2=new(ELeave) CFbsBitmap();
1.804 + User::LeaveIfError(iBitmap2->Create(TSize(40,40),EGray4));
1.805 + iMask=new(ELeave) CFbsBitmap();
1.806 + User::LeaveIfError(iMask->Create(TSize(10,10),EGray4));
1.807 + iMask2=new(ELeave) CFbsBitmap();
1.808 + User::LeaveIfError(iMask2->Create(TSize(40,40),EGray4));
1.809 + }
1.810 +
1.811 +//
1.812 +
1.813 +COomSprite::COomSprite(CTOom *aTest) : COomSpriteBase(aTest)
1.814 + {}
1.815 +
1.816 +TOomTestName COomSprite::TestName()
1.817 + {
1.818 + return(_L("Sprites"));
1.819 + }
1.820 +
1.821 +/** Creates a sprite.
1.822 +*/
1.823 +TInt COomSprite::Fail()
1.824 + {
1.825 + iSprite=RWsSprite(iWs);
1.826 + TInt err=iSprite.Construct(iWin,TPoint(10,10),0);
1.827 + if (err==KErrNone)
1.828 + {
1.829 + TSpriteMember sprite;
1.830 + sprite.iBitmap=iBitmap;
1.831 + sprite.iMaskBitmap=iMask;
1.832 + sprite.iInvertMask=EFalse;
1.833 + sprite.iDrawMode=CGraphicsContext::EDrawModePEN;
1.834 + sprite.iOffset=TPoint(0,0);
1.835 + sprite.iInterval=TTimeIntervalMicroSeconds32(100000);
1.836 + if ((err=iSprite.AppendMember(sprite))==KErrNone)
1.837 + if ((err=iSprite.Activate())==KErrNone)
1.838 + {
1.839 + sprite.iBitmap=iBitmap2; // Bigger bitmap to force resize of bitmap
1.840 + sprite.iMaskBitmap=iMask2;
1.841 + if ((err=iSprite.AppendMember(sprite))==KErrNone)
1.842 + err=iSprite.UpdateMember(1,sprite);
1.843 + }
1.844 + }
1.845 + return(err);
1.846 + }
1.847 +
1.848 +void COomSprite::ClearUpL()
1.849 + {
1.850 + iSprite.Close();
1.851 + }
1.852 +
1.853 +//
1.854 +
1.855 +COomPointerCursor::COomPointerCursor(CTOom *aTest) : COomSpriteBase(aTest)
1.856 + {}
1.857 +
1.858 +TOomTestName COomPointerCursor::TestName()
1.859 + {
1.860 + return(_L("Pointer cursor"));
1.861 + }
1.862 +
1.863 +/** Creates a pointer cursor.
1.864 +*/
1.865 +TInt COomPointerCursor::Fail()
1.866 + {
1.867 + iPointerCursor=RWsPointerCursor(iWs);
1.868 + TInt err=iPointerCursor.Construct(0);
1.869 + if (err==KErrNone)
1.870 + {
1.871 + TSpriteMember sprite;
1.872 + sprite.iBitmap=iBitmap;
1.873 + sprite.iMaskBitmap=iMask;
1.874 + sprite.iInvertMask=EFalse;
1.875 + sprite.iDrawMode=CGraphicsContext::EDrawModePEN;
1.876 + sprite.iOffset=TPoint(0,0);
1.877 + sprite.iInterval=TTimeIntervalMicroSeconds32(100000);
1.878 + if ((err=iPointerCursor.AppendMember(sprite))==KErrNone)
1.879 + if ((err=iPointerCursor.Activate())==KErrNone)
1.880 + {
1.881 + sprite.iBitmap=iBitmap2; // Bigger bitmap to force resize of bitmap
1.882 + sprite.iMaskBitmap=iMask2;
1.883 + if ((err=iPointerCursor.AppendMember(sprite))==KErrNone)
1.884 + err=iPointerCursor.UpdateMember(1,sprite);
1.885 + }
1.886 + }
1.887 + return(err);
1.888 + }
1.889 +
1.890 +void COomPointerCursor::ClearUpL()
1.891 + {
1.892 + iPointerCursor.Close();
1.893 + }
1.894 +
1.895 +//
1.896 +
1.897 +COomGc::COomGc(CTOom *aTest) : COomSetup(aTest)
1.898 + {}
1.899 +
1.900 +COomGc::~COomGc()
1.901 + {
1.902 + delete iScrDev;
1.903 + }
1.904 +
1.905 +TOomTestName COomGc::TestName()
1.906 + {
1.907 + return(_L("Graphic Context"));
1.908 + }
1.909 +
1.910 +void COomGc::ConstructL()
1.911 + {
1.912 + COomSetup::ConstructL();
1.913 + iScrDev=new(ELeave) CWsScreenDevice(iWs);
1.914 + User::LeaveIfError(iScrDev->Construct(iTest->ScreenNumber()));
1.915 + }
1.916 +
1.917 +/** Creates a graphical context for a previously created screen device.
1.918 +*/
1.919 +TInt COomGc::Fail()
1.920 + {
1.921 + TRAPD(err,iFailGc=new(ELeave) CWindowGc(iScrDev));
1.922 + if (err!=KErrNone)
1.923 + return(err);
1.924 + return(iFailGc->Construct());
1.925 + }
1.926 +
1.927 +void COomGc::ClearUpL()
1.928 + {
1.929 + delete iFailGc;
1.930 + iFailGc=NULL;
1.931 + }
1.932 +
1.933 +//
1.934 +
1.935 +COomPolygon::COomPolygon(CTOom *aTest) : COomSetup(aTest), iPnts(5)
1.936 + {}
1.937 +
1.938 +COomPolygon::~COomPolygon()
1.939 + {
1.940 + delete iGc;
1.941 + delete iScrDev;
1.942 + iWin.Close();
1.943 + }
1.944 +
1.945 +TOomTestName COomPolygon::TestName()
1.946 + {
1.947 + return(_L("Polygon"));
1.948 + }
1.949 +
1.950 +void COomPolygon::ConstructL()
1.951 + {
1.952 + COomSetup::ConstructL();
1.953 + iScrDev=new(ELeave) CWsScreenDevice(iWs);
1.954 + User::LeaveIfError(iScrDev->Construct(iTest->ScreenNumber()));
1.955 + User::LeaveIfError(iScrDev->CreateContext(iGc));
1.956 + iWin=RBackedUpWindow(iWs);
1.957 + User::LeaveIfError(iWin.Construct(iWinGroup,EGray16,33));
1.958 + User::LeaveIfError(iWin.SetSizeErr(TSize(40,40)));
1.959 + iWin.Activate();
1.960 + TInt index;
1.961 + for(index=0;index<20;index+=2)
1.962 + iPnts.AppendL(TPoint(20+index,index));
1.963 + for(index=0;index<20;index+=2)
1.964 + iPnts.AppendL(TPoint(40-index,20+index));
1.965 + for(index=0;index<20;index+=2)
1.966 + iPnts.AppendL(TPoint(20-index,40-index));
1.967 + for(index=0;index<20;index+=2)
1.968 + iPnts.AppendL(TPoint(index,20-index));
1.969 + }
1.970 +
1.971 +/** Draws a polygon.
1.972 +*/
1.973 +TInt COomPolygon::Fail()
1.974 + {
1.975 + iGc->Activate(iWin);
1.976 + iGc->Clear();
1.977 + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1.978 + iGc->SetBrushColor(TRgb::Gray4(2));
1.979 + iGc->SetPenColor(TRgb::Gray4(0));
1.980 + TInt err=iGc->DrawPolygon(&iPnts,CGraphicsContext::EAlternate);
1.981 + if (err!=KErrNone)
1.982 + return(err);
1.983 + err=iGc->DrawPolygon(&iPnts,CGraphicsContext::EWinding);
1.984 + if (err!=KErrNone)
1.985 + return(err);
1.986 + return(KErrNone);
1.987 + }
1.988 +
1.989 +void COomPolygon::ClearUpL()
1.990 + {
1.991 + iGc->Deactivate();
1.992 + }
1.993 +
1.994 +//
1.995 +
1.996 +COomScreenDevice::COomScreenDevice(CTOom *aTest) : COomSetup(aTest)
1.997 + {}
1.998 +
1.999 +TOomTestName COomScreenDevice::TestName()
1.1000 + {
1.1001 + return(_L("Screen device"));
1.1002 + }
1.1003 +
1.1004 +/** Creates a screen device handle.
1.1005 +*/
1.1006 +TInt COomScreenDevice::Fail()
1.1007 + {
1.1008 + TRAPD(err,iScrDev=new(ELeave) CWsScreenDevice(iWs));
1.1009 + if (err!=KErrNone)
1.1010 + return(err);
1.1011 + return(iScrDev->Construct(iTest->ScreenNumber()));
1.1012 + }
1.1013 +
1.1014 +void COomScreenDevice::ClearUpL()
1.1015 + {
1.1016 + delete iScrDev;
1.1017 + iScrDev=NULL;
1.1018 + }
1.1019 +
1.1020 +//
1.1021 +
1.1022 +COomCustomTextCursor::COomCustomTextCursor(CTOom *aTest) : COomSetup(aTest)
1.1023 + {}
1.1024 +
1.1025 +COomCustomTextCursor::~COomCustomTextCursor()
1.1026 + {
1.1027 + delete iMemberArray;
1.1028 + delete iBitmap;
1.1029 + }
1.1030 +
1.1031 +TOomTestName COomCustomTextCursor::TestName()
1.1032 + {
1.1033 + return(_L("Custom Text Cursor"));
1.1034 + }
1.1035 +
1.1036 +void COomCustomTextCursor::ConstructL()
1.1037 + {
1.1038 + COomSetup::ConstructL();
1.1039 +
1.1040 + iBitmap = new(ELeave) CFbsBitmap;
1.1041 + User::LeaveIfError(iBitmap->Load(TEST_BITMAP_NAME, EMbmWsautotestBmp1));
1.1042 +
1.1043 + TSpriteMember member;
1.1044 + member.iMaskBitmap=NULL;
1.1045 + member.iInvertMask=EFalse;
1.1046 + member.iDrawMode=CGraphicsContext::EDrawModePEN;
1.1047 + member.iOffset=TPoint();
1.1048 + member.iInterval=TTimeIntervalMicroSeconds32(0);
1.1049 + member.iBitmap = iBitmap;
1.1050 +
1.1051 + iMemberArray = new(ELeave) CArrayFixFlat<TSpriteMember>(1);
1.1052 + iMemberArray->AppendL(member);
1.1053 + }
1.1054 +
1.1055 +/** Adds a custom text cursor to the server's list of cursors.
1.1056 +*/
1.1057 +TInt COomCustomTextCursor::Fail()
1.1058 + {
1.1059 + TInt err = TheClient->iWs.SetCustomTextCursor(0x98765432, iMemberArray->Array(), 0, RWsSession::ECustomTextCursorAlignTop);
1.1060 + if (err == KErrAlreadyExists)
1.1061 + return KErrNone;
1.1062 + else
1.1063 + return err;
1.1064 + }
1.1065 +
1.1066 +void COomCustomTextCursor::ClearUpL()
1.1067 + {
1.1068 + }
1.1069 +
1.1070 +COomTranspWindow::COomTranspWindow(CTOom *aTest) : COomSetup(aTest)
1.1071 + {}
1.1072 +
1.1073 +COomTranspWindow::~COomTranspWindow()
1.1074 + {
1.1075 + delete iBackgroundWin;
1.1076 + delete iFirst;
1.1077 + delete iSecond;
1.1078 +
1.1079 + delete iFbsBitmap;
1.1080 + delete iWsBitmap;
1.1081 + delete iFbsBitmapDevice;
1.1082 + delete iFbsBitmapGc;
1.1083 + delete iWsBitmapDevice;
1.1084 + delete iWsBitmapGc;
1.1085 + }
1.1086 +
1.1087 +TOomTestName COomTranspWindow::TestName()
1.1088 + {
1.1089 + return(_L("Transparent Window"));
1.1090 + }
1.1091 +
1.1092 +void COomTranspWindow::ConstructL()
1.1093 + {
1.1094 + COomSetup::ConstructL();
1.1095 +
1.1096 + iTransparencyEnabled = (TransparencySupportedL() == KErrNone);
1.1097 + if(!iTransparencyEnabled)
1.1098 + return;
1.1099 +
1.1100 + iFbsBitmap = new (ELeave) CFbsBitmap;
1.1101 +
1.1102 + // Do the creation
1.1103 + const TSize KSizeForBitmap(10,10);
1.1104 + iFbsBitmap->Create(KSizeForBitmap,EGray256);
1.1105 +
1.1106 + // Fill the bitmap with a colour
1.1107 + iFbsBitmapDevice=CFbsBitmapDevice::NewL(iFbsBitmap);
1.1108 +
1.1109 + iFbsBitmapDevice->CreateContext(iFbsBitmapGc);
1.1110 +
1.1111 + iFbsBitmapGc->SetPenStyle(CGraphicsContext::ENullPen);
1.1112 + iFbsBitmapGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1.1113 + iFbsBitmapGc->SetBrushColor(128);
1.1114 + iFbsBitmapGc->DrawRect(TRect(KSizeForBitmap));
1.1115 +
1.1116 + // Create a CWsBitmap, and fill it with a colour
1.1117 + iWsBitmap = new (ELeave) CWsBitmap(TheClient->iWs);
1.1118 +
1.1119 + // Do the creation
1.1120 + iWsBitmap->Create(KSizeForBitmap,EGray256);
1.1121 +
1.1122 + // Fill the bitmap with a colour
1.1123 + iWsBitmapDevice=CFbsBitmapDevice::NewL(iWsBitmap);
1.1124 +
1.1125 + iWsBitmapDevice->CreateContext(iWsBitmapGc);
1.1126 + iWsBitmapGc->SetPenStyle(CGraphicsContext::ENullPen);
1.1127 + iWsBitmapGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1.1128 + iWsBitmapGc->SetBrushColor(128);
1.1129 + iWsBitmapGc->DrawRect(TRect(KSizeForBitmap));
1.1130 + }
1.1131 +
1.1132 +
1.1133 +/** Does nothing if transparency is not enabled. Creates a blank window with
1.1134 +* two transparent child-windows. Tests setting the transparency via a factor, CFbsBitmap
1.1135 +* or a CWsBitmap, and changing from one to the other.
1.1136 +* Changes child-windows' sizes and toggles their visibility.
1.1137 +*/
1.1138 +TInt COomTranspWindow::Fail()
1.1139 + {
1.1140 + if(!iTransparencyEnabled)
1.1141 + return KErrNone;
1.1142 + TSize scrSize(TheClient->iScreen->SizeInPixels());
1.1143 + TRAPD(res, iBackgroundWin = new (ELeave) CBlankWindow(TRgb(0,0,238)));
1.1144 + if(res != KErrNone)
1.1145 + {
1.1146 + return res;
1.1147 + }
1.1148 +
1.1149 + TDisplayMode mode=EColor256;
1.1150 + TRAP(res, iBackgroundWin->SetUpL(TPoint(50,50),scrSize-TSize(100,100),TheClient->iGroup,*TheClient->iGc,&mode));
1.1151 + if(res != KErrNone)
1.1152 + {
1.1153 + return res;
1.1154 + }
1.1155 +
1.1156 + TheClient->Flush();
1.1157 + TheClient->WaitForRedrawsToFinish();
1.1158 +
1.1159 + iBackgroundWin->Win()->SetBackgroundColor(TRgb(51,204,51));
1.1160 + iBackgroundWin->Invalidate();
1.1161 +
1.1162 + TheClient->Flush();
1.1163 + TheClient->WaitForRedrawsToFinish();
1.1164 +
1.1165 + TRect thePos1(20, 20, 60, 60);
1.1166 + TRect thePos2(100, 40, 160, 80);
1.1167 + TRAP(res, iFirst = CTransWindow::NewL(iBackgroundWin, TRgb(255,0,0,128),&mode));
1.1168 + if(res != KErrNone)
1.1169 + {
1.1170 + return res;
1.1171 + }
1.1172 +
1.1173 + TRAP(res, iSecond = CTransWindow::NewL(iBackgroundWin, TRgb(255,0,0,128),&mode));
1.1174 + if(res != KErrNone)
1.1175 + {
1.1176 + return res;
1.1177 + }
1.1178 +
1.1179 + TRAP(res, iFirst->SetExtL(thePos1.iTl,thePos1.Size()));
1.1180 + if(res != KErrNone)
1.1181 + {
1.1182 + return res;
1.1183 + }
1.1184 +
1.1185 + TRAP(res, iSecond->SetExtL(thePos2.iTl,thePos2.Size()));
1.1186 + if(res != KErrNone)
1.1187 + {
1.1188 + return res;
1.1189 + }
1.1190 +
1.1191 + res=SetTransparencyTesting();
1.1192 + if(res != KErrNone)
1.1193 + {
1.1194 + return res;
1.1195 + }
1.1196 +
1.1197 + TheClient->Flush();
1.1198 + //TheClient->WaitForRedrawsToFinish();
1.1199 +
1.1200 + iFirst->Activate();
1.1201 + iFirst->AssignGC(*TheClient->iGc);
1.1202 +
1.1203 + iSecond->Activate();
1.1204 + iSecond->AssignGC(*TheClient->iGc);
1.1205 +
1.1206 + iFirst->Win()->SetBackgroundColor(TRgb(0, 0, 255));
1.1207 + iSecond->Win()->SetBackgroundColor(TRgb(0, 0, 255));
1.1208 + iFirst->Invalidate();
1.1209 + iSecond->Invalidate();
1.1210 +
1.1211 + iFirst->AdjustSize(150,10, 0);
1.1212 + iSecond->AdjustSize(150,10, 0);
1.1213 +
1.1214 + TheClient->Flush();
1.1215 + TheClient->WaitForRedrawsToFinish();
1.1216 +
1.1217 + iFirst->ToggleVisibility();
1.1218 + iSecond->ToggleVisibility();
1.1219 +
1.1220 + TheClient->Flush();
1.1221 + TheClient->WaitForRedrawsToFinish();
1.1222 +
1.1223 + iFirst->AdjustSize(200,10, 0);
1.1224 + iSecond->AdjustSize(200,10, 0);
1.1225 +
1.1226 + iFirst->ToggleVisibility();
1.1227 + iSecond->ToggleVisibility();
1.1228 +
1.1229 + TheClient->Flush();
1.1230 + TheClient->WaitForRedrawsToFinish();
1.1231 +
1.1232 + return KErrNone;
1.1233 + }
1.1234 +
1.1235 +
1.1236 +// This function tests setting the transparency via a factor, CFbsBitmap
1.1237 +// or a CWsBitmap, and changing from one to the other.
1.1238 +TInt COomTranspWindow::SetTransparencyTesting()
1.1239 + {
1.1240 + TInt res;
1.1241 + TLogMessageText buf;
1.1242 +
1.1243 + // Need all nine transitions, from the 3 ways to the same 3 ways.
1.1244 + // The ways are Factor, CWsBitmap, CFbsBitmap
1.1245 + const TRgb KTransparencyFactor(128,128,128);
1.1246 + res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor);
1.1247 + if (res!=KErrNone)
1.1248 + {
1.1249 + buf=_L("test failure!! with SetTransparencyFactor -1");
1.1250 + TheClient->LogMessage(buf);
1.1251 + return res;
1.1252 + }
1.1253 +
1.1254 + res=iFirst->Win()->SetTransparencyBitmap(*iFbsBitmap);
1.1255 + if (res!=KErrNone)
1.1256 + {
1.1257 + buf=_L("test failure!! with SetTransparencyBitmap - fbs -2");
1.1258 + TheClient->LogMessage(buf);
1.1259 + return res;
1.1260 + }
1.1261 +
1.1262 + res=iFirst->Win()->SetTransparencyWsBitmap(*iWsBitmap);
1.1263 + if (res!=KErrNone)
1.1264 + {
1.1265 + buf=_L("test failure!! with SetTransparencyBitmap - Ws -3");
1.1266 + TheClient->LogMessage(buf);
1.1267 + return res;
1.1268 + }
1.1269 +
1.1270 + res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor);
1.1271 + if (res!=KErrNone)
1.1272 + {
1.1273 + buf=_L("test failure!! with SetTransparencyBitmap - fbs -4");
1.1274 + TheClient->LogMessage(buf);
1.1275 + return res;
1.1276 + }
1.1277 + res=iFirst->Win()->SetTransparencyWsBitmap(*iWsBitmap);
1.1278 + if (res!=KErrNone)
1.1279 + {
1.1280 + buf=_L("test failure!! with SetTransparencyBitmap - Ws -5");
1.1281 + TheClient->LogMessage(buf);
1.1282 + return res;
1.1283 + }
1.1284 + res=iFirst->Win()->SetTransparencyWsBitmap(*iWsBitmap);
1.1285 + if (res!=KErrNone)
1.1286 + {
1.1287 + buf=_L("test failure!! with SetTransparencyBitmap - Ws -6");
1.1288 + TheClient->LogMessage(buf);
1.1289 + return res;
1.1290 + }
1.1291 +
1.1292 + res=iFirst->Win()->SetTransparencyBitmap(*iFbsBitmap);
1.1293 + if (res!=KErrNone)
1.1294 + {
1.1295 + buf=_L("test failure!! with SetTransparencyBitmap - fbs -7");
1.1296 + TheClient->LogMessage(buf);
1.1297 + return res;
1.1298 + }
1.1299 +
1.1300 + res=iFirst->Win()->SetTransparencyBitmap(*iFbsBitmap);
1.1301 + if (res!=KErrNone)
1.1302 + {
1.1303 + buf=_L("test failure!! with SetTransparencyBitmap - fbs -8");
1.1304 + TheClient->LogMessage(buf);
1.1305 + return res;
1.1306 + }
1.1307 +
1.1308 + res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor);
1.1309 + if (res!=KErrNone)
1.1310 + {
1.1311 + buf=_L("test failure!! with SetTransparencyFactor -9");
1.1312 + TheClient->LogMessage(buf);
1.1313 + return res;
1.1314 + }
1.1315 +
1.1316 + res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor);
1.1317 + if (res!=KErrNone)
1.1318 + {
1.1319 + buf=_L("test failure!! with SetTransparencyFactor -10");
1.1320 + TheClient->LogMessage(buf);
1.1321 + return res;
1.1322 + }
1.1323 +
1.1324 + return res;
1.1325 + }
1.1326 +
1.1327 +void COomTranspWindow::ClearUpL()
1.1328 + {
1.1329 + delete iFirst;
1.1330 + iFirst = NULL;
1.1331 + delete iSecond;
1.1332 + iSecond = NULL;
1.1333 + delete iBackgroundWin;
1.1334 + iBackgroundWin = NULL;
1.1335 + }
1.1336 +
1.1337 +//
1.1338 +
1.1339 +CWindowWithOneLine* CWindowWithOneLine::NewL(CTWinBase& aParent, const TRect& aExtent)
1.1340 + {
1.1341 + CWindowWithOneLine* self = new(ELeave) CWindowWithOneLine;
1.1342 + CleanupStack::PushL(self);
1.1343 + self->ConstructL(aParent);
1.1344 + const TSize screenSize(TheClient->iScreen->SizeInPixels());
1.1345 + self->SetExtL(aExtent.iTl, aExtent.Size());
1.1346 + self->AssignGC(*TheClient->iGc);
1.1347 + self->Activate();
1.1348 + self->DrawNow();
1.1349 + CleanupStack::Pop(self);
1.1350 + return self;
1.1351 + }
1.1352 +
1.1353 +void CWindowWithOneLine::Draw()
1.1354 + {
1.1355 + iGc->DrawLine(TPoint(0,0), TPoint(Size().iWidth, Size().iHeight));
1.1356 + }
1.1357 +
1.1358 +//
1.1359 +
1.1360 +COomObscuredWindow::COomObscuredWindow(CTOom *aTest) : COomSetup(aTest)
1.1361 + {}
1.1362 +
1.1363 +TOomTestName COomObscuredWindow::TestName()
1.1364 + {
1.1365 + return(_L("Obscured window"));
1.1366 + }
1.1367 +
1.1368 +TInt COomObscuredWindow::Fail()
1.1369 + {
1.1370 + TRAPD(err, DoFailL());
1.1371 + return err;
1.1372 + }
1.1373 +
1.1374 +
1.1375 +void COomObscuredWindow::DoFailL()
1.1376 + {
1.1377 +#ifdef __WINS__
1.1378 + RDebug::Print(_L("COomObscuredWindow::DoFailL - enter"));
1.1379 +#endif
1.1380 + const TRect extent(20, 20, 100, 100);
1.1381 + CBlankWindow* backgroundWindow = new(ELeave) CBlankWindow(TRgb(12, 23, 34));
1.1382 + CleanupStack::PushL(backgroundWindow);
1.1383 + TDisplayMode mode = EColor16MAP;
1.1384 + backgroundWindow->SetUpL(extent.iTl, extent.Size(), TheClient->iGroup, *TheClient->iGc, &mode);
1.1385 +
1.1386 + CWindowWithOneLine* window = CWindowWithOneLine::NewL(*backgroundWindow, extent);
1.1387 + CleanupStack::PushL(window);
1.1388 +#ifdef __WINS__
1.1389 + RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 1"));
1.1390 +#endif
1.1391 + TheClient->WaitForRedrawsToFinish();
1.1392 +
1.1393 + CBlankWindow* obscuringWindow = new(ELeave) CBlankWindow(TRgb(255, 0, 0));
1.1394 + CleanupStack::PushL(obscuringWindow);
1.1395 + obscuringWindow->SetUpL(extent.iTl, extent.Size(), backgroundWindow, *TheClient->iGc, &mode);
1.1396 +
1.1397 + TheClient->Flush();
1.1398 +#ifdef __WINS__
1.1399 + RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 2"));
1.1400 +#endif
1.1401 + TheClient->WaitForRedrawsToFinish();
1.1402 +
1.1403 + window->Invalidate();
1.1404 +
1.1405 + for(TInt i = 0; i < 50; i++)
1.1406 + {
1.1407 + RWindow anotherWin(iWs);
1.1408 + User::LeaveIfError(anotherWin.Construct(iWinGroup, 11));
1.1409 + anotherWin.Close();
1.1410 +
1.1411 + if(i % 4)
1.1412 + window->Invalidate();
1.1413 +
1.1414 + TheClient->Flush();
1.1415 +#ifdef __WINS__
1.1416 + RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 3 - %d"), i);
1.1417 +#endif
1.1418 + TheClient->WaitForRedrawsToFinish();
1.1419 + }
1.1420 +
1.1421 + TheClient->Flush();
1.1422 +#ifdef __WINS__
1.1423 + RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 4"));
1.1424 +#endif
1.1425 + TheClient->WaitForRedrawsToFinish();
1.1426 +
1.1427 + CleanupStack::PopAndDestroy(obscuringWindow);
1.1428 + CleanupStack::PopAndDestroy(window);
1.1429 + CleanupStack::PopAndDestroy(backgroundWindow);
1.1430 +#ifdef __WINS__
1.1431 + RDebug::Print(_L("COomObscuredWindow::DoFailL - exit"));
1.1432 +#endif
1.1433 + }
1.1434 +
1.1435 +void COomObscuredWindow::ClearUpL()
1.1436 + {
1.1437 + }
1.1438 +
1.1439 +//
1.1440 +
1.1441 +CTOom::CTOom(CTestStep* aStep) : CTWsGraphicsBase(aStep)
1.1442 + {
1.1443 + iState = 0;
1.1444 + }
1.1445 +
1.1446 +const TDesC& CTOom::TestName() const
1.1447 + {
1.1448 + _LIT(KTestName,"CTOom");
1.1449 + return(KTestName());
1.1450 + }
1.1451 +
1.1452 +void CTOom::DoOomTestL(COomFailBase *aOomTest)
1.1453 + {
1.1454 + //TLogMessageText buf;
1.1455 + TEST(aOomTest!=NULL);
1.1456 + if (aOomTest==NULL)
1.1457 + INFO_PRINTF1(_L("aOomTest - Expected: Not Null, Actual: NULL"));
1.1458 +
1.1459 + TRAPD(ret1,aOomTest->ConstructL());
1.1460 + TEST(ret1==KErrNone);
1.1461 + if (ret1!=KErrNone)
1.1462 + INFO_PRINTF3(_L("aOomTest->ConstructL() return value - Expected: %d, Actual: %d"), KErrNone, ret1);
1.1463 +
1.1464 + aOomTest->Flush();
1.1465 + __UHEAP_MARK;
1.1466 +// TInt oldCount=TheClient->iWs.HeapCount();
1.1467 + for(TInt mode=0;mode<3;mode++)
1.1468 + {
1.1469 + /*buf.Format(_L("OOMTest[%d] Mode=%d"),iState,mode),
1.1470 + TheClient->LogMessage(buf);*/
1.1471 + TInt successCount=0;
1.1472 + for(TInt count=1;;count++)
1.1473 + {
1.1474 + TInt ret;
1.1475 + aOomTest->PreFail();
1.1476 + if (mode==0)
1.1477 + TheClient->iWs.HeapSetFail(RHeap::EDeterministic,count);
1.1478 + else if (mode==1)
1.1479 + TheClient->iWs.HeapSetBurstFail(RHeap::EBurstFailNext, count, KMaxTUint16);
1.1480 + else if (mode==3)
1.1481 + {
1.1482 + __UHEAP_SETFAIL(RHeap::EDeterministic,count); //Leavescan will complain about EFailNext, although it isn't a leaving function
1.1483 + }
1.1484 + ret=aOomTest->Fail();
1.1485 + if (mode==0)
1.1486 + TheClient->iWs.HeapSetFail(RHeap::ENone,0);
1.1487 + else if (mode==1)
1.1488 + TheClient->iWs.HeapSetBurstFail(RHeap::ENone, 0, 0);
1.1489 + else if (mode==2)
1.1490 + {
1.1491 + __UHEAP_RESET;
1.1492 + }
1.1493 + aOomTest->ClearUpL(); //In just 1 case this could leave...
1.1494 + aOomTest->Flush();
1.1495 + if (ret==KErrNone)
1.1496 + {
1.1497 + if (successCount==10)
1.1498 + break;
1.1499 + successCount++;
1.1500 + }
1.1501 + else
1.1502 + {
1.1503 + /*if (successCount>0)
1.1504 + {
1.1505 + buf.Format(_L("[%d,%d] Count=%d, MaxSuccess=%d"),iState,mode,count,successCount);
1.1506 + TheClient->LogMessage(buf);
1.1507 + }*/
1.1508 + successCount=0;
1.1509 + /*if (ret!=KErrNoMemory)
1.1510 + {
1.1511 + buf.Format(_L("[%d,%d] Fail, Count=%d, Error=%d"),iState,mode,count,ret);
1.1512 + TheClient->LogMessage(buf);
1.1513 + }*/
1.1514 + TEST(ret==KErrNoMemory);
1.1515 + if (ret!=KErrNoMemory)
1.1516 + INFO_PRINTF3(_L("aOomTest->Fail() return value - Expected: %d, Actual: %d"), KErrNoMemory, ret);
1.1517 +
1.1518 + }
1.1519 + }
1.1520 + /*buf.Format(_L("[%d,%d] LastCount=%d"),iState,mode,count),
1.1521 + TheClient->LogMessage(buf);*/
1.1522 + }
1.1523 +// TEST(oldCount>=TheClient->iWs.HeapCount());
1.1524 + __UHEAP_MARKEND;
1.1525 + delete aOomTest;
1.1526 + /*buf.Format(_L("OOMTest[%d] Finished"),iState);
1.1527 + TheClient->LogMessage(buf);*/
1.1528 + }
1.1529 +
1.1530 +void CTOom::ConstructL()
1.1531 + {
1.1532 + iShieldWin=RBlankWindow(TheClient->iWs);
1.1533 + User::LeaveIfError(iShieldWin.Construct(*(TheClient->iGroup->GroupWin()),1));
1.1534 +// iShieldWin.SetOrdinalPosition(0,-1);
1.1535 + iShieldWin.Activate();
1.1536 + }
1.1537 +
1.1538 +CTOom::~CTOom()
1.1539 + {
1.1540 + iShieldWin.Close();
1.1541 + }
1.1542 +
1.1543 +/**
1.1544 +@SYMTestCaseID GRAPHICS-WSERV-0124
1.1545 +
1.1546 +@SYMDEF DEF081259
1.1547 +
1.1548 +@SYMTestCaseDesc Out of memory tests
1.1549 +
1.1550 +@SYMTestPriority High
1.1551 +
1.1552 +@SYMTestStatus Implemented
1.1553 +
1.1554 +@SYMTestActions Uses deterministic heap failure mode to test WSERV classes against out-of-memory errors.
1.1555 + Sets and unsets deterministic mode using both RWsSession.HeapSetFail() methods and
1.1556 + __UHEAP_SETFAIL/__UHEAP_RESET macros (doing this both client and WSERV threads are tested).
1.1557 + On each step the test creates a failure object and repeatedly asks it to do some work (calling Fail() method).
1.1558 + A failure object is an object which encapsulates some allocation functionality inside it's Fail() method.
1.1559 + The test is performed for 23 different failure objects that do the following:
1.1560 + 1. Creates a wserv session, connects and creates CWsScreenDevice object.
1.1561 + 2. Creates a RWindowGroup object.
1.1562 + 3. Creates a RWindow object.
1.1563 + 4. Creates a RBackedUpWindow object.
1.1564 + 5. Sets the size of previously created backed-up window.
1.1565 + 6. Creates a RBlankWindow object.
1.1566 + 7. Allocates a buffer for storing pointer movements for a previously created backed-up window.
1.1567 + 8. Adds a priority key for a previously created window group.
1.1568 + 9. Requests a capture keys for a previously created window group.
1.1569 + 10. Requests the capture of key-up and key-down events for a previously created window group.
1.1570 + 11. Sets hot key for the session.
1.1571 + 12. Sets the window group's name.
1.1572 + 13. Sends a message to another window group.
1.1573 + 14. Fetches a message.
1.1574 + 15. Enables window group change events and modifier change events.
1.1575 + 16. Copies screen to bitmap.
1.1576 + 17. Creates a sprite.
1.1577 + 18. Creates a pointer cursor.
1.1578 + 19. Creates a graphical context for a previously created screen device.
1.1579 + 20. Draws a polygon.
1.1580 + 21. Creates a screen device handle.
1.1581 + 22. Adds a custom text cursor to the server's list of cursors.
1.1582 + 23. Does nothing if transparency is not enabled. Creates a blank window with
1.1583 + two transparent child-windows. Tests setting the transparency via a factor, CFbsBitmap
1.1584 + or a CWsBitmap, and changing from one to the other.
1.1585 + Changes child-windows' sizes and toggles their visibility.
1.1586 +
1.1587 +
1.1588 +@SYMTestExpectedResults The test checks that the creation failure objects doesn't fail and their's work either causes no errors or causes KErrNoMemory error.
1.1589 +*/
1.1590 +void CTOom::RunTestCaseL(TInt /*aCurTestCase*/)
1.1591 + {
1.1592 + ((CTOomStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0124"));
1.1593 + if (iState==0)
1.1594 + {
1.1595 + // commented by Anton Golovko, 01.03.2006 while converting to TEF
1.1596 + // the code below prevented the test to do anything.
1.1597 +// if (iTest->IsFullRomL())
1.1598 +// {
1.1599 +// TestComplete();
1.1600 +// return;
1.1601 +// }
1.1602 + iOldCount=TheClient->iWs.HeapCount();
1.1603 + }
1.1604 + else if (iState==sizeof(CreateOomFailTest)/sizeof(CreateOomFailTest[0]))
1.1605 + {
1.1606 + iTest->CloseAllPanicWindows();
1.1607 + TInt heapCount=TheClient->iWs.HeapCount();
1.1608 + if (heapCount>iOldCount)
1.1609 + {
1.1610 + TEST(iOldCount>=heapCount-184); //For some uninvestigated reason 184 object get allocated on the server side, partly because of INFO_PRINTF1
1.1611 + if (iOldCount<heapCount-184)
1.1612 + INFO_PRINTF3(_L("iOldCount>=heapCount-174 - Expected: %d, Actual: %d"), heapCount-184, iOldCount);
1.1613 +
1.1614 + }
1.1615 + ((CTOomStep*)iStep)->CloseTMSGraphicsStep();
1.1616 + TestComplete();
1.1617 + return;
1.1618 + }
1.1619 + DoOomTestL(CreateOomFailTest[iState++](this));
1.1620 + ((CTOomStep*)iStep)->RecordTestResultL();
1.1621 + }
1.1622 +
1.1623 +
1.1624 +
1.1625 +
1.1626 +__WS_CONSTRUCT_STEP__(Oom)
1.1627 +