(TextInput) Don't show grab handle when edit modes starts until actually needed
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-adaptor.h
1 #ifndef __DALI_TOOLKIT_TOOLKIT_ADAPTOR_H__
2 #define __DALI_TOOLKIT_TOOLKIT_ADAPTOR_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 // EXTERNAL INCLUDES
22 #include <boost/function.hpp>
23
24 // INTERNAL INCLUDES
25 #include "toolkit-style-monitor.h"
26 #include "toolkit-accessibility-manager.h"
27 #include "toolkit-timer.h"
28 #include "toolkit-imf-manager.h"
29 #include "toolkit-clipboard-event-notifier.h"
30
31 #include <dali/public-api/events/touch-point.h>
32 #include <dali/public-api/math/rect.h>
33
34 namespace Dali
35 {
36
37 class Adaptor;
38
39 typedef Dali::Rect<int> PositionSize;
40
41 /**
42  * This creates a stubbed Adaptor so that internal Toolkit Adaptor calls work.
43  * Furthermore, it provides an interface to see if certain methods were invoked.
44  */
45 class ToolkitAdaptor
46 {
47 public: // Construction & Destruction
48
49   ToolkitAdaptor();
50   ~ToolkitAdaptor();
51
52 public: // Getters
53
54   boost::function<void(void)> GetLastIdleAdded() const
55   {
56     return mLastIdleAdded;
57   }
58
59   TouchPoint GetLastTouchPointFed() const
60   {
61     return mLastTouchPointFed;
62   }
63
64   int GetLastTimeStampFed() const
65   {
66     return mLastTimeStampFed;
67   }
68
69   PositionSize GetLastSizeSet() const
70   {
71     return mLastSizeSet;
72   }
73
74   StyleMonitor& GetToolkitStyleMonitor()
75   {
76     return mStyleMonitor;
77   }
78
79   AccessibilityManager& GetAccessibilityManager()
80   {
81     return mAccessibilityManager;
82   }
83
84   ToolkitClipboardEventNotifier& GetClipboardEventNotifier()
85   {
86     return mClipboardEventNotifier;
87   }
88
89 public: // Signal Emissions
90
91   void EmitSignalResize();
92
93 public: // TEST FUNCTIONS
94
95   // Enumeration of Adaptor methods
96   enum TestFuncEnum
97   {
98     StartType,
99     PauseType,
100     ResumeType,
101     StopType,
102     AddIdleType,
103     FeedEventType,
104     MoveResizeType,
105     SurfaceResizedType,
106     ReplaceSurfaceType,
107     RenderSyncType,
108     GetSurfaceType,
109     GetType,
110     IsAvailableType,
111     RegisterSingletonType,
112     GetSingletonType,
113     SignalResizeType,
114   };
115
116   void Reset()
117   {
118     mFunctionsCalled.Reset();
119   }
120
121   bool WasCalled(TestFuncEnum func)
122   {
123     switch(func)
124     {
125       case StartType:                             return mFunctionsCalled.Start;
126       case PauseType:                             return mFunctionsCalled.Pause;
127       case ResumeType:                            return mFunctionsCalled.Resume;
128       case StopType:                              return mFunctionsCalled.Stop;
129       case AddIdleType:                           return mFunctionsCalled.AddIdle;
130       case FeedEventType:                         return mFunctionsCalled.FeedEvent;
131       case MoveResizeType:                        return mFunctionsCalled.MoveResize;
132       case SurfaceResizedType:                    return mFunctionsCalled.SurfaceResized;
133       case ReplaceSurfaceType:                    return mFunctionsCalled.ReplaceSurface;
134       case RenderSyncType:                        return mFunctionsCalled.RenderSync;
135       case GetSurfaceType:                        return mFunctionsCalled.GetSurface;
136       case GetType:                               return mFunctionsCalled.Get;
137       case IsAvailableType:                       return mFunctionsCalled.IsAvailable;
138       case RegisterSingletonType:                 return mFunctionsCalled.RegisterSingleton;
139       case GetSingletonType:                      return mFunctionsCalled.GetSingleton;
140       case SignalResizeType:                      return mFunctionsCalled.SignalResize;
141     }
142     return false;
143   }
144
145   void ResetCallStatistics(TestFuncEnum func)
146   {
147     switch(func)
148     {
149       case StartType:                             mFunctionsCalled.Start = false; break;
150       case PauseType:                             mFunctionsCalled.Pause = false; break;
151       case ResumeType:                            mFunctionsCalled.Resume = false; break;
152       case StopType:                              mFunctionsCalled.Stop = false; break;
153       case AddIdleType:                           mFunctionsCalled.AddIdle = false; break;
154       case FeedEventType:                         mFunctionsCalled.FeedEvent = false; break;
155       case MoveResizeType:                        mFunctionsCalled.MoveResize = false; break;
156       case SurfaceResizedType:                    mFunctionsCalled.SurfaceResized = false; break;
157       case ReplaceSurfaceType:                    mFunctionsCalled.ReplaceSurface = false; break;
158       case RenderSyncType:                        mFunctionsCalled.RenderSync = false; break;
159       case GetSurfaceType:                        mFunctionsCalled.GetSurface = false; break;
160       case GetType:                               mFunctionsCalled.Get = false; break;
161       case IsAvailableType:                       mFunctionsCalled.IsAvailable = false; break;
162       case RegisterSingletonType:                 mFunctionsCalled.RegisterSingleton = false; break;
163       case GetSingletonType:                      mFunctionsCalled.GetSingleton = false; break;
164       case SignalResizeType:                      mFunctionsCalled.SignalResize = false; break;
165     }
166   }
167
168 private:
169
170   struct TestFunctions
171   {
172     TestFunctions()
173     : Start(false),
174       Pause(false),
175       Resume(false),
176       Stop(false),
177       AddIdle(false),
178       FeedEvent(false),
179       MoveResize(false),
180       SurfaceResized(false),
181       ReplaceSurface(false),
182       RenderSync(false),
183       GetSurface(false),
184       Get(false),
185       IsAvailable(false),
186       RegisterSingleton(false),
187       GetSingleton(false),
188       SignalResize(false)
189     {
190     }
191
192     void Reset()
193     {
194       Start = false;
195       Pause = false;
196       Resume = false;
197       Stop = false;
198       AddIdle = false;
199       FeedEvent = false;
200       MoveResize = false;
201       SurfaceResized = false;
202       ReplaceSurface = false;
203       RenderSync = false;
204       GetSurface = false;
205       Get = false;
206       IsAvailable = false;
207       RegisterSingleton = false;
208       GetSingleton = false;
209       SignalResize = false;
210     }
211
212     bool Start;
213     bool Pause;
214     bool Resume;
215     bool Stop;
216     bool AddIdle;
217     bool FeedEvent;
218     bool MoveResize;
219     bool SurfaceResized;
220     bool ReplaceSurface;
221     bool RenderSync;
222     bool GetSurface;
223     bool Get;
224     bool IsAvailable;
225     bool RegisterSingleton;
226     bool GetSingleton;
227     bool SignalResize;
228   };
229
230   TestFunctions mFunctionsCalled;
231
232   // Last set information
233   boost::function<void(void)> mLastIdleAdded;
234   TouchPoint mLastTouchPointFed;
235   int mLastTimeStampFed;
236   PositionSize mLastSizeSet;
237
238   // Contains Test functions for the Style Monitor
239   StyleMonitor mStyleMonitor;
240
241   // Stub for AccessibilityManager
242   AccessibilityManager mAccessibilityManager;
243
244   // Stub for ClipboardEventNotifier
245   ToolkitClipboardEventNotifier mClipboardEventNotifier;
246
247   ImfManager mImfManager;
248
249   // The Adaptor Stub
250   Adaptor* mAdaptorStub;
251   friend class Adaptor;
252 };
253
254 } // namespace Dali
255
256 #endif // __DALI_TOOLKIT_TOOLKIT_ADAPTOR_H__