/** Inform with a message ,the timer seconds remaining till its up.\n Send event to windows group when timer time is up .\n */ void CTestTimer::RunL() { --iSecondsRemaining; if (iSecondsRemaining>0) { QueueAndInfoPrint(); } else { User::InfoPrint(_L("Time's up")); iCompleted = ETrue; CCoeEnv* env = CCoeEnv::Static(); TWsEvent theEvent; theEvent.SetType(EEventUser + 1); RWsSession ws; TInt theRes = ws.Connect(); if(theRes == KErrNone) { RWindowGroup& winGroup = env->RootWin(); theEvent.SetType(EEventUser + 1); theEvent.SetTimeNow(); TInt theId = winGroup.Identifier(); ws.SendEventToWindowGroup(theId, theEvent); } ws.Close(); } }
/** @SYMTestCaseID GRAPHICS-WSERV-GCE-0700 @SYMDEF DEF123129 @SYMTestCaseDesc Test activating a sprite twice does not cause the system to hang @SYMTestPriority High @SYMTestStatus Implemented @SYMTestActions Construct a sprite and add a member to it. Activate twice. @SYMTestExpectedResults The test should terminate smoothly and it should not hang the system. */ void CTTSprite::DoubleActivateL() { RWsSession ws; User::LeaveIfError(ws.Connect()); CleanupClosePushL(ws); RWindowGroup group(ws); User::LeaveIfError(group.Construct(890, EFalse)); CleanupClosePushL(group); RWsSprite sprite = RWsSprite(ws); User::LeaveIfError(sprite.Construct(group,TPoint(),0)); CleanupClosePushL(sprite); CFbsBitmap* bitmap=new(ELeave) CFbsBitmap; CleanupStack::PushL(bitmap); User::LeaveIfError(bitmap->Create(TSize(10,12),EColor256)); TSpriteMember member; member.iMaskBitmap=NULL; member.iInvertMask=EFalse; member.iDrawMode=CGraphicsContext::EDrawModePEN; member.iOffset=TPoint(); member.iInterval=TTimeIntervalMicroSeconds32(0); member.iBitmap=bitmap; User::LeaveIfError(sprite.AppendMember(member)); User::LeaveIfError(sprite.Activate()); User::LeaveIfError(sprite.Activate()); sprite.Close(); CleanupStack::PopAndDestroy(4, &ws); group.Close(); ws.Close(); }
/** Test using an indipendent method that GCE version of WServ is running * This method can be called at any time, even by external code, but creates temporary window session objects * * @return true if WServ version is GCE technology, false if legacy technology **/ TBool CWsGceCscBase::GCEIsSupportedStatic() { CFbsDrawDevice* screenDevice=NULL; RWsSession session; if (session.Connect()!=KErrNone) { return EFalse; } CWsScreenDevice screen(session); if (screen.Construct(TGlobalSettings::Instance().iScreen)!=KErrNone) { return EFalse; } TDisplayMode displayMode=screen.DisplayMode(); TRAPD(err, screenDevice = CFbsDrawDevice::NewScreenDeviceL(TGlobalSettings::Instance().iScreen, displayMode)); TBool rv=EFalse; if(err == KErrNone) { TAny* p=NULL; rv=(screenDevice->GetInterface(KSurfaceInterfaceID, p)==KErrNone); delete screenDevice; } return rv; }
void CTTSprite::GeneralTestsL() { // // Close cursor while still active on a window // RWindow win(TheClient->iWs); win.Construct(*TheClient->iGroup->GroupWin(),1); win.Activate(); SetUpPointerCursorL(iCursor1,TheClient->iWs); win.SetCustomPointerCursor(iCursor1); iCursor1.Close(); // // Close window while cursor active on it // SetUpPointerCursorL(iCursor1,TheClient->iWs); win.SetCustomPointerCursor(iCursor1); win.Close(); iCursor1.Close(); // // Close session with: // An open cursor active on a window & A closed cursor active on another window // RWsSession ws; User::LeaveIfError(ws.Connect()); // use correct screen // ws.SetFocusScreen(iTest->iScreenNumber); CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); CleanupStack::PushL(screen); User::LeaveIfError(screen->Construct(0)); RWindowGroup group(ws); User::LeaveIfError(group.Construct(123)); group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close RWindow win2(ws); User::LeaveIfError(win2.Construct(group, 1)); win2.Activate(); RWindow win3(ws); User::LeaveIfError(win3.Construct(group, 2)); win3.Activate(); // SetUpPointerCursorL(iCursor1,ws); SetUpPointerCursorL(iCursor2,ws); win2.SetCustomPointerCursor(iCursor1); win3.SetCustomPointerCursor(iCursor2); // TSpriteMember member; member.iBitmap=member.iMaskBitmap=NULL; TInt err = iCursor1.UpdateMember(9999,member); TEST(err==KErrArgument); if (err!=KErrArgument) INFO_PRINTF3(_L("iCursor1.UpdateMember(9999,member) return value - Expected: %d, Actual: %d"), KErrArgument, err); iCursor1.Close(); CleanupStack::PopAndDestroy(screen); ws.Close(); }
// --------------------------------------------------------------------------- // CCmFmUpnpMngr::ScreenSizeL // --------------------------------------------------------------------------- // void CCmFmUpnpMngr::ScreenSizeL() { LOG(_L("[FILL MNGR]\t CCmFmUpnpMngr::ScreenSizeL start")); RWsSession session; TInt error = session.Connect() ; CleanupClosePushL( session ); if ( !error ) { CWsScreenDevice* screenDevice = new ( ELeave ) CWsScreenDevice( session ); if ( screenDevice && !screenDevice->Construct() ) { iScreenSize = screenDevice->SizeInPixels(); } delete screenDevice; screenDevice = NULL; } else { TRACE(Print(_L("[FILL MNGR]\t ScreenSizeL error = %d"), error )); } CleanupStack::PopAndDestroy( &session ); LOG(_L("[FILL MNGR]\t CCmFmUpnpMngr::ScreenSizeL end")); }
// ----------------------------------------------------------------------------- // CSisxUISilentHandler::BringToForeground // Swithces application to foreground or background. Used when user confirmation // dialog is used dialog is used in silent installation // ----------------------------------------------------------------------------- // void CSisxUISilentHandler::BringToForeground( TBool aForeground ) { RWsSession ws; if ( ws.Connect() == KErrNone ) { CleanupClosePushL(ws); TApaTaskList tasklist(ws); if ( aForeground ) { TApaTask task = tasklist.FindApp( TUid::Uid(KSWInstSvrUid) ); if ( task.Exists() ) { task.BringToForeground(); } } else { TApaTask task = tasklist.FindApp( TUid::Uid(KSWInstSvrUid) ); if ( task.Exists() ) { task.SendToBackground(); } } CleanupStack::PopAndDestroy(); //ws } }
void CTcAppLauncher::RunL() { // Fatal error occurred, report User::LeaveIfError( iStatus.Int() ); if( iDismissDialog ) { TKeyEvent event; event.iCode = EKeyDevice3; RWsSession wsSession; User::LeaveIfError( wsSession.Connect() ); wsSession.SimulateKeyEvent( event ); wsSession.Close(); } RApaLsSession apparc; User::LeaveIfError( apparc.Connect() ); CleanupClosePushL( apparc ); CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); cmdLine->SetExecutableNameL( iAppName ); cmdLine->SetCommandL( EApaCommandRun ); User::LeaveIfError( apparc.StartApp( *cmdLine ) ); CleanupStack::PopAndDestroy( 2 ); // Write log entry LOG( _L("[APPLAUNCHER] Client restarted.") ); delete this; }
// ---------------------------------------------------------------------------- // Helper to get the window group ID associated with a process // ---------------------------------------------------------------------------- // EXPORT_C TInt MPXUser::FindWindowGroupIdL( TProcessId aProcId, RWsSession& aWsSession ) { TInt wgId( KErrNotFound ); RArray<RWsSession::TWindowGroupChainInfo> windowArray; CleanupClosePushL( windowArray ); aWsSession.WindowGroupList( &windowArray ); TInt wgCount( windowArray.Count() ); for ( TInt i = 0; i < wgCount && wgId == KErrNotFound; i++ ) { TThreadId threadId; User::LeaveIfError( aWsSession.GetWindowGroupClientThreadId( windowArray[i].iId, threadId ) ); RThread thread; CleanupClosePushL( thread ); User::LeaveIfError( thread.Open( threadId )); RProcess proc; CleanupClosePushL( proc ); User::LeaveIfError( thread.Process( proc )); if ( proc.Id() == aProcId ) { wgId = windowArray[i].iId; } CleanupStack::PopAndDestroy( &proc ); CleanupStack::PopAndDestroy( &thread ); } CleanupStack::PopAndDestroy( &windowArray ); return wgId; }
TVerdict CApStartTestStep::doTestStepL() { INFO_PRINTF1(_L("CApStartTestStep started....\n")); __UHEAP_MARK; RWsSession wsSession; User::LeaveIfError(wsSession.Connect()); CleanupClosePushL(wsSession); TRAPD(err, TestStartAndForgetL(wsSession)); TESTE(KErrNone == err, err); TRAP(err, TestStartAndFollowUpL(wsSession)); TESTE(KErrNone == err, err); CleanupStack::PopAndDestroy(); //wsSession.Close(); TRAP(err, TestInitApparcL()); TESTE(KErrNone == err, err); __UHEAP_MARKEND; INFO_PRINTF1(_L(".... CApStartTestStep finished!!")); return TestStepResult(); }
void showDebugMessage( const char* source, const char* message ) { if ( source && message ) { memset(g_szSource, 0, sizeof(g_szSource) ); memset(g_szMessage, 0, sizeof(g_szMessage) ); memcpy( g_szSource, source, strlen(source) > 20 ? 20 : strlen(source) ); memcpy( g_szMessage, message, strlen(message) > 100 ? 100 : strlen(message)); // Create a window server event RWsSession wsSession; TWsEvent event; if ( wsSession.Connect() == KErrNone ) { // Set event data. eventType.data = KData; event.SetType(EEventUser + ECmdShowDebugWindow); // set event type event.SetTimeNow(); // set the event time event.SetHandle(wsSession.WsHandle()); // set window server handle // Send the created event wsSession.SendEventToAllWindowGroups(event); } } }
void CMultipleSurfacesAppUi::BringToFront() { RWindow window = iAppView->Window(); RWsSession wsSession = iAppView->ControlEnv()->WsSession(); wsSession.SetWindowGroupOrdinalPosition(window.WindowGroupId(), 0); wsSession.Flush(); wsSession.Finish(); }
// Failures are written to WSERV.log void CWsGraphicShareBase::Test(TInt aCondition) { if(!aCondition) { TLogMessageText buf; _LIT(Fail,"AUTO Failed in WsGraphics Test : DrawSharedGraphic"); buf.Format(Fail); iWs.LogMessage(buf); iWs.Flush(); RProcess().Terminate(KErrTestExeFailure); // terminate this process immediately. Expect TWsGraph test step (TAutoServer.exe) to capture this } }
// ---------------------------------------------------------------------------- // // ---------------------------------------------------------------------------- // TBool CWrtHarvester::CheckTaskExistsL() { TUid widgetAppUid( TUid::Uid( KWidgetAppUid ) ); RWsSession wsSession; // Create Window server session User::LeaveIfError( wsSession.Connect() ); TApaTaskList taskList( wsSession ); TApaTask task = taskList.FindApp( widgetAppUid ); return task.Exists()?ETrue:EFalse; }
TInt LoadsOfText(TInt aOwningGroup) { RWsSession ws; ws.Connect(); CWsScreenDevice *device=new(ELeave) CWsScreenDevice(ws); device->Construct(); RWindowGroup group(ws); group.Construct(ENullWsHandle); group.SetOwningWindowGroup(aOwningGroup); TSize scrSize(device->SizeInPixels()); // RWindow window(ws); window.Construct(group,ENullWsHandle); window.SetExtent(TPoint(), scrSize); window.Activate(); // CWindowGc *gc; device->CreateContext(gc); window.BeginRedraw(); gc->Activate(window); gc->Clear(); window.EndRedraw(); TFontSpec fspec(KTestFontTypefaceName,200); CFbsFont *font; User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips((CFont *&)font, fspec)); gc->UseFont(font); TBuf<100> loadsatext(_L("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890zyxwvutsrqponmlkjihgfedcba")); TInt ascent=font->AscentInPixels(); TInt fheight=font->HeightInPixels(); for(TInt nTimes=0;nTimes<10;nTimes++) { TPoint pos; // for(pos.iY=ascent;pos.iY<scrSize.iHeight;pos.iY+=font->HeightInPixels()) // gc->DrawText(loadsatext,pos); for(pos.iY=0;pos.iY<scrSize.iHeight;pos.iY+=fheight) gc->DrawText(loadsatext,TRect(pos,TPoint(scrSize.iWidth,pos.iY+fheight)),ascent); gc->Clear(); } gc->Deactivate(); // ws.Flush(); delete gc; device->ReleaseFont(font); window.Close(); group.Close(); delete device; ws.Close(); return(KErrNone); }
void CSpriteSet::ConstructL(RWindowTreeNode& aWindow, RWsSession& aWs, CWsScreenDevice& aDevice) { TInt grayscaleCapabilities; TInt colorCapabilities; const TDisplayMode mode=aWs.GetDefModeMaxNumColors(colorCapabilities,grayscaleCapabilities); iTargetBitmap = new (ELeave) CWsBitmap(aWs); const TSize zeroSize(0,0); User::LeaveIfError(iTargetBitmap->Create(zeroSize,mode)); iTargetMaskBitmap = new (ELeave) CWsBitmap(aWs); User::LeaveIfError(iTargetMaskBitmap->Create(zeroSize,mode)); iSprite=RWsSprite(aWs); User::LeaveIfError(iSprite.Construct(aWindow, TPoint(KOffScreenValue,KOffScreenValue), ESpriteNoChildClip)); CreateSpriteMember(); iSprite.AppendMember(iSpriteMember); iSprite.Activate(); iMainFbsBitGc=CFbsBitGc::NewL(); // for the main bitmap iWindowToBitmapMappingGc = CWindowToBitmapMappingGc::NewL(aDevice,*iMainFbsBitGc); // takes place of iMainFbsBitGc (not passing ownership of context here !) iMaskFbsBitGc=CFbsBitGc::NewL(); // for the mask bitmap iMainBmpDevice=CFbsBitmapDevice::NewL(iTargetBitmap); iMaskBmpDevice=CFbsBitmapDevice::NewL(iTargetMaskBitmap); iMainFbsBitGc->Activate(iMainBmpDevice); iMaskFbsBitGc->Activate(iMaskBmpDevice); }
void CSyncEngineWrap::SendWindowEvent(TInt aEvent) { // Create a window server event RWsSession wsSession; TWsEvent event; if (wsSession.Connect() == KErrNone) { // Set event data. eventType.data = KData; event.SetType(EEventUser + aEvent); // set event type event.SetTimeNow(); // set the event time event.SetHandle(wsSession.WsHandle()); // set window server handle // Send the created event wsSession.SendEventToAllWindowGroups(event); } }
/** * Runs the test in a second thread. * * @param aFunctionIndex The drawing function command to be executed. All commands are defined in TestFunctionIndex. */ TInt CTW32CmdBuf::DoTestCmdBufFunctionL(TTestFunctionIndex aFunctionIndex) { RWsSession session; User::LeaveIfError(session.Connect()); CleanupClosePushL(session); CWsScreenDevice *device = new(ELeave) CWsScreenDevice(session); CleanupStack::PushL(device); User::LeaveIfError(device->Construct(CTestBase::iScreenNo)); CWindowGc* gc; User::LeaveIfError(device->CreateContext(gc)); CleanupStack::PushL(gc); RWindowGroup group(session); User::LeaveIfError(group.Construct(1, EFalse)); CleanupClosePushL(group); RWindow window(session); User::LeaveIfError(window.Construct(group, 2)); CleanupClosePushL(window); window.SetExtent(TPoint(0,0), TSize(200, 200)); User::LeaveIfError(window.SetRequiredDisplayMode(EColor64K)); window.Activate(); gc->Activate(window); session.SetAutoFlush(EFalse); window.Invalidate(); window.BeginRedraw(); for(TInt i=KMinTestIterations; i<KMaxTestIterations; ++i) { for(TInt j=0; j<i; ++j) { gc->Clear(); } CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; CleanupStack::PushL(bitmap); User::LeaveIfError(bitmap->Create(TSize(100, 100), EColor64K)); CFbsBitmap* mask = new(ELeave) CFbsBitmap; CleanupStack::PushL(mask); User::LeaveIfError(mask->Create(TSize(100, 100), EColor64K)); KTestFunctions[aFunctionIndex](gc, bitmap, mask); CleanupStack::PopAndDestroy(2); session.Flush(); } window.EndRedraw(); gc->Deactivate(); CleanupStack::PopAndDestroy(5); return KErrNone; }
/** Draws a stretched bitmap with or without a mask. @param aUseMask set to ETrue to use a alpha mask. Normally used for 16MU display modes that do not store the alpha. @param aSrcMode is the source display mode @param aDstMode is the destination display mode @param aSession is the windows server session @param aWindow is a reference to the window @param aGc is the graphics context of the window @param aNumIterations is the number of iterations to run the test */ void CAlphaBlendTest::DoDrawBitmapL(TBool aUseMask, TDisplayMode aSrcMode, TDisplayMode aDstMode, RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TInt aNumIterations) { const TSize bitmapSize = aWindow.Size(); // Construct target bitmap. CFbsBitmap* bitmapTarget = CreateSoftwareBitmapLC(bitmapSize, aDstMode); CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmapTarget); CleanupStack::PushL(bitmapDevice); // Construct GC. CFbsBitGc* bitmapGc = NULL; User::LeaveIfError(bitmapDevice->CreateContext(bitmapGc)); CleanupStack::PushL(bitmapGc); // Construct source bitmap. TSize smallerSize(bitmapSize.iWidth/2, bitmapSize.iHeight/2); CFbsBitmap* source = CreateSoftwareBitmapLC(smallerSize, aSrcMode); VerticalGradientAlphaL(source, TRgb(0x00000000), TRgb(0xffffffff)); CFbsBitmap* sourceAlpha = CreateSoftwareBitmapLC(smallerSize, EGray256); // match size to src VerticalGradientAlphaL(sourceAlpha, TRgb(0x01010101), TRgb(0xfefefefe)); bitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush); bitmapGc->SetBrushColor(TRANSPARENT_BLACK); bitmapGc->Clear(); bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN); aGc->Activate(aWindow); TPoint point(0,0); bitmapGc->BitBlt(point, bitmapTarget); aGc->Deactivate(); aSession.Flush(); TBuf <20> testName; if (!aUseMask) { testName=_L("DrawBitmap"); iProfiler->InitResults(); for(int i=0; i<aNumIterations; i++) { bitmapGc->DrawBitmap(TRect(point, bitmapSize), source); iProfiler->MarkResultSetL(); } } else { testName=_L("DrawBitmapMasked"); iProfiler->InitResults(); for(int i=0; i<aNumIterations; i++) { bitmapGc->DrawBitmapMasked(TRect(point, bitmapSize), source,TRect(point, smallerSize), sourceAlpha, EFalse); iProfiler->MarkResultSetL(); } } INFO_PRINTF4(_L("%S(Stretched) with src = %S, dst = %S"), &testName, &ColorModeName(aSrcMode), &ColorModeName(aDstMode)); iProfiler->ResultsAnalysis(testName, 0, aSrcMode, aDstMode, aNumIterations); // copy up to screen for sanity check BitBlt(aSession, aWindow, aGc, *bitmapTarget); CleanupStack::PopAndDestroy(5, bitmapTarget); }
void CGlobalSettings::SetScreenNoL(TInt aScreenNo) { RWsSession session; ASSERT_EQUALS(session.Connect(), KErrNone); TInt maxScreens=session.NumberOfScreens(); if (maxScreens>aScreenNo) { INFO_PRINTF2(_L("New screen number for all output selected: %i"),aScreenNo); { CWsScreenDevice screen(session); screen.Construct(aScreenNo); screen.SetCurrentRotations(0,CFbsBitGc::TGraphicsOrientation(0)); screen.SetScreenMode(0); screen.SetAppScreenMode(0); } settings_instance.iScreen=aScreenNo; session.Flush(); session.Close(); } else { INFO_PRINTF1(_L("**************************")); INFO_PRINTF1(_L("")); INFO_PRINTF3(_L("Can't set screen output to %i. Only got %i screens"),aScreenNo,maxScreens); INFO_PRINTF2(_L("Screen number for all output remains at: %i"),settings_instance.iScreen); INFO_PRINTF1(_L("")); INFO_PRINTF1(_L("**************************")); session.Flush(); session.Close(); User::Leave(KErrTEFUnitFail); } }
void CWsGraphicShareBase::DoTestDrawGraphicCompareL(TPtrC aShare) { // UID of the shared graphic TUid uid1 = {0x12000021}; TWsGraphicId twsGraphicId1(uid1); _LIT8(KTestData,"HelloWorld"); CFbsBitmap bitmap1; CFbsBitmap mask1; TSize screenSize = iScreen->SizeInPixels(); User::LeaveIfError(bitmap1.Load(MY_TEST_BITMAP,0)); mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode()); CWsGraphicBitmap* bTest = CWsGraphicBitmap::NewL(&bitmap1,&mask1); // divide the screen into two equal rectangles TRect position1(0,0,screenSize.iWidth/2,screenSize.iHeight); TRect position2(screenSize.iWidth/2,0,screenSize.iWidth,screenSize.iHeight); // draw the new graphic and attempt to draw the shared graphic iGc->Activate(*iWin); iWin->Invalidate(); iWin->BeginRedraw(); iGc->Clear(position1); iGc->Clear(position2); iGc->DrawWsGraphic(bTest->Id(),position1,KTestData); iGc->DrawWsGraphic(twsGraphicId1.Uid(),position2,KTestData); iGc->Deactivate(); iWin->EndRedraw(); iWs.Flush(); iWs.Finish(); // compare the graphic in both positions if (aShare==_L("false")) Test(!iScreen->RectCompare(position1,position2)); else Test(iScreen->RectCompare(position1,position2)); delete bTest; }
void CTGdi::NonDrawing() // // Test all non-drawing GDI functions // { TDisplayMode mode=TheClient->iScreen->DisplayMode(); TEST((mode!=ERgb) && (mode!=ENone)); RWsSession session; TInt res = session.Connect(); TEST(res == KErrNone); CArrayFixFlat<TInt>* modeList= new CArrayFixFlat<TInt> (15); if(!modeList) return; #if defined(SYMBIAN_GRAPHICS_GCE) res = session.GetColorModeList(iTest->iScreenNumber, modeList); #else res = session.GetColorModeList(modeList); #endif //SYMBIAN_GRAPHICS_GCE session.Close(); TEST(res == KErrNone); if(res != KErrNone) { modeList->Reset(); delete modeList; return; } TBool found = EFalse; for(TInt ii = 0; ii < modeList->Count() && !found; ii++) { TDisplayMode mode1 = (TDisplayMode) ((*modeList)[ii]); if(mode == mode1) { found = ETrue; } } modeList->Reset(); delete modeList; TEST(found); }
/** BitBlts a bitmap to the windows GC. @param aSession is the windows server session @param aWindow is a reference to the window @param aGc is the graphics context of the window @param aImage is the bitmap to bitblt */ void CAlphaBlendTest::BitBlt(RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, CFbsBitmap& aImage) { aWindow.Invalidate(); aWindow.BeginRedraw(); aGc->Activate(aWindow); aGc->BitBlt(TPoint(0,0), &aImage); aGc->Deactivate(); aWindow.EndRedraw(); aSession.Flush(); }
void SendWindowEvent(TInt aEvent, const char* data) { // Create a window server event RWsSession wsSession; TWsEvent event; if ( wsSession.Connect() == KErrNone ) { // Set event data. eventType.data = KData; event.SetType(EEventUser + aEvent); // set event type event.SetTimeNow(); // set the event time event.SetHandle(wsSession.WsHandle()); // set window server handle if ( data ) ((char**)event.EventData())[0] = strdup(data); // Send the created event wsSession.SendEventToAllWindowGroups(event); } }
void CWsGraphicShareBase::ConstructL() { User::LeaveIfError(iWs.Connect()); iScreen=new(ELeave) CWsScreenDevice(iWs); User::LeaveIfError(iScreen->Construct(iScreenNumber)); iGc=new(ELeave) CWindowGc(iScreen); User::LeaveIfError(iGc->Construct()); iGroupWin=new(ELeave) RWindowGroup(iWs); iGroupWin->Construct(1); iWin=new(ELeave) RWindow(iWs); iWin->Construct(*iGroupWin,ENullWsHandle); iWin->SetRequiredDisplayMode(EColor256); iWin->SetExtent(TPoint(0,0),iScreen->SizeInPixels()); iWin->Activate(); iWin->BeginRedraw(); iWin->EndRedraw(); iWs.Flush(); }
// ============================================================================ // CWidgetEntry::Active() // Is widget running? 0 if not, non zero if running. // // @since 3.1 // ============================================================================ // TInt CWidgetEntry::ActiveL() { if ( iActive ) { // check that WidgetUI didn't crash, this assumes all widgets // in the registry are running under WidgetUI RWsSession wsSession; User::LeaveIfError( wsSession.Connect() ); CleanupClosePushL( wsSession ); TApaTaskList taskList( wsSession ); TApaTask task = taskList.FindApp( KUidWidgetUi ); if ( EFalse == task.Exists() ) { // widget UI crashed, reset active iActive = 0; } CleanupStack::PopAndDestroy( &wsSession ); } return iActive; }
/** Clears the window to a colour @param aSession is the windows server session @param aWindow is a reference to the window @param aGc is the graphics context of the window @param aColor is the colour to clear the window with */ void CAlphaBlendTest::ClearWindow(RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TRgb aColor) { // clear so we can see bitmap version has completed aWindow.Invalidate(); aWindow.BeginRedraw(); aGc->Activate(aWindow); aGc->SetBrushColor(aColor); aGc->Clear(); aGc->Deactivate(); aWindow.EndRedraw(); aSession.Flush(); }
/** Alpha blends two bitmaps together @param aDisplayMode1 is the source display mode @param aDisplayMode2 is the destination display mode @param aSession is the windows server session @param aWindow is a reference to the window @param aGc is the graphics context of the window @param aNumIterations is the number of iterations to run the test */ void CAlphaBlendTest::DoAlphaBlendBitmapsBitmapTestL(TDisplayMode aSrcMode, TDisplayMode aDstMode, RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TInt aNumIterations) { const TSize bitmapSize = aWindow.Size(); CFbsBitmap* bitmapTarget = CreateSoftwareBitmapLC(bitmapSize, aDstMode); CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmapTarget); CleanupStack::PushL(bitmapDevice); CFbsBitGc* bitmapGc=NULL; User::LeaveIfError(bitmapDevice->CreateContext(bitmapGc)); CleanupStack::PushL(bitmapGc); CFbsBitmap* sourceUnder = CreateSoftwareBitmapLC(bitmapSize, aDstMode); CFbsBitmap* sourceOver = CreateSoftwareBitmapLC(bitmapSize, aSrcMode); CFbsBitmap* sourceAlpha = CreateSoftwareBitmapLC(bitmapSize, EGray256); VerticalGradientAlphaL(sourceAlpha, TRgb(0x01010101), TRgb(0xfefefefe)); VerticalGradientAlphaL(sourceUnder, TRgb(0xff000000), TRgb(0x00ffffff)); VerticalGradientAlphaL(sourceOver, TRgb(0x00ffffff), TRgb(0xff000000)); RDebug::Printf("DABBBT 2"); TPoint point(0,0); TRect rect(bitmapSize); bitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush); bitmapGc->SetBrushColor(TRANSPARENT_BLACK); bitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); bitmapGc->Clear(); bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN); bitmapGc->AlphaBlendBitmaps(point, sourceUnder, sourceOver, rect, point, sourceAlpha, point); aGc->Activate(aWindow); aGc->BitBlt(point, bitmapTarget); aGc->Deactivate(); aSession.Flush(); iProfiler->InitResults(); // blend sourceUnder with sourceOver using alpha mask for(TInt i=0; i<aNumIterations; i++) { bitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); bitmapGc->Clear(); bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN); bitmapGc->AlphaBlendBitmaps(point, sourceUnder, sourceOver, rect, point, sourceAlpha, point); iProfiler->MarkResultSetL(); } iProfiler->ResultsAnalysis(_L("DoAlphaBlendBitmapsBitmapTestL"), 0, aSrcMode, aDstMode, aNumIterations); // copy up to screen for sanity check BitBlt(aSession, aWindow, aGc, *bitmapTarget); CleanupStack::PopAndDestroy(6, bitmapTarget); // sourceAlpha, sourceOver, sourceUnder, bitmapGc, bitmapDevice, bitmapTarget }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ TInt CExPolicy_Server::KillTasks(TUid& aUid) { TInt RetErr(KErrNone); RWsSession wsSession; RetErr= wsSession.Connect(); if(RetErr == KErrNone) { TApaTaskList taskList( wsSession ); TApaTask task = taskList.FindApp(aUid); if( task.Exists() ) { task.KillTask(); } } wsSession.Close(); return RetErr; }
void CCustomCmdTestDeviceSecurityCheck::SimulatePasswordEntry() { RWsSession wsSession; TInt err = wsSession.Connect(); TEST(KErrNone == err); const TInt okButtonPos1 = 60; //the position of ok button const TInt okButtonPos2 = 600; //the position of ok button //Simulate the key press ,(comma) in to pin notifier dialogue TRawEvent eventDown; TRawEvent eventUp; eventDown.Set(TRawEvent::EKeyDown, EStdKeyComma); UserSvr::AddEvent(eventDown); eventUp.Set(TRawEvent::EKeyUp, EStdKeyComma); UserSvr::AddEvent(eventUp); User::After(100000); //Enter wrong pwd if iWrongPwd is ETrue if(iWrongPwd) { eventDown.Set(TRawEvent::EKeyDown, EStdKeyComma); UserSvr::AddEvent(eventDown); eventUp.Set(TRawEvent::EKeyUp, EStdKeyComma); UserSvr::AddEvent(eventUp); User::After(100000); //Reset it to false as wrong password should be entered only once iWrongPwd = EFalse; } eventDown.Set(TRawEvent::EButton1Down, okButtonPos1,okButtonPos2); UserSvr::AddEvent(eventDown); eventUp.Set(TRawEvent::EButton1Up, okButtonPos1,okButtonPos2); UserSvr::AddEvent(eventUp); User::After(100000); wsSession.Flush(); wsSession.Close(); }
void CTScreenDevice::ConstructL() { //The following is just another test... it doesn't leave any resources for use by the test class AFAICT... RWsSession aSession; CWsScreenDevice *device1; CWsScreenDevice *device2; CWsScreenDevice *device3; aSession.Connect(); device1=new(ELeave) CWsScreenDevice(aSession); device1->Construct(iTest->iScreenNumber); delete device1; device1=new(ELeave) CWsScreenDevice(aSession); device1->Construct(iTest->iScreenNumber); device2=new(ELeave) CWsScreenDevice(aSession); device2->Construct(iTest->iScreenNumber); device3=new(ELeave) CWsScreenDevice(aSession); device3->Construct(iTest->iScreenNumber); delete device3; CFbsFont *font; User::LeaveIfError(device1->GetNearestFontToDesignHeightInTwips((CFont *&)font,TFontSpec())); RWindowGroup group(aSession); group.Construct(777); group.SetOwningWindowGroup(TheClient->iGroup->GroupWin()->Identifier()); RWindow win(aSession); win.Construct(group,77); CWindowGc *gc=new(ELeave) CWindowGc(device1); gc->Construct(); gc->Activate(win); gc->UseFont(font); device1->ReleaseFont(font); aSession.Flush(); delete gc; win.Close(); group.Close(); delete device1; delete device2; aSession.Close(); }