1 #ifndef __DALI_TOOLKIT_TEST_DUMMY_CONTROL_H__
2 #define __DALI_TOOLKIT_TEST_DUMMY_CONTROL_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 // http://floralicense.org/license/
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.
21 #include <dali-toolkit/dali-toolkit.h>
29 class DummyControlImpl;
32 * Control does not have a New method so use this dummy class for the handle.
34 class DummyControl : public Control
39 : mCustomSlot1Called(false)
43 DummyControl(const DummyControl& control)
45 mCustomSlot1Called(false)
49 virtual ~DummyControl()
53 static DummyControl New( bool override = false );
55 static DummyControl DownCast( BaseHandle handle )
57 return Control::DownCast<DummyControl, DummyControlImpl>(handle);
60 DummyControl& operator=(const DummyControl& control)
62 Control::operator=( control );
66 // Used to test signal connections
67 void CustomSlot1( Actor actor, const Vector3& value )
69 mCustomSlot1Called = true;
70 mCustomSlot1Value = value;
75 bool mCustomSlot1Called;
76 Vector3 mCustomSlot1Value;
78 public: // Not intended for application developers
80 DummyControl( DummyControlImpl& implementation );
81 DummyControl( Dali::Internal::CustomActor* internal );
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.
88 class DummyControlImpl : public ControlImpl
92 static DummyControl New()
94 IntrusivePtr< DummyControlImpl > impl = new DummyControlImpl;
95 DummyControl control( *impl );
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(); }
115 virtual ~DummyControlImpl()
121 * Cannot create an instance of ControlImpl, so use this dummy class for the implementation.
122 * This class DOES override ControlImpl's behaviour.
124 class DummyControlImplOverride : public DummyControlImpl
128 static DummyControl New()
130 IntrusivePtr< DummyControlImplOverride > impl = new DummyControlImplOverride;
131 DummyControl control( *impl );
138 DummyControlImplOverride()
139 : DummyControlImpl(),
140 initializeCalled(false),
141 styleChangeCalled(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)
160 virtual ~DummyControlImplOverride() { }
162 private: // From ControlImpl
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; }
171 private: // From CustomActorImpl
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; }
187 bool initializeCalled;
188 bool styleChangeCalled;
192 bool longPressCalled;
193 bool stageConnectionCalled;
194 bool stageDisconnectionCalled;
196 bool childRemoveCalled;
198 bool sizeAnimationCalled;
199 bool touchEventCalled;
200 bool mouseWheelEventCalled;
202 bool keyInputFocusGained;
203 bool keyInputFocusLost;
206 DummyControl DummyControl::New( bool override )
208 DummyControl control;
212 control = DummyControlImplOverride::New();
216 control = DummyControlImpl::New();
222 DummyControl::DummyControl( DummyControlImpl& implementation )
223 : Control( implementation )
227 DummyControl::DummyControl( Dali::Internal::CustomActor* internal )
228 : Control( internal )
230 VerifyCustomActorPointer<DummyControlImpl>(internal);
233 } // namespace Toolkit
237 #endif // __DALI_TOOLKIT_TEST_DUMMY_CONTROL_H__