2 * Copyright (c) 2021 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/devel-api/actors/actor-devel.h>
24 #include <dali/integration-api/events/key-event-integ.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali-toolkit-test-suite-utils.h>
27 #include <dali-toolkit/dali-toolkit.h>
28 #include <dali-toolkit/devel-api/focus-manager/keyboard-focus-manager-devel.h>
29 #include <dali-toolkit/devel-api/controls/control-devel.h>
30 #include <dali-toolkit/devel-api/controls/table-view/table-view.h>
33 using namespace Dali::Toolkit;
35 void utc_dali_toolkit_keyboard_focus_manager_startup(void)
37 test_return_value = TET_UNDEF;
40 void utc_dali_toolkit_keyboard_focus_manager_cleanup(void)
42 test_return_value = TET_PASS;
49 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
51 // Functors to test whether GetNextFocusableActor() method of CustomAlgorithmInterface is called when the keyboard focus is about to change
52 class CustomAlgorithm : public Dali::Toolkit::DevelKeyboardFocusManager::CustomAlgorithmInterface
55 CustomAlgorithm(bool& interfaceVerified)
56 : mInterfaceVerified(interfaceVerified),
57 mCurrentFocusedActor(),
58 mProposedActorToFocus(),
59 mDirection(Control::KeyboardFocus::LEFT)
63 Actor GetNextFocusableActor(Actor currentFocusedActor, Actor proposedActorToFocus, Control::KeyboardFocus::Direction direction)
65 tet_infoline("Verifying CustomAlgorithm()");
67 mInterfaceVerified = true;
69 mCurrentFocusedActor = currentFocusedActor;
70 mProposedActorToFocus = proposedActorToFocus;
71 mDirection = direction;
73 return mProposedActorToFocus;
78 mInterfaceVerified = false;
79 mCurrentFocusedActor = Actor();
80 mProposedActorToFocus = Actor();
81 mDirection = Control::KeyboardFocus::LEFT;
84 bool& mInterfaceVerified;
85 Actor mCurrentFocusedActor;
86 Actor mProposedActorToFocus;
87 Control::KeyboardFocus::Direction mDirection;
90 // Functors to test whether PreFocusChange signal is emitted when the keyboard focus is about to change
91 class PreFocusChangeCallback : public Dali::ConnectionTracker
94 PreFocusChangeCallback(bool& signalReceived)
95 : mSignalVerified(signalReceived),
96 mCurrentFocusedActor(),
97 mProposedActorToFocus(),
98 mDirection(Control::KeyboardFocus::LEFT)
102 Actor Callback(Actor currentFocusedActor, Actor proposedActorToFocus, Control::KeyboardFocus::Direction direction)
104 tet_infoline("Verifying PreFocusChangeCallback()");
106 mSignalVerified = true;
108 mCurrentFocusedActor = currentFocusedActor;
109 mProposedActorToFocus = proposedActorToFocus;
110 mDirection = direction;
112 return mProposedActorToFocus;
117 mSignalVerified = false;
118 mCurrentFocusedActor = Actor();
119 mProposedActorToFocus = Actor();
120 mDirection = Control::KeyboardFocus::LEFT;
123 bool& mSignalVerified;
124 Actor mCurrentFocusedActor;
125 Actor mProposedActorToFocus;
126 Control::KeyboardFocus::Direction mDirection;
129 // Functors to test whether focus changed signal is emitted when the keyboard focus is changed
130 class FocusChangedCallback : public Dali::ConnectionTracker
133 FocusChangedCallback(bool& signalReceived)
134 : mSignalVerified(signalReceived),
135 mOriginalFocusedActor(),
136 mCurrentFocusedActor()
140 void Callback(Actor originalFocusedActor, Actor currentFocusedActor)
142 tet_infoline("Verifying FocusChangedCallback()");
144 if(originalFocusedActor == mCurrentFocusedActor)
146 mSignalVerified = true;
149 mOriginalFocusedActor = originalFocusedActor;
150 mCurrentFocusedActor = currentFocusedActor;
155 mSignalVerified = false;
158 bool& mSignalVerified;
159 Actor mOriginalFocusedActor;
160 Actor mCurrentFocusedActor;
163 // Functors to test whether focus group changed signal is emitted when the keyboard focus group is changed
164 class FocusGroupChangedCallback : public Dali::ConnectionTracker
167 FocusGroupChangedCallback(bool& signalReceived)
168 : mSignalVerified(signalReceived),
169 mCurrentFocusedActor(),
174 void Callback(Actor currentFocusedActor, bool forward)
176 tet_infoline("Verifying FocusGroupChangedCallback()");
178 mSignalVerified = true;
180 mCurrentFocusedActor = currentFocusedActor;
186 mSignalVerified = false;
189 bool& mSignalVerified;
190 Actor mCurrentFocusedActor;
194 // Functors to test whether focused actor activated signal is emitted when the focused actor is activated
195 class FocusedActorActivatedCallback : public Dali::ConnectionTracker
198 FocusedActorActivatedCallback(bool& signalReceived)
199 : mSignalVerified(signalReceived),
204 void Callback(Actor activatedActor)
206 tet_infoline("Verifying FocusedActorActivatedCallback()");
208 mSignalVerified = true;
210 mActivatedActor = activatedActor;
215 mSignalVerified = false;
218 bool& mSignalVerified;
219 Actor mActivatedActor;
222 class KeyEventCallback : public Dali::ConnectionTracker
227 * @param[in] returnValue Set return value of KeyEvent callback.
229 KeyEventCallback( bool consumed )
230 : mConsumed( consumed ),
235 bool Callback( Control control, const KeyEvent& keyEvent )
241 void Callback( const KeyEvent& keyEvent )
250 // Used to connect to signals via the ConnectSignal Handle method
251 struct CallbackFunctor
264 int UtcDaliKeyboardFocusManagerGet(void)
266 ToolkitTestApplication application;
268 tet_infoline(" UtcDaliKeyboardKeyboardFocusManagerGet");
272 type = TypeRegistry::Get().GetTypeInfo( "KeyboardFocusManager" );
273 DALI_TEST_CHECK( type );
274 BaseHandle handle = type.CreateInstance();
275 DALI_TEST_CHECK( handle );
277 KeyboardFocusManager manager;
279 manager = KeyboardFocusManager::Get();
280 DALI_TEST_CHECK(manager);
282 KeyboardFocusManager newManager = KeyboardFocusManager::Get();
283 DALI_TEST_CHECK(newManager);
285 // Check that focus manager is a singleton
286 DALI_TEST_CHECK(manager == newManager);
290 int UtcDaliKeyboardFocusManagerSetAndGetCurrentFocusActor(void)
292 ToolkitTestApplication application;
294 tet_infoline(" UtcDaliKeyboardFocusManagerSetAndGetCurrentFocusActor");
296 KeyboardFocusManager manager = KeyboardFocusManager::Get();
297 DALI_TEST_CHECK(manager);
299 // Create the first actor and add it to the stage
300 Actor first = Actor::New();
301 first.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
302 application.GetScene().Add(first);
304 // Create the second actor and add it to the stage
305 Actor second = Actor::New();
306 second.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
307 application.GetScene().Add(second);
309 // Create the third actor but don't add it to the stage
310 Actor third = Actor::New();
312 // Check that no actor is being focused yet.
313 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
315 // Check that it will fail to set focus on an invalid actor
316 DALI_TEST_CHECK(manager.SetCurrentFocusActor(Actor()) == false);
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);
322 // Check that the focus is set on the second actor
323 DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
324 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
326 // Check that it will fail to set focus on the third actor as it's not in the stage
327 DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false);
328 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
330 // Add the third actor to the stage
331 application.GetScene().Add(third);
333 // Check that it will fail to set focus on the third actor as it's not focusable
334 DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false);
335 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
337 // Make the third actor focusable
338 third.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
340 // Check that the focus is successfully moved to the third actor
341 DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true);
342 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
346 int UtcDaliKeyboardFocusManagerMoveFocus(void)
348 ToolkitTestApplication application;
350 tet_infoline(" UtcDaliKeyboardFocusManagerMoveFocus");
354 type = TypeRegistry::Get().GetTypeInfo( "KeyboardFocusManager" );
355 DALI_TEST_CHECK( type );
356 BaseHandle handle = type.CreateInstance();
357 DALI_TEST_CHECK( handle );
359 KeyboardFocusManager manager = KeyboardFocusManager::Get();
360 DALI_TEST_CHECK(manager);
362 bool preFocusChangeSignalVerified = false;
363 PreFocusChangeCallback preFocusChangeCallback(preFocusChangeSignalVerified);
364 manager.PreFocusChangeSignal().Connect( &preFocusChangeCallback, &PreFocusChangeCallback::Callback );
366 bool focusChangedSignalVerified = false;
367 FocusChangedCallback focusChangedCallback(focusChangedSignalVerified);
368 manager.FocusChangedSignal().Connect( &focusChangedCallback, &FocusChangedCallback::Callback );
370 // Create the first actor and add it to the stage
371 Actor first = Actor::New();
372 first.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
373 application.GetScene().Add(first);
375 // Create the second actor and add it to the stage
376 Actor second = Actor::New();
377 second.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
378 application.GetScene().Add(second);
380 // Move the focus to the right
381 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
383 // Because no layout control in the stage and no actor is focused, it should emit the PreFocusChange signal
384 DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
385 DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == Actor());
386 DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
387 DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::RIGHT);
388 preFocusChangeCallback.Reset();
390 // Check that the focus is set on the first actor
391 DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
392 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
393 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
394 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == Actor());
395 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
396 focusChangedCallback.Reset();
398 // Move the focus towards right
399 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
401 // Because no layout control in the stage and the first actor is focused, it should emit the PreFocusChange signal
402 DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
403 DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == first);
404 DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
405 DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::RIGHT);
406 preFocusChangeCallback.Reset();
408 // Check that the focus is set on the second actor
409 DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
410 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
411 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
412 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == first);
413 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == second);
414 focusChangedCallback.Reset();
416 // Move the focus towards up
417 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::UP) == false);
419 // Because no layout control in the stage and no actor is focused, it should emit the PreFocusChange signal
420 DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
421 DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == second);
422 DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
423 DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::UP);
424 preFocusChangeCallback.Reset();
425 DALI_TEST_CHECK(!focusChangedCallback.mSignalVerified);
427 // Create a 2x2 table view and try to move focus inside it
428 TableView tableView = TableView::New( 2, 2 );
429 application.GetScene().Add(tableView);
431 // Create the third actor
432 Actor third = Actor::New();
433 third.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
435 // Create the fourth actor
436 Actor fourth = Actor::New();
437 fourth.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
439 // Add the four children to table view
440 tableView.AddChild(first, TableView::CellPosition(0, 0));
441 tableView.AddChild(second, TableView::CellPosition(0, 1));
442 tableView.AddChild(third, TableView::CellPosition(1, 0));
443 tableView.AddChild(fourth, TableView::CellPosition(1, 1));
445 // Set the focus to the first actor
446 DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
447 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
448 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
449 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == second);
450 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
451 focusChangedCallback.Reset();
453 // Move the focus towards right
454 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
455 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
456 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
457 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == first);
458 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == second);
459 focusChangedCallback.Reset();
461 // Move the focus towards down
462 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::DOWN) == true);
463 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == fourth);
464 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
465 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == second);
466 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == fourth);
467 focusChangedCallback.Reset();
469 // Move the focus towards left
470 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == true);
471 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
472 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
473 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == fourth);
474 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == third);
475 focusChangedCallback.Reset();
477 // Move the focus towards up
478 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::UP) == true);
479 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
480 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
481 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == third);
482 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
483 focusChangedCallback.Reset();
485 // Move the focus towards left. The focus move will fail as no way to move it upwards
486 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == false);
487 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
488 DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
489 DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == first);
490 DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
491 DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::LEFT);
492 preFocusChangeCallback.Reset();
493 DALI_TEST_CHECK(!focusChangedCallback.mSignalVerified);
496 manager.SetFocusGroupLoop(true);
497 DALI_TEST_CHECK(manager.GetFocusGroupLoop() == true);
499 // Move the focus towards left again. The focus should move to the fourth actor.
500 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == true);
501 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == fourth);
502 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
503 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == first);
504 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == fourth);
505 focusChangedCallback.Reset();
509 int UtcDaliKeyboardFocusManagerCustomAlgorithmMoveFocus(void)
511 ToolkitTestApplication application;
513 tet_infoline(" UtcDaliKeyboardFocusManagerCustomAlgorithmMoveFocus");
517 type = TypeRegistry::Get().GetTypeInfo( "KeyboardFocusManager" );
518 DALI_TEST_CHECK( type );
519 BaseHandle handle = type.CreateInstance();
520 DALI_TEST_CHECK( handle );
522 KeyboardFocusManager manager = KeyboardFocusManager::Get();
523 DALI_TEST_CHECK(manager);
525 bool preFocusChangeSignalVerified = false;
526 PreFocusChangeCallback preFocusChangeCallback(preFocusChangeSignalVerified);
527 manager.PreFocusChangeSignal().Connect( &preFocusChangeCallback, &PreFocusChangeCallback::Callback );
529 bool focusChangedSignalVerified = false;
530 FocusChangedCallback focusChangedCallback(focusChangedSignalVerified);
531 manager.FocusChangedSignal().Connect( &focusChangedCallback, &FocusChangedCallback::Callback );
533 // Create the first actor and add it to the stage
534 Actor first = Actor::New();
535 first.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
536 application.GetScene().Add(first);
538 // Create the second actor and add it to the stage
539 Actor second = Actor::New();
540 second.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
541 application.GetScene().Add(second);
543 // Move the focus to the right
544 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
546 // Because no layout control in the stage and no actor is focused, it should emit the PreFocusChange signal
547 DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
548 DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == Actor());
549 DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
550 DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::RIGHT);
551 preFocusChangeCallback.Reset();
553 bool customAlgorithmInterfaceVerified = false;
554 CustomAlgorithm customAlgorithm(customAlgorithmInterfaceVerified);
555 Toolkit::DevelKeyboardFocusManager::SetCustomAlgorithm(manager, customAlgorithm);
557 // Move the focus towards right
558 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
560 // Because no layout control in the stage and the first actor is focused, it should invoke CustomAlgorithm
561 DALI_TEST_CHECK(customAlgorithm.mInterfaceVerified);
562 DALI_TEST_CHECK(customAlgorithm.mCurrentFocusedActor == Actor());
563 DALI_TEST_CHECK(customAlgorithm.mProposedActorToFocus == Actor());
564 DALI_TEST_CHECK(customAlgorithm.mDirection == Control::KeyboardFocus::RIGHT);
565 customAlgorithm.Reset();
567 // Check that the focus is set on the first actor
568 DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
569 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
570 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
571 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == Actor());
572 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
573 focusChangedCallback.Reset();
575 // Move the focus towards right
576 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
578 // Because no layout control in the stage and the first actor is focused, it should invoke CustomAlgorithm
579 DALI_TEST_CHECK(customAlgorithm.mInterfaceVerified);
580 DALI_TEST_CHECK(customAlgorithm.mCurrentFocusedActor == first);
581 DALI_TEST_CHECK(customAlgorithm.mProposedActorToFocus == Actor());
582 DALI_TEST_CHECK(customAlgorithm.mDirection == Control::KeyboardFocus::RIGHT);
583 customAlgorithm.Reset();
585 // Check that the focus is set on the second actor
586 DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
587 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
588 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
589 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == first);
590 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == second);
591 focusChangedCallback.Reset();
593 // Move the focus towards up
594 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::UP) == false);
596 // Because no layout control in the stage and no actor is focused, it should invoke CustomAlgorithm
597 DALI_TEST_CHECK(customAlgorithm.mInterfaceVerified);
598 DALI_TEST_CHECK(customAlgorithm.mCurrentFocusedActor == second);
599 DALI_TEST_CHECK(customAlgorithm.mProposedActorToFocus == Actor());
600 DALI_TEST_CHECK(customAlgorithm.mDirection == Control::KeyboardFocus::UP);
601 customAlgorithm.Reset();
602 DALI_TEST_CHECK(!focusChangedCallback.mSignalVerified);
606 int UtcDaliKeyboardFocusManagerFocusablePropertiesMoveFocus(void)
608 ToolkitTestApplication application;
610 tet_infoline(" UtcDaliKeyboardFocusManagerCustomAlgorithmMoveFocus");
614 type = TypeRegistry::Get().GetTypeInfo( "KeyboardFocusManager" );
615 DALI_TEST_CHECK( type );
616 BaseHandle handle = type.CreateInstance();
617 DALI_TEST_CHECK( handle );
619 KeyboardFocusManager manager = KeyboardFocusManager::Get();
620 DALI_TEST_CHECK(manager);
622 bool focusChangedSignalVerified = false;
623 FocusChangedCallback focusChangedCallback(focusChangedSignalVerified);
624 manager.FocusChangedSignal().Connect( &focusChangedCallback, &FocusChangedCallback::Callback );
626 PushButton button1 = PushButton::New();
627 PushButton button2 = PushButton::New();
628 button1.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
629 button2.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
630 application.GetScene().Add(button1);
631 application.GetScene().Add(button2);
633 // Set the focus to the button1
634 DALI_TEST_CHECK(manager.SetCurrentFocusActor(button1) == true);
635 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == button1);
636 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
637 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == Actor());
638 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button1);
639 focusChangedCallback.Reset();
641 // set the navigation properties of button1
642 button1.SetProperty(Toolkit::DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID, Property::Value((int)button2.GetProperty< int >( Actor::Property::ID )));
643 button1.SetProperty(Toolkit::DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID, Property::Value((int)button2.GetProperty< int >( Actor::Property::ID )));
644 button1.SetProperty(Toolkit::DevelControl::Property::UP_FOCUSABLE_ACTOR_ID, Property::Value((int)button2.GetProperty< int >( Actor::Property::ID )));
645 button1.SetProperty(Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, Property::Value((int)button2.GetProperty< int >( Actor::Property::ID )));
647 // set the navigation properties of button2
648 button2.SetProperty(Toolkit::DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID, Property::Value((int)button1.GetProperty< int >( Actor::Property::ID )));
649 button2.SetProperty(Toolkit::DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID, Property::Value((int)button1.GetProperty< int >( Actor::Property::ID )));
650 button2.SetProperty(Toolkit::DevelControl::Property::UP_FOCUSABLE_ACTOR_ID, Property::Value((int)button1.GetProperty< int >( Actor::Property::ID )));
651 button2.SetProperty(Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, Property::Value((int)button1.GetProperty< int >( Actor::Property::ID )));
653 // Move the focus towards left
654 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == true);
656 // Confirm whether focus is moved to button2
657 DALI_TEST_EQUALS(button2.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
658 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
659 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == button1);
660 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button2);
661 focusChangedCallback.Reset();
663 // Move the focus towards right
664 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
666 // Confirm whether focus is moved to button1
667 DALI_TEST_EQUALS(button1.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
668 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
669 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == button2);
670 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button1);
671 focusChangedCallback.Reset();
673 // Move the focus towards up
674 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::UP) == true);
676 // Confirm whether focus is moved to button2
677 DALI_TEST_EQUALS(button2.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
678 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
679 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == button1);
680 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button2);
681 focusChangedCallback.Reset();
683 // Move the focus towards down
684 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::DOWN) == true);
686 // Confirm whether focus is moved to button1
687 DALI_TEST_EQUALS(button1.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
688 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
689 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == button2);
690 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button1);
691 focusChangedCallback.Reset();
693 // Create a 1x1 table view and try to move focus inside it
694 TableView tableView = TableView::New( 1, 1 );
695 application.GetScene().Add(tableView);
697 PushButton button = PushButton::New();
698 button.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
699 tableView.AddChild(button, TableView::CellPosition(0, 0));
701 // set the navigation properties of button3
702 button.SetProperty(Toolkit::DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID, Property::Value((int)button1.GetProperty< int >( Actor::Property::ID )));
704 // Set the focus to the button
705 DALI_TEST_CHECK(manager.SetCurrentFocusActor(button) == true);
706 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == button);
707 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
708 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == button1);
709 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button);
710 focusChangedCallback.Reset();
712 // Move the focus towards left
713 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == true);
715 // Confirm whether focus is moved to button1
716 DALI_TEST_EQUALS(button1.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
717 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
718 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == button);
719 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button1);
720 focusChangedCallback.Reset();
725 int UtcDaliKeyboardFocusManagerClearFocus(void)
727 ToolkitTestApplication application;
729 tet_infoline(" UtcDaliKeyboardFocusManagerClearFocus");
731 KeyboardFocusManager manager = KeyboardFocusManager::Get();
732 DALI_TEST_CHECK(manager);
734 // Create the first actor and add it to the stage
735 Actor first = Actor::New();
736 first.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
737 application.GetScene().Add(first);
739 // Create the second actor and add it to the stage
740 Actor second = Actor::New();
741 second.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
742 application.GetScene().Add(second);
744 // Check that the focus is set on the first actor
745 DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
746 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
748 // Check that the focus is set on the second actor
749 DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
750 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
753 manager.ClearFocus();
755 // Check that no actor is being focused now.
756 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
760 int UtcDaliKeyboardFocusManagerSetAndGetFocusGroupLoop(void)
762 ToolkitTestApplication application;
764 tet_infoline(" UtcDaliKeyboardFocusManagerSetAndGetFocusGroupLoop");
766 KeyboardFocusManager manager = KeyboardFocusManager::Get();
767 DALI_TEST_CHECK(manager);
769 // Check that the focus movement is not looped within the same focus group by default
770 DALI_TEST_CHECK(manager.GetFocusGroupLoop() == false);
773 manager.SetFocusGroupLoop(true);
774 DALI_TEST_CHECK(manager.GetFocusGroupLoop() == true);
778 int UtcDaliKeyboardFocusManagerSetAsFocusGroup(void)
780 ToolkitTestApplication application;
782 tet_infoline(" UtcDaliKeyboardFocusManagerSetAsFocusGroup");
784 KeyboardFocusManager manager = KeyboardFocusManager::Get();
785 DALI_TEST_CHECK(manager);
787 // Create an actor and check that it is not a focus group by default
788 Actor actor = Actor::New();
789 DALI_TEST_CHECK(manager.IsFocusGroup(actor) == false);
791 // Set the actor as focus group
792 manager.SetAsFocusGroup(actor, true);
794 // flush the queue and render once
795 application.SendNotification();
796 application.Render();
798 DALI_TEST_CHECK(manager.IsFocusGroup(actor) == true);
800 // Set the actor not as focus group
801 manager.SetAsFocusGroup(actor, false);
803 // flush the queue and render once
804 application.SendNotification();
805 application.Render();
807 DALI_TEST_CHECK(manager.IsFocusGroup(actor) == false);
811 int UtcDaliKeyboardFocusManagerGetFocusGroup(void)
813 ToolkitTestApplication application;
815 tet_infoline(" UtcDaliKeyboardFocusManagerGetFocusGroup");
817 KeyboardFocusManager manager = KeyboardFocusManager::Get();
818 DALI_TEST_CHECK(manager);
820 // Create an actor with two child actors and add it to the stage
821 Actor parent = Actor::New();
822 Actor child = Actor::New();
824 application.GetScene().Add(parent);
826 // Create three actors and add them as the children of the first child actor
827 Actor grandChild = Actor::New();
828 child.Add(grandChild);
830 // Set the parent and the first child actor as focus groups
831 manager.SetAsFocusGroup(parent, true);
833 // flush the queue and render once
834 application.SendNotification();
835 application.Render();
837 DALI_TEST_CHECK(manager.IsFocusGroup(parent) == true);
839 // The current focus group should be the parent, As it is the immediate parent which is also a focus group.
840 DALI_TEST_CHECK(manager.GetFocusGroup(grandChild) == parent);
842 manager.SetAsFocusGroup(child, true);
844 // flush the queue and render once
845 application.SendNotification();
846 application.Render();
848 DALI_TEST_CHECK(manager.IsFocusGroup(child) == true);
850 // The focus group should be the child, As it is the immediate parent which is also a focus group.
851 DALI_TEST_CHECK(manager.GetFocusGroup(grandChild) == child);
853 manager.SetAsFocusGroup(grandChild, true);
855 // flush the queue and render once
856 application.SendNotification();
857 application.Render();
859 DALI_TEST_CHECK(manager.IsFocusGroup(grandChild) == true);
861 // The current focus group should be itself, As it is also a focus group.
862 DALI_TEST_CHECK(manager.GetFocusGroup(grandChild) == grandChild);
866 int UtcDaliKeyboardFocusManagerSetAndGetFocusIndicator(void)
868 ToolkitTestApplication application;
870 tet_infoline(" UtcDaliKeyboardFocusManagerSetAndGetFocusIndicator");
872 KeyboardFocusManager manager = KeyboardFocusManager::Get();
873 DALI_TEST_CHECK(manager);
875 Actor defaultFocusIndicatorActor = manager.GetFocusIndicatorActor();
876 DALI_TEST_CHECK(defaultFocusIndicatorActor);
878 Actor newFocusIndicatorActor = Actor::New();
879 manager.SetFocusIndicatorActor(newFocusIndicatorActor);
880 DALI_TEST_CHECK(manager.GetFocusIndicatorActor() == newFocusIndicatorActor);
885 int UtcDaliKeyboardFocusManagerSignalFocusedActorActivated(void)
887 ToolkitTestApplication application;
889 tet_infoline(" UtcDaliKeyboardFocusManagerSignalFocusedActorActivated");
891 KeyboardFocusManager manager = KeyboardFocusManager::Get();
892 DALI_TEST_CHECK(manager);
894 bool focusedActorActivatedSignalVerified = false;
895 FocusedActorActivatedCallback focusedActorActivatedCallback(focusedActorActivatedSignalVerified);
896 manager.FocusedActorEnterKeySignal().Connect( &focusedActorActivatedCallback, &FocusedActorActivatedCallback::Callback );
898 Integration::KeyEvent returnEvent( "Return", "", "", 0, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
900 // Press Any key to notice physical keyboard event is comming to KeyboardFocusManager
901 // It makes mIsFocusIndicatorEnabled true
902 application.ProcessEvent(returnEvent);
904 // Create the first button and add it to the stage
905 PushButton firstPushButton = PushButton::New();
906 firstPushButton.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
907 application.GetScene().Add(firstPushButton);
909 // Create the second button and add it to the stage
910 PushButton secondPushButton = PushButton::New();
911 secondPushButton.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
912 application.GetScene().Add(secondPushButton);
914 // Check that the focus is set on the first button
915 DALI_TEST_CHECK(manager.SetCurrentFocusActor(firstPushButton) == true);
916 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstPushButton);
918 // Send the return event to activate the first button
919 application.ProcessEvent(returnEvent);
920 DALI_TEST_CHECK(focusedActorActivatedCallback.mSignalVerified);
921 DALI_TEST_CHECK(focusedActorActivatedCallback.mActivatedActor == firstPushButton);
922 focusedActorActivatedCallback.Reset();
924 // Check that the focus is set on the second button
925 DALI_TEST_CHECK(manager.SetCurrentFocusActor(secondPushButton) == true);
926 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondPushButton);
928 // Send the return event again to activate the second button
929 application.ProcessEvent(returnEvent);
930 DALI_TEST_CHECK(focusedActorActivatedCallback.mSignalVerified);
931 DALI_TEST_CHECK(focusedActorActivatedCallback.mActivatedActor == secondPushButton);
932 focusedActorActivatedCallback.Reset();
936 int UtcDaliKeyboardFocusManagerSignalFocusGroupChanged(void)
938 ToolkitTestApplication application;
940 tet_infoline(" UtcDaliKeyboardFocusManagerSignalFocusGroupChanged");
944 type = TypeRegistry::Get().GetTypeInfo( "KeyboardFocusManager" );
945 DALI_TEST_CHECK( type );
946 BaseHandle handle = type.CreateInstance();
947 DALI_TEST_CHECK( handle );
949 KeyboardFocusManager manager = KeyboardFocusManager::Get();
950 DALI_TEST_CHECK(manager);
952 bool focusGroupChangedSignalVerified = false;
953 FocusGroupChangedCallback focusGroupChangedCallback(focusGroupChangedSignalVerified);
954 manager.FocusGroupChangedSignal().Connect( &focusGroupChangedCallback, &FocusGroupChangedCallback::Callback );
956 Integration::KeyEvent tabEvent( "Tab", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
957 Integration::KeyEvent shiftTabEvent( "Tab", "", "", 0, 1, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
959 // Press Any key to notice physical keyboard event is comming to KeyboardFocusManager
960 // It makes mIsFocusIndicatorEnabled true
961 application.ProcessEvent(tabEvent);
963 // Send the tab event to change focus group in the forward direction
964 application.ProcessEvent(tabEvent);
965 DALI_TEST_CHECK(focusGroupChangedCallback.mSignalVerified);
966 DALI_TEST_CHECK(focusGroupChangedCallback.mCurrentFocusedActor == Actor());
967 DALI_TEST_CHECK(focusGroupChangedCallback.mForward == true);
968 focusGroupChangedCallback.Reset();
970 // Send the shift tab event to change focus group in the backward direction
971 application.ProcessEvent(shiftTabEvent);
972 DALI_TEST_CHECK(focusGroupChangedCallback.mSignalVerified);
973 DALI_TEST_CHECK(focusGroupChangedCallback.mCurrentFocusedActor == Actor());
974 DALI_TEST_CHECK(focusGroupChangedCallback.mForward == false);
975 focusGroupChangedCallback.Reset();
979 int UtcDaliKeyboardFocusManagerSignals(void)
981 ToolkitTestApplication application;
983 KeyboardFocusManager manager = KeyboardFocusManager::Get();
984 DALI_TEST_CHECK( manager );
986 ConnectionTracker* testTracker = new ConnectionTracker();
987 DALI_TEST_EQUALS( true, manager.ConnectSignal( testTracker, "keyboardPreFocusChange", CallbackFunctor() ), TEST_LOCATION );
988 DALI_TEST_EQUALS( true, manager.ConnectSignal( testTracker, "keyboardFocusChanged", CallbackFunctor() ), TEST_LOCATION );
989 DALI_TEST_EQUALS( true, manager.ConnectSignal( testTracker, "keyboardFocusGroupChanged", CallbackFunctor() ), TEST_LOCATION );
990 DALI_TEST_EQUALS( true, manager.ConnectSignal( testTracker, "keyboardFocusedActorEnterKey", CallbackFunctor() ), TEST_LOCATION );
995 int UtcDaliKeyboardFocusManagerMoveFocusBackward(void)
997 ToolkitTestApplication application;
999 tet_infoline(" UtcDaliKeyboardFocusManagerMoveFocusBackward");
1001 KeyboardFocusManager manager = KeyboardFocusManager::Get();
1002 DALI_TEST_CHECK(manager);
1004 // Create the first actor and add it to the stage
1005 Actor first = Actor::New();
1006 first.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
1007 application.GetScene().Add(first);
1009 // Create the second actor and add it to the stage
1010 Actor second = Actor::New();
1011 second.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
1012 application.GetScene().Add(second);
1014 // Create the third actor and add it to the stage
1015 Actor third = Actor::New();
1016 third.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
1017 application.GetScene().Add(third);
1019 // Create the fourth actor and add it to the stage
1020 Actor fourth = Actor::New();
1021 fourth.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
1022 application.GetScene().Add(fourth);
1024 // Check that the focus is set on the second actor
1025 DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
1026 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
1028 // Check that the focus is set on the second actor
1029 DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
1030 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
1032 // Check that the focus is set on the third actor
1033 DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true);
1034 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
1036 // Check that the focus is set on the third actor
1037 DALI_TEST_CHECK(manager.SetCurrentFocusActor(fourth) == true);
1038 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == fourth);
1040 // Move the focus backward
1041 manager.MoveFocusBackward();
1043 // Check that it current focused actor is third actor
1044 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
1046 // Remove the second actor on stage
1049 // Reset the first actor
1053 // Move the focus backward
1054 manager.MoveFocusBackward();
1056 // Check that it current focused actor is third actor
1057 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
1059 // Make history stack full
1060 for(int i = 0 ; i < 31 ; i ++)
1062 Actor actor = Actor::New();
1063 actor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
1064 application.GetScene().Add(actor);
1065 manager.SetCurrentFocusActor(actor);
1068 for(int i = 0 ; i < 31 ; i ++)
1070 manager.MoveFocusBackward();
1073 // Check that it current focused actor is not second actor
1074 DALI_TEST_CHECK(manager.GetCurrentFocusActor() != second);
1079 int UtcDaliKeyboardFocusManagerChangeFocusDirectionByKeyEvents(void)
1081 ToolkitTestApplication application;
1083 tet_infoline(" UtcDaliKeyboardFocusManagerChangeFocusDirectionByKeyEvents");
1085 KeyboardFocusManager manager = KeyboardFocusManager::Get();
1086 DALI_TEST_CHECK(manager);
1088 bool preFocusChangeSignalVerified = false;
1089 PreFocusChangeCallback preFocusChangeCallback(preFocusChangeSignalVerified);
1090 manager.PreFocusChangeSignal().Connect( &preFocusChangeCallback, &PreFocusChangeCallback::Callback );
1092 bool focusChangedSignalVerified = false;
1093 FocusChangedCallback focusChangedCallback(focusChangedSignalVerified);
1094 manager.FocusChangedSignal().Connect( &focusChangedCallback, &FocusChangedCallback::Callback );
1096 Integration::KeyEvent leftEvent( "Left", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
1097 Integration::KeyEvent rightEvent( "Right", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
1098 Integration::KeyEvent upEvent( "Up", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
1099 Integration::KeyEvent downEvent( "Down", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
1100 Integration::KeyEvent pageUpEvent( "Prior", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
1101 Integration::KeyEvent pageDownEvent( "Next", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
1103 // Press Any key to notice physical keyboard event is comming to KeyboardFocusManager
1104 // It makes mIsFocusIndicatorEnabled true
1105 application.ProcessEvent(leftEvent);
1107 // Create a 2x2 table view and try to move focus inside it
1108 TableView tableView = TableView::New( 2, 2 );
1109 application.GetScene().Add(tableView);
1111 // Create the first actor
1112 Actor first = Actor::New();
1113 first.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
1115 // Create the second actor
1116 Actor second = Actor::New();
1117 second.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
1119 // Create the third actor
1120 Actor third = Actor::New();
1121 third.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
1123 // Create the fourth actor
1124 Actor fourth = Actor::New();
1125 fourth.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
1127 // Add the four children to table view
1128 tableView.AddChild(first, TableView::CellPosition(0, 0));
1129 tableView.AddChild(second, TableView::CellPosition(0, 1));
1130 tableView.AddChild(third, TableView::CellPosition(1, 0));
1131 tableView.AddChild(fourth, TableView::CellPosition(1, 1));
1133 // Set the focus to the first actor
1134 DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
1135 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
1136 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1137 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == Actor());
1138 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
1139 focusChangedCallback.Reset();
1141 // Send the right key event to move the focus towards right
1142 application.ProcessEvent(rightEvent);
1143 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
1144 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1145 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == first);
1146 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == second);
1147 focusChangedCallback.Reset();
1149 // Send the down key event to move the focus towards down
1150 application.ProcessEvent(downEvent);
1151 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == fourth);
1152 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1153 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == second);
1154 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == fourth);
1155 focusChangedCallback.Reset();
1157 // Send the down event to move the focus towards left
1158 application.ProcessEvent(leftEvent);
1159 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
1160 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1161 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == fourth);
1162 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == third);
1163 focusChangedCallback.Reset();
1165 // Send the up event to move the focus towards up
1166 application.ProcessEvent(upEvent);
1167 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
1168 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1169 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == third);
1170 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
1171 focusChangedCallback.Reset();
1173 // Send the pape up event, but focus should not be moved because page up is not supported by table view
1174 application.ProcessEvent(pageUpEvent);
1175 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
1176 DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
1177 DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == first);
1178 DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == first);
1179 DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::PAGE_UP);
1180 preFocusChangeCallback.Reset();
1182 // Send the pape down event, but focus should not be moved because page down is not supported by table view
1183 application.ProcessEvent(pageDownEvent);
1184 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
1185 DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
1186 DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == first);
1187 DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == first);
1188 DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::PAGE_DOWN);
1189 preFocusChangeCallback.Reset();
1192 manager.ClearFocus();
1194 // Send the pape up event, but nothing was focued so focus manager will try the initial focus
1195 preFocusChangeCallback.Reset();
1196 application.ProcessEvent(pageUpEvent);
1197 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
1198 DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
1199 DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == Actor());
1200 DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
1201 DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::RIGHT);
1203 // Clear the focus again
1204 manager.ClearFocus();
1206 // Send the pape down event, but nothing was focued so focus manager will try the initial focus
1207 preFocusChangeCallback.Reset();
1208 application.ProcessEvent(pageDownEvent);
1209 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
1210 DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
1211 DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == Actor());
1212 DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
1213 DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::RIGHT);
1215 // Clear the focus again
1216 manager.ClearFocus();
1218 // Send the up event for line coverage, but nothing was focued so focus manager will try the initial focus
1219 preFocusChangeCallback.Reset();
1220 application.ProcessEvent(upEvent);
1221 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
1222 DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
1223 DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == Actor());
1224 DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
1226 // Clear the focus again
1227 manager.ClearFocus();
1229 // Send the down event for line coverage, but nothing was focued so focus manager will try the initial focus
1230 preFocusChangeCallback.Reset();
1231 application.ProcessEvent(downEvent);
1232 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
1233 DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
1234 DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == Actor());
1235 DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
1240 int UtcDaliKeyboardFocusManagerSignalChangedBySpaceKeyEvent(void)
1242 ToolkitTestApplication application;
1244 tet_infoline(" UtcDaliKeyboardFocusManagerSignalChangedBySpaceKeyEvent");
1246 KeyboardFocusManager manager = KeyboardFocusManager::Get();
1247 DALI_TEST_CHECK(manager);
1249 bool preFocusChangeSignalVerified = false;
1250 PreFocusChangeCallback preFocusChangeCallback(preFocusChangeSignalVerified);
1251 manager.PreFocusChangeSignal().Connect( &preFocusChangeCallback, &PreFocusChangeCallback::Callback );
1253 Integration::KeyEvent spaceEvent( "space", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
1255 // Press Any key to notice physical keyboard event is comming to KeyboardFocusManager
1256 // It makes mIsFocusIndicatorEnabled true
1257 application.ProcessEvent(spaceEvent);
1259 // Send the space event
1260 application.ProcessEvent(spaceEvent);
1261 DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
1262 DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == Actor());
1264 // Clear the focus again
1265 manager.ClearFocus();
1267 // Send the space event again for line coverage
1268 preFocusChangeCallback.Reset();
1269 application.ProcessEvent(spaceEvent);
1270 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
1271 DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
1272 DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == Actor());
1273 DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
1280 int UtcDaliKeyboardFocusManagerMoveFocusTestStateChange(void)
1282 ToolkitTestApplication application;
1284 tet_infoline(" UtcDaliKeyboardFocusManagerMoveFocusTestStateChange");
1288 type = TypeRegistry::Get().GetTypeInfo( "KeyboardFocusManager" );
1289 DALI_TEST_CHECK( type );
1290 BaseHandle handle = type.CreateInstance();
1291 DALI_TEST_CHECK( handle );
1293 KeyboardFocusManager manager = KeyboardFocusManager::Get();
1294 DALI_TEST_CHECK(manager);
1296 bool preFocusChangeSignalVerified = false;
1297 PreFocusChangeCallback preFocusChangeCallback(preFocusChangeSignalVerified);
1298 manager.PreFocusChangeSignal().Connect( &preFocusChangeCallback, &PreFocusChangeCallback::Callback );
1300 bool focusChangedSignalVerified = false;
1301 FocusChangedCallback focusChangedCallback(focusChangedSignalVerified);
1302 manager.FocusChangedSignal().Connect( &focusChangedCallback, &FocusChangedCallback::Callback );
1304 // Create the first actor and add it to the stage
1305 Control first = Control::New();
1306 first.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
1307 application.GetScene().Add(first);
1309 // Create the second actor and add it to the stage
1310 Control second = Control::New();
1311 second.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
1312 application.GetScene().Add(second);
1314 // Move the focus to the right
1315 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
1317 // Because no layout control in the stage and no actor is focused, it should emit the PreFocusChange signal
1318 DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
1319 DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == Actor());
1320 DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
1321 DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::RIGHT);
1322 preFocusChangeCallback.Reset();
1324 // Check that the focus is set on the first actor
1325 DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
1326 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
1327 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1328 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == Actor());
1329 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
1330 DALI_TEST_EQUALS(first.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
1331 focusChangedCallback.Reset();
1333 // Move the focus towards right
1334 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false);
1336 // Because no layout control in the stage and the first actor is focused, it should emit the PreFocusChange signal
1337 DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
1338 DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == first);
1339 DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
1340 DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::RIGHT);
1341 preFocusChangeCallback.Reset();
1343 // Check that the focus is set on the second actor
1344 DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
1345 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
1346 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1347 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == first);
1348 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == second);
1349 DALI_TEST_EQUALS(first.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
1350 DALI_TEST_EQUALS(second.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
1351 focusChangedCallback.Reset();
1353 // Move the focus towards up
1354 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::UP) == false);
1356 // Because no layout control in the stage and no actor is focused, it should emit the PreFocusChange signal
1357 DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
1358 DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == second);
1359 DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
1360 DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::UP);
1361 preFocusChangeCallback.Reset();
1362 DALI_TEST_CHECK(!focusChangedCallback.mSignalVerified);
1364 // Create a 2x2 table view and try to move focus inside it
1365 TableView tableView = TableView::New( 2, 2 );
1366 application.GetScene().Add(tableView);
1368 // Create the third actor
1369 Control third = Control::New();
1370 third.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
1372 // Create the fourth actor
1373 Control fourth = Control::New();
1374 fourth.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
1376 // Add the four children to table view
1377 tableView.AddChild(first, TableView::CellPosition(0, 0));
1378 tableView.AddChild(second, TableView::CellPosition(0, 1));
1379 tableView.AddChild(third, TableView::CellPosition(1, 0));
1380 tableView.AddChild(fourth, TableView::CellPosition(1, 1));
1382 // Set the focus to the first actor
1383 DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
1384 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
1385 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1386 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == second);
1387 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
1389 DALI_TEST_EQUALS(first.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
1390 DALI_TEST_EQUALS(second.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
1392 focusChangedCallback.Reset();
1394 // Move the focus towards right
1395 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
1396 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
1397 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1398 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == first);
1399 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == second);
1400 DALI_TEST_EQUALS(first.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
1401 DALI_TEST_EQUALS(second.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
1403 focusChangedCallback.Reset();
1405 // Move the focus towards down
1406 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::DOWN) == true);
1407 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == fourth);
1408 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1409 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == second);
1410 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == fourth);
1412 DALI_TEST_EQUALS(first.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
1413 DALI_TEST_EQUALS(second.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
1414 DALI_TEST_EQUALS(third.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
1415 DALI_TEST_EQUALS(fourth.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
1417 focusChangedCallback.Reset();
1419 // Move the focus towards left
1420 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == true);
1421 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
1422 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1423 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == fourth);
1424 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == third);
1426 DALI_TEST_EQUALS(first.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
1427 DALI_TEST_EQUALS(second.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
1428 DALI_TEST_EQUALS(third.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
1429 DALI_TEST_EQUALS(fourth.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
1431 focusChangedCallback.Reset();
1433 // Move the focus towards up
1434 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::UP) == true);
1435 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
1436 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1437 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == third);
1438 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
1439 DALI_TEST_EQUALS(first.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
1440 DALI_TEST_EQUALS(second.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
1441 DALI_TEST_EQUALS(third.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
1442 DALI_TEST_EQUALS(fourth.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
1443 focusChangedCallback.Reset();
1445 // Move the focus towards left. The focus move will fail as no way to move it upwards
1446 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == false);
1447 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
1448 DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
1449 DALI_TEST_CHECK(preFocusChangeCallback.mCurrentFocusedActor == first);
1450 DALI_TEST_CHECK(preFocusChangeCallback.mProposedActorToFocus == Actor());
1451 DALI_TEST_CHECK(preFocusChangeCallback.mDirection == Control::KeyboardFocus::LEFT);
1452 DALI_TEST_EQUALS(first.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
1453 DALI_TEST_EQUALS(second.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
1454 DALI_TEST_EQUALS(third.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
1455 DALI_TEST_EQUALS(fourth.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
1457 preFocusChangeCallback.Reset();
1458 DALI_TEST_CHECK(!focusChangedCallback.mSignalVerified);
1461 manager.SetFocusGroupLoop(true);
1462 DALI_TEST_CHECK(manager.GetFocusGroupLoop() == true);
1464 // Move the focus towards left again. The focus should move to the fourth actor.
1465 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == true);
1466 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == fourth);
1467 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1468 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == first);
1469 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == fourth);
1471 DALI_TEST_EQUALS(first.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
1472 DALI_TEST_EQUALS(second.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
1473 DALI_TEST_EQUALS(third.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
1474 DALI_TEST_EQUALS(fourth.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION );
1476 focusChangedCallback.Reset();
1479 manager.ClearFocus();
1480 DALI_TEST_EQUALS(first.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
1481 DALI_TEST_EQUALS(second.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
1482 DALI_TEST_EQUALS(third.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
1483 DALI_TEST_EQUALS(fourth.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::NORMAL, TEST_LOCATION );
1489 int UtcDaliKeyboardFocusManagerFocusedActorUnstaged(void)
1491 ToolkitTestApplication application;
1493 tet_infoline( "Ensure we cannot set an actor to be focused if it is not staged and that we do not retrieve an actor if it has been unstaged" );
1495 KeyboardFocusManager manager = KeyboardFocusManager::Get();
1496 DALI_TEST_CHECK( ! manager.GetCurrentFocusActor() );
1498 Actor actor = Actor::New();
1499 actor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true );
1501 tet_infoline( "Attempt to set unstaged actor, no actor should be returned from KeyboardFocusManager" );
1502 manager.SetCurrentFocusActor( actor );
1503 DALI_TEST_CHECK( ! manager.GetCurrentFocusActor() );
1505 tet_infoline( "Add actor to stage and attempt to set, our actor should be returned from KeyboardFocusManager" );
1506 application.GetScene().Add( actor );
1507 manager.SetCurrentFocusActor( actor );
1508 DALI_TEST_CHECK( manager.GetCurrentFocusActor() == actor );
1510 tet_infoline( "Remove actor from stage and attempt to retrieve, no actor should be returned from KeyboardFocusManager" );
1512 DALI_TEST_CHECK( ! manager.GetCurrentFocusActor() );
1517 int UtcDaliKeyboardFocusManagerEnableFocusIndicator(void)
1519 ToolkitTestApplication application;
1521 tet_infoline( "Ensure we cannot set an actor to be focused if it is not staged and that we do not retrieve an actor if it has been unstaged" );
1523 KeyboardFocusManager manager = KeyboardFocusManager::Get();
1524 DALI_TEST_CHECK( ! manager.GetCurrentFocusActor() );
1526 Actor actor = Actor::New();
1527 actor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true );
1528 application.GetScene().Add( actor );
1529 manager.SetCurrentFocusActor( actor );
1531 // Press Any key to notice physical keyboard event is comming to KeyboardFocusManager
1532 // It makes mIsFocusIndicatorEnabled true and add focus indicator to focused actor.
1533 Integration::KeyEvent rightEvent( "Right", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
1534 application.ProcessEvent(rightEvent);
1536 Actor indicatorActor = manager.GetFocusIndicatorActor();
1538 tet_infoline( "Indicator is added to focused actor" );
1539 DALI_TEST_CHECK( actor == indicatorActor.GetParent() );
1541 Dali::Toolkit::DevelKeyboardFocusManager::EnableFocusIndicator(manager, false);
1542 DALI_TEST_CHECK( !Dali::Toolkit::DevelKeyboardFocusManager::IsFocusIndicatorEnabled(manager) );
1544 tet_infoline( "Indicator is removed from focused actor because mUseFocusIndicator is false" );
1545 DALI_TEST_CHECK( !indicatorActor.GetParent() );
1550 int UtcDaliKeyboardFocusManagerCheckConsumedKeyEvent(void)
1552 ToolkitTestApplication application;
1554 tet_infoline( "Ensure Window can't receive KeyEvent when Control already consumed it" );
1555 Dali::Integration::Scene scene = application.GetScene();
1557 KeyboardFocusManager manager = KeyboardFocusManager::Get();
1558 DALI_TEST_CHECK( ! manager.GetCurrentFocusActor() );
1560 // Create the first actor and add it to the stage
1561 Control control = Control::New();
1562 control.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
1565 KeyEventCallback controlCallback( true );
1566 control.KeyEventSignal().Connect( &controlCallback, &KeyEventCallback::Callback );
1568 KeyEventCallback sceneCallback( false );
1569 scene.KeyEventSignal().Connect( &sceneCallback, &KeyEventCallback::Callback );
1571 manager.SetCurrentFocusActor( control );
1573 // Press Any key to notice physical keyboard event is comming to KeyboardFocusManager
1574 // It makes mIsFocusIndicatorEnabled true and add focus indicator to focused actor.
1575 Integration::KeyEvent event1( "Right", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
1576 application.ProcessEvent(event1);
1578 DALI_TEST_CHECK( controlCallback.mIsCalled );
1579 DALI_TEST_CHECK( !sceneCallback.mIsCalled );
1584 int UtcDaliKeyboardFocusManagerFocusPerWindow(void)
1586 ToolkitTestApplication application;
1588 tet_infoline( "Ensure Memory focus actors for each window ");
1589 KeyboardFocusManager manager = KeyboardFocusManager::Get();
1590 DALI_TEST_CHECK( ! manager.GetCurrentFocusActor() );
1592 Window firstWindow = Window::New(PositionSize(0,0,300,500) ,"", false);
1593 DALI_TEST_CHECK( firstWindow );
1594 Control first = Control::New();
1595 first.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
1596 firstWindow.Add(first);
1598 Window secondWindow = Window::New(PositionSize(0,0,400,600) ,"", false);
1599 DALI_TEST_CHECK( secondWindow );
1600 Control second = Control::New();
1601 second.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
1602 secondWindow.Add( second );
1604 DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
1605 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
1607 DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
1608 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
1609 firstWindow.Raise();
1610 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
1612 secondWindow.Remove( second );
1613 secondWindow.Raise();
1614 DALI_TEST_CHECK(manager.GetCurrentFocusActor() != second);
1616 secondWindow.Reset();
1620 int UtcDaliKeyboardFocusManagerWithoutFocusablePropertiesMoveFocus(void)
1622 ToolkitTestApplication application;
1624 tet_infoline(" UtcDaliKeyboardFocusManagerWithoutFocusablePropertiesMoveFocus");
1628 type = TypeRegistry::Get().GetTypeInfo( "KeyboardFocusManager" );
1629 DALI_TEST_CHECK( type );
1630 BaseHandle handle = type.CreateInstance();
1631 DALI_TEST_CHECK( handle );
1633 KeyboardFocusManager manager = KeyboardFocusManager::Get();
1634 DALI_TEST_CHECK(manager);
1636 bool focusChangedSignalVerified = false;
1637 FocusChangedCallback focusChangedCallback(focusChangedSignalVerified);
1638 manager.FocusChangedSignal().Connect( &focusChangedCallback, &FocusChangedCallback::Callback );
1640 PushButton button1 = PushButton::New();
1641 PushButton button2 = PushButton::New();
1642 PushButton button3 = PushButton::New();
1643 PushButton button4 = PushButton::New();
1644 PushButton button5 = PushButton::New();
1646 button1.SetProperty(Actor::Property::SIZE, Vector2(50, 50));
1647 button2.SetProperty(Actor::Property::SIZE, Vector2(50, 50));
1648 button3.SetProperty(Actor::Property::SIZE, Vector2(50, 50));
1649 button4.SetProperty(Actor::Property::SIZE, Vector2(50, 50));
1650 button5.SetProperty(Actor::Property::SIZE, Vector2(50, 50));
1652 button1.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE,true);
1653 button2.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE,true);
1654 button3.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE,true);
1655 button4.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE,true);
1656 button5.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE,true);
1658 application.GetScene().Add(button1);
1659 application.GetScene().Add(button2);
1660 application.GetScene().Add(button3);
1661 button5.Add(button4);
1662 application.GetScene().Add(button5);
1665 // button1 -- button2
1668 // button3 -- button4
1669 button1.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f));
1670 button2.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 0.0f));
1671 button3.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 100.0f));
1672 button4.SetProperty(Actor::Property::POSITION, Vector2(40.0f, 40.0f));
1673 button5.SetProperty(Actor::Property::POSITION, Vector2(60.0f, 60.0f));
1675 // flush the queue and render once
1676 application.SendNotification();
1677 application.Render();
1679 // Set the focus to the button1
1680 // [button1] -- button2
1683 // button3 -- button4
1684 DALI_TEST_CHECK(manager.SetCurrentFocusActor(button1) == true);
1685 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == button1);
1686 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1687 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == Actor());
1688 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button1);
1689 focusChangedCallback.Reset();
1691 // without set the navigation properties, but we can focus move
1692 // enable the default algorithm
1693 Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, true);
1694 DALI_TEST_CHECK( Dali::Toolkit::DevelKeyboardFocusManager::IsDefaultAlgorithmEnabled(manager) );
1696 // Move the focus towards right
1697 // button1 -- [button2]
1700 // button3 -- button4
1701 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
1703 // Confirm whether focus is moved to button2
1704 DALI_TEST_EQUALS(button2.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION);
1705 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1706 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == button1);
1707 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button2);
1708 focusChangedCallback.Reset();
1710 // Move the focus towards down
1711 // button1 -- button2
1714 // button3 -- button4
1715 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::DOWN) == true);
1717 // Confirm whether focus is moved to button5
1718 DALI_TEST_EQUALS(button5.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION);
1719 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1720 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == button2);
1721 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button5);
1722 focusChangedCallback.Reset();
1724 // Move the focus towards right
1725 // button1 -- button2
1728 // button3 -- [button4]
1729 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
1731 // Confirm whether focus is moved to button4
1732 DALI_TEST_EQUALS(button4.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION);
1733 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1734 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == button5);
1735 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button4);
1736 focusChangedCallback.Reset();
1738 // Move the focus towards left
1739 // button1 -- button2
1742 // button3 -- button4
1743 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == true);
1745 // Confirm whether focus is moved to button5
1746 DALI_TEST_EQUALS(button5.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION);
1747 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1748 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == button4);
1749 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button5);
1750 focusChangedCallback.Reset();
1752 // Move the focus towards left
1753 // button1 -- button2
1756 //[button3] -- button4
1757 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == true);
1759 // Confirm whether focus is moved to button3
1760 DALI_TEST_EQUALS(button3.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION);
1761 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1762 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == button5);
1763 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button3);
1764 focusChangedCallback.Reset();
1766 // Move the focus towards right
1767 // button1 -- button2
1770 // button3 -- button4
1771 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
1773 // Confirm whether focus is moved to button5
1774 DALI_TEST_EQUALS(button5.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION);
1775 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1776 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == button3);
1777 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button5);
1778 focusChangedCallback.Reset();
1780 // Move the focus towards left
1781 // button1 -- button2
1784 //[button3] -- button4
1785 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == true);
1787 // Confirm whether focus is moved to button3
1788 DALI_TEST_EQUALS(button3.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION);
1789 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1790 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == button5);
1791 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button3);
1792 focusChangedCallback.Reset();
1794 // Move the focus towards up
1795 //[button1]-- button2
1798 // button3 -- button4
1799 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::UP) == true);
1801 // Confirm whether focus is moved to button1
1802 DALI_TEST_EQUALS(button1.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION);
1803 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1804 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == button3);
1805 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button1);
1806 focusChangedCallback.Reset();
1809 // Move the focus towards left. The focus move will fail as no way to move it upwards
1810 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == false);
1812 // Move the focus toward page up/down. The focus move will fail as invalid direction.
1813 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::PAGE_UP) == false);
1814 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::PAGE_DOWN) == false);
1815 focusChangedCallback.Reset();
1821 int UtcDaliKeyboardFocusManagerSetAndGetCurrentFocusActorInTouchMode(void)
1823 ToolkitTestApplication application;
1825 tet_infoline(" UtcDaliKeyboardFocusManagerSetAndGetCurrentFocusActorInTouchMode");
1827 KeyboardFocusManager manager = KeyboardFocusManager::Get();
1828 DALI_TEST_CHECK(manager);
1830 // Create the first actor and add it to the stage
1831 Actor first = Actor::New();
1832 first.SetProperty(Actor::Property::SIZE, Vector2( 50, 50 ));
1833 first.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f));
1834 first.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1835 first.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE,true);
1836 first.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE,true);
1837 application.GetScene().Add(first);
1839 // Create the second actor and add it to the stage
1840 Actor second = Actor::New();
1841 second.SetProperty(Actor::Property::SIZE, Vector2( 50, 50 ));
1842 second.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 0.0f));
1843 second.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1844 second.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE,true);
1845 application.GetScene().Add(second);
1847 // flush the queue and render once
1848 application.SendNotification();
1849 application.Render();
1851 // Check that no actor is being focused yet.
1852 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
1854 // Check that it will fail to set focus on an invalid actor
1855 DALI_TEST_CHECK(manager.SetCurrentFocusActor(Actor()) == false);
1858 Dali::Integration::TouchEvent event1 = Dali::Integration::TouchEvent();
1859 Dali::Integration::Point pointDown1;
1860 pointDown1.SetState( PointState::DOWN );
1861 pointDown1.SetDeviceId(1);
1862 // touch first actor
1863 pointDown1.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
1864 event1.AddPoint(pointDown1);
1865 application.ProcessEvent( event1 );
1867 // flush the queue and render once
1868 application.SendNotification();
1869 application.Render();
1871 // Check that the focus is successfully to the first actor
1872 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
1874 Dali::Integration::TouchEvent event2 = Dali::Integration::TouchEvent();
1875 Dali::Integration::Point pointDown2;
1876 pointDown2.SetState( PointState::DOWN );
1877 pointDown2.SetDeviceId(1);
1878 // touch second actor
1879 pointDown2.SetScreenPosition( Vector2( 110.0f, 10.0f ) );
1880 event2.AddPoint(pointDown2);
1881 application.ProcessEvent( event2 );
1883 // flush the queue and render once
1884 application.SendNotification();
1885 application.Render();
1887 // Check that the focus is successfully to clear
1888 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
1890 // Make the second actor focusableInTouchMode
1891 second.SetProperty( DevelActor::Property::TOUCH_FOCUSABLE,true);
1893 // touch second actor
1894 application.ProcessEvent( event2 );
1896 // flush the queue and render once
1897 application.SendNotification();
1898 application.Render();
1900 // Check that the focus is successfully to the second actor
1901 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
1906 int UtcDaliKeyboardFocusManagerEnableDefaultAlgorithm(void)
1908 ToolkitTestApplication application;
1910 tet_infoline(" UtcDaliKeyboardFocusManagerEnableDefaultAlgorithm");
1914 type = TypeRegistry::Get().GetTypeInfo( "KeyboardFocusManager" );
1915 DALI_TEST_CHECK( type );
1916 BaseHandle handle = type.CreateInstance();
1917 DALI_TEST_CHECK( handle );
1919 KeyboardFocusManager manager = KeyboardFocusManager::Get();
1920 DALI_TEST_CHECK(manager);
1922 bool focusChangedSignalVerified = false;
1923 FocusChangedCallback focusChangedCallback(focusChangedSignalVerified);
1924 manager.FocusChangedSignal().Connect( &focusChangedCallback, &FocusChangedCallback::Callback );
1926 PushButton button1 = PushButton::New();
1927 PushButton button2 = PushButton::New();
1929 button1.SetProperty(Actor::Property::SIZE, Vector2(50, 50));
1930 button2.SetProperty(Actor::Property::SIZE, Vector2(50, 50));
1932 button1.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE,true);
1933 button2.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE,true);
1935 application.GetScene().Add(button1);
1936 application.GetScene().Add(button2);
1939 // button1 -- button2
1940 button1.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f));
1941 button2.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 0.0f));
1943 // flush the queue and render once
1944 application.SendNotification();
1945 application.Render();
1947 // Set the focus to the button1
1948 // [button1] -- button2
1949 DALI_TEST_CHECK(manager.SetCurrentFocusActor(button1) == true);
1950 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == button1);
1951 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1952 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == Actor());
1953 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button1);
1954 focusChangedCallback.Reset();
1956 // without set the navigation properties, but we can focus move
1957 // enable the default algorithm
1958 Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, true);
1959 DALI_TEST_CHECK( Dali::Toolkit::DevelKeyboardFocusManager::IsDefaultAlgorithmEnabled(manager) );
1961 // Move the focus towards right
1962 // button1 -- [button2]
1963 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
1965 // Confirm whether focus is moved to button2
1966 DALI_TEST_EQUALS(button2.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION);
1967 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1968 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == button1);
1969 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button2);
1970 focusChangedCallback.Reset();
1972 // disable the default algorithm
1973 Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, false);
1974 DALI_TEST_CHECK( !Dali::Toolkit::DevelKeyboardFocusManager::IsDefaultAlgorithmEnabled(manager) );
1976 // Move the focus towards left, The focus move will fail because the default algorithm is disabled.
1977 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == false);
1979 // enable the default algorithm
1980 Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, true);
1981 DALI_TEST_CHECK( Dali::Toolkit::DevelKeyboardFocusManager::IsDefaultAlgorithmEnabled(manager) );
1983 // Move the focus towards left, The focus move will success because the default algorithm is enabled.
1984 // [button1] -- button2
1985 DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == true);
1986 // Confirm whether focus is moved to button2
1987 DALI_TEST_EQUALS(button1.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION);
1988 DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
1989 DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == button2);
1990 DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button1);
1991 focusChangedCallback.Reset();
1998 int UtcDaliKeyboardFocusManagerWithKeyboardFocusableChildren(void)
2000 ToolkitTestApplication application;
2002 tet_infoline(" UtcDaliKeyboardFocusManagerWithKeyboardFocusableChildren");
2004 KeyboardFocusManager manager = KeyboardFocusManager::Get();
2005 DALI_TEST_CHECK(manager);
2007 // Create the first actor and add it to the stage
2008 Actor first = Actor::New();
2009 first.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true);
2010 application.GetScene().Add(first);
2012 // Create the second actor and add it to the first actor.
2013 Actor second = Actor::New();
2014 second.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true);
2017 // Check that no actor is being focused yet.
2018 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
2020 // Check that the focus is set on the first actor
2021 DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
2022 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
2024 // Set KeyboardFocusableChildren false.
2025 first.SetProperty( DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, false);
2027 // Check that it will fail to set focus on the second actor as it's not focusable
2028 DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == false);
2029 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
2031 // Set KeyboardFocusableChildren true.
2032 first.SetProperty( DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, true);
2034 // Check that the focus is set on the second actor
2035 DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
2036 DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);