Merge "Accessibility Manager public API UTC tests and coverage" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-AccessibilityManager.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 <iostream>
19 #include <stdlib.h>
20
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
23 #include <dali-toolkit-test-suite-utils.h>
24 #include <toolkit-accessibility-adaptor.h>
25
26 #include <dali-toolkit/dali-toolkit.h>
27
28 using namespace Dali;
29 using namespace Toolkit;
30
31
32 void utc_dali_toolkit_accessibility_manager_startup(void)
33 {
34   test_return_value = TET_UNDEF;
35 }
36
37 void utc_dali_toolkit_accessibility_manager_cleanup(void)
38 {
39   test_return_value = TET_PASS;
40 }
41
42
43 namespace
44 {
45
46 static bool gObjectCreatedCallBackCalled;
47
48 static void TestCallback(BaseHandle handle)
49 {
50   gObjectCreatedCallBackCalled = true;
51 }
52
53 // Functors to test whether focus changed signal is emitted when the focus is changed
54 class FocusChangedCallback : public Dali::ConnectionTracker
55 {
56 public:
57   FocusChangedCallback(bool& signalReceived)
58   : mSignalVerified(signalReceived),
59     mOriginalFocusedActor(),
60     mCurrentFocusedActor()
61   {
62   }
63
64   void Callback(Actor originalFocusedActor, Actor currentFocusedActor)
65   {
66     tet_infoline("Verifying FocusChangedCallback()");
67
68     if(originalFocusedActor == mCurrentFocusedActor)
69     {
70       mSignalVerified = true;
71     }
72
73     mOriginalFocusedActor = originalFocusedActor;
74     mCurrentFocusedActor = currentFocusedActor;
75   }
76
77   void Reset()
78   {
79     mSignalVerified = false;
80   }
81
82   bool& mSignalVerified;
83   Actor mOriginalFocusedActor;
84   Actor mCurrentFocusedActor;
85 };
86
87 // Functors to test whether focus overshot signal is emitted when there is no way to move focus further.
88 class FocusOvershotCallback : public Dali::ConnectionTracker
89 {
90 public:
91   FocusOvershotCallback(bool& signalReceived)
92   : mSignalVerified(signalReceived),
93     mCurrentFocusedActor(),
94     mFocusOvershotDirection(Toolkit::AccessibilityManager::OVERSHOT_NEXT)
95   {
96   }
97
98   void Callback(Actor currentFocusedActor, Toolkit::AccessibilityManager::FocusOvershotDirection direction)
99   {
100     tet_infoline("Verifying FocusOvershotCallback()");
101
102     if(currentFocusedActor == mCurrentFocusedActor && direction == mFocusOvershotDirection)
103     {
104       mSignalVerified = true;
105     }
106   }
107
108   void Reset()
109   {
110     mSignalVerified = false;
111   }
112
113   bool& mSignalVerified;
114   Actor mCurrentFocusedActor;
115   Toolkit::AccessibilityManager::FocusOvershotDirection mFocusOvershotDirection;
116 };
117
118 // Functor to test whether focused actor activated signal is emitted.
119 class FocusedActorActivatedCallback : public Dali::ConnectionTracker
120 {
121 public:
122   FocusedActorActivatedCallback()
123   {
124   }
125
126   void Callback(Actor activatedActor)
127   {
128     tet_infoline("Verifying FocusedActorActivatedCallback()");
129   }
130 };
131
132 } // namespace
133
134
135 int UtcDaliAccessibilityManagerGet(void)
136 {
137   ToolkitTestApplication application;
138
139   tet_infoline(" UtcDaliAccessibilityManagerGet");
140
141   AccessibilityManager manager;
142
143   //Ensure object is created by checking if it's registered
144   ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
145   DALI_TEST_CHECK(registry);
146
147   gObjectCreatedCallBackCalled = false;
148   registry.ObjectCreatedSignal().Connect( &TestCallback );
149   {
150     manager = AccessibilityManager::Get();
151     DALI_TEST_CHECK(manager);
152   }
153   DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
154
155   AccessibilityManager newManager = AccessibilityManager::Get();
156   DALI_TEST_CHECK(newManager);
157
158   // Check that accessibility manager is a singleton
159   DALI_TEST_CHECK(manager == newManager);
160   END_TEST;
161 }
162
163 int UtcDaliAccessibilityManagerSetAndGetAccessibilityAttribute(void)
164 {
165   ToolkitTestApplication application;
166
167   tet_infoline(" UtcDaliAccessibilityManagerSetAndGetAccessibilityAttribute");
168
169   AccessibilityManager manager = AccessibilityManager::Get();
170   DALI_TEST_CHECK(manager);
171
172   Actor actor = Actor::New();
173   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(actor, AccessibilityManager::ACCESSIBILITY_LABEL) == "");
174
175   manager.SetAccessibilityAttribute(actor, AccessibilityManager::ACCESSIBILITY_LABEL, "Description");
176   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(actor, AccessibilityManager::ACCESSIBILITY_LABEL) == "Description");
177
178   manager.SetAccessibilityAttribute(actor, AccessibilityManager::ACCESSIBILITY_LABEL, "New description");
179   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(actor, AccessibilityManager::ACCESSIBILITY_LABEL) == "New description");
180   END_TEST;
181 }
182
183 int UtcDaliAccessibilityManagerSetAndGetFocusOrder(void)
184 {
185   ToolkitTestApplication application;
186
187   tet_infoline(" UtcDaliAccessibilityManagerSetAndGetFocusOrder");
188
189   AccessibilityManager manager = AccessibilityManager::Get();
190   DALI_TEST_CHECK(manager);
191
192   Actor first = Actor::New();
193   Actor second = Actor::New();
194   DALI_TEST_CHECK(manager.GetFocusOrder(first) == 0);
195   DALI_TEST_CHECK(manager.GetFocusOrder(second) == 0);
196
197   // Set the focus order and description for the first actor
198   manager.SetFocusOrder(first, 1);
199   manager.SetAccessibilityAttribute(first, AccessibilityManager::ACCESSIBILITY_LABEL, "first");
200   DALI_TEST_CHECK(manager.GetFocusOrder(first) == 1);
201   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, AccessibilityManager::ACCESSIBILITY_LABEL) == "first");
202
203   // Set the focus order and description for the second actor
204   manager.SetFocusOrder(second, 2);
205   manager.SetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL, "second");
206   DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2);
207   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL) == "second");
208
209   // check that the focus order of the first actor is changed
210   manager.SetFocusOrder(first, 2);
211   DALI_TEST_CHECK(manager.GetFocusOrder(first) == 2);
212   // make sure the change of focus order doesn't affect the actor's description
213   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, AccessibilityManager::ACCESSIBILITY_LABEL) == "first");
214
215   // check that the focus order of the second actor is increased to 3
216   DALI_TEST_CHECK(manager.GetFocusOrder(second) == 3);
217   // make sure the change of focus order doesn't affect the actor's description
218   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL) == "second");
219
220   // check that the focus order of the second actor is changed to 1
221   manager.SetFocusOrder(second, 1);
222   DALI_TEST_CHECK(manager.GetFocusOrder(second) == 1);
223   // make sure the change of focus order doesn't affect the actor's description
224   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL) == "second");
225
226   // Set the focus order and description for the third actor
227   Actor third = Actor::New();
228   manager.SetFocusOrder(third, 1);
229   manager.SetAccessibilityAttribute(third, AccessibilityManager::ACCESSIBILITY_LABEL, "third");
230   DALI_TEST_CHECK(manager.GetFocusOrder(third) == 1);
231   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(third, AccessibilityManager::ACCESSIBILITY_LABEL) == "third");
232
233   // check that the focus order of the second actor is increased to 2.
234   DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2);
235   // make sure the change of focus order doesn't affect the actor's description
236   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL) == "second");
237
238   // check that the focus order of the first actor is increased to 3.
239   DALI_TEST_CHECK(manager.GetFocusOrder(first) == 3);
240   // make sure the change of focus order doesn't affect the actor's description
241   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, AccessibilityManager::ACCESSIBILITY_LABEL) == "first");
242   END_TEST;
243 }
244
245 int UtcDaliAccessibilityManagerGenerateNewFocusOrder(void)
246 {
247   ToolkitTestApplication application;
248
249   tet_infoline(" UtcDaliAccessibilityManagerGenerateNewFocusOrder");
250
251   AccessibilityManager manager = AccessibilityManager::Get();
252   DALI_TEST_CHECK(manager);
253
254   DALI_TEST_CHECK(1 == manager.GenerateNewFocusOrder());
255   DALI_TEST_CHECK(1 == manager.GenerateNewFocusOrder());
256
257   Actor first = Actor::New();
258   Actor second = Actor::New();
259
260   // Set the focus order for the first actor
261   manager.SetFocusOrder(first, 1);
262   manager.SetAccessibilityAttribute(first, AccessibilityManager::ACCESSIBILITY_LABEL, "first");
263   DALI_TEST_CHECK(manager.GetFocusOrder(first) == 1);
264
265   //Test for new focus order
266   DALI_TEST_CHECK(2 == manager.GenerateNewFocusOrder());
267
268   // Set the focus order for the first actor
269   manager.SetFocusOrder(second, 2);
270   manager.SetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL, "first");
271   DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2);
272   END_TEST;
273 }
274
275 int UtcDaliAccessibilityManagerGetActorByFocusOrder(void)
276 {
277   ToolkitTestApplication application;
278
279   tet_infoline(" UtcDaliAccessibilityManagerGetActorByFocusOrder");
280
281   AccessibilityManager manager = AccessibilityManager::Get();
282   DALI_TEST_CHECK(manager);
283
284   // Create the actors and set their focus orders
285   Actor first = Actor::New();
286   manager.SetFocusOrder(first, 1);
287
288   Actor second = Actor::New();
289   manager.SetFocusOrder(second, 2);
290
291   Actor third = Actor::New();
292   manager.SetFocusOrder(third, 3);
293
294   // Check that we get an empty handle as no actor is added to the stage yet.
295   DALI_TEST_CHECK(manager.GetActorByFocusOrder(1) == Actor());
296   DALI_TEST_CHECK(manager.GetActorByFocusOrder(2) == Actor());
297   DALI_TEST_CHECK(manager.GetActorByFocusOrder(3) == Actor());
298
299   // Add the actors to the stage
300   Stage::GetCurrent().Add(first);
301   Stage::GetCurrent().Add(second);
302   Stage::GetCurrent().Add(third);
303
304   // Check that we get an empty handle because focus order 0 means undefined.
305   DALI_TEST_CHECK(manager.GetActorByFocusOrder(0) == Actor());
306
307   // Check that we get correct actors for the specified focus orders
308   DALI_TEST_CHECK(manager.GetActorByFocusOrder(1) == first);
309   DALI_TEST_CHECK(manager.GetActorByFocusOrder(2) == second);
310   DALI_TEST_CHECK(manager.GetActorByFocusOrder(3) == third);
311
312   // Change the focus order of the third actor to 1
313   manager.SetFocusOrder(third, 1);
314
315   // Check that we still get correct actors after changing their focus orders
316   DALI_TEST_CHECK(manager.GetActorByFocusOrder(1) == third);
317   DALI_TEST_CHECK(manager.GetActorByFocusOrder(2) == first);
318   DALI_TEST_CHECK(manager.GetActorByFocusOrder(3) == second);
319
320   // Check that we get an empty handle because no actor has a focus order of 4
321   DALI_TEST_CHECK(manager.GetActorByFocusOrder(4) == Actor());
322   END_TEST;
323 }
324
325 int UtcDaliAccessibilityManagerSetAndGetCurrentFocusActor(void)
326 {
327   ToolkitTestApplication application;
328
329   tet_infoline(" UtcDaliAccessibilityManagerSetAndGetCurrentFocusActor");
330
331   AccessibilityManager manager = AccessibilityManager::Get();
332   DALI_TEST_CHECK(manager);
333
334   // Create the first actor and add it to the stage
335   Actor first = Actor::New();
336   manager.SetFocusOrder(first, 1);
337   Stage::GetCurrent().Add(first);
338
339   // Create the second actor and add it to the stage
340   Actor second = Actor::New();
341   manager.SetFocusOrder(second, 2);
342   Stage::GetCurrent().Add(second);
343
344   // Create the third actor but don't add it to the stage
345   Actor third = Actor::New();
346   manager.SetFocusOrder(third, 3);
347
348   // Check that no actor is being focused yet.
349   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
350
351   // Check that it will fail to set focus on an invalid actor
352   DALI_TEST_CHECK(manager.SetCurrentFocusActor(Actor()) == false);
353
354   // Check that the focus is set on the first actor
355   DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
356   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
357
358   // Check that the focus is set on the second actor
359   DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
360   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
361
362   // Check that it will fail to set focus on the third actor as it's not in the stage
363   DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false);
364
365   // Add the third actor to the stage
366   Stage::GetCurrent().Add(third);
367
368   // make the third actor invisible
369   third.SetVisible(false);
370   // flush the queue and render once
371   application.SendNotification();
372   application.Render();
373
374   // Check that it will fail to set focus on the third actor as it's invisible
375   DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false);
376
377   // Make the third actor visible
378   third.SetVisible(true);
379   // flush the queue and render once
380   application.SendNotification();
381   application.Render();
382
383   // Make the third actor not focusable
384   Property::Index propertyActorFocusable = third.GetPropertyIndex("focusable");
385   third.SetProperty(propertyActorFocusable, false);
386   // flush the queue and render once
387   application.SendNotification();
388   application.Render();
389
390   // Check that it will fail to set focus on the third actor as it's not focusable
391   DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false);
392
393   // Make the third actor focusable
394   third.SetProperty(propertyActorFocusable, true);
395   // flush the queue and render once
396   application.SendNotification();
397   application.Render();
398
399   // Check that the focus is successfully moved to the third actor
400   DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true);
401
402   // Make the current focused actor to be not focusable by setting its focus order to be 0
403   manager.SetFocusOrder(third, 0);
404
405   // Check that the focus is automatically cleared
406   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
407
408   // Set the focus order of the third actor again
409   manager.SetFocusOrder(third, 3);
410
411   // Check that the third actor can be focused successfully now
412   DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true);
413   END_TEST;
414 }
415
416 int UtcDaliAccessibilityManagerGetCurrentFocusGroup(void)
417 {
418   ToolkitTestApplication application;
419
420   tet_infoline(" UtcDaliAccessibilityManagerGetCurrentFocusGroup");
421
422   AccessibilityManager manager = AccessibilityManager::Get();
423   DALI_TEST_CHECK(manager);
424
425   // Create an actor with two child actors and add it to the stage
426   Actor parent = Actor::New();
427   Actor firstChild = Actor::New();
428   Actor secondChild = Actor::New();
429   parent.Add(firstChild);
430   parent.Add(secondChild);
431   Stage::GetCurrent().Add(parent);
432
433   // Create three actors and add them as the children of the first child actor
434   Actor firstGrandChild = Actor::New();
435   Actor secondGrandChild = Actor::New();
436   Actor thirdGrandChild = Actor::New();
437   firstChild.Add(firstGrandChild);
438   firstChild.Add(secondGrandChild);
439   firstChild.Add(thirdGrandChild);
440
441   // Set focus order to the actors
442   manager.SetFocusOrder(parent, 1);
443   manager.SetFocusOrder(firstChild, 2);
444   manager.SetFocusOrder(firstGrandChild, 3);
445   manager.SetFocusOrder(secondGrandChild, 4);
446   manager.SetFocusOrder(thirdGrandChild, 5);
447   manager.SetFocusOrder(secondChild, 6);
448
449   // Set the parent and the first child actor as focus groups
450   manager.SetFocusGroup(parent, true);
451   DALI_TEST_CHECK(manager.IsFocusGroup(parent) == true);
452
453   // Set focus to the first grand child actor
454   DALI_TEST_CHECK(manager.SetCurrentFocusActor(firstGrandChild) == true);
455   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild);
456
457   // The current focus group should be the parent, As it is the immediate parent which is also a focus group.
458   DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == parent);
459
460   manager.SetFocusGroup(firstChild, true);
461   DALI_TEST_CHECK(manager.IsFocusGroup(firstChild) == true);
462
463   // The current focus group should be the firstChild, As it is the immediate parent which is also a focus group.
464   DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == firstChild);
465
466   manager.SetFocusGroup(firstGrandChild, true);
467   DALI_TEST_CHECK(manager.IsFocusGroup(firstGrandChild) == true);
468
469   // The current focus group should be itself, As it is also a focus group.
470   DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == firstGrandChild);
471
472   // Set focus to the second grand child actor
473   DALI_TEST_CHECK(manager.SetCurrentFocusActor(secondGrandChild) == true);
474   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondGrandChild);
475
476   // The current focus group should be the firstChild, As it is the immediate parent which is also a
477   // focus group for the current focus actor.
478   DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == firstChild);
479
480   END_TEST;
481 }
482
483 int UtcDaliAccessibilityManagerGetCurrentFocusOrder(void)
484 {
485   ToolkitTestApplication application;
486
487   tet_infoline(" UtcDaliAccessibilityManagerGetCurrentFocusOrder");
488
489   AccessibilityManager manager = AccessibilityManager::Get();
490   DALI_TEST_CHECK(manager);
491
492   Actor first = Actor::New();
493   Stage::GetCurrent().Add(first);
494
495   Actor second = Actor::New();
496   Stage::GetCurrent().Add(second);
497
498   Actor third = Actor::New();
499   Stage::GetCurrent().Add(third);
500
501   // Set the focus order and description for the first actor
502   manager.SetFocusOrder(first, 1);
503   manager.SetAccessibilityAttribute(first, AccessibilityManager::ACCESSIBILITY_LABEL, "first");
504   DALI_TEST_CHECK(manager.GetFocusOrder(first) == 1);
505   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, AccessibilityManager::ACCESSIBILITY_LABEL) == "first");
506
507   // Set the focus order and description for the second actor
508   manager.SetFocusOrder(second, 2);
509   manager.SetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL, "second");
510   DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2);
511   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL) == "second");
512
513   // Set the focus order and description for the second actor
514   manager.SetFocusOrder(third, 3);
515   manager.SetAccessibilityAttribute(third, AccessibilityManager::ACCESSIBILITY_LABEL, "third");
516   DALI_TEST_CHECK(manager.GetFocusOrder(third) == 3);
517   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(third, AccessibilityManager::ACCESSIBILITY_LABEL) == "third");
518
519   // Check that no actor is being focused yet.
520   DALI_TEST_CHECK(manager.GetCurrentFocusOrder() == 0);
521
522   // Set the focus on the first actor and test
523   DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
524   DALI_TEST_CHECK(manager.GetCurrentFocusOrder() == 1);
525
526   // Move the focus forward to the second actor and test
527   manager.MoveFocusForward();
528   DALI_TEST_CHECK(manager.GetCurrentFocusOrder() == 2);
529
530   // Move the focus forward to the third actor and test
531   manager.MoveFocusForward();
532   DALI_TEST_CHECK(manager.GetCurrentFocusOrder() == 3);
533
534   // Clear focus and test
535   manager.ClearFocus();
536   DALI_TEST_CHECK(manager.GetCurrentFocusOrder() == 0);
537   END_TEST;
538 }
539
540 int UtcDaliAccessibilityManagerMoveFocusForward(void)
541 {
542   ToolkitTestApplication application;
543
544   tet_infoline(" UtcDaliAccessibilityManagerMoveFocusForward");
545
546   AccessibilityManager manager = AccessibilityManager::Get();
547   DALI_TEST_CHECK(manager);
548
549   Actor first = Actor::New();
550   Stage::GetCurrent().Add(first);
551
552   Actor second = Actor::New();
553   Stage::GetCurrent().Add(second);
554
555   Actor third = Actor::New();
556   Stage::GetCurrent().Add(third);
557
558   // Set the focus order and description for the first actor
559   manager.SetFocusOrder(first, 1);
560   manager.SetAccessibilityAttribute(first, AccessibilityManager::ACCESSIBILITY_LABEL, "first");
561   DALI_TEST_CHECK(manager.GetFocusOrder(first) == 1);
562   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, AccessibilityManager::ACCESSIBILITY_LABEL) == "first");
563
564   // Set the focus order and description for the second actor
565   manager.SetFocusOrder(second, 2);
566   manager.SetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL, "second");
567   DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2);
568   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL) == "second");
569
570   // Set the focus order and description for the second actor
571   manager.SetFocusOrder(third, 3);
572   manager.SetAccessibilityAttribute(third, AccessibilityManager::ACCESSIBILITY_LABEL, "third");
573   DALI_TEST_CHECK(manager.GetFocusOrder(third) == 3);
574   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(third, AccessibilityManager::ACCESSIBILITY_LABEL) == "third");
575
576   // Check that no actor is being focused yet.
577   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
578
579   // Set the focus on the first actor
580   DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
581   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
582   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "first");
583
584   // Test the non-wrapped move first
585   manager.SetWrapMode(false);
586   DALI_TEST_CHECK(manager.GetWrapMode() == false);
587
588   // Move the focus forward to the second actor
589   manager.MoveFocusForward();
590   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
591   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "second");
592
593   // Move the focus forward to the third actor
594   manager.MoveFocusForward();
595   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
596   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "third");
597
598   // Check that it will fail to move the focus forward again as the third actor is the last
599   // focusable actor in the focus chain
600   manager.MoveFocusForward();
601   // The focus should still be set on the third actor
602   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
603   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "third");
604
605   // Now test the wrapped move
606   manager.SetWrapMode(true);
607   DALI_TEST_CHECK(manager.GetWrapMode() == true);
608
609   // Move the focus forward recursively and this time the first actor should be focused
610   manager.MoveFocusForward();
611   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
612   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "first");
613
614   // Make the second actor not focusable
615   Property::Index propertyActorFocusable = second.GetPropertyIndex("focusable");
616   second.SetProperty(propertyActorFocusable, false);
617   // flush the queue and render once
618   application.SendNotification();
619   application.Render();
620
621   // Move the focus forward and check that the second actor should be skipped and
622   // the third actor should be focused now.
623   manager.MoveFocusForward();
624   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
625   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "third");
626
627   // Make the first actor invisible
628   first.SetVisible(false);
629   // flush the queue and render once
630   application.SendNotification();
631   application.Render();
632
633   // Move the focus forward and check that the first actor should be skipped as it's
634   // invisible and the second actor should also be skipped as it's not focusable,
635   // so the focus will still be on the third actor
636   manager.MoveFocusForward();
637   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
638   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "third");
639
640   // Make the third actor invisible so that no actor can be focused.
641   third.SetVisible(false);
642   // flush the queue and render once
643   application.SendNotification();
644   application.Render();
645
646   // Check that the focus move is failed as all the three actors can not be focused
647   manager.MoveFocusForward();
648   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
649   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "third");
650   END_TEST;
651 }
652
653 int UtcDaliAccessibilityManagerMoveFocusBackward(void)
654 {
655   ToolkitTestApplication application;
656
657   tet_infoline(" UtcDaliAccessibilityManagerMoveFocusBackward");
658
659   AccessibilityManager manager = AccessibilityManager::Get();
660   DALI_TEST_CHECK(manager);
661
662   Actor first = Actor::New();
663   Stage::GetCurrent().Add(first);
664
665   Actor second = Actor::New();
666   Stage::GetCurrent().Add(second);
667
668   Actor third = Actor::New();
669   Stage::GetCurrent().Add(third);
670
671   // Set the focus order and description for the first actor
672   manager.SetFocusOrder(first, 1);
673   manager.SetAccessibilityAttribute(first, AccessibilityManager::ACCESSIBILITY_LABEL, "first");
674   DALI_TEST_CHECK(manager.GetFocusOrder(first) == 1);
675   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, AccessibilityManager::ACCESSIBILITY_LABEL) == "first");
676
677   // Set the focus order and description for the second actor
678   manager.SetFocusOrder(second, 2);
679   manager.SetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL, "second");
680   DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2);
681   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL) == "second");
682
683   // Set the focus order and description for the second actor
684   manager.SetFocusOrder(third, 3);
685   manager.SetAccessibilityAttribute(third, AccessibilityManager::ACCESSIBILITY_LABEL, "third");
686   DALI_TEST_CHECK(manager.GetFocusOrder(third) == 3);
687   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(third, AccessibilityManager::ACCESSIBILITY_LABEL) == "third");
688
689   // Check that no actor is being focused yet.
690   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
691
692   // Set the focus on the third actor
693   DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true);
694   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
695   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "third");
696
697   // Test the non-wrapped move first
698   manager.SetWrapMode(false);
699   DALI_TEST_CHECK(manager.GetWrapMode() == false);
700
701   // Move the focus backward to the second actor
702   manager.MoveFocusBackward();
703   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
704   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "second");
705
706   // Move the focus backward to the first actor
707   manager.MoveFocusBackward();
708   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
709   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "first");
710
711   // Check that it will fail to move the focus backward again as the first actor is the first
712   // focusable actor in the focus chain
713   manager.MoveFocusBackward();
714   // The focus should still be set on the first actor
715   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
716   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "first");
717
718   // Now test the wrapped move
719   manager.SetWrapMode(true);
720   DALI_TEST_CHECK(manager.GetWrapMode() == true);
721
722   // Move the focus backward recursively and this time the third actor should be focused
723   manager.MoveFocusBackward();
724   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
725   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "third");
726
727   // Make the second actor not focusable
728   Property::Index propertyActorFocusable = second.GetPropertyIndex("focusable");
729   second.SetProperty(propertyActorFocusable, false);
730   // flush the queue and render once
731   application.SendNotification();
732   application.Render();
733
734   // Move the focus backward and check that the second actor should be skipped and
735   // the first actor should be focused now.
736   manager.MoveFocusBackward();
737   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
738   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "first");
739
740   // Make the third actor invisible
741   third.SetVisible(false);
742   // flush the queue and render once
743   application.SendNotification();
744   application.Render();
745
746   // Move the focus backward and check that the third actor should be skipped as it's
747   // invisible and the second actor should also be skipped as it's not focusable,
748   // so the focus will still be on the first actor
749   manager.MoveFocusBackward();
750   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
751   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "first");
752
753   // Make the first actor invisible so that no actor can be focused.
754   first.SetVisible(false);
755   // flush the queue and render once
756   application.SendNotification();
757   application.Render();
758
759   // Check that the focus move is failed as all the three actors can not be focused
760   manager.MoveFocusBackward();
761   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
762   DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "first");
763   END_TEST;
764 }
765
766 int UtcDaliAccessibilityManagerClearFocus(void)
767 {
768   ToolkitTestApplication application;
769
770   tet_infoline(" UtcDaliAccessibilityManagerClearFocus");
771
772   AccessibilityManager manager = AccessibilityManager::Get();
773   DALI_TEST_CHECK(manager);
774
775   // Create the first actor and add it to the stage
776   Actor first = Actor::New();
777   manager.SetFocusOrder(first, 1);
778   Stage::GetCurrent().Add(first);
779
780   // Create the second actor and add it to the stage
781   Actor second = Actor::New();
782   manager.SetFocusOrder(second, 2);
783   Stage::GetCurrent().Add(second);
784
785   // Check that no actor is being focused yet.
786   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
787
788   // Check that the focus is set on the first actor
789   DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
790   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
791
792   // Check that the focus is set on the second actor
793   DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
794   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
795
796   // Clear the focus
797   manager.ClearFocus();
798
799   // Check that no actor is being focused now.
800   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
801   END_TEST;
802 }
803
804 int UtcDaliAccessibilityManagerReset(void)
805 {
806   ToolkitTestApplication application;
807
808   tet_infoline(" UtcDaliAccessibilityManagerReset");
809
810   AccessibilityManager manager = AccessibilityManager::Get();
811   DALI_TEST_CHECK(manager);
812
813   // Create the first actor and add it to the stage
814   Actor first = Actor::New();
815   manager.SetFocusOrder(first, 1);
816   Stage::GetCurrent().Add(first);
817
818   // Create the second actor and add it to the stage
819   Actor second = Actor::New();
820   manager.SetFocusOrder(second, 2);
821   Stage::GetCurrent().Add(second);
822
823   // Check that no actor is being focused yet.
824   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
825
826   // Check that the focus is set on the first actor
827   DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
828   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
829
830   // Check that the focus is set on the second actor
831   DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
832   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
833
834   // Clear the focus
835   manager.Reset();
836
837   // Check that no actor is being focused now and the focus order of actors have been cleared
838   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
839   DALI_TEST_CHECK(manager.GetFocusOrder(first) == 0);
840   DALI_TEST_CHECK(manager.GetFocusOrder(first) == 0);
841   END_TEST;
842 }
843
844 int UtcDaliAccessibilityManagerFocusGroup(void)
845 {
846   ToolkitTestApplication application;
847
848   tet_infoline(" UtcDaliAccessibilityManagerFocusGroup");
849
850   AccessibilityManager manager = AccessibilityManager::Get();
851   DALI_TEST_CHECK(manager);
852
853   // Create an actor with two child actors and add it to the stage
854   Actor parent = Actor::New();
855   Actor firstChild = Actor::New();
856   Actor secondChild = Actor::New();
857   parent.Add(firstChild);
858   parent.Add(secondChild);
859   Stage::GetCurrent().Add(parent);
860
861   // Create three actors and add them as the children of the first child actor
862   Actor firstGrandChild = Actor::New();
863   Actor secondGrandChild = Actor::New();
864   Actor thirdGrandChild = Actor::New();
865   firstChild.Add(firstGrandChild);
866   firstChild.Add(secondGrandChild);
867   firstChild.Add(thirdGrandChild);
868
869   // Set focus order to the actors
870   manager.SetFocusOrder(parent, 1);
871   manager.SetFocusOrder(firstChild, 2);
872   manager.SetFocusOrder(firstGrandChild, 3);
873   manager.SetFocusOrder(secondGrandChild, 4);
874   manager.SetFocusOrder(thirdGrandChild, 5);
875   manager.SetFocusOrder(secondChild, 6);
876
877   // Set the parent and the first child actor as focus groups
878   manager.SetFocusGroup(parent, true);
879   DALI_TEST_CHECK(manager.IsFocusGroup(parent) == true);
880
881   // The focus group of the parent should be itself, as it is set to be a focus group.
882   DALI_TEST_CHECK(manager.GetFocusGroup(parent) == parent);
883
884   // The focus group of the firstChild should be its parent, as it is the immediate parent which is also a group.
885   DALI_TEST_CHECK(manager.GetFocusGroup(firstChild) == parent);
886
887   manager.SetFocusGroup(firstChild, true);
888   DALI_TEST_CHECK(manager.IsFocusGroup(firstChild) == true);
889
890   // The focus group of the firstChild should be itself, as it is set to be a focus group now.
891   DALI_TEST_CHECK(manager.GetFocusGroup(firstChild) == firstChild);
892
893   // Enable wrap mode for focus movement.
894   manager.SetWrapMode(true);
895   DALI_TEST_CHECK(manager.GetWrapMode() == true);
896
897   // Check that no actor is being focused yet.
898   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
899
900   // Check that the focus is set on the parent actor.
901   DALI_TEST_CHECK(manager.SetCurrentFocusActor(parent) == true);
902   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == parent);
903
904   // Check that group mode is disabled.
905   DALI_TEST_CHECK(manager.GetGroupMode() == false);
906
907   // Check that the focus movement is wrapped as normal.
908   DALI_TEST_CHECK(manager.MoveFocusForward() == true);
909   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstChild);
910   DALI_TEST_CHECK(manager.MoveFocusForward() == true);
911   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild);
912   DALI_TEST_CHECK(manager.MoveFocusForward() == true);
913   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondGrandChild);
914   DALI_TEST_CHECK(manager.MoveFocusForward() == true);
915   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == thirdGrandChild);
916   DALI_TEST_CHECK(manager.MoveFocusForward() == true);
917   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondChild);
918   DALI_TEST_CHECK(manager.MoveFocusForward() == true);
919   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == parent);
920   DALI_TEST_CHECK(manager.MoveFocusForward() == true);
921   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstChild);
922   DALI_TEST_CHECK(manager.MoveFocusForward() == true);
923   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild);
924
925   // Enable the group mode.
926   manager.SetGroupMode(true);
927   DALI_TEST_CHECK(manager.GetGroupMode() == true);
928
929   // Check that the focus movement is now limited to the current focus group.
930   DALI_TEST_CHECK(manager.MoveFocusForward() == true);
931   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondGrandChild);
932   DALI_TEST_CHECK(manager.MoveFocusForward() == true);
933   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == thirdGrandChild);
934   DALI_TEST_CHECK(manager.MoveFocusForward() == true);
935   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstChild);
936   DALI_TEST_CHECK(manager.MoveFocusForward() == true);
937   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild);
938   END_TEST;
939 }
940
941 int UtcDaliAccessibilityManagerSetAndGetFocusIndicator(void)
942 {
943   ToolkitTestApplication application;
944
945   tet_infoline(" UtcDaliAccessibilityManagerSetAndGetFocusIndicator");
946
947   AccessibilityManager manager = AccessibilityManager::Get();
948   DALI_TEST_CHECK(manager);
949
950   Actor defaultFocusIndicatorActor = manager.GetFocusIndicatorActor();
951   DALI_TEST_CHECK(defaultFocusIndicatorActor);
952
953   Actor newFocusIndicatorActor = Actor::New();
954   manager.SetFocusIndicatorActor(newFocusIndicatorActor);
955   DALI_TEST_CHECK(manager.GetFocusIndicatorActor() == newFocusIndicatorActor);
956   END_TEST;
957 }
958
959 int UtcDaliAccessibilityManagerSignalFocusChanged(void)
960 {
961   ToolkitTestApplication application;
962
963   tet_infoline(" UtcDaliAccessibilityManagerSignalFocusChanged");
964
965   AccessibilityManager manager = AccessibilityManager::Get();
966   DALI_TEST_CHECK(manager);
967
968   bool signalVerified = false;
969   FocusChangedCallback callback(signalVerified);
970   manager.FocusChangedSignal().Connect( &callback, &FocusChangedCallback::Callback );
971
972   // Create the first actor and add it to the stage
973   Actor first = Actor::New();
974   manager.SetFocusOrder(first, 1);
975   Stage::GetCurrent().Add(first);
976
977   // Create the second actor and add it to the stage
978   Actor second = Actor::New();
979   manager.SetFocusOrder(second, 2);
980   Stage::GetCurrent().Add(second);
981
982   // Check that no actor is being focused yet.
983   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
984
985   // Check that the focus is set on the first actor
986   DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
987   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
988   DALI_TEST_CHECK(callback.mSignalVerified);
989   callback.Reset();
990
991   // Check that the focus is set on the second actor
992   DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
993   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
994   DALI_TEST_CHECK(callback.mSignalVerified);
995   callback.Reset();
996
997   // Clear the focus
998   manager.ClearFocus();
999
1000   // Check that no actor is being focused now.
1001   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
1002   DALI_TEST_CHECK(callback.mSignalVerified);
1003   END_TEST;
1004 }
1005
1006 int UtcDaliAccessibilityManagerSignalFocusOvershot(void)
1007 {
1008   ToolkitTestApplication application;
1009
1010   tet_infoline(" UtcDaliAccessibilityManagerSignalFocusOvershot");
1011
1012   AccessibilityManager manager = AccessibilityManager::Get();
1013   DALI_TEST_CHECK(manager);
1014
1015   bool signalVerified = false;
1016   FocusOvershotCallback callback(signalVerified);
1017   manager.FocusOvershotSignal().Connect(&callback, &FocusOvershotCallback::Callback);
1018
1019   // Create the first actor and add it to the stage
1020   Actor first = Actor::New();
1021   manager.SetFocusOrder(first, 1);
1022   Stage::GetCurrent().Add(first);
1023
1024   // Create the second actor and add it to the stage
1025   Actor second = Actor::New();
1026   manager.SetFocusOrder(second, 2);
1027   Stage::GetCurrent().Add(second);
1028
1029   // Check that the wrap mode is disabled
1030   DALI_TEST_CHECK(manager.GetWrapMode() == false);
1031
1032   // Check that the focus is set on the first actor
1033   DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
1034   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
1035
1036   // Check that the focus is moved to the second actor successfully.
1037   DALI_TEST_CHECK(manager.MoveFocusForward() == true);
1038   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
1039
1040   // Check that the forward focus movement is overshot.
1041   callback.mCurrentFocusedActor = second;
1042   callback.mFocusOvershotDirection = Toolkit::AccessibilityManager::OVERSHOT_NEXT;
1043   DALI_TEST_CHECK(manager.MoveFocusForward() == false);
1044   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
1045   DALI_TEST_CHECK(signalVerified);
1046   callback.Reset();
1047
1048   // Enable the wrap mode
1049   manager.SetWrapMode(true);
1050   DALI_TEST_CHECK(manager.GetWrapMode() == true);
1051
1052   // Check that the forward focus movement is wrapped and no overshot happens.
1053   DALI_TEST_CHECK(manager.MoveFocusForward() == true);
1054   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
1055   DALI_TEST_CHECK(signalVerified == false);
1056
1057   // Disable the wrap mode
1058   manager.SetWrapMode(false);
1059   DALI_TEST_CHECK(manager.GetWrapMode() == false);
1060
1061   // Check that the backward focus movement is overshot.
1062   callback.mCurrentFocusedActor = first;
1063   callback.mFocusOvershotDirection = Toolkit::AccessibilityManager::OVERSHOT_PREVIOUS;
1064   DALI_TEST_CHECK(manager.MoveFocusBackward() == false);
1065   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
1066   DALI_TEST_CHECK(signalVerified);
1067   END_TEST;
1068 }
1069
1070 int UtcDaliAccessibilityManagerSignalFocusedActorActivated(void)
1071 {
1072   ToolkitTestApplication application;
1073
1074   tet_infoline(" UtcDaliAccessibilityManagerSignalFocusedActorActivated");
1075
1076   AccessibilityManager manager = AccessibilityManager::Get();
1077   DALI_TEST_CHECK(manager);
1078
1079   FocusedActorActivatedCallback callback;
1080   manager.FocusedActorActivatedSignal().Connect(&callback, &FocusedActorActivatedCallback::Callback);
1081   DALI_TEST_CHECK(true);
1082
1083   END_TEST;
1084 }
1085
1086 // Note: No negative test for GetReadPosition as it will always return something.
1087 int UtcDaliAccessibilityManagerGetReadPositionP(void)
1088 {
1089   ToolkitTestApplication application;
1090   tet_infoline(" UtcDaliAccessibilityManagerGetReadPositionP");
1091
1092   AccessibilityManager manager = AccessibilityManager::Get();
1093   DALI_TEST_CHECK( manager );
1094
1095   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1096   Vector2 position( 1.0f, 2.0f );
1097   accessibilityAdaptor.MockSetReadPosition( position );
1098
1099   DALI_TEST_EQUALS( manager.GetReadPosition(), position, TEST_LOCATION );
1100
1101   END_TEST;
1102 }
1103
1104 // Functor to test if an accessibility signal has been called.
1105 class AccessibilityManagerSignalHandler : public Dali::ConnectionTracker
1106 {
1107 public:
1108   AccessibilityManagerSignalHandler() :
1109     mCalls( 0 )
1110   {
1111   }
1112
1113   bool Callback( AccessibilityManager& accessibilityManager )
1114   {
1115     mCalls++;
1116     tet_infoline( "Signal called" );
1117     return true;
1118   }
1119
1120   unsigned int GetCalls() const
1121   {
1122     return mCalls;
1123   }
1124
1125 private:
1126   unsigned int mCalls;  ///< Keeps track of how many times the signal has been called.
1127 };
1128
1129 int UtcDaliAccessibilityManagerStatusChangedSignalP(void)
1130 {
1131   ToolkitTestApplication application;
1132   tet_infoline( " UtcDaliAccessibilityManagerStatusChangedSignalP" );
1133
1134   AccessibilityManagerSignalHandler callback;
1135
1136   AccessibilityManager manager = AccessibilityManager::Get();
1137   DALI_TEST_CHECK( manager );
1138
1139   manager.StatusChangedSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1140
1141   // Cause a state change.
1142   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1143   accessibilityAdaptor.HandleActionEnableEvent();
1144
1145   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1146
1147   END_TEST;
1148 }
1149
1150 int UtcDaliAccessibilityManagerStatusChangedSignalN(void)
1151 {
1152   ToolkitTestApplication application;
1153   tet_infoline( " UtcDaliAccessibilityManagerStatusChangedSignalN" );
1154
1155   AccessibilityManagerSignalHandler callback;
1156
1157   AccessibilityManager manager = AccessibilityManager::Get();
1158   DALI_TEST_CHECK( manager );
1159
1160   manager.StatusChangedSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1161   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1162
1163   END_TEST;
1164 }
1165
1166 int UtcDaliAccessibilityManagerActionNextSignalP(void)
1167 {
1168   ToolkitTestApplication application;
1169   tet_infoline( " UtcDaliAccessibilityManagerActionNextSignalP" );
1170
1171   AccessibilityManagerSignalHandler callback;
1172
1173   AccessibilityManager manager = AccessibilityManager::Get();
1174   DALI_TEST_CHECK( manager );
1175
1176   manager.ActionNextSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1177
1178   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1179   accessibilityAdaptor.HandleActionNextEvent();
1180
1181   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1182
1183   END_TEST;
1184 }
1185
1186 int UtcDaliAccessibilityManagerActionNextSignalN(void)
1187 {
1188   ToolkitTestApplication application;
1189   tet_infoline( " UtcDaliAccessibilityManagerActionNextSignalN" );
1190
1191   AccessibilityManagerSignalHandler callback;
1192
1193   AccessibilityManager manager = AccessibilityManager::Get();
1194   DALI_TEST_CHECK( manager );
1195
1196   manager.ActionNextSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1197   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1198
1199   END_TEST;
1200 }
1201
1202 int UtcDaliAccessibilityManagerActionPreviousSignalP(void)
1203 {
1204   ToolkitTestApplication application;
1205   tet_infoline( " UtcDaliAccessibilityManagerActionPreviousSignalP" );
1206
1207   AccessibilityManagerSignalHandler callback;
1208
1209   AccessibilityManager manager = AccessibilityManager::Get();
1210   DALI_TEST_CHECK( manager );
1211
1212   manager.ActionPreviousSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1213
1214   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1215   accessibilityAdaptor.HandleActionPreviousEvent();
1216
1217   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1218
1219   END_TEST;
1220 }
1221
1222 int UtcDaliAccessibilityManagerActionPreviousSignalN(void)
1223 {
1224   ToolkitTestApplication application;
1225   tet_infoline( " UtcDaliAccessibilityManagerActionPreviousSignalN" );
1226
1227   AccessibilityManagerSignalHandler callback;
1228
1229   AccessibilityManager manager = AccessibilityManager::Get();
1230   DALI_TEST_CHECK( manager );
1231
1232   manager.ActionPreviousSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1233   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1234
1235   END_TEST;
1236 }
1237
1238 int UtcDaliAccessibilityManagerActionActivateSignalP(void)
1239 {
1240   ToolkitTestApplication application;
1241   tet_infoline( " UtcDaliAccessibilityManagerActionActivateSignalP" );
1242
1243   AccessibilityManagerSignalHandler callback;
1244
1245   AccessibilityManager manager = AccessibilityManager::Get();
1246   DALI_TEST_CHECK( manager );
1247
1248   manager.ActionActivateSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1249
1250   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1251   accessibilityAdaptor.HandleActionActivateEvent();
1252
1253   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1254
1255   END_TEST;
1256 }
1257
1258 int UtcDaliAccessibilityManagerActionActivateSignalN(void)
1259 {
1260   ToolkitTestApplication application;
1261   tet_infoline( " UtcDaliAccessibilityManagerActionActivateSignalN" );
1262
1263   AccessibilityManagerSignalHandler callback;
1264
1265   AccessibilityManager manager = AccessibilityManager::Get();
1266   DALI_TEST_CHECK( manager );
1267
1268   manager.ActionActivateSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1269   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1270
1271   END_TEST;
1272 }
1273
1274 int UtcDaliAccessibilityManagerActionReadSignalP(void)
1275 {
1276   ToolkitTestApplication application;
1277   tet_infoline( " UtcDaliAccessibilityManagerActionReadSignalP" );
1278
1279   AccessibilityManagerSignalHandler callback;
1280
1281   AccessibilityManager manager = AccessibilityManager::Get();
1282   DALI_TEST_CHECK( manager );
1283
1284   manager.ActionReadSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1285
1286   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1287   accessibilityAdaptor.HandleActionReadEvent( 100.0f, 200.0f, true );
1288
1289   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1290
1291   END_TEST;
1292 }
1293
1294 int UtcDaliAccessibilityManagerActionReadSignalN(void)
1295 {
1296   ToolkitTestApplication application;
1297   tet_infoline( " UtcDaliAccessibilityManagerActionReadSignalN" );
1298
1299   AccessibilityManagerSignalHandler callback;
1300
1301   AccessibilityManager manager = AccessibilityManager::Get();
1302   DALI_TEST_CHECK( manager );
1303
1304   manager.ActionReadSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1305   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1306
1307   END_TEST;
1308 }
1309
1310 int UtcDaliAccessibilityManagerActionOverSignalP(void)
1311 {
1312   ToolkitTestApplication application;
1313   tet_infoline( " UtcDaliAccessibilityManagerActionOverSignalP" );
1314
1315   AccessibilityManagerSignalHandler callback;
1316
1317   AccessibilityManager manager = AccessibilityManager::Get();
1318   DALI_TEST_CHECK( manager );
1319
1320   manager.ActionOverSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1321
1322   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1323   // Note that the ActionOverSignal is provoked by a read even when "allow read again" is set to false.
1324   accessibilityAdaptor.HandleActionReadEvent( 100.0f, 200.0f, false );
1325
1326   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1327
1328   END_TEST;
1329 }
1330
1331 int UtcDaliAccessibilityManagerActionOverSignalN(void)
1332 {
1333   ToolkitTestApplication application;
1334   tet_infoline( " UtcDaliAccessibilityManagerActionOverSignalN" );
1335
1336   AccessibilityManagerSignalHandler callback;
1337
1338   AccessibilityManager manager = AccessibilityManager::Get();
1339   DALI_TEST_CHECK( manager );
1340
1341   manager.ActionOverSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1342   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1343
1344   END_TEST;
1345 }
1346
1347 int UtcDaliAccessibilityManagerActionReadNextSignalP(void)
1348 {
1349   ToolkitTestApplication application;
1350   tet_infoline( " UtcDaliAccessibilityManagerActionReadNextSignalP" );
1351
1352   AccessibilityManagerSignalHandler callback;
1353
1354   AccessibilityManager manager = AccessibilityManager::Get();
1355   DALI_TEST_CHECK( manager );
1356
1357   manager.ActionReadNextSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1358
1359   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1360   accessibilityAdaptor.HandleActionReadNextEvent();
1361
1362   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1363
1364   END_TEST;
1365 }
1366
1367 int UtcDaliAccessibilityManagerActionReadNextSignalN(void)
1368 {
1369   ToolkitTestApplication application;
1370   tet_infoline( " UtcDaliAccessibilityManagerActionReadNextSignalN" );
1371
1372   AccessibilityManagerSignalHandler callback;
1373
1374   AccessibilityManager manager = AccessibilityManager::Get();
1375   DALI_TEST_CHECK( manager );
1376
1377   manager.ActionReadNextSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1378   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1379
1380   END_TEST;
1381 }
1382
1383 int UtcDaliAccessibilityManagerActionReadPreviousSignalP(void)
1384 {
1385   ToolkitTestApplication application;
1386   tet_infoline( " UtcDaliAccessibilityManagerActionReadPreviousSignalP" );
1387
1388   AccessibilityManagerSignalHandler callback;
1389
1390   AccessibilityManager manager = AccessibilityManager::Get();
1391   DALI_TEST_CHECK( manager );
1392
1393   manager.ActionReadPreviousSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1394
1395   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1396   accessibilityAdaptor.HandleActionReadPreviousEvent();
1397
1398   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1399
1400   END_TEST;
1401 }
1402
1403 int UtcDaliAccessibilityManagerActionReadPreviousSignalN(void)
1404 {
1405   ToolkitTestApplication application;
1406   tet_infoline( " UtcDaliAccessibilityManagerActionReadPreviousSignalN" );
1407
1408   AccessibilityManagerSignalHandler callback;
1409
1410   AccessibilityManager manager = AccessibilityManager::Get();
1411   DALI_TEST_CHECK( manager );
1412
1413   manager.ActionReadPreviousSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1414   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1415
1416   END_TEST;
1417 }
1418
1419 int UtcDaliAccessibilityManagerActionUpSignalP(void)
1420 {
1421   ToolkitTestApplication application;
1422   tet_infoline( " UtcDaliAccessibilityManagerActionUpSignalP" );
1423
1424   AccessibilityManagerSignalHandler callback;
1425
1426   AccessibilityManager manager = AccessibilityManager::Get();
1427   DALI_TEST_CHECK( manager );
1428
1429   manager.ActionUpSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1430
1431   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1432   accessibilityAdaptor.HandleActionUpEvent();
1433
1434   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1435
1436   END_TEST;
1437 }
1438
1439 int UtcDaliAccessibilityManagerActionUpSignalN(void)
1440 {
1441   ToolkitTestApplication application;
1442   tet_infoline( " UtcDaliAccessibilityManagerActionUpSignalN" );
1443
1444   AccessibilityManagerSignalHandler callback;
1445
1446   AccessibilityManager manager = AccessibilityManager::Get();
1447   DALI_TEST_CHECK( manager );
1448
1449   manager.ActionUpSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1450   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1451
1452   END_TEST;
1453 }
1454
1455 int UtcDaliAccessibilityManagerActionDownSignalP(void)
1456 {
1457   ToolkitTestApplication application;
1458   tet_infoline( " UtcDaliAccessibilityManagerActionDownSignalP" );
1459
1460   AccessibilityManagerSignalHandler callback;
1461
1462   AccessibilityManager manager = AccessibilityManager::Get();
1463   DALI_TEST_CHECK( manager );
1464
1465   manager.ActionDownSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1466
1467   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1468   accessibilityAdaptor.HandleActionDownEvent();
1469
1470   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1471
1472   END_TEST;
1473 }
1474
1475 int UtcDaliAccessibilityManagerActionDownSignalN(void)
1476 {
1477   ToolkitTestApplication application;
1478   tet_infoline( " UtcDaliAccessibilityManagerActionDownSignalN" );
1479
1480   AccessibilityManagerSignalHandler callback;
1481
1482   AccessibilityManager manager = AccessibilityManager::Get();
1483   DALI_TEST_CHECK( manager );
1484
1485   manager.ActionDownSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1486   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1487
1488   END_TEST;
1489 }
1490
1491 int UtcDaliAccessibilityManagerActionClearFocusSignalP(void)
1492 {
1493   ToolkitTestApplication application;
1494   tet_infoline( " UtcDaliAccessibilityManagerActionClearFocusSignalP" );
1495
1496   AccessibilityManagerSignalHandler callback;
1497
1498   AccessibilityManager manager = AccessibilityManager::Get();
1499   DALI_TEST_CHECK( manager );
1500
1501   manager.ActionClearFocusSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1502
1503   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1504   accessibilityAdaptor.HandleActionClearFocusEvent();
1505
1506   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1507
1508   END_TEST;
1509 }
1510
1511 int UtcDaliAccessibilityManagerActionClearFocusSignalN(void)
1512 {
1513   ToolkitTestApplication application;
1514   tet_infoline( " UtcDaliAccessibilityManagerActionClearFocusSignalN" );
1515
1516   AccessibilityManagerSignalHandler callback;
1517
1518   AccessibilityManager manager = AccessibilityManager::Get();
1519   DALI_TEST_CHECK( manager );
1520
1521   manager.ActionClearFocusSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1522   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1523
1524   END_TEST;
1525 }
1526
1527 int UtcDaliAccessibilityManagerActionBackSignalP(void)
1528 {
1529   ToolkitTestApplication application;
1530   tet_infoline( " UtcDaliAccessibilityManagerActionBackSignalP" );
1531
1532   AccessibilityManagerSignalHandler callback;
1533
1534   AccessibilityManager manager = AccessibilityManager::Get();
1535   DALI_TEST_CHECK( manager );
1536
1537   manager.ActionBackSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1538
1539   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1540   accessibilityAdaptor.HandleActionBackEvent();
1541
1542   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1543
1544   END_TEST;
1545 }
1546
1547 int UtcDaliAccessibilityManagerActionBackSignalN(void)
1548 {
1549   ToolkitTestApplication application;
1550   tet_infoline( " UtcDaliAccessibilityManagerActionBackSignalN" );
1551
1552   AccessibilityManagerSignalHandler callback;
1553
1554   AccessibilityManager manager = AccessibilityManager::Get();
1555   DALI_TEST_CHECK( manager );
1556
1557   manager.ActionBackSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1558   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1559
1560   END_TEST;
1561 }
1562
1563 int UtcDaliAccessibilityManagerActionScrollUpSignalP(void)
1564 {
1565   ToolkitTestApplication application;
1566   tet_infoline( " UtcDaliAccessibilityManagerActionScrollUpSignalP" );
1567
1568   AccessibilityManagerSignalHandler callback;
1569
1570   AccessibilityManager manager = AccessibilityManager::Get();
1571   DALI_TEST_CHECK( manager );
1572
1573   manager.ActionScrollUpSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1574
1575   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1576   accessibilityAdaptor.HandleActionScrollUpEvent();
1577
1578   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1579
1580   END_TEST;
1581 }
1582
1583 int UtcDaliAccessibilityManagerActionScrollUpSignalN(void)
1584 {
1585   ToolkitTestApplication application;
1586   tet_infoline( " UtcDaliAccessibilityManagerActionScrollUpSignalN" );
1587
1588   AccessibilityManagerSignalHandler callback;
1589
1590   AccessibilityManager manager = AccessibilityManager::Get();
1591   DALI_TEST_CHECK( manager );
1592
1593   manager.ActionScrollUpSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1594   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1595
1596   END_TEST;
1597 }
1598
1599 int UtcDaliAccessibilityManagerActionScrollDownSignalP(void)
1600 {
1601   ToolkitTestApplication application;
1602   tet_infoline( " UtcDaliAccessibilityManagerActionScrollDownSignalP" );
1603
1604   AccessibilityManagerSignalHandler callback;
1605
1606   AccessibilityManager manager = AccessibilityManager::Get();
1607   DALI_TEST_CHECK( manager );
1608
1609   manager.ActionScrollDownSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1610
1611   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1612   accessibilityAdaptor.HandleActionScrollDownEvent();
1613
1614   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1615
1616   END_TEST;
1617 }
1618
1619 int UtcDaliAccessibilityManagerActionScrollDownSignalN(void)
1620 {
1621   ToolkitTestApplication application;
1622   tet_infoline( " UtcDaliAccessibilityManagerActionScrollDownSignalN" );
1623
1624   AccessibilityManagerSignalHandler callback;
1625
1626   AccessibilityManager manager = AccessibilityManager::Get();
1627   DALI_TEST_CHECK( manager );
1628
1629   manager.ActionScrollDownSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1630   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1631
1632   END_TEST;
1633 }
1634
1635 int UtcDaliAccessibilityManagerActionPageLeftSignalP(void)
1636 {
1637   ToolkitTestApplication application;
1638   tet_infoline( " UtcDaliAccessibilityManagerActionPageLeftSignalP" );
1639
1640   AccessibilityManagerSignalHandler callback;
1641
1642   AccessibilityManager manager = AccessibilityManager::Get();
1643   DALI_TEST_CHECK( manager );
1644
1645   manager.ActionPageLeftSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1646
1647   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1648   accessibilityAdaptor.HandleActionPageLeftEvent();
1649
1650   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1651
1652   END_TEST;
1653 }
1654
1655 int UtcDaliAccessibilityManagerActionPageLeftSignalN(void)
1656 {
1657   ToolkitTestApplication application;
1658   tet_infoline( " UtcDaliAccessibilityManagerActionPageLeftSignalN" );
1659
1660   AccessibilityManagerSignalHandler callback;
1661
1662   AccessibilityManager manager = AccessibilityManager::Get();
1663   DALI_TEST_CHECK( manager );
1664
1665   manager.ActionPageLeftSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1666   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1667
1668   END_TEST;
1669 }
1670
1671 int UtcDaliAccessibilityManagerActionPageRightSignalP(void)
1672 {
1673   ToolkitTestApplication application;
1674   tet_infoline( " UtcDaliAccessibilityManagerActionPageRightSignalP" );
1675
1676   AccessibilityManagerSignalHandler callback;
1677
1678   AccessibilityManager manager = AccessibilityManager::Get();
1679   DALI_TEST_CHECK( manager );
1680
1681   manager.ActionPageRightSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1682
1683   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1684   accessibilityAdaptor.HandleActionPageRightEvent();
1685
1686   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1687
1688   END_TEST;
1689 }
1690
1691 int UtcDaliAccessibilityManagerActionPageRightSignalN(void)
1692 {
1693   ToolkitTestApplication application;
1694   tet_infoline( " UtcDaliAccessibilityManagerActionPageRightSignalN" );
1695
1696   AccessibilityManagerSignalHandler callback;
1697
1698   AccessibilityManager manager = AccessibilityManager::Get();
1699   DALI_TEST_CHECK( manager );
1700
1701   manager.ActionPageRightSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1702   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1703
1704   END_TEST;
1705 }
1706
1707 int UtcDaliAccessibilityManagerActionPageUpSignalP(void)
1708 {
1709   ToolkitTestApplication application;
1710   tet_infoline( " UtcDaliAccessibilityManagerActionPageUpSignalP" );
1711
1712   AccessibilityManagerSignalHandler callback;
1713
1714   AccessibilityManager manager = AccessibilityManager::Get();
1715   DALI_TEST_CHECK( manager );
1716
1717   manager.ActionPageUpSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1718
1719   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1720   accessibilityAdaptor.HandleActionPageUpEvent();
1721
1722   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1723
1724   END_TEST;
1725 }
1726
1727 int UtcDaliAccessibilityManagerActionPageUpSignalN(void)
1728 {
1729   ToolkitTestApplication application;
1730   tet_infoline( " UtcDaliAccessibilityManagerActionPageUpSignalN" );
1731
1732   AccessibilityManagerSignalHandler callback;
1733
1734   AccessibilityManager manager = AccessibilityManager::Get();
1735   DALI_TEST_CHECK( manager );
1736
1737   manager.ActionPageUpSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1738   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1739
1740   END_TEST;
1741 }
1742
1743 int UtcDaliAccessibilityManagerActionPageDownSignalP(void)
1744 {
1745   ToolkitTestApplication application;
1746   tet_infoline( " UtcDaliAccessibilityManagerActionPageDownSignalP" );
1747
1748   AccessibilityManagerSignalHandler callback;
1749
1750   AccessibilityManager manager = AccessibilityManager::Get();
1751   DALI_TEST_CHECK( manager );
1752
1753   manager.ActionPageDownSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1754
1755   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1756   accessibilityAdaptor.HandleActionPageDownEvent();
1757
1758   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1759
1760   END_TEST;
1761 }
1762
1763 int UtcDaliAccessibilityManagerActionPageDownSignalN(void)
1764 {
1765   ToolkitTestApplication application;
1766   tet_infoline( " UtcDaliAccessibilityManagerActionPageDownSignalN" );
1767
1768   AccessibilityManagerSignalHandler callback;
1769
1770   AccessibilityManager manager = AccessibilityManager::Get();
1771   DALI_TEST_CHECK( manager );
1772
1773   manager.ActionPageDownSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1774   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1775
1776   END_TEST;
1777 }
1778
1779 int UtcDaliAccessibilityManagerActionMoveToFirstSignalP(void)
1780 {
1781   ToolkitTestApplication application;
1782   tet_infoline( " UtcDaliAccessibilityManagerActionMoveToFirstSignalP" );
1783
1784   AccessibilityManagerSignalHandler callback;
1785
1786   AccessibilityManager manager = AccessibilityManager::Get();
1787   DALI_TEST_CHECK( manager );
1788
1789   manager.ActionMoveToFirstSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1790
1791   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1792   accessibilityAdaptor.HandleActionMoveToFirstEvent();
1793
1794   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1795
1796   END_TEST;
1797 }
1798
1799 int UtcDaliAccessibilityManagerActionMoveToFirstSignalN(void)
1800 {
1801   ToolkitTestApplication application;
1802   tet_infoline( " UtcDaliAccessibilityManagerActionMoveToFirstSignalN" );
1803
1804   AccessibilityManagerSignalHandler callback;
1805
1806   AccessibilityManager manager = AccessibilityManager::Get();
1807   DALI_TEST_CHECK( manager );
1808
1809   manager.ActionMoveToFirstSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1810   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1811
1812   END_TEST;
1813 }
1814
1815 int UtcDaliAccessibilityManagerActionMoveToLastSignalP(void)
1816 {
1817   ToolkitTestApplication application;
1818   tet_infoline( " UtcDaliAccessibilityManagerActionMoveToLastSignalP" );
1819
1820   AccessibilityManagerSignalHandler callback;
1821
1822   AccessibilityManager manager = AccessibilityManager::Get();
1823   DALI_TEST_CHECK( manager );
1824
1825   manager.ActionMoveToLastSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1826
1827   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1828   accessibilityAdaptor.HandleActionMoveToLastEvent();
1829
1830   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1831
1832   END_TEST;
1833 }
1834
1835 int UtcDaliAccessibilityManagerActionMoveToLastSignalN(void)
1836 {
1837   ToolkitTestApplication application;
1838   tet_infoline( " UtcDaliAccessibilityManagerActionMoveToLastSignalN" );
1839
1840   AccessibilityManagerSignalHandler callback;
1841
1842   AccessibilityManager manager = AccessibilityManager::Get();
1843   DALI_TEST_CHECK( manager );
1844
1845   manager.ActionMoveToLastSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1846   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1847
1848   END_TEST;
1849 }
1850
1851 int UtcDaliAccessibilityManagerActionReadFromTopSignalP(void)
1852 {
1853   ToolkitTestApplication application;
1854   tet_infoline( " UtcDaliAccessibilityManagerActionReadFromTopSignalP" );
1855
1856   AccessibilityManagerSignalHandler callback;
1857
1858   AccessibilityManager manager = AccessibilityManager::Get();
1859   DALI_TEST_CHECK( manager );
1860
1861   manager.ActionReadFromTopSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1862
1863   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1864   accessibilityAdaptor.HandleActionReadFromTopEvent();
1865
1866   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1867
1868   END_TEST;
1869 }
1870
1871 int UtcDaliAccessibilityManagerActionReadFromTopSignalN(void)
1872 {
1873   ToolkitTestApplication application;
1874   tet_infoline( " UtcDaliAccessibilityManagerActionReadFromTopSignalN" );
1875
1876   AccessibilityManagerSignalHandler callback;
1877
1878   AccessibilityManager manager = AccessibilityManager::Get();
1879   DALI_TEST_CHECK( manager );
1880
1881   manager.ActionReadFromTopSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1882   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1883
1884   END_TEST;
1885 }
1886
1887 int UtcDaliAccessibilityManagerActionReadFromNextSignalP(void)
1888 {
1889   ToolkitTestApplication application;
1890   tet_infoline( " UtcDaliAccessibilityManagerActionReadFromNextSignalP" );
1891
1892   AccessibilityManagerSignalHandler callback;
1893
1894   AccessibilityManager manager = AccessibilityManager::Get();
1895   DALI_TEST_CHECK( manager );
1896
1897   manager.ActionReadFromNextSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1898
1899   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1900   accessibilityAdaptor.HandleActionReadFromNextEvent();
1901
1902   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1903
1904   END_TEST;
1905 }
1906
1907 int UtcDaliAccessibilityManagerActionReadFromNextSignalN(void)
1908 {
1909   ToolkitTestApplication application;
1910   tet_infoline( " UtcDaliAccessibilityManagerActionReadFromNextSignalN" );
1911
1912   AccessibilityManagerSignalHandler callback;
1913
1914   AccessibilityManager manager = AccessibilityManager::Get();
1915   DALI_TEST_CHECK( manager );
1916
1917   manager.ActionReadFromNextSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1918   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1919
1920   END_TEST;
1921 }
1922
1923 int UtcDaliAccessibilityManagerActionZoomSignalP(void)
1924 {
1925   ToolkitTestApplication application;
1926   tet_infoline( " UtcDaliAccessibilityManagerActionZoomSignalP" );
1927
1928   AccessibilityManagerSignalHandler callback;
1929
1930   AccessibilityManager manager = AccessibilityManager::Get();
1931   DALI_TEST_CHECK( manager );
1932
1933   manager.ActionZoomSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1934
1935   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1936   accessibilityAdaptor.HandleActionZoomEvent();
1937
1938   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1939
1940   END_TEST;
1941 }
1942
1943 int UtcDaliAccessibilityManagerActionZoomSignalN(void)
1944 {
1945   ToolkitTestApplication application;
1946   tet_infoline( " UtcDaliAccessibilityManagerActionZoomSignalN" );
1947
1948   AccessibilityManagerSignalHandler callback;
1949
1950   AccessibilityManager manager = AccessibilityManager::Get();
1951   DALI_TEST_CHECK( manager );
1952
1953   manager.ActionZoomSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1954   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1955
1956   END_TEST;
1957 }
1958
1959 int UtcDaliAccessibilityManagerActionReadIndicatorInformationSignalP(void)
1960 {
1961   ToolkitTestApplication application;
1962   tet_infoline( " UtcDaliAccessibilityManagerActionReadIndicatorInformationSignalP" );
1963
1964   AccessibilityManagerSignalHandler callback;
1965
1966   AccessibilityManager manager = AccessibilityManager::Get();
1967   DALI_TEST_CHECK( manager );
1968
1969   manager.ActionReadIndicatorInformationSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1970
1971   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
1972   accessibilityAdaptor.HandleActionReadIndicatorInformationEvent();
1973
1974   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
1975
1976   END_TEST;
1977 }
1978
1979 int UtcDaliAccessibilityManagerActionReadIndicatorInformationSignalN(void)
1980 {
1981   ToolkitTestApplication application;
1982   tet_infoline( " UtcDaliAccessibilityManagerActionReadIndicatorInformationSignalN" );
1983
1984   AccessibilityManagerSignalHandler callback;
1985
1986   AccessibilityManager manager = AccessibilityManager::Get();
1987   DALI_TEST_CHECK( manager );
1988
1989   manager.ActionReadIndicatorInformationSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
1990   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
1991
1992   END_TEST;
1993 }
1994
1995 int UtcDaliAccessibilityManagerActionReadPauseResumeSignalP(void)
1996 {
1997   ToolkitTestApplication application;
1998   tet_infoline( " UtcDaliAccessibilityManagerActionReadPauseResumeSignalP" );
1999
2000   AccessibilityManagerSignalHandler callback;
2001
2002   AccessibilityManager manager = AccessibilityManager::Get();
2003   DALI_TEST_CHECK( manager );
2004
2005   manager.ActionReadPauseResumeSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
2006
2007   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
2008   accessibilityAdaptor.HandleActionReadPauseResumeEvent();
2009
2010   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
2011
2012   END_TEST;
2013 }
2014
2015 int UtcDaliAccessibilityManagerActionReadPauseResumeSignalN(void)
2016 {
2017   ToolkitTestApplication application;
2018   tet_infoline( " UtcDaliAccessibilityManagerActionReadPauseResumeSignalN" );
2019
2020   AccessibilityManagerSignalHandler callback;
2021
2022   AccessibilityManager manager = AccessibilityManager::Get();
2023   DALI_TEST_CHECK( manager );
2024
2025   manager.ActionReadPauseResumeSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
2026   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
2027
2028   END_TEST;
2029 }
2030
2031 int UtcDaliAccessibilityManagerActionStartStopSignalP(void)
2032 {
2033   ToolkitTestApplication application;
2034   tet_infoline( " UtcDaliAccessibilityManagerActionStartStopSignalP" );
2035
2036   AccessibilityManagerSignalHandler callback;
2037
2038   AccessibilityManager manager = AccessibilityManager::Get();
2039   DALI_TEST_CHECK( manager );
2040
2041   manager.ActionStartStopSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
2042
2043   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
2044   accessibilityAdaptor.HandleActionStartStopEvent();
2045
2046   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
2047
2048   END_TEST;
2049 }
2050
2051 int UtcDaliAccessibilityManagerActionStartStopSignalN(void)
2052 {
2053   ToolkitTestApplication application;
2054   tet_infoline( " UtcDaliAccessibilityManagerActionStartStopSignalN" );
2055
2056   AccessibilityManagerSignalHandler callback;
2057
2058   AccessibilityManager manager = AccessibilityManager::Get();
2059   DALI_TEST_CHECK( manager );
2060
2061   manager.ActionStartStopSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback );
2062   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
2063
2064   END_TEST;
2065 }
2066
2067 // Functor to test if a accessibility scroll signal has been called.
2068 class AccessibilityManagerScrollSignalHandler : public Dali::ConnectionTracker
2069 {
2070 public:
2071   AccessibilityManagerScrollSignalHandler() :
2072     mCalls( 0 )
2073   {
2074   }
2075
2076   bool Callback( AccessibilityManager& accessibilityManager, const Dali::TouchEvent& touchEvent )
2077   {
2078     mCalls++;
2079     mTouchEvent = touchEvent;
2080     tet_infoline( "Signal called" );
2081     return true;
2082   }
2083
2084   unsigned int GetCalls() const
2085   {
2086     return mCalls;
2087   }
2088
2089   const Dali::TouchEvent& GetTouchEvent() const
2090   {
2091     return mTouchEvent;
2092   }
2093
2094 private:
2095   unsigned int mCalls;         ///< Keeps track of how many times the signal has been called.
2096   Dali::TouchEvent mTouchEvent; ///< Stores the last touch event received.
2097 };
2098
2099 int UtcDaliAccessibilityManagerActionScrollSignalP(void)
2100 {
2101   ToolkitTestApplication application;
2102   tet_infoline( " UtcDaliAccessibilityManagerActionScrollSignalP" );
2103
2104   AccessibilityManagerScrollSignalHandler callback;
2105
2106   AccessibilityManager manager = AccessibilityManager::Get();
2107   DALI_TEST_CHECK( manager );
2108
2109   manager.ActionScrollSignal().Connect( &callback, &AccessibilityManagerScrollSignalHandler::Callback );
2110
2111   Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get();
2112
2113   TouchPoint point( 0, TouchPoint::Started, 100.0f, 200.0f );
2114   accessibilityAdaptor.HandleActionScrollEvent( point, 0u );
2115
2116   DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION );
2117
2118   const TouchEvent& signalTouchEvent = callback.GetTouchEvent();
2119   DALI_TEST_EQUALS( signalTouchEvent.GetPointCount(), 1u, TEST_LOCATION );
2120
2121   const TouchPoint& signalTouchPoint = signalTouchEvent.GetPoint( 0u );
2122
2123   DALI_TEST_EQUALS( signalTouchPoint.state, TouchPoint::Started, TEST_LOCATION );
2124   DALI_TEST_EQUALS( signalTouchPoint.screen.x, 100.0f, TEST_LOCATION );
2125   DALI_TEST_EQUALS( signalTouchPoint.screen.y, 200.0f, TEST_LOCATION );
2126
2127   END_TEST;
2128 }
2129
2130 int UtcDaliAccessibilityManagerActionScrollSignalN(void)
2131 {
2132   ToolkitTestApplication application;
2133   tet_infoline( " UtcDaliAccessibilityManagerActionScrollSignalN" );
2134
2135   AccessibilityManagerScrollSignalHandler callback;
2136
2137   AccessibilityManager manager = AccessibilityManager::Get();
2138   DALI_TEST_CHECK( manager );
2139
2140   manager.ActionScrollSignal().Connect( &callback, &AccessibilityManagerScrollSignalHandler::Callback );
2141
2142   DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION );
2143
2144   END_TEST;
2145 }