+
+int UtcDaliKeyboardFocusManagerEnableFocusIndicator(void)
+{
+ ToolkitTestApplication application;
+
+ 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" );
+
+ KeyboardFocusManager manager = KeyboardFocusManager::Get();
+ DALI_TEST_CHECK( ! manager.GetCurrentFocusActor() );
+
+ Actor actor = Actor::New();
+ actor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true );
+ application.GetScene().Add( actor );
+ manager.SetCurrentFocusActor( actor );
+
+ // Press Any key to notice physical keyboard event is comming to KeyboardFocusManager
+ // It makes mIsFocusIndicatorEnabled true and add focus indicator to focused actor.
+ Integration::KeyEvent rightEvent( "Right", "", "", 0, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
+ application.ProcessEvent(rightEvent);
+
+ Actor indicatorActor = manager.GetFocusIndicatorActor();
+
+ tet_infoline( "Indicator is added to focused actor" );
+ DALI_TEST_CHECK( actor == indicatorActor.GetParent() );
+
+ Dali::Toolkit::DevelKeyboardFocusManager::EnableFocusIndicator(manager, false);
+ DALI_TEST_CHECK( !Dali::Toolkit::DevelKeyboardFocusManager::IsFocusIndicatorEnabled(manager) );
+
+ tet_infoline( "Indicator is removed from focused actor because mUseFocusIndicator is false" );
+ DALI_TEST_CHECK( !indicatorActor.GetParent() );
+
+ END_TEST;
+}
+
+int UtcDaliKeyboardFocusManagerCheckConsumedKeyEvent(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline( "Ensure Window can't receive KeyEvent when Control already consumed it" );
+ Dali::Integration::Scene scene = application.GetScene();
+
+ KeyboardFocusManager manager = KeyboardFocusManager::Get();
+ DALI_TEST_CHECK( ! manager.GetCurrentFocusActor() );
+
+ // Create the first actor and add it to the stage
+ Control control = Control::New();
+ control.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
+ scene.Add(control);
+
+ KeyEventCallback controlCallback( true );
+ control.KeyEventSignal().Connect( &controlCallback, &KeyEventCallback::Callback );
+
+ KeyEventCallback sceneCallback( false );
+ scene.KeyEventSignal().Connect( &sceneCallback, &KeyEventCallback::Callback );
+
+ manager.SetCurrentFocusActor( control );
+
+ // Press Any key to notice physical keyboard event is comming to KeyboardFocusManager
+ // It makes mIsFocusIndicatorEnabled true and add focus indicator to focused actor.
+ Integration::KeyEvent event1( "Right", "", "", 0, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE );
+ application.ProcessEvent(event1);
+
+ DALI_TEST_CHECK( controlCallback.mIsCalled );
+ DALI_TEST_CHECK( !sceneCallback.mIsCalled );
+
+ END_TEST;
+}
+
+int UtcDaliKeyboardFocusManagerFocusPerWindow(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline( "Ensure Memory focus actors for each window ");
+ KeyboardFocusManager manager = KeyboardFocusManager::Get();
+ DALI_TEST_CHECK( ! manager.GetCurrentFocusActor() );
+
+ Window firstWindow = Window::New(PositionSize(0,0,300,500) ,"", false);
+ DALI_TEST_CHECK( firstWindow );
+ Control first = Control::New();
+ first.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
+ firstWindow.Add(first);
+
+ Window secondWindow = Window::New(PositionSize(0,0,400,600) ,"", false);
+ DALI_TEST_CHECK( secondWindow );
+ Control second = Control::New();
+ second.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
+ secondWindow.Add( second );
+
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
+ firstWindow.Raise();
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+
+ secondWindow.Remove( second );
+ secondWindow.Raise();
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() != second);
+
+ secondWindow.Reset();
+ END_TEST;
+}
+
+