2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
25 #include <dali-toolkit/dali-toolkit.h>
26 #include <dali/integration-api/events/key-event-integ.h>
30 using namespace Dali::Toolkit;
32 void utc_dali_toolkit_keyboard_focus_manager_startup(void)
34 test_return_value = TET_UNDEF;
37 void utc_dali_toolkit_keyboard_focus_manager_cleanup(void)
39 test_return_value = TET_PASS;
46 // Functors to test whether PreFocusChange signal is emitted when the keyboard focus is about to change
47 class PreFocusChangeCallback : public Dali::ConnectionTracker
50 PreFocusChangeCallback(bool& signalReceived)
51 : mSignalVerified(signalReceived),
52 mCurrentFocusedActor(),
53 mProposedActorToFocus(),
54 mDirection(Control::KeyboardFocus::LEFT)
58 Actor Callback(Actor currentFocusedActor, Actor proposedActorToFocus, Control::KeyboardFocus::Direction direction)
60 tet_infoline("Verifying PreFocusChangeCallback()");
62 mSignalVerified = true;
64 mCurrentFocusedActor = currentFocusedActor;
65 mProposedActorToFocus = proposedActorToFocus;
66 mDirection = direction;
68 return mProposedActorToFocus;
73 mSignalVerified = false;
74 mCurrentFocusedActor = Actor();
75 mProposedActorToFocus = Actor();
76 mDirection = Control::KeyboardFocus::LEFT;
79 bool& mSignalVerified;
80 Actor mCurrentFocusedActor;
81 Actor mProposedActorToFocus;
82 Control::KeyboardFocus::Direction mDirection;
85 // Functors to test whether focus changed signal is emitted when the keyboard focus is changed
86 class FocusChangedCallback : public Dali::ConnectionTracker
89 FocusChangedCallback(bool& signalReceived)
90 : mSignalVerified(signalReceived),
91 mOriginalFocusedActor(),
92 mCurrentFocusedActor()
96 void Callback(Actor originalFocusedActor, Actor currentFocusedActor)
98 tet_infoline("Verifying FocusChangedCallback()");
100 if(originalFocusedActor == mCurrentFocusedActor)
102 mSignalVerified = true;
105 mOriginalFocusedActor = originalFocusedActor;
106 mCurrentFocusedActor = currentFocusedActor;
111 mSignalVerified = false;
114 bool& mSignalVerified;
115 Actor mOriginalFocusedActor;
116 Actor mCurrentFocusedActor;
119 // Functors to test whether focus group changed signal is emitted when the keyboard focus group is changed
120 class FocusGroupChangedCallback : public Dali::ConnectionTracker
123 FocusGroupChangedCallback(bool& signalReceived)
124 : mSignalVerified(signalReceived),
125 mCurrentFocusedActor(),
130 void Callback(Actor currentFocusedActor, bool forward)
132 tet_infoline("Verifying FocusGroupChangedCallback()");
134 mSignalVerified = true;
136 mCurrentFocusedActor = currentFocusedActor;
142 mSignalVerified = false;
145 bool& mSignalVerified;
146 Actor mCurrentFocusedActor;
150 // Functors to test whether focused actor activated signal is emitted when the focused actor is activated
151 class FocusedActorActivatedCallback : public Dali::ConnectionTracker
154 FocusedActorActivatedCallback(bool& signalReceived)
155 : mSignalVerified(signalReceived),
160 void Callback(Actor activatedActor)
162 tet_infoline("Verifying FocusedActorActivatedCallback()");
164 mSignalVerified = true;
166 mActivatedActor = activatedActor;
171 mSignalVerified = false;
174 bool& mSignalVerified;
175 Actor mActivatedActor;
178 // Used to connect to signals via the ConnectSignal Handle method
179 struct CallbackFunctor
192 int UtcDaliKeyboardFocusManagerGet(void)
194 ToolkitTestApplication application;
196 tet_infoline(" UtcDaliKeyboardKeyboardFocusManagerGet");
200 type = TypeRegistry::Get().GetTypeInfo( "KeyboardFocusManager" );
201 DALI_TEST_CHECK( type );
202 BaseHandle handle = type.CreateInstance();
203 DALI_TEST_CHECK( handle );
205 KeyboardFocusManager manager;
207 manager = KeyboardFocusManager::Get();
208 DALI_TEST_CHECK(manager);
210 KeyboardFocusManager newManager = KeyboardFocusManager::Get();
211 DALI_TEST_CHECK(newManager);
213 // Check that focus manager is a singleton
214 DALI_TEST_CHECK(manager == newManager);
218 int UtcDaliKeyboardFocusManagerSetAndGetCurrentFocusActor(void)
220 ToolkitTestApplication application;
222 tet_infoline(" UtcDaliKeyboardFocusManagerSetAndGetCurrentFocusActor");
224 KeyboardFocusManager manager = KeyboardFocusManager::Get();
225 DALI_TEST_CHECK(manager);
227 // Create the first actor and add it to the stage
228 Actor first = Actor::New();
229 first.SetKeyboardFocusable(true);
230 Stage::GetCurrent().Add(first);
232 // Create the second actor and add it to the stage
233 Actor second = Actor::New();
234 second.SetKeyboardFocusable(true);
235 Stage::GetCurrent().Add(second);
237 // Create the third actor but don't add it to the stage
238 Actor third = Actor::New();
240 // Check that no actor is being focused yet.
241 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
243 // Check that it will fail to set focus on an invalid actor
244 DALI_TEST_CHECK(manager.SetCurrentFocusActor(Actor()) == false);
246 // Check that the focus is set on the first actor
247 DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
248 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
250 // Check that the focus is set on the second actor
251 DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
252 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
254 // Check that it will fail to set focus on the third actor as it's not in the stage
255 DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false);
256 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
258 // Add the third actor to the stage
259 Stage::GetCurrent().Add(third);
261 // Check that it will fail to set focus on the third actor as it's not focusable
262 DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false);
263 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
265 // Make the third actor focusable
266 third.SetKeyboardFocusable(true);
268 // Check that the focus is successfully moved to the third actor
269 DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true);
270 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
274 int UtcDaliKeyboardFocusManagerMoveFocus(void)
276 ToolkitTestApplication application;
278 tet_infoline(" UtcDaliKeyboardFocusManagerMoveFocus");
282 type = TypeRegistry::Get().GetTypeInfo( "KeyboardFocusManager" );
283 DALI_TEST_CHECK( type );
284 BaseHandle handle = type.CreateInstance();
285 DALI_TEST_CHECK( handle );
287 KeyboardFocusManager manager = KeyboardFocusManager::Get();
288 DALI_TEST_CHECK(manager);
290 bool preFocusChangeSignalVerified = false;
291 PreFocusChangeCallback preFocusChangeCallback(preFocusChangeSignalVerified);
292 manager.PreFocusChangeSignal().Connect( &preFocusChangeCallback, &PreFocusChangeCallback::Callback );
294 bool focusChangedSignalVerified = false;
295 FocusChangedCallback focusChangedCallback(focusChangedSignalVerified);
296 manager.FocusChangedSignal().Connect( &focusChangedCallback, &FocusChangedCallback::Callback );
298 // Create the first actor and add it to the stage
299 Actor first = Actor::New();
300 first.SetKeyboardFocusable(true);
301 Stage::GetCurrent().Add(first);
303 // Create the second actor and add it to the stage
304 Actor second = Actor::New();
305 second.SetKeyboardFocusable(true);
306 Stage::GetCurrent().Add(second);
308 // Move the focus to the right
309 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
311 // Because no layout control in the stage and no actor is focused, it should emit the PreFocusChange signal
312 DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
313 DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == Actor());
314 DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
315 DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::RIGHT);
316 preFocusChangeCallback.Reset();
318 // Check that the focus is set on the first actor
319 DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
320 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
321 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
322 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == Actor());
323 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
324 focusChangedCallback.Reset();
326 // Move the focus towards right
327 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
329 // Because no layout control in the stage and the first actor is focused, it should emit the PreFocusChange signal
330 DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
331 DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == first);
332 DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
333 DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::RIGHT);
334 preFocusChangeCallback.Reset();
336 // Check that the focus is set on the second actor
337 DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
338 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
339 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
340 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == first);
341 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == second);
342 focusChangedCallback.Reset();
344 // Move the focus towards up
345 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::UP) == false);
347 // Because no layout control in the stage and no actor is focused, it should emit the PreFocusChange signal
348 DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
349 DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == second);
350 DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
351 DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::UP);
352 preFocusChangeCallback.Reset();
353 DALI_TEST_CHECK(!focusChangedCallback.mSignalVerified);
355 // Create a 2x2 table view and try to move focus inside it
356 TableView tableView = TableView::New( 2, 2 );
357 Stage::GetCurrent().Add(tableView);
359 // Create the third actor
360 Actor third = Actor::New();
361 third.SetKeyboardFocusable(true);
363 // Create the fourth actor
364 Actor fourth = Actor::New();
365 fourth.SetKeyboardFocusable(true);
367 // Add the four children to table view
368 tableView.AddChild(first, TableView::CellPosition(0, 0));
369 tableView.AddChild(second, TableView::CellPosition(0, 1));
370 tableView.AddChild(third, TableView::CellPosition(1, 0));
371 tableView.AddChild(fourth, TableView::CellPosition(1, 1));
373 // Set the focus to the first actor
374 DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
375 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
376 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
377 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == second);
378 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
379 focusChangedCallback.Reset();
381 // Move the focus towards right
382 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
383 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
384 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
385 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == first);
386 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == second);
387 focusChangedCallback.Reset();
389 // Move the focus towards down
390 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::DOWN) == true);
391 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == fourth);
392 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
393 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == second);
394 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == fourth);
395 focusChangedCallback.Reset();
397 // Move the focus towards left
398 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == true);
399 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
400 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
401 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == fourth);
402 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == third);
403 focusChangedCallback.Reset();
405 // Move the focus towards up
406 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::UP) == true);
407 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
408 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
409 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == third);
410 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
411 focusChangedCallback.Reset();
413 // Move the focus towards left. The focus move will fail as no way to move it upwards
414 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == false);
415 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
416 DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
417 DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == first);
418 DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
419 DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::LEFT);
420 preFocusChangeCallback.Reset();
421 DALI_TEST_CHECK(!focusChangedCallback.mSignalVerified);
424 manager.SetFocusGroupLoop(true);
425 DALI_TEST_CHECK(manager.GetFocusGroupLoop() == true);
427 // Move the focus towards left again. The focus should move to the fourth actor.
428 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == true);
429 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == fourth);
430 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
431 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == first);
432 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == fourth);
433 focusChangedCallback.Reset();
437 int UtcDaliKeyboardFocusManagerClearFocus(void)
439 ToolkitTestApplication application;
441 tet_infoline(" UtcDaliKeyboardFocusManagerClearFocus");
443 KeyboardFocusManager manager = KeyboardFocusManager::Get();
444 DALI_TEST_CHECK(manager);
446 // Create the first actor and add it to the stage
447 Actor first = Actor::New();
448 first.SetKeyboardFocusable(true);
449 Stage::GetCurrent().Add(first);
451 // Create the second actor and add it to the stage
452 Actor second = Actor::New();
453 second.SetKeyboardFocusable(true);
454 Stage::GetCurrent().Add(second);
456 // Check that the focus is set on the first actor
457 DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
458 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
460 // Check that the focus is set on the second actor
461 DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
462 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
465 manager.ClearFocus();
467 // Check that no actor is being focused now.
468 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
472 int UtcDaliKeyboardFocusManagerSetAndGetFocusGroupLoop(void)
474 ToolkitTestApplication application;
476 tet_infoline(" UtcDaliKeyboardFocusManagerSetAndGetFocusGroupLoop");
478 KeyboardFocusManager manager = KeyboardFocusManager::Get();
479 DALI_TEST_CHECK(manager);
481 // Check that the focus movement is not looped within the same focus group by default
482 DALI_TEST_CHECK(manager.GetFocusGroupLoop() == false);
485 manager.SetFocusGroupLoop(true);
486 DALI_TEST_CHECK(manager.GetFocusGroupLoop() == true);
490 int UtcDaliKeyboardFocusManagerSetAsFocusGroup(void)
492 ToolkitTestApplication application;
494 tet_infoline(" UtcDaliKeyboardFocusManagerSetAsFocusGroup");
496 KeyboardFocusManager manager = KeyboardFocusManager::Get();
497 DALI_TEST_CHECK(manager);
499 // Create an actor and check that it is not a focus group by default
500 Actor actor = Actor::New();
501 DALI_TEST_CHECK(manager.IsFocusGroup(actor) == false);
503 // Set the actor as focus group
504 manager.SetAsFocusGroup(actor, true);
506 // flush the queue and render once
507 application.SendNotification();
508 application.Render();
510 DALI_TEST_CHECK(manager.IsFocusGroup(actor) == true);
512 // Set the actor not as focus group
513 manager.SetAsFocusGroup(actor, false);
515 // flush the queue and render once
516 application.SendNotification();
517 application.Render();
519 DALI_TEST_CHECK(manager.IsFocusGroup(actor) == false);
523 int UtcDaliKeyboardFocusManagerGetFocusGroup(void)
525 ToolkitTestApplication application;
527 tet_infoline(" UtcDaliKeyboardFocusManagerGetFocusGroup");
529 KeyboardFocusManager manager = KeyboardFocusManager::Get();
530 DALI_TEST_CHECK(manager);
532 // Create an actor with two child actors and add it to the stage
533 Actor parent = Actor::New();
534 Actor child = Actor::New();
536 Stage::GetCurrent().Add(parent);
538 // Create three actors and add them as the children of the first child actor
539 Actor grandChild = Actor::New();
540 child.Add(grandChild);
542 // Set the parent and the first child actor as focus groups
543 manager.SetAsFocusGroup(parent, true);
545 // flush the queue and render once
546 application.SendNotification();
547 application.Render();
549 DALI_TEST_CHECK(manager.IsFocusGroup(parent) == true);
551 // The current focus group should be the parent, As it is the immediate parent which is also a focus group.
552 DALI_TEST_CHECK(manager.GetFocusGroup(grandChild) == parent);
554 manager.SetAsFocusGroup(child, true);
556 // flush the queue and render once
557 application.SendNotification();
558 application.Render();
560 DALI_TEST_CHECK(manager.IsFocusGroup(child) == true);
562 // The focus group should be the child, As it is the immediate parent which is also a focus group.
563 DALI_TEST_CHECK(manager.GetFocusGroup(grandChild) == child);
565 manager.SetAsFocusGroup(grandChild, true);
567 // flush the queue and render once
568 application.SendNotification();
569 application.Render();
571 DALI_TEST_CHECK(manager.IsFocusGroup(grandChild) == true);
573 // The current focus group should be itself, As it is also a focus group.
574 DALI_TEST_CHECK(manager.GetFocusGroup(grandChild) == grandChild);
578 int UtcDaliKeyboardFocusManagerSetAndGetFocusIndicator(void)
580 ToolkitTestApplication application;
582 tet_infoline(" UtcDaliKeyboardFocusManagerSetAndGetFocusIndicator");
584 KeyboardFocusManager manager = KeyboardFocusManager::Get();
585 DALI_TEST_CHECK(manager);
587 Actor defaultFocusIndicatorActor = manager.GetFocusIndicatorActor();
588 DALI_TEST_CHECK(defaultFocusIndicatorActor);
590 Actor newFocusIndicatorActor = Actor::New();
591 manager.SetFocusIndicatorActor(newFocusIndicatorActor);
592 DALI_TEST_CHECK(manager.GetFocusIndicatorActor() == newFocusIndicatorActor);
597 int UtcDaliKeyboardFocusManagerSignalFocusedActorActivated(void)
599 ToolkitTestApplication application;
601 tet_infoline(" UtcDaliKeyboardFocusManagerSignalFocusedActorActivated");
603 KeyboardFocusManager manager = KeyboardFocusManager::Get();
604 DALI_TEST_CHECK(manager);
606 bool focusedActorActivatedSignalVerified = false;
607 FocusedActorActivatedCallback focusedActorActivatedCallback(focusedActorActivatedSignalVerified);
608 manager.FocusedActorEnterKeySignal().Connect( &focusedActorActivatedCallback, &FocusedActorActivatedCallback::Callback );
610 Integration::KeyEvent returnEvent("Return", "", 0, 0, 0, Integration::KeyEvent::Up);
612 // Create the first button and add it to the stage
613 PushButton firstPushButton = PushButton::New();
614 firstPushButton.SetKeyboardFocusable(true);
615 Stage::GetCurrent().Add(firstPushButton);
617 // Create the second button and add it to the stage
618 PushButton secondPushButton = PushButton::New();
619 secondPushButton.SetKeyboardFocusable(true);
620 Stage::GetCurrent().Add(secondPushButton);
622 // Check that the focus is set on the first button
623 DALI_TEST_CHECK(manager.SetCurrentFocusActor(firstPushButton) == true);
624 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstPushButton);
626 // Send the return event to activate the first button
627 application.ProcessEvent(returnEvent);
628 DALI_TEST_CHECK(focusedActorActivatedCallback.mSignalVerified);
629 DALI_TEST_CHECK(focusedActorActivatedCallback.mActivatedActor == firstPushButton);
630 focusedActorActivatedCallback.Reset();
632 // Check that the focus is set on the second button
633 DALI_TEST_CHECK(manager.SetCurrentFocusActor(secondPushButton) == true);
634 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondPushButton);
636 // Send the return event again to activate the second button
637 application.ProcessEvent(returnEvent);
638 DALI_TEST_CHECK(focusedActorActivatedCallback.mSignalVerified);
639 DALI_TEST_CHECK(focusedActorActivatedCallback.mActivatedActor == secondPushButton);
640 focusedActorActivatedCallback.Reset();
644 int UtcDaliKeyboardFocusManagerSignalFocusGroupChanged(void)
646 ToolkitTestApplication application;
648 tet_infoline(" UtcDaliKeyboardFocusManagerSignalFocusGroupChanged");
652 type = TypeRegistry::Get().GetTypeInfo( "KeyboardFocusManager" );
653 DALI_TEST_CHECK( type );
654 BaseHandle handle = type.CreateInstance();
655 DALI_TEST_CHECK( handle );
657 KeyboardFocusManager manager = KeyboardFocusManager::Get();
658 DALI_TEST_CHECK(manager);
660 bool focusGroupChangedSignalVerified = false;
661 FocusGroupChangedCallback focusGroupChangedCallback(focusGroupChangedSignalVerified);
662 manager.FocusGroupChangedSignal().Connect( &focusGroupChangedCallback, &FocusGroupChangedCallback::Callback );
664 Integration::KeyEvent tabEvent("Tab", "", 0, 0, 0, Integration::KeyEvent::Down);
665 Integration::KeyEvent shiftTabEvent("Tab", "", 0, 1, 0, Integration::KeyEvent::Down);
667 // Send the tab event to change focus group in the forward direction
668 application.ProcessEvent(tabEvent);
669 DALI_TEST_CHECK(focusGroupChangedCallback.mSignalVerified);
670 DALI_TEST_CHECK(focusGroupChangedCallback.mCurrentFocusedActor == Actor());
671 DALI_TEST_CHECK(focusGroupChangedCallback.mForward == true);
672 focusGroupChangedCallback.Reset();
674 // Send the shift tab event to change focus group in the backward direction
675 application.ProcessEvent(shiftTabEvent);
676 DALI_TEST_CHECK(focusGroupChangedCallback.mSignalVerified);
677 DALI_TEST_CHECK(focusGroupChangedCallback.mCurrentFocusedActor == Actor());
678 DALI_TEST_CHECK(focusGroupChangedCallback.mForward == false);
679 focusGroupChangedCallback.Reset();
683 int UtcDaliKeyboardFocusManagerSignals(void)
685 ToolkitTestApplication application;
687 KeyboardFocusManager manager = KeyboardFocusManager::Get();
688 DALI_TEST_CHECK( manager );
690 ConnectionTracker* testTracker = new ConnectionTracker();
691 DALI_TEST_EQUALS( true, manager.ConnectSignal( testTracker, "keyboardPreFocusChange", CallbackFunctor() ), TEST_LOCATION );
692 DALI_TEST_EQUALS( true, manager.ConnectSignal( testTracker, "keyboardFocusChanged", CallbackFunctor() ), TEST_LOCATION );
693 DALI_TEST_EQUALS( true, manager.ConnectSignal( testTracker, "keyboardFocusGroupChanged", CallbackFunctor() ), TEST_LOCATION );
694 DALI_TEST_EQUALS( true, manager.ConnectSignal( testTracker, "keyboardFocusedActorEnterKey", CallbackFunctor() ), TEST_LOCATION );