[dali_1.4.44] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-KeyInputFocusManager.cpp
old mode 100644 (file)
new mode 100755 (executable)
index cf1a006..4686512
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -139,6 +139,7 @@ int UtcDaliKeyInputFocusManagerGet(void)
 
   // Check that focus manager is a singleton
   DALI_TEST_CHECK(manager == newManager);
+
   END_TEST;
 }
 
@@ -250,7 +251,7 @@ int UtcDaliKeyInputFocusManagerKeyEventPropagation01(void)
   manager.SetFocus( dummy3 );
   DALI_TEST_CHECK( dummy3Impl.keyInputFocusGained );
 
-  Integration::KeyEvent event( "a", "a", 0, 0, 0, Integration::KeyEvent::Up, "", DevelDevice::Class::TOUCH, DevelDevice::Subclass::NONE );
+  Integration::KeyEvent event( "a", "", "a", 0, 0, 0, Integration::KeyEvent::Up, "", "", Device::Class::TOUCH, Device::Subclass::NONE );
   application.ProcessEvent(event);
 
   DALI_TEST_CHECK( callback1.mIsCalled );
@@ -296,7 +297,7 @@ int UtcDaliKeyInputFocusManagerKeyEventPropagation02(void)
   manager.SetFocus( dummy3 );
   DALI_TEST_CHECK( dummy3Impl.keyInputFocusGained );
 
-  Integration::KeyEvent event( "a", "a", 0, 0, 0, Integration::KeyEvent::Up, "", DevelDevice::Class::TOUCH, DevelDevice::Subclass::NONE );
+  Integration::KeyEvent event( "a", "", "a", 0, 0, 0, Integration::KeyEvent::Up, "", "", Device::Class::TOUCH, Device::Subclass::NONE );
   application.ProcessEvent(event);
 
   DALI_TEST_CHECK( !callback1.mIsCalled );
@@ -430,3 +431,49 @@ int UtcDaliKeyInputFocusManagerSignalKeyInputFocusChanged(void)
   DALI_TEST_CHECK( lostActor == Control() );
   END_TEST;
 }
+
+int UtcDaliKeyInputFocusManagerSignalKeyInputFocusChangedforNewWindow(void)
+{
+  ToolkitTestApplication application;
+  KeyInputFocusManager manager = KeyInputFocusManager::Get();
+
+  tet_infoline(" UtcDaliKeyInputFocusManagerSignalKeyInputFocusChanged");
+
+  PushButton pushButton1 = PushButton::New();
+  PushButton pushButton2 = PushButton::New();
+
+  Window window = Window::New(PositionSize(0,0,0,0) ,"", false);
+  DALI_TEST_CHECK( window );
+
+  window.Add( pushButton1 );
+  window.Add( pushButton2 );
+
+  PushButton gainActor, lostActor;
+  KeyInputFocusChangedCallback callback( gainActor, lostActor );
+  manager.KeyInputFocusChangedSignal().Connect( &callback, &KeyInputFocusChangedCallback::Callback );
+
+  manager.SetFocus(pushButton1);
+
+  DALI_TEST_CHECK( gainActor == pushButton1 );
+  DALI_TEST_CHECK( lostActor == Control() );
+
+  gainActor.Reset();
+  lostActor.Reset();
+
+  manager.SetFocus(pushButton2);
+
+  DALI_TEST_CHECK( gainActor == pushButton2 );
+  DALI_TEST_CHECK( lostActor == pushButton1 );
+
+  gainActor.Reset();
+  lostActor.Reset();
+
+  // Removing the focus actor from the window would also result in signal emission.
+  window.Remove( pushButton1 );
+  window.Remove( pushButton2 );
+  DALI_TEST_CHECK( gainActor == Control() );
+  DALI_TEST_CHECK( lostActor == Control() );
+
+  window.Reset();
+  END_TEST;
+}