X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-KeyboardFocusManager.cpp;h=c7a2a1269cf422a2c1353774df84c4771139e1f6;hb=227d24038db910dd02672455085382f0c0be4c51;hp=95a6eb572410515912d64e583b867c093aad1ade;hpb=aabc3440c8952244a7f50af568e23c735a04ffef;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp b/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp index 95a6eb5..c7a2a12 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. @@ -175,8 +175,19 @@ public: Actor mActivatedActor; }; -} // namespace +// Used to connect to signals via the ConnectSignal Handle method +struct CallbackFunctor +{ + CallbackFunctor() + { + } + void operator()() + { + } +}; + +} // namespace int UtcDaliKeyboardFocusManagerGet(void) { @@ -668,3 +679,86 @@ int UtcDaliKeyboardFocusManagerSignalFocusGroupChanged(void) focusGroupChangedCallback.Reset(); END_TEST; } + +int UtcDaliKeyboardFocusManagerSignals(void) +{ + ToolkitTestApplication application; + + KeyboardFocusManager manager = KeyboardFocusManager::Get(); + DALI_TEST_CHECK( manager ); + + ConnectionTracker* testTracker = new ConnectionTracker(); + DALI_TEST_EQUALS( true, manager.ConnectSignal( testTracker, "keyboardPreFocusChange", CallbackFunctor() ), TEST_LOCATION ); + DALI_TEST_EQUALS( true, manager.ConnectSignal( testTracker, "keyboardFocusChanged", CallbackFunctor() ), TEST_LOCATION ); + DALI_TEST_EQUALS( true, manager.ConnectSignal( testTracker, "keyboardFocusGroupChanged", CallbackFunctor() ), TEST_LOCATION ); + DALI_TEST_EQUALS( true, manager.ConnectSignal( testTracker, "keyboardFocusedActorEnterKey", CallbackFunctor() ), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliKeyboardFocusManagerMoveFocusBackward(void) +{ + ToolkitTestApplication application; + + tet_infoline(" UtcDaliKeyboardFocusManagerMoveFocusBackward"); + + KeyboardFocusManager manager = KeyboardFocusManager::Get(); + DALI_TEST_CHECK(manager); + + // Make history stack full + for(int i = 0 ; i < 31 ; i ++) + { + Actor actor = Actor::New(); + actor.SetKeyboardFocusable(true); + Stage::GetCurrent().Add(actor); + manager.SetCurrentFocusActor(actor); + } + + // Create the first actor and add it to the stage + Actor first = Actor::New(); + first.SetKeyboardFocusable(true); + Stage::GetCurrent().Add(first); + + // Create the second actor and add it to the stage + Actor second = Actor::New(); + second.SetKeyboardFocusable(true); + Stage::GetCurrent().Add(second); + + // Create the second actor and add it to the stage + Actor third = Actor::New(); + third.SetKeyboardFocusable(true); + Stage::GetCurrent().Add(third); + + // Check that the focus is set on the second actor + DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true); + DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first); + + // Check that the focus is set on the second actor + DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true); + DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second); + + // Check that the focus is set on the third actor + DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true); + DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third); + + // Move the focus backward + manager.MoveFocusBackward(); + + // Check that it current focused actor is second actor + DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second); + + // Check that the focus is set on the third actor + DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true); + DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third); + + // Remove the second actor on stage + second.Unparent(); + + // Move the focus backward + manager.MoveFocusBackward(); + + // Check that it current focused actor is first actor + DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first); + + END_TEST; +}