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 themeChangeCalled(false),
142 fontChangeCalled( false ),
146 longPressCalled(false),
147 stageConnectionCalled(false),
148 stageDisconnectionCalled(false),
149 childAddCalled(false),
150 childRemoveCalled(false),
151 sizeSetCalled(false),
152 sizeAnimationCalled(false),
153 touchEventCalled(false),
154 mouseWheelEventCalled(false),
155 keyEventCalled(false),
156 keyInputFocusGained(false),
157 keyInputFocusLost(false)
161 virtual ~DummyControlImplOverride() { }
163 private: // From ControlImpl
165 virtual void OnInitialize() { initializeCalled = true; }
166 virtual void OnThemeChange( StyleManager styleManager ) { themeChangeCalled = true }
167 virtual void OnFontChange( bool defaultFontChange, bool defaultFontSizeChange ) { fontChangeCalled = true;}
168 virtual void OnPinch(PinchGesture pinch) { pinchCalled = true; }
169 virtual void OnPan(PanGesture pan) { panCalled = true; }
170 virtual void OnTap(TapGesture tap) { tapCalled = true; }
171 virtual void OnLongPress(LongPressGesture longPress) { longPressCalled = true; }
173 private: // From CustomActorImpl
175 virtual void OnStageConnection() { stageConnectionCalled = true; }
176 virtual void OnStageDisconnection() { stageDisconnectionCalled = true; }
177 virtual void OnChildAdd(Actor& child) { childAddCalled = true; }
178 virtual void OnChildRemove(Actor& child) { childRemoveCalled = true; }
179 virtual void OnSizeSet(const Vector3& targetSize) { sizeSetCalled = true; }
180 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize) { sizeAnimationCalled = true; }
181 virtual bool OnTouchEvent(const TouchEvent& event) { touchEventCalled = true; return false; }
182 virtual bool OnMouseWheelEvent(const MouseWheelEvent& event) { mouseWheelEventCalled = true; return false; }
183 virtual bool OnKeyEvent(const KeyEvent& event) { keyEventCalled = true; return false;}
184 virtual void OnKeyInputFocusGained() { keyInputFocusGained = true; }
185 virtual void OnKeyInputFocusLost() { keyInputFocusLost = true; }
189 bool initializeCalled;
190 bool themeChangeCalled;
191 bool fontChangeCalled;
195 bool longPressCalled;
196 bool stageConnectionCalled;
197 bool stageDisconnectionCalled;
199 bool childRemoveCalled;
201 bool sizeAnimationCalled;
202 bool touchEventCalled;
203 bool mouseWheelEventCalled;
205 bool keyInputFocusGained;
206 bool keyInputFocusLost;
209 DummyControl DummyControl::New( bool override )
211 DummyControl control;
215 control = DummyControlImplOverride::New();
219 control = DummyControlImpl::New();
225 DummyControl::DummyControl( DummyControlImpl& implementation )
226 : Control( implementation )
230 DummyControl::DummyControl( Dali::Internal::CustomActor* internal )
231 : Control( internal )
233 VerifyCustomActorPointer<DummyControlImpl>(internal);
236 } // namespace Toolkit
240 #endif // __DALI_TOOLKIT_TEST_DUMMY_CONTROL_H__