X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-AccessibilityManager.cpp;h=06cc50f85a185d112f2b07419fdb9374796ce960;hp=6cdb503886fb7bf3c5a6d174ad2fef590cef4ac6;hb=6e1c172b801e44992f243e9ebf908ce3beeb6e84;hpb=0b98fd2bb35714d1b888ca2de530f8d6be8050f8 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-AccessibilityManager.cpp b/automated-tests/src/dali-toolkit/utc-Dali-AccessibilityManager.cpp index 6cdb503..06cc50f 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-AccessibilityManager.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-AccessibilityManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -42,13 +43,6 @@ void utc_dali_toolkit_accessibility_manager_cleanup(void) namespace { -static bool gObjectCreatedCallBackCalled; - -static void TestCallback(BaseHandle handle) -{ - gObjectCreatedCallBackCalled = true; -} - // Functors to test whether focus changed signal is emitted when the focus is changed class FocusChangedCallback : public Dali::ConnectionTracker { @@ -137,19 +131,8 @@ int UtcDaliAccessibilityManagerGet(void) tet_infoline(" UtcDaliAccessibilityManagerGet"); - AccessibilityManager manager; - - //Ensure object is created by checking if it's registered - ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry(); - DALI_TEST_CHECK(registry); - - gObjectCreatedCallBackCalled = false; - registry.ObjectCreatedSignal().Connect( &TestCallback ); - { - manager = AccessibilityManager::Get(); - DALI_TEST_CHECK(manager); - } - DALI_TEST_CHECK( gObjectCreatedCallBackCalled ); + AccessibilityManager manager = AccessibilityManager::Get(); + DALI_TEST_CHECK(manager); AccessibilityManager newManager = AccessibilityManager::Get(); DALI_TEST_CHECK(newManager); @@ -300,9 +283,9 @@ int UtcDaliAccessibilityManagerGetActorByFocusOrder(void) DALI_TEST_CHECK(manager.GetActorByFocusOrder(3) == Actor()); // Add the actors to the stage - Stage::GetCurrent().Add(first); - Stage::GetCurrent().Add(second); - Stage::GetCurrent().Add(third); + application.GetScene().Add(first); + application.GetScene().Add(second); + application.GetScene().Add(third); // Check that we get an empty handle because focus order 0 means undefined. DALI_TEST_CHECK(manager.GetActorByFocusOrder(0) == Actor()); @@ -345,12 +328,12 @@ int UtcDaliAccessibilityManagerSetAndGetCurrentFocusActor(void) // Create the first actor and add it to the stage Actor first = Actor::New(); manager.SetFocusOrder(first, 1); - Stage::GetCurrent().Add(first); + application.GetScene().Add(first); // Create the second actor and add it to the stage Actor second = Actor::New(); manager.SetFocusOrder(second, 2); - Stage::GetCurrent().Add(second); + application.GetScene().Add(second); // Create the third actor but don't add it to the stage Actor third = Actor::New(); @@ -374,10 +357,10 @@ int UtcDaliAccessibilityManagerSetAndGetCurrentFocusActor(void) DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false); // Add the third actor to the stage - Stage::GetCurrent().Add(third); + application.GetScene().Add(third); // make the third actor invisible - third.SetVisible(false); + third.SetProperty( Actor::Property::VISIBLE,false); // flush the queue and render once application.SendNotification(); application.Render(); @@ -386,7 +369,7 @@ int UtcDaliAccessibilityManagerSetAndGetCurrentFocusActor(void) DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false); // Make the third actor visible - third.SetVisible(true); + third.SetProperty( Actor::Property::VISIBLE,true); // flush the queue and render once application.SendNotification(); application.Render(); @@ -443,7 +426,7 @@ int UtcDaliAccessibilityManagerGetCurrentFocusGroup(void) Actor secondChild = Actor::New(); parent.Add(firstChild); parent.Add(secondChild); - Stage::GetCurrent().Add(parent); + application.GetScene().Add(parent); // Create three actors and add them as the children of the first child actor Actor firstGrandChild = Actor::New(); @@ -509,13 +492,13 @@ int UtcDaliAccessibilityManagerGetCurrentFocusOrder(void) accAdaptor.HandleActionEnableEvent(); Actor first = Actor::New(); - Stage::GetCurrent().Add(first); + application.GetScene().Add(first); Actor second = Actor::New(); - Stage::GetCurrent().Add(second); + application.GetScene().Add(second); Actor third = Actor::New(); - Stage::GetCurrent().Add(third); + application.GetScene().Add(third); // Set the focus order and description for the first actor manager.SetFocusOrder(first, 1); @@ -568,15 +551,16 @@ int UtcDaliAccessibilityManagerMoveFocusForward(void) Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); accAdaptor.HandleActionEnableEvent(); + accAdaptor.HandleActionNextEvent(true); Actor first = Actor::New(); - Stage::GetCurrent().Add(first); + application.GetScene().Add(first); Actor second = Actor::New(); - Stage::GetCurrent().Add(second); + application.GetScene().Add(second); Actor third = Actor::New(); - Stage::GetCurrent().Add(third); + application.GetScene().Add(third); // Set the focus order and description for the first actor manager.SetFocusOrder(first, 1); @@ -648,7 +632,7 @@ int UtcDaliAccessibilityManagerMoveFocusForward(void) DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "third"); // Make the first actor invisible - first.SetVisible(false); + first.SetProperty( Actor::Property::VISIBLE,false); // flush the queue and render once application.SendNotification(); application.Render(); @@ -661,7 +645,7 @@ int UtcDaliAccessibilityManagerMoveFocusForward(void) DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "third"); // Make the third actor invisible so that no actor can be focused. - third.SetVisible(false); + third.SetProperty( Actor::Property::VISIBLE,false); // flush the queue and render once application.SendNotification(); application.Render(); @@ -687,13 +671,13 @@ int UtcDaliAccessibilityManagerMoveFocusBackward(void) accAdaptor.HandleActionEnableEvent(); Actor first = Actor::New(); - Stage::GetCurrent().Add(first); + application.GetScene().Add(first); Actor second = Actor::New(); - Stage::GetCurrent().Add(second); + application.GetScene().Add(second); Actor third = Actor::New(); - Stage::GetCurrent().Add(third); + application.GetScene().Add(third); // Set the focus order and description for the first actor manager.SetFocusOrder(first, 1); @@ -765,7 +749,7 @@ int UtcDaliAccessibilityManagerMoveFocusBackward(void) DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "first"); // Make the third actor invisible - third.SetVisible(false); + third.SetProperty( Actor::Property::VISIBLE,false); // flush the queue and render once application.SendNotification(); application.Render(); @@ -778,7 +762,7 @@ int UtcDaliAccessibilityManagerMoveFocusBackward(void) DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "first"); // Make the first actor invisible so that no actor can be focused. - first.SetVisible(false); + first.SetProperty( Actor::Property::VISIBLE,false); // flush the queue and render once application.SendNotification(); application.Render(); @@ -806,12 +790,12 @@ int UtcDaliAccessibilityManagerClearFocus(void) // Create the first actor and add it to the stage Actor first = Actor::New(); manager.SetFocusOrder(first, 1); - Stage::GetCurrent().Add(first); + application.GetScene().Add(first); // Create the second actor and add it to the stage Actor second = Actor::New(); manager.SetFocusOrder(second, 2); - Stage::GetCurrent().Add(second); + application.GetScene().Add(second); // Check that no actor is being focused yet. DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor()); @@ -844,12 +828,12 @@ int UtcDaliAccessibilityManagerReset(void) // Create the first actor and add it to the stage Actor first = Actor::New(); manager.SetFocusOrder(first, 1); - Stage::GetCurrent().Add(first); + application.GetScene().Add(first); // Create the second actor and add it to the stage Actor second = Actor::New(); manager.SetFocusOrder(second, 2); - Stage::GetCurrent().Add(second); + application.GetScene().Add(second); // Check that no actor is being focused yet. DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor()); @@ -891,7 +875,7 @@ int UtcDaliAccessibilityManagerFocusGroup(void) Actor secondChild = Actor::New(); parent.Add(firstChild); parent.Add(secondChild); - Stage::GetCurrent().Add(parent); + application.GetScene().Add(parent); // Create three actors and add them as the children of the first child actor Actor firstGrandChild = Actor::New(); @@ -991,6 +975,51 @@ int UtcDaliAccessibilityManagerSetAndGetFocusIndicator(void) END_TEST; } +int UtcDaliAccessibilityManagerSetAndGetFocusIndicatorWithFocusedActor(void) +{ + ToolkitTestApplication application; + + tet_infoline(" UtcDaliAccessibilityManagerSetAndGetFocusIndicatorWithFocusedActor"); + + AccessibilityManager manager = AccessibilityManager::Get(); + DALI_TEST_CHECK(manager); + + Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); + Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); + accAdaptor.HandleActionEnableEvent(); + + Actor defaultFocusIndicatorActor = manager.GetFocusIndicatorActor(); + DALI_TEST_CHECK(defaultFocusIndicatorActor); + + Actor focusedActor = Actor::New(); + application.GetScene().Add( focusedActor ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( focusedActor.GetChildCount(), 0u, TEST_LOCATION ); + + manager.SetFocusOrder( focusedActor, 1 ); + manager.SetCurrentFocusActor( focusedActor ); + + DALI_TEST_EQUALS( focusedActor.GetChildCount(), 1u, TEST_LOCATION ); + DALI_TEST_CHECK( focusedActor.GetChildAt(0) == defaultFocusIndicatorActor ); + + Actor newFocusIndicatorActor = Actor::New(); + manager.SetFocusIndicatorActor( newFocusIndicatorActor ); + DALI_TEST_CHECK(manager.GetFocusIndicatorActor() == newFocusIndicatorActor); + DALI_TEST_EQUALS( focusedActor.GetChildCount(), 1u, TEST_LOCATION ); + DALI_TEST_CHECK( focusedActor.GetChildAt(0) == newFocusIndicatorActor ); + + // Disable Accessibility + Test::AccessibilityAdaptor::SetEnabled( accAdaptor, false ); + accAdaptor.HandleActionEnableEvent(); + + DALI_TEST_EQUALS( focusedActor.GetChildCount(), 0u, TEST_LOCATION ); + + END_TEST; +} + int UtcDaliAccessibilityManagerSignalFocusChanged(void) { ToolkitTestApplication application; @@ -1007,12 +1036,12 @@ int UtcDaliAccessibilityManagerSignalFocusChanged(void) // Create the first actor and add it to the stage Actor first = Actor::New(); manager.SetFocusOrder(first, 1); - Stage::GetCurrent().Add(first); + application.GetScene().Add(first); // Create the second actor and add it to the stage Actor second = Actor::New(); manager.SetFocusOrder(second, 2); - Stage::GetCurrent().Add(second); + application.GetScene().Add(second); // Check that no actor is being focused yet. DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor()); @@ -1058,12 +1087,12 @@ int UtcDaliAccessibilityManagerSignalFocusOvershot(void) // Create the first actor and add it to the stage Actor first = Actor::New(); manager.SetFocusOrder(first, 1); - Stage::GetCurrent().Add(first); + application.GetScene().Add(first); // Create the second actor and add it to the stage Actor second = Actor::New(); manager.SetFocusOrder(second, 2); - Stage::GetCurrent().Add(second); + application.GetScene().Add(second); // Check that the wrap mode is disabled DALI_TEST_CHECK(manager.GetWrapMode() == false); @@ -1287,8 +1316,8 @@ int UtcDaliAccessibilityManagerActionActivateSignalP(void) accAdaptor.HandleActionEnableEvent(); Dali::Toolkit::PushButton button = Dali::Toolkit::PushButton::New(); - button.SetSize(480, 800); - Stage::GetCurrent().Add(button); + button.SetProperty( Actor::Property::SIZE, Vector2(480, 800) ); + application.GetScene().Add(button); manager.SetFocusOrder( button, 1 ); manager.SetCurrentFocusActor( button ); @@ -1496,9 +1525,9 @@ int UtcDaliAccessibilityManagerActionUpSignalP(void) manager.ActionUpSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); DummyControl dummyControl = DummyControl::New(true); - dummyControl.SetSize(480, 800); + dummyControl.SetProperty( Actor::Property::SIZE, Vector2(480, 800) ); manager.SetFocusOrder( dummyControl, 1 ); - Stage::GetCurrent().Add( dummyControl ); + application.GetScene().Add( dummyControl ); manager.SetCurrentFocusActor( dummyControl ); accessibilityAdaptor.HandleActionUpEvent(); @@ -1541,8 +1570,8 @@ int UtcDaliAccessibilityManagerActionDownSignalP(void) manager.ActionDownSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); Dali::Toolkit::PushButton button = Dali::Toolkit::PushButton::New(); - button.SetSize(480, 800); - Stage::GetCurrent().Add(button); + button.SetProperty( Actor::Property::SIZE, Vector2(480, 800) ); + application.GetScene().Add(button); manager.SetFocusOrder( button, 1 ); manager.SetCurrentFocusActor( button ); @@ -1917,6 +1946,7 @@ int UtcDaliAccessibilityManagerActionMoveToFirstSignalP(void) END_TEST; } + int UtcDaliAccessibilityManagerActionMoveToFirstSignalN(void) { ToolkitTestApplication application; @@ -2068,8 +2098,8 @@ int UtcDaliAccessibilityManagerActionZoomSignalP(void) DALI_TEST_CHECK( manager ); Dali::Toolkit::PushButton button = Dali::Toolkit::PushButton::New(); - button.SetSize(480, 800); - Stage::GetCurrent().Add(button); + button.SetProperty( Actor::Property::SIZE, Vector2(480, 800) ); + application.GetScene().Add(button); manager.SetFocusOrder( button, 1 ); manager.SetCurrentFocusActor( button ); @@ -2103,46 +2133,6 @@ int UtcDaliAccessibilityManagerActionZoomSignalN(void) END_TEST; } -int UtcDaliAccessibilityManagerActionReadIndicatorInformationSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionReadIndicatorInformationSignalP" ); - - AccessibilityManagerSignalHandler callback; - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionReadIndicatorInformationSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionReadIndicatorInformationEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionReadIndicatorInformationSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionReadIndicatorInformationSignalN" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionReadIndicatorInformationSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - int UtcDaliAccessibilityManagerActionReadPauseResumeSignalP(void) { ToolkitTestApplication application; @@ -2228,10 +2218,11 @@ public: { } - bool Callback( AccessibilityManager& accessibilityManager, const Dali::TouchEvent& touchEvent ) + bool Callback( AccessibilityManager& accessibilityManager, const Dali::TouchData& touchEvent ) { mCalls++; - mTouchEvent = touchEvent; + Dali::TouchData handle(touchEvent); // Ensure it's ref-counted + mTouchData = handle; tet_infoline( "Signal called" ); return true; } @@ -2241,14 +2232,14 @@ public: return mCalls; } - const Dali::TouchEvent& GetTouchEvent() const + const Dali::TouchData& GetTouchData() const { - return mTouchEvent; + return mTouchData; } private: unsigned int mCalls; ///< Keeps track of how many times the signal has been called. - Dali::TouchEvent mTouchEvent; ///< Stores the last touch event received. + Dali::TouchData mTouchData ; ///< Stores the last touch event received. }; int UtcDaliAccessibilityManagerActionScrollSignalP(void) @@ -2270,14 +2261,13 @@ int UtcDaliAccessibilityManagerActionScrollSignalP(void) DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - const TouchEvent& signalTouchEvent = callback.GetTouchEvent(); - DALI_TEST_EQUALS( signalTouchEvent.GetPointCount(), 1u, TEST_LOCATION ); + const TouchData& signalTouchData = callback.GetTouchData(); + DALI_TEST_EQUALS( signalTouchData.GetPointCount(), 1u, TEST_LOCATION ); - const TouchPoint& signalTouchPoint = signalTouchEvent.GetPoint( 0u ); - DALI_TEST_EQUALS( signalTouchPoint.state, TouchPoint::Started, TEST_LOCATION ); - DALI_TEST_EQUALS( signalTouchPoint.screen.x, 100.0f, TEST_LOCATION ); - DALI_TEST_EQUALS( signalTouchPoint.screen.y, 200.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( signalTouchData.GetState(0), PointState::STARTED, TEST_LOCATION ); + DALI_TEST_EQUALS( signalTouchData.GetScreenPosition(0).x, 100.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( signalTouchData.GetScreenPosition(0).y, 200.0f, TEST_LOCATION ); END_TEST; } @@ -2310,10 +2300,10 @@ int UtcDaliAccessibilityManagerActionTouch(void) Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); DummyControl dummyControl = DummyControl::New(true); - DummyControlImplOverride& dummyImpl = static_cast(dummyControl.GetImplementation()); - dummyControl.SetSize(480, 800); + Impl::DummyControl& dummyImpl = static_cast(dummyControl.GetImplementation()); + dummyControl.SetProperty( Actor::Property::SIZE, Vector2(480, 800) ); manager.SetFocusOrder( dummyControl, 1 ); - Stage::GetCurrent().Add( dummyControl ); + application.GetScene().Add( dummyControl ); manager.SetCurrentFocusActor( dummyControl ); TouchPoint point( 0, TouchPoint::Started, 100.0f, 200.0f ); @@ -2337,10 +2327,10 @@ int UtcDaliAccessibilityManagerHandlePanGesture(void) Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); DummyControl dummyControl = DummyControl::New(true); - dummyControl.SetSize(480, 800); - Stage::GetCurrent().Add( dummyControl ); + dummyControl.SetProperty( Actor::Property::SIZE, Vector2(480, 800) ); + application.GetScene().Add( dummyControl ); - Dali::Integration::PanGestureEvent panGestureEvent(Gesture::Started); + AccessibilityGestureEvent panGestureEvent(AccessibilityGestureEvent::Started); panGestureEvent.previousPosition = Vector2(0.f, 0.f); panGestureEvent.currentPosition = Vector2(100.f, 0.f); panGestureEvent.timeDelta = 16; @@ -2348,12 +2338,12 @@ int UtcDaliAccessibilityManagerHandlePanGesture(void) Test::AccessibilityAdaptor::SendPanGesture( accessibilityAdaptor, panGestureEvent ); - panGestureEvent.state = Gesture::Continuing; + panGestureEvent.state = AccessibilityGestureEvent::Continuing; panGestureEvent.previousPosition = Vector2(100.f, 0.f); panGestureEvent.currentPosition = Vector2(200.f, 0.f); Test::AccessibilityAdaptor::SendPanGesture( accessibilityAdaptor, panGestureEvent ); - panGestureEvent.state = Gesture::Finished; + panGestureEvent.state = AccessibilityGestureEvent::Finished; panGestureEvent.previousPosition = Vector2(200.f, 0.f); panGestureEvent.currentPosition = Vector2(300.f, 0.f); Test::AccessibilityAdaptor::SendPanGesture( accessibilityAdaptor, panGestureEvent );