a69b323c9d72073a916f99147d5bb31398b43acf
[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
398 } // namespace Adaptor
399 } // namespace Internal
400
401 ////////////////////////////////////////////////////////////////////////////////////////////////////
402
403 AccessibilityAdaptor::AccessibilityAdaptor()
404 {
405 }
406
407 AccessibilityAdaptor AccessibilityAdaptor::Get()
408 {
409   return Internal::Adaptor::AccessibilityAdaptor::Get();
410 }
411
412 AccessibilityAdaptor::~AccessibilityAdaptor()
413 {
414 }
415
416 // Mock setup:
417
418 void AccessibilityAdaptor::MockSetReadPosition( Vector2& position )
419 {
420   Internal::Adaptor::GetImplementation(*this).MockSetReadPosition( position );
421 }
422
423 // Methods:
424
425 Vector2 AccessibilityAdaptor::GetReadPosition()
426 {
427   return Internal::Adaptor::GetImplementation(*this).GetReadPosition();
428 }
429
430 bool AccessibilityAdaptor::IsEnabled() const
431 {
432   //return Internal::Adaptor::GetImplementation(*this).IsEnabled();
433   return false;
434 }
435
436 void AccessibilityAdaptor::SetActionHandler(AccessibilityActionHandler& handler)
437 {
438   Internal::Adaptor::GetImplementation(*this).SetActionHandler(handler);
439 }
440
441 void AccessibilityAdaptor::SetGestureHandler(AccessibilityGestureHandler& handler)
442 {
443   Internal::Adaptor::GetImplementation(*this).SetGestureHandler(handler);
444 }
445
446 bool AccessibilityAdaptor::HandleActionNextEvent()
447 {
448   return Internal::Adaptor::GetImplementation(*this).HandleActionNextEvent();
449 }
450
451 bool AccessibilityAdaptor::HandleActionPreviousEvent()
452 {
453   return Internal::Adaptor::GetImplementation(*this).HandleActionPreviousEvent();
454 }
455
456 bool AccessibilityAdaptor::HandleActionActivateEvent()
457 {
458   return Internal::Adaptor::GetImplementation(*this).HandleActionActivateEvent();
459 }
460
461 bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y,  bool allowReadAgain)
462 {
463   return Internal::Adaptor::GetImplementation(*this).HandleActionReadEvent( x, y, allowReadAgain );
464 }
465
466 bool AccessibilityAdaptor::HandleActionReadNextEvent()
467 {
468   return Internal::Adaptor::GetImplementation(*this).HandleActionReadNextEvent();
469 }
470
471 bool AccessibilityAdaptor::HandleActionReadPreviousEvent()
472 {
473   return Internal::Adaptor::GetImplementation(*this).HandleActionReadPreviousEvent();
474 }
475
476 bool AccessibilityAdaptor::HandleActionUpEvent()
477 {
478   return Internal::Adaptor::GetImplementation(*this).HandleActionUpEvent();
479 }
480
481 bool AccessibilityAdaptor::HandleActionDownEvent()
482 {
483   return Internal::Adaptor::GetImplementation(*this).HandleActionDownEvent();
484 }
485
486 bool AccessibilityAdaptor::HandleActionClearFocusEvent()
487 {
488   return Internal::Adaptor::GetImplementation(*this).HandleActionClearFocusEvent();
489 }
490
491 bool AccessibilityAdaptor::HandleActionScrollEvent(TouchPoint& point, unsigned long timeStamp)
492 {
493   return Internal::Adaptor::GetImplementation(*this).HandleActionScrollEvent(point, timeStamp);
494 }
495
496 bool AccessibilityAdaptor::HandleActionBackEvent()
497 {
498   return Internal::Adaptor::GetImplementation(*this).HandleActionBackEvent();
499 }
500
501 void AccessibilityAdaptor::HandleActionEnableEvent()
502 {
503   Internal::Adaptor::GetImplementation(*this).HandleActionEnableEvent();
504 }
505
506 void AccessibilityAdaptor::HandleActionDisableEvent()
507 {
508   Internal::Adaptor::GetImplementation(*this).HandleActionDisableEvent();
509 }
510
511 bool AccessibilityAdaptor::HandleActionScrollUpEvent()
512 {
513   return Internal::Adaptor::GetImplementation(*this).HandleActionScrollUpEvent();
514 }
515
516 bool AccessibilityAdaptor::HandleActionScrollDownEvent()
517 {
518   return Internal::Adaptor::GetImplementation(*this).HandleActionScrollDownEvent();
519 }
520
521 bool AccessibilityAdaptor::HandleActionPageLeftEvent()
522 {
523   return Internal::Adaptor::GetImplementation(*this).HandleActionPageLeftEvent();
524 }
525
526 bool AccessibilityAdaptor::HandleActionPageRightEvent()
527 {
528   return Internal::Adaptor::GetImplementation(*this).HandleActionPageRightEvent();
529 }
530
531 bool AccessibilityAdaptor::HandleActionPageUpEvent()
532 {
533   return Internal::Adaptor::GetImplementation(*this).HandleActionPageUpEvent();
534 }
535
536 bool AccessibilityAdaptor::HandleActionPageDownEvent()
537 {
538   return Internal::Adaptor::GetImplementation(*this).HandleActionPageDownEvent();
539 }
540
541 bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
542 {
543   return Internal::Adaptor::GetImplementation(*this).HandleActionMoveToFirstEvent();
544 }
545
546 bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
547 {
548   return Internal::Adaptor::GetImplementation(*this).HandleActionMoveToLastEvent();
549 }
550
551 bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
552 {
553   return Internal::Adaptor::GetImplementation(*this).HandleActionReadFromTopEvent();
554 }
555
556 bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
557 {
558   return Internal::Adaptor::GetImplementation(*this).HandleActionReadFromNextEvent();
559 }
560
561 bool AccessibilityAdaptor::HandleActionZoomEvent()
562 {
563   return Internal::Adaptor::GetImplementation(*this).HandleActionZoomEvent();
564 }
565
566 bool AccessibilityAdaptor::HandleActionReadIndicatorInformationEvent()
567 {
568   return Internal::Adaptor::GetImplementation(*this).HandleActionReadIndicatorInformationEvent();
569 }
570
571 bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
572 {
573   return Internal::Adaptor::GetImplementation(*this).HandleActionReadPauseResumeEvent();
574 }
575
576 bool AccessibilityAdaptor::HandleActionStartStopEvent()
577 {
578   return Internal::Adaptor::GetImplementation(*this).HandleActionStartStopEvent();
579 }
580
581 AccessibilityAdaptor::AccessibilityAdaptor( Internal::Adaptor::AccessibilityAdaptor* adaptor )
582 : BaseHandle( adaptor )
583 {
584 }
585
586 } // namespace Dali