(ControlImpl) Move Visual related APIs to the Devel API
[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 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 class DummyControlImpl;
31 class TransitionData;
32
33 namespace Visual
34 {
35 class Base;
36 }
37
38 /**
39  * Control does not have a New method so use this dummy class for the handle.
40  */
41 class DummyControl : public Control
42 {
43 public:
44   enum PropertyRange
45   {
46     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @SINCE_1_0.0
47     PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000              ///< Reserve property index
48   };
49
50   struct Property
51   {
52     enum Type
53     {
54       TEST_VISUAL = PROPERTY_START_INDEX,
55       TEST_VISUAL2,
56       FOREGROUND_VISUAL,
57       FOCUS_VISUAL,
58       LABEL_VISUAL
59     };
60   };
61
62   DummyControl();
63   DummyControl(const DummyControl& control);
64   ~DummyControl();
65
66   static DummyControl New( bool override = false );
67
68   static DummyControl DownCast( BaseHandle handle );
69
70
71   DummyControl& operator=(const DummyControl& control);
72
73 public: // Not intended for application developers
74
75   DummyControl( DummyControlImpl& implementation );
76   DummyControl( Dali::Internal::CustomActor* internal );
77 };
78
79 /**
80  * Cannot create an instance of Internal::Control, so use this dummy class for the implementation.
81  * This class does not override any of Internal::Control's behaviour.
82  */
83 class DummyControlImpl : public Toolkit::Internal::Control
84 {
85 public:
86
87   static DummyControl New();
88
89 public:
90   inline void EnableGestureDetection(Gesture::Type type) { Internal::Control::EnableGestureDetection(type); }
91   inline void DisableGestureDetection(Gesture::Type type) { Internal::Control::DisableGestureDetection(type); }
92   inline PinchGestureDetector GetPinchGestureDetector() const { return Internal::Control::GetPinchGestureDetector(); }
93   inline PanGestureDetector GetPanGestureDetector() const { return Internal::Control::GetPanGestureDetector(); }
94   inline TapGestureDetector GetTapGestureDetector() const { return Internal::Control::GetTapGestureDetector(); }
95   inline LongPressGestureDetector GetLongPressGestureDetector() const { return Internal::Control::GetLongPressGestureDetector(); }
96
97   void RegisterVisual( Property::Index index, Toolkit::Visual::Base visual);
98   void RegisterVisual( Property::Index index, Toolkit::Visual::Base visual, bool enabled );
99   void UnregisterVisual( Property::Index index );
100   void EnableVisual( Property::Index index, bool enabled );
101   bool IsVisualEnabled( Property::Index index );
102   int GetVisualCount();
103   Toolkit::Visual::Base GetVisual( Property::Index index );
104   Animation CreateTransition( const Toolkit::TransitionData& transition );
105
106   static void SetProperty( BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value );
107
108   static Property::Value GetProperty( BaseObject* object, Dali::Property::Index propertyIndex );
109
110   // Used to test signal connections
111   void CustomSlot1( Actor actor );
112
113   bool mCustomSlot1Called;
114   typedef std::vector<Property::Index> VisualIndices;
115   VisualIndices mRegisteredVisualIndices;
116
117 protected:
118
119   DummyControlImpl();
120
121   virtual ~DummyControlImpl();
122 };
123
124 namespace Impl
125 {
126
127 /**
128  * Cannot create an instance of Internal::Control, so use this dummy class for the implementation.
129  * This class DOES override Internal::Control's behaviour.
130  */
131 class DummyControl : public Toolkit::DummyControlImpl
132 {
133 public:
134
135   static Toolkit::DummyControl New();
136
137   void SetLayout( Property::Index visualIndex, Property::Map& map );
138
139 private:
140
141   DummyControl();
142
143   virtual ~DummyControl();
144
145 private: // From Internal::Control
146
147   virtual void OnInitialize();
148   virtual bool OnAccessibilityActivated();
149   virtual bool OnAccessibilityTouch( const TouchEvent& touchEvent );
150   virtual bool OnAccessibilityValueChange( bool isIncrease );
151
152   virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change );
153   virtual void OnPinch(const PinchGesture& pinch);
154   virtual void OnPan(const PanGesture& pan);
155   virtual void OnTap(const TapGesture& tap);
156   virtual void OnLongPress(const LongPressGesture& longPress);
157
158 private: // From CustomActorImpl
159
160   virtual void OnStageConnection( int depth );
161   virtual void OnStageDisconnection();
162   virtual void OnChildAdd(Actor& child);
163   virtual void OnChildRemove(Actor& child);
164   virtual void OnSizeSet(const Vector3& targetSize);
165   virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize);
166   virtual bool OnTouchEvent(const TouchEvent& event);
167   virtual bool OnHoverEvent(const HoverEvent& event);
168   virtual bool OnWheelEvent(const WheelEvent& event);
169   virtual bool OnKeyEvent(const KeyEvent& event);
170   virtual void OnKeyInputFocusGained();
171   virtual void OnKeyInputFocusLost();
172   virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
173
174   DALI_INTERNAL DummyControl( const DummyControl& );
175   DALI_INTERNAL DummyControl& operator=( const DummyControl& );
176
177 public:
178
179   bool initializeCalled;
180   bool activatedCalled;
181   bool onAccTouchedCalled;
182   bool onAccValueChangeCalled;
183   bool themeChangeCalled;
184   bool fontChangeCalled;
185   bool pinchCalled;
186   bool panCalled;
187   bool tapCalled;
188   bool longPressCalled;
189   bool stageConnectionCalled;
190   bool stageDisconnectionCalled;
191   bool childAddCalled;
192   bool childRemoveCalled;
193   bool sizeSetCalled;
194   bool sizeAnimationCalled;
195   bool touchEventCalled;
196   bool hoverEventCalled;
197   bool wheelEventCalled;
198   bool keyEventCalled;
199   bool keyInputFocusGained;
200   bool keyInputFocusLost;
201
202   Property::Map mLayouts;
203 };
204
205 } // namespace Impl
206
207 } // namespace Toolkit
208
209 } // namespace Dali
210
211 #endif // __DALI_TOOLKIT_TEST_DUMMY_CONTROL_H__