Add Wayland support.
[platform/core/uifw/dali-toolkit.git] / automated-tests / TET / dali-test-suite / control / dummy-control.h
1 #ifndef __DALI_TOOLKIT_TEST_DUMMY_CONTROL_H__
2 #define __DALI_TOOLKIT_TEST_DUMMY_CONTROL_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/dali-toolkit.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 class DummyControlImpl;
31
32 /**
33  * Control does not have a New method so use this dummy class for the handle.
34  */
35 class DummyControl : public Control
36 {
37 public:
38
39   DummyControl()
40   : mCustomSlot1Called(false)
41   {
42   }
43
44   DummyControl(const DummyControl& control)
45   : Control( control ),
46     mCustomSlot1Called(false)
47   {
48   }
49
50   virtual ~DummyControl()
51   {
52   }
53
54   static DummyControl New( bool override = false );
55
56   static DummyControl DownCast( BaseHandle handle )
57   {
58     return Control::DownCast<DummyControl, DummyControlImpl>(handle);
59   }
60
61   DummyControl& operator=(const DummyControl& control)
62   {
63     Control::operator=( control );
64     return *this;
65   }
66
67   // Used to test signal connections
68   void CustomSlot1( Actor actor, const Vector3& value )
69   {
70     mCustomSlot1Called = true;
71     mCustomSlot1Value = value;
72   }
73
74 public:
75
76   bool mCustomSlot1Called;
77   Vector3 mCustomSlot1Value;
78
79 public: // Not intended for application developers
80
81   DummyControl( DummyControlImpl& implementation );
82   DummyControl( Dali::Internal::CustomActor* internal );
83 };
84
85 /**
86  * Cannot create an instance of ControlImpl, so use this dummy class for the implementation.
87  * This class does not override any of ControlImpl's behaviour.
88  */
89 class DummyControlImpl : public ControlImpl
90 {
91 public:
92
93   static DummyControl New()
94   {
95     IntrusivePtr< DummyControlImpl > impl = new DummyControlImpl;
96     DummyControl control( *impl );
97     impl->Initialize();
98     return control;
99   }
100
101 public:
102   void EnableGestureDetection(Gesture::Type type) { ControlImpl::EnableGestureDetection(type); }
103   void DisableGestureDetection(Gesture::Type type) { ControlImpl::DisableGestureDetection(type); }
104   PinchGestureDetector GetPinchGestureDetector() const { return ControlImpl::GetPinchGestureDetector(); }
105   PanGestureDetector GetPanGestureDetector() const { return ControlImpl::GetPanGestureDetector(); }
106   TapGestureDetector GetTapGestureDetector() const { return ControlImpl::GetTapGestureDetector(); }
107   LongPressGestureDetector GetLongPressGestureDetector() const { return ControlImpl::GetLongPressGestureDetector(); }
108
109 protected:
110
111   DummyControlImpl()
112   : ControlImpl(true)
113   {
114   }
115
116   virtual ~DummyControlImpl()
117   {
118   }
119 };
120
121 /**
122  * Cannot create an instance of ControlImpl, so use this dummy class for the implementation.
123  * This class DOES override ControlImpl's behaviour.
124  */
125 class DummyControlImplOverride : public DummyControlImpl
126 {
127 public:
128
129   static DummyControl New()
130   {
131     IntrusivePtr< DummyControlImplOverride > impl = new DummyControlImplOverride;
132     DummyControl control( *impl );
133     impl->Initialize();
134     return control;
135   }
136
137 private:
138
139   DummyControlImplOverride()
140   : DummyControlImpl(),
141     initializeCalled(false),
142     themeChangeCalled(false),
143     fontChangeCalled( false ),
144     pinchCalled(false),
145     panCalled(false),
146     tapCalled(false),
147     longPressCalled(false),
148     stageConnectionCalled(false),
149     stageDisconnectionCalled(false),
150     childAddCalled(false),
151     childRemoveCalled(false),
152     sizeSetCalled(false),
153     sizeAnimationCalled(false),
154     touchEventCalled(false),
155     mouseWheelEventCalled(false),
156     keyEventCalled(false),
157     keyInputFocusGained(false),
158     keyInputFocusLost(false)
159   {
160   }
161
162   virtual ~DummyControlImplOverride() { }
163
164 private: // From ControlImpl
165
166   virtual void OnInitialize() { initializeCalled = true; }
167   virtual void OnThemeChange( StyleManager styleManager ) { themeChangeCalled = true }
168   virtual void OnFontChange( bool defaultFontChange, bool defaultFontSizeChange ) { fontChangeCalled = true;}
169   virtual void OnPinch(PinchGesture pinch) { pinchCalled = true; }
170   virtual void OnPan(PanGesture pan) { panCalled = true; }
171   virtual void OnTap(TapGesture tap) { tapCalled = true; }
172   virtual void OnLongPress(LongPressGesture longPress) { longPressCalled = true; }
173
174 private: // From CustomActorImpl
175
176   virtual void OnStageConnection() { stageConnectionCalled = true; }
177   virtual void OnStageDisconnection() { stageDisconnectionCalled = true; }
178   virtual void OnChildAdd(Actor& child) { childAddCalled = true; }
179   virtual void OnChildRemove(Actor& child) { childRemoveCalled = true; }
180   virtual void OnSizeSet(const Vector3& targetSize) { sizeSetCalled = true; }
181   virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize) { sizeAnimationCalled = true; }
182   virtual bool OnTouchEvent(const TouchEvent& event) { touchEventCalled = true; return false; }
183   virtual bool OnMouseWheelEvent(const MouseWheelEvent& event) { mouseWheelEventCalled = true; return false; }
184   virtual bool OnKeyEvent(const KeyEvent& event) { keyEventCalled = true; return false;}
185   virtual void OnKeyInputFocusGained() { keyInputFocusGained = true; }
186   virtual void OnKeyInputFocusLost() { keyInputFocusLost = true; }
187
188 public:
189
190   bool initializeCalled;
191   bool themeChangeCalled;
192   bool fontChangeCalled;
193   bool pinchCalled;
194   bool panCalled;
195   bool tapCalled;
196   bool longPressCalled;
197   bool stageConnectionCalled;
198   bool stageDisconnectionCalled;
199   bool childAddCalled;
200   bool childRemoveCalled;
201   bool sizeSetCalled;
202   bool sizeAnimationCalled;
203   bool touchEventCalled;
204   bool mouseWheelEventCalled;
205   bool keyEventCalled;
206   bool keyInputFocusGained;
207   bool keyInputFocusLost;
208 };
209
210 DummyControl DummyControl::New( bool override )
211 {
212   DummyControl control;
213
214   if (override)
215   {
216     control = DummyControlImplOverride::New();
217   }
218   else
219   {
220     control = DummyControlImpl::New();
221   }
222
223   return control;
224 }
225
226 DummyControl::DummyControl( DummyControlImpl& implementation )
227 : Control( implementation )
228 {
229 }
230
231 DummyControl::DummyControl( Dali::Internal::CustomActor* internal )
232 : Control( internal )
233 {
234   VerifyCustomActorPointer<DummyControlImpl>(internal);
235 }
236
237 } // namespace Toolkit
238
239 } // namespace Dali
240
241 #endif // __DALI_TOOLKIT_TEST_DUMMY_CONTROL_H__