/** @SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0054-0001 @SYMPREQ PGM027 @SYMTestCaseDesc Negative Tests RWsSpriteBase::UpdateMember API. @SYMTestPriority 1 @SYMTestStatus Implemented @SYMTestActions This test calls RWsPointerCursor::UpdateMember @SYMTestExpectedResults Should run properly with out any Panics. */ void CTTSprite::SpriteUpdateMemberNegTestsL() { RWsPointerCursor iCursor1; CFbsBitmap bitmap; bitmap.Load(TEST_BITMAP_NAME,0); RWindow win(TheClient->iWs); win.Construct(*TheClient->iGroup->GroupWin(),1); win.Activate(); iCursor1=RWsPointerCursor(TheClient->iWs); TSpriteMember member; SetUpMember(member); member.iBitmap=&bitmap; User::LeaveIfError(iCursor1.Construct(0)); User::LeaveIfError(iCursor1.AppendMember(member)); User::LeaveIfError(iCursor1.Activate()); win.SetCustomPointerCursor(iCursor1); iCursor1.UpdateMember(-100); RWsPointerCursor iCursor2; bitmap.Load(TEST_NEW_BITMAP_NAME,0); iCursor2=RWsPointerCursor(TheClient->iWs); User::LeaveIfError(iCursor2.Construct(0)); User::LeaveIfError(iCursor2.AppendMember(member)); User::LeaveIfError(iCursor2.Activate()); win.SetCustomPointerCursor(iCursor2); iCursor2.UpdateMember(10000); iCursor1.Close(); iCursor2.Close(); win.Close(); }
void CTTSprite::SetUpPointerCursorL(RWsPointerCursor &aCursor, RWsSession &aSession) { aCursor=RWsPointerCursor(aSession); TSpriteMember member; SetUpMember(member); User::LeaveIfError(aCursor.Construct(0)); User::LeaveIfError(aCursor.AppendMember(member)); User::LeaveIfError(aCursor.Activate()); }
/* * returns an opaque native handle to a cursor. * It happens to be the address of the native handle, as window server handles * are not POD types. Note there is no QCursor(HANDLE) constructor on Symbian, * Mac or QWS. */ Qt::HANDLE QCursor::handle() const { if (d->pcurs.WsHandle()) return reinterpret_cast<Qt::HANDLE> (&(d->pcurs)); #ifdef Q_SYMBIAN_HAS_SYSTEM_CURSORS // don't construct shape cursors, QApplication_s60 will use the system cursor instead if (!(d->bm)) return 0; #endif d->pcurs = RWsPointerCursor(S60->wsSession()); d->pcurs.Construct(0); d->constructCursorSprite(d->pcurs); d->pcurs.Activate(); return reinterpret_cast<Qt::HANDLE> (&(d->pcurs)); }
/** Creates a pointer cursor. */ TInt COomPointerCursor::Fail() { iPointerCursor=RWsPointerCursor(iWs); TInt err=iPointerCursor.Construct(0); if (err==KErrNone) { TSpriteMember sprite; sprite.iBitmap=iBitmap; sprite.iMaskBitmap=iMask; sprite.iInvertMask=EFalse; sprite.iDrawMode=CGraphicsContext::EDrawModePEN; sprite.iOffset=TPoint(0,0); sprite.iInterval=TTimeIntervalMicroSeconds32(100000); if ((err=iPointerCursor.AppendMember(sprite))==KErrNone) if ((err=iPointerCursor.Activate())==KErrNone) { sprite.iBitmap=iBitmap2; // Bigger bitmap to force resize of bitmap sprite.iMaskBitmap=iMask2; if ((err=iPointerCursor.AppendMember(sprite))==KErrNone) err=iPointerCursor.UpdateMember(1,sprite); } } return(err); }
void CTTSprite::PointerCursorVisibleL() { if (!TestBase()->ConfigurationSupportsPointerEventTesting()) { INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); return; } // The pointer events need time to have an affect on the wserv static const TInt eventPropagationDelay = 100 * 1000; // 100 ms TInt screenNumber = TheClient->iScreen->GetScreenNumber(); if(screenNumber != 0) // pointer events only supported on emulator screen 0 { LOG_MESSAGE(_L("Pointer Cursor Visible only runs on screen 0")); return; } // set up objects used in test // 50x50 red rectangle colour 24 CFbsBitmap bitmap; User::LeaveIfError(bitmap.Load(TEST_BITMAP_NAME, 8)); TSize bmSize = bitmap.SizeInPixels(); TPoint bmSample = TPoint(bmSize.iWidth / 2, bmSize.iHeight / 2); TRgb bmColour; bitmap.GetPixel(bmColour, bmSample); TEST(bmColour == KRgbRed); // single window, size of screen RWindow win(TheClient->iWs); User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(),1)); win.Activate(); // setup cursor mode TheClient->iWs.SetPointerCursorMode(EPointerCursorWindow); // setup cursor to contain single 50x50 red bitmap RWsPointerCursor iCursor1 = RWsPointerCursor(TheClient->iWs); TSpriteMember member; SetUpMember(member); member.iBitmap=&bitmap; User::LeaveIfError(iCursor1.Construct(0)); User::LeaveIfError(iCursor1.AppendMember(member)); User::LeaveIfError(iCursor1.Activate()); win.SetCustomPointerCursor(iCursor1); iCursor1.UpdateMember(0); // draw a green rect, size of screen as defined background and wait till it is rendered win.BeginRedraw(); TheGc->Activate(win); TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); TheGc->SetBrushColor(KRgbGreen); TSize wSize = win.Size(); TheGc->DrawRect(TRect(TPoint(0,0), wSize)); TheGc->Deactivate(); win.EndRedraw(); TheClient->iWs.Finish(); // #### do test #### // define locations of simulated pointer events and sample positions of where we expect to see the cursor // The cursor will be moved and a check will be made to see if this has actually happened TPoint pos1(wSize.iWidth / 2, wSize.iHeight / 2); // top left of cursor at centre screen TPoint sample1(pos1 + bmSample); // centre of sprite at pos1 TPoint pos2 = pos1 - bmSize; // bottom right of cursor at centre screen TPoint sample2 = pos2 + bmSample; // centre of sprite at pos2 TRgb pixel; // check initial state of screen at both sample positions TheClient->iScreen->GetPixel(pixel, sample1); TEST(pixel == KRgbGreen); TheClient->iScreen->GetPixel(pixel, sample2); TEST(pixel == KRgbGreen); TRawEvent e; // to simulate pointer events // simulate button 1 down event at pos1 e.Set(TRawEvent::EButton1Down, pos1.iX, pos1.iY); e.SetDeviceNumber(screenNumber); UserSvr::AddEvent(e); User::After(eventPropagationDelay); // check red cursor visible on top of background TheClient->iScreen->GetPixel(pixel, sample1); TEST(pixel == KRgbRed); // simulate button 1 up event e.Set(TRawEvent::EButton1Up, pos1.iX, pos1.iY); UserSvr::AddEvent(e); User::After(eventPropagationDelay); // Move cursor away to pos2 e.Set(TRawEvent::EButton1Down, pos2.iX, pos2.iY); e.SetDeviceNumber(screenNumber); UserSvr::AddEvent(e); User::After(eventPropagationDelay); // check cursor has left this position ... TheClient->iScreen->GetPixel(pixel, sample1); TEST(pixel == KRgbGreen); // and arrived at the correct place TheClient->iScreen->GetPixel(pixel, sample2); TEST(pixel == KRgbRed); // simulate button 1 up event e.Set(TRawEvent::EButton1Up, pos2.iX, pos2.iY); UserSvr::AddEvent(e); User::After(eventPropagationDelay); // remove the cursor win.ClearPointerCursor(); User::After(eventPropagationDelay); // check it has gone TheClient->iScreen->GetPixel(pixel, sample2); TEST(pixel == KRgbGreen); // #### clean up #### iCursor1.Close(); win.Close(); }