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