Revert "License conversion from Flora to Apache 2.0"
[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 Flora License, Version 1.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://floralicense.org/license/
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 // INTERNAL INCLUDES
21 #include <dali-toolkit/dali-toolkit.h>
22
23 namespace Dali
24 {
25
26 namespace Toolkit
27 {
28
29 class DummyControlImpl;
30
31 /**
32  * Control does not have a New method so use this dummy class for the handle.
33  */
34 class DummyControl : public Control
35 {
36 public:
37
38   DummyControl()
39   : mCustomSlot1Called(false)
40   {
41   }
42
43   DummyControl(const DummyControl& control)
44   : Control( control ),
45     mCustomSlot1Called(false)
46   {
47   }
48
49   virtual ~DummyControl()
50   {
51   }
52
53   static DummyControl New( bool override = false );
54
55   static DummyControl DownCast( BaseHandle handle )
56   {
57     return Control::DownCast<DummyControl, DummyControlImpl>(handle);
58   }
59
60   DummyControl& operator=(const DummyControl& control)
61   {
62     Control::operator=( control );
63     return *this;
64   }
65
66   // Used to test signal connections
67   void CustomSlot1( Actor actor, const Vector3& value )
68   {
69     mCustomSlot1Called = true;
70     mCustomSlot1Value = value;
71   }
72
73 public:
74
75   bool mCustomSlot1Called;
76   Vector3 mCustomSlot1Value;
77
78 public: // Not intended for application developers
79
80   DummyControl( DummyControlImpl& implementation );
81   DummyControl( Dali::Internal::CustomActor* internal );
82 };
83
84 /**
85  * Cannot create an instance of ControlImpl, so use this dummy class for the implementation.
86  * This class does not override any of ControlImpl's behaviour.
87  */
88 class DummyControlImpl : public ControlImpl
89 {
90 public:
91
92   static DummyControl New()
93   {
94     IntrusivePtr< DummyControlImpl > impl = new DummyControlImpl;
95     DummyControl control( *impl );
96     impl->Initialize();
97     return control;
98   }
99
100 public:
101   void EnableGestureDetection(Gesture::Type type) { ControlImpl::EnableGestureDetection(type); }
102   void DisableGestureDetection(Gesture::Type type) { ControlImpl::DisableGestureDetection(type); }
103   PinchGestureDetector GetPinchGestureDetector() const { return ControlImpl::GetPinchGestureDetector(); }
104   PanGestureDetector GetPanGestureDetector() const { return ControlImpl::GetPanGestureDetector(); }
105   TapGestureDetector GetTapGestureDetector() const { return ControlImpl::GetTapGestureDetector(); }
106   LongPressGestureDetector GetLongPressGestureDetector() const { return ControlImpl::GetLongPressGestureDetector(); }
107
108 protected:
109
110   DummyControlImpl()
111   : ControlImpl(true)
112   {
113   }
114
115   virtual ~DummyControlImpl()
116   {
117   }
118 };
119
120 /**
121  * Cannot create an instance of ControlImpl, so use this dummy class for the implementation.
122  * This class DOES override ControlImpl's behaviour.
123  */
124 class DummyControlImplOverride : public DummyControlImpl
125 {
126 public:
127
128   static DummyControl New()
129   {
130     IntrusivePtr< DummyControlImplOverride > impl = new DummyControlImplOverride;
131     DummyControl control( *impl );
132     impl->Initialize();
133     return control;
134   }
135
136 private:
137
138   DummyControlImplOverride()
139   : DummyControlImpl(),
140     initializeCalled(false),
141     styleChangeCalled(false),
142     pinchCalled(false),
143     panCalled(false),
144     tapCalled(false),
145     longPressCalled(false),
146     stageConnectionCalled(false),
147     stageDisconnectionCalled(false),
148     childAddCalled(false),
149     childRemoveCalled(false),
150     sizeSetCalled(false),
151     sizeAnimationCalled(false),
152     touchEventCalled(false),
153     mouseWheelEventCalled(false),
154     keyEventCalled(false),
155     keyInputFocusGained(false),
156     keyInputFocusLost(false)
157   {
158   }
159
160   virtual ~DummyControlImplOverride() { }
161
162 private: // From ControlImpl
163
164   virtual void OnInitialize() { initializeCalled = true; }
165   virtual void OnStyleChange(StyleChange change) { styleChangeCalled = true;}
166   virtual void OnPinch(PinchGesture pinch) { pinchCalled = true; }
167   virtual void OnPan(PanGesture pan) { panCalled = true; }
168   virtual void OnTap(TapGesture tap) { tapCalled = true; }
169   virtual void OnLongPress(LongPressGesture longPress) { longPressCalled = true; }
170
171 private: // From CustomActorImpl
172
173   virtual void OnStageConnection() { stageConnectionCalled = true; }
174   virtual void OnStageDisconnection() { stageDisconnectionCalled = true; }
175   virtual void OnChildAdd(Actor& child) { childAddCalled = true; }
176   virtual void OnChildRemove(Actor& child) { childRemoveCalled = true; }
177   virtual void OnSizeSet(const Vector3& targetSize) { sizeSetCalled = true; }
178   virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize) { sizeAnimationCalled = true; }
179   virtual bool OnTouchEvent(const TouchEvent& event) { touchEventCalled = true; return false; }
180   virtual bool OnMouseWheelEvent(const MouseWheelEvent& event) { mouseWheelEventCalled = true; return false; }
181   virtual bool OnKeyEvent(const KeyEvent& event) { keyEventCalled = true; return false;}
182   virtual void OnKeyInputFocusGained() { keyInputFocusGained = true; }
183   virtual void OnKeyInputFocusLost() { keyInputFocusLost = true; }
184
185 public:
186
187   bool initializeCalled;
188   bool styleChangeCalled;
189   bool pinchCalled;
190   bool panCalled;
191   bool tapCalled;
192   bool longPressCalled;
193   bool stageConnectionCalled;
194   bool stageDisconnectionCalled;
195   bool childAddCalled;
196   bool childRemoveCalled;
197   bool sizeSetCalled;
198   bool sizeAnimationCalled;
199   bool touchEventCalled;
200   bool mouseWheelEventCalled;
201   bool keyEventCalled;
202   bool keyInputFocusGained;
203   bool keyInputFocusLost;
204 };
205
206 DummyControl DummyControl::New( bool override )
207 {
208   DummyControl control;
209
210   if (override)
211   {
212     control = DummyControlImplOverride::New();
213   }
214   else
215   {
216     control = DummyControlImpl::New();
217   }
218
219   return control;
220 }
221
222 DummyControl::DummyControl( DummyControlImpl& implementation )
223 : Control( implementation )
224 {
225 }
226
227 DummyControl::DummyControl( Dali::Internal::CustomActor* internal )
228 : Control( internal )
229 {
230   VerifyCustomActorPointer<DummyControlImpl>(internal);
231 }
232
233 } // namespace Toolkit
234
235 } // namespace Dali
236
237 #endif // __DALI_TOOLKIT_TEST_DUMMY_CONTROL_H__