X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Fdali-toolkit-test-utils%2Ftoolkit-window.cpp;h=9fc2763f64ab7896dffa79825a4f8b72966e5f86;hb=abc8459e18c5a7f8730c9493885fd067126520cb;hp=2726434b894396c6c208956179bc3669a40a8553;hpb=d559bcfd3dacea3441cf649b28687a0ea8bb1912;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-window.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-window.cpp index 2726434..9fc2763 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-window.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-window.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,16 +16,18 @@ */ // CLASS HEADER -#include "toolkit-window.h" +#include "toolkit-window-impl.h" // EXTERNAL INCLUDES #include #include -#include #include -// INTERNAL INCLUDES -#include "test-render-surface.h" +#define DALI_WINDOW_H +#include +#include + +using AdaptorImpl = Dali::Internal::Adaptor::Adaptor; namespace Dali { @@ -40,26 +42,49 @@ namespace Internal { namespace Adaptor { -class Window : public Dali::BaseObject + +Window::Window( const PositionSize& positionSize ) +: SceneHolder( positionSize ), + mFocusChangeSignal(), + mResizeSignal(), + mRotationAngle(90), // dummy angle for test coverage + mVisible(true), + mVisibilityChangedSignal() { -public: +} - Window( const PositionSize& positionSize ) - : mRenderSurface( positionSize ), - mScene( Dali::Integration::Scene::New( mRenderSurface ) ) - { - } +Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent) +{ + return new Window( positionSize ); +} - virtual ~Window() = default; +WindowPosition Window::GetPosition() const +{ + PositionSize positionSize = mRenderSurface.GetPositionSize(); - static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent) - { - return new Window( positionSize ); - } + return WindowPosition(positionSize.x, positionSize.y); +} - TestRenderSurface mRenderSurface; - Integration::Scene mScene; -}; +PositionSize Window::GetPositionSize() const +{ + return mRenderSurface.GetPositionSize(); +} + +Dali::Window::WindowSize Window::GetSize() const +{ + PositionSize positionSize = mRenderSurface.GetPositionSize(); + + return Dali::Window::WindowSize(positionSize.width, positionSize.height); +} + +void Window::SetPositionSize(PositionSize positionSize) +{ + mRenderSurface.MoveResize(positionSize); + + Uint16Pair newSize(positionSize.width, positionSize.height); + Dali::Window handle(this); + mResizeSignal.Emit(handle, newSize); +} } // Adaptor } // Internal @@ -71,6 +96,13 @@ inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window) return static_cast(object); } +inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window) +{ + DALI_ASSERT_ALWAYS( window && "Window handle is empty" ); + const BaseObject& object = window.GetBaseObject(); + return static_cast(object); +} + Window::Window() { } @@ -79,47 +111,105 @@ Window::~Window() { } -Window::Window(const Window& handle) -: BaseHandle( handle ) +Window::Window( const Window& copy ) = default; + +Window& Window::operator=( const Window& rhs ) = default; + +Window::Window( Window&& rhs ) = default; + +Window& Window::operator=( Window&& rhs ) = default; + +Dali::Window Window::New( PositionSize windowPosition, const std::string& name, bool isTransparent ) { + return New( windowPosition, name, "", isTransparent ); } -Window& Window::operator=(const Window& rhs) +Dali::Window Window::New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent ) { - BaseHandle::operator=(rhs); - return *this; + Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, className, isTransparent ); + + Dali::Window result( window ); + + // This will also emit the window created signals + AdaptorImpl::GetImpl( AdaptorImpl::Get() ).AddWindow( window ); + + return result; } -Dali::Window Window::New( PositionSize windowPosition, const std::string& name, bool isTransparent ) +Window::Window( Internal::Adaptor::Window* window ) +: BaseHandle( window ) { - Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, "", isTransparent ); - return Window( window ); } -Dali::Window Window::New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent ) +Integration::Scene Window::GetScene() { - Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, className, isTransparent ); - return Window( window ); + return GetImplementation( *this ).GetScene(); +} + +Dali::RenderSurfaceInterface& Window::GetRenderSurface() +{ + return GetImplementation( *this ).GetRenderSurface(); +} + +void Window::Add( Actor actor ) +{ + GetImplementation( *this ).Add( actor ); +} + +void Window::Remove( Actor actor ) +{ + GetImplementation( *this ).Remove( actor ); } Dali::Layer Window::GetRootLayer() const { - return Dali::Stage::GetCurrent().GetRootLayer(); + return GetImplementation( *this ).GetRootLayer(); } -Window::Window( Internal::Adaptor::Window* window ) -: BaseHandle( window ) +void Window::SetBackgroundColor( const Vector4& color ) { + GetImplementation( *this ).SetBackgroundColor( color ); } -Integration::Scene Window::GetScene() +Vector4 Window::GetBackgroundColor() const +{ + return GetImplementation( *this ).GetBackgroundColor(); +} + +void Window::Raise() +{ + GetImplementation( *this ).mFocusChangeSignal.Emit(*this, true); +} + +void Window::Hide() +{ + GetImplementation( *this ).mVisibilityChangedSignal.Emit( *this, false ); + GetImplementation( *this ).mVisible = false; +} + +bool Window::IsVisible() const +{ + return GetImplementation( *this ).mVisible; +} + +FocusChangeSignalType& Window::FocusChangeSignal() +{ + return GetImplementation( *this ).mFocusChangeSignal; +} + +ResizeSignalType& Window::ResizeSignal() +{ + return GetImplementation( *this ).mResizeSignal; +} + +Window::KeyEventSignalType& Window::KeyEventSignal() { - return GetImplementation( *this ).mScene; + return GetImplementation( *this ).KeyEventSignal(); } -Integration::RenderSurface& Window::GetRenderSurface() +Window::TouchEventSignalType& Window::TouchedSignal() { - return GetImplementation( *this ).mRenderSurface; + return GetImplementation( *this ).TouchedSignal(); } namespace DevelWindow @@ -127,27 +217,69 @@ namespace DevelWindow Window Get( Actor actor ) { - return Window(); + Internal::Adaptor::Window* windowImpl = nullptr; + + if ( Dali::Adaptor::IsAvailable() ) + { + windowImpl = static_cast( AdaptorImpl::GetImpl( AdaptorImpl::Get() ).GetWindow( actor ) ); + } + + return Dali::Window( windowImpl ); +} + +Window DownCast( BaseHandle handle ) +{ + Internal::Adaptor::Window* windowImpl = nullptr; + if ( Dali::Adaptor::IsAvailable() ) + { + windowImpl = dynamic_cast( handle.GetObjectPtr()); + } + return Dali::Window( windowImpl ); +} + +void SetPositionSize(Window window, PositionSize positionSize) +{ + GetImplementation( window ).SetPositionSize(positionSize); } -EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window ) +int GetPhysicalOrientation(Window window) +{ + return GetImplementation( window ).mRotationAngle; +} + +void AddFrameRenderedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId ) +{ + CallbackBase::Execute( *callback, frameId ); +} + +void AddFramePresentedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId ) { - return GetImplementation( window ).mScene.EventProcessingFinishedSignal(); + CallbackBase::Execute( *callback, frameId ); } -KeyEventSignalType& KeyEventSignal( Window window ) +EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window ) { - return GetImplementation( window ).mScene.KeyEventSignal(); + return GetImplementation( window ).GetScene().EventProcessingFinishedSignal(); } -TouchSignalType& TouchSignal( Window window ) +KeyEventGeneratedSignalType& KeyEventGeneratedSignal( Window window ) { - return GetImplementation( window ).mScene.TouchSignal(); + return GetImplementation( window ).KeyEventGeneratedSignal(); } WheelEventSignalType& WheelEventSignal( Window window ) { - return GetImplementation( window ).mScene.WheelEventSignal(); + return GetImplementation( window ).WheelEventSignal(); +} + +WheelEventGeneratedSignalType& WheelEventGeneratedSignal( Window window ) +{ + return GetImplementation( window ).WheelEventGeneratedSignal(); +} + +VisibilityChangedSignalType& VisibilityChangedSignal( Window window ) +{ + return GetImplementation( window ).mVisibilityChangedSignal; } } // namespace DevelWindow