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