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 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali-toolkit/dali-toolkit.h>
30 class DummyControlImpl;
33 * Control does not have a New method so use this dummy class for the handle.
35 class DummyControl : public Control
40 : mCustomSlot1Called(false)
44 DummyControl(const DummyControl& control)
46 mCustomSlot1Called(false)
50 virtual ~DummyControl()
54 static DummyControl New( bool override = false );
56 static DummyControl DownCast( BaseHandle handle )
58 return Control::DownCast<DummyControl, DummyControlImpl>(handle);
61 DummyControl& operator=(const DummyControl& control)
63 Control::operator=( control );
67 // Used to test signal connections
68 void CustomSlot1( Actor actor, const Vector3& value )
70 mCustomSlot1Called = true;
71 mCustomSlot1Value = value;
76 bool mCustomSlot1Called;
77 Vector3 mCustomSlot1Value;
79 public: // Not intended for application developers
81 DummyControl( DummyControlImpl& implementation );
82 DummyControl( Dali::Internal::CustomActor* internal );
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.
89 class DummyControlImpl : public ControlImpl
93 static DummyControl New()
95 IntrusivePtr< DummyControlImpl > impl = new DummyControlImpl;
96 DummyControl control( *impl );
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(); }
116 virtual ~DummyControlImpl()
122 * Cannot create an instance of ControlImpl, so use this dummy class for the implementation.
123 * This class DOES override ControlImpl's behaviour.
125 class DummyControlImplOverride : public DummyControlImpl
129 static DummyControl New()
131 IntrusivePtr< DummyControlImplOverride > impl = new DummyControlImplOverride;
132 DummyControl control( *impl );
139 DummyControlImplOverride()
140 : DummyControlImpl(),
141 initializeCalled(false),
142 themeChangeCalled(false),
143 fontChangeCalled( 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)
162 virtual ~DummyControlImplOverride() { }
164 private: // From ControlImpl
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; }
174 private: // From CustomActorImpl
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; }
190 bool initializeCalled;
191 bool themeChangeCalled;
192 bool fontChangeCalled;
196 bool longPressCalled;
197 bool stageConnectionCalled;
198 bool stageDisconnectionCalled;
200 bool childRemoveCalled;
202 bool sizeAnimationCalled;
203 bool touchEventCalled;
204 bool mouseWheelEventCalled;
206 bool keyInputFocusGained;
207 bool keyInputFocusLost;
210 DummyControl DummyControl::New( bool override )
212 DummyControl control;
216 control = DummyControlImplOverride::New();
220 control = DummyControlImpl::New();
226 DummyControl::DummyControl( DummyControlImpl& implementation )
227 : Control( implementation )
231 DummyControl::DummyControl( Dali::Internal::CustomActor* internal )
232 : Control( internal )
234 VerifyCustomActorPointer<DummyControlImpl>(internal);
237 } // namespace Toolkit
241 #endif // __DALI_TOOLKIT_TEST_DUMMY_CONTROL_H__