sl@0: /* sl@0: * Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent - Internal Symbian test code sl@0: */ sl@0: sl@0: #ifndef __TUIANDVIDEO_H__ sl@0: #define __TUIANDVIDEO_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include "te_conestepbase.h" sl@0: sl@0: _LIT(KTUiAndVideo,"tuiandvideo"); sl@0: sl@0: #include sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: //#include sl@0: //#include sl@0: //#include sl@0: #include sl@0: #include sl@0: sl@0: class CTestAppView; sl@0: class CVideoPane; sl@0: class CTUiAndVideoAppUi; sl@0: sl@0: /** sl@0: Helper class to manage commands between test framework and test thread. sl@0: */ sl@0: class CCommandSink : public CActive sl@0: { sl@0: public: sl@0: CCommandSink(CTestAppView* aTestView); sl@0: ~CCommandSink(); sl@0: void Init(RThread* aTargetThread, TRequestStatus* aTargetStatus); sl@0: sl@0: protected: sl@0: void DoCancel(); sl@0: sl@0: private: sl@0: void RunL(); sl@0: sl@0: CTestAppView* iTestView; sl@0: TRequestStatus* iTargetStatus; sl@0: RThread* iTargetThread; sl@0: TUint32 iState; sl@0: }; sl@0: sl@0: sl@0: class CTUiAndVideo : public CTe_ConeStepBase sl@0: { sl@0: public: sl@0: CTUiAndVideo(); sl@0: sl@0: private: sl@0: // From CTestStep sl@0: virtual TVerdict doTestStepL(); sl@0: virtual void InitUIL(CCoeEnv* aCoeEnv); sl@0: void IssueCommand (TUint aCommand); sl@0: void StepState (TUint aNextState, TUint aPause); sl@0: sl@0: private: sl@0: CTUiAndVideoAppUi* iAppUi; sl@0: TRequestStatus iTestState; sl@0: }; sl@0: sl@0: //************************************************************************************************************ sl@0: //** Application UI sl@0: //************************************************************************************************************ sl@0: sl@0: class CTUiAndVideoAppUi : public CEikAppUi, public MVideoPlayerUtilityObserver sl@0: { sl@0: public: sl@0: void ConstructL(TRequestStatus iCommandSource); sl@0: ~CTUiAndVideoAppUi(); sl@0: sl@0: public: // from MVIdeoPlayerUtilityObserver sl@0: void MvpuoOpenComplete(TInt aError); sl@0: void MvpuoPrepareComplete(TInt aError); sl@0: void MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError); sl@0: void MvpuoPlayComplete(TInt aError); sl@0: void MvpuoEvent(const TMMFEvent &aEvent); sl@0: sl@0: private: sl@0: // from CEikAppUi sl@0: void HandleCommandL(TInt aCommand); sl@0: void HandleForegroundEventL(TBool aForeground); sl@0: static TInt BackgroundCallBack(TAny* aSelf); sl@0: static TInt UIMoverCallBack(TAny* aSelf); sl@0: void SetPos(); sl@0: void BringToForeground(); sl@0: static TInt PlayTimerCallBack(TAny* aSelf); sl@0: sl@0: public: sl@0: void Bounce (TBool aBounce); sl@0: void Jump (TBool aJump); sl@0: sl@0: TInt PopulateDirFilesL(const TDesC& aDir); sl@0: void OpenSelectedFileL(const TDesC& aFile); sl@0: TInt PlayNextFileL(); sl@0: TInt PlayPreviousFileL(); sl@0: void LogError(const TDesC& aFileName, const TDesC& aErrorMsg); sl@0: TRequestStatus* CommandSink (); sl@0: TBool iInitialised; sl@0: sl@0: private: sl@0: CCommandSink* iCommandSink; sl@0: CTestAppView* iAppView; sl@0: CVideoPlayerUtility2* iLoadingPlayer; sl@0: CPeriodic* iIdleTimer; sl@0: CPeriodic* iUIMover; sl@0: CPeriodic* iPlayTimer; sl@0: CDir* iDirList; sl@0: TInt iCurrentIndex; sl@0: TFileName iCurrentFile; sl@0: }; sl@0: sl@0: sl@0: sl@0: //************************************************************************************************************ sl@0: //** View class sl@0: //************************************************************************************************************ sl@0: sl@0: class CTestAppView : public CCoeControl, public MCoeControlObserver sl@0: { sl@0: public: sl@0: static CTestAppView* NewL(const TRect& aWindowedRect); sl@0: ~CTestAppView(); sl@0: RWindow& TheWindow(); sl@0: const RWindow& TheWindow() const { return const_cast(this)->TheWindow(); } sl@0: void EnableVideo(CVideoPlayerUtility2*& aPlayer); sl@0: void DisableVideo(); sl@0: TRect VideoPaneRect() const; sl@0: sl@0: void SetRunMode (TUint32 aMode); sl@0: sl@0: void PlayVideo(); sl@0: void PauseVideo(); sl@0: void StopVideo(); sl@0: void PlayComplete(TInt aError); sl@0: void SetPos(TPoint* aPos); sl@0: private: sl@0: CTestAppView(); sl@0: void ConstructL(const TRect& aRect); sl@0: void SetVideoSize(CVideoPlayerUtility2& aVideo) const; sl@0: void UpdateButtonState(); sl@0: void PlayPrevious(); sl@0: void PlayNext(); sl@0: private: // from MCoeControlObserver sl@0: void HandleControlEventL(CCoeControl *aControl, TCoeEvent aEventType); sl@0: sl@0: private: // from CCoeControl sl@0: void HandlePointerEventL(const TPointerEvent& aPointerEvent); sl@0: TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); sl@0: void SizeChanged(); sl@0: void Draw(const TRect& aRect) const; sl@0: sl@0: private: sl@0: TPoint iVidPos; sl@0: TPoint iIncrement; sl@0: TPoint iDirection; sl@0: TInt32 iRunMode; sl@0: sl@0: TRect iWindowedViewRect; sl@0: TSize iNativeVideoSize; sl@0: TPoint iPointerDownPos; sl@0: TTime iPointerDownTime; sl@0: CVideoPlayerUtility2* iCurrentPlayer; sl@0: TBool iIsPlaying; sl@0: private: sl@0: CFbsBitmap* iBkgrdImage; sl@0: CFbsBitmap* iBkgrdMask; sl@0: private: sl@0: CVideoPane* iVideoPane; sl@0: sl@0: enum sl@0: { sl@0: KFourButtonControlID, sl@0: KThreeButtonControlID, sl@0: KVideoControlID sl@0: }; sl@0: }; sl@0: sl@0: enum TButtonPaneAction sl@0: { sl@0: KButtonEventNotInit = -2, sl@0: KButtonEventDoNothing = -1, sl@0: KButtonEventDoPlayPause = 10, sl@0: KButtonEventDoBackward, sl@0: KButtonEventDoForward, sl@0: KButtonEventDoOpenFile sl@0: }; sl@0: sl@0: sl@0: //************************************************************************************************************ sl@0: //** CVideoPane class - place 'video' window sl@0: //************************************************************************************************************ sl@0: sl@0: class CVideoPane : public CCoeControl sl@0: { sl@0: public: sl@0: ~CVideoPane(); sl@0: CVideoPane(); sl@0: void ConstructL(CCoeControl& aParent); sl@0: RWindow& TheWindow() { return Window(); } sl@0: const RWindow& TheWindow() const { return const_cast(this)->TheWindow(); } sl@0: TBool IsVideoPanePointerEvent(); sl@0: void BlackoutPane(); sl@0: void SetVideoUseRect(const TRect& aRect); sl@0: void EnableSubtitle(CVideoPlayerUtility2* aSubtitlePlayer); sl@0: private: // from CCoeControl sl@0: void SizeChanged(); sl@0: void HandlePointerEventL(const TPointerEvent& aPointerEvent); sl@0: void Draw(const TRect& aRect) const; sl@0: private: sl@0: TBool iIsVideoPanePointerEvent; sl@0: TRect iVideoUseRect; sl@0: private: sl@0: CVideoPlayerUtility2* iSubtitlePlayer; sl@0: }; sl@0: sl@0: #endif