(Vector) Reset the current frame when stopped
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / dummy-control.h
1 #ifndef __DALI_TOOLKIT_TEST_DUMMY_CONTROL_H__
2 #define __DALI_TOOLKIT_TEST_DUMMY_CONTROL_H__
3
4 /*
5  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/dali-toolkit.h>
23
24 // EXTERNAL INCLUDES
25 #include <functional>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 class DummyControlImpl;
34 class TransitionData;
35
36 namespace Visual
37 {
38 class Base;
39 }
40
41 /**
42  * Control does not have a New method so use this dummy class for the handle.
43  */
44 class DummyControl : public Control
45 {
46 public:
47   enum PropertyRange
48   {
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
51   };
52
53   struct Property
54   {
55     enum Type
56     {
57       TEST_VISUAL = PROPERTY_START_INDEX,
58       TEST_VISUAL2,
59       FOREGROUND_VISUAL,
60       FOCUS_VISUAL,
61       LABEL_VISUAL
62     };
63   };
64
65   DummyControl();
66   DummyControl(const DummyControl& control);
67   ~DummyControl();
68
69   static DummyControl New( bool override = false );
70
71   static DummyControl DownCast( BaseHandle handle );
72
73
74   DummyControl& operator=(const DummyControl& control);
75
76 public: // Not intended for application developers
77
78   DummyControl( DummyControlImpl& implementation );
79   DummyControl( Dali::Internal::CustomActor* internal );
80 };
81
82 /**
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.
85  */
86 class DummyControlImpl : public Toolkit::Internal::Control
87 {
88 public:
89
90   static DummyControl New();
91
92 public:
93   inline void EnableGestureDetection(Gesture::Type type) { Internal::Control::EnableGestureDetection(type); }
94   inline void DisableGestureDetection(Gesture::Type 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(); }
99
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 );
109
110   static void SetProperty( BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value );
111
112   static Property::Value GetProperty( BaseObject* object, Dali::Property::Index propertyIndex );
113
114   // Used to test signal connections
115   void CustomSlot1( Actor actor );
116
117   bool mCustomSlot1Called;
118   typedef std::vector<Property::Index> VisualIndices;
119   VisualIndices mRegisteredVisualIndices;
120
121 protected:
122
123   DummyControlImpl();
124
125   virtual ~DummyControlImpl();
126 };
127
128 namespace Impl
129 {
130
131 /**
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.
134  */
135 class DummyControl : public Toolkit::DummyControlImpl
136 {
137 public:
138
139   typedef std::function<void( Size )> RelayoutCallbackFunc;
140
141   static Toolkit::DummyControl New();
142
143   void SetLayout( Property::Index visualIndex, Property::Map& map );
144
145   void SetRelayoutCallback( RelayoutCallbackFunc callback );
146
147 private:
148
149   DummyControl();
150
151   virtual ~DummyControl();
152
153 private: // From Internal::Control
154
155   virtual void OnInitialize();
156   virtual bool OnAccessibilityActivated();
157   virtual bool OnAccessibilityTouch( const TouchEvent& touchEvent );
158   virtual bool OnAccessibilityValueChange( bool isIncrease );
159
160   virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change );
161   virtual void OnPinch(const PinchGesture& pinch);
162   virtual void OnPan(const PanGesture& pan);
163   virtual void OnTap(const TapGesture& tap);
164   virtual void OnLongPress(const LongPressGesture& longPress);
165   virtual Vector3 GetNaturalSize();
166
167 private: // From CustomActorImpl
168
169   virtual void OnStageConnection( int depth );
170   virtual void OnStageDisconnection();
171   virtual void OnChildAdd(Actor& child);
172   virtual void OnChildRemove(Actor& child);
173   virtual void OnSizeSet(const Vector3& targetSize);
174   virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize);
175   virtual bool OnTouchEvent(const TouchEvent& event);
176   virtual bool OnHoverEvent(const HoverEvent& event);
177   virtual bool OnWheelEvent(const WheelEvent& event);
178   virtual bool OnKeyEvent(const KeyEvent& event);
179   virtual void OnKeyInputFocusGained();
180   virtual void OnKeyInputFocusLost();
181   virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
182
183   DALI_INTERNAL DummyControl( const DummyControl& );
184   DALI_INTERNAL DummyControl& operator=( const DummyControl& );
185
186 public:
187
188   bool initializeCalled;
189   bool activatedCalled;
190   bool onAccTouchedCalled;
191   bool onAccValueChangeCalled;
192   bool themeChangeCalled;
193   bool fontChangeCalled;
194   bool pinchCalled;
195   bool panCalled;
196   bool tapCalled;
197   bool longPressCalled;
198   bool stageConnectionCalled;
199   bool stageDisconnectionCalled;
200   bool childAddCalled;
201   bool childRemoveCalled;
202   bool sizeSetCalled;
203   bool sizeAnimationCalled;
204   bool touchEventCalled;
205   bool hoverEventCalled;
206   bool wheelEventCalled;
207   bool keyEventCalled;
208   bool keyInputFocusGained;
209   bool keyInputFocusLost;
210   static int constructorCount;
211   static int destructorCount;
212
213   Property::Map mLayouts;
214   RelayoutCallbackFunc mRelayoutCallback;
215
216 };
217
218 } // namespace Impl
219
220 } // namespace Toolkit
221
222 } // namespace Dali
223
224 #endif // __DALI_TOOLKIT_TEST_DUMMY_CONTROL_H__