X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-internal%2Futc-Dali-Accessibility-Controls-BridgeUp.cpp;h=047018d371ac407c6d063ebbbca551e0168b395b;hp=c68e84f96f26f770f9628f8bc29ded1ee4a80060;hb=refs%2Fchanges%2F79%2F265679%2F5;hpb=ed11499452da1ccd5fdfa36324881dc66a5281bc diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Controls-BridgeUp.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Controls-BridgeUp.cpp index c68e84f..047018d 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Controls-BridgeUp.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Controls-BridgeUp.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -460,6 +461,22 @@ int UtcDaliControlReadingInfoType(void) auto control = Control::New(); auto reading_info_type = DevelControl::GetAccessibilityReadingInfoType(control); + + for ( auto i = 0u; i < 4; ++i) + DALI_TEST_CHECK ( reading_info_type[ static_cast< Dali::Accessibility::ReadingInfoType >( i ) ]); + + reading_info_type[Dali::Accessibility::ReadingInfoType::DESCRIPTION] = false; + reading_info_type[Dali::Accessibility::ReadingInfoType::STATE] = false; + reading_info_type[Dali::Accessibility::ReadingInfoType::NAME] = false; + reading_info_type[Dali::Accessibility::ReadingInfoType::ROLE] = false; + + DevelControl::SetAccessibilityReadingInfoType(control, reading_info_type); + + reading_info_type = DevelControl::GetAccessibilityReadingInfoType(control); + + for ( auto i = 0u; i < 4; ++i) + DALI_TEST_CHECK ( false == reading_info_type[ static_cast< Dali::Accessibility::ReadingInfoType >( i ) ]); + reading_info_type[Dali::Accessibility::ReadingInfoType::DESCRIPTION] = true; reading_info_type[Dali::Accessibility::ReadingInfoType::STATE] = true; reading_info_type[Dali::Accessibility::ReadingInfoType::NAME] = true; @@ -678,17 +695,24 @@ int UtcDaliAccessibilityGrabFocus(void) END_TEST; } -int UtcDaliAccessibilityGetExtents(void) +int UtcDaliAccessibilityGetExtentsScreenAndWindowPositionMatch(void) { ToolkitTestApplication application; + tet_infoline( "UtcDaliAccessibilityGetExtentsScreenAndWindowPositionMatch" ); Dali::Accessibility::TestEnableSC( true ); auto control = Control::New(); Stage::GetCurrent().GetRootLayer().Add( control ); - control.SetProperty(Actor::Property::POSITION, Vector3(10, 10, 100)); - control.SetProperty(Actor::Property::SIZE, Vector2(10, 10)); + auto window = Dali::DevelWindow::Get( control ); + DALI_TEST_CHECK( window ); + + //window.SetPosition({0,0}); + DevelWindow::SetPositionSize( window, PositionSize( 0,0,480, 240 ) ); + + control.SetProperty( Actor::Property::POSITION, Vector3( 10, 10, 100 ) ); + control.SetProperty( Actor::Property::SIZE, Vector2( 10, 10 ) ); application.SendNotification(); application.Render( 1 ); @@ -696,13 +720,25 @@ int UtcDaliAccessibilityGetExtents(void) auto a = Dali::Accessibility::Accessible::Get( control ); auto a_component = dynamic_cast( a ); - auto extents = a_component->GetExtents(Dali::Accessibility::CoordType::SCREEN); + auto extents = a_component->GetExtents( Dali::Accessibility::CoordinateType::SCREEN ); DALI_TEST_EQUALS( extents.x, 5.0f, TEST_LOCATION ); DALI_TEST_EQUALS( extents.y, 5.0f, TEST_LOCATION ); DALI_TEST_EQUALS( extents.height, 10.0f, TEST_LOCATION ); DALI_TEST_EQUALS( extents.width, 10.0f, TEST_LOCATION ); - auto bridge_extents = TestGetExtents( a_component -> GetAddress() ); + auto bridge_extents = TestGetExtents( a_component -> GetAddress(), Dali::Accessibility::CoordinateType::SCREEN ); + DALI_TEST_EQUALS( std::get< 0 >( bridge_extents ), 5, TEST_LOCATION ); + DALI_TEST_EQUALS( std::get< 1 >( bridge_extents ), 5, TEST_LOCATION ); + DALI_TEST_EQUALS( std::get< 2 >( bridge_extents ), 10, TEST_LOCATION ); + DALI_TEST_EQUALS( std::get< 3 >( bridge_extents ), 10, TEST_LOCATION ); + + extents = a_component->GetExtents( Dali::Accessibility::CoordinateType::WINDOW ); + DALI_TEST_EQUALS( extents.x, 5.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.y, 5.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.height, 10.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.width, 10.0f, TEST_LOCATION ); + + bridge_extents = TestGetExtents( a_component -> GetAddress(), Dali::Accessibility::CoordinateType::WINDOW ); DALI_TEST_EQUALS( std::get< 0 >( bridge_extents ), 5, TEST_LOCATION ); DALI_TEST_EQUALS( std::get< 1 >( bridge_extents ), 5, TEST_LOCATION ); DALI_TEST_EQUALS( std::get< 2 >( bridge_extents ), 10, TEST_LOCATION ); @@ -712,13 +748,103 @@ int UtcDaliAccessibilityGetExtents(void) application.SendNotification(); application.Render( 1 ); - extents = a_component->GetExtents(Dali::Accessibility::CoordType::SCREEN); + extents = a_component->GetExtents( Dali::Accessibility::CoordinateType::SCREEN ); + DALI_TEST_EQUALS( extents.x, 10.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.y, 10.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.height, 10.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.width, 10.0f, TEST_LOCATION ); + + bridge_extents = TestGetExtents( a_component -> GetAddress(), Dali::Accessibility::CoordinateType::SCREEN ); + DALI_TEST_EQUALS( std::get< 0 >( bridge_extents ), 10, TEST_LOCATION ); + DALI_TEST_EQUALS( std::get< 1 >( bridge_extents ), 10, TEST_LOCATION ); + DALI_TEST_EQUALS( std::get< 2 >( bridge_extents ), 10, TEST_LOCATION ); + DALI_TEST_EQUALS( std::get< 3 >( bridge_extents ), 10, TEST_LOCATION ); + + extents = a_component->GetExtents( Dali::Accessibility::CoordinateType::WINDOW ); DALI_TEST_EQUALS( extents.x, 10.0f, TEST_LOCATION ); DALI_TEST_EQUALS( extents.y, 10.0f, TEST_LOCATION ); DALI_TEST_EQUALS( extents.height, 10.0f, TEST_LOCATION ); DALI_TEST_EQUALS( extents.width, 10.0f, TEST_LOCATION ); - bridge_extents = TestGetExtents( a_component -> GetAddress() ); + bridge_extents = TestGetExtents( a_component -> GetAddress(), Dali::Accessibility::CoordinateType::WINDOW ); + DALI_TEST_EQUALS( std::get< 0 >( bridge_extents ), 10, TEST_LOCATION ); + DALI_TEST_EQUALS( std::get< 1 >( bridge_extents ), 10, TEST_LOCATION ); + DALI_TEST_EQUALS( std::get< 2 >( bridge_extents ), 10, TEST_LOCATION ); + DALI_TEST_EQUALS( std::get< 3 >( bridge_extents ), 10, TEST_LOCATION ); + + Dali::Accessibility::TestEnableSC( false ); + + END_TEST; +} + +int UtcDaliAccessibilityGetExtentsScreenAndWindowPositionDoNotMatch(void) +{ + ToolkitTestApplication application; + + Dali::Accessibility::TestEnableSC( true ); + + auto control = Control::New(); + Stage::GetCurrent().GetRootLayer().Add( control ); + auto window = Dali::DevelWindow::Get( control ); + //window.SetPosition({33,33}); + DevelWindow::SetPositionSize( window, PositionSize( 33,33,480, 240 ) ); + + control.SetProperty( Actor::Property::POSITION, Vector3( 10, 10, 100 ) ); + control.SetProperty( Actor::Property::SIZE, Vector2( 10, 10 ) ); + + application.SendNotification(); + application.Render( 1 ); + + auto a = Dali::Accessibility::Accessible::Get( control ); + auto a_component = dynamic_cast( a ); + + auto extents = a_component->GetExtents( Dali::Accessibility::CoordinateType::SCREEN ); + DALI_TEST_EQUALS( extents.x, 38.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.y, 38.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.height, 10.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.width, 10.0f, TEST_LOCATION ); + + auto bridge_extents = TestGetExtents( a_component -> GetAddress(), Dali::Accessibility::CoordinateType::SCREEN ); + DALI_TEST_EQUALS( std::get< 0 >( bridge_extents ), 38, TEST_LOCATION ); + DALI_TEST_EQUALS( std::get< 1 >( bridge_extents ), 38, TEST_LOCATION ); + DALI_TEST_EQUALS( std::get< 2 >( bridge_extents ), 10, TEST_LOCATION ); + DALI_TEST_EQUALS( std::get< 3 >( bridge_extents ), 10, TEST_LOCATION ); + + extents = a_component->GetExtents( Dali::Accessibility::CoordinateType::WINDOW ); + DALI_TEST_EQUALS( extents.x, 5.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.y, 5.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.height, 10.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.width, 10.0f, TEST_LOCATION ); + + bridge_extents = TestGetExtents( a_component -> GetAddress(), Dali::Accessibility::CoordinateType::WINDOW ); + DALI_TEST_EQUALS( std::get< 0 >( bridge_extents ), 5, TEST_LOCATION ); + DALI_TEST_EQUALS( std::get< 1 >( bridge_extents ), 5, TEST_LOCATION ); + DALI_TEST_EQUALS( std::get< 2 >( bridge_extents ), 10, TEST_LOCATION ); + DALI_TEST_EQUALS( std::get< 3 >( bridge_extents ), 10, TEST_LOCATION ); + + control.SetProperty( Dali::DevelActor::Property::POSITION_USES_ANCHOR_POINT, false ); + application.SendNotification(); + application.Render( 1 ); + + extents = a_component->GetExtents( Dali::Accessibility::CoordinateType::SCREEN ); + DALI_TEST_EQUALS( extents.x, 43.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.y, 43.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.height, 10.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.width, 10.0f, TEST_LOCATION ); + + bridge_extents = TestGetExtents( a_component -> GetAddress(), Dali::Accessibility::CoordinateType::SCREEN ); + DALI_TEST_EQUALS( std::get< 0 >( bridge_extents ), 43, TEST_LOCATION ); + DALI_TEST_EQUALS( std::get< 1 >( bridge_extents ), 43, TEST_LOCATION ); + DALI_TEST_EQUALS( std::get< 2 >( bridge_extents ), 10, TEST_LOCATION ); + DALI_TEST_EQUALS( std::get< 3 >( bridge_extents ), 10, TEST_LOCATION ); + + extents = a_component->GetExtents( Dali::Accessibility::CoordinateType::WINDOW ); + DALI_TEST_EQUALS( extents.x, 10.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.y, 10.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.height, 10.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.width, 10.0f, TEST_LOCATION ); + + bridge_extents = TestGetExtents( a_component -> GetAddress(), Dali::Accessibility::CoordinateType::WINDOW ); DALI_TEST_EQUALS( std::get< 0 >( bridge_extents ), 10, TEST_LOCATION ); DALI_TEST_EQUALS( std::get< 1 >( bridge_extents ), 10, TEST_LOCATION ); DALI_TEST_EQUALS( std::get< 2 >( bridge_extents ), 10, TEST_LOCATION ); @@ -921,3 +1047,230 @@ int UtcDaliAccessibilitySignals(void) END_TEST; } + +static void Wait(ToolkitTestApplication& application) +{ + application.SendNotification(); + application.Render(16); +} + +int UtcDaliAccessibilityScrollToChildScrollView(void) +{ + ToolkitTestApplication application; + Dali::Accessibility::TestEnableSC( true ); + + ScrollView scrollView = ScrollView::New(); + application.GetScene().Add( scrollView ); + + PushButton actorA = PushButton::New(); + const Dali::Vector3 positionA = Vector3(100.0f, 400.0f, 0.0f); + actorA.SetProperty( Dali::Actor::Property::POSITION, positionA ); + scrollView.Add(actorA); + + PushButton actorB = PushButton::New(); + const Dali::Vector3 positionB = Vector3(500.0f, 200.0f, 0.0f); + actorB.SetProperty( Dali::Actor::Property::POSITION, positionB ); + scrollView.Add(actorB); + + Wait(application); + + auto* accessibleParent = dynamic_cast(Dali::Accessibility::Accessible::Get(scrollView)); + DALI_TEST_CHECK(accessibleParent); + auto* accessibleA = dynamic_cast(Dali::Accessibility::Accessible::Get(actorA)); + DALI_TEST_CHECK(accessibleA); + auto* accessibleB = dynamic_cast(Dali::Accessibility::Accessible::Get(actorB)); + DALI_TEST_CHECK(accessibleB); + + accessibleA->GrabHighlight(); // == scrollView.ScrollTo(actorA) + Wait(application); + accessibleB->GrabHighlight(); // == scrollView.ScrollTo(actorB) + Wait(application); + + Dali::Accessibility::TestEnableSC( false ); + END_TEST; +} + +namespace { + class TestItemFactory : public ItemFactory + { + public: + TestItemFactory() + { + } + + unsigned int GetNumberOfItems() override + { + return 2; + } + + Dali::Actor NewItem(unsigned int itemId) override + { + return TextLabel::New(std::to_string(itemId)); + } + }; +} + +int UtcDaliAccessibilityScrollToChildItemView(void) +{ + ToolkitTestApplication application; + Dali::Accessibility::TestEnableSC( true ); + + TestItemFactory factory; + ItemView view = ItemView::New(factory); + Dali::Vector3 vec(480.0f, 800.0f, 0.0f); + ItemLayoutPtr layout = DefaultItemLayout::New( DefaultItemLayout::DEPTH ); + + view.AddLayout(*layout); + view.SetProperty( Actor::Property::SIZE, vec ); + + application.GetScene().Add(view); + layout->SetOrientation(ControlOrientation::Down); + view.ActivateLayout(0, vec, 0.0f); + + Wait(application); + + auto* accessibleParent = dynamic_cast(Dali::Accessibility::Accessible::Get(view)); + DALI_TEST_CHECK(accessibleParent); + auto* accessibleA = dynamic_cast(Dali::Accessibility::Accessible::Get(view.GetItem(0))); + DALI_TEST_CHECK(accessibleA); + auto* accessibleB = dynamic_cast(Dali::Accessibility::Accessible::Get(view.GetItem(1))); + DALI_TEST_CHECK(accessibleB); + + accessibleA->GrabHighlight(); // == view.ScrollToItem(view.GetItemId(actorA)) + Wait(application); + accessibleB->GrabHighlight(); // == view.ScrollToItem(view.GetItemId(actorB)) + Wait(application); + + Dali::Accessibility::TestEnableSC( false ); + END_TEST; +} + +int UtcDaliAccessibilityScrollToChildNonScrollable(void) +{ + ToolkitTestApplication application; + Dali::Accessibility::TestEnableSC( true ); + + TextLabel label = TextLabel::New("123"); + + auto* accessible = dynamic_cast(Dali::Accessibility::Accessible::Get(label)); + DALI_TEST_CHECK(accessible); + + DALI_TEST_EQUALS(accessible->IsScrollable(), false, TEST_LOCATION); + DALI_TEST_EQUALS(accessible->ScrollToChild({}), false, TEST_LOCATION); + DALI_TEST_EQUALS(accessible->GetInternalActor(), Dali::Actor{}, TEST_LOCATION); + + Dali::Accessibility::TestEnableSC( false ); + END_TEST; +} + +int UtcDaliAccessibilityCheckHighlight(void) +{ + ToolkitTestApplication application; + Dali::Accessibility::TestEnableSC( true ); + Dali::Accessibility::TestResetMoveOutedCalled(); + + // Make precondition two children exist in parent area + PushButton parentButton = PushButton::New(); + parentButton.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX); + parentButton.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + parentButton.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + parentButton.SetProperty(Actor::Property::POSITION, Dali::Vector2(0.0f, 0.0f)); + parentButton.SetProperty(Actor::Property::SIZE, Dali::Vector2(100.0f, 200.0f)); + application.GetScene().Add( parentButton ); + + PushButton buttonA = PushButton::New(); + buttonA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + buttonA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + buttonA.SetProperty(Actor::Property::POSITION, Dali::Vector2(0.0f, 0.0f)); + buttonA.SetProperty(Actor::Property::SIZE, Dali::Vector2(100.0f, 100.0f)); + parentButton.Add(buttonA); + + PushButton buttonB = PushButton::New(); + buttonB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + buttonB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + buttonB.SetProperty(Actor::Property::POSITION, Dali::Vector2(0.0f, 100.0f)); + buttonB.SetProperty(Actor::Property::SIZE, Dali::Vector2(100.0f, 100.0f)); + parentButton.Add(buttonB); + Wait(application); + + // Set highlight to first child (A) to enable movement tracking + auto* accessible = dynamic_cast(Dali::Accessibility::Accessible::Get(buttonA)); + DALI_TEST_CHECK(accessible); + accessible->GrabHighlight(); + Wait(application); + + // Move first child (A) out of parent area through the parent's area top edge - single move outed event expected for A object and OUTGOING_TOP_LEFT direction + buttonA.SetProperty(Actor::Property::POSITION, Dali::Vector2(0.0f, -200.0f)); + Wait(application); + // Need one more notificaiton to get correct updated position + application.SendNotification(); + DALI_TEST_EQUALS( true, Dali::Accessibility::TestGetMoveOutedCalled(), TEST_LOCATION ); + + // Reset verdict data + Dali::Accessibility::TestResetMoveOutedCalled(); + + // Move first child (A) outside of parent area (both start and end position are outside of parent area) - no move outed event expected for A object + buttonA.SetProperty( Dali::Actor::Property::POSITION, Dali::Vector2(0.0f, -300.0f) ); + Wait(application); + // Need one more notificaiton to get correct updated position + application.SendNotification(); + DALI_TEST_EQUALS( false, Dali::Accessibility::TestGetMoveOutedCalled(), TEST_LOCATION ); + + // Reset verdict data + Dali::Accessibility::TestResetMoveOutedCalled(); + + // Set highlight to second child (B) to enable movement tracking + accessible = dynamic_cast(Dali::Accessibility::Accessible::Get(buttonB)); + DALI_TEST_CHECK(accessible); + accessible->GrabHighlight(); + Wait(application); + + // Move second child (B) inside of parent area (both start and end position are inside of parent area) - no move outed event expected for B object + // B: (0,100) --> (0, 50) + buttonB.SetProperty( Dali::Actor::Property::POSITION, Dali::Vector2(0.0f, 50.0f) ); + Wait(application); + // Need one more notificaiton to get correct updated position + application.SendNotification(); + DALI_TEST_EQUALS( false, Dali::Accessibility::TestGetMoveOutedCalled(), TEST_LOCATION ); + + // Reset verdict data + Dali::Accessibility::TestResetMoveOutedCalled(); + + // Move second child (B) out of parent area through the parent's area right edge - single move outed event expected for B object and OUTGOING_BOTTOM_RIGHT direction + buttonB.SetProperty(Actor::Property::POSITION, Dali::Vector2(300.0f, 100.0f)); + Wait(application); + // Need one more notificaiton to get correct updated position + application.SendNotification(); + DALI_TEST_EQUALS( true, Dali::Accessibility::TestGetMoveOutedCalled(), TEST_LOCATION ); + + // Reset verdict data + Dali::Accessibility::TestResetMoveOutedCalled(); + + // Move second child (B) back into parent area (start position is outside but end position is inside of parent area) - no move outed event expected for B object + // B: (300,100) --> (0, 100) + buttonB.SetProperty( Dali::Actor::Property::POSITION, Dali::Vector2(0.0f, 100.0f) ); + Wait(application); + // Need one more seding notificaiton to get correct updated position + application.SendNotification(); + DALI_TEST_EQUALS( false, Dali::Accessibility::TestGetMoveOutedCalled(), TEST_LOCATION ); + + // Reset verdict data + Dali::Accessibility::TestResetMoveOutedCalled(); + + // Disable movement tracking on B by giving highlight to A + accessible = dynamic_cast(Dali::Accessibility::Accessible::Get(buttonA)); + DALI_TEST_CHECK(accessible); + accessible->GrabHighlight(); + Wait(application); + + // Move B (untracked) out of parent area through the parent's area right edge - no move outed event expected for B object + // B: (0,100) --> (300, 100) + buttonB.SetProperty( Dali::Actor::Property::POSITION, Dali::Vector2(300.0f, 100.0f) ); + Wait(application); + // Need one more seding notificaiton to get correct updated position + application.SendNotification(); + DALI_TEST_EQUALS( false, Dali::Accessibility::TestGetMoveOutedCalled(), TEST_LOCATION ); + + Dali::Accessibility::TestEnableSC( false ); + END_TEST; +}