Changed signal order for StyleManager
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-accessibility-adaptor.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include "toolkit-accessibility-adaptor.h"
19
20 #include <dali/public-api/object/base-object.h>
21 #include <dali/public-api/object/base-object.h>
22 #include <dali/devel-api/adaptor-framework/accessibility-action-handler.h>
23
24 namespace Dali
25 {
26
27 namespace Internal
28 {
29
30 namespace Adaptor
31 {
32
33 /**
34  * Stub for the AccessibilityAdaptor
35  */
36 class AccessibilityAdaptor : public BaseObject
37 {
38 public: // Creation & Destruction
39
40   static Dali::AccessibilityAdaptor Get();
41
42   AccessibilityAdaptor();
43   ~AccessibilityAdaptor();
44
45 public:
46
47   // Functions to modify mock returns:
48
49   void MockSetReadPosition( Vector2& position );
50
51 public:
52
53   bool IsEnabled() const;
54   void SetActionHandler(Dali::AccessibilityActionHandler& handler);
55   void SetGestureHandler(Dali::AccessibilityGestureHandler& handler);
56
57   Vector2 GetReadPosition() const;
58
59   bool HandleActionNextEvent();
60   bool HandleActionPreviousEvent();
61   bool HandleActionActivateEvent();
62   bool HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain);
63   bool HandleActionReadNextEvent();
64   bool HandleActionReadPreviousEvent();
65   bool HandleActionUpEvent();
66   bool HandleActionDownEvent();
67   bool HandleActionClearFocusEvent();
68   bool HandleActionScrollEvent(TouchPoint& point, unsigned long timeStamp);
69   bool HandleActionBackEvent();
70   bool HandleActionEnableEvent();
71   bool HandleActionDisableEvent();
72   bool HandleActionScrollUpEvent();
73   bool HandleActionScrollDownEvent();
74   bool HandleActionPageLeftEvent();
75   bool HandleActionPageRightEvent();
76   bool HandleActionPageUpEvent();
77   bool HandleActionPageDownEvent();
78   bool HandleActionMoveToFirstEvent();
79   bool HandleActionMoveToLastEvent();
80   bool HandleActionReadFromTopEvent();
81   bool HandleActionReadFromNextEvent();
82   bool HandleActionZoomEvent();
83   bool HandleActionReadIndicatorInformationEvent();
84   bool HandleActionReadPauseResumeEvent();
85   bool HandleActionStartStopEvent();
86
87 public: // Signals
88
89 private:
90
91   bool mIsEnabled;
92   Dali::AccessibilityActionHandler* mActionHandler;
93   Dali::AccessibilityGestureHandler* mGestureHandler;
94   Vector2 mReadPosition;
95
96   static Dali::AccessibilityAdaptor mToolkitAccessibilityAdaptor;
97 };
98
99 Dali::AccessibilityAdaptor AccessibilityAdaptor::mToolkitAccessibilityAdaptor;
100
101
102 Dali::AccessibilityAdaptor AccessibilityAdaptor::Get()
103 {
104   if( !mToolkitAccessibilityAdaptor )
105   {
106     mToolkitAccessibilityAdaptor = Dali::AccessibilityAdaptor( new Dali::Internal::Adaptor::AccessibilityAdaptor() );
107   }
108   return mToolkitAccessibilityAdaptor;
109 }
110
111 AccessibilityAdaptor::AccessibilityAdaptor()
112 : mIsEnabled(false),
113   mReadPosition( 0.0f, 0.0f )
114 {
115 }
116
117 AccessibilityAdaptor::~AccessibilityAdaptor()
118 {
119 }
120
121 Vector2 AccessibilityAdaptor::GetReadPosition() const
122 {
123   return mReadPosition;
124 }
125
126 void AccessibilityAdaptor::MockSetReadPosition( Vector2& position )
127 {
128   mReadPosition = position;
129 }
130
131 bool AccessibilityAdaptor::IsEnabled() const
132 {
133   return mIsEnabled;
134 }
135
136 void AccessibilityAdaptor::SetActionHandler(Dali::AccessibilityActionHandler& handler)
137 {
138   mActionHandler = &handler;
139 }
140
141 void AccessibilityAdaptor::SetGestureHandler(Dali::AccessibilityGestureHandler& handler)
142 {
143   mGestureHandler = &handler;
144 }
145
146 bool AccessibilityAdaptor::HandleActionNextEvent()
147 {
148   if( mActionHandler )
149   {
150     return mActionHandler->AccessibilityActionNext( true );
151   }
152   return false;
153 }
154
155 bool AccessibilityAdaptor::HandleActionPreviousEvent()
156 {
157   if( mActionHandler )
158   {
159     return mActionHandler->AccessibilityActionPrevious( true );
160   }
161   return false;
162 }
163
164 bool AccessibilityAdaptor::HandleActionActivateEvent()
165 {
166   if( mActionHandler )
167   {
168     return mActionHandler->AccessibilityActionActivate();
169   }
170   return false;
171 }
172
173 bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y,  bool allowReadAgain)
174 {
175   if( mActionHandler )
176   {
177     return mActionHandler->AccessibilityActionRead( allowReadAgain );
178   }
179   return false;
180 }
181
182 bool AccessibilityAdaptor::HandleActionReadNextEvent()
183 {
184   if( mActionHandler )
185   {
186     return mActionHandler->AccessibilityActionReadNext( true );
187   }
188   return false;
189 }
190
191 bool AccessibilityAdaptor::HandleActionReadPreviousEvent()
192 {
193   if( mActionHandler )
194   {
195     return mActionHandler->AccessibilityActionReadPrevious( true );
196   }
197   return false;
198 }
199
200 bool AccessibilityAdaptor::HandleActionUpEvent()
201 {
202   if( mActionHandler )
203   {
204     return mActionHandler->AccessibilityActionUp();
205   }
206   return false;
207 }
208
209 bool AccessibilityAdaptor::HandleActionDownEvent()
210 {
211   if( mActionHandler )
212   {
213     return mActionHandler->AccessibilityActionDown();
214   }
215   return false;
216 }
217
218 bool AccessibilityAdaptor::HandleActionClearFocusEvent()
219 {
220   if( mActionHandler )
221   {
222     return mActionHandler->ClearAccessibilityFocus();
223   }
224   return false;
225 }
226
227 bool AccessibilityAdaptor::HandleActionScrollEvent(TouchPoint& point, unsigned long timeStamp)
228 {
229   if( mActionHandler )
230   {
231     Dali::TouchEvent touchEvent;
232     touchEvent.points.push_back( point );
233     return mActionHandler->AccessibilityActionScroll( touchEvent );
234   }
235   return false;
236 }
237
238 bool AccessibilityAdaptor::HandleActionBackEvent()
239 {
240   if( mActionHandler )
241   {
242     return mActionHandler->AccessibilityActionBack();
243   }
244   return false;
245 }
246
247 bool AccessibilityAdaptor::HandleActionEnableEvent()
248 {
249   if( mActionHandler )
250   {
251     return mActionHandler->ChangeAccessibilityStatus();
252   }
253   return false;
254 }
255
256 bool AccessibilityAdaptor::HandleActionDisableEvent()
257 {
258   if( mActionHandler )
259   {
260     return mActionHandler->ChangeAccessibilityStatus();
261   }
262   return false;
263 }
264
265 bool AccessibilityAdaptor::HandleActionScrollUpEvent()
266 {
267   if( mActionHandler )
268   {
269     return mActionHandler->AccessibilityActionScrollUp();
270   }
271   return false;
272 }
273
274 bool AccessibilityAdaptor::HandleActionScrollDownEvent()
275 {
276   if( mActionHandler )
277   {
278     return mActionHandler->AccessibilityActionScrollDown();
279   }
280   return false;
281 }
282
283 bool AccessibilityAdaptor::HandleActionPageLeftEvent()
284 {
285   if( mActionHandler )
286   {
287     return mActionHandler->AccessibilityActionPageLeft();
288   }
289   return false;
290 }
291
292 bool AccessibilityAdaptor::HandleActionPageRightEvent()
293 {
294   if( mActionHandler )
295   {
296     return mActionHandler->AccessibilityActionPageRight();
297   }
298   return false;
299 }
300
301 bool AccessibilityAdaptor::HandleActionPageUpEvent()
302 {
303   if( mActionHandler )
304   {
305     return mActionHandler->AccessibilityActionPageUp();
306   }
307   return false;
308 }
309
310 bool AccessibilityAdaptor::HandleActionPageDownEvent()
311 {
312   if( mActionHandler )
313   {
314     return mActionHandler->AccessibilityActionPageDown();
315   }
316   return false;
317 }
318
319 bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
320 {
321   if( mActionHandler )
322   {
323     return mActionHandler->AccessibilityActionMoveToFirst();
324   }
325   return false;
326 }
327
328 bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
329 {
330   if( mActionHandler )
331   {
332     return mActionHandler->AccessibilityActionMoveToLast();
333   }
334   return false;
335 }
336
337 bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
338 {
339   if( mActionHandler )
340   {
341     return mActionHandler->AccessibilityActionReadFromTop();
342   }
343   return false;
344 }
345
346 bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
347 {
348   if( mActionHandler )
349   {
350     return mActionHandler->AccessibilityActionReadFromNext();
351   }
352   return false;
353 }
354
355 bool AccessibilityAdaptor::HandleActionZoomEvent()
356 {
357   if( mActionHandler )
358   {
359     return mActionHandler->AccessibilityActionZoom();
360   }
361   return false;
362 }
363
364 bool AccessibilityAdaptor::HandleActionReadIndicatorInformationEvent()
365 {
366   if( mActionHandler )
367   {
368     return mActionHandler->AccessibilityActionReadIndicatorInformation();
369   }
370   return false;
371 }
372
373 bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
374 {
375   if( mActionHandler )
376   {
377     return mActionHandler->AccessibilityActionReadPauseResume();
378   }
379   return false;
380 }
381
382 bool AccessibilityAdaptor::HandleActionStartStopEvent()
383 {
384   if( mActionHandler )
385   {
386     return mActionHandler->AccessibilityActionStartStop();
387   }
388   return false;
389 }
390
391 static Internal::Adaptor::AccessibilityAdaptor& GetImplementation(Dali::AccessibilityAdaptor& adaptor)
392 {
393   BaseObject& handle = adaptor.GetBaseObject();
394   return static_cast<Internal::Adaptor::AccessibilityAdaptor&>(handle);
395 }
396
397 static const Internal::Adaptor::AccessibilityAdaptor& GetImplementation(const Dali::AccessibilityAdaptor& adaptor)
398 {
399   const BaseObject& handle = adaptor.GetBaseObject();
400   return static_cast<const Internal::Adaptor::AccessibilityAdaptor&>(handle);
401 }
402
403
404 } // namespace Adaptor
405 } // namespace Internal
406
407 ////////////////////////////////////////////////////////////////////////////////////////////////////
408
409 AccessibilityAdaptor::AccessibilityAdaptor()
410 {
411 }
412
413 AccessibilityAdaptor AccessibilityAdaptor::Get()
414 {
415   return Internal::Adaptor::AccessibilityAdaptor::Get();
416 }
417
418 AccessibilityAdaptor::~AccessibilityAdaptor()
419 {
420 }
421
422 // Mock setup:
423
424 void AccessibilityAdaptor::MockSetReadPosition( Vector2& position )
425 {
426   Internal::Adaptor::GetImplementation(*this).MockSetReadPosition( position );
427 }
428
429 // Methods:
430
431 Vector2 AccessibilityAdaptor::GetReadPosition() const
432 {
433   return Internal::Adaptor::GetImplementation(*this).GetReadPosition();
434 }
435
436 bool AccessibilityAdaptor::IsEnabled() const
437 {
438   //return Internal::Adaptor::GetImplementation(*this).IsEnabled();
439   return false;
440 }
441
442 void AccessibilityAdaptor::SetActionHandler(AccessibilityActionHandler& handler)
443 {
444   Internal::Adaptor::GetImplementation(*this).SetActionHandler(handler);
445 }
446
447 void AccessibilityAdaptor::SetGestureHandler(AccessibilityGestureHandler& handler)
448 {
449   Internal::Adaptor::GetImplementation(*this).SetGestureHandler(handler);
450 }
451
452 bool AccessibilityAdaptor::HandleActionNextEvent()
453 {
454   return Internal::Adaptor::GetImplementation(*this).HandleActionNextEvent();
455 }
456
457 bool AccessibilityAdaptor::HandleActionPreviousEvent()
458 {
459   return Internal::Adaptor::GetImplementation(*this).HandleActionPreviousEvent();
460 }
461
462 bool AccessibilityAdaptor::HandleActionActivateEvent()
463 {
464   return Internal::Adaptor::GetImplementation(*this).HandleActionActivateEvent();
465 }
466
467 bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y,  bool allowReadAgain)
468 {
469   return Internal::Adaptor::GetImplementation(*this).HandleActionReadEvent( x, y, allowReadAgain );
470 }
471
472 bool AccessibilityAdaptor::HandleActionReadNextEvent()
473 {
474   return Internal::Adaptor::GetImplementation(*this).HandleActionReadNextEvent();
475 }
476
477 bool AccessibilityAdaptor::HandleActionReadPreviousEvent()
478 {
479   return Internal::Adaptor::GetImplementation(*this).HandleActionReadPreviousEvent();
480 }
481
482 bool AccessibilityAdaptor::HandleActionUpEvent()
483 {
484   return Internal::Adaptor::GetImplementation(*this).HandleActionUpEvent();
485 }
486
487 bool AccessibilityAdaptor::HandleActionDownEvent()
488 {
489   return Internal::Adaptor::GetImplementation(*this).HandleActionDownEvent();
490 }
491
492 bool AccessibilityAdaptor::HandleActionClearFocusEvent()
493 {
494   return Internal::Adaptor::GetImplementation(*this).HandleActionClearFocusEvent();
495 }
496
497 bool AccessibilityAdaptor::HandleActionScrollEvent(TouchPoint& point, unsigned long timeStamp)
498 {
499   return Internal::Adaptor::GetImplementation(*this).HandleActionScrollEvent(point, timeStamp);
500 }
501
502 bool AccessibilityAdaptor::HandleActionBackEvent()
503 {
504   return Internal::Adaptor::GetImplementation(*this).HandleActionBackEvent();
505 }
506
507 void AccessibilityAdaptor::HandleActionEnableEvent()
508 {
509   Internal::Adaptor::GetImplementation(*this).HandleActionEnableEvent();
510 }
511
512 void AccessibilityAdaptor::HandleActionDisableEvent()
513 {
514   Internal::Adaptor::GetImplementation(*this).HandleActionDisableEvent();
515 }
516
517 bool AccessibilityAdaptor::HandleActionScrollUpEvent()
518 {
519   return Internal::Adaptor::GetImplementation(*this).HandleActionScrollUpEvent();
520 }
521
522 bool AccessibilityAdaptor::HandleActionScrollDownEvent()
523 {
524   return Internal::Adaptor::GetImplementation(*this).HandleActionScrollDownEvent();
525 }
526
527 bool AccessibilityAdaptor::HandleActionPageLeftEvent()
528 {
529   return Internal::Adaptor::GetImplementation(*this).HandleActionPageLeftEvent();
530 }
531
532 bool AccessibilityAdaptor::HandleActionPageRightEvent()
533 {
534   return Internal::Adaptor::GetImplementation(*this).HandleActionPageRightEvent();
535 }
536
537 bool AccessibilityAdaptor::HandleActionPageUpEvent()
538 {
539   return Internal::Adaptor::GetImplementation(*this).HandleActionPageUpEvent();
540 }
541
542 bool AccessibilityAdaptor::HandleActionPageDownEvent()
543 {
544   return Internal::Adaptor::GetImplementation(*this).HandleActionPageDownEvent();
545 }
546
547 bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
548 {
549   return Internal::Adaptor::GetImplementation(*this).HandleActionMoveToFirstEvent();
550 }
551
552 bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
553 {
554   return Internal::Adaptor::GetImplementation(*this).HandleActionMoveToLastEvent();
555 }
556
557 bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
558 {
559   return Internal::Adaptor::GetImplementation(*this).HandleActionReadFromTopEvent();
560 }
561
562 bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
563 {
564   return Internal::Adaptor::GetImplementation(*this).HandleActionReadFromNextEvent();
565 }
566
567 bool AccessibilityAdaptor::HandleActionZoomEvent()
568 {
569   return Internal::Adaptor::GetImplementation(*this).HandleActionZoomEvent();
570 }
571
572 bool AccessibilityAdaptor::HandleActionReadIndicatorInformationEvent()
573 {
574   return Internal::Adaptor::GetImplementation(*this).HandleActionReadIndicatorInformationEvent();
575 }
576
577 bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
578 {
579   return Internal::Adaptor::GetImplementation(*this).HandleActionReadPauseResumeEvent();
580 }
581
582 bool AccessibilityAdaptor::HandleActionStartStopEvent()
583 {
584   return Internal::Adaptor::GetImplementation(*this).HandleActionStartStopEvent();
585 }
586
587 AccessibilityAdaptor::AccessibilityAdaptor( Internal::Adaptor::AccessibilityAdaptor* adaptor )
588 : BaseHandle( adaptor )
589 {
590 }
591
592 } // namespace Dali