Changes in Javascript plugin to compile under new mesh api
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-KeyboardFocusManager.cpp
1 /*
2  * Copyright (c) 2014 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
25 #include <dali-toolkit/dali-toolkit.h>
26 #include <dali/integration-api/events/key-event-integ.h>
27
28
29 using namespace Dali;
30 using namespace Dali::Toolkit;
31
32 void utc_dali_toolkit_keyboard_focus_manager_startup(void)
33 {
34   test_return_value = TET_UNDEF;
35 }
36
37 void utc_dali_toolkit_keyboard_focus_manager_cleanup(void)
38 {
39   test_return_value = TET_PASS;
40 }
41
42
43 namespace
44 {
45
46 // Functors to test whether PreFocusChange signal is emitted when the keyboard focus is about to change
47 class PreFocusChangeCallback : public Dali::ConnectionTracker
48 {
49 public:
50   PreFocusChangeCallback(bool& signalReceived)
51   : mSignalVerified(signalReceived),
52     mCurrentFocusedActor(),
53     mProposedActorToFocus(),
54     mDirection(Control::KeyboardFocus::LEFT)
55   {
56   }
57
58   Actor Callback(Actor currentFocusedActor, Actor proposedActorToFocus, Control::KeyboardFocus::Direction direction)
59   {
60     tet_infoline("Verifying PreFocusChangeCallback()");
61
62     mSignalVerified = true;
63
64     mCurrentFocusedActor = currentFocusedActor;
65     mProposedActorToFocus = proposedActorToFocus;
66     mDirection = direction;
67
68     return mProposedActorToFocus;
69   }
70
71   void Reset()
72   {
73     mSignalVerified = false;
74     mCurrentFocusedActor = Actor();
75     mProposedActorToFocus = Actor();
76     mDirection = Control::KeyboardFocus::LEFT;
77   }
78
79   bool& mSignalVerified;
80   Actor mCurrentFocusedActor;
81   Actor mProposedActorToFocus;
82   Control::KeyboardFocus::Direction mDirection;
83 };
84
85 // Functors to test whether focus changed signal is emitted when the keyboard focus is changed
86 class FocusChangedCallback : public Dali::ConnectionTracker
87 {
88 public:
89   FocusChangedCallback(bool& signalReceived)
90   : mSignalVerified(signalReceived),
91     mOriginalFocusedActor(),
92     mCurrentFocusedActor()
93   {
94   }
95
96   void Callback(Actor originalFocusedActor, Actor currentFocusedActor)
97   {
98     tet_infoline("Verifying FocusChangedCallback()");
99
100     if(originalFocusedActor == mCurrentFocusedActor)
101     {
102       mSignalVerified = true;
103     }
104
105     mOriginalFocusedActor = originalFocusedActor;
106     mCurrentFocusedActor = currentFocusedActor;
107   }
108
109   void Reset()
110   {
111     mSignalVerified = false;
112   }
113
114   bool& mSignalVerified;
115   Actor mOriginalFocusedActor;
116   Actor mCurrentFocusedActor;
117 };
118
119 // Functors to test whether focus group changed signal is emitted when the keyboard focus group is changed
120 class FocusGroupChangedCallback : public Dali::ConnectionTracker
121 {
122 public:
123   FocusGroupChangedCallback(bool& signalReceived)
124   : mSignalVerified(signalReceived),
125     mCurrentFocusedActor(),
126     mForward(true)
127   {
128   }
129
130   void Callback(Actor currentFocusedActor, bool forward)
131   {
132     tet_infoline("Verifying FocusGroupChangedCallback()");
133
134     mSignalVerified = true;
135
136     mCurrentFocusedActor = currentFocusedActor;
137     mForward = forward;
138   }
139
140   void Reset()
141   {
142     mSignalVerified = false;
143   }
144
145   bool& mSignalVerified;
146   Actor mCurrentFocusedActor;
147   bool mForward;
148 };
149
150 // Functors to test whether focused actor activated signal is emitted when the focused actor is activated
151 class FocusedActorActivatedCallback : public Dali::ConnectionTracker
152 {
153 public:
154   FocusedActorActivatedCallback(bool& signalReceived)
155   : mSignalVerified(signalReceived),
156     mActivatedActor()
157   {
158   }
159
160   void Callback(Actor activatedActor)
161   {
162     tet_infoline("Verifying FocusedActorActivatedCallback()");
163
164     mSignalVerified = true;
165
166     mActivatedActor = activatedActor;
167   }
168
169   void Reset()
170   {
171     mSignalVerified = false;
172   }
173
174   bool& mSignalVerified;
175   Actor mActivatedActor;
176 };
177
178 } // namespace
179
180
181 int UtcDaliKeyboardFocusManagerGet(void)
182 {
183   ToolkitTestApplication application;
184
185   tet_infoline(" UtcDaliKeyboardKeyboardFocusManagerGet");
186
187   // Register Type
188   TypeInfo type;
189   type = TypeRegistry::Get().GetTypeInfo( "KeyboardFocusManager" );
190   DALI_TEST_CHECK( type );
191   BaseHandle handle = type.CreateInstance();
192   DALI_TEST_CHECK( handle );
193
194   KeyboardFocusManager manager;
195
196   manager = KeyboardFocusManager::Get();
197   DALI_TEST_CHECK(manager);
198
199   KeyboardFocusManager newManager = KeyboardFocusManager::Get();
200   DALI_TEST_CHECK(newManager);
201
202   // Check that focus manager is a singleton
203   DALI_TEST_CHECK(manager == newManager);
204   END_TEST;
205 }
206
207 int UtcDaliKeyboardFocusManagerSetAndGetCurrentFocusActor(void)
208 {
209   ToolkitTestApplication application;
210
211   tet_infoline(" UtcDaliKeyboardFocusManagerSetAndGetCurrentFocusActor");
212
213   KeyboardFocusManager manager = KeyboardFocusManager::Get();
214   DALI_TEST_CHECK(manager);
215
216   // Create the first actor and add it to the stage
217   Actor first = Actor::New();
218   first.SetKeyboardFocusable(true);
219   Stage::GetCurrent().Add(first);
220
221   // Create the second actor and add it to the stage
222   Actor second = Actor::New();
223   second.SetKeyboardFocusable(true);
224   Stage::GetCurrent().Add(second);
225
226   // Create the third actor but don't add it to the stage
227   Actor third = Actor::New();
228
229   // Check that no actor is being focused yet.
230   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
231
232   // Check that it will fail to set focus on an invalid actor
233   DALI_TEST_CHECK(manager.SetCurrentFocusActor(Actor()) == false);
234
235   // Check that the focus is set on the first actor
236   DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
237   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
238
239   // Check that the focus is set on the second actor
240   DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
241   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
242
243   // Check that it will fail to set focus on the third actor as it's not in the stage
244   DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false);
245   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
246
247   // Add the third actor to the stage
248   Stage::GetCurrent().Add(third);
249
250   // Check that it will fail to set focus on the third actor as it's not focusable
251   DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false);
252   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
253
254   // Make the third actor focusable
255   third.SetKeyboardFocusable(true);
256
257   // Check that the focus is successfully moved to the third actor
258   DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true);
259   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
260   END_TEST;
261 }
262
263 int UtcDaliKeyboardFocusManagerMoveFocus(void)
264 {
265   ToolkitTestApplication application;
266
267   tet_infoline(" UtcDaliKeyboardFocusManagerMoveFocus");
268
269   // Register Type
270   TypeInfo type;
271   type = TypeRegistry::Get().GetTypeInfo( "KeyboardFocusManager" );
272   DALI_TEST_CHECK( type );
273   BaseHandle handle = type.CreateInstance();
274   DALI_TEST_CHECK( handle );
275
276   KeyboardFocusManager manager = KeyboardFocusManager::Get();
277   DALI_TEST_CHECK(manager);
278
279   bool preFocusChangeSignalVerified = false;
280   PreFocusChangeCallback preFocusChangeCallback(preFocusChangeSignalVerified);
281   manager.PreFocusChangeSignal().Connect( &preFocusChangeCallback, &PreFocusChangeCallback::Callback );
282
283   bool focusChangedSignalVerified = false;
284   FocusChangedCallback focusChangedCallback(focusChangedSignalVerified);
285   manager.FocusChangedSignal().Connect( &focusChangedCallback, &FocusChangedCallback::Callback );
286
287   // Create the first actor and add it to the stage
288   Actor first = Actor::New();
289   first.SetKeyboardFocusable(true);
290   Stage::GetCurrent().Add(first);
291
292   // Create the second actor and add it to the stage
293   Actor second = Actor::New();
294   second.SetKeyboardFocusable(true);
295   Stage::GetCurrent().Add(second);
296
297   // Move the focus to the right
298   DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
299
300   // Because no layout control in the stage and no actor is focused, it should emit the PreFocusChange signal
301   DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
302   DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == Actor());
303   DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
304   DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::RIGHT);
305   preFocusChangeCallback.Reset();
306
307   // Check that the focus is set on the first actor
308   DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
309   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
310   DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
311   DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == Actor());
312   DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
313   focusChangedCallback.Reset();
314
315   // Move the focus towards right
316   DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
317
318   // Because no layout control in the stage and the first actor is focused, it should emit the PreFocusChange signal
319   DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
320   DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == first);
321   DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
322   DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::RIGHT);
323   preFocusChangeCallback.Reset();
324
325   // Check that the focus is set on the second actor
326   DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
327   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
328   DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
329   DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == first);
330   DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == second);
331   focusChangedCallback.Reset();
332
333   // Move the focus towards up
334   DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::UP) == false);
335
336   // Because no layout control in the stage and no actor is focused, it should emit the PreFocusChange signal
337   DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
338   DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == second);
339   DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
340   DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::UP);
341   preFocusChangeCallback.Reset();
342   DALI_TEST_CHECK(!focusChangedCallback.mSignalVerified);
343
344   // Create a 2x2 table view and try to move focus inside it
345   TableView tableView = TableView::New( 2, 2 );
346   Stage::GetCurrent().Add(tableView);
347
348   // Create the third actor
349   Actor third = Actor::New();
350   third.SetKeyboardFocusable(true);
351
352   // Create the fourth actor
353   Actor fourth = Actor::New();
354   fourth.SetKeyboardFocusable(true);
355
356   // Add the four children to table view
357   tableView.AddChild(first, TableView::CellPosition(0, 0));
358   tableView.AddChild(second, TableView::CellPosition(0, 1));
359   tableView.AddChild(third, TableView::CellPosition(1, 0));
360   tableView.AddChild(fourth, TableView::CellPosition(1, 1));
361
362   // Set the focus to the first actor
363   DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
364   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
365   DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
366   DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == second);
367   DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
368   focusChangedCallback.Reset();
369
370   // Move the focus towards right
371   DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
372   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
373   DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
374   DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == first);
375   DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == second);
376   focusChangedCallback.Reset();
377
378   // Move the focus towards down
379   DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::DOWN) == true);
380   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == fourth);
381   DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
382   DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == second);
383   DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == fourth);
384   focusChangedCallback.Reset();
385
386   // Move the focus towards left
387   DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == true);
388   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
389   DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
390   DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == fourth);
391   DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == third);
392   focusChangedCallback.Reset();
393
394   // Move the focus towards up
395   DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::UP) == true);
396   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
397   DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
398   DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == third);
399   DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
400   focusChangedCallback.Reset();
401
402   // Move the focus towards left. The focus move will fail as no way to move it upwards
403   DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == false);
404   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
405   DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
406   DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == first);
407   DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
408   DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::LEFT);
409   preFocusChangeCallback.Reset();
410   DALI_TEST_CHECK(!focusChangedCallback.mSignalVerified);
411
412   // Enable the loop
413   manager.SetFocusGroupLoop(true);
414   DALI_TEST_CHECK(manager.GetFocusGroupLoop() == true);
415
416   // Move the focus towards left again. The focus should move to the fourth actor.
417   DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == true);
418   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == fourth);
419   DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
420   DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == first);
421   DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == fourth);
422   focusChangedCallback.Reset();
423   END_TEST;
424 }
425
426 int UtcDaliKeyboardFocusManagerClearFocus(void)
427 {
428   ToolkitTestApplication application;
429
430   tet_infoline(" UtcDaliKeyboardFocusManagerClearFocus");
431
432   KeyboardFocusManager manager = KeyboardFocusManager::Get();
433   DALI_TEST_CHECK(manager);
434
435   // Create the first actor and add it to the stage
436   Actor first = Actor::New();
437   first.SetKeyboardFocusable(true);
438   Stage::GetCurrent().Add(first);
439
440   // Create the second actor and add it to the stage
441   Actor second = Actor::New();
442   second.SetKeyboardFocusable(true);
443   Stage::GetCurrent().Add(second);
444
445   // Check that the focus is set on the first actor
446   DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
447   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
448
449   // Check that the focus is set on the second actor
450   DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
451   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
452
453   // Clear the focus
454   manager.ClearFocus();
455
456   // Check that no actor is being focused now.
457   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
458   END_TEST;
459 }
460
461 int UtcDaliKeyboardFocusManagerSetAndGetFocusGroupLoop(void)
462 {
463   ToolkitTestApplication application;
464
465   tet_infoline(" UtcDaliKeyboardFocusManagerSetAndGetFocusGroupLoop");
466
467   KeyboardFocusManager manager = KeyboardFocusManager::Get();
468   DALI_TEST_CHECK(manager);
469
470   // Check that the focus movement is not looped within the same focus group by default
471   DALI_TEST_CHECK(manager.GetFocusGroupLoop() == false);
472
473   // Enable the loop
474   manager.SetFocusGroupLoop(true);
475   DALI_TEST_CHECK(manager.GetFocusGroupLoop() == true);
476   END_TEST;
477 }
478
479 int UtcDaliKeyboardFocusManagerSetAsFocusGroup(void)
480 {
481   ToolkitTestApplication application;
482
483   tet_infoline(" UtcDaliKeyboardFocusManagerSetAsFocusGroup");
484
485   KeyboardFocusManager manager = KeyboardFocusManager::Get();
486   DALI_TEST_CHECK(manager);
487
488   // Create an actor and check that it is not a focus group by default
489   Actor actor = Actor::New();
490   DALI_TEST_CHECK(manager.IsFocusGroup(actor) == false);
491
492   // Set the actor as focus group
493   manager.SetAsFocusGroup(actor, true);
494
495   // flush the queue and render once
496   application.SendNotification();
497   application.Render();
498
499   DALI_TEST_CHECK(manager.IsFocusGroup(actor) == true);
500
501   // Set the actor not as focus group
502   manager.SetAsFocusGroup(actor, false);
503
504   // flush the queue and render once
505   application.SendNotification();
506   application.Render();
507
508   DALI_TEST_CHECK(manager.IsFocusGroup(actor) == false);
509   END_TEST;
510 }
511
512 int UtcDaliKeyboardFocusManagerGetFocusGroup(void)
513 {
514   ToolkitTestApplication application;
515
516   tet_infoline(" UtcDaliKeyboardFocusManagerGetFocusGroup");
517
518   KeyboardFocusManager manager = KeyboardFocusManager::Get();
519   DALI_TEST_CHECK(manager);
520
521   // Create an actor with two child actors and add it to the stage
522   Actor parent = Actor::New();
523   Actor child = Actor::New();
524   parent.Add(child);
525   Stage::GetCurrent().Add(parent);
526
527   // Create three actors and add them as the children of the first child actor
528   Actor grandChild = Actor::New();
529   child.Add(grandChild);
530
531   // Set the parent and the first child actor as focus groups
532   manager.SetAsFocusGroup(parent, true);
533
534   // flush the queue and render once
535   application.SendNotification();
536   application.Render();
537
538   DALI_TEST_CHECK(manager.IsFocusGroup(parent) == true);
539
540   // The current focus group should be the parent, As it is the immediate parent which is also a focus group.
541   DALI_TEST_CHECK(manager.GetFocusGroup(grandChild) == parent);
542
543   manager.SetAsFocusGroup(child, true);
544
545   // flush the queue and render once
546   application.SendNotification();
547   application.Render();
548
549   DALI_TEST_CHECK(manager.IsFocusGroup(child) == true);
550
551   // The focus group should be the child, As it is the immediate parent which is also a focus group.
552   DALI_TEST_CHECK(manager.GetFocusGroup(grandChild) == child);
553
554   manager.SetAsFocusGroup(grandChild, true);
555
556   // flush the queue and render once
557   application.SendNotification();
558   application.Render();
559
560   DALI_TEST_CHECK(manager.IsFocusGroup(grandChild) == true);
561
562   // The current focus group should be itself, As it is also a focus group.
563   DALI_TEST_CHECK(manager.GetFocusGroup(grandChild) == grandChild);
564   END_TEST;
565 }
566
567 int UtcDaliKeyboardFocusManagerSetAndGetFocusIndicator(void)
568 {
569   ToolkitTestApplication application;
570
571   tet_infoline(" UtcDaliKeyboardFocusManagerSetAndGetFocusIndicator");
572
573   KeyboardFocusManager manager = KeyboardFocusManager::Get();
574   DALI_TEST_CHECK(manager);
575
576   Actor defaultFocusIndicatorActor = manager.GetFocusIndicatorActor();
577   DALI_TEST_CHECK(defaultFocusIndicatorActor);
578
579   Actor newFocusIndicatorActor = Actor::New();
580   manager.SetFocusIndicatorActor(newFocusIndicatorActor);
581   DALI_TEST_CHECK(manager.GetFocusIndicatorActor() == newFocusIndicatorActor);
582   END_TEST;
583 }
584
585
586 int UtcDaliKeyboardFocusManagerSignalFocusedActorActivated(void)
587 {
588   ToolkitTestApplication application;
589
590   tet_infoline(" UtcDaliKeyboardFocusManagerSignalFocusedActorActivated");
591
592   KeyboardFocusManager manager = KeyboardFocusManager::Get();
593   DALI_TEST_CHECK(manager);
594
595   bool focusedActorActivatedSignalVerified = false;
596   FocusedActorActivatedCallback focusedActorActivatedCallback(focusedActorActivatedSignalVerified);
597   manager.FocusedActorActivatedSignal().Connect( &focusedActorActivatedCallback, &FocusedActorActivatedCallback::Callback );
598
599   Integration::KeyEvent returnEvent("Return", "", 0, 0, 0, Integration::KeyEvent::Up);
600
601   // Create the first button and add it to the stage
602   PushButton firstPushButton = PushButton::New();
603   firstPushButton.SetKeyboardFocusable(true);
604   Stage::GetCurrent().Add(firstPushButton);
605
606   // Create the second button and add it to the stage
607   PushButton secondPushButton = PushButton::New();
608   secondPushButton.SetKeyboardFocusable(true);
609   Stage::GetCurrent().Add(secondPushButton);
610
611   // Check that the focus is set on the first button
612   DALI_TEST_CHECK(manager.SetCurrentFocusActor(firstPushButton) == true);
613   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstPushButton);
614
615   // Send the return event to activate the first button
616   application.ProcessEvent(returnEvent);
617   DALI_TEST_CHECK(focusedActorActivatedCallback.mSignalVerified);
618   DALI_TEST_CHECK(focusedActorActivatedCallback.mActivatedActor == firstPushButton);
619   focusedActorActivatedCallback.Reset();
620
621   // Check that the focus is set on the second button
622   DALI_TEST_CHECK(manager.SetCurrentFocusActor(secondPushButton) == true);
623   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondPushButton);
624
625   // Send the return event again to activate the second button
626   application.ProcessEvent(returnEvent);
627   DALI_TEST_CHECK(focusedActorActivatedCallback.mSignalVerified);
628   DALI_TEST_CHECK(focusedActorActivatedCallback.mActivatedActor == secondPushButton);
629   focusedActorActivatedCallback.Reset();
630   END_TEST;
631 }
632
633 int UtcDaliKeyboardFocusManagerSignalFocusGroupChanged(void)
634 {
635   ToolkitTestApplication application;
636
637   tet_infoline(" UtcDaliKeyboardFocusManagerSignalFocusGroupChanged");
638
639   // Register Type
640   TypeInfo type;
641   type = TypeRegistry::Get().GetTypeInfo( "KeyboardFocusManager" );
642   DALI_TEST_CHECK( type );
643   BaseHandle handle = type.CreateInstance();
644   DALI_TEST_CHECK( handle );
645
646   KeyboardFocusManager manager = KeyboardFocusManager::Get();
647   DALI_TEST_CHECK(manager);
648
649   bool focusGroupChangedSignalVerified = false;
650   FocusGroupChangedCallback focusGroupChangedCallback(focusGroupChangedSignalVerified);
651   manager.FocusGroupChangedSignal().Connect( &focusGroupChangedCallback, &FocusGroupChangedCallback::Callback );
652
653   Integration::KeyEvent tabEvent("Tab", "", 0, 0, 0, Integration::KeyEvent::Down);
654   Integration::KeyEvent shiftTabEvent("Tab", "", 0, 1, 0, Integration::KeyEvent::Down);
655
656   // Send the tab event to change focus group in the forward direction
657   application.ProcessEvent(tabEvent);
658   DALI_TEST_CHECK(focusGroupChangedCallback.mSignalVerified);
659   DALI_TEST_CHECK(focusGroupChangedCallback.mCurrentFocusedActor == Actor());
660   DALI_TEST_CHECK(focusGroupChangedCallback.mForward == true);
661   focusGroupChangedCallback.Reset();
662
663   // Send the shift tab event to change focus group in the backward direction
664   application.ProcessEvent(shiftTabEvent);
665   DALI_TEST_CHECK(focusGroupChangedCallback.mSignalVerified);
666   DALI_TEST_CHECK(focusGroupChangedCallback.mCurrentFocusedActor == Actor());
667   DALI_TEST_CHECK(focusGroupChangedCallback.mForward == false);
668   focusGroupChangedCallback.Reset();
669   END_TEST;
670 }