(Automated Tests) Use Default Scene signals in Window stub
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-window.cpp
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include "toolkit-window.h"
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/actors/actor.h>
23 #include <dali/public-api/actors/layer.h>
24 #include <dali/public-api/common/stage.h>
25 #include <dali/public-api/object/base-object.h>
26
27 // INTERNAL INCLUDES
28 #include "test-render-surface.h"
29
30 namespace Dali
31 {
32
33 class Window;
34
35 /********************************************************************************
36  * Stub for Dali::Internal::Adaptor::Window
37  ********************************************************************************/
38
39 namespace Internal
40 {
41 namespace Adaptor
42 {
43 class Window : public Dali::BaseObject
44 {
45 public:
46
47   Window( const PositionSize& positionSize )
48   : mScene( Dali::Integration::Scene::New( Size( positionSize.width, positionSize.height ) ) ),
49     mRenderSurface( new TestRenderSurface( positionSize ) )
50   {
51     mScene.SetSurface( *mRenderSurface );
52   }
53
54   virtual ~Window()
55   {
56     delete mRenderSurface;
57     mRenderSurface = nullptr;
58   }
59
60   static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
61   {
62     return new Window( positionSize );
63   }
64
65   Integration::Scene mScene;
66   TestRenderSurface* mRenderSurface;
67 };
68
69 } // Adaptor
70 } // Internal
71
72 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
73 {
74   DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
75   BaseObject& object = window.GetBaseObject();
76   return static_cast<Internal::Adaptor::Window&>(object);
77 }
78
79 Window::Window()
80 {
81 }
82
83 Window::~Window()
84 {
85 }
86
87 Dali::Window Window::New( PositionSize windowPosition, const std::string& name, bool isTransparent )
88 {
89   Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, "", isTransparent );
90   return Window( window );
91 }
92
93 Dali::Window Window::New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent )
94 {
95   Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, className, isTransparent );
96   return Window( window );
97 }
98
99 Dali::Layer Window::GetRootLayer() const
100 {
101   return Dali::Stage::GetCurrent().GetRootLayer();
102 }
103
104 Window::Window( Internal::Adaptor::Window* window )
105 : BaseHandle( window )
106 {
107 }
108
109 Integration::Scene Window::GetScene()
110 {
111   return GetImplementation( *this ).mScene;
112 }
113
114 Integration::RenderSurface& Window::GetRenderSurface()
115 {
116   return *GetImplementation( *this ).mRenderSurface;
117 }
118
119 namespace DevelWindow
120 {
121
122 Window Get( Actor actor )
123 {
124   return Window();
125 }
126
127 EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window )
128 {
129   return GetImplementation( window ).mScene.EventProcessingFinishedSignal();
130 }
131
132 KeyEventSignalType& KeyEventSignal( Window window )
133 {
134   return GetImplementation( window ).mScene.KeyEventSignal();
135 }
136
137 TouchSignalType& TouchSignal( Window window )
138 {
139   return GetImplementation( window ).mScene.TouchSignal();
140 }
141
142 WheelEventSignalType& WheelEventSignal( Window window )
143 {
144   return GetImplementation( window ).mScene.WheelEventSignal();
145 }
146
147 } // namespace DevelWindow
148
149 } // Dali