1 #ifndef DALI_TOOLKIT_TEST_DUMMY_CONTROL_H
2 #define DALI_TOOLKIT_TEST_DUMMY_CONTROL_H
5 * Copyright (c) 2020 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>
33 class DummyControlImpl;
42 * Control does not have a New method so use this dummy class for the handle.
44 class DummyControl : public Control
49 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @SINCE_1_0.0
50 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property index
57 TEST_VISUAL = PROPERTY_START_INDEX,
66 DummyControl(const DummyControl& control);
69 static DummyControl New( bool override = false );
71 static DummyControl DownCast( BaseHandle handle );
74 DummyControl& operator=(const DummyControl& control);
76 public: // Not intended for application developers
78 DummyControl( DummyControlImpl& implementation );
79 DummyControl( Dali::Internal::CustomActor* internal );
83 * Cannot create an instance of Internal::Control, so use this dummy class for the implementation.
84 * This class does not override any of Internal::Control's behaviour.
86 class DummyControlImpl : public Toolkit::Internal::Control
90 static DummyControl New();
93 inline void EnableGestureDetection(GestureType::Value type) { Internal::Control::EnableGestureDetection(type); }
94 inline void DisableGestureDetection(GestureType::Value type) { Internal::Control::DisableGestureDetection(type); }
95 inline PinchGestureDetector GetPinchGestureDetector() const { return Internal::Control::GetPinchGestureDetector(); }
96 inline PanGestureDetector GetPanGestureDetector() const { return Internal::Control::GetPanGestureDetector(); }
97 inline TapGestureDetector GetTapGestureDetector() const { return Internal::Control::GetTapGestureDetector(); }
98 inline LongPressGestureDetector GetLongPressGestureDetector() const { return Internal::Control::GetLongPressGestureDetector(); }
100 void RegisterVisual( Property::Index index, Toolkit::Visual::Base visual);
101 void RegisterVisual( Property::Index index, Toolkit::Visual::Base visual, bool enabled );
102 void UnregisterVisual( Property::Index index );
103 void EnableVisual( Property::Index index, bool enabled );
104 bool IsVisualEnabled( Property::Index index );
105 int GetVisualCount();
106 Toolkit::Visual::Base GetVisual( Property::Index index );
107 Animation CreateTransition( const Toolkit::TransitionData& transition );
108 void DoAction( Dali::Property::Index index, Dali::Property::Index action, const Dali::Property::Value attributes );
110 static void SetProperty( BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value );
112 static Property::Value GetProperty( BaseObject* object, Dali::Property::Index propertyIndex );
114 // Used to test signal connections
115 void CustomSlot1( Actor actor );
117 bool mCustomSlot1Called;
118 typedef std::vector<Property::Index> VisualIndices;
119 VisualIndices mRegisteredVisualIndices;
125 ~DummyControlImpl() override;
132 * Cannot create an instance of Internal::Control, so use this dummy class for the implementation.
133 * This class DOES override Internal::Control's behaviour.
135 class DummyControl : public Toolkit::DummyControlImpl
139 typedef std::function<void( Size )> RelayoutCallbackFunc;
141 static Toolkit::DummyControl New();
143 void SetLayout( Property::Index visualIndex, Property::Map& map );
145 void SetRelayoutCallback( RelayoutCallbackFunc callback );
151 ~DummyControl() override;
153 private: // From Internal::Control
155 void OnInitialize() override;
156 bool OnAccessibilityActivated() override;
157 bool OnAccessibilityValueChange( bool isIncrease ) override;
159 void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change ) override;
160 void OnPinch(const PinchGesture& pinch) override;
161 void OnPan(const PanGesture& pan) override;
162 void OnTap(const TapGesture& tap) override;
163 void OnLongPress(const LongPressGesture& longPress) override;
164 Vector3 GetNaturalSize() override;
165 bool OnKeyEvent(const KeyEvent& event) override;
167 private: // From CustomActorImpl
169 void OnSceneConnection( int depth ) override;
170 void OnSceneDisconnection() override;
171 void OnChildAdd(Actor& child) override;
172 void OnChildRemove(Actor& child) override;
173 void OnSizeSet(const Vector3& targetSize) override;
174 void OnSizeAnimation(Animation& animation, const Vector3& targetSize) override;
175 void OnKeyInputFocusGained() override;
176 void OnKeyInputFocusLost() override;
177 void OnRelayout( const Vector2& size, RelayoutContainer& container ) override;
179 DALI_INTERNAL DummyControl( const DummyControl& );
180 DALI_INTERNAL DummyControl& operator=( const DummyControl& );
184 bool initializeCalled;
185 bool activatedCalled;
186 bool onAccValueChangeCalled;
187 bool themeChangeCalled;
188 bool fontChangeCalled;
192 bool longPressCalled;
193 bool stageConnectionCalled;
194 bool stageDisconnectionCalled;
196 bool childRemoveCalled;
198 bool sizeAnimationCalled;
199 bool hoverEventCalled;
200 bool wheelEventCalled;
202 bool keyInputFocusGained;
203 bool keyInputFocusLost;
204 static int constructorCount;
205 static int destructorCount;
207 Property::Map mLayouts;
208 RelayoutCallbackFunc mRelayoutCallback;
214 } // namespace Toolkit
218 #endif // DALI_TOOLKIT_TEST_DUMMY_CONTROL_H