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 styleChangeCalled(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 OnStyleChange(StyleChange change) { styleChangeCalled = true;}
167 virtual void OnPinch(PinchGesture pinch) { pinchCalled = true; }
168 virtual void OnPan(PanGesture pan) { panCalled = true; }
169 virtual void OnTap(TapGesture tap) { tapCalled = true; }
170 virtual void OnLongPress(LongPressGesture longPress) { longPressCalled = true; }
172 private: // From CustomActorImpl
174 virtual void OnStageConnection() { stageConnectionCalled = true; }
175 virtual void OnStageDisconnection() { stageDisconnectionCalled = true; }
176 virtual void OnChildAdd(Actor& child) { childAddCalled = true; }
177 virtual void OnChildRemove(Actor& child) { childRemoveCalled = true; }
178 virtual void OnSizeSet(const Vector3& targetSize) { sizeSetCalled = true; }
179 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize) { sizeAnimationCalled = true; }
180 virtual bool OnTouchEvent(const TouchEvent& event) { touchEventCalled = true; return false; }
181 virtual bool OnMouseWheelEvent(const MouseWheelEvent& event) { mouseWheelEventCalled = true; return false; }
182 virtual bool OnKeyEvent(const KeyEvent& event) { keyEventCalled = true; return false;}
183 virtual void OnKeyInputFocusGained() { keyInputFocusGained = true; }
184 virtual void OnKeyInputFocusLost() { keyInputFocusLost = true; }
188 bool initializeCalled;
189 bool styleChangeCalled;
193 bool longPressCalled;
194 bool stageConnectionCalled;
195 bool stageDisconnectionCalled;
197 bool childRemoveCalled;
199 bool sizeAnimationCalled;
200 bool touchEventCalled;
201 bool mouseWheelEventCalled;
203 bool keyInputFocusGained;
204 bool keyInputFocusLost;
207 DummyControl DummyControl::New( bool override )
209 DummyControl control;
213 control = DummyControlImplOverride::New();
217 control = DummyControlImpl::New();
223 DummyControl::DummyControl( DummyControlImpl& implementation )
224 : Control( implementation )
228 DummyControl::DummyControl( Dali::Internal::CustomActor* internal )
229 : Control( internal )
231 VerifyCustomActorPointer<DummyControlImpl>(internal);
234 } // namespace Toolkit
238 #endif // __DALI_TOOLKIT_TEST_DUMMY_CONTROL_H__