namespace
{
+const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
+
// Functors to test whether GetNextFocusableActor() method of CustomAlgorithmInterface is called when the keyboard focus is about to change
class CustomAlgorithm : public Dali::Toolkit::DevelKeyboardFocusManager::CustomAlgorithmInterface
{
FocusedActorActivatedCallback focusedActorActivatedCallback(focusedActorActivatedSignalVerified);
manager.FocusedActorEnterKeySignal().Connect( &focusedActorActivatedCallback, &FocusedActorActivatedCallback::Callback );
- Integration::KeyEvent returnEvent("Return", "", 0, 0, 0, Integration::KeyEvent::Up);
+ Integration::KeyEvent returnEvent( "Return", "", 0, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE );
// Press Any key to notice physical keyboard event is comming to KeyboardFocusManager
// It makes mIsFocusIndicatorEnabled true
FocusGroupChangedCallback focusGroupChangedCallback(focusGroupChangedSignalVerified);
manager.FocusGroupChangedSignal().Connect( &focusGroupChangedCallback, &FocusGroupChangedCallback::Callback );
- Integration::KeyEvent tabEvent("Tab", "", 0, 0, 0, Integration::KeyEvent::Down);
- Integration::KeyEvent shiftTabEvent("Tab", "", 0, 1, 0, Integration::KeyEvent::Down);
+ Integration::KeyEvent tabEvent( "Tab", "", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE );
+ Integration::KeyEvent shiftTabEvent( "Tab", "", 0, 1, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE );
// Press Any key to notice physical keyboard event is comming to KeyboardFocusManager
// It makes mIsFocusIndicatorEnabled true
FocusChangedCallback focusChangedCallback(focusChangedSignalVerified);
manager.FocusChangedSignal().Connect( &focusChangedCallback, &FocusChangedCallback::Callback );
- Integration::KeyEvent leftEvent("Left", "", 0, 0, 0, Integration::KeyEvent::Down);
- Integration::KeyEvent rightEvent("Right", "", 0, 0, 0, Integration::KeyEvent::Down);
- Integration::KeyEvent upEvent("Up", "", 0, 0, 0, Integration::KeyEvent::Down);
- Integration::KeyEvent downEvent("Down", "", 0, 0, 0, Integration::KeyEvent::Down);
- Integration::KeyEvent pageUpEvent("Prior", "", 0, 0, 0, Integration::KeyEvent::Down);
- Integration::KeyEvent pageDownEvent("Next", "", 0, 0, 0, Integration::KeyEvent::Down);
+ Integration::KeyEvent leftEvent( "Left", "", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE );
+ Integration::KeyEvent rightEvent( "Right", "", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE );
+ Integration::KeyEvent upEvent( "Up", "", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE );
+ Integration::KeyEvent downEvent( "Down", "", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE );
+ Integration::KeyEvent pageUpEvent( "Prior", "", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE );
+ Integration::KeyEvent pageDownEvent( "Next", "", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE );
// Press Any key to notice physical keyboard event is comming to KeyboardFocusManager
// It makes mIsFocusIndicatorEnabled true
END_TEST;
}
+
+int UtcDaliKeyboardFocusManagerFocusedActorUnstaged(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.SetKeyboardFocusable( true );
+
+ tet_infoline( "Attempt to set unstaged actor, no actor should be returned from KeyboardFocusManager" );
+ manager.SetCurrentFocusActor( actor );
+ DALI_TEST_CHECK( ! manager.GetCurrentFocusActor() );
+
+ tet_infoline( "Add actor to stage and attempt to set, our actor should be returned from KeyboardFocusManager" );
+ Stage::GetCurrent().Add( actor );
+ manager.SetCurrentFocusActor( actor );
+ DALI_TEST_CHECK( manager.GetCurrentFocusActor() == actor );
+
+ tet_infoline( "Remove actor from stage and attempt to retrieve, no actor should be returned from KeyboardFocusManager" );
+ actor.Unparent();
+ DALI_TEST_CHECK( ! manager.GetCurrentFocusActor() );
+
+ END_TEST;
+}