From: dongsug.song Date: Tue, 17 Sep 2019 09:57:40 +0000 (+0900) Subject: [Tizen](ATSPI) squashed implementation X-Git-Tag: submit/tizen/20190917.102651^0 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=26efc210fc636e51a4d3df9ae7fbcc1d2a8bac40 [Tizen](ATSPI) squashed implementation Author: Radoslaw Cybulski Change-Id: I8e47e53b70cabe41d340600a11a926fb847616ac --- diff --git a/automated-tests/src/dali-toolkit-accessibility/dali-toolkit-accessibility-test-utils.cpp b/automated-tests/src/dali-toolkit-accessibility/dali-toolkit-accessibility-test-utils.cpp new file mode 100644 index 0000000..ea23826 --- /dev/null +++ b/automated-tests/src/dali-toolkit-accessibility/dali-toolkit-accessibility-test-utils.cpp @@ -0,0 +1,285 @@ +#include +#include + +namespace Dali { + namespace Accessibility { + + using MethodType = TestDBusWrapper::MethodType; + using MessagePtr = DBusWrapper::MessagePtr; + + void TestEnableSC(bool b) { + static bool firstTime = true; + if (b && firstTime) { + firstTime = false; + auto bridge = Accessibility::Bridge::GetCurrentBridge(); + Dali::Stage stage = Dali::Stage::GetCurrent(); + auto accessible = Accessibility::Accessible::Get( stage.GetRootLayer() ); + bridge->SetApplicationChild( accessible ); + bridge->SetApplicationName( "TestApp" ); + bridge->Initialize(); + + static bool ScreenReaderEnabled = false; + static bool IsEnabled = false; + + auto wr = static_cast(DBusWrapper::Installed()); + + wr->testMethods[std::tuple{"/org/a11y/bus", "org.a11y.Status", "ScreenReaderEnabled", MethodType::Getter}] = [wr](const MessagePtr &m) -> MessagePtr { + auto reply = wr->newReplyMessage(m); + wr->Encode(reply, std::tuple>{ ScreenReaderEnabled }); + return reply; + }; + wr->testMethods[std::tuple{"/org/a11y/bus", "org.a11y.Status", "IsEnabled", MethodType::Getter}] = [wr](const MessagePtr &m) -> MessagePtr { + auto reply = wr->newReplyMessage(m); + wr->Encode(reply, std::tuple>{ IsEnabled }); + return reply; + }; + wr->testMethods[std::tuple{"/org/a11y/bus", "org.a11y.Bus", "GetAddress", MethodType::Method}] = [wr](const MessagePtr &m) -> MessagePtr { + auto reply = wr->newReplyMessage(m); + wr->Encode(reply, std::tuple{ "bus" }); + return reply; + }; + wr->testMethods[std::tuple{"/org/a11y/atspi/accessible/root", "org.a11y.atspi.Socket", "Embed", MethodType::Method}] = [wr](const MessagePtr &m) -> MessagePtr { + auto reply = wr->newReplyMessage(m); + wr->Encode(reply, std::tuple
{ {"bus", "root"} }); + return reply; + }; + wr->testMethods[std::tuple{"/org/a11y/atspi/accessible", "org.a11y.atspi.Event.Object", "PropertyChange", MethodType::Method}] = + [wr](const MessagePtr &m) -> MessagePtr { + return wr->newReplyMessage(m); + }; + wr->testMethods[std::tuple{"/org/a11y/atspi/accessible", "org.a11y.atspi.Event.Object", "StateChanged", MethodType::Method}] = + [wr](const MessagePtr &m) -> MessagePtr { + return wr->newReplyMessage(m); + }; + wr->testMethods[std::tuple{"/org/a11y/atspi/accessible", "org.a11y.atspi.Event.Object", "BoundsChanged", MethodType::Method}] = + [wr](const MessagePtr &m) -> MessagePtr { + return wr->newReplyMessage(m); + }; + wr->testMethods[std::tuple{"/org/a11y/atspi/accessible", "org.a11y.atspi.Event.Object", "ActiveDescendantChanged", MethodType::Method}] = + [wr](const MessagePtr &m) -> MessagePtr { + return wr->newReplyMessage(m); + }; + wr->testMethods[std::tuple{"/org/a11y/atspi/accessible", "org.a11y.atspi.Event.Object", "TextChanged", MethodType::Method}] = + [wr](const MessagePtr &m) -> MessagePtr { + return wr->newReplyMessage(m); + }; + wr->testMethods[std::tuple{"/org/a11y/atspi/accessible", "org.a11y.atspi.Event.Object", "TextCaretMoved", MethodType::Method}] = + [wr](const MessagePtr &m) -> MessagePtr { + return wr->newReplyMessage(m); + }; + } + auto wr = static_cast(DBusWrapper::Installed()); + wr->fromTestChangeProperty("/org/a11y/bus", "org.a11y.Status", "ScreenReaderEnabled", b); + } + + std::vector
TestGetChildren(const Address &adr) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall>(adr.GetPath(), "org.a11y.atspi.Accessible", "GetChildren", std::tuple<>()); + return std::move(std::get<0>(chs)); + } + + std::string TestGetName(const Address &adr) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto name = wr->fromTestGet(adr.GetPath(), "org.a11y.atspi.Accessible", "Name"); + return name; + } + + std::string TestGetDescription(const Address &adr) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto description = wr->fromTestGet(adr.GetPath(), "org.a11y.atspi.Accessible", "Description"); + return description; + } + + uint32_t TestGetRole(const Address &adr) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall(adr.GetPath(), "org.a11y.atspi.Accessible", "GetRole", std::tuple<>()); + return std::move(std::get<0>(chs)); + } + + std::string TestGetRoleName(const Address &adr) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall(adr.GetPath(), "org.a11y.atspi.Accessible", "GetRoleName", std::tuple<>()); + return std::move(std::get<0>(chs)); + } + + Address TestGetParent(const Address &adr) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestGet< Address >(adr.GetPath(), "org.a11y.atspi.Accessible", "Parent"); + return chs; + } + + std::string TestGetLocalizedRoleName(const Address &adr) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall(adr.GetPath(), "org.a11y.atspi.Accessible", "GetLocalizedRoleName", std::tuple<>()); + return std::move(std::get<0>(chs)); + } + + std::array< uint32_t, 2 > TestGetStates(const Address &adr) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall>(adr.GetPath(), "org.a11y.atspi.Accessible", "GetState", std::tuple<>()); + return std::move(std::get<0>(chs)); + } + + std::unordered_map< std::string, std::string > TestGetAttributes(const Address &adr) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall>(adr.GetPath(), "org.a11y.atspi.Accessible", "GetAttributes", std::tuple<>()); + return std::move(std::get<0>(chs)); + } + + bool TestDoGesture(const Address &adr, Dali::Accessibility::Gesture type, int32_t xBeg, int32_t xEnd, int32_t yBeg, int32_t yEnd, Dali::Accessibility::GestureState state, uint32_t eventTime) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall< bool >(adr.GetPath(), "org.a11y.atspi.Accessible", "DoGesture", + std::tuple< Dali::Accessibility::Gesture, int32_t, int32_t, int32_t, int32_t, Dali::Accessibility::GestureState, uint32_t >(type, xBeg, xEnd, yBeg, yEnd, state, eventTime )); + return std::move(std::get<0>(chs)); + } + + std::vector< std::tuple< uint32_t, std::vector< Dali::Accessibility::Address > > > TestGetRelationSet(const Address &adr) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall< std::vector< std::tuple< uint32_t, std::vector< Dali::Accessibility::Address > > > >(adr.GetPath(), "org.a11y.atspi.Accessible", "GetRelationSet", std::tuple<>()); + return std::move(std::get<0>(chs)); + } + + Address TestGetChildAtIndex(const Address &adr, int index) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall< Address >(adr.GetPath(), "org.a11y.atspi.Accessible", "GetChildAtIndex", std::tuple< int >( index )); + return std::move(std::get<0>(chs)); + } + + ComponentLayer TestGetLayer(const Address &adr) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall< Dali::Accessibility::ComponentLayer >(adr.GetPath(), "org.a11y.atspi.Component", "GetLayer", std::tuple<>()); + return std::move(std::get<0>(chs)); + } + + int TestGetIndexInParent(const Address &adr) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall< int >(adr.GetPath(), "org.a11y.atspi.Accessible", "GetIndexInParent", std::tuple<>()); + return std::move(std::get<0>(chs)); + } + + bool TestGrabFocus(const Address &adr) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall< bool >(adr.GetPath(), "org.a11y.atspi.Component", "GrabFocus", std::tuple<>()); + return std::move(std::get<0>(chs)); + } + + bool TestGrabHighlight(const Address &adr) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall< bool >(adr.GetPath(), "org.a11y.atspi.Component", "GrabHighlight", std::tuple<>()); + return std::move(std::get<0>(chs)); + } + + bool TestClearHighlight(const Address &adr) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall< bool >(adr.GetPath(), "org.a11y.atspi.Component", "ClearHighlight", std::tuple<>()); + return std::move(std::get<0>(chs)); + } + + std::tuple< int32_t, int32_t, int32_t, int32_t > TestGetExtents(const Address &adr) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall< std::tuple< int32_t, int32_t, int32_t, int32_t > >(adr.GetPath(), "org.a11y.atspi.Component", "GetExtents", std::tuple(0)); + return std::move(std::get<0>(chs)); + } + + int TestGetMdiZOrder(const Address &adr) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall< int16_t >(adr.GetPath(), "org.a11y.atspi.Component", "GetMDIZOrder", std::tuple<>()); + return std::move(std::get<0>(chs)); + } + + double TestGetAlpha(const Address &adr) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall< double >(adr.GetPath(), "org.a11y.atspi.Component", "GetAlpha", std::tuple<>()); + return std::move(std::get<0>(chs)); + } + + std::string TestGetActionName( const Address &adr, size_t index ) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall< std::string >(adr.GetPath(), "org.a11y.atspi.Action", "GetName", std::tuple< int32_t >( index )); + return std::move(std::get<0>(chs)); + } + + std::string TestGetLocalizedActionName( const Address &adr, size_t index ) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall< std::string >(adr.GetPath(), "org.a11y.atspi.Action", "GetLocalizedName", std::tuple< int32_t >( index )); + return std::move(std::get<0>(chs)); + } + + size_t TestGetActionCount( const Address &adr ) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto count = wr->fromTestGet< int32_t >(adr.GetPath(), "org.a11y.atspi.Action", "NActions"); + return count; + } + + bool TestDoAction ( const Address &adr, size_t index ) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall< bool >(adr.GetPath(), "org.a11y.atspi.Action", "DoAction", std::tuple< int32_t >( index )); + return std::move(std::get<0>(chs)); + } + + bool TestDoAction ( const Address &adr, const std::string& name ) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall< bool >(adr.GetPath(), "org.a11y.atspi.Action", "DoActionName", std::tuple< std::string >( name )); + return std::move(std::get<0>(chs)); + } + + std::string TestGetActionKeyBinding ( const Address &adr, size_t index ) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall< std::string >(adr.GetPath(), "org.a11y.atspi.Action", "GetKeyBinding", std::tuple< int32_t >( index )); + return std::move(std::get<0>(chs)); + } + + std::string TestGetActionDescription ( const Address &adr, size_t index ) + { + auto wr = static_cast(DBusWrapper::Installed()); + auto chs = wr->fromTestCall< std::string >(adr.GetPath(), "org.a11y.atspi.Action", "GetDescription", std::tuple< int32_t >( index )); + return std::move(std::get<0>(chs)); + } + + + void printTree(const Address &root, size_t depth) + { + auto name = TestGetName(root); + printf("%10s", root.GetPath().c_str()); + for(unsigned int i = 0; i < depth; ++i) printf(" "); + printf("%s\n", name.c_str()); + auto chs = TestGetChildren(root); + for(auto &c : chs) + printTree(c, depth + 1); + } + + bool Find( const std::vector< std::string > &collection, const std::string &key) + { + for ( auto& it : collection) + if( it == key ) + return true; + return false; + } + } +} \ No newline at end of file diff --git a/automated-tests/src/dali-toolkit-accessibility/dali-toolkit-accessibility-test-utils.h b/automated-tests/src/dali-toolkit-accessibility/dali-toolkit-accessibility-test-utils.h new file mode 100644 index 0000000..25adccd --- /dev/null +++ b/automated-tests/src/dali-toolkit-accessibility/dali-toolkit-accessibility-test-utils.h @@ -0,0 +1,43 @@ +#ifndef __DALI_TOOLKIT_ACCESSIBILITY_TEST_UTILS__ +#define __DALI_TOOLKIT_ACCESSIBILITY_TEST_UTILS__ + +#include + + +namespace Dali { + namespace Accessibility { + void TestEnableSC(bool b); + std::vector
TestGetChildren(const Address &adr); + std::string TestGetName(const Address &adr); + std::string TestGetDescription(const Address &adr); + uint32_t TestGetRole(const Address &adr); + std::string TestGetRoleName(const Address &adr); + Address TestGetParent(const Address &adr); + std::string TestGetLocalizedRoleName(const Address &adr); + std::array< uint32_t, 2 > TestGetStates(const Address &adr); + std::unordered_map< std::string, std::string > TestGetAttributes(const Address &adr); + bool TestDoGesture(const Address &adr, Dali::Accessibility::Gesture type, int32_t xBeg, int32_t xEnd, int32_t yBeg, int32_t yEnd, Dali::Accessibility::GestureState state, uint32_t eventTime); + std::vector< std::tuple< uint32_t, std::vector< Dali::Accessibility::Address > > > TestGetRelationSet(const Address &adr); + Address TestGetChildAtIndex(const Address &adr, int index); + ComponentLayer TestGetLayer(const Address &adr); + int TestGetIndexInParent(const Address &adr); + bool TestGrabFocus(const Address &adr); + bool TestGrabHighlight(const Address &adr); + bool TestClearHighlight(const Address &adr); + std::tuple< int32_t, int32_t, int32_t, int32_t > TestGetExtents(const Address &adr); + int TestGetMdiZOrder(const Address &adr); + double TestGetAlpha(const Address &adr); + void printTree(const Address &root, size_t depth = 0); + bool Find( const std::vector< std::string > &collection, const std::string &key); + std::string TestGetActionName( const Address &adr, size_t index ); + std::string TestGetLocalizedActionName( const Address &adr, size_t index ); + size_t TestGetActionCount( const Address &adr ); + bool TestDoAction ( const Address &adr, size_t index ); + bool TestDoAction ( const Address &adr, const std::string& name ); + std::string TestGetActionKeyBinding ( const Address &adr, size_t index ); + std::string TestGetActionDescription ( const Address &adr, size_t index ); + + } +} + +#endif //__DALI_TOOLKIT_ACCESSIBILITY_TEST_UTILS__ \ No newline at end of file diff --git a/automated-tests/src/dali-toolkit-accessibility/tct-dali-toolkit-accessibility-core.cpp b/automated-tests/src/dali-toolkit-accessibility/tct-dali-toolkit-accessibility-core.cpp new file mode 100644 index 0000000..77c02c6 --- /dev/null +++ b/automated-tests/src/dali-toolkit-accessibility/tct-dali-toolkit-accessibility-core.cpp @@ -0,0 +1,51 @@ +#include +#include +#include +#include +#include "tct-dali-toolkit-accessibility-core.h" + +int main(int argc, char * const argv[]) +{ + int result = TestHarness::EXIT_STATUS_BAD_ARGUMENT; + + const char* optString = "sf"; + bool optRerunFailed(true); + bool optRunSerially(false); + + int nextOpt = 0; + do + { + nextOpt = getopt( argc, argv, optString ); + switch(nextOpt) + { + case 'f': + optRerunFailed = false; + break; + case 's': + optRunSerially = true; + break; + case '?': + TestHarness::Usage(argv[0]); + exit(TestHarness::EXIT_STATUS_BAD_ARGUMENT); + break; + } + } while( nextOpt != -1 ); + + if( optind == argc ) // no testcase name in argument list + { + if( optRunSerially ) + { + result = TestHarness::RunAll( argv[0], tc_array ); + } + else + { + result = TestHarness::RunAllInParallel( argv[0], tc_array, optRerunFailed ); + } + } + else + { + // optind is index of next argument - interpret as testcase name + result = TestHarness::FindAndRunTestCase(tc_array, argv[optind]); + } + return result; +} diff --git a/automated-tests/src/dali-toolkit-accessibility/utc-Dali-Accessibility-Accessible.cpp b/automated-tests/src/dali-toolkit-accessibility/utc-Dali-Accessibility-Accessible.cpp new file mode 100644 index 0000000..55f39ec --- /dev/null +++ b/automated-tests/src/dali-toolkit-accessibility/utc-Dali-Accessibility-Accessible.cpp @@ -0,0 +1,61 @@ +/** + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// Need to override adaptor classes for toolkit test harness, so include +// test harness headers before dali headers. +#include + +#include +#include + +#include + +void utc_dali_toolkit_accessibility_accessible_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_toolkit_accessibility_accessible_cleanup(void) +{ + test_return_value = TET_PASS; +} + +int utcDaliAccessibilityCheckBoxButtonGetStates(void) +{ + ToolkitTestApplication application; + + auto check_box_button = Toolkit::CheckBoxButton::New(); + auto q = Dali::Accessibility::Accessible::Get( check_box_button ); + DALI_TEST_CHECK( q ); + auto states = q->GetStates(); + DALI_TEST_EQUALS( (int) states[ Dali::Accessibility::State::SELECTABLE ], (int) true, TEST_LOCATION ); + + END_TEST; +} + +int utcDaliAccessibilityCheckLabelText(void) +{ + ToolkitTestApplication application; + + auto check_box_button = Toolkit::CheckBoxButton::New(); + check_box_button.SetLabelText( "button" ); + auto q = Dali::Accessibility::Accessible::Get( check_box_button ); + DALI_TEST_CHECK( q ); + DALI_TEST_EQUALS( q->GetName(), "button", TEST_LOCATION ); + + END_TEST; +} \ No newline at end of file diff --git a/automated-tests/src/dali-toolkit-accessibility/utc-Dali-Accessibility-Controls-BridgeUp.cpp b/automated-tests/src/dali-toolkit-accessibility/utc-Dali-Accessibility-Controls-BridgeUp.cpp new file mode 100644 index 0000000..dbeb2b8 --- /dev/null +++ b/automated-tests/src/dali-toolkit-accessibility/utc-Dali-Accessibility-Controls-BridgeUp.cpp @@ -0,0 +1,843 @@ +#include +#include +#include +#include +#include +#include +#include + +using namespace Dali::Toolkit; + +using DBusWrapper = Dali::Accessibility::DBusWrapper; + +void utc_dali_accessibility_controls_bridge_up_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_accessibility_controls_bridge_up_cleanup(void) +{ + test_return_value = TET_PASS; + //DBusWrapper::Install({}) is a de-install + DBusWrapper::Install({}); +} + +namespace Dali { + namespace Accessibility { + std::ostream & operator<< (std::ostream & stream, const Address & address) + { + stream << address.ToString(); + return stream; + } + } +} + +int UtcDaliControlAccessibilityRaiseBridge(void) +{ + ToolkitTestApplication application; + + DALI_TEST_CHECK(!Accessibility::IsUp()); + + Dali::Accessibility::TestEnableSC(true); + + DALI_TEST_CHECK(Accessibility::IsUp()); + + // auto wr = static_cast(DBusWrapper::Installed()); + // for(auto &a : wr->daliMethods) { + // const char *mt; + // if (std::get<3>(a.first) == MethodType::Method) mt = "MethodType::Method"; + // else if (std::get<3>(a.first) == MethodType::Getter) mt = "MethodType::Getter"; + // else if (std::get<3>(a.first) == MethodType::Setter) mt = "MethodType::Setter"; + // else assert(0); + // printf("%s %s %s %s\n", std::get<0>(a.first).c_str(), std::get<1>(a.first).c_str(), std::get<2>(a.first).c_str(), mt); + // } + + Dali::Accessibility::TestEnableSC(false); + + DALI_TEST_CHECK(!Accessibility::IsUp()); + + END_TEST; +} + +int UtcDaliControlAccessibilityName(void) +{ + ToolkitTestApplication application; + + auto control = Control::New(); + Stage::GetCurrent().Add( control ); + + auto q = Dali::Accessibility::Accessible::Get( control ); + DALI_TEST_CHECK( q ); + + DALI_TEST_EQUALS( "" , q->GetName(), TEST_LOCATION ); + + control.SetProperty( DevelControl::Property::ACCESSIBILITY_NAME, "Accessibility_Name" ); + DALI_TEST_EQUALS( "Accessibility_Name" , q->GetName(), TEST_LOCATION ); + DALI_TEST_EQUALS( control.GetProperty( DevelControl::Property::ACCESSIBILITY_NAME ).Get< std::string >() , "Accessibility_Name", TEST_LOCATION ); + + control.AccessibilityGetNameSignal().Connect( [] (std::string &accessibility_name) { + accessibility_name = "Accessibility_Name_With_Callback"; } ); + + DALI_TEST_EQUALS( "Accessibility_Name_With_Callback" , q->GetName(), TEST_LOCATION ); + + Dali::Accessibility::TestEnableSC(true); + + DALI_TEST_EQUALS( "Accessibility_Name_With_Callback" , TestGetName( q->GetAddress()), TEST_LOCATION ); + + Dali::Accessibility::TestEnableSC( false ); + + END_TEST; +} + +int UtcDaliControlAccessibilityDescription(void) +{ + ToolkitTestApplication application; + + auto control = Control::New(); + + auto q = Dali::Accessibility::Accessible::Get( control ); + DALI_TEST_CHECK( q ); + + DALI_TEST_EQUALS( "" , q->GetDescription(), TEST_LOCATION ); + + control.SetProperty( Control::Property::ACCESSIBILITY_DESCRIPTON, "Accessibility_Description" ); + DALI_TEST_EQUALS( "Accessibility_Description" , q->GetDescription(), TEST_LOCATION ); + + auto property = control.GetProperty( Control::Property::ACCESSIBILITY_DESCRIPTON ).Get(); + DALI_TEST_EQUALS( "Accessibility_Description", property, TEST_LOCATION ); + + control.AccessibilityGetDescriptionSignal().Connect( [] (std::string &accessibility_description) { + accessibility_description = "Accessibility_Description_With_Callback"; } ); + + DALI_TEST_EQUALS( "Accessibility_Description_With_Callback" , q->GetDescription(), TEST_LOCATION ); + + Dali::Accessibility::TestEnableSC( true ); + + DALI_TEST_EQUALS( "Accessibility_Description_With_Callback" , TestGetDescription( q->GetAddress()), TEST_LOCATION ); + + Dali::Accessibility::TestEnableSC( false ); + + END_TEST; +} + +int UtcDaliControlAccessibilityRole(void) +{ + ToolkitTestApplication application; + + auto control = Control::New(); + auto role_unknown = Dali::Accessibility::Role::UNKNOWN; + auto role_pushbutton = Dali::Accessibility::Role::PUSH_BUTTON; + + DALI_TEST_EQUALS( role_unknown,control.GetProperty( Control::Property::ACCESSIBILITY_ROLE ).Get< Dali::Accessibility::Role >(), TEST_LOCATION ); + + auto q = Dali::Accessibility::Accessible::Get( control ); + DALI_TEST_EQUALS( role_unknown , q->GetRole(), TEST_LOCATION); + DALI_TEST_EQUALS( "unknown" , q->GetRoleName(), TEST_LOCATION ); + + Dali::Accessibility::TestEnableSC( true ); + DALI_TEST_CHECK( q ); + DALI_TEST_EQUALS( static_cast< uint32_t >( role_unknown ), TestGetRole( q->GetAddress() ), TEST_LOCATION ); + DALI_TEST_EQUALS( "unknown" , TestGetRoleName( q->GetAddress() ), TEST_LOCATION ); + DALI_TEST_EQUALS( "unknown" , TestGetLocalizedRoleName( q->GetAddress() ), TEST_LOCATION ); + + control.SetProperty( Control::Property::ACCESSIBILITY_ROLE, role_pushbutton ); + + DALI_TEST_EQUALS( static_cast< uint32_t >( role_pushbutton ), TestGetRole( q->GetAddress() ), TEST_LOCATION ); + DALI_TEST_EQUALS( "push button" ,TestGetRoleName( q->GetAddress() ), TEST_LOCATION ); + DALI_TEST_EQUALS( "push button" , TestGetLocalizedRoleName( q->GetAddress() ), TEST_LOCATION ); + + Dali::Accessibility::TestEnableSC( false ); + + DALI_TEST_EQUALS( role_pushbutton , q->GetRole(), TEST_LOCATION); + DALI_TEST_EQUALS( "push button" , q->GetRoleName(), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliControlAccessibilityState(void) +{ + ToolkitTestApplication application; + + auto control = Control::New(); + auto q = Dali::Accessibility::Accessible::Get( control ); + + Dali::Accessibility::TestEnableSC( true ); + + auto states_by_bridge = Dali::Accessibility::States { TestGetStates( q->GetAddress() )}; + auto states = control.GetAccessibilityStates(); + DALI_TEST_CHECK( states_by_bridge == states ); + + Dali::Accessibility::TestEnableSC( false ); + + END_TEST; +} + +int UtcDaliControlAccessibilityModal(void) +{ + ToolkitTestApplication application; + auto control = TextSelectionPopup::New( NULL ); + auto states = control.GetAccessibilityStates(); + + DALI_TEST_CHECK( states[ Dali::Accessibility::State::MODAL ] ); + + END_TEST; +} + +int UtcDaliControlAccessibilityHighlightable(void) +{ + ToolkitTestApplication application; + auto control = Control::New(); + + auto noneset = control.GetProperty( Control::Property::ACCESSIBILITY_HIGHLIGHTABLE ); + DALI_TEST_EQUALS( Property::NONE, noneset.GetType(), TEST_LOCATION ); + + auto q = Dali::Accessibility::Accessible::Get( control ); + + Dali::Accessibility::TestEnableSC( true ); + + auto states_by_bridge = Dali::Accessibility::States { TestGetStates( q->GetAddress() )}; + DALI_TEST_CHECK( states_by_bridge[ Dali::Accessibility::State::HIGHLIGHTABLE ] ); + + control.SetProperty( Control::Property::ACCESSIBILITY_HIGHLIGHTABLE, true ); + DALI_TEST_EQUALS( Property::BOOLEAN, control.GetProperty( Control::Property::ACCESSIBILITY_HIGHLIGHTABLE ).GetType(), TEST_LOCATION ); + DALI_TEST_EQUALS( true, control.GetProperty( Control::Property::ACCESSIBILITY_HIGHLIGHTABLE ).Get< bool >(), TEST_LOCATION ); + + states_by_bridge = Dali::Accessibility::States { TestGetStates( q->GetAddress() )}; + DALI_TEST_CHECK( states_by_bridge[ Dali::Accessibility::State::HIGHLIGHTABLE ] ); + + control.SetProperty( Control::Property::ACCESSIBILITY_HIGHLIGHTABLE, false ); + DALI_TEST_EQUALS( Property::BOOLEAN, control.GetProperty( Control::Property::ACCESSIBILITY_HIGHLIGHTABLE ).GetType(), TEST_LOCATION ); + DALI_TEST_EQUALS( false, control.GetProperty( Control::Property::ACCESSIBILITY_HIGHLIGHTABLE ).Get< bool >(), TEST_LOCATION ); + + states_by_bridge = Dali::Accessibility::States { TestGetStates( q->GetAddress() )}; + DALI_TEST_CHECK( !states_by_bridge[ Dali::Accessibility::State::HIGHLIGHTABLE ] ); + + Dali::Accessibility::TestEnableSC( false ); + + END_TEST; +} + +int UtcDaliControlAccessibilityHighlightBridgeUp(void) +{ + ToolkitTestApplication application; + + auto controla = Control::New(); + auto controlb = Control::New(); + + Dali::Accessibility::TestEnableSC( true ); + + auto accessible_a = Dali::Accessibility::Accessible::Get( controla ); + auto accessible_b = Dali::Accessibility::Accessible::Get( controlb ); + + auto a = dynamic_cast( accessible_a ); + auto b = dynamic_cast( accessible_b ); + + auto states_by_bridge_a = Dali::Accessibility::States { TestGetStates( a->GetAddress() )}; + auto states_by_bridge_b = Dali::Accessibility::States { TestGetStates( b->GetAddress() )}; + + DALI_TEST_CHECK( !states_by_bridge_a[ Dali::Accessibility::State::HIGHLIGHTED ] ); + DALI_TEST_CHECK( !states_by_bridge_b[ Dali::Accessibility::State::HIGHLIGHTED ] ); + + DALI_TEST_EQUALS( true, controla.GrabAccessibilityHighlight(), TEST_LOCATION ); + + states_by_bridge_a = Dali::Accessibility::States { TestGetStates( a->GetAddress() )}; + states_by_bridge_b = Dali::Accessibility::States { TestGetStates( b->GetAddress() )}; + + DALI_TEST_CHECK( states_by_bridge_a[ Dali::Accessibility::State::HIGHLIGHTED ] ); + DALI_TEST_CHECK( !states_by_bridge_b[ Dali::Accessibility::State::HIGHLIGHTED ] ); + + DALI_TEST_EQUALS( true, controlb.GrabAccessibilityHighlight(), TEST_LOCATION ); + DALI_TEST_EQUALS( true, controlb.GrabAccessibilityHighlight(), TEST_LOCATION ); + + states_by_bridge_a = Dali::Accessibility::States { TestGetStates( a->GetAddress() )}; + states_by_bridge_b = Dali::Accessibility::States { TestGetStates( b->GetAddress() )}; + + DALI_TEST_CHECK( !states_by_bridge_a[ Dali::Accessibility::State::HIGHLIGHTED ] ); + DALI_TEST_CHECK( states_by_bridge_b[ Dali::Accessibility::State::HIGHLIGHTED ] ); + + DALI_TEST_EQUALS( false, controla.ClearAccessibilityHighlight(), TEST_LOCATION ); + + states_by_bridge_a = Dali::Accessibility::States { TestGetStates( a->GetAddress() )}; + states_by_bridge_b = Dali::Accessibility::States { TestGetStates( b->GetAddress() )}; + + DALI_TEST_CHECK( !states_by_bridge_a[ Dali::Accessibility::State::HIGHLIGHTED ] ); + DALI_TEST_CHECK( states_by_bridge_b[ Dali::Accessibility::State::HIGHLIGHTED ] ); + + DALI_TEST_EQUALS( true, controlb.ClearAccessibilityHighlight(), TEST_LOCATION ); + + states_by_bridge_a = Dali::Accessibility::States { TestGetStates( a->GetAddress() )}; + states_by_bridge_b = Dali::Accessibility::States { TestGetStates( b->GetAddress() )}; + + DALI_TEST_CHECK( !states_by_bridge_a[ Dali::Accessibility::State::HIGHLIGHTED ] ); + DALI_TEST_CHECK( !states_by_bridge_b[ Dali::Accessibility::State::HIGHLIGHTED ] ); + + DALI_TEST_CHECK( TestGrabHighlight( a -> GetAddress() ) ); + + states_by_bridge_a = Dali::Accessibility::States { TestGetStates( a->GetAddress() )}; + states_by_bridge_b = Dali::Accessibility::States { TestGetStates( b->GetAddress() )}; + + DALI_TEST_CHECK( states_by_bridge_a[ Dali::Accessibility::State::HIGHLIGHTED ] ); + DALI_TEST_CHECK( !states_by_bridge_b[ Dali::Accessibility::State::HIGHLIGHTED ] ); + + DALI_TEST_CHECK( TestGrabHighlight( b -> GetAddress() ) ); + + states_by_bridge_a = Dali::Accessibility::States { TestGetStates( a->GetAddress() )}; + states_by_bridge_b = Dali::Accessibility::States { TestGetStates( b->GetAddress() )}; + + DALI_TEST_CHECK( !states_by_bridge_a[ Dali::Accessibility::State::HIGHLIGHTED ] ); + DALI_TEST_CHECK( states_by_bridge_b[ Dali::Accessibility::State::HIGHLIGHTED ] ); + + DALI_TEST_CHECK( TestClearHighlight( b -> GetAddress() ) ); + + states_by_bridge_a = Dali::Accessibility::States { TestGetStates( a->GetAddress() )}; + states_by_bridge_b = Dali::Accessibility::States { TestGetStates( b->GetAddress() )}; + + DALI_TEST_CHECK( !states_by_bridge_a[ Dali::Accessibility::State::HIGHLIGHTED ] ); + DALI_TEST_CHECK( !states_by_bridge_b[ Dali::Accessibility::State::HIGHLIGHTED ] ); + + + Dali::Accessibility::TestEnableSC( false ); + + END_TEST; +} + +int utcDaliAccessibilityControlAttributes(void) +{ + ToolkitTestApplication application; + auto check_box_button = Toolkit::Control::New(); + + std::string value; + + + auto attributes = check_box_button.GetProperty( Toolkit::Control::Property::ACCESSIBILITY_ATTRIBUTES ); + auto attributes_map = attributes.GetMap(); + + auto position = attributes_map->Find( "access_key1" ); + DALI_TEST_CHECK( !position ); + + check_box_button.AppendAccessibilityAttribute( "access_key1", "access_value1" ); + attributes = check_box_button.GetProperty( Toolkit::Control::Property::ACCESSIBILITY_ATTRIBUTES ); + attributes_map = attributes.GetMap(); + + DALI_TEST_EQUALS( (attributes_map->Find( "access_key1" ))->Get(), "access_value1", TEST_LOCATION ); + + check_box_button.AppendAccessibilityAttribute( "access_key2", "access_value2_a" ); + attributes = check_box_button.GetProperty( Toolkit::Control::Property::ACCESSIBILITY_ATTRIBUTES ); + attributes_map = attributes.GetMap(); + + DALI_TEST_EQUALS( (attributes_map->Find( "access_key1" ))->Get(), "access_value1", TEST_LOCATION ); + DALI_TEST_EQUALS( (attributes_map->Find( "access_key2" ))->Get(), "access_value2_a", TEST_LOCATION ); + + check_box_button.AppendAccessibilityAttribute( "access_key2", "access_value2_b" ); + attributes = check_box_button.GetProperty( Toolkit::Control::Property::ACCESSIBILITY_ATTRIBUTES ); + attributes_map = attributes.GetMap(); + + DALI_TEST_EQUALS( (attributes_map->Find( "access_key2" ))->Get(), "access_value2_b", TEST_LOCATION ); + + check_box_button.RemoveAccessibilityAttribute( "access_key2" ); + attributes = check_box_button.GetProperty( Toolkit::Control::Property::ACCESSIBILITY_ATTRIBUTES ); + attributes_map = attributes.GetMap(); + + // In case when we are removing one of attributes the property is setting for NONE type. + DALI_TEST_EQUALS( (attributes_map->Find( "access_key2" ))->GetType(), Property::NONE, TEST_LOCATION ); + + Dali::Accessibility::TestEnableSC( true ); + + auto ptr = Dali::Accessibility::Accessible::Get( check_box_button ); + auto attribute_map_bridge = TestGetAttributes( ptr->GetAddress() ); + auto counter = 0u; + for (auto i = 0u; iCount();++i) + if((attributes_map->GetValue(i)).GetType() != Property::NONE ) + ++counter; + + DALI_TEST_EQUALS( counter, attribute_map_bridge.size(), TEST_LOCATION ); + + for (auto it : attribute_map_bridge) + DALI_TEST_EQUALS( (attributes_map->Find( it.first ))->Get(), it.second, TEST_LOCATION ); + + check_box_button.ClearAccessibilityAttributes(); + attributes = check_box_button.GetProperty( Toolkit::Control::Property::ACCESSIBILITY_ATTRIBUTES ); + attributes_map = attributes.GetMap(); + + position = attributes_map->Find( "access_key1" ); + DALI_TEST_CHECK( !position ); + + position = attributes_map->Find( "access_key2" ); + DALI_TEST_CHECK( !position ); + + Dali::Accessibility::TestEnableSC( false ); + + END_TEST; +} + +int UtcDaliControlReadingInfoType(void) +{ + ToolkitTestApplication application; + auto control = Control::New(); + + auto reading_info_type = control.GetAccessibilityReadingInfoType(); + reading_info_type[Dali::Accessibility::ReadingInfoType::Description] = true; + reading_info_type[Dali::Accessibility::ReadingInfoType::State] = true; + reading_info_type[Dali::Accessibility::ReadingInfoType::Name] = true; + reading_info_type[Dali::Accessibility::ReadingInfoType::Role] = true; + + control.SetAccessibilityReadingInfoType(reading_info_type); + + auto q = control.GetProperty( Toolkit::Control::Property::ACCESSIBILITY_ATTRIBUTES ); + auto z = q.GetMap(); + + DALI_TEST_EQUALS( (z->Find( "reading_info_type" ))->Get(), "name|role|description|state", TEST_LOCATION ); + reading_info_type = control.GetAccessibilityReadingInfoType(); + for ( auto i = 0u; i < 4; ++i) + DALI_TEST_CHECK ( reading_info_type[ static_cast< Dali::Accessibility::ReadingInfoType >( i ) ]); + + END_TEST; +} + +int UtcDaliControlDoGesture(void) +{ + ToolkitTestApplication application; + auto control = Control::New(); + Dali::Accessibility::TestEnableSC( true ); + + auto accessible = Dali::Accessibility::Accessible::Get( control ); + auto gesture_one = Dali::Accessibility::GestureInfo { Dali::Accessibility::Gesture::OneFingerFlickLeft, 600, 100, 500, 500, Dali::Accessibility::GestureState::Begin, 1000 }; + auto gesture_two = Dali::Accessibility::GestureInfo { Dali::Accessibility::Gesture::OneFingerFlickRight, 600, 100, 500, 500, Dali::Accessibility::GestureState::Begin, 1000 }; + + DALI_TEST_CHECK( !accessible->DoGesture( gesture_one ) ); + DALI_TEST_CHECK( !TestDoGesture( accessible->GetAddress(), Dali::Accessibility::Gesture::OneFingerFlickLeft, 600, 100, 500, 500, Dali::Accessibility::GestureState::Begin, 1000 ) ); + + control.AccessibilityDoGestureSignal().Connect( [] ( std::pair< Dali::Accessibility::GestureInfo, bool > &gesture ) { + if ( gesture.first.type == Dali::Accessibility::Gesture::OneFingerFlickLeft ) + gesture.second = true; + else + gesture.second = false; + } ); + + DALI_TEST_CHECK( accessible->DoGesture( gesture_one ) ); + DALI_TEST_CHECK( TestDoGesture( accessible->GetAddress(), Dali::Accessibility::Gesture::OneFingerFlickLeft, 600, 100, 500, 500, Dali::Accessibility::GestureState::Begin, 1000 ) ); + + DALI_TEST_CHECK( !accessible->DoGesture( gesture_two ) ); + DALI_TEST_CHECK( !TestDoGesture( accessible->GetAddress(), Dali::Accessibility::Gesture::OneFingerFlickRight, 600, 100, 500, 500, Dali::Accessibility::GestureState::Begin, 1000 ) ); + + Dali::Accessibility::TestEnableSC( false ); + + END_TEST; +} + +int UtcDaliAccessibilityRelation(void) +{ + ToolkitTestApplication application; + Dali::Accessibility::TestEnableSC( true ); + + auto rel = Accessibility::RelationType::FlowsTo; + auto number = static_cast< size_t >( rel ); + auto control = Control::New(); + auto destination1 = Control::New(); + auto destination2 = Control::New(); + + control.AppendAccessibilityRelation( destination1, rel ); + auto relations = control.GetAccessibilityRelations(); + DALI_TEST_CHECK( relations[ number ].size() == 1 ); + + control.AppendAccessibilityRelation( destination2, rel ); + relations = control.GetAccessibilityRelations(); + DALI_TEST_CHECK( relations[ number ].size() == 2 ); + + auto accessible = Dali::Accessibility::Accessible::Get( control ); + auto accessible_destination1 = Dali::Accessibility::Accessible::Get( destination1 ); + auto accessible_destination2 = Dali::Accessibility::Accessible::Get( destination2 ); + auto relationset = accessible->GetRelationSet(); + + DALI_TEST_CHECK( relationset[0].relationType == rel ); + DALI_TEST_CHECK( relationset[0].targets[0] == accessible_destination1->GetAddress() || relationset[0].targets[1] == accessible_destination1->GetAddress() ); + DALI_TEST_CHECK( relationset[0].targets[0] == accessible_destination2->GetAddress() || relationset[0].targets[1] == accessible_destination2->GetAddress() ); + + auto relationset_bridge = TestGetRelationSet( accessible -> GetAddress() ); + DALI_TEST_CHECK( static_cast< uint32_t >( relationset[0].relationType ) == std::get<0>( relationset_bridge[0] ) ); + + DALI_TEST_CHECK( relationset[0].targets[0] == std::get<1>( relationset_bridge[0] )[0] || relationset[0].targets[1] == std::get<1>( relationset_bridge[0] )[0] ); + DALI_TEST_CHECK( relationset[0].targets[0] == std::get<1>( relationset_bridge[0] )[1] || relationset[0].targets[1] == std::get<1>( relationset_bridge[0] )[1] ); + + control.RemoveAccessibilityRelation(destination2,rel); + relations = control.GetAccessibilityRelations(); + DALI_TEST_CHECK( relations[ number ].size() == 1 ); + + control.ClearAccessibilityRelations(); + relations = control.GetAccessibilityRelations(); + DALI_TEST_CHECK( relations[ number ].size() == 0 ); + + Dali::Accessibility::TestEnableSC( false ); + + END_TEST; +} + +int UtcDaliAccessibilityParentChildren(void) +{ + ToolkitTestApplication application; + Dali::Accessibility::TestEnableSC( true ); + + auto parent = Control::New(); + auto child_1 = Control::New(); + auto child_2 = Control::New(); + + auto parent_accessible = Dali::Accessibility::Accessible::Get( parent ); + auto child_1_accessible = Dali::Accessibility::Accessible::Get( child_1 ); + auto child_2_accessible = Dali::Accessibility::Accessible::Get( child_2 ); + + auto children = TestGetChildren( parent_accessible -> GetAddress() ); + DALI_TEST_EQUALS( children.size(), 0, TEST_LOCATION ); + + try + { + TestGetIndexInParent( child_1_accessible -> GetAddress() ); + DALI_ABORT("Object has parent, test abort"); + } + catch(Accessibility::TestDBusWrapper::error){} + + try + { + TestGetChildAtIndex( parent_accessible -> GetAddress(), -1 ); + DALI_ABORT("Positive index, test abort"); + } + catch(Accessibility::TestDBusWrapper::error){} + + DALI_TEST_EQUALS( parent_accessible -> GetChildCount(), 0, TEST_LOCATION ); + + try + { + child_1_accessible -> GetIndexInParent(); + DALI_ABORT("Object has parent, test abort"); + } + catch (std::domain_error){} + + parent.Add(child_1); + parent.Add(child_2); + + children = TestGetChildren( parent_accessible -> GetAddress() ); + DALI_TEST_EQUALS( children.size(), 2, TEST_LOCATION ); + + DALI_TEST_EQUALS( parent_accessible -> GetAddress(), TestGetParent( child_1_accessible -> GetAddress() ), TEST_LOCATION ); + DALI_TEST_EQUALS( child_2_accessible -> GetAddress(), TestGetChildAtIndex( parent_accessible -> GetAddress(), TestGetIndexInParent( child_2_accessible -> GetAddress() ) ), TEST_LOCATION ); + + DALI_TEST_EQUALS( parent_accessible, child_1_accessible -> GetParent(), TEST_LOCATION ); + DALI_TEST_EQUALS( child_2_accessible, parent_accessible -> GetChildAtIndex( child_2_accessible -> GetIndexInParent() ) , TEST_LOCATION ); + + Dali::Accessibility::TestEnableSC( false ); + + END_TEST; +} + +int UtcDaliAccessibilityGetLayer(void) +{ + ToolkitTestApplication application; + + Dali::Accessibility::TestEnableSC( true ); + + auto control = Control::New(); + auto accessible_obj = Dali::Accessibility::Accessible::Get( control ); + auto accessible_component = dynamic_cast(accessible_obj); + DALI_TEST_CHECK( accessible_component ); + DALI_TEST_EQUALS( Dali::Accessibility::ComponentLayer::Window, accessible_component -> GetLayer(), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::Accessibility::ComponentLayer::Window, TestGetLayer( accessible_component -> GetAddress() ), TEST_LOCATION ); + + Dali::Accessibility::TestEnableSC( false ); + + END_TEST; +} + +int UtcDaliAccessibilityGrabFocus(void) +{ + ToolkitTestApplication application; + + Dali::Accessibility::TestEnableSC( true ); + + auto controla = Control::New(); + auto controlb = Control::New(); + + Stage::GetCurrent().Add( controla ); + Stage::GetCurrent().Add( controlb ); + + controla.SetKeyboardFocusable( true ); + controlb.SetKeyboardFocusable( true ); + + auto a = Dali::Accessibility::Accessible::Get( controla ); + auto b = Dali::Accessibility::Accessible::Get( controlb ); + + auto a_component = dynamic_cast( a ); + auto b_component = dynamic_cast( b ); + + auto states_by_bridge_a = Dali::Accessibility::States { TestGetStates( a_component -> GetAddress() )}; + auto states_by_bridge_b = Dali::Accessibility::States { TestGetStates( b_component -> GetAddress() )}; + + DALI_TEST_CHECK( !states_by_bridge_a[ Dali::Accessibility::State::FOCUSED ] ); + DALI_TEST_CHECK( !states_by_bridge_b[ Dali::Accessibility::State::FOCUSED ] ); + + DALI_TEST_CHECK( a_component -> GrabFocus() ); + + states_by_bridge_a = Dali::Accessibility::States { TestGetStates( a_component -> GetAddress() )}; + states_by_bridge_b = Dali::Accessibility::States { TestGetStates( b_component -> GetAddress() )}; + + DALI_TEST_CHECK( states_by_bridge_a[ Dali::Accessibility::State::FOCUSED ] ); + DALI_TEST_CHECK( !states_by_bridge_b[ Dali::Accessibility::State::FOCUSED ] ); + + DALI_TEST_CHECK( TestGrabFocus( b_component -> GetAddress() ) ); + + states_by_bridge_a = Dali::Accessibility::States { TestGetStates( a_component -> GetAddress() )}; + states_by_bridge_b = Dali::Accessibility::States { TestGetStates( b_component -> GetAddress() )}; + + DALI_TEST_CHECK( !states_by_bridge_a[ Dali::Accessibility::State::FOCUSED ] ); + DALI_TEST_CHECK( states_by_bridge_b[ Dali::Accessibility::State::FOCUSED ] ); + + Dali::Accessibility::TestEnableSC( false ); + + END_TEST; +} + +int UtcDaliAccessibilityGetExtents(void) +{ + ToolkitTestApplication application; + + Dali::Accessibility::TestEnableSC( true ); + + auto control = Control::New(); + Stage::GetCurrent().GetRootLayer().Add( control ); + + control.SetPosition(Vector3(10,10,100)); + control.SetSize( 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::CoordType::Screen); + DALI_TEST_EQUALS( extents.position.x, 5, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.position.y, 5, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.size.height, 10, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.size.width, 10, TEST_LOCATION ); + + auto bridge_extents = TestGetExtents( a_component -> GetAddress() ); + 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::CoordType::Screen); + DALI_TEST_EQUALS( extents.position.x, 10, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.position.y, 10, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.size.height, 10, TEST_LOCATION ); + DALI_TEST_EQUALS( extents.size.width, 10, TEST_LOCATION ); + + bridge_extents = TestGetExtents( a_component -> GetAddress() ); + 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 UtcDaliAccessibilityGetAlpha(void) +{ + ToolkitTestApplication application; + + Dali::Accessibility::TestEnableSC( true ); + + auto control = Control::New(); + auto a = Dali::Accessibility::Accessible::Get( control ); + auto a_component = dynamic_cast( a ); + + DALI_TEST_EQUALS( 0.0, a_component -> GetAlpha(), TEST_LOCATION ); + DALI_TEST_EQUALS( 0.0, TestGetAlpha( a_component -> GetAddress() ), TEST_LOCATION ); + + Dali::Accessibility::TestEnableSC( false ); + + END_TEST; +} + +int UtcDaliAccessibilityGetMdiZOrder(void) +{ + ToolkitTestApplication application; + + Dali::Accessibility::TestEnableSC( true ); + + auto control = Control::New(); + auto a = Dali::Accessibility::Accessible::Get( control ); + auto a_component = dynamic_cast( a ); + + DALI_TEST_EQUALS( 0, static_cast< int >( a_component -> GetMdiZOrder() ), TEST_LOCATION ); + DALI_TEST_EQUALS( 0, TestGetMdiZOrder( a_component -> GetAddress() ), TEST_LOCATION ); + + Dali::Accessibility::TestEnableSC( false ); + + END_TEST; +} + +int UtcDaliAccessibilityAction(void) +{ + ToolkitTestApplication application; + + Dali::Accessibility::TestEnableSC( true ); + + auto control = Control::New( ); + auto a = Dali::Accessibility::Accessible::Get( control ); + auto b = dynamic_cast( a ); + + std::vector< std::string > actions { "activate", "accessibilityActivated", "ReadingSkipped", "ReadingCancelled", "ReadingStopped", "show", "hide" }; + auto count = b -> GetActionCount(); + + DALI_TEST_EQUALS( count, 7, TEST_LOCATION ); + + for (auto i = 0u; i GetActionName( i ) ) ); + DALI_TEST_EQUALS( b -> GetActionName( i ), b -> GetLocalizedActionName( i ), TEST_LOCATION ); + DALI_TEST_EQUALS( b -> GetActionDescription( i ), "", TEST_LOCATION ); + DALI_TEST_EQUALS( b -> GetActionKeyBinding( i ), "", TEST_LOCATION ); + } + + try + { + b ->GetActionDescription( count ); + DALI_ABORT( "Correct index, abort" ); + } + catch( std::domain_error ){} + + try + { + b ->GetActionName( count ); + DALI_ABORT( "Correct index, abort" ); + } + catch( std::domain_error ){} + + try + { + b ->GetLocalizedActionName( count ); + DALI_ABORT( "Correct index, abort" ); + } + catch( std::domain_error ){} + + try + { + b ->GetActionKeyBinding( count ); + DALI_ABORT( "Correct index, abort" ); + } + catch( std::domain_error ){} + + count = TestGetActionCount(b -> GetAddress()); + + DALI_TEST_EQUALS( count, 7, TEST_LOCATION ); + + for (auto i = 0u; iGetAddress(), i ) ) ); + DALI_TEST_EQUALS( TestGetActionName( b->GetAddress(), i ), TestGetLocalizedActionName( b->GetAddress(), i ), TEST_LOCATION ); + DALI_TEST_EQUALS( TestGetActionDescription( b->GetAddress(), i ), "", TEST_LOCATION ); + DALI_TEST_EQUALS( TestGetActionKeyBinding( b->GetAddress(), i ), "", TEST_LOCATION ); + } + + try + { + TestGetActionDescription( b->GetAddress(), count ); + DALI_ABORT( "Correct index, abort" ); + } + catch( Dali::Accessibility::TestDBusWrapper::error ){} + + try + { + TestGetActionName( b->GetAddress(), count ); + DALI_ABORT( "Correct index, abort" ); + } + catch( Dali::Accessibility::TestDBusWrapper::error ){} + + try + { + TestGetLocalizedActionName( b->GetAddress(), count ); + DALI_ABORT( "Correct index, abort" ); + } + catch( Dali::Accessibility::TestDBusWrapper::error ){} + + try + { + TestGetActionKeyBinding( b->GetAddress(), count ); + DALI_ABORT( "Correct index, abort" ); + } + catch( Dali::Accessibility::TestDBusWrapper::error ){} + + + Dali::Accessibility::TestEnableSC( false ); + + END_TEST; +} + +int UtcDaliAccessibilityDoAction(void) +{ + ToolkitTestApplication application; + + Dali::Accessibility::TestEnableSC( true ); + thread_local std::vector< bool > actions_done { false, false, false, false }; + + auto control = Control::New( ); + auto a = Dali::Accessibility::Accessible::Get( control ); + auto b = dynamic_cast( a ); + std::vector< std::string > actions { "activate", "accessibilityActivated", "ReadingSkipped", "ReadingCancelled", "ReadingStopped", "show", "hide" }; + + DALI_TEST_CHECK( b -> DoAction( actions[2] ) ); + DALI_TEST_CHECK( b -> DoAction( actions[4] ) ); + DALI_TEST_CHECK( b -> DoAction( actions[4] ) ); + + control.AccessibilityReadingSkippedSignal().Connect( [] () { + actions_done[ 1 ] = true; + } ); + control.AccessibilityReadingCancelledSignal().Connect( [] () { + actions_done[ 2 ] = true; + } ); + control.AccessibilityReadingStoppedSignal().Connect( [] () { + actions_done[ 3 ] = true; + } ); + control.AccessibilityActivateSignal().Connect( [] () { + actions_done[ 0 ] = true; + } ); + + DALI_TEST_CHECK( b -> DoAction( 1 ) ); + DALI_TEST_CHECK( b -> DoAction( 2 ) ); + DALI_TEST_CHECK( b -> DoAction( 3 ) ); + DALI_TEST_CHECK( b -> DoAction( 4 ) ); + + for ( auto i = 0u; i < actions_done.size(); ++i ) + { + DALI_TEST_CHECK( actions_done[ i ] ); + actions_done[ i ] = false; + } + + DALI_TEST_CHECK( TestDoAction( b -> GetAddress(), 1 ) ); + DALI_TEST_CHECK( TestDoAction( b -> GetAddress(), 2 ) ); + DALI_TEST_CHECK( TestDoAction( b -> GetAddress(), 3 ) ); + DALI_TEST_CHECK( TestDoAction( b -> GetAddress(), 4 ) ); + + for ( auto i = 0u; i < actions_done.size(); ++i ) + { + DALI_TEST_CHECK( actions_done[ i ] ); + actions_done[ i ] = false; + } + + DALI_TEST_CHECK( TestDoAction( b -> GetAddress(), actions[ 1 ] ) ); + DALI_TEST_CHECK( TestDoAction( b -> GetAddress(), actions[ 2 ] ) ); + DALI_TEST_CHECK( TestDoAction( b -> GetAddress(), actions[ 3 ] ) ); + DALI_TEST_CHECK( TestDoAction( b -> GetAddress(), actions[ 4 ] ) ); + + for ( auto i = 0u; i < actions_done.size(); ++i ) + DALI_TEST_CHECK( actions_done[ i ] ); + + Dali::Accessibility::TestEnableSC( false ); + + END_TEST; +} \ No newline at end of file diff --git a/automated-tests/src/dali-toolkit-accessibility/utc-Dali-Accessibility-Controls.cpp b/automated-tests/src/dali-toolkit-accessibility/utc-Dali-Accessibility-Controls.cpp new file mode 100644 index 0000000..bdfdc1b --- /dev/null +++ b/automated-tests/src/dali-toolkit-accessibility/utc-Dali-Accessibility-Controls.cpp @@ -0,0 +1,630 @@ +#include +#include +#include + +using namespace Dali::Toolkit; + +using DBusWrapper = Dali::Accessibility::DBusWrapper; + +void utc_dali_accessibility_controls_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_accessibility_controls_cleanup(void) +{ + test_return_value = TET_PASS; + //DBusWrapper::Install({}) is a de-install + DBusWrapper::Install({}); +} + +int UtcDaliControlPropertyAccessibilityTranslationDomain(void) +{ + ToolkitTestApplication application; + + auto control = Control::New(); + + auto accessibility_translation_domain = Control::Property::ACCESSIBILITY_TRANSLATION_DOMAIN; + DALI_TEST_EQUALS( Property::NONE , control.GetProperty( accessibility_translation_domain ).GetType(), TEST_LOCATION ); + + control.SetProperty( accessibility_translation_domain, "translation_domain_test_1" ); + DALI_TEST_EQUALS( "translation_domain_test_1" , control.GetProperty( accessibility_translation_domain ).Get< std::string >(), TEST_LOCATION ); + + control.SetProperty( accessibility_translation_domain, "translation_domain_test_2" ); + DALI_TEST_EQUALS( "translation_domain_test_2" , control.GetProperty( accessibility_translation_domain ).Get< std::string >(), TEST_LOCATION ); + + END_TEST; +} + +// This test shows that when the accessibility bridge is +// not up, there is no possibility to grab or clear highlight +int UtcDaliControlAccessibilityHighlight(void) +{ + ToolkitTestApplication application; + auto controla = Control::New(); + auto controlb = Control::New(); + + DALI_TEST_EQUALS( false, controla.GrabAccessibilityHighlight(), TEST_LOCATION ); + DALI_TEST_EQUALS( false, controlb.GrabAccessibilityHighlight(), TEST_LOCATION ); + DALI_TEST_EQUALS( false, controla.ClearAccessibilityHighlight(), TEST_LOCATION ); + DALI_TEST_EQUALS( false, controlb.ClearAccessibilityHighlight(), TEST_LOCATION ); + + END_TEST; +} + +#include +int UtcDaliAccessibilityToolBarConstructor(void) +{ + ToolkitTestApplication application; + + auto toolbar = ToolBar::New(); + DALI_TEST_CHECK( toolbar ); + + auto accessible = Dali::Accessibility::Accessible::Get( toolbar ); + DALI_TEST_CHECK( accessible ); + DALI_TEST_EQUALS( accessible->GetRole(), Accessibility::Role::ToolBar, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliAccessibilityPushButtonConstructor(void) +{ + ToolkitTestApplication application; + + auto pushbutton = PushButton::New(); + DALI_TEST_CHECK( pushbutton ); + + auto accessible = Dali::Accessibility::Accessible::Get( pushbutton ); + DALI_TEST_CHECK( accessible ); + DALI_TEST_EQUALS( accessible->GetRole(), Accessibility::Role::PushButton, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliAccessibilityPushButtonStates(void) +{ + ToolkitTestApplication application; + + auto pushbutton = PushButton::New(); + DALI_TEST_CHECK( pushbutton ); + + auto accessible = Dali::Accessibility::Accessible::Get( pushbutton ); + DALI_TEST_CHECK( accessible ); + + Dali::Accessibility::TestEnableSC( true ); + + auto states = accessible->GetStates(); + DALI_TEST_EQUALS( static_cast< unsigned int >( states[ Accessibility::State::Pressed ] ), false, TEST_LOCATION ); + + // auto button = dynamic_cast( accessible ) ; + pushbutton.SetProperty( Toolkit::Button::Property::TOGGLABLE, true ); + pushbutton.SetProperty( Toolkit::Button::Property::SELECTED, true ); + + states = accessible->GetStates(); + DALI_TEST_EQUALS( static_cast< unsigned int >( states[ Accessibility::State::Pressed ] ), true, TEST_LOCATION ); + + Dali::Accessibility::TestEnableSC( false ); + + END_TEST; +} + +#include +int UtcDaliAccessibilityToggleButtonConstructor(void) +{ + ToolkitTestApplication application; + + auto togglebutton = ToggleButton::New(); + DALI_TEST_CHECK( togglebutton ); + + auto accessible = Dali::Accessibility::Accessible::Get( togglebutton ); + DALI_TEST_CHECK( accessible ); + DALI_TEST_EQUALS( accessible->GetRole(), Accessibility::Role::ToggleButton, TEST_LOCATION ); + + END_TEST; +} + +#include +int UtcDaliAccessibilityTextSelectionPopupConstructor(void) +{ + ToolkitTestApplication application; + + auto textselectionpopup = TextSelectionPopup::New( NULL ); + DALI_TEST_CHECK( textselectionpopup ); + + auto accessible = Dali::Accessibility::Accessible::Get( textselectionpopup ); + DALI_TEST_CHECK( accessible ); + DALI_TEST_EQUALS( accessible->GetRole(), Accessibility::Role::Dialog, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliAccessibilityAlignmentConstructor(void) +{ + ToolkitTestApplication application; + + auto alignment = Alignment::New(); + DALI_TEST_CHECK( alignment ); + + auto accessible = Dali::Accessibility::Accessible::Get( alignment ); + DALI_TEST_CHECK( accessible ); + DALI_TEST_EQUALS( accessible->GetRole(), Accessibility::Role::Filler, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliAccessibilityRadioButtonStates(void) +{ + ToolkitTestApplication application; + + auto radiobutton = RadioButton::New(); + DALI_TEST_CHECK( radiobutton ); + + auto accessible = Dali::Accessibility::Accessible::Get( radiobutton ); + DALI_TEST_CHECK( accessible ); + + Dali::Accessibility::TestEnableSC( true ); + + auto states = accessible->GetStates(); + DALI_TEST_CHECK( states ); + DALI_TEST_EQUALS( static_cast< unsigned int >( states[ Accessibility::State::Checked ] ), false, TEST_LOCATION ); + radiobutton.SetProperty( Toolkit::RadioButton::Property::SELECTED, true ); + states = accessible->GetStates(); + DALI_TEST_CHECK( states ); + DALI_TEST_EQUALS( static_cast< unsigned int >( states[ Accessibility::State::Checked ] ), true, TEST_LOCATION ); + + Dali::Accessibility::TestEnableSC( false ); + + END_TEST; +} + +int UtcDaliAccessibilityFlexContainerConstructor(void) +{ + ToolkitTestApplication application; + + auto flexcontainer = FlexContainer::New(); + DALI_TEST_CHECK( flexcontainer ); + + auto accessible = Dali::Accessibility::Accessible::Get( flexcontainer ); + DALI_TEST_CHECK( accessible ); + DALI_TEST_EQUALS( accessible->GetRole(), Accessibility::Role::Filler, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliAccessibilityCheckBoxButton(void) +{ + ToolkitTestApplication application; + + auto checkboxbutton = CheckBoxButton::New(); + DALI_TEST_CHECK( checkboxbutton ); + + auto accessible = Dali::Accessibility::Accessible::Get( checkboxbutton ); + DALI_TEST_CHECK( accessible ); + + Dali::Accessibility::TestEnableSC( true ); + + auto states = accessible->GetStates(); + DALI_TEST_EQUALS( static_cast< unsigned int >( states[ Accessibility::State::Checked ] ), false, TEST_LOCATION ); + checkboxbutton.SetProperty( Toolkit::CheckBoxButton::Property::SELECTED, true ); + states = accessible->GetStates(); + DALI_TEST_EQUALS( static_cast< unsigned int >( states[ Accessibility::State::Checked ] ), true, TEST_LOCATION ); + + Dali::Accessibility::TestEnableSC( false ); + + END_TEST; +} + +#include +int UtcDaliAccessibilityTextSelectionConstructor(void) +{ + ToolkitTestApplication application; + + auto textselectiontoolbar = TextSelectionToolbar::New(); + DALI_TEST_CHECK( textselectiontoolbar ); + + auto accessible = Dali::Accessibility::Accessible::Get( textselectiontoolbar ); + DALI_TEST_CHECK( accessible ); + DALI_TEST_EQUALS( accessible->GetRole(), Accessibility::Role::ToolBar, TEST_LOCATION ); + + END_TEST; +} + +#include +int UtcDaliAccessibilityManager(void) +{ + ToolkitTestApplication application; + + auto accessmanager = new Dali::Toolkit::Internal::AccessibilityManager; + auto actor = Dali::Actor::New(); + + auto str = accessmanager->GetAccessibilityAttribute( actor, Toolkit::AccessibilityManager::AccessibilityAttribute::ACCESSIBILITY_LABEL ); + DALI_TEST_EQUALS( str, "", TEST_LOCATION ); + DALI_TEST_EQUALS( accessmanager->GetFocusOrder( actor ), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( accessmanager->GenerateNewFocusOrder(), 0, TEST_LOCATION ); + accessmanager->GetActorByFocusOrder( 0 ); + accessmanager->GetCurrentFocusActor(); + accessmanager->GetCurrentFocusGroup(); + DALI_TEST_EQUALS( accessmanager->GetCurrentFocusOrder(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( accessmanager->MoveFocusForward(), false, TEST_LOCATION ); + DALI_TEST_EQUALS( accessmanager->MoveFocusBackward(), false, TEST_LOCATION ); + DALI_TEST_EQUALS( accessmanager->IsFocusGroup( actor ), false, TEST_LOCATION ); + accessmanager->GetFocusGroup( actor ); + auto vector = accessmanager->GetReadPosition(); + DALI_TEST_EQUALS( vector.x, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( vector.y, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( accessmanager->GetGroupMode(), false, TEST_LOCATION ); + DALI_TEST_EQUALS( accessmanager->GetWrapMode(), false, TEST_LOCATION ); + accessmanager->GetFocusIndicatorActor(); + + END_TEST; +} + +int UtcDaliAccessibilityModel3dViewConstructor(void) +{ + ToolkitTestApplication application; + + auto model3dview = Model3dView::New(); + DALI_TEST_CHECK( model3dview ); + + auto accessible = Dali::Accessibility::Accessible::Get( model3dview ); + DALI_TEST_CHECK( accessible ); + DALI_TEST_EQUALS( accessible->GetRole(), Accessibility::Role::Image, TEST_LOCATION ); + + END_TEST; +} + +#include +int UtcDaliAccessibilityEffectsViewConstructor(void) +{ + ToolkitTestApplication application; + + auto etype = Dali::Toolkit::EffectsView::EffectType::DROP_SHADOW; + auto effectsview = EffectsView::New( etype ); + DALI_TEST_CHECK( effectsview ); + + auto accessible = Dali::Accessibility::Accessible::Get( effectsview ); + DALI_TEST_CHECK( accessible ); + DALI_TEST_EQUALS( accessible->GetRole(), Accessibility::Role::Filler, TEST_LOCATION ); + + END_TEST; +} + +#include +int UtcDaliAccessibilitySuperBlurViewConstructor(void) +{ + ToolkitTestApplication application; + + auto superblurview = SuperBlurView::New( 1 ); + DALI_TEST_CHECK( superblurview ); + + auto accessible = Dali::Accessibility::Accessible::Get( superblurview ); + DALI_TEST_CHECK( accessible ); + DALI_TEST_EQUALS( accessible->GetRole(), Accessibility::Role::Filler, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliAccessibilityImageViewConstructor(void) +{ + ToolkitTestApplication application; + + auto imageview = ImageView::New(); + DALI_TEST_CHECK( imageview ); + + auto accessible = Dali::Accessibility::Accessible::Get( imageview ); + DALI_TEST_CHECK( accessible ); + DALI_TEST_EQUALS( accessible->GetRole(), Accessibility::Role::Image, TEST_LOCATION ); + + END_TEST; +} + +#include +class TestPageFactory : public PageFactory +{ +public: + + TestPageFactory( bool returnValidTexture = true ) + : mValidTexture( returnValidTexture ) + { + mTotalPageNumber = 100; + } + + /** + * Query the number of pages available from the factory. + * The maximum available page has an ID of GetNumberOfPages()-1. + */ + virtual unsigned int GetNumberOfPages() + { + return mTotalPageNumber; + } + + /** + * Create an texture to represent a page content. + * @param[in] pageId The ID of the page to create. + * @return An image, or an empty handle if the ID is out of range. + */ + virtual Texture NewPage( unsigned int pageId ) + { + if( mValidTexture ) + { + return Texture::New( Dali::TextureType::TEXTURE_2D, Pixel::RGB888, 100, 100 ); + } + return Texture(); // empty handle + } + +private: + unsigned int mTotalPageNumber; + bool mValidTexture; +}; + +#include +int UtcDaliAccessibilityPageTurnViewConstructor(void) +{ + ToolkitTestApplication application; + + auto testpagefactory = TestPageFactory(); + auto vector2 = Vector2( 1.0, 1.0 ); + auto pageturnlandscapeview = PageTurnLandscapeView::New( testpagefactory, vector2 ); + DALI_TEST_CHECK( pageturnlandscapeview ); + + auto accessible = Dali::Accessibility::Accessible::Get( pageturnlandscapeview ); + DALI_TEST_CHECK( accessible ); + DALI_TEST_EQUALS( accessible->GetRole(), Accessibility::Role::PageTabList, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliAccessibilityGaussianBlurViewConstructor(void) +{ + ToolkitTestApplication application; + + auto gaussianblurview = GaussianBlurView::New(); + DALI_TEST_CHECK( gaussianblurview ); + + auto accessible = Dali::Accessibility::Accessible::Get( gaussianblurview ); + DALI_TEST_CHECK( accessible ); + DALI_TEST_EQUALS( accessible->GetRole(), Accessibility::Role::Filler, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliAccessibilityShadowViewConstructor(void) +{ + ToolkitTestApplication application; + + auto shadowview = ShadowView::New(); + DALI_TEST_CHECK( shadowview ); + + auto accessible = Dali::Accessibility::Accessible::Get( shadowview ); + DALI_TEST_CHECK( accessible ); + DALI_TEST_EQUALS( accessible->GetRole(), Accessibility::Role::Filler, TEST_LOCATION ); + + END_TEST; +} + +#include +#include +int UtcDaliAccessibilityScrollableConstructor(void) +{ + ToolkitTestApplication application; + + auto scrollview = ScrollView::New(); + DALI_TEST_CHECK( scrollview ); + + auto accessible = Dali::Accessibility::Accessible::Get( scrollview ); + DALI_TEST_CHECK( accessible ); + DALI_TEST_EQUALS( accessible->GetRole(), Accessibility::Role::ScrollPane, TEST_LOCATION ); + + END_TEST; +} + +#include +int UtcDaliAccessibilityMagnifierConstructor(void) +{ + ToolkitTestApplication application; + + auto magnifier = Magnifier::New(); + DALI_TEST_CHECK( magnifier ); + + auto accessible = Dali::Accessibility::Accessible::Get( magnifier ); + DALI_TEST_CHECK( accessible ); + DALI_TEST_EQUALS( accessible->GetRole(), Accessibility::Role::Filler, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliAccessibilityTableViewConstructor(void) +{ + ToolkitTestApplication application; + + auto tableview = TableView::New( 10, 10 ); + DALI_TEST_CHECK( tableview ); + + auto accessible = Dali::Accessibility::Accessible::Get( tableview ); + DALI_TEST_CHECK( accessible ); + DALI_TEST_EQUALS( accessible->GetRole(), Accessibility::Role::Table, TEST_LOCATION ); + + END_TEST; +} + +#include +int UtcDaliAccessibilityBloomViewConstructor(void) +{ + ToolkitTestApplication application; + + auto bloomview = BloomView::New(); + DALI_TEST_CHECK( bloomview ); + + auto accessible = Dali::Accessibility::Accessible::Get( bloomview ); + DALI_TEST_CHECK( accessible ); + DALI_TEST_EQUALS( accessible->GetRole(), Accessibility::Role::Animation, TEST_LOCATION ); + + END_TEST; +} + +#include +int UtcDaliAccessibilityTextField(void) +{ + ToolkitTestApplication application; + + auto textfield = TextField::New(); + DALI_TEST_CHECK( textfield ); + + textfield.SetName( "test" ); + DALI_TEST_EQUALS( textfield.GetName(), "test", TEST_LOCATION ); + + auto accessible = Dali::Accessibility::Accessible::Get( textfield ); + DALI_TEST_CHECK( accessible ); + + DALI_TEST_EQUALS( accessible->GetName(), "", TEST_LOCATION ); + DALI_TEST_EQUALS( accessible->GetRole(), Accessibility::Role::Entry, TEST_LOCATION ); + auto states = accessible->GetStates(); + DALI_TEST_EQUALS( static_cast< unsigned int >( states[ Accessibility::State::Editable ] ), true, TEST_LOCATION ); + + Dali::Accessibility::TestEnableSC( true ); + + textfield.SetProperty( Toolkit::TextField::Property::TEXT, "test" ); + auto text = dynamic_cast< Dali::Accessibility::Text* >( accessible ); + DALI_TEST_CHECK( text ); + DALI_TEST_EQUALS( text->GetText( 0, 10 ), "", TEST_LOCATION ); + DALI_TEST_EQUALS( text->SetCaretOffset(100), false, TEST_LOCATION ); + DALI_TEST_EQUALS( text->SetCaretOffset(2), true, TEST_LOCATION ); + DALI_TEST_EQUALS( text->GetCaretOffset(), 2, TEST_LOCATION ); + + auto editabletext = dynamic_cast< Dali::Accessibility::EditableText* >( accessible ); + DALI_TEST_CHECK( editabletext ); + DALI_TEST_EQUALS( editabletext->CopyText( 3, 1 ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( editabletext->CopyText( 1, 3 ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( editabletext->CutText( 3, 1 ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( editabletext->CutText( 1, 3 ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( text->GetText( 0, 1 ), "t", TEST_LOCATION ); + + auto range = text->GetSelection( 1 ); + DALI_TEST_EQUALS( range.startOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.content, "", TEST_LOCATION ); + DALI_TEST_EQUALS( text->SetSelection( 1, 0, 1 ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( text->RemoveSelection( 1 ), false, TEST_LOCATION ); + + Dali::Accessibility::TestEnableSC( false ); + + END_TEST; +} + +#include +int UtcDaliAccessibilityTextEditor(void) +{ + ToolkitTestApplication application; + + auto texteditor = TextEditor::New(); + DALI_TEST_CHECK( texteditor ); + + texteditor.SetName( "test" ); + DALI_TEST_EQUALS( texteditor.GetName(), "test", TEST_LOCATION ); + + auto accessible = Dali::Accessibility::Accessible::Get( texteditor ); + DALI_TEST_CHECK( accessible ); + + DALI_TEST_EQUALS( accessible->GetName(), "", TEST_LOCATION ); + DALI_TEST_EQUALS( accessible->GetRole(), Accessibility::Role::Entry, TEST_LOCATION ); + auto states = accessible->GetStates(); + DALI_TEST_EQUALS( static_cast< unsigned int >( states[ Accessibility::State::Editable ] ), true, TEST_LOCATION ); + + Dali::Accessibility::TestEnableSC( true ); + + texteditor.SetProperty( Toolkit::TextEditor::Property::TEXT, "test" ); + auto text = dynamic_cast< Dali::Accessibility::Text* >( accessible ); + DALI_TEST_CHECK( text ); + DALI_TEST_EQUALS( text->GetText( 0, 10 ), "", TEST_LOCATION ); + DALI_TEST_EQUALS( text->SetCaretOffset(100), false, TEST_LOCATION ); + DALI_TEST_EQUALS( text->SetCaretOffset(2), true, TEST_LOCATION ); + DALI_TEST_EQUALS( text->GetCaretOffset(), 2, TEST_LOCATION ); + + auto editabletext = dynamic_cast< Dali::Accessibility::EditableText* >( accessible ); + DALI_TEST_CHECK( editabletext ); + DALI_TEST_EQUALS( editabletext->CopyText( 3, 1 ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( editabletext->CopyText( 1, 3 ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( editabletext->CutText( 3, 1 ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( editabletext->CutText( 1, 3 ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( text->GetText( 0, 1 ), "t", TEST_LOCATION ); + + auto range = text->GetSelection( 1 ); + DALI_TEST_EQUALS( range.startOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.content, "", TEST_LOCATION ); + DALI_TEST_EQUALS( text->SetSelection( 1, 0, 1 ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( text->RemoveSelection( 1 ), false, TEST_LOCATION ); + + Dali::Accessibility::TestEnableSC( false ); + + END_TEST; +} + +int UtcDaliAccessibilityTextLabel(void) +{ + ToolkitTestApplication application; + + auto textlabel = TextLabel::New(); + DALI_TEST_CHECK( textlabel ); + + textlabel.SetName( "test" ); + DALI_TEST_EQUALS( textlabel.GetName(), "test", TEST_LOCATION ); + + auto accessible = Dali::Accessibility::Accessible::Get( textlabel ); + DALI_TEST_CHECK( accessible ); + + DALI_TEST_EQUALS( accessible->GetName(), "", TEST_LOCATION ); + DALI_TEST_EQUALS( accessible->GetRole(), Accessibility::Role::Label, TEST_LOCATION ); + + Dali::Accessibility::TestEnableSC( true ); + + textlabel.SetProperty( Toolkit::TextLabel::Property::TEXT, "test" ); + auto text = dynamic_cast< Dali::Accessibility::Text* >( accessible ); + DALI_TEST_CHECK( text ); + DALI_TEST_EQUALS( text->GetText( 0, 10 ), "", TEST_LOCATION ); + DALI_TEST_EQUALS( text->GetText( 0, 4 ), "test", TEST_LOCATION ); + DALI_TEST_EQUALS( text->SetCaretOffset(0), false, TEST_LOCATION ); + DALI_TEST_EQUALS( text->GetCaretOffset(), 0, TEST_LOCATION ); + + auto range = text->GetSelection( 1 ); + DALI_TEST_EQUALS( range.startOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.content, "", TEST_LOCATION ); + DALI_TEST_EQUALS( text->SetSelection( 1, 0, 1 ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( text->RemoveSelection( 1 ), false, TEST_LOCATION ); + + Dali::Accessibility::TestEnableSC( false ); + + END_TEST; +} + +#include +int UtcDaliAccessibilityNavigationViewConstructor(void) +{ + ToolkitTestApplication application; + + auto navigationview = NavigationView::New(); + DALI_TEST_CHECK( navigationview ); + + auto accessible = Dali::Accessibility::Accessible::Get( navigationview ); + DALI_TEST_CHECK( accessible ); + + DALI_TEST_EQUALS( accessible->GetRole(), Dali::Accessibility::Role::FILLER, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliAccessibilityVideoViewConstructor(void) +{ + ToolkitTestApplication application; + + auto videoview = VideoView::New(); + DALI_TEST_CHECK( videoview ); + + auto accessible = Dali::Accessibility::Accessible::Get( videoview ); + DALI_TEST_CHECK( accessible ); + + DALI_TEST_EQUALS( accessible->GetRole(), Dali::Accessibility::Role::VIDEO, TEST_LOCATION ); + + END_TEST; +} \ No newline at end of file diff --git a/automated-tests/src/dali-toolkit-accessibility/utc-Dali-Accessibility-Text.cpp b/automated-tests/src/dali-toolkit-accessibility/utc-Dali-Accessibility-Text.cpp new file mode 100644 index 0000000..c1b69d3 --- /dev/null +++ b/automated-tests/src/dali-toolkit-accessibility/utc-Dali-Accessibility-Text.cpp @@ -0,0 +1,483 @@ +/** + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// Need to override adaptor classes for toolkit test harness, so include +// test harness headers before dali headers. +#include + +#include +#include + +#include +#include + +void utc_dali_toolkit_accessibility_text_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_toolkit_accessibility_text_cleanup(void) +{ + test_return_value = TET_PASS; +} + +int utcDaliAccessibilityTextEditorGetName(void) +{ + ToolkitTestApplication application; + + auto editor = Dali::Toolkit::TextEditor::New(); + DALI_TEST_EQUALS( editor.GetName(), "", TEST_LOCATION ); + editor.SetName("editor"); + DALI_TEST_EQUALS( editor.GetName(), "editor", TEST_LOCATION ); + + END_TEST; +} + +int utcDaliAccessibilityTextEditorGetText(void) +{ + ToolkitTestApplication application; + + auto editor = Dali::Toolkit::TextEditor::New(); + auto q = Dali::Accessibility::Accessible::Get( editor ); + auto x = dynamic_cast< Dali::Accessibility::Text* >( q ); + DALI_TEST_CHECK( x ); + if( x ) + { + DALI_TEST_EQUALS( x->GetText( 0, 0 ), "", TEST_LOCATION ); + editor.SetProperty( Toolkit::TextEditor::Property::TEXT, "exemplary_text" ); + DALI_TEST_EQUALS( x->GetText( 0, 9 ), "exemplary", TEST_LOCATION ); + } + + END_TEST; +} + +int utcDaliAccessibilityTextEditorGetCharacterCount(void) +{ + ToolkitTestApplication application; + + auto editor = Dali::Toolkit::TextEditor::New(); + auto q = Dali::Accessibility::Accessible::Get( editor ); + auto x = dynamic_cast< Dali::Accessibility::Text* >( q ); + DALI_TEST_CHECK( x ); + if( x ) + { + DALI_TEST_EQUALS( x->GetCharacterCount(), 0, TEST_LOCATION ); + editor.SetProperty( Toolkit::TextEditor::Property::TEXT, "editor" ); + DALI_TEST_EQUALS( x->GetCharacterCount(), 6, TEST_LOCATION ); + } + + END_TEST; +} + +int utcDaliAccessibilityTextEditorGetTextAtOffset(void) +{ + ToolkitTestApplication application; + + auto editor = Dali::Toolkit::TextEditor::New(); + auto q = Dali::Accessibility::Accessible::Get( editor ); + auto x = dynamic_cast< Dali::Accessibility::Text* >( q ); + DALI_TEST_CHECK( x ); + if( x ) + { + auto range = x->GetTextAtOffset( 0, Dali::Accessibility::TextBoundary::Line ); + DALI_TEST_EQUALS( range.content, "", TEST_LOCATION ); + DALI_TEST_EQUALS( range.startOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 0, TEST_LOCATION ); + + editor.SetProperty( Toolkit::TextEditor::Property::TEXT, "text editor test sentence" ); + range = x->GetTextAtOffset( 5, Dali::Accessibility::TextBoundary::Character ); + DALI_TEST_EQUALS( range.content, "e", TEST_LOCATION ); + DALI_TEST_EQUALS( range.startOffset, 5, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 6, TEST_LOCATION ); + + editor.SetProperty( Toolkit::TextEditor::Property::TEXT, "text \n\n\n\n\n\n editor \n\n test sentence" ); + range = x->GetTextAtOffset( 3, Dali::Accessibility::TextBoundary::Word ); + DALI_TEST_EQUALS( range.content, "sentence", TEST_LOCATION ); + DALI_TEST_EQUALS( range.startOffset, 28, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 36, TEST_LOCATION ); + + editor.SetProperty( Toolkit::TextEditor::Property::TEXT, "text \n\n\n\n\n\n editor \n\n test sentence" ); + range = x->GetTextAtOffset( 4, Dali::Accessibility::TextBoundary::Word ); + DALI_TEST_EQUALS( range.content, "", TEST_LOCATION ); + DALI_TEST_EQUALS( range.startOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 0, TEST_LOCATION ); + + editor.SetProperty( Toolkit::TextEditor::Property::TEXT, "text \n\n\n\n\n\n editor \n\n test sentence" ); + range = x->GetTextAtOffset( 0, Dali::Accessibility::TextBoundary::Line ); + DALI_TEST_EQUALS( range.content, "text \n", TEST_LOCATION ); + DALI_TEST_EQUALS( range.startOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 9, TEST_LOCATION ); + + editor.SetProperty( Toolkit::TextEditor::Property::TEXT, "text \n\n\n\n\n\n editor \n\n test sentence" ); + range = x->GetTextAtOffset( 6, Dali::Accessibility::TextBoundary::Line ); + DALI_TEST_EQUALS( range.content, " editor \n", TEST_LOCATION ); + DALI_TEST_EQUALS( range.startOffset, 14, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 24, TEST_LOCATION ); + + editor.SetProperty( Toolkit::TextEditor::Property::TEXT, "text \n\n\n\n\n\n editor \n\n test sentence" ); + range = x->GetTextAtOffset( 8, Dali::Accessibility::TextBoundary::Line ); + DALI_TEST_EQUALS( range.content, " test sentence", TEST_LOCATION ); + DALI_TEST_EQUALS( range.startOffset, 25, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 39, TEST_LOCATION ); + } + + END_TEST; +} + +int utcDaliAccessibilityTextEditorGetSetSelection(void) +{ + ToolkitTestApplication application; + + auto editor = Dali::Toolkit::TextEditor::New(); + auto q = Dali::Accessibility::Accessible::Get( editor ); + auto x = dynamic_cast< Dali::Accessibility::Text* >( q ); + DALI_TEST_CHECK( x ); + if( x ) + { + auto range = x->GetSelection( 0 ); + DALI_TEST_EQUALS( range.startOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.content, "", TEST_LOCATION ); + + x->SetSelection( 0, 4, 9 ); + editor.SetProperty( Toolkit::TextEditor::Property::TEXT, "exemplary_text" ); + range = x->GetSelection( 0 ); + + DALI_TEST_EQUALS( range.startOffset, 4, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 9, TEST_LOCATION ); + DALI_TEST_EQUALS( range.content, "plary", TEST_LOCATION ); + } + + END_TEST; +} + +int utcDaliAccessibilityTextEditorRemoveSelection(void) +{ + ToolkitTestApplication application; + + auto editor = Dali::Toolkit::TextEditor::New(); + auto q = Dali::Accessibility::Accessible::Get( editor ); + auto x = dynamic_cast< Dali::Accessibility::Text* >( q ); + DALI_TEST_CHECK( x ); + if( x ) + { + auto range = x->GetSelection( 0 ); + DALI_TEST_EQUALS( range.startOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 0, TEST_LOCATION ); + + x->SetSelection( 0, 4, 9 ); + range = x->GetSelection( 0 ); + DALI_TEST_EQUALS( range.startOffset, 4, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 9, TEST_LOCATION ); + + x->RemoveSelection( 0 ); + range = x->GetSelection( 0 ); + DALI_TEST_EQUALS( range.startOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 0, TEST_LOCATION ); + } + + END_TEST; +} + +int utcDaliAccessibilityTextFieldGetName(void) +{ + ToolkitTestApplication application; + + auto field = Toolkit::TextField::New(); + DALI_TEST_EQUALS( field.GetName(), "", TEST_LOCATION ); + field.SetName("field"); + DALI_TEST_EQUALS( field.GetName(), "field", TEST_LOCATION ); + + END_TEST; +} + +int utcDaliAccessibilityTextFieldGetText(void) +{ + ToolkitTestApplication application; + + auto field = Dali::Toolkit::TextField::New(); + auto q = Dali::Accessibility::Accessible::Get( field ); + auto x = dynamic_cast< Dali::Accessibility::Text* >( q ); + DALI_TEST_CHECK( x ); + if( x ) + { + DALI_TEST_EQUALS( x->GetText( 0, 0 ), "", TEST_LOCATION ); + field.SetProperty( Toolkit::TextField::Property::TEXT, "exemplary_text" ); + DALI_TEST_EQUALS( x->GetText( 0, 9 ), "exemplary", TEST_LOCATION ); + } + + END_TEST; +} + +int utcDaliAccessibilityTextFieldGetCharacterCount(void) +{ + ToolkitTestApplication application; + + auto field = Dali::Toolkit::TextField::New(); + auto q = Dali::Accessibility::Accessible::Get( field ); + auto x = dynamic_cast< Dali::Accessibility::Text* >( q ); + DALI_TEST_CHECK( x ); + if( x ) + { + DALI_TEST_EQUALS( x->GetCharacterCount(), 0, TEST_LOCATION ); + field.SetProperty( Toolkit::TextField::Property::TEXT, "field" ); + DALI_TEST_EQUALS( x->GetCharacterCount(), 5, TEST_LOCATION ); + } + + END_TEST; +} + +int utcDaliAccessibilityTextFieldGetTextAtOffset(void) +{ + ToolkitTestApplication application; + + auto field = Dali::Toolkit::TextField::New(); + auto q = Dali::Accessibility::Accessible::Get( field ); + auto x = dynamic_cast< Dali::Accessibility::Text* >( q ); + DALI_TEST_CHECK( x ); + if( x ) + { + auto range = x->GetTextAtOffset( 0, Dali::Accessibility::TextBoundary::Line ); + DALI_TEST_EQUALS( range.content, "", TEST_LOCATION ); + DALI_TEST_EQUALS( range.startOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 0, TEST_LOCATION ); + + field.SetProperty( Toolkit::TextField::Property::TEXT, "text editor test sentence" ); + range = x->GetTextAtOffset( 5, Dali::Accessibility::TextBoundary::Character ); + DALI_TEST_EQUALS( range.content, "e", TEST_LOCATION ); + DALI_TEST_EQUALS( range.startOffset, 5, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 6, TEST_LOCATION ); + + field.SetProperty( Toolkit::TextField::Property::TEXT, "text \n\n\n\n\n\n editor \n\n test sentence" ); + range = x->GetTextAtOffset( 3, Dali::Accessibility::TextBoundary::Word ); + DALI_TEST_EQUALS( range.content, "sentence", TEST_LOCATION ); + DALI_TEST_EQUALS( range.startOffset, 28, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 36, TEST_LOCATION ); + + field.SetProperty( Toolkit::TextField::Property::TEXT, "text \n\n\n\n\n\n editor \n\n test sentence" ); + range = x->GetTextAtOffset( 4, Dali::Accessibility::TextBoundary::Word ); + DALI_TEST_EQUALS( range.content, "", TEST_LOCATION ); + DALI_TEST_EQUALS( range.startOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 0, TEST_LOCATION ); + + field.SetProperty( Toolkit::TextField::Property::TEXT, "text \n\n\n\n\n\n editor \n\n test sentence" ); + range = x->GetTextAtOffset( 0, Dali::Accessibility::TextBoundary::Line ); + DALI_TEST_EQUALS( range.content, "text \n", TEST_LOCATION ); + DALI_TEST_EQUALS( range.startOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 9, TEST_LOCATION ); + + field.SetProperty( Toolkit::TextField::Property::TEXT, "text \n\n\n\n\n\n editor \n\n test sentence" ); + range = x->GetTextAtOffset( 6, Dali::Accessibility::TextBoundary::Line ); + DALI_TEST_EQUALS( range.content, " editor \n", TEST_LOCATION ); + DALI_TEST_EQUALS( range.startOffset, 14, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 24, TEST_LOCATION ); + + field.SetProperty( Toolkit::TextField::Property::TEXT, "text \n\n\n\n\n\n editor \n\n test sentence" ); + range = x->GetTextAtOffset( 8, Dali::Accessibility::TextBoundary::Line ); + DALI_TEST_EQUALS( range.content, " test sentence", TEST_LOCATION ); + DALI_TEST_EQUALS( range.startOffset, 25, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 39, TEST_LOCATION ); + } + + END_TEST; +} + +int utcDaliAccessibilityTextFieldGetSetSelection(void) +{ + ToolkitTestApplication application; + + auto field = Dali::Toolkit::TextField::New(); + auto q = Dali::Accessibility::Accessible::Get( field ); + auto x = dynamic_cast< Dali::Accessibility::Text* >( q ); + DALI_TEST_CHECK( x ); + if( x ) + { + auto range = x->GetSelection( 0 ); + DALI_TEST_EQUALS( range.startOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.content, "", TEST_LOCATION ); + + x->SetSelection( 0, 4, 9 ); + field.SetProperty( Toolkit::TextEditor::Property::TEXT, "exemplary_text" ); + range = x->GetSelection( 0 ); + + DALI_TEST_EQUALS( range.startOffset, 4, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 9, TEST_LOCATION ); + DALI_TEST_EQUALS( range.content, "plary", TEST_LOCATION ); + } + + END_TEST; +} + +int utcDaliAccessibilityTextFieldRemoveSelection(void) +{ + ToolkitTestApplication application; + + auto field = Dali::Toolkit::TextField::New(); + auto q = Dali::Accessibility::Accessible::Get( field ); + auto x = dynamic_cast< Dali::Accessibility::Text* >( q ); + DALI_TEST_CHECK( x ); + if( x ) + { + auto range = x->GetSelection( 0 ); + DALI_TEST_EQUALS( range.startOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 0, TEST_LOCATION ); + + x->SetSelection( 0, 4, 9 ); + range = x->GetSelection( 0 ); + DALI_TEST_EQUALS( range.startOffset, 4, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 9, TEST_LOCATION ); + + x->RemoveSelection( 0 ); + range = x->GetSelection( 0 ); + DALI_TEST_EQUALS( range.startOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 0, TEST_LOCATION ); + } + + END_TEST; +} + +int utcDaliAccessibilityTextLabelGetName(void) +{ + ToolkitTestApplication application; + + auto label = Toolkit::TextLabel::New(); + DALI_TEST_EQUALS( label.GetName(), "", TEST_LOCATION ); + label.SetName("label"); + DALI_TEST_EQUALS( label.GetName(), "label", TEST_LOCATION ); + + END_TEST; +} + +int utcDaliAccessibilityTextLabelGetText(void) +{ + ToolkitTestApplication application; + + auto label = Dali::Toolkit::TextLabel::New(); + auto q = Dali::Accessibility::Accessible::Get( label ); + auto x = dynamic_cast< Dali::Accessibility::Text* >( q ); + DALI_TEST_CHECK( x ); + if( x ) + { + DALI_TEST_EQUALS( x->GetText( 0, 0 ), "", TEST_LOCATION ); + label.SetProperty( Toolkit::TextField::Property::TEXT, "exemplary_text" ); + DALI_TEST_EQUALS( x->GetText( 0, 9 ), "exemplary", TEST_LOCATION ); + } + + END_TEST; +} + +int utcDaliAccessibilityTextLabelGetCharacterCount(void) +{ + ToolkitTestApplication application; + + auto label = Dali::Toolkit::TextLabel::New(); + auto q = Dali::Accessibility::Accessible::Get( label ); + auto x = dynamic_cast< Dali::Accessibility::Text* >( q ); + DALI_TEST_CHECK( x ); + if( x ) + { + DALI_TEST_EQUALS( x->GetCharacterCount(), 0, TEST_LOCATION ); + label.SetProperty( Toolkit::TextField::Property::TEXT, "field" ); + DALI_TEST_EQUALS( x->GetCharacterCount(), 5, TEST_LOCATION ); + } + + END_TEST; +} + +int utcDaliAccessibilityTextLabelGetTextAtOffset(void) +{ + ToolkitTestApplication application; + + auto label = Dali::Toolkit::TextLabel::New(); + auto q = Dali::Accessibility::Accessible::Get( label ); + auto x = dynamic_cast< Dali::Accessibility::Text* >( q ); + DALI_TEST_CHECK( x ); + if( x ) + { + auto range = x->GetTextAtOffset( 0, Dali::Accessibility::TextBoundary::Line ); + DALI_TEST_EQUALS( range.content, "", TEST_LOCATION ); + DALI_TEST_EQUALS( range.startOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 0, TEST_LOCATION ); + + label.SetProperty( Toolkit::TextLabel::Property::TEXT, "text editor test sentence" ); + range = x->GetTextAtOffset( 5, Dali::Accessibility::TextBoundary::Character ); + DALI_TEST_EQUALS( range.content, "e", TEST_LOCATION ); + DALI_TEST_EQUALS( range.startOffset, 5, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 6, TEST_LOCATION ); + + label.SetProperty( Toolkit::TextLabel::Property::TEXT, "text \n\n\n\n\n\n editor \n\n test sentence" ); + range = x->GetTextAtOffset( 3, Dali::Accessibility::TextBoundary::Word ); + DALI_TEST_EQUALS( range.content, "sentence", TEST_LOCATION ); + DALI_TEST_EQUALS( range.startOffset, 28, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 36, TEST_LOCATION ); + + label.SetProperty( Toolkit::TextLabel::Property::TEXT, "text \n\n\n\n\n\n editor \n\n test sentence" ); + range = x->GetTextAtOffset( 4, Dali::Accessibility::TextBoundary::Word ); + DALI_TEST_EQUALS( range.content, "", TEST_LOCATION ); + DALI_TEST_EQUALS( range.startOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 0, TEST_LOCATION ); + + label.SetProperty( Toolkit::TextLabel::Property::TEXT, "text \n\n\n\n\n\n editor \n\n test sentence" ); + range = x->GetTextAtOffset( 0, Dali::Accessibility::TextBoundary::Line ); + DALI_TEST_EQUALS( range.content, "text \n", TEST_LOCATION ); + DALI_TEST_EQUALS( range.startOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 9, TEST_LOCATION ); + + label.SetProperty( Toolkit::TextLabel::Property::TEXT, "text \n\n\n\n\n\n editor \n\n test sentence" ); + range = x->GetTextAtOffset( 6, Dali::Accessibility::TextBoundary::Line ); + DALI_TEST_EQUALS( range.content, " editor \n", TEST_LOCATION ); + DALI_TEST_EQUALS( range.startOffset, 14, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 24, TEST_LOCATION ); + + label.SetProperty( Toolkit::TextLabel::Property::TEXT, "text \n\n\n\n\n\n editor \n\n test sentence" ); + range = x->GetTextAtOffset( 8, Dali::Accessibility::TextBoundary::Line ); + DALI_TEST_EQUALS( range.content, " test sentence", TEST_LOCATION ); + DALI_TEST_EQUALS( range.startOffset, 25, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 39, TEST_LOCATION ); + } + + END_TEST; +} + +int utcDaliAccessibilityTextLabelRemoveSelection( void ) +{ + ToolkitTestApplication application; + + auto label = Dali::Toolkit::TextLabel::New(); + auto q = Dali::Accessibility::Accessible::Get( label ); + auto x = dynamic_cast< Dali::Accessibility::Text* >( q ); + DALI_TEST_CHECK( x ); + if( x ) + { + auto range = x->GetSelection( 0 ); + DALI_TEST_EQUALS( range.startOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 0, TEST_LOCATION ); + + x->SetSelection( 0, 4, 9 ); + range = x->GetSelection( 0 ); + DALI_TEST_EQUALS( range.startOffset, 4, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 9, TEST_LOCATION ); + + x->RemoveSelection( 0 ); + range = x->GetSelection( 0 ); + DALI_TEST_EQUALS( range.startOffset, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( range.endOffset, 0, TEST_LOCATION ); + } + + END_TEST; +} \ No newline at end of file diff --git a/automated-tests/src/dali-toolkit-accessibility/utc-Dali-Accessibility-Value.cpp b/automated-tests/src/dali-toolkit-accessibility/utc-Dali-Accessibility-Value.cpp new file mode 100644 index 0000000..da8fca2 --- /dev/null +++ b/automated-tests/src/dali-toolkit-accessibility/utc-Dali-Accessibility-Value.cpp @@ -0,0 +1,243 @@ +/** + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// Need to override adaptor classes for toolkit test harness, so include +// test harness headers before dali headers. +#include + +#include +#include + +#include + +using namespace Dali::Accessibility; + +void utc_dali_toolkit_accessibility_value_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_toolkit_accessibility_value_cleanup(void) +{ + test_return_value = TET_PASS; +} + +int utcDaliAccessibilityProgressBarGetMinimum(void) +{ + ToolkitTestApplication application; + + Toolkit::ProgressBar progress_bar = Toolkit::ProgressBar::New(); + auto q = Dali::Accessibility::Accessible::Get( progress_bar ); + auto x = dynamic_cast< Dali::Accessibility::Value* >( q ); + DALI_TEST_CHECK( x ); + DALI_TEST_EQUALS( x->GetMinimum(), 0.0, TEST_LOCATION ); + + END_TEST; +} + +int utcDaliAccessibilityProgressBarGetMaximum(void) +{ + ToolkitTestApplication application; + + Toolkit::ProgressBar progress_bar = Toolkit::ProgressBar::New(); + auto q = Dali::Accessibility::Accessible::Get( progress_bar ); + auto x = dynamic_cast< Dali::Accessibility::Value* >( q ); + DALI_TEST_CHECK( x ); + DALI_TEST_EQUALS( x->GetMaximum(), 1.0, TEST_LOCATION ); + + END_TEST; +} + +int utcDaliAccessibilityProgressBarGetMinimumIncrement(void) +{ + ToolkitTestApplication application; + + Toolkit::ProgressBar progress_bar = Toolkit::ProgressBar::New(); + auto q = Dali::Accessibility::Accessible::Get(progress_bar); + auto x = dynamic_cast< Dali::Accessibility::Value* >( q ); + DALI_TEST_CHECK( x ); + DALI_TEST_EQUALS( x->GetMinimumIncrement(), 0.001, TEST_LOCATION ); + + END_TEST; +} + +int utcDaliAccessibilityProgressBarGetSetCurrent(void) +{ + ToolkitTestApplication application; + + Toolkit::ProgressBar progress_bar = Toolkit::ProgressBar::New(); + auto q = Dali::Accessibility::Accessible::Get(progress_bar); + auto x = dynamic_cast< Dali::Accessibility::Value* >( q ); + DALI_TEST_CHECK( x ); + DALI_TEST_EQUALS( x->GetCurrent(), 0.0, TEST_LOCATION ); + DALI_TEST_EQUALS( x->SetCurrent( 2.0 ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( x->SetCurrent( 0.25 ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( x->GetCurrent(), 0.25, TEST_LOCATION ); + + END_TEST; +} + +int utcDaliAccessibilityScrollBarGetMinimum(void) +{ + ToolkitTestApplication application; + + // Create a source actor that owns the scroll properties required by the scroll bar + Actor sourceActor = Actor::New(); + Stage::GetCurrent().Add( sourceActor ); + + // Register the scroll properties + Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f ); + Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 10.0f ); + Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f ); + Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f ); + + Toolkit::ScrollBar scroll_bar = Toolkit::ScrollBar::New(); + + scroll_bar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize); + + auto q = Dali::Accessibility::Accessible::Get(scroll_bar); + auto x = dynamic_cast< Dali::Accessibility::Value* >( q ); + DALI_TEST_CHECK( x ); + DALI_TEST_EQUALS( x->GetMinimum(), 10.0, TEST_LOCATION ); + + END_TEST; +} + +int utcDaliAccessibilityScrollBarGetMaximum(void) +{ + ToolkitTestApplication application; + + // Create a source actor that owns the scroll properties required by the scroll bar + Actor sourceActor = Actor::New(); + Stage::GetCurrent().Add( sourceActor ); + + // Register the scroll properties + Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f ); + Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f ); + Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f ); + Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f ); + + Toolkit::ScrollBar scroll_bar = Toolkit::ScrollBar::New(); + + scroll_bar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize); + + auto q = Dali::Accessibility::Accessible::Get(scroll_bar); + auto x = dynamic_cast< Dali::Accessibility::Value* >( q ); + DALI_TEST_CHECK( x ); + DALI_TEST_EQUALS( x->GetMaximum(), 100.0, TEST_LOCATION ); + + END_TEST; +} + +int utcDaliAccessibilityScrollBarGetMinimumIncrement(void) +{ + ToolkitTestApplication application; + + Toolkit::ScrollBar scroll_bar = Toolkit::ScrollBar::New(); + auto q = Dali::Accessibility::Accessible::Get(scroll_bar); + auto x = dynamic_cast< Dali::Accessibility::Value* >( q ); + DALI_TEST_CHECK( x ); + DALI_TEST_EQUALS( x->GetMinimumIncrement(), 1.0, TEST_LOCATION ); + + END_TEST; +} + +int utcDaliAccessibilityScrollBarGetSetCurrent(void) +{ + ToolkitTestApplication application; + + // Create a source actor that owns the scroll properties required by the scroll bar + Actor sourceActor = Actor::New(); + Stage::GetCurrent().Add( sourceActor ); + + // Register the scroll properties + Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f ); + Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f ); + Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f ); + Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f ); + + Toolkit::ScrollBar scroll_bar = Toolkit::ScrollBar::New(); + + scroll_bar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize); + + //sourceActor.SetProperty(propertyScrollPosition, 20.0f); + + auto q = Dali::Accessibility::Accessible::Get(scroll_bar); + auto x = dynamic_cast< Dali::Accessibility::Value* >( q ); + DALI_TEST_CHECK( x ); + DALI_TEST_EQUALS( x->GetCurrent(), 0.0, TEST_LOCATION ); + DALI_TEST_EQUALS( x->SetCurrent( 1000.0 ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( x->SetCurrent( 50.0 ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( x->GetCurrent(), 0.0, TEST_LOCATION ); + + END_TEST; +} + +int utcDaliAccessibilitySliderGetMinimum(void) +{ + ToolkitTestApplication application; + + Toolkit::Slider slider = Toolkit::Slider::New(); + auto q = Dali::Accessibility::Accessible::Get(slider); + auto x = dynamic_cast< Dali::Accessibility::Value* >( q ); + DALI_TEST_CHECK( x ); + DALI_TEST_EQUALS( x->GetMinimum(), 0.0, TEST_LOCATION ); + + END_TEST; +} + +int utcDaliAccessibilitySliderGetMaximum(void) +{ + ToolkitTestApplication application; + + Toolkit::Slider slider = Toolkit::Slider::New(); + auto q = Dali::Accessibility::Accessible::Get(slider); + auto x = dynamic_cast< Dali::Accessibility::Value* >( q ); + DALI_TEST_CHECK( x ); + DALI_TEST_EQUALS( x->GetMaximum(), 1.0, TEST_LOCATION ); + + END_TEST; +} + +int utcDaliAccessibilitySliderGetMinimumIncrement(void) +{ + ToolkitTestApplication application; + + Toolkit::Slider slider = Toolkit::Slider::New(); + auto q = Dali::Accessibility::Accessible::Get(slider); + auto x = dynamic_cast< Dali::Accessibility::Value* >( q ); + DALI_TEST_CHECK( x ); + DALI_TEST_EQUALS( x->GetMinimumIncrement(), 0.05, TEST_LOCATION ); + + END_TEST; +} + +int utcDaliAccessibilitySliderGetSetCurrent(void) +{ + ToolkitTestApplication application; + + Toolkit::Slider slider = Toolkit::Slider::New(); + auto q = Dali::Accessibility::Accessible::Get(slider); + auto x = dynamic_cast< Dali::Accessibility::Value* >( q ); + DALI_TEST_CHECK( x ); + DALI_TEST_EQUALS( x->GetCurrent(), 0.0, TEST_LOCATION ); + DALI_TEST_EQUALS( x->SetCurrent( 2.0 ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( x->SetCurrent( 0.25 ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( x->GetCurrent(), 0.25, TEST_LOCATION ); + + END_TEST; +} \ No newline at end of file diff --git a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt index 984e177..cc0b3ba 100755 --- a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt @@ -34,7 +34,6 @@ SET(TC_SOURCES # Append list of test harness files (Won't get parsed for test cases) LIST(APPEND TC_SOURCES ../dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp - ../dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.cpp ../dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp ../dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard.cpp ../dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard-event-notifier.cpp diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Visuals-internal.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Visuals-internal.cpp index 87345ea..1f93f71 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Visuals-internal.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Visuals-internal.cpp @@ -162,7 +162,7 @@ int UtcDaliVisualSetProperties(void) int UtcDaliNPatchBufferGetRedOffsetAndMask(void) { - TestApplication application; + ToolkitTestApplication application; tet_infoline("UtcDaliNPatchBufferGetRedOffsetAndMask"); diff --git a/automated-tests/src/dali-toolkit-styling/CMakeLists.txt b/automated-tests/src/dali-toolkit-styling/CMakeLists.txt index 0b08ff4..f53fdfd 100644 --- a/automated-tests/src/dali-toolkit-styling/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit-styling/CMakeLists.txt @@ -14,7 +14,6 @@ SET(TC_SOURCES LIST(APPEND TC_SOURCES ../dali-toolkit/dali-toolkit-test-utils/test-harness.cpp ../dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp - ../dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.cpp ../dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp ../dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard.cpp ../dali-toolkit/dali-toolkit-test-utils/toolkit-color-controller.cpp diff --git a/automated-tests/src/dali-toolkit-third-party/CMakeLists.txt b/automated-tests/src/dali-toolkit-third-party/CMakeLists.txt index dfbe07f..0d4d2eb 100644 --- a/automated-tests/src/dali-toolkit-third-party/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit-third-party/CMakeLists.txt @@ -12,6 +12,18 @@ SET(TC_SOURCES # Append list of test harness files (Won't get parsed for test cases) LIST(APPEND TC_SOURCES + ../dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp + ../dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard.cpp + ../dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard-event-notifier.cpp + ../dali-toolkit/dali-toolkit-test-utils/toolkit-event-thread-callback.cpp + ../dali-toolkit/dali-toolkit-test-utils/toolkit-environment-variable.cpp + ../dali-toolkit/dali-toolkit-test-utils/toolkit-input-method-context.cpp + ../dali-toolkit/dali-toolkit-test-utils/toolkit-orientation.cpp + ../dali-toolkit/dali-toolkit-test-utils/toolkit-physical-keyboard.cpp + ../dali-toolkit/dali-toolkit-test-utils/toolkit-style-monitor.cpp + ../dali-toolkit/dali-toolkit-test-utils/toolkit-singleton-service.cpp + ../dali-toolkit/dali-toolkit-test-utils/toolkit-timer.cpp + ../dali-toolkit/dali-toolkit-test-utils/toolkit-tts-player.cpp ../dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.cpp ../dali-toolkit/dali-toolkit-test-utils/mesh-builder.cpp ../dali-toolkit/dali-toolkit-test-utils/test-actor-utils.cpp diff --git a/automated-tests/src/dali-toolkit/CMakeLists.txt b/automated-tests/src/dali-toolkit/CMakeLists.txt index 7177d8c..8f2df12 100755 --- a/automated-tests/src/dali-toolkit/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit/CMakeLists.txt @@ -45,7 +45,6 @@ SET(TC_SOURCES utc-Dali-Button.cpp utc-Dali-Control.cpp utc-Dali-ControlImpl.cpp - utc-Dali-AccessibilityManager.cpp utc-Dali-ItemLayout.cpp utc-Dali-ItemView.cpp utc-Dali-KeyboardFocusManager.cpp @@ -74,7 +73,6 @@ SET(TC_SOURCES # Append list of test harness files (Won't get parsed for test cases) LIST(APPEND TC_SOURCES dali-toolkit-test-utils/toolkit-adaptor.cpp - dali-toolkit-test-utils/toolkit-accessibility-adaptor.cpp dali-toolkit-test-utils/toolkit-application.cpp dali-toolkit-test-utils/toolkit-clipboard.cpp dali-toolkit-test-utils/toolkit-clipboard-event-notifier.cpp diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.cpp deleted file mode 100644 index df3e5d5..0000000 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.cpp +++ /dev/null @@ -1,624 +0,0 @@ -/* - * Copyright (c) 2019 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -namespace Adaptor -{ - -/** - * Stub for the AccessibilityAdaptor - */ -class AccessibilityAdaptor : public BaseObject -{ -public: // Creation & Destruction - - static Dali::AccessibilityAdaptor Get(); - - AccessibilityAdaptor(); - ~AccessibilityAdaptor(); - -public: - - // Functions to modify mock returns: - - void MockSetReadPosition( Vector2& position ); - - void SetEnabled(bool enabled) - { - mIsEnabled = enabled; - } - - void SendPanGesture( const AccessibilityGestureEvent& panEvent ); - -public: - - bool IsEnabled() const; - void SetActionHandler(Dali::AccessibilityActionHandler& handler); - void SetGestureHandler(Dali::AccessibilityGestureHandler& handler); - - Vector2 GetReadPosition() const; - - bool HandleActionNextEvent(bool); - bool HandleActionPreviousEvent(bool); - bool HandleActionActivateEvent(); - bool HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain); - bool HandleActionReadNextEvent(bool); - bool HandleActionReadPreviousEvent(bool); - bool HandleActionUpEvent(); - bool HandleActionDownEvent(); - bool HandleActionClearFocusEvent(); - bool HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp); - bool HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp); - bool HandleActionBackEvent(); - bool HandleActionEnableEvent(); - bool HandleActionDisableEvent(); - bool HandleActionScrollUpEvent(); - bool HandleActionScrollDownEvent(); - bool HandleActionPageLeftEvent(); - bool HandleActionPageRightEvent(); - bool HandleActionPageUpEvent(); - bool HandleActionPageDownEvent(); - bool HandleActionMoveToFirstEvent(); - bool HandleActionMoveToLastEvent(); - bool HandleActionReadFromTopEvent(); - bool HandleActionReadFromNextEvent(); - bool HandleActionZoomEvent(); - bool HandleActionReadPauseResumeEvent(); - bool HandleActionStartStopEvent(); - -private: - - bool mIsEnabled; - Dali::AccessibilityActionHandler* mActionHandler; - Dali::AccessibilityGestureHandler* mGestureHandler; - Vector2 mReadPosition; - - static Dali::AccessibilityAdaptor mToolkitAccessibilityAdaptor; -}; - -Dali::AccessibilityAdaptor AccessibilityAdaptor::mToolkitAccessibilityAdaptor; - - -Dali::AccessibilityAdaptor AccessibilityAdaptor::Get() -{ - if( !mToolkitAccessibilityAdaptor ) - { - mToolkitAccessibilityAdaptor = Dali::AccessibilityAdaptor( new Dali::Internal::Adaptor::AccessibilityAdaptor() ); - } - return mToolkitAccessibilityAdaptor; -} - -AccessibilityAdaptor::AccessibilityAdaptor() -: mIsEnabled(false), - mActionHandler(NULL), - mGestureHandler(NULL), - mReadPosition( 0.0f, 0.0f ) -{ -} - -AccessibilityAdaptor::~AccessibilityAdaptor() -{ -} - -Vector2 AccessibilityAdaptor::GetReadPosition() const -{ - return mReadPosition; -} - -void AccessibilityAdaptor::MockSetReadPosition( Vector2& position ) -{ - mReadPosition = position; -} - -bool AccessibilityAdaptor::IsEnabled() const -{ - return mIsEnabled; -} - -void AccessibilityAdaptor::SendPanGesture( const AccessibilityGestureEvent& panEvent ) -{ - mGestureHandler->HandlePanGesture( panEvent ); -} - -void AccessibilityAdaptor::SetActionHandler(Dali::AccessibilityActionHandler& handler) -{ - mActionHandler = &handler; -} - -void AccessibilityAdaptor::SetGestureHandler(Dali::AccessibilityGestureHandler& handler) -{ - mGestureHandler = &handler; -} - -bool AccessibilityAdaptor::HandleActionNextEvent(bool allowEndFeedback) -{ - if( mActionHandler ) - { - return mActionHandler->AccessibilityActionNext( true ); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionPreviousEvent(bool allowEndFeedback) -{ - if( mActionHandler ) - { - return mActionHandler->AccessibilityActionPrevious( true ); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionActivateEvent() -{ - if( mActionHandler ) - { - return mActionHandler->AccessibilityActionActivate(); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain) -{ - if( mActionHandler ) - { - return mActionHandler->AccessibilityActionRead( allowReadAgain ); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionReadNextEvent(bool allowEndFeedback) -{ - if( mActionHandler ) - { - return mActionHandler->AccessibilityActionReadNext( true ); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionReadPreviousEvent(bool allowEndFeedback) -{ - if( mActionHandler ) - { - return mActionHandler->AccessibilityActionReadPrevious( true ); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionUpEvent() -{ - if( mActionHandler ) - { - return mActionHandler->AccessibilityActionUp(); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionDownEvent() -{ - if( mActionHandler ) - { - return mActionHandler->AccessibilityActionDown(); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionClearFocusEvent() -{ - if( mActionHandler ) - { - return mActionHandler->ClearAccessibilityFocus(); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp) -{ - if( mActionHandler ) - { - Dali::TouchEvent touchEvent; - touchEvent.points.push_back( point ); - return mActionHandler->AccessibilityActionScroll( touchEvent ); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp) -{ - if( mActionHandler ) - { - Dali::TouchEvent touchEvent; - touchEvent.points.push_back( point ); - return mActionHandler->AccessibilityActionTouch( touchEvent ); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionBackEvent() -{ - if( mActionHandler ) - { - return mActionHandler->AccessibilityActionBack(); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionEnableEvent() -{ - if( mActionHandler ) - { - return mActionHandler->ChangeAccessibilityStatus(); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionDisableEvent() -{ - if( mActionHandler ) - { - return mActionHandler->ChangeAccessibilityStatus(); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionScrollUpEvent() -{ - if( mActionHandler ) - { - return mActionHandler->AccessibilityActionScrollUp(); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionScrollDownEvent() -{ - if( mActionHandler ) - { - return mActionHandler->AccessibilityActionScrollDown(); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionPageLeftEvent() -{ - if( mActionHandler ) - { - return mActionHandler->AccessibilityActionPageLeft(); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionPageRightEvent() -{ - if( mActionHandler ) - { - return mActionHandler->AccessibilityActionPageRight(); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionPageUpEvent() -{ - if( mActionHandler ) - { - return mActionHandler->AccessibilityActionPageUp(); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionPageDownEvent() -{ - if( mActionHandler ) - { - return mActionHandler->AccessibilityActionPageDown(); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionMoveToFirstEvent() -{ - if( mActionHandler ) - { - return mActionHandler->AccessibilityActionMoveToFirst(); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionMoveToLastEvent() -{ - if( mActionHandler ) - { - return mActionHandler->AccessibilityActionMoveToLast(); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionReadFromTopEvent() -{ - if( mActionHandler ) - { - return mActionHandler->AccessibilityActionReadFromTop(); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionReadFromNextEvent() -{ - if( mActionHandler ) - { - return mActionHandler->AccessibilityActionReadFromNext(); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionZoomEvent() -{ - if( mActionHandler ) - { - return mActionHandler->AccessibilityActionZoom(); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent() -{ - if( mActionHandler ) - { - return mActionHandler->AccessibilityActionReadPauseResume(); - } - return false; -} - -bool AccessibilityAdaptor::HandleActionStartStopEvent() -{ - if( mActionHandler ) - { - return mActionHandler->AccessibilityActionStartStop(); - } - return false; -} - -static Internal::Adaptor::AccessibilityAdaptor& GetImplementation(Dali::AccessibilityAdaptor& adaptor) -{ - BaseObject& handle = adaptor.GetBaseObject(); - return static_cast(handle); -} - -static const Internal::Adaptor::AccessibilityAdaptor& GetImplementation(const Dali::AccessibilityAdaptor& adaptor) -{ - const BaseObject& handle = adaptor.GetBaseObject(); - return static_cast(handle); -} - - -} // namespace Adaptor -} // namespace Internal - -//////////////////////////////////////////////////////////////////////////////////////////////////// - -AccessibilityAdaptor::AccessibilityAdaptor() -{ -} - -AccessibilityAdaptor AccessibilityAdaptor::Get() -{ - return Internal::Adaptor::AccessibilityAdaptor::Get(); -} - -AccessibilityAdaptor::~AccessibilityAdaptor() -{ -} - -// Methods: - -Vector2 AccessibilityAdaptor::GetReadPosition() const -{ - return Internal::Adaptor::GetImplementation(*this).GetReadPosition(); -} - -bool AccessibilityAdaptor::IsEnabled() const -{ - return Internal::Adaptor::GetImplementation(*this).IsEnabled(); -} - -void AccessibilityAdaptor::SetActionHandler(AccessibilityActionHandler& handler) -{ - Internal::Adaptor::GetImplementation(*this).SetActionHandler(handler); -} - -void AccessibilityAdaptor::SetGestureHandler(AccessibilityGestureHandler& handler) -{ - Internal::Adaptor::GetImplementation(*this).SetGestureHandler(handler); -} - -bool AccessibilityAdaptor::HandleActionNextEvent(bool allowEndFeedback) -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionNextEvent(allowEndFeedback); -} - -bool AccessibilityAdaptor::HandleActionPreviousEvent(bool allowEndFeedback) -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionPreviousEvent(allowEndFeedback); -} - -bool AccessibilityAdaptor::HandleActionActivateEvent() -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionActivateEvent(); -} - -bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain) -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionReadEvent( x, y, allowReadAgain ); -} - -bool AccessibilityAdaptor::HandleActionReadNextEvent(bool allowEndFeedback) -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionReadNextEvent(allowEndFeedback); -} - -bool AccessibilityAdaptor::HandleActionReadPreviousEvent(bool allowEndFeedback) -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionReadPreviousEvent(allowEndFeedback); -} - -bool AccessibilityAdaptor::HandleActionUpEvent() -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionUpEvent(); -} - -bool AccessibilityAdaptor::HandleActionDownEvent() -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionDownEvent(); -} - -bool AccessibilityAdaptor::HandleActionClearFocusEvent() -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionClearFocusEvent(); -} - -bool AccessibilityAdaptor::HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp) -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionScrollEvent(point, timeStamp); -} - -bool AccessibilityAdaptor::HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp) -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionTouchEvent(point, timeStamp); -} - -bool AccessibilityAdaptor::HandleActionBackEvent() -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionBackEvent(); -} - -void AccessibilityAdaptor::HandleActionEnableEvent() -{ - Internal::Adaptor::GetImplementation(*this).HandleActionEnableEvent(); -} - -void AccessibilityAdaptor::HandleActionDisableEvent() -{ - Internal::Adaptor::GetImplementation(*this).HandleActionDisableEvent(); -} - -bool AccessibilityAdaptor::HandleActionScrollUpEvent() -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionScrollUpEvent(); -} - -bool AccessibilityAdaptor::HandleActionScrollDownEvent() -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionScrollDownEvent(); -} - -bool AccessibilityAdaptor::HandleActionPageLeftEvent() -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionPageLeftEvent(); -} - -bool AccessibilityAdaptor::HandleActionPageRightEvent() -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionPageRightEvent(); -} - -bool AccessibilityAdaptor::HandleActionPageUpEvent() -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionPageUpEvent(); -} - -bool AccessibilityAdaptor::HandleActionPageDownEvent() -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionPageDownEvent(); -} - -bool AccessibilityAdaptor::HandleActionMoveToFirstEvent() -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionMoveToFirstEvent(); -} - -bool AccessibilityAdaptor::HandleActionMoveToLastEvent() -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionMoveToLastEvent(); -} - -bool AccessibilityAdaptor::HandleActionReadFromTopEvent() -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionReadFromTopEvent(); -} - -bool AccessibilityAdaptor::HandleActionReadFromNextEvent() -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionReadFromNextEvent(); -} - -bool AccessibilityAdaptor::HandleActionZoomEvent() -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionZoomEvent(); -} - -bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent() -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionReadPauseResumeEvent(); -} - -bool AccessibilityAdaptor::HandleActionStartStopEvent() -{ - return Internal::Adaptor::GetImplementation(*this).HandleActionStartStopEvent(); -} - -AccessibilityAdaptor::AccessibilityAdaptor( Internal::Adaptor::AccessibilityAdaptor* adaptor ) -: BaseHandle( adaptor ) -{ -} - -} // namespace Dali - - -namespace Test -{ -namespace AccessibilityAdaptor -{ - -// Mock setup: - -void MockSetReadPosition( Dali::AccessibilityAdaptor adaptor, Dali::Vector2& position ) -{ - Dali::Internal::Adaptor::GetImplementation(adaptor).MockSetReadPosition( position ); -} - -void SetEnabled( Dali::AccessibilityAdaptor adaptor, bool enabled ) -{ - Dali::Internal::Adaptor::GetImplementation(adaptor).SetEnabled(enabled); -} - -void SendPanGesture( Dali::AccessibilityAdaptor adaptor, const Dali::AccessibilityGestureEvent& panEvent ) -{ - Dali::Internal::Adaptor::GetImplementation(adaptor).SendPanGesture( panEvent ); -} - -} // namespace AccessibilityAdaptor -} // namespace Test diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.h deleted file mode 100644 index a463baf..0000000 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef DALI_TEST_TOOLKIT_ACCESSIBILITY_ADAPTOR_H -#define DALI_TEST_TOOLKIT_ACCESSIBILITY_ADAPTOR_H - -/* - * Copyright (c) 2019 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// EXTERNAL INCLUDES -#include -#include - -namespace Test -{ -namespace AccessibilityAdaptor -{ - -void MockSetReadPosition( Dali::AccessibilityAdaptor adaptor, Dali::Vector2& position ); -void SetEnabled( Dali::AccessibilityAdaptor adaptor, bool enabled); -void SendPanGesture( Dali::AccessibilityAdaptor adaptor, const Dali::AccessibilityGestureEvent& panEvent ); - -} // namespace AccessibilityAdaptor -} // namespace Test - -#endif // DALI_TEST_TOOLKIT_ACCESSIBILITY_ADAPTOR_H diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp index bfc2478..6300ddb 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp @@ -31,6 +31,7 @@ #include #include #include +#include namespace Dali { @@ -349,6 +350,24 @@ void Adaptor::SceneCreated() { } +class LogFactory : public LogFactoryInterface +{ +public: + virtual void InstallLogFunction() const + { + Dali::Integration::Log::LogFunction logFunction(&ToolkitTestApplication::LogMessage); + Dali::Integration::Log::InstallLogFunction(logFunction); + } + + LogFactory() + { + } + virtual ~LogFactory() + { + } +}; + +LogFactory* gLogFactory = NULL; const LogFactoryInterface& Adaptor::GetLogFactory() { if( gLogFactory == NULL ) diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-singleton-service.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-singleton-service.cpp index 7ba5ca4..987ddef 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-singleton-service.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-singleton-service.cpp @@ -22,6 +22,7 @@ #include #include #include +#include "toolkit-test-application.h" namespace Dali { @@ -108,9 +109,9 @@ public: return object; } - void SetApplication( Dali::TestApplication& testApplication ) + void SetApplication( Dali::ToolkitTestApplication& ToolkitTestApplication ) { - mTestApplication = &testApplication; + mTestApplication = &ToolkitTestApplication; } private: @@ -145,7 +146,7 @@ private: typedef SingletonContainer::const_iterator SingletonConstIter; SingletonContainer mSingletonContainer; ///< The container to look up singleton by its type name - TestApplication* mTestApplication; + ToolkitTestApplication* mTestApplication; }; } // namespace Adaptor @@ -211,9 +212,9 @@ SingletonService::SingletonService( Internal::Adaptor::SingletonService* singlet namespace Test { -void SetApplication( Dali::SingletonService singletonService, TestApplication& testApplication ) +void SetApplication( Dali::SingletonService singletonService, ToolkitTestApplication& ToolkitTestApplication ) { - GetImplementation( singletonService ).SetApplication( testApplication ); + GetImplementation( singletonService ).SetApplication( ToolkitTestApplication ); } } // Test diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-singleton-service.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-singleton-service.h index 7f57f55..b18ca3f 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-singleton-service.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-singleton-service.h @@ -18,12 +18,19 @@ */ #include -#include "test-application.h" + + +namespace Dali +{ + +class ToolkitTestApplication; + +} namespace Test { -void SetApplication( Dali::SingletonService singletonService, TestApplication& testApplication ); +void SetApplication( Dali::SingletonService singletonService, Dali::ToolkitTestApplication& ToolkitTestApplication ); } // Test diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.cpp index 1ee9219..349642c 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.cpp @@ -39,6 +39,8 @@ ToolkitTestApplication::ToolkitTestApplication( size_t surfaceWidth, size_t surf // Create Core next CreateCore(); + Dali::Accessibility::DBusWrapper::Install(std::unique_ptr(new Dali::Accessibility::TestDBusWrapper())); + // Override Scene creation in TestApplication by creating a window. // The window will create a Scene & surface and set up the scene's surface appropriately. *mMainWindow = Window::New( PositionSize( 0, 0, surfaceWidth, surfaceHeight ), "" ); diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.h index 7dd21b5..7fa39e1 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.h @@ -23,6 +23,14 @@ // INTERNAL INCLUDES #include +#include +#include +#include +#include +#include +#include "test-application.h" + +#undef assert namespace Dali { diff --git a/automated-tests/src/dali-toolkit/utc-Dali-AccessibilityManager.cpp b/automated-tests/src/dali-toolkit/utc-Dali-AccessibilityManager.cpp deleted file mode 100644 index ee6f133..0000000 --- a/automated-tests/src/dali-toolkit/utc-Dali-AccessibilityManager.cpp +++ /dev/null @@ -1,2373 +0,0 @@ -/* - * Copyright (c) 2019 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include - -#include - -#include -#include -#include - -using namespace Dali; -using namespace Toolkit; - - -void utc_dali_toolkit_accessibility_manager_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_toolkit_accessibility_manager_cleanup(void) -{ - test_return_value = TET_PASS; -} - - -namespace -{ - -// Functors to test whether focus changed signal is emitted when the focus is changed -class FocusChangedCallback : public Dali::ConnectionTracker -{ -public: - FocusChangedCallback(bool& signalReceived) - : mSignalVerified(signalReceived), - mOriginalFocusedActor(), - mCurrentFocusedActor() - { - } - - void Callback(Actor originalFocusedActor, Actor currentFocusedActor) - { - tet_infoline("Verifying FocusChangedCallback()"); - - if(originalFocusedActor == mCurrentFocusedActor) - { - mSignalVerified = true; - } - - mOriginalFocusedActor = originalFocusedActor; - mCurrentFocusedActor = currentFocusedActor; - } - - void Reset() - { - mSignalVerified = false; - } - - bool& mSignalVerified; - Actor mOriginalFocusedActor; - Actor mCurrentFocusedActor; -}; - -// Functors to test whether focus overshot signal is emitted when there is no way to move focus further. -class FocusOvershotCallback : public Dali::ConnectionTracker -{ -public: - FocusOvershotCallback(bool& signalReceived) - : mSignalVerified(signalReceived), - mCurrentFocusedActor(), - mFocusOvershotDirection(Toolkit::AccessibilityManager::OVERSHOT_NEXT) - { - } - - void Callback(Actor currentFocusedActor, Toolkit::AccessibilityManager::FocusOvershotDirection direction) - { - tet_infoline("Verifying FocusOvershotCallback()"); - - if(currentFocusedActor == mCurrentFocusedActor && direction == mFocusOvershotDirection) - { - mSignalVerified = true; - } - } - - void Reset() - { - mSignalVerified = false; - } - - bool& mSignalVerified; - Actor mCurrentFocusedActor; - Toolkit::AccessibilityManager::FocusOvershotDirection mFocusOvershotDirection; -}; - -// Functor to test whether focused actor activated signal is emitted. -class FocusedActorActivatedCallback : public Dali::ConnectionTracker -{ -public: - FocusedActorActivatedCallback() - { - } - - void Callback(Actor activatedActor) - { - tet_infoline("Verifying FocusedActorActivatedCallback()"); - } -}; - -} // namespace - - -int UtcDaliAccessibilityManagerGet(void) -{ - ToolkitTestApplication application; - - tet_infoline(" UtcDaliAccessibilityManagerGet"); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK(manager); - - AccessibilityManager newManager = AccessibilityManager::Get(); - DALI_TEST_CHECK(newManager); - - // Check that accessibility manager is a singleton - DALI_TEST_CHECK(manager == newManager); - END_TEST; -} - -int UtcDaliAccessibilityManagerSetAndGetAccessibilityAttribute(void) -{ - ToolkitTestApplication application; - - tet_infoline(" UtcDaliAccessibilityManagerSetAndGetAccessibilityAttribute"); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK(manager); - - Actor actor = Actor::New(); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(actor, AccessibilityManager::ACCESSIBILITY_LABEL) == ""); - - manager.SetAccessibilityAttribute(actor, AccessibilityManager::ACCESSIBILITY_LABEL, "Description"); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(actor, AccessibilityManager::ACCESSIBILITY_LABEL) == "Description"); - - manager.SetAccessibilityAttribute(actor, AccessibilityManager::ACCESSIBILITY_LABEL, "New description"); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(actor, AccessibilityManager::ACCESSIBILITY_LABEL) == "New description"); - END_TEST; -} - -int UtcDaliAccessibilityManagerSetAndGetFocusOrder(void) -{ - ToolkitTestApplication application; - - tet_infoline(" UtcDaliAccessibilityManagerSetAndGetFocusOrder"); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK(manager); - - Actor first = Actor::New(); - Actor second = Actor::New(); - DALI_TEST_CHECK(manager.GetFocusOrder(first) == 0); - DALI_TEST_CHECK(manager.GetFocusOrder(second) == 0); - - // Set the focus order and description for the first actor - manager.SetFocusOrder(first, 1); - manager.SetAccessibilityAttribute(first, AccessibilityManager::ACCESSIBILITY_LABEL, "first"); - DALI_TEST_CHECK(manager.GetFocusOrder(first) == 1); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, AccessibilityManager::ACCESSIBILITY_LABEL) == "first"); - - // Set the focus order and description for the second actor - manager.SetFocusOrder(second, 2); - manager.SetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL, "second"); - DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL) == "second"); - - // check that the focus order of the first actor is changed - manager.SetFocusOrder(first, 2); - DALI_TEST_CHECK(manager.GetFocusOrder(first) == 2); - // make sure the change of focus order doesn't affect the actor's description - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, AccessibilityManager::ACCESSIBILITY_LABEL) == "first"); - - // check that the focus order of the second actor is increased to 3 - DALI_TEST_CHECK(manager.GetFocusOrder(second) == 3); - // make sure the change of focus order doesn't affect the actor's description - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL) == "second"); - - // check that the focus order of the second actor is changed to 1 - manager.SetFocusOrder(second, 1); - DALI_TEST_CHECK(manager.GetFocusOrder(second) == 1); - // make sure the change of focus order doesn't affect the actor's description - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL) == "second"); - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - // Set the focus order and description for the third actor - Actor third = Actor::New(); - manager.SetFocusOrder(third, 1); - manager.SetAccessibilityAttribute(third, AccessibilityManager::ACCESSIBILITY_LABEL, "third"); - DALI_TEST_CHECK(manager.GetFocusOrder(third) == 1); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(third, AccessibilityManager::ACCESSIBILITY_LABEL) == "third"); - - // check that the focus order of the second actor is increased to 2. - DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2); - // make sure the change of focus order doesn't affect the actor's description - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL) == "second"); - - // check that the focus order of the first actor is increased to 3. - DALI_TEST_CHECK(manager.GetFocusOrder(first) == 3); - // make sure the change of focus order doesn't affect the actor's description - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, AccessibilityManager::ACCESSIBILITY_LABEL) == "first"); - END_TEST; -} - -int UtcDaliAccessibilityManagerGenerateNewFocusOrder(void) -{ - ToolkitTestApplication application; - - tet_infoline(" UtcDaliAccessibilityManagerGenerateNewFocusOrder"); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK(manager); - - DALI_TEST_CHECK(1 == manager.GenerateNewFocusOrder()); - DALI_TEST_CHECK(1 == manager.GenerateNewFocusOrder()); - - Actor first = Actor::New(); - Actor second = Actor::New(); - - // Set the focus order for the first actor - manager.SetFocusOrder(first, 1); - manager.SetAccessibilityAttribute(first, AccessibilityManager::ACCESSIBILITY_LABEL, "first"); - DALI_TEST_CHECK(manager.GetFocusOrder(first) == 1); - - //Test for new focus order - DALI_TEST_CHECK(2 == manager.GenerateNewFocusOrder()); - - // Set the focus order for the first actor - manager.SetFocusOrder(second, 2); - manager.SetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL, "first"); - DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2); - END_TEST; -} - -int UtcDaliAccessibilityManagerGetActorByFocusOrder(void) -{ - ToolkitTestApplication application; - - tet_infoline(" UtcDaliAccessibilityManagerGetActorByFocusOrder"); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK(manager); - - // Create the actors and set their focus orders - Actor first = Actor::New(); - manager.SetFocusOrder(first, 1); - - Actor second = Actor::New(); - manager.SetFocusOrder(second, 2); - - Actor third = Actor::New(); - manager.SetFocusOrder(third, 3); - - // Check that we get an empty handle as no actor is added to the stage yet. - DALI_TEST_CHECK(manager.GetActorByFocusOrder(1) == Actor()); - DALI_TEST_CHECK(manager.GetActorByFocusOrder(2) == Actor()); - 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); - - // Check that we get an empty handle because focus order 0 means undefined. - DALI_TEST_CHECK(manager.GetActorByFocusOrder(0) == Actor()); - - // Check that we get correct actors for the specified focus orders - DALI_TEST_CHECK(manager.GetActorByFocusOrder(1) == first); - DALI_TEST_CHECK(manager.GetActorByFocusOrder(2) == second); - DALI_TEST_CHECK(manager.GetActorByFocusOrder(3) == third); - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - // Change the focus order of the third actor to 1 - manager.SetFocusOrder(third, 1); - - // Check that we still get correct actors after changing their focus orders - DALI_TEST_CHECK(manager.GetActorByFocusOrder(1) == third); - DALI_TEST_CHECK(manager.GetActorByFocusOrder(2) == first); - DALI_TEST_CHECK(manager.GetActorByFocusOrder(3) == second); - - // Check that we get an empty handle because no actor has a focus order of 4 - DALI_TEST_CHECK(manager.GetActorByFocusOrder(4) == Actor()); - END_TEST; -} - -int UtcDaliAccessibilityManagerSetAndGetCurrentFocusActor(void) -{ - ToolkitTestApplication application; - - tet_infoline(" UtcDaliAccessibilityManagerSetAndGetCurrentFocusActor"); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK(manager); - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - // Create the first actor and add it to the stage - Actor first = Actor::New(); - manager.SetFocusOrder(first, 1); - Stage::GetCurrent().Add(first); - - // Create the second actor and add it to the stage - Actor second = Actor::New(); - manager.SetFocusOrder(second, 2); - Stage::GetCurrent().Add(second); - - // Create the third actor but don't add it to the stage - Actor third = Actor::New(); - manager.SetFocusOrder(third, 3); - - // Check that no actor is being focused yet. - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor()); - - // Check that it will fail to set focus on an invalid actor - DALI_TEST_CHECK(manager.SetCurrentFocusActor(Actor()) == false); - - // Check that the focus is set on the first 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 it will fail to set focus on the third actor as it's not in the stage - DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false); - - // Add the third actor to the stage - Stage::GetCurrent().Add(third); - - // make the third actor invisible - third.SetVisible(false); - // flush the queue and render once - application.SendNotification(); - application.Render(); - - // Check that it will fail to set focus on the third actor as it's invisible - DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false); - - // Make the third actor visible - third.SetVisible(true); - // flush the queue and render once - application.SendNotification(); - application.Render(); - - // Make the third actor not focusable - Property::Index propertyActorFocusable = third.GetPropertyIndex("focusable"); - third.SetProperty(propertyActorFocusable, false); - // flush the queue and render once - application.SendNotification(); - application.Render(); - - // Check that it will fail to set focus on the third actor as it's not focusable - DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false); - - // Make the third actor focusable - third.SetProperty(propertyActorFocusable, true); - // flush the queue and render once - application.SendNotification(); - application.Render(); - - // Check that the focus is successfully moved to the third actor - DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true); - - // Make the current focused actor to be not focusable by setting its focus order to be 0 - manager.SetFocusOrder(third, 0); - - // Check that the focus is automatically cleared - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor()); - - // Set the focus order of the third actor again - manager.SetFocusOrder(third, 3); - - // Check that the third actor can be focused successfully now - DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true); - END_TEST; -} - -int UtcDaliAccessibilityManagerGetCurrentFocusGroup(void) -{ - ToolkitTestApplication application; - - tet_infoline(" UtcDaliAccessibilityManagerGetCurrentFocusGroup"); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK(manager); - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - // Create an actor with two child actors and add it to the stage - Actor parent = Actor::New(); - Actor firstChild = Actor::New(); - Actor secondChild = Actor::New(); - parent.Add(firstChild); - parent.Add(secondChild); - Stage::GetCurrent().Add(parent); - - // Create three actors and add them as the children of the first child actor - Actor firstGrandChild = Actor::New(); - Actor secondGrandChild = Actor::New(); - Actor thirdGrandChild = Actor::New(); - firstChild.Add(firstGrandChild); - firstChild.Add(secondGrandChild); - firstChild.Add(thirdGrandChild); - - // Set focus order to the actors - manager.SetFocusOrder(parent, 1); - manager.SetFocusOrder(firstChild, 2); - manager.SetFocusOrder(firstGrandChild, 3); - manager.SetFocusOrder(secondGrandChild, 4); - manager.SetFocusOrder(thirdGrandChild, 5); - manager.SetFocusOrder(secondChild, 6); - - // Set the parent and the first child actor as focus groups - manager.SetFocusGroup(parent, true); - DALI_TEST_CHECK(manager.IsFocusGroup(parent) == true); - - // Set focus to the first grand child actor - DALI_TEST_CHECK(manager.SetCurrentFocusActor(firstGrandChild) == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild); - - // The current focus group should be the parent, As it is the immediate parent which is also a focus group. - DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == parent); - - manager.SetFocusGroup(firstChild, true); - DALI_TEST_CHECK(manager.IsFocusGroup(firstChild) == true); - - // The current focus group should be the firstChild, As it is the immediate parent which is also a focus group. - DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == firstChild); - - manager.SetFocusGroup(firstGrandChild, true); - DALI_TEST_CHECK(manager.IsFocusGroup(firstGrandChild) == true); - - // The current focus group should be itself, As it is also a focus group. - DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == firstGrandChild); - - // Set focus to the second grand child actor - DALI_TEST_CHECK(manager.SetCurrentFocusActor(secondGrandChild) == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondGrandChild); - - // The current focus group should be the firstChild, As it is the immediate parent which is also a - // focus group for the current focus actor. - DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == firstChild); - - END_TEST; -} - -int UtcDaliAccessibilityManagerGetCurrentFocusOrder(void) -{ - ToolkitTestApplication application; - - tet_infoline(" UtcDaliAccessibilityManagerGetCurrentFocusOrder"); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK(manager); - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - Actor first = Actor::New(); - Stage::GetCurrent().Add(first); - - Actor second = Actor::New(); - Stage::GetCurrent().Add(second); - - Actor third = Actor::New(); - Stage::GetCurrent().Add(third); - - // Set the focus order and description for the first actor - manager.SetFocusOrder(first, 1); - manager.SetAccessibilityAttribute(first, AccessibilityManager::ACCESSIBILITY_LABEL, "first"); - DALI_TEST_CHECK(manager.GetFocusOrder(first) == 1); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, AccessibilityManager::ACCESSIBILITY_LABEL) == "first"); - - // Set the focus order and description for the second actor - manager.SetFocusOrder(second, 2); - manager.SetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL, "second"); - DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL) == "second"); - - // Set the focus order and description for the second actor - manager.SetFocusOrder(third, 3); - manager.SetAccessibilityAttribute(third, AccessibilityManager::ACCESSIBILITY_LABEL, "third"); - DALI_TEST_CHECK(manager.GetFocusOrder(third) == 3); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(third, AccessibilityManager::ACCESSIBILITY_LABEL) == "third"); - - // Check that no actor is being focused yet. - DALI_TEST_CHECK(manager.GetCurrentFocusOrder() == 0); - - // Set the focus on the first actor and test - DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true); - DALI_TEST_CHECK(manager.GetCurrentFocusOrder() == 1); - - // Move the focus forward to the second actor and test - manager.MoveFocusForward(); - DALI_TEST_CHECK(manager.GetCurrentFocusOrder() == 2); - - // Move the focus forward to the third actor and test - manager.MoveFocusForward(); - DALI_TEST_CHECK(manager.GetCurrentFocusOrder() == 3); - - // Clear focus and test - manager.ClearFocus(); - DALI_TEST_CHECK(manager.GetCurrentFocusOrder() == 0); - END_TEST; -} - -int UtcDaliAccessibilityManagerMoveFocusForward(void) -{ - ToolkitTestApplication application; - - tet_infoline(" UtcDaliAccessibilityManagerMoveFocusForward"); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK(manager); - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - Actor first = Actor::New(); - Stage::GetCurrent().Add(first); - - Actor second = Actor::New(); - Stage::GetCurrent().Add(second); - - Actor third = Actor::New(); - Stage::GetCurrent().Add(third); - - // Set the focus order and description for the first actor - manager.SetFocusOrder(first, 1); - manager.SetAccessibilityAttribute(first, AccessibilityManager::ACCESSIBILITY_LABEL, "first"); - DALI_TEST_CHECK(manager.GetFocusOrder(first) == 1); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, AccessibilityManager::ACCESSIBILITY_LABEL) == "first"); - - // Set the focus order and description for the second actor - manager.SetFocusOrder(second, 2); - manager.SetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL, "second"); - DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL) == "second"); - - // Set the focus order and description for the second actor - manager.SetFocusOrder(third, 3); - manager.SetAccessibilityAttribute(third, AccessibilityManager::ACCESSIBILITY_LABEL, "third"); - DALI_TEST_CHECK(manager.GetFocusOrder(third) == 3); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(third, AccessibilityManager::ACCESSIBILITY_LABEL) == "third"); - - // Check that no actor is being focused yet. - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor()); - - // Set the focus on the first actor - DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "first"); - - // Test the non-wrapped move first - manager.SetWrapMode(false); - DALI_TEST_CHECK(manager.GetWrapMode() == false); - - // Move the focus forward to the second actor - manager.MoveFocusForward(); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "second"); - - // Move the focus forward to the third actor - manager.MoveFocusForward(); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "third"); - - // Check that it will fail to move the focus forward again as the third actor is the last - // focusable actor in the focus chain - manager.MoveFocusForward(); - // The focus should still be set on the third actor - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "third"); - - // Now test the wrapped move - manager.SetWrapMode(true); - DALI_TEST_CHECK(manager.GetWrapMode() == true); - - // Move the focus forward recursively and this time the first actor should be focused - manager.MoveFocusForward(); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "first"); - - // Make the second actor not focusable - Property::Index propertyActorFocusable = second.GetPropertyIndex("focusable"); - second.SetProperty(propertyActorFocusable, false); - // flush the queue and render once - application.SendNotification(); - application.Render(); - - // Move the focus forward and check that the second actor should be skipped and - // the third actor should be focused now. - manager.MoveFocusForward(); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "third"); - - // Make the first actor invisible - first.SetVisible(false); - // flush the queue and render once - application.SendNotification(); - application.Render(); - - // Move the focus forward and check that the first actor should be skipped as it's - // invisible and the second actor should also be skipped as it's not focusable, - // so the focus will still be on the third actor - manager.MoveFocusForward(); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third); - 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); - // flush the queue and render once - application.SendNotification(); - application.Render(); - - // Check that the focus move is failed as all the three actors can not be focused - manager.MoveFocusForward(); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "third"); - END_TEST; -} - -int UtcDaliAccessibilityManagerMoveFocusBackward(void) -{ - ToolkitTestApplication application; - - tet_infoline(" UtcDaliAccessibilityManagerMoveFocusBackward"); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK(manager); - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - Actor first = Actor::New(); - Stage::GetCurrent().Add(first); - - Actor second = Actor::New(); - Stage::GetCurrent().Add(second); - - Actor third = Actor::New(); - Stage::GetCurrent().Add(third); - - // Set the focus order and description for the first actor - manager.SetFocusOrder(first, 1); - manager.SetAccessibilityAttribute(first, AccessibilityManager::ACCESSIBILITY_LABEL, "first"); - DALI_TEST_CHECK(manager.GetFocusOrder(first) == 1); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, AccessibilityManager::ACCESSIBILITY_LABEL) == "first"); - - // Set the focus order and description for the second actor - manager.SetFocusOrder(second, 2); - manager.SetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL, "second"); - DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, AccessibilityManager::ACCESSIBILITY_LABEL) == "second"); - - // Set the focus order and description for the second actor - manager.SetFocusOrder(third, 3); - manager.SetAccessibilityAttribute(third, AccessibilityManager::ACCESSIBILITY_LABEL, "third"); - DALI_TEST_CHECK(manager.GetFocusOrder(third) == 3); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(third, AccessibilityManager::ACCESSIBILITY_LABEL) == "third"); - - // Check that no actor is being focused yet. - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor()); - - // Set the focus on the third actor - DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "third"); - - // Test the non-wrapped move first - manager.SetWrapMode(false); - DALI_TEST_CHECK(manager.GetWrapMode() == false); - - // Move the focus backward to the second actor - manager.MoveFocusBackward(); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "second"); - - // Move the focus backward to the first actor - manager.MoveFocusBackward(); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "first"); - - // Check that it will fail to move the focus backward again as the first actor is the first - // focusable actor in the focus chain - manager.MoveFocusBackward(); - // The focus should still be set on the first actor - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "first"); - - // Now test the wrapped move - manager.SetWrapMode(true); - DALI_TEST_CHECK(manager.GetWrapMode() == true); - - // Move the focus backward recursively and this time the third actor should be focused - manager.MoveFocusBackward(); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "third"); - - // Make the second actor not focusable - Property::Index propertyActorFocusable = second.GetPropertyIndex("focusable"); - second.SetProperty(propertyActorFocusable, false); - // flush the queue and render once - application.SendNotification(); - application.Render(); - - // Move the focus backward and check that the second actor should be skipped and - // the first actor should be focused now. - manager.MoveFocusBackward(); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "first"); - - // Make the third actor invisible - third.SetVisible(false); - // flush the queue and render once - application.SendNotification(); - application.Render(); - - // Move the focus backward and check that the third actor should be skipped as it's - // invisible and the second actor should also be skipped as it's not focusable, - // so the focus will still be on the first actor - manager.MoveFocusBackward(); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first); - 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); - // flush the queue and render once - application.SendNotification(); - application.Render(); - - // Check that the focus move is failed as all the three actors can not be focused - manager.MoveFocusBackward(); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first); - DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityManager::ACCESSIBILITY_LABEL) == "first"); - END_TEST; -} - -int UtcDaliAccessibilityManagerClearFocus(void) -{ - ToolkitTestApplication application; - - tet_infoline(" UtcDaliAccessibilityManagerClearFocus"); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK(manager); - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - // Create the first actor and add it to the stage - Actor first = Actor::New(); - manager.SetFocusOrder(first, 1); - Stage::GetCurrent().Add(first); - - // Create the second actor and add it to the stage - Actor second = Actor::New(); - manager.SetFocusOrder(second, 2); - Stage::GetCurrent().Add(second); - - // Check that no actor is being focused yet. - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor()); - - // Check that the focus is set on the first 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); - - // Clear the focus - manager.ClearFocus(); - - // Check that no actor is being focused now. - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor()); - END_TEST; -} - -int UtcDaliAccessibilityManagerReset(void) -{ - ToolkitTestApplication application; - - tet_infoline(" UtcDaliAccessibilityManagerReset"); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK(manager); - - // Create the first actor and add it to the stage - Actor first = Actor::New(); - manager.SetFocusOrder(first, 1); - Stage::GetCurrent().Add(first); - - // Create the second actor and add it to the stage - Actor second = Actor::New(); - manager.SetFocusOrder(second, 2); - Stage::GetCurrent().Add(second); - - // Check that no actor is being focused yet. - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor()); - - // Check that the focus is set on the first 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); - - // Clear the focus - manager.Reset(); - - // Check that no actor is being focused now and the focus order of actors have been cleared - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor()); - DALI_TEST_CHECK(manager.GetFocusOrder(first) == 0); - DALI_TEST_CHECK(manager.GetFocusOrder(first) == 0); - END_TEST; -} - -int UtcDaliAccessibilityManagerFocusGroup(void) -{ - ToolkitTestApplication application; - - tet_infoline(" UtcDaliAccessibilityManagerFocusGroup"); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK(manager); - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - // Create an actor with two child actors and add it to the stage - Actor parent = Actor::New(); - Actor firstChild = Actor::New(); - Actor secondChild = Actor::New(); - parent.Add(firstChild); - parent.Add(secondChild); - Stage::GetCurrent().Add(parent); - - // Create three actors and add them as the children of the first child actor - Actor firstGrandChild = Actor::New(); - Actor secondGrandChild = Actor::New(); - Actor thirdGrandChild = Actor::New(); - firstChild.Add(firstGrandChild); - firstChild.Add(secondGrandChild); - firstChild.Add(thirdGrandChild); - - // Set focus order to the actors - manager.SetFocusOrder(parent, 1); - manager.SetFocusOrder(firstChild, 2); - manager.SetFocusOrder(firstGrandChild, 3); - manager.SetFocusOrder(secondGrandChild, 4); - manager.SetFocusOrder(thirdGrandChild, 5); - manager.SetFocusOrder(secondChild, 6); - - // Set the parent and the first child actor as focus groups - manager.SetFocusGroup(parent, true); - DALI_TEST_CHECK(manager.IsFocusGroup(parent) == true); - - // The focus group of the parent should be itself, as it is set to be a focus group. - DALI_TEST_CHECK(manager.GetFocusGroup(parent) == parent); - - // The focus group of the firstChild should be its parent, as it is the immediate parent which is also a group. - DALI_TEST_CHECK(manager.GetFocusGroup(firstChild) == parent); - - manager.SetFocusGroup(firstChild, true); - DALI_TEST_CHECK(manager.IsFocusGroup(firstChild) == true); - - // The focus group of the firstChild should be itself, as it is set to be a focus group now. - DALI_TEST_CHECK(manager.GetFocusGroup(firstChild) == firstChild); - - // Enable wrap mode for focus movement. - manager.SetWrapMode(true); - DALI_TEST_CHECK(manager.GetWrapMode() == true); - - // Check that no actor is being focused yet. - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor()); - - // Check that the focus is set on the parent actor. - DALI_TEST_CHECK(manager.SetCurrentFocusActor(parent) == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == parent); - - // Check that group mode is disabled. - DALI_TEST_CHECK(manager.GetGroupMode() == false); - - // Check that the focus movement is wrapped as normal. - DALI_TEST_CHECK(manager.MoveFocusForward() == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstChild); - DALI_TEST_CHECK(manager.MoveFocusForward() == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild); - DALI_TEST_CHECK(manager.MoveFocusForward() == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondGrandChild); - DALI_TEST_CHECK(manager.MoveFocusForward() == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == thirdGrandChild); - DALI_TEST_CHECK(manager.MoveFocusForward() == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondChild); - DALI_TEST_CHECK(manager.MoveFocusForward() == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == parent); - DALI_TEST_CHECK(manager.MoveFocusForward() == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstChild); - DALI_TEST_CHECK(manager.MoveFocusForward() == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild); - - // Enable the group mode. - manager.SetGroupMode(true); - DALI_TEST_CHECK(manager.GetGroupMode() == true); - - // Check that the focus movement is now limited to the current focus group. - DALI_TEST_CHECK(manager.MoveFocusForward() == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondGrandChild); - DALI_TEST_CHECK(manager.MoveFocusForward() == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == thirdGrandChild); - DALI_TEST_CHECK(manager.MoveFocusForward() == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstChild); - DALI_TEST_CHECK(manager.MoveFocusForward() == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild); - END_TEST; -} - -int UtcDaliAccessibilityManagerSetAndGetFocusIndicator(void) -{ - ToolkitTestApplication application; - - tet_infoline(" UtcDaliAccessibilityManagerSetAndGetFocusIndicator"); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK(manager); - - Actor defaultFocusIndicatorActor = manager.GetFocusIndicatorActor(); - DALI_TEST_CHECK(defaultFocusIndicatorActor); - - Actor newFocusIndicatorActor = Actor::New(); - manager.SetFocusIndicatorActor(newFocusIndicatorActor); - DALI_TEST_CHECK(manager.GetFocusIndicatorActor() == newFocusIndicatorActor); - 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(); - Stage::GetCurrent().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; - - tet_infoline(" UtcDaliAccessibilityManagerSignalFocusChanged"); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK(manager); - - bool signalVerified = false; - FocusChangedCallback callback(signalVerified); - manager.FocusChangedSignal().Connect( &callback, &FocusChangedCallback::Callback ); - - // Create the first actor and add it to the stage - Actor first = Actor::New(); - manager.SetFocusOrder(first, 1); - Stage::GetCurrent().Add(first); - - // Create the second actor and add it to the stage - Actor second = Actor::New(); - manager.SetFocusOrder(second, 2); - Stage::GetCurrent().Add(second); - - // Check that no actor is being focused yet. - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor()); - - // Check that the focus is set on the first actor - DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first); - DALI_TEST_CHECK(callback.mSignalVerified); - callback.Reset(); - - // Check that the focus is set on the second actor - DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second); - DALI_TEST_CHECK(callback.mSignalVerified); - callback.Reset(); - - // Clear the focus - manager.ClearFocus(); - - // Check that no actor is being focused now. - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor()); - DALI_TEST_CHECK(callback.mSignalVerified); - END_TEST; -} - -int UtcDaliAccessibilityManagerSignalFocusOvershot(void) -{ - ToolkitTestApplication application; - - tet_infoline(" UtcDaliAccessibilityManagerSignalFocusOvershot"); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK(manager); - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - bool signalVerified = false; - FocusOvershotCallback callback(signalVerified); - manager.FocusOvershotSignal().Connect(&callback, &FocusOvershotCallback::Callback); - - // Create the first actor and add it to the stage - Actor first = Actor::New(); - manager.SetFocusOrder(first, 1); - Stage::GetCurrent().Add(first); - - // Create the second actor and add it to the stage - Actor second = Actor::New(); - manager.SetFocusOrder(second, 2); - Stage::GetCurrent().Add(second); - - // Check that the wrap mode is disabled - DALI_TEST_CHECK(manager.GetWrapMode() == false); - - // Check that the focus is set on the first actor - DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first); - - // Check that the focus is moved to the second actor successfully. - DALI_TEST_CHECK(manager.MoveFocusForward() == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second); - - // Check that the forward focus movement is overshot. - callback.mCurrentFocusedActor = second; - callback.mFocusOvershotDirection = Toolkit::AccessibilityManager::OVERSHOT_NEXT; - DALI_TEST_CHECK(manager.MoveFocusForward() == false); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second); - DALI_TEST_CHECK(signalVerified); - callback.Reset(); - - // Enable the wrap mode - manager.SetWrapMode(true); - DALI_TEST_CHECK(manager.GetWrapMode() == true); - - // Check that the forward focus movement is wrapped and no overshot happens. - DALI_TEST_CHECK(manager.MoveFocusForward() == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first); - DALI_TEST_CHECK(signalVerified == false); - - // Disable the wrap mode - manager.SetWrapMode(false); - DALI_TEST_CHECK(manager.GetWrapMode() == false); - - // Check that the backward focus movement is overshot. - callback.mCurrentFocusedActor = first; - callback.mFocusOvershotDirection = Toolkit::AccessibilityManager::OVERSHOT_PREVIOUS; - DALI_TEST_CHECK(manager.MoveFocusBackward() == false); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first); - DALI_TEST_CHECK(signalVerified); - END_TEST; -} - -int UtcDaliAccessibilityManagerSignalFocusedActorActivated(void) -{ - ToolkitTestApplication application; - - tet_infoline(" UtcDaliAccessibilityManagerSignalFocusedActorActivated"); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK(manager); - - FocusedActorActivatedCallback callback; - manager.FocusedActorActivatedSignal().Connect(&callback, &FocusedActorActivatedCallback::Callback); - DALI_TEST_CHECK(true); - - END_TEST; -} - -// Note: No negative test for GetReadPosition as it will always return something. -int UtcDaliAccessibilityManagerGetReadPositionP(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliAccessibilityManagerGetReadPositionP"); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - Vector2 readPosition( manager.GetReadPosition() ); - DALI_TEST_EQUALS( readPosition.x, 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION ); - DALI_TEST_EQUALS( readPosition.y, 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION ); - - END_TEST; -} - -// Functor to test if an accessibility signal has been called. -class AccessibilityManagerSignalHandler : public Dali::ConnectionTracker -{ -public: - AccessibilityManagerSignalHandler() : - mCalls( 0 ) - { - } - - bool Callback( AccessibilityManager& accessibilityManager ) - { - mCalls++; - tet_infoline( "Signal called" ); - return true; - } - - unsigned int GetCalls() const - { - return mCalls; - } - -private: - unsigned int mCalls; ///< Keeps track of how many times the signal has been called. -}; - -int UtcDaliAccessibilityManagerStatusChangedSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerStatusChangedSignalP" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.StatusChangedSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - // Cause a state change. - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionEnableEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerStatusChangedSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerStatusChangedSignalN" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.StatusChangedSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionNextSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionNextSignalP" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionNextSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionNextEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionNextSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionNextSignalN" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionNextSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionPreviousSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionPreviousSignalP" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionPreviousSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionPreviousEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionPreviousSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionPreviousSignalN" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionPreviousSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionActivateSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionActivateSignalP" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - Dali::Toolkit::PushButton button = Dali::Toolkit::PushButton::New(); - button.SetSize(480, 800); - Stage::GetCurrent().Add(button); - manager.SetFocusOrder( button, 1 ); - manager.SetCurrentFocusActor( button ); - - manager.ActionActivateSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionActivateEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionActivateSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionActivateSignalN" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionActivateSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionReadSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionReadSignalP" ); - - AccessibilityManagerSignalHandler callback; - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionReadSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionReadEvent( 100.0f, 200.0f, true ); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionReadSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionReadSignalN" ); - - AccessibilityManagerSignalHandler callback; - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionReadSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionOverSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionOverSignalP" ); - - AccessibilityManagerSignalHandler callback; - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionOverSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - // Note that the ActionOverSignal is provoked by a read even when "allow read again" is set to false. - accessibilityAdaptor.HandleActionReadEvent( 100.0f, 200.0f, false ); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionOverSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionOverSignalN" ); - - AccessibilityManagerSignalHandler callback; - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionOverSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionReadNextSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionReadNextSignalP" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionReadNextSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionReadNextEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionReadNextSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionReadNextSignalN" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionReadNextSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionReadPreviousSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionReadPreviousSignalP" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionReadPreviousSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionReadPreviousEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionReadPreviousSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionReadPreviousSignalN" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionReadPreviousSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionUpSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionUpSignalP" ); - - AccessibilityManagerSignalHandler callback; - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accessibilityAdaptor, true ); - accessibilityAdaptor.HandleActionEnableEvent(); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionUpSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - DummyControl dummyControl = DummyControl::New(true); - dummyControl.SetSize(480, 800); - manager.SetFocusOrder( dummyControl, 1 ); - Stage::GetCurrent().Add( dummyControl ); - manager.SetCurrentFocusActor( dummyControl ); - - accessibilityAdaptor.HandleActionUpEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionUpSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionUpSignalN" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionUpSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionDownSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionDownSignalP" ); - - AccessibilityManagerSignalHandler callback; - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accessibilityAdaptor, true ); - accessibilityAdaptor.HandleActionEnableEvent(); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionDownSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::Toolkit::PushButton button = Dali::Toolkit::PushButton::New(); - button.SetSize(480, 800); - Stage::GetCurrent().Add(button); - manager.SetFocusOrder( button, 1 ); - manager.SetCurrentFocusActor( button ); - - accessibilityAdaptor.HandleActionDownEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionDownSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionDownSignalN" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionDownSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionClearFocusSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionClearFocusSignalP" ); - - AccessibilityManagerSignalHandler callback; - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionClearFocusSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionClearFocusEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionClearFocusSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionClearFocusSignalN" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionClearFocusSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionBackSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionBackSignalP" ); - - AccessibilityManagerSignalHandler callback; - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionBackSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionBackEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionBackSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionBackSignalN" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionBackSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionScrollUpSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionScrollUpSignalP" ); - - AccessibilityManagerSignalHandler callback; - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionScrollUpSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionScrollUpEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionScrollUpSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionScrollUpSignalN" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionScrollUpSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionScrollDownSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionScrollDownSignalP" ); - - AccessibilityManagerSignalHandler callback; - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionScrollDownSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionScrollDownEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionScrollDownSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionScrollDownSignalN" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionScrollDownSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionPageLeftSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionPageLeftSignalP" ); - - AccessibilityManagerSignalHandler callback; - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionPageLeftSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionPageLeftEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionPageLeftSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionPageLeftSignalN" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionPageLeftSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionPageRightSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionPageRightSignalP" ); - - AccessibilityManagerSignalHandler callback; - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionPageRightSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionPageRightEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionPageRightSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionPageRightSignalN" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionPageRightSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionPageUpSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionPageUpSignalP" ); - - AccessibilityManagerSignalHandler callback; - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionPageUpSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionPageUpEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionPageUpSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionPageUpSignalN" ); - - AccessibilityManagerSignalHandler callback; - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionPageUpSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionPageDownSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionPageDownSignalP" ); - - AccessibilityManagerSignalHandler callback; - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionPageDownSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionPageDownEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionPageDownSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionPageDownSignalN" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionPageDownSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionMoveToFirstSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionMoveToFirstSignalP" ); - - AccessibilityManagerSignalHandler callback; - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionMoveToFirstSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionMoveToFirstEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - - -int UtcDaliAccessibilityManagerActionMoveToFirstSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionMoveToFirstSignalN" ); - - AccessibilityManagerSignalHandler callback; - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionMoveToFirstSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionMoveToLastSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionMoveToLastSignalP" ); - - AccessibilityManagerSignalHandler callback; - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionMoveToLastSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionMoveToLastEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionMoveToLastSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionMoveToLastSignalN" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionMoveToLastSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionReadFromTopSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionReadFromTopSignalP" ); - - AccessibilityManagerSignalHandler callback; - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionReadFromTopSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionReadFromTopEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionReadFromTopSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionReadFromTopSignalN" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionReadFromTopSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionReadFromNextSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionReadFromNextSignalP" ); - - AccessibilityManagerSignalHandler callback; - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionReadFromNextSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionReadFromNextEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionReadFromNextSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionReadFromNextSignalN" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionReadFromNextSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionZoomSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionZoomSignalP" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - Dali::Toolkit::PushButton button = Dali::Toolkit::PushButton::New(); - button.SetSize(480, 800); - Stage::GetCurrent().Add(button); - manager.SetFocusOrder( button, 1 ); - manager.SetCurrentFocusActor( button ); - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - manager.ActionZoomSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionZoomEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionZoomSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionZoomSignalN" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionZoomSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, 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; - tet_infoline( " UtcDaliAccessibilityManagerActionReadPauseResumeSignalP" ); - - AccessibilityManagerSignalHandler callback; - - Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get(); - Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true ); - accAdaptor.HandleActionEnableEvent(); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionReadPauseResumeSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionReadPauseResumeEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionReadPauseResumeSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionReadPauseResumeSignalN" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionReadPauseResumeSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionStartStopSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionStartStopSignalP" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionStartStopSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - accessibilityAdaptor.HandleActionStartStopEvent(); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionStartStopSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionStartStopSignalN" ); - - AccessibilityManagerSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionStartStopSignal().Connect( &callback, &AccessibilityManagerSignalHandler::Callback ); - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -// Functor to test if a accessibility scroll signal has been called. -class AccessibilityManagerScrollSignalHandler : public Dali::ConnectionTracker -{ -public: - AccessibilityManagerScrollSignalHandler() : - mCalls( 0 ) - { - } - - bool Callback( AccessibilityManager& accessibilityManager, const Dali::TouchEvent& touchEvent ) - { - mCalls++; - mTouchEvent = touchEvent; - tet_infoline( "Signal called" ); - return true; - } - - unsigned int GetCalls() const - { - return mCalls; - } - - const Dali::TouchEvent& GetTouchEvent() const - { - return mTouchEvent; - } - -private: - unsigned int mCalls; ///< Keeps track of how many times the signal has been called. - Dali::TouchEvent mTouchEvent; ///< Stores the last touch event received. -}; - -int UtcDaliAccessibilityManagerActionScrollSignalP(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionScrollSignalP" ); - - AccessibilityManagerScrollSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionScrollSignal().Connect( &callback, &AccessibilityManagerScrollSignalHandler::Callback ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - - TouchPoint point( 0, TouchPoint::Started, 100.0f, 200.0f ); - accessibilityAdaptor.HandleActionScrollEvent( point, 0u ); - - DALI_TEST_EQUALS( callback.GetCalls(), 1u, TEST_LOCATION ); - - const TouchEvent& signalTouchEvent = callback.GetTouchEvent(); - DALI_TEST_EQUALS( signalTouchEvent.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 ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionScrollSignalN(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionScrollSignalN" ); - - AccessibilityManagerScrollSignalHandler callback; - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - manager.ActionScrollSignal().Connect( &callback, &AccessibilityManagerScrollSignalHandler::Callback ); - - DALI_TEST_EQUALS( callback.GetCalls(), 0u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliAccessibilityManagerActionTouch(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerActionTouch" ); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - - DummyControl dummyControl = DummyControl::New(true); - Impl::DummyControl& dummyImpl = static_cast(dummyControl.GetImplementation()); - dummyControl.SetSize(480, 800); - manager.SetFocusOrder( dummyControl, 1 ); - Stage::GetCurrent().Add( dummyControl ); - manager.SetCurrentFocusActor( dummyControl ); - - TouchPoint point( 0, TouchPoint::Started, 100.0f, 200.0f ); - accessibilityAdaptor.HandleActionTouchEvent( point, 0u ); - - DALI_TEST_CHECK( dummyImpl.onAccTouchedCalled ); - - END_TEST; -} - - -int UtcDaliAccessibilityManagerHandlePanGesture(void) -{ - // Pan gesture sent from adaptor to manager via AccessibilityGestureHandler - // Adaptor.SetGestureHandler is called in Initialize (check it's the toolkit version) - ToolkitTestApplication application; - tet_infoline( " UtcDaliAccessibilityManagerHandlePanGesture" ); - - AccessibilityManager manager = AccessibilityManager::Get(); - DALI_TEST_CHECK( manager ); - - Dali::AccessibilityAdaptor accessibilityAdaptor = Dali::AccessibilityAdaptor::Get(); - DummyControl dummyControl = DummyControl::New(true); - dummyControl.SetSize(480, 800); - Stage::GetCurrent().Add( dummyControl ); - - AccessibilityGestureEvent panGestureEvent(AccessibilityGestureEvent::Started); - panGestureEvent.previousPosition = Vector2(0.f, 0.f); - panGestureEvent.currentPosition = Vector2(100.f, 0.f); - panGestureEvent.timeDelta = 16; - panGestureEvent.numberOfTouches = 1; - - Test::AccessibilityAdaptor::SendPanGesture( accessibilityAdaptor, panGestureEvent ); - - 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 = AccessibilityGestureEvent::Finished; - panGestureEvent.previousPosition = Vector2(200.f, 0.f); - panGestureEvent.currentPosition = Vector2(300.f, 0.f); - Test::AccessibilityAdaptor::SendPanGesture( accessibilityAdaptor, panGestureEvent ); - - - END_TEST; -} - -// Methods missing coverage: -// IsActorFocusableFunction -// DoActivate -// SetFocusable -// TtsStateChanged diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp index b1c5386..cabe2f6 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp @@ -143,7 +143,7 @@ Dali::Integration::Point GetPointUpOutside() int UtcDaliButtonConstructorP(void) { - TestApplication application; + ToolkitTestApplication application; Button button; @@ -153,7 +153,7 @@ int UtcDaliButtonConstructorP(void) int UtcDaliButtonCopyConstructorP(void) { - TestApplication application; + ToolkitTestApplication application; // Initialize an object, ref count == 1 Button button = PushButton::New(); @@ -165,7 +165,7 @@ int UtcDaliButtonCopyConstructorP(void) int UtcDaliButtonAssignmentOperatorP(void) { - TestApplication application; + ToolkitTestApplication application; Button button = PushButton::New(); @@ -178,7 +178,7 @@ int UtcDaliButtonAssignmentOperatorP(void) int UtcDaliButtonDownCastP(void) { - TestApplication application; + ToolkitTestApplication application; Button button = PushButton::New(); @@ -194,7 +194,7 @@ int UtcDaliButtonDownCastP(void) int UtcDaliButtonDownCastN(void) { - TestApplication application; + ToolkitTestApplication application; BaseHandle unInitializedObject; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ControlWrapper.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ControlWrapper.cpp index 0921d61..db89b0a 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ControlWrapper.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ControlWrapper.cpp @@ -293,7 +293,7 @@ int UtcDaliControlWrapperConstructor(void) int UtcDaliControlWrapperDestructor(void) { - TestApplication application; + ToolkitTestApplication application; ControlWrapper control = ControlWrapper::New( customControlTypeName, *( new Toolkit::Internal::ControlWrapper( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT ) ) ); @@ -312,7 +312,7 @@ int UtcDaliControlWrapperDestructor(void) int UtcDaliControlWrapperRelayoutRequest(void) { - TestApplication application; + ToolkitTestApplication application; DALI_TEST_EQUALS( gOnRelayout, false, TEST_LOCATION ); @@ -338,7 +338,7 @@ int UtcDaliControlWrapperRelayoutRequest(void) int UtcDaliControlWrapperImplGetHeightForWidthBase(void) { - TestApplication application; + ToolkitTestApplication application; Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT ); ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl ); @@ -358,7 +358,7 @@ int UtcDaliControlWrapperImplGetHeightForWidthBase(void) int UtcDaliControlWrapperGetWidthForHeightBase(void) { - TestApplication application; + ToolkitTestApplication application; Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT ); ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl ); @@ -378,7 +378,7 @@ int UtcDaliControlWrapperGetWidthForHeightBase(void) int UtcDaliControlWrapperCalculateChildSizeBase(void) { - TestApplication application; + ToolkitTestApplication application; Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT ); ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl ); @@ -399,7 +399,7 @@ int UtcDaliControlWrapperCalculateChildSizeBase(void) int UtcDaliControlWrapperRelayoutDependentOnChildrenBase(void) { - TestApplication application; + ToolkitTestApplication application; Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT ); ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl ); @@ -613,7 +613,7 @@ int UtcDaliControlWrapperRegisterUnregisterVisual(void) int UtcDaliControlWrapperTransitionDataMap1N(void) { - TestApplication application; + ToolkitTestApplication application; Property::Map map; map["target"] = "Actor1"; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp b/automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp index a013d58..c164432 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp @@ -167,7 +167,7 @@ static std::string GetButtonText( Button button ) int UtcDaliPushButtonConstructorP(void) { - TestApplication application; + ToolkitTestApplication application; PushButton button; @@ -177,7 +177,7 @@ int UtcDaliPushButtonConstructorP(void) int UtcDaliPushButtonCopyConstructorP(void) { - TestApplication application; + ToolkitTestApplication application; // Initialize an object, ref count == 1 PushButton button = PushButton::New(); @@ -189,7 +189,7 @@ int UtcDaliPushButtonCopyConstructorP(void) int UtcDaliPushButtonAssignmentOperatorP(void) { - TestApplication application; + ToolkitTestApplication application; PushButton button = PushButton::New(); @@ -202,7 +202,7 @@ int UtcDaliPushButtonAssignmentOperatorP(void) int UtcDaliPushButtonNewP(void) { - TestApplication application; + ToolkitTestApplication application; PushButton button = PushButton::New(); @@ -212,7 +212,7 @@ int UtcDaliPushButtonNewP(void) int UtcDaliPushButtonDownCastP(void) { - TestApplication application; + ToolkitTestApplication application; PushButton button = PushButton::New(); @@ -228,7 +228,7 @@ int UtcDaliPushButtonDownCastP(void) int UtcDaliPushButtonDownCastN(void) { - TestApplication application; + ToolkitTestApplication application; BaseHandle unInitializedObject; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-RadioButton.cpp b/automated-tests/src/dali-toolkit/utc-Dali-RadioButton.cpp index ce5881c..913f3a2 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-RadioButton.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-RadioButton.cpp @@ -66,7 +66,7 @@ static std::string GetButtonText( Button button ) int UtcDaliRadioButtonConstructorP(void) { - TestApplication application; + ToolkitTestApplication application; RadioButton button; @@ -76,7 +76,7 @@ int UtcDaliRadioButtonConstructorP(void) int UtcDaliRadioButtonCopyConstructorP(void) { - TestApplication application; + ToolkitTestApplication application; // Initialize an object, ref count == 1 RadioButton button = RadioButton::New(); @@ -88,7 +88,7 @@ int UtcDaliRadioButtonCopyConstructorP(void) int UtcDaliRadioButtonAssignmentOperatorP(void) { - TestApplication application; + ToolkitTestApplication application; RadioButton button = RadioButton::New(); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Scene3dView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Scene3dView.cpp index 7c8dad4..c88a2db 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Scene3dView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Scene3dView.cpp @@ -74,7 +74,7 @@ const char* TEST_SPECULAR_TEXTURE = TEST_RESOURCE_DIR "/forest_specular_cubemap. int UtcDaliScene3dViewConstructorP(void) { - TestApplication application; + ToolkitTestApplication application; Scene3dView scene3dView; @@ -84,7 +84,7 @@ int UtcDaliScene3dViewConstructorP(void) int UtcDaliScene3dViewCopyConstructorP(void) { - TestApplication application; + ToolkitTestApplication application; // Initialize an object, ref count == 1 Scene3dView scene3dView = Scene3dView::New( TEST_GLTF_FILE_NAME ); @@ -96,7 +96,7 @@ int UtcDaliScene3dViewCopyConstructorP(void) int UtcDaliScene3dViewCopyConstructor2P(void) { - TestApplication application; + ToolkitTestApplication application; // Initialize an object, ref count == 1 Toolkit::Scene3dView scene3dView = Toolkit::Scene3dView::New( TEST_GLTF_FILE_NAME, TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE, Vector4::ONE ); @@ -108,7 +108,7 @@ int UtcDaliScene3dViewCopyConstructor2P(void) int UtcDaliScene3dViewAssignmentOperatorP(void) { - TestApplication application; + ToolkitTestApplication application; Scene3dView scene3dView = Scene3dView::New( TEST_GLTF_FILE_NAME ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp index 3a8ce20..7538795 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp @@ -92,7 +92,7 @@ static void SetupTableViewAndActors(TableView& tableView, Actor& actor1, Actor& int UtcDaliTableViewCtorCopyP(void) { - TestApplication application; + ToolkitTestApplication application; TableView actor1 = TableView::New(10,10); TableView actor2( actor1 ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ToggleButton.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ToggleButton.cpp index 2f75b37..279f81d 100755 --- a/automated-tests/src/dali-toolkit/utc-Dali-ToggleButton.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ToggleButton.cpp @@ -74,7 +74,7 @@ Dali::Integration::Point GetPointUpInside() int UtcDaliToggleButtonConstructorP(void) { - TestApplication application; + ToolkitTestApplication application; tet_infoline(" UtcDaliToggleButtonConstructorP"); ToggleButton button; @@ -84,7 +84,7 @@ int UtcDaliToggleButtonConstructorP(void) int UtcDaliToggleButtonCopyConstructorP(void) { - TestApplication application; + ToolkitTestApplication application; tet_infoline(" UtcDaliToggleButtonCopyConstructorP"); // Initialize an object, ref count == 1 @@ -97,7 +97,7 @@ int UtcDaliToggleButtonCopyConstructorP(void) int UtcDaliToggleButtonAssignmentOperatorP(void) { - TestApplication application; + ToolkitTestApplication application; tet_infoline(" UtcDaliToggleButtonAssignmentOperatorP"); ToggleButton button = ToggleButton::New(); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp index 374afe0..cb3c09f 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp @@ -137,21 +137,6 @@ bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Ma return true; } - -void PrepareResourceImage( ToolkitTestApplication& application, unsigned int imageWidth, unsigned int imageHeight, Pixel::Format pixelFormat ) -{ - TestPlatformAbstraction& platform = application.GetPlatform(); - platform.SetClosestImageSize(Vector2( imageWidth, imageHeight)); - - Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN ); - Integration::PixelBuffer* pixbuffer = bitmap->GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, imageWidth, imageHeight, imageWidth, imageHeight ); - unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat ); - unsigned int initialColor = 0xFF; - memset( pixbuffer, initialColor, imageHeight*imageWidth*bytesPerPixel); - - Integration::ResourcePointer resourcePtr(bitmap); - platform.SetSynchronouslyLoadedResource( resourcePtr ); -} } //namespace void dali_visual_startup(void) diff --git a/dali-toolkit/devel-api/controls/control-devel.cpp b/dali-toolkit/devel-api/controls/control-devel.cpp index 04b13d3..5c94017 100755 --- a/dali-toolkit/devel-api/controls/control-devel.cpp +++ b/dali-toolkit/devel-api/controls/control-devel.cpp @@ -22,7 +22,9 @@ #include // INTERNAL INCLUDES +#include #include +#include #include #include @@ -117,6 +119,216 @@ VisualEventSignalType& VisualEventSignal( Control control ) return controlDataImpl.VisualEventSignal(); } +static Toolkit::Internal::Control::Impl *GetControlImplementationIfAny( Dali::Actor actor) +{ + Dali::Toolkit::Control c = Toolkit::Control::DownCast( actor ); + if ( c ) + { + auto &impl1 = Toolkit::Internal::GetImplementation( c ); + auto &impl2 = Toolkit::Internal::Control::Impl::Get( impl1 ); + return &impl2; + } + return nullptr; +} + +Toolkit::Control::AccessibilityActivateSignalType &AccessibilityActivateSignal( Toolkit::Control control ) +{ + auto ac = GetControlImplementationIfAny ( control ); + return ac->mAccessibilityActivateSignal; +} + +Toolkit::Control::AccessibilityReadingSkippedSignalType &AccessibilityReadingSkippedSignal( Toolkit::Control control ) +{ + auto ac = GetControlImplementationIfAny ( control ); + return ac->mAccessibilityReadingSkippedSignal; +} + +Toolkit::Control::AccessibilityReadingCancelledSignalType &AccessibilityReadingCancelledSignal( Toolkit::Control control ) +{ + auto ac = GetControlImplementationIfAny ( control ); + return ac->mAccessibilityReadingCancelledSignal; +} + +Toolkit::Control::AccessibilityReadingStoppedSignalType &AccessibilityReadingStoppedSignal( Toolkit::Control control ) +{ + auto ac = GetControlImplementationIfAny ( control ); + return ac->mAccessibilityReadingStoppedSignal; +} + +Toolkit::Control::AccessibilityGetNameSignalType &AccessibilityGetNameSignal( Toolkit::Control control ) +{ + auto ac = GetControlImplementationIfAny ( control ); + return ac->mAccessibilityGetNameSignal; +} + +Toolkit::Control::AccessibilityGetDescriptionSignalType &AccessibilityGetDescriptionSignal( Toolkit::Control control ) +{ + auto ac = GetControlImplementationIfAny ( control ); + return ac->mAccessibilityGetDescriptionSignal; +} + +Toolkit::Control::AccessibilityDoGestureSignalType &AccessibilityDoGestureSignal( Toolkit::Control control ) +{ + auto ac = GetControlImplementationIfAny ( control ); + return ac->mAccessibilityDoGestureSignal; +} + +void AppendAccessibilityRelation( Dali::Actor control, Actor destination, Dali::Accessibility::RelationType relation) +{ + if ( auto ac = GetControlImplementationIfAny ( control ) ) + { + auto index = static_cast(relation); + if (index >= ac->mAccessibilityRelations.size()) + { + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Relation index exceeds vector size." ); + return; + } + + auto obj = ac->GetAccessibilityObject(destination); + ac->mAccessibilityRelations[index].push_back(obj->GetAddress()); + } +} + +void RemoveAccessibilityRelation( Dali::Actor control, Actor destination, Dali::Accessibility::RelationType relation) +{ + if ( auto ac = GetControlImplementationIfAny ( control ) ) + { + auto index = static_cast(relation); + if (index >= ac->mAccessibilityRelations.size()) + { + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Relation index exceeds vector size." ); + return; + } + + auto obj = ac->GetAccessibilityObject(destination); + auto address = obj->GetAddress(); + + auto &targets = ac->mAccessibilityRelations[index]; + for (auto i = 0u; i < targets.size(); ++i) { + if (targets[i].ToString() == address.ToString()) + { + targets[i] = targets.back(); + targets.erase(targets.end() - 1); + } + } + } +} + +std::vector> GetAccessibilityRelations( Dali::Actor control ) +{ + if ( auto ac = GetControlImplementationIfAny ( control ) ) + { + return ac->mAccessibilityRelations; + } + return {}; +} + +void ClearAccessibilityRelations( Dali::Actor control ) +{ + if ( auto ac = GetControlImplementationIfAny ( control ) ) + { + for (auto &it : ac->mAccessibilityRelations) + it.clear(); + } +} + +void SetAccessibilityConstructor( Dali::Actor control, + std::function< std::unique_ptr< Dali::Accessibility::Accessible >( Dali::Actor ) > constructor ) +{ + if ( auto ac = GetControlImplementationIfAny ( control ) ) + { + ac->accessibilityConstructor = constructor; + } +} + +void AppendAccessibilityAttribute( Dali::Actor control, const std::string& key, + const std::string value ) +{ + if ( auto ac = GetControlImplementationIfAny ( control ) ) + { + ac->AppendAccessibilityAttribute( key, value ); + } +} + +void RemoveAccessibilityAttribute( Dali::Actor control, const std::string& key ) +{ + if ( auto ac = GetControlImplementationIfAny ( control ) ) + { + ac->RemoveAccessibilityAttribute( key ); + } +} + +void ClearAccessibilityAttributes( Dali::Actor control ) +{ + if ( auto ac = GetControlImplementationIfAny ( control ) ) + { + ac->ClearAccessibilityAttributes(); + } +} + +void SetAccessibilityReadingInfoType( Dali::Actor control, const Dali::Accessibility::ReadingInfoTypes types ) +{ + if ( auto ac = GetControlImplementationIfAny ( control ) ) + { + ac->SetAccessibilityReadingInfoType( types ); + } +} + +Dali::Accessibility::ReadingInfoTypes GetAccessibilityReadingInfoType(Dali::Actor control ) +{ + if ( auto ac = GetControlImplementationIfAny ( control ) ) + { + return ac->GetAccessibilityReadingInfoType(); + } + return {}; +} + +bool ClearAccessibilityHighlight( Dali::Actor control ) +{ + if ( auto ac = GetControlImplementationIfAny ( control ) ) + { + auto ptr = dynamic_cast( ac ); + if( ptr ) + return ptr->ClearHighlight(); + } + return false; +} + +bool GrabAccessibilityHighlight( Dali::Actor control ) +{ + if ( auto ac = GetControlImplementationIfAny ( control ) ) + { + auto ptr = dynamic_cast( ac ); + if( ptr ) + return ptr->GrabHighlight(); + } + return false; +} + +Dali::Accessibility::States GetAccessibilityStates( Dali::Actor control ) +{ + if ( auto ac = GetControlImplementationIfAny ( control ) ) + { + auto ptr = dynamic_cast( ac ); + if(ptr) + return ptr->GetStates(); + } + return {}; +} + +void NotifyAccessibilityStateChange( Dali::Actor control, Dali::Accessibility::States states, bool doRecursive ) +{ + if ( auto ac = GetControlImplementationIfAny ( control ) ) + { + ac->GetAccessibilityObject()->NotifyAccessibilityStateChange( states, doRecursive ); + } +} + +Dali::Accessibility::Accessible *GetBoundAccessibilityObject( Dali::Actor control ) +{ + return Dali::Accessibility::Accessible::Get( control ); +} + } // namespace DevelControl } // namespace Toolkit diff --git a/dali-toolkit/devel-api/controls/control-devel.h b/dali-toolkit/devel-api/controls/control-devel.h index eb2bcda..d13bcb0 100755 --- a/dali-toolkit/devel-api/controls/control-devel.h +++ b/dali-toolkit/devel-api/controls/control-devel.h @@ -63,11 +63,11 @@ enum /** * @brief Displays a tooltip when the control is hovered over. * @details Name "tooltip", type Property::STRING, Property::ARRAY or Property::MAP. - * If Property::STRING, then the style specified in the stylesheet is used. - * If Property::ARRAY of Visuals then all are displayed in one row. - * If Property::MAP, then it should be a map of Tooltip properties. + * If Property::STRING, then the style specified in the stylesheet is used. + * If Property::ARRAY of Visuals then all are displayed in one row. + * If Property::MAP, then it should be a map of Tooltip properties. * @note The tooltip is only activated if display content is received, i.e. a string (text) or visual to show. - * The rest is used to just build up the style of the tooltip (i.e. background, text color/point-size etc.) + * The rest is used to just build up the style of the tooltip (i.e. background, text color/point-size etc.) * @note When retrieved, a Property::MAP is returned. * @see Toolkit::Tooltip */ @@ -83,7 +83,7 @@ enum /** * @brief The current sub state of the control. - * @details Name "subState", type Property::INTEGER or Property::STRING. The enumeration used is dependent on the derived control. + * @details Name "subState", type Property::INTEGER or Property::STRING. The numeration used is dependent on the derived control. * * @see DevelControl::State */ @@ -115,7 +115,52 @@ enum * @details Name "downFocusableActorId", type Property::INTEGER. * */ - DOWN_FOCUSABLE_ACTOR_ID = PADDING + 7 + DOWN_FOCUSABLE_ACTOR_ID = PADDING + 7, + + /** + * @brief The name of object visible in accessibility tree. + * @details Name "accessibilityName", type Property::STRING. + */ + ACCESSIBILITY_NAME, + + /** + * @brief The description of object visible in accessibility tree. + * @details Name "accessibilityDescription", type Property::STRING. + */ + ACCESSIBILITY_DESCRIPTON, + + /** + * @brief Current translation domain for accessibility clients. + * @details Name "accessibilityTranslationDomain", type Property::STRING. + */ + ACCESSIBILITY_TRANSLATION_DOMAIN, + + /** + * @brief Role being performed in accessibility hierarchy. + * @details Name "accessibilityRole", type Property::INTEGER. + * @note Property is stored as INTEGER, however its interpretaton + * depend on enumeration Dali::Accessibility::Role and should be read and written + * with usage of enumerated values. + * @see Dali::Accessibility::Role + */ + ACCESSIBILITY_ROLE, + /** + * @brief Mark of able to highlight object. + * @details Name "accessibilityHighlightable", type Property::BOOLEAN. + */ + ACCESSIBILITY_HIGHLIGHTABLE, + /** + * @brief Set of accessibility attributes describing object in accessibility hierarchy + * @details Name "accessibilityAttributes", type Property::MAP + */ + ACCESSIBILITY_ATTRIBUTES, + + /** + * @brief Boolean flag describing object as animated + * @details Name "accessibilityAnimated", type Property::BOOLEAN + * @note Flag set to true will prevent BoundChanged accessibility signal from emiting + */ + ACCESSIBILITY_ANIMATED }; } // namespace Property @@ -285,6 +330,200 @@ using VisualEventSignalType = Signal< void ( Control, Dali::Property::Index, Dal */ DALI_TOOLKIT_API VisualEventSignalType& VisualEventSignal( Control control ); +/** + * @brief The signal is emmited as a succession of "activate" signal send by accessibility client. + * @return The signal to connect to + */ +DALI_TOOLKIT_API Toolkit::Control::AccessibilityActivateSignalType &AccessibilityActivateSignal( Toolkit::Control control ); + +/** + * @brief The signal is emmited when text send via Dali::Accessibility::Bridge::Say + * was placed in TTS queue but other text with higher priority prevented it from being read. + * + * @return The signal to connect to + */ +DALI_TOOLKIT_API Toolkit::Control::AccessibilityReadingSkippedSignalType &AccessibilityReadingSkippedSignal( Toolkit::Control control ); + +/** + * @brief The signal is emmited when text send via Dali::Accessibility::Bridge::Say + * was placed in TTS queue and reading was started but other text with higher priority cancelled it. + * + * @return The signal to connect to + */ +DALI_TOOLKIT_API Toolkit::Control::AccessibilityReadingCancelledSignalType &AccessibilityReadingCancelledSignal( Toolkit::Control control ); + +/** + * @brief The signal is emmited when text send via Dali::Accessibility::Bridge::Say + * was fully read by TTS module. + * + * @return The signal to connect to + */ +DALI_TOOLKIT_API Toolkit::Control::AccessibilityReadingStoppedSignalType &AccessibilityReadingStoppedSignal( Toolkit::Control control ); + +/** + * @brief The signal is emmited when accessibility client asks for object's name. + * + * Connected callback should assign name to std::string call parameter. + * Accessibility name can be stored in two ways: + * this signal, + * ACCESSIBILITY_NAME property, + * Priority is as above. If none is used, default implementation is provided. + * @return [description] + */ +DALI_TOOLKIT_API Toolkit::Control::AccessibilityGetNameSignalType &AccessibilityGetNameSignal( Toolkit::Control control ); + +/** + * @brief The signal is emmited when accessibility client asks for object's description. + * + * Connected callback should assign description to std::string call parameter. + * Accessibility description can be stored in two ways: + * this signal, + * ACCESSIBILITY_DESCRIPTON property, + * Priority is as above. If none is used, default implementation is provided. + * @return signal handler + */ +DALI_TOOLKIT_API Toolkit::Control::AccessibilityGetDescriptionSignalType &AccessibilityGetDescriptionSignal( Toolkit::Control control ); + +/** + * @brief The signal is emitted when accessibility client call "DoGesture" method via IPC mechanism. + * + * This signal allows developers to serve incoming gesture in specific way. + * @return signal handler + */ +DALI_TOOLKIT_API Toolkit::Control::AccessibilityDoGestureSignalType &AccessibilityDoGestureSignal( Toolkit::Control control ); + +/** + * @brief The method allows connection with other actor with usage of concrete accessibility relation type. + * + * @param control object to append attribute to + * @param destination Actor object + * @param relation enumerated value describing relation + */ +DALI_TOOLKIT_API void AppendAccessibilityRelation( Dali::Actor control, Actor destination, Dali::Accessibility::RelationType relation ); + +/** + * @brief The method allows removing relation + * + * @param control object to append attribute to + * @param destination Actor object + * @param relation enumerated value describing relation + */ +DALI_TOOLKIT_API void RemoveAccessibilityRelation( Dali::Actor control, Actor destination, Dali::Accessibility::RelationType relation ); + +/** + * @brief The method returns collection accessibility addresses representing objects connected with current object + * + * @param control object to append attribute to + * @return std::vector, where index is casted value of Accessibility::RelationType and value is std::vector of type Accessibility::Address + */ +DALI_TOOLKIT_API std::vector> GetAccessibilityRelations( Dali::Actor control ); + +/** + * @brief The method removes all previously appended relations + * + * @param control object to append attribute to + */ +DALI_TOOLKIT_API void ClearAccessibilityRelations( Dali::Actor control ); + +/** + * @brief The method allows to add or modify value matched with given key. + * Modification take place if key was previously set. + * + * @param control object to append attribute to + * @param key std::string value + * @param value std::string value + */ +DALI_TOOLKIT_API void AppendAccessibilityAttribute( Dali::Actor control, const std::string& key, const std::string value ); + +/** + * @brief The method erases key with its value from accessibility attributes + * @param control object to append attribute to + * @param key std::string value + */ +DALI_TOOLKIT_API void RemoveAccessibilityAttribute( Dali::Actor control, const std::string& key ); + +/** + * @brief The method clears accessibility attributes + * + * @param control object to append attribute to + */ +DALI_TOOLKIT_API void ClearAccessibilityAttributes( Dali::Actor control ); + +/** + * @brief The method inserts reading information of an accessible object into attributes + * + * @param control object to append attribute to + * @param types Reading information types + */ +DALI_TOOLKIT_API void SetAccessibilityReadingInfoType( Dali::Actor control, const Dali::Accessibility::ReadingInfoTypes types ); + +/** + * @brief The method returns reading information of an accessible object + * + * @param control object to append attribute to + * @return Reading information types + */ +DALI_TOOLKIT_API Dali::Accessibility::ReadingInfoTypes GetAccessibilityReadingInfoType( Dali::Actor control ); + +/** + * @brief The method erases highlight. + * + * @param control object to append attribute to + * @return bool value, false when it is not possible or something went wrong, at the other way true. + */ +DALI_TOOLKIT_API bool ClearAccessibilityHighlight( Dali::Actor control ); + +/** + * @brief The method grabs highlight. + * + * @param control object to append attribute to + * @return bool value, false when it is not possible or something went wrong, at the other way true. + */ +DALI_TOOLKIT_API bool GrabAccessibilityHighlight( Dali::Actor control ); + +/** + * @brief The metod presents bitset of control's states. + * + * @param control object to append attribute to + * @return Dali::Accessibility::States is vector of enumerated State. + */ +DALI_TOOLKIT_API Dali::Accessibility::States GetAccessibilityStates( Dali::Actor control ); + +/** + * @brief The method force sending notifications about current states to accessibility clients + * + * @param control object to append attribute to + * @param states mask with states expected to broadcast + * @param doRecursive flag pointing if notifications of children's state would be sent + */ +DALI_TOOLKIT_API void NotifyAccessibilityStateChange( Dali::Actor control, Dali::Accessibility::States states, bool doRecursive ); + +/** + * The method allows to set specific constructor for creating accessibility structure + * + * Thank to this method hierarchy of accessibility objects can be based on internal hierarchy of Actors. + * It prevents from necessity of keeping two trees synchronized. + * The method should be called inside constructors of all classes inheriting from Control. + * + * Possible usage can be as follows: + * @code + * SetAccessibilityConstructor( []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new AccessibleImpl( actor, Dali::Accessibility::Role::DIALOG, true ) ); + } ); + * @endcode + * + * param constructor callback creating Accessible object + */ +DALI_TOOLKIT_API void SetAccessibilityConstructor( Dali::Actor control, std::function(Dali::Actor)> constructor); + +/** + * Returns accessibility object bound to actor, if any + * + * This method won't bound new accessibility object. Use Dali::Accessibility::Accessible::Get in that case. + */ +DALI_TOOLKIT_API Dali::Accessibility::Accessible *GetBoundAccessibilityObject( Dali::Actor control ); + } // namespace DevelControl } // namespace Toolkit diff --git a/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.cpp b/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.cpp index 9eeab0e..e752eda 100644 --- a/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.cpp +++ b/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.cpp @@ -21,7 +21,6 @@ // EXTERNAL INCLUDES #include // for strcmp #include -#include #include #include #include @@ -32,6 +31,7 @@ #include #include #include +#include namespace Dali { @@ -42,84 +42,7 @@ namespace Toolkit namespace Internal { -namespace // unnamed namespace -{ - -// Signals - -const char* const SIGNAL_FOCUS_CHANGED = "focusChanged"; -const char* const SIGNAL_FOCUS_OVERSHOT = "focusOvershot"; -const char* const SIGNAL_FOCUSED_ACTOR_ACTIVATED = "focusedActorActivated"; - -#if defined(DEBUG_ENABLED) -Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_FOCUS_MANAGER"); -#endif - -const char* const ACTOR_FOCUSABLE("focusable"); -const char* const IS_FOCUS_GROUP("isFocusGroup"); - -const char* FOCUS_BORDER_IMAGE_PATH = DALI_IMAGE_DIR "B16-8_TTS_focus.9.png"; - -const char* FOCUS_SOUND_FILE = DALI_SOUND_DIR "Focus.ogg"; -const char* FOCUS_CHAIN_END_SOUND_FILE = DALI_SOUND_DIR "End_of_List.ogg"; - -/** - * The function to be used in the hit-test algorithm to check whether the actor is hittable. - */ -bool IsActorFocusableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType type) -{ - bool hittable = false; - - switch (type) - { - case Dali::HitTestAlgorithm::CHECK_ACTOR: - { - // Check whether the actor is visible and not fully transparent. - if( actor.IsVisible() - && actor.GetCurrentWorldColor().a > 0.01f) // not FULLY_TRANSPARENT - { - // Check whether the actor is focusable - Property::Index propertyActorFocusable = actor.GetPropertyIndex(ACTOR_FOCUSABLE); - if(propertyActorFocusable != Property::INVALID_INDEX) - { - hittable = actor.GetProperty(propertyActorFocusable); - } - } - break; - } - case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE: - { - if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible. - { - hittable = true; - } - break; - } - default: - { - break; - } - } - - return hittable; -}; - -} - AccessibilityManager::AccessibilityManager() -: mCurrentFocusActor(FocusIDPair(0, 0)), - mCurrentGesturedActor(), - mFocusIndicatorActor(), - mPreviousPosition( 0.0f, 0.0f ), - mRecursiveFocusMoveCounter(0), - mIsWrapped(false), - mIsFocusWithinGroup(false), - mIsEndcapFeedbackEnabled(false), - mIsEndcapFeedbackPlayed(false), - mIsAccessibilityTtsEnabled(false), - mTtsCreated(false), - mIsFocusIndicatorEnabled(false), - mContinuousPlayMode(false) { } @@ -129,1251 +52,118 @@ AccessibilityManager::~AccessibilityManager() void AccessibilityManager::Initialise() { - AccessibilityAdaptor adaptor = AccessibilityAdaptor::Get(); - adaptor.SetActionHandler(*this); - adaptor.SetGestureHandler(*this); - - ChangeAccessibilityStatus(); -} - -AccessibilityManager::ActorAdditionalInfo AccessibilityManager::GetActorAdditionalInfo(const unsigned int actorID) const -{ - ActorAdditionalInfo data; - IDAdditionalInfoConstIter iter = mIDAdditionalInfoContainer.find(actorID); - if(iter != mIDAdditionalInfoContainer.end()) - { - data = (*iter).second; - } - - return data; -} - -void AccessibilityManager::SynchronizeActorAdditionalInfo(const unsigned int actorID, const unsigned int order) -{ - ActorAdditionalInfo actorInfo = GetActorAdditionalInfo(actorID); - actorInfo.mFocusOrder = order; - mIDAdditionalInfoContainer.erase(actorID); - mIDAdditionalInfoContainer.insert(IDAdditionalInfoPair(actorID, actorInfo)); } void AccessibilityManager::SetAccessibilityAttribute(Actor actor, Toolkit::AccessibilityManager::AccessibilityAttribute type, const std::string& text) { - if(actor) - { - unsigned int actorID = actor.GetId(); - - ActorAdditionalInfo info = GetActorAdditionalInfo(actorID); - info.mAccessibilityAttributes[type] = text; - - mIDAdditionalInfoContainer.erase(actorID); - mIDAdditionalInfoContainer.insert(IDAdditionalInfoPair(actorID, info)); - } } std::string AccessibilityManager::GetAccessibilityAttribute(Actor actor, Toolkit::AccessibilityManager::AccessibilityAttribute type) const { - std::string text; - - if(actor) - { - ActorAdditionalInfo data = GetActorAdditionalInfo(actor.GetId()); - text = data.mAccessibilityAttributes[type]; - } - - return text; + return ""; } void AccessibilityManager::SetFocusOrder(Actor actor, const unsigned int order) { - // Do nothing if the focus order of the actor is not changed. - if(actor && GetFocusOrder(actor) != order) - { - // Firstly delete the actor from the focus chain if it's already there with a different focus order. - mFocusIDContainer.erase(GetFocusOrder(actor)); - - // Create/retrieve actor focusable property - Property::Index propertyActorFocusable = actor.RegisterProperty( ACTOR_FOCUSABLE, true, Property::READ_WRITE ); - - if(order == 0) - { - // The actor is not focusable without a defined focus order. - actor.SetProperty(propertyActorFocusable, false); - - // If the actor is currently being focused, it should clear the focus - if(actor == GetCurrentFocusActor()) - { - ClearFocus(); - } - } - else // Insert the actor to the focus chain - { - // Check whether there is another actor in the focus chain with the same focus order already. - FocusIDIter focusIDIter = mFocusIDContainer.find(order); - if(focusIDIter != mFocusIDContainer.end()) - { - // We need to increase the focus order of that actor and all the actors followed it - // in the focus chain. - FocusIDIter lastIter = mFocusIDContainer.end(); - --lastIter;//We want forward iterator to the last element here - mFocusIDContainer.insert(FocusIDPair((*lastIter).first + 1, (*lastIter).second)); - - // Update the actor's focus order in its additional data - SynchronizeActorAdditionalInfo((*lastIter).second, (*lastIter).first + 1); - - for(FocusIDIter iter = lastIter; iter != focusIDIter; iter--) - { - FocusIDIter previousIter = iter; - --previousIter;//We want forward iterator to the previous element here - unsigned int actorID = (*previousIter).second; - (*iter).second = actorID; - - // Update the actor's focus order in its additional data - SynchronizeActorAdditionalInfo(actorID, (*iter).first); - } - - mFocusIDContainer.erase(order); - } - - // The actor is focusable - actor.SetProperty(propertyActorFocusable, true); - - // Now we insert the actor into the focus chain with the specified focus order - mFocusIDContainer.insert(FocusIDPair(order, actor.GetId())); - } - - // Update the actor's focus order in its additional data - SynchronizeActorAdditionalInfo(actor.GetId(), order); - } } unsigned int AccessibilityManager::GetFocusOrder(Actor actor) const { - unsigned int focusOrder = 0; - - if(actor) - { - ActorAdditionalInfo data = GetActorAdditionalInfo(actor.GetId()); - focusOrder = data.mFocusOrder; - } - - return focusOrder; + return 0; } unsigned int AccessibilityManager::GenerateNewFocusOrder() const { - unsigned int order = 1; - FocusIDContainer::const_reverse_iterator iter = mFocusIDContainer.rbegin(); - - if(iter != mFocusIDContainer.rend()) - { - order = (*iter).first + 1; - } - - return order; + return 0; } Actor AccessibilityManager::GetActorByFocusOrder(const unsigned int order) { - Actor actor = Actor(); - - FocusIDIter focusIDIter = mFocusIDContainer.find(order); - if(focusIDIter != mFocusIDContainer.end()) - { - Actor rootActor = Stage::GetCurrent().GetRootLayer(); - actor = rootActor.FindChildById(mFocusIDContainer[order]); - } - - return actor; + return {}; } bool AccessibilityManager::SetCurrentFocusActor(Actor actor) { - if(actor) - { - return DoSetCurrentFocusActor(actor.GetId()); - } - - return false; -} - -bool AccessibilityManager::DoSetCurrentFocusActor(const unsigned int actorID) -{ - Actor rootActor = Stage::GetCurrent().GetRootLayer(); - - // If the group mode is enabled, check which focus group the current focused actor belongs to - Actor focusGroup; - if(mIsFocusWithinGroup) - { - focusGroup = GetFocusGroup(GetCurrentFocusActor()); - } - - if(!focusGroup) - { - focusGroup = rootActor; - } - - Actor actor = focusGroup.FindChildById(actorID); - - // Check whether the actor is in the stage - if(actor) - { - // Check whether the actor is focusable - bool actorFocusable = false; - Property::Index propertyActorFocusable = actor.GetPropertyIndex(ACTOR_FOCUSABLE); - if(propertyActorFocusable != Property::INVALID_INDEX) - { - actorFocusable = actor.GetProperty(propertyActorFocusable); - } - - // Go through the actor's hierarchy to check whether the actor is visible - bool actorVisible = actor.IsVisible(); - Actor parent = actor.GetParent(); - while (actorVisible && parent && parent != rootActor) - { - actorVisible = parent.IsVisible(); - parent = parent.GetParent(); - } - - // Check whether the actor is fully transparent - bool actorOpaque = actor.GetCurrentWorldColor().a > 0.01f; - - // Set the focus only when the actor is focusable and visible and not fully transparent - if(actorVisible && actorFocusable && actorOpaque) - { - // Draw the focus indicator upon the focused actor - if( mIsFocusIndicatorEnabled ) - { - actor.Add( GetFocusIndicatorActor() ); - } - - // Send notification for the change of focus actor - mFocusChangedSignal.Emit( GetCurrentFocusActor(), actor ); - - // Save the current focused actor - mCurrentFocusActor = FocusIDPair(GetFocusOrder(actor), actorID); - - if(mIsAccessibilityTtsEnabled) - { - Dali::SoundPlayer soundPlayer = Dali::SoundPlayer::Get(); - if(soundPlayer) - { - soundPlayer.PlaySound(FOCUS_SOUND_FILE); - } - - // Play the accessibility attributes with the TTS player. - Dali::TtsPlayer player = Dali::TtsPlayer::Get(Dali::TtsPlayer::SCREEN_READER); - - // Combine attribute texts to one text - std::string informationText; - for(int i = 0; i < Toolkit::AccessibilityManager::ACCESSIBILITY_ATTRIBUTE_NUM; i++) - { - if(!GetActorAdditionalInfo(actorID).mAccessibilityAttributes[i].empty()) - { - if( i > 0 ) - { - informationText += ", "; // for space time between each information - } - informationText += GetActorAdditionalInfo(actorID).mAccessibilityAttributes[i]; - } - } - player.Play(informationText); - } - - return true; - } - } - - DALI_LOG_WARNING("[%s:%d] FAILED\n", __FUNCTION__, __LINE__); return false; } Actor AccessibilityManager::GetCurrentFocusActor() { - Actor rootActor = Stage::GetCurrent().GetRootLayer(); - return rootActor.FindChildById(mCurrentFocusActor.second); + return {}; } Actor AccessibilityManager::GetCurrentFocusGroup() { - return GetFocusGroup(GetCurrentFocusActor()); + return {}; } unsigned int AccessibilityManager::GetCurrentFocusOrder() { - return mCurrentFocusActor.first; + return 0; } bool AccessibilityManager::MoveFocusForward() { - bool ret = false; - mRecursiveFocusMoveCounter = 0; - - FocusIDIter focusIDIter = mFocusIDContainer.find(mCurrentFocusActor.first); - if(focusIDIter != mFocusIDContainer.end()) - { - DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] focus order : %d\n", __FUNCTION__, __LINE__, (*focusIDIter).first); - ret = DoMoveFocus(focusIDIter, true, mIsWrapped); - } - else - { - // TODO: if there is not focused actor, move first actor - if(!mFocusIDContainer.empty()) - { - //if there is not focused actor, move 1st actor - focusIDIter = mFocusIDContainer.begin(); // TODO: I'm not sure it was sorted. - DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] focus order : %d\n", __FUNCTION__, __LINE__, (*focusIDIter).first); - ret = DoSetCurrentFocusActor((*focusIDIter).second); - } - } - - DALI_LOG_INFO( gLogFilter, Debug::General, "[%s] %s\n", __FUNCTION__, ret?"SUCCEED!!!":"FAILED!!!"); - - return ret; + return false; } bool AccessibilityManager::MoveFocusBackward() { - bool ret = false; - mRecursiveFocusMoveCounter = 0; - - FocusIDIter focusIDIter = mFocusIDContainer.find(mCurrentFocusActor.first); - if(focusIDIter != mFocusIDContainer.end()) - { - DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] focus order : %d\n", __FUNCTION__, __LINE__, (*focusIDIter).first); - ret = DoMoveFocus(focusIDIter, false, mIsWrapped); - } - else - { - // TODO: if there is not focused actor, move last actor - if(!mFocusIDContainer.empty()) - { - //if there is not focused actor, move last actor - focusIDIter = mFocusIDContainer.end(); - --focusIDIter;//We want forward iterator to the last element here - DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] focus order : %d\n", __FUNCTION__, __LINE__, (*focusIDIter).first); - ret = DoSetCurrentFocusActor((*focusIDIter).second); - } - } - - DALI_LOG_INFO( gLogFilter, Debug::General, "[%s] %s\n", __FUNCTION__, ret?"SUCCEED!!!":"FAILED!!!"); - - return ret; -} - -void AccessibilityManager::DoActivate(Actor actor) -{ - if(actor) - { - Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(actor); - if(control) - { - // Notify the control that it is activated - GetImplementation( control ).AccessibilityActivate(); - } - - // Send notification for the activation of focused actor - mFocusedActorActivatedSignal.Emit(actor); - } + return false; } void AccessibilityManager::ClearFocus() { - Actor actor = GetCurrentFocusActor(); - if( actor && mFocusIndicatorActor ) - { - actor.Remove( mFocusIndicatorActor ); - } - - mCurrentFocusActor = FocusIDPair(0, 0); - - // Send notification for the change of focus actor - mFocusChangedSignal.Emit(actor, Actor()); - - if(mIsAccessibilityTtsEnabled) - { - // Stop the TTS playing if any - Dali::TtsPlayer player = Dali::TtsPlayer::Get(Dali::TtsPlayer::SCREEN_READER); - player.Stop(); - } } void AccessibilityManager::Reset() { - ClearFocus(); - mFocusIDContainer.clear(); - mIDAdditionalInfoContainer.clear(); } void AccessibilityManager::SetFocusGroup(Actor actor, bool isFocusGroup) { - if(actor) - { - // Create/Set focus group property. - actor.RegisterProperty( IS_FOCUS_GROUP, isFocusGroup, Property::READ_WRITE ); - } } bool AccessibilityManager::IsFocusGroup(Actor actor) const { - // Check whether the actor is a focus group - bool isFocusGroup = false; - - if(actor) - { - Property::Index propertyIsFocusGroup = actor.GetPropertyIndex(IS_FOCUS_GROUP); - if(propertyIsFocusGroup != Property::INVALID_INDEX) - { - isFocusGroup = actor.GetProperty(propertyIsFocusGroup); - } - } - - return isFocusGroup; + return false; } Actor AccessibilityManager::GetFocusGroup(Actor actor) { - // Go through the actor's hierarchy to check which focus group the actor belongs to - while (actor && !IsFocusGroup(actor)) - { - actor = actor.GetParent(); - } - - return actor; + return {}; } Vector2 AccessibilityManager::GetReadPosition() const { - AccessibilityAdaptor adaptor = AccessibilityAdaptor::Get(); - return adaptor.GetReadPosition(); + return {}; } void AccessibilityManager::SetGroupMode(bool enabled) { - mIsFocusWithinGroup = enabled; } bool AccessibilityManager::GetGroupMode() const { - return mIsFocusWithinGroup; + return false; } void AccessibilityManager::SetWrapMode(bool wrapped) { - mIsWrapped = wrapped; } bool AccessibilityManager::GetWrapMode() const { - return mIsWrapped; + return false; } void AccessibilityManager::SetFocusIndicatorActor(Actor indicator) { - if( mFocusIndicatorActor != indicator ) - { - Actor currentFocusActor = GetCurrentFocusActor(); - if( currentFocusActor ) - { - // The new focus indicator should be added to the current focused actor immediately - if( mFocusIndicatorActor ) - { - currentFocusActor.Remove( mFocusIndicatorActor ); - } - - if( indicator ) - { - currentFocusActor.Add( indicator ); - } - } - - mFocusIndicatorActor = indicator; - } } Actor AccessibilityManager::GetFocusIndicatorActor() { - if( ! mFocusIndicatorActor ) - { - // Create the default if it hasn't been set and one that's shared by all the keyboard focusable actors - mFocusIndicatorActor = Toolkit::ImageView::New( FOCUS_BORDER_IMAGE_PATH ); - mFocusIndicatorActor.SetParentOrigin( ParentOrigin::CENTER ); - mFocusIndicatorActor.SetZ( 1.0f ); - - // Apply size constraint to the focus indicator - mFocusIndicatorActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - } - - return mFocusIndicatorActor; -} - -bool AccessibilityManager::DoMoveFocus(FocusIDIter focusIDIter, bool forward, bool wrapped) -{ - DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] %d focusable actors\n", __FUNCTION__, __LINE__, mFocusIDContainer.size()); - DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] focus order : %d\n", __FUNCTION__, __LINE__, (*focusIDIter).first); - - if( (forward && ++focusIDIter == mFocusIDContainer.end()) - || (!forward && focusIDIter-- == mFocusIDContainer.begin()) ) - { - if(mIsEndcapFeedbackEnabled) - { - if(mIsEndcapFeedbackPlayed == false) - { - // play sound & skip moving once - Dali::SoundPlayer soundPlayer = Dali::SoundPlayer::Get(); - if(soundPlayer) - { - soundPlayer.PlaySound(FOCUS_CHAIN_END_SOUND_FILE); - } - - mIsEndcapFeedbackPlayed = true; - return true; - } - mIsEndcapFeedbackPlayed = false; - } - - if(wrapped) - { - if(forward) - { - focusIDIter = mFocusIDContainer.begin(); - } - else - { - focusIDIter = mFocusIDContainer.end(); - --focusIDIter;//We want forward iterator to the last element here - } - } - else - { - DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] Overshot\n", __FUNCTION__, __LINE__); - // Send notification for handling overshooted situation - mFocusOvershotSignal.Emit(GetCurrentFocusActor(), forward ? Toolkit::AccessibilityManager::OVERSHOT_NEXT : Toolkit::AccessibilityManager::OVERSHOT_PREVIOUS); - - return false; // Try to move the focus out of the scope - } - } - - // Invalid focus. - if( focusIDIter == mFocusIDContainer.end() ) - { - return false; - } - - // Note: This function performs the focus change. - if( !DoSetCurrentFocusActor( (*focusIDIter).second ) ) - { - mRecursiveFocusMoveCounter++; - if(mRecursiveFocusMoveCounter > mFocusIDContainer.size()) - { - // We've attempted to focus all the actors in the whole focus chain and no actor - // can be focused successfully. - DALI_LOG_WARNING("[%s] There is no more focusable actor in %d focus chains\n", __FUNCTION__, mRecursiveFocusMoveCounter); - - return false; - } - else - { - return DoMoveFocus(focusIDIter, forward, wrapped); - } - } - - return true; -} - -void AccessibilityManager::SetFocusable(Actor actor, bool focusable) -{ - if(actor) - { - // Create/Set actor focusable property. - actor.RegisterProperty( ACTOR_FOCUSABLE, focusable, Property::READ_WRITE ); - } -} - -bool AccessibilityManager::ChangeAccessibilityStatus() -{ - AccessibilityAdaptor adaptor = AccessibilityAdaptor::Get(); - mIsAccessibilityTtsEnabled = adaptor.IsEnabled(); - Dali::Toolkit::AccessibilityManager handle( this ); - - if(mIsAccessibilityTtsEnabled) - { - // Show indicator when tts turned on if there is focused actor. - Actor actor = GetCurrentFocusActor(); - if(actor) - { - actor.Add( GetFocusIndicatorActor() ); - } - mIsFocusIndicatorEnabled = true; - - // Connect a signal to the TTS player to implement continuous reading mode. - Dali::TtsPlayer player = Dali::TtsPlayer::Get( Dali::TtsPlayer::SCREEN_READER ); - player.StateChangedSignal().Connect( this, &AccessibilityManager::TtsStateChanged ); - mTtsCreated = true; - } - else - { - // Hide indicator when tts turned off - Actor actor = GetCurrentFocusActor(); - if( actor && mFocusIndicatorActor ) - { - actor.Remove( mFocusIndicatorActor ); - } - mIsFocusIndicatorEnabled = false; - - if( mTtsCreated ) - { - // Disconnect the TTS state change signal. - Dali::TtsPlayer player = Dali::TtsPlayer::Get( Dali::TtsPlayer::SCREEN_READER ); - player.StateChangedSignal().Disconnect( this, &AccessibilityManager::TtsStateChanged ); - mTtsCreated = true; - } - } - - mStatusChangedSignal.Emit( handle ); - - return true; -} - -bool AccessibilityManager::AccessibilityActionNext(bool allowEndFeedback) -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionNextSignal.Empty() ) - { - mActionNextSignal.Emit( handle ); - } - - if(mIsAccessibilityTtsEnabled) - { - mIsEndcapFeedbackEnabled = allowEndFeedback; - return MoveFocusForward(); - } - else - { - return false; - } -} - -bool AccessibilityManager::AccessibilityActionPrevious(bool allowEndFeedback) -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionPreviousSignal.Empty() ) - { - mActionPreviousSignal.Emit( handle ); - } - - if(mIsAccessibilityTtsEnabled) - { - mIsEndcapFeedbackEnabled = allowEndFeedback; - return MoveFocusBackward(); - } - else - { - return false; - } -} - -bool AccessibilityManager::AccessibilityActionActivate() -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionActivateSignal.Empty() ) - { - mActionActivateSignal.Emit( handle ); - } - - bool ret = false; - - Actor actor = GetCurrentFocusActor(); - if(actor) - { - DoActivate(actor); - ret = true; - } - - return ret; -} - -bool AccessibilityManager::AccessibilityActionRead(bool allowReadAgain) -{ - Dali::Toolkit::AccessibilityManager handle( this ); - - if( allowReadAgain ) - { - if ( !mActionReadSignal.Empty() ) - { - mActionReadSignal.Emit( handle ); - } - } - else - { - if ( !mActionOverSignal.Empty() ) - { - mActionOverSignal.Emit( handle ); - } - } - - bool ret = false; - - if(mIsAccessibilityTtsEnabled) - { - // Find the focusable actor at the read position - AccessibilityAdaptor adaptor = AccessibilityAdaptor::Get(); - Dali::HitTestAlgorithm::Results results; - Dali::HitTestAlgorithm::HitTest( Stage::GetCurrent(), adaptor.GetReadPosition(), results, IsActorFocusableFunction ); - - FocusIDIter focusIDIter = mFocusIDContainer.find(GetFocusOrder(results.actor)); - if(focusIDIter != mFocusIDContainer.end()) - { - if( allowReadAgain || (results.actor != GetCurrentFocusActor()) ) - { - // Move the focus to the actor - ret = SetCurrentFocusActor(results.actor); - DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] SetCurrentFocusActor returns %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE"); - } - } - } - - return ret; -} - -bool AccessibilityManager::AccessibilityActionReadNext(bool allowEndFeedback) -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionReadNextSignal.Empty() ) - { - mActionReadNextSignal.Emit( handle ); - } - - if(mIsAccessibilityTtsEnabled) - { - return MoveFocusForward(); - } - else - { - return false; - } -} - -bool AccessibilityManager::AccessibilityActionReadPrevious(bool allowEndFeedback) -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionReadPreviousSignal.Empty() ) - { - mActionReadPreviousSignal.Emit( handle ); - } - - if(mIsAccessibilityTtsEnabled) - { - return MoveFocusBackward(); - } - else - { - return false; - } -} - -bool AccessibilityManager::AccessibilityActionUp() -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionUpSignal.Empty() ) - { - mActionUpSignal.Emit( handle ); - } - - bool ret = false; - - if(mIsAccessibilityTtsEnabled) - { - Actor actor = GetCurrentFocusActor(); - if(actor) - { - Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(actor); - if(control) - { - // Notify the control that it is activated - ret = GetImplementation( control ).OnAccessibilityValueChange(true); - } - } - } - - return ret; -} - -bool AccessibilityManager::AccessibilityActionDown() -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionDownSignal.Empty() ) - { - mActionDownSignal.Emit( handle ); - } - - bool ret = false; - - if(mIsAccessibilityTtsEnabled) - { - Actor actor = GetCurrentFocusActor(); - if(actor) - { - Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(actor); - if(control) - { - // Notify the control that it is activated - ret = GetImplementation( control ).OnAccessibilityValueChange(false); - } - } - } - - return ret; -} - -bool AccessibilityManager::ClearAccessibilityFocus() -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionClearFocusSignal.Empty() ) - { - mActionClearFocusSignal.Emit( handle ); - } - - if(mIsAccessibilityTtsEnabled) - { - ClearFocus(); - return true; - } - else - { - return false; - } -} - -bool AccessibilityManager::AccessibilityActionScroll( Dali::TouchEvent& touchEvent ) -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionScrollSignal.Empty() ) - { - mActionScrollSignal.Emit( handle, touchEvent ); - } - - return true; -} - -bool AccessibilityManager::AccessibilityActionBack() -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionBackSignal.Empty() ) - { - mActionBackSignal.Emit( handle ); - } - - // TODO: Back to previous view - - return mIsAccessibilityTtsEnabled; -} - -bool AccessibilityManager::AccessibilityActionScrollUp() -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionScrollUpSignal.Empty() ) - { - mActionScrollUpSignal.Emit( handle ); - } - - bool ret = false; - - if(mIsAccessibilityTtsEnabled) - { - Actor actor = GetCurrentFocusActor(); - if(actor) - { - Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(actor); - if(control) - { - // TODO: Notify the control to scroll up. Should control handle this? -// ret = GetImplementation( control ).OnAccessibilityScroll(Direction::UP); - } - } - } - - return ret; -} - -bool AccessibilityManager::AccessibilityActionScrollDown() -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionScrollDownSignal.Empty() ) - { - mActionScrollDownSignal.Emit( handle ); - } - - bool ret = false; - - if(mIsAccessibilityTtsEnabled) - { - Actor actor = GetCurrentFocusActor(); - if(actor) - { - Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(actor); - if(control) - { - // TODO: Notify the control to scroll down. Should control handle this? -// ret = GetImplementation( control ).OnAccessibilityScrollDown(Direction::DOWN); - } - } - } - - return ret; -} - -bool AccessibilityManager::AccessibilityActionPageLeft() -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionPageLeftSignal.Empty() ) - { - mActionPageLeftSignal.Emit( handle ); - } - - bool ret = false; - - if(mIsAccessibilityTtsEnabled) - { - Actor actor = GetCurrentFocusActor(); - if(actor) - { - Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(actor); - if(control) - { - // TODO: Notify the control to scroll left to the previous page. Should control handle this? -// ret = GetImplementation( control ).OnAccessibilityScrollToPage(Direction::LEFT); - } - } - } - - return ret; -} - -bool AccessibilityManager::AccessibilityActionPageRight() -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionPageRightSignal.Empty() ) - { - mActionPageRightSignal.Emit( handle ); - } - - bool ret = false; - - if(mIsAccessibilityTtsEnabled) - { - Actor actor = GetCurrentFocusActor(); - if(actor) - { - Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(actor); - if(control) - { - // TODO: Notify the control to scroll right to the next page. Should control handle this? -// ret = GetImplementation( control ).OnAccessibilityScrollToPage(Direction::RIGHT); - } - } - } - - return ret; -} - -bool AccessibilityManager::AccessibilityActionPageUp() -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionPageUpSignal.Empty() ) - { - mActionPageUpSignal.Emit( handle ); - } - - bool ret = false; - - if(mIsAccessibilityTtsEnabled) - { - Actor actor = GetCurrentFocusActor(); - if(actor) - { - Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(actor); - if(control) - { - // TODO: Notify the control to scroll up to the previous page. Should control handle this? -// ret = GetImplementation( control ).OnAccessibilityScrollToPage(Direction::UP); - } - } - } - - return ret; -} - -bool AccessibilityManager::AccessibilityActionPageDown() -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionPageDownSignal.Empty() ) - { - mActionPageDownSignal.Emit( handle ); - } - - bool ret = false; - - if(mIsAccessibilityTtsEnabled) - { - Actor actor = GetCurrentFocusActor(); - if(actor) - { - Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(actor); - if(control) - { - // TODO: Notify the control to scroll down to the next page. Should control handle this? -// ret = GetImplementation( control ).OnAccessibilityScrollToPage(Direction::DOWN); - } - } - } - - return ret; -} - -bool AccessibilityManager::AccessibilityActionMoveToFirst() -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionMoveToFirstSignal.Empty() ) - { - mActionMoveToFirstSignal.Emit( handle ); - } - - // TODO: Move to the first item on screen - - return mIsAccessibilityTtsEnabled; -} - -bool AccessibilityManager::AccessibilityActionMoveToLast() -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionMoveToLastSignal.Empty() ) - { - mActionMoveToLastSignal.Emit( handle ); - } - - // TODO: Move to the last item on screen - - return mIsAccessibilityTtsEnabled; -} - -bool AccessibilityManager::AccessibilityActionReadFromTop() -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionReadFromTopSignal.Empty() ) - { - mActionReadFromTopSignal.Emit( handle ); - } - - // TODO: Move to the top item on screen and read from the item continuously - - return mIsAccessibilityTtsEnabled; -} - -bool AccessibilityManager::AccessibilityActionReadFromNext() -{ - Dali::Toolkit::AccessibilityManager handle( this ); - - if( !mActionReadFromNextSignal.Empty() ) - { - mActionReadFromNextSignal.Emit( handle ); - } - - if( mIsAccessibilityTtsEnabled ) - { - // Mark that we are in continuous play mode, so TTS signals can move focus. - mContinuousPlayMode = true; - - // Attempt to move to the next item and read from the item continuously. - MoveFocusForward(); - } - - return mIsAccessibilityTtsEnabled; -} - -void AccessibilityManager::TtsStateChanged( const Dali::TtsPlayer::State previousState, const Dali::TtsPlayer::State currentState ) -{ - if( mContinuousPlayMode ) - { - // If we were playing and now we have stopped, attempt to play the next item. - if( ( previousState == Dali::TtsPlayer::PLAYING ) && ( currentState == Dali::TtsPlayer::READY ) ) - { - // Attempt to move the focus forward and play. - // If we can't cancel continuous play mode. - if( !MoveFocusForward() ) - { - // We are done, exit continuous play mode. - mContinuousPlayMode = false; - } - } - else - { - // Unexpected play state change, exit continuous play mode. - mContinuousPlayMode = false; - } - } -} - -bool AccessibilityManager::AccessibilityActionZoom() -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionZoomSignal.Empty() ) - { - mActionZoomSignal.Emit( handle ); - } - - bool ret = false; - - if(mIsAccessibilityTtsEnabled) - { - Actor actor = GetCurrentFocusActor(); - if(actor) - { - Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(actor); - if(control) - { - // Notify the control to zoom - ret = GetImplementation( control ).OnAccessibilityZoom(); - } - } - } - - return ret; -} - -bool AccessibilityManager::AccessibilityActionReadPauseResume() -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionReadPauseResumeSignal.Empty() ) - { - mActionReadPauseResumeSignal.Emit( handle ); - } - - bool ret = false; - - if(mIsAccessibilityTtsEnabled) - { - // Pause or resume the TTS player - Dali::TtsPlayer player = Dali::TtsPlayer::Get(Dali::TtsPlayer::SCREEN_READER); - Dali::TtsPlayer::State state = player.GetState(); - if(state == Dali::TtsPlayer::PLAYING) - { - player.Pause(); - ret = true; - } - else if(state == Dali::TtsPlayer::PAUSED) - { - player.Resume(); - ret = true; - } - } - - return ret; -} - -bool AccessibilityManager::AccessibilityActionStartStop() -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionStartStopSignal.Empty() ) - { - mActionStartStopSignal.Emit( handle ); - } - - // TODO: Start/stop the current action - - return mIsAccessibilityTtsEnabled; -} - -bool AccessibilityManager::AccessibilityActionTouch(const TouchEvent& touchEvent) -{ - bool handled = false; - - // TODO: Need to convert the touchevent for the focused actor? - - Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(GetCurrentFocusActor()); - if(control) - { - handled = GetImplementation( control ).OnAccessibilityTouch(touchEvent); - } - - return handled; -} - -bool AccessibilityManager::HandlePanGesture(const AccessibilityGestureEvent& panEvent) -{ - bool handled = false; - - if( panEvent.state == AccessibilityGestureEvent::Started ) - { - // Find the focusable actor at the event position - Dali::HitTestAlgorithm::Results results; - AccessibilityAdaptor adaptor = AccessibilityAdaptor::Get(); - - Dali::HitTestAlgorithm::HitTest( Stage::GetCurrent(), panEvent.currentPosition, results, IsActorFocusableFunction ); - mCurrentGesturedActor = results.actor; - - if(!mCurrentGesturedActor) - { - DALI_LOG_ERROR("Gesture detected, but no hit actor\n"); - } - } - - // Gesture::Finished (Up) events are delivered with previous (Motion) event position - // Use the real previous position; otherwise we may incorrectly get a ZERO velocity - if ( AccessibilityGestureEvent::Finished != panEvent.state ) - { - // Store the previous position for next Gesture::Finished iteration. - mPreviousPosition = panEvent.previousPosition; - } - - Actor rootActor = Stage::GetCurrent().GetRootLayer(); - - Dali::PanGesture pan( static_cast(panEvent.state) ); - - pan.time = panEvent.time; - pan.numberOfTouches = panEvent.numberOfTouches; - pan.screenPosition = panEvent.currentPosition; - pan.screenDisplacement = mPreviousPosition - panEvent.currentPosition; - pan.screenVelocity.x = pan.screenDisplacement.x / panEvent.timeDelta; - pan.screenVelocity.y = pan.screenDisplacement.y / panEvent.timeDelta; - - // Only handle the pan gesture when the current focused actor is scrollable or within a scrollable actor - while(mCurrentGesturedActor && mCurrentGesturedActor != rootActor && !handled) - { - Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(mCurrentGesturedActor); - if(control) - { - Vector2 localCurrent; - control.ScreenToLocal( localCurrent.x, localCurrent.y, panEvent.currentPosition.x, panEvent.currentPosition.y ); - pan.position = localCurrent; - - Vector2 localPrevious; - control.ScreenToLocal( localPrevious.x, localPrevious.y, mPreviousPosition.x, mPreviousPosition.y ); - - pan.displacement = localCurrent - localPrevious; - pan.velocity.x = pan.displacement.x / panEvent.timeDelta; - pan.velocity.y = pan.displacement.y / panEvent.timeDelta; - - handled = GetImplementation( control ).OnAccessibilityPan(pan); - } - - // If the gesture is not handled by the control, check its parent - if(!handled) - { - mCurrentGesturedActor = mCurrentGesturedActor.GetParent(); - - if(!mCurrentGesturedActor) - { - DALI_LOG_ERROR("no more gestured actor\n"); - } - } - else - { - // If handled, then update the pan gesture properties - PanGestureDetector::SetPanGestureProperties( pan ); - } - } - - return handled; + return {}; } Toolkit::AccessibilityManager::FocusChangedSignalType& AccessibilityManager::FocusChangedSignal() diff --git a/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.h b/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.h index d51d753..7266a42 100644 --- a/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.h +++ b/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.h @@ -21,9 +21,6 @@ // EXTERNAL INCLUDES #include #include -#include -#include -#include #include // INTERNAL INCLUDES @@ -44,7 +41,7 @@ class AccessibilityManager; /** * @copydoc Toolkit::AccessibilityManager */ -class AccessibilityManager : public Dali::BaseObject, Dali::AccessibilityActionHandler, Dali::AccessibilityGestureHandler, public Dali::ConnectionTracker +class AccessibilityManager : public Dali::BaseObject, public Dali::ConnectionTracker { public: @@ -446,299 +443,36 @@ protected: virtual ~AccessibilityManager(); private: - - /** - * Get the additional information (e.g. focus order and description) of the given actor. - * @param actorID The ID of the actor to be queried - * @return The additional information of the actor - */ - ActorAdditionalInfo GetActorAdditionalInfo(const unsigned int actorID) const; - - /** - * Synchronize the actor's additional information to reflect its latest focus order - * @param actorID The ID of the actor - * @param order The focus order of the actor - * @return The additional information of the actor - */ - void SynchronizeActorAdditionalInfo(const unsigned int actorID, const unsigned int order); - - /** - * Move the focus to the specified actor and send notification for the focus change. - * @param actorID The ID of the actor to be queried - * @return Whether the focus is successful or not - */ - bool DoSetCurrentFocusActor(const unsigned int actorID); - - /** - * Move the focus to the next actor in the focus chain towards the specified direction. - * @param focusIDIter The iterator pointing to the current focused actor - * @param forward Whether the focus movement is forward or not. The focus movement will be backward if this is false. - * @param wrapped Whether the focus shoule be moved wrapped around or not - * @return Whether the focus is successful or not - */ - bool DoMoveFocus(FocusIDIter focusIDIter, bool forward, bool wrapped); - - /** - * Activate the actor. If the actor is control, call OnAccessibilityActivated virtual function. - * This function will emit FocusedActorActivatedSignal. - * @param actor The actor to activate - */ - void DoActivate(Actor actor); - - /** - * Set whether the actor is focusable or not. A focusable property will be registered for - * the actor if not yet. - * @param actor The actor to be focused - * @param focusable Whether the actor is focusable or not - */ - void SetFocusable(Actor actor, bool focusable); - - /** - * Handle the accessibility pan gesture. - * @param[in] panEvent The pan event to be handled. - * @return whether the gesture is handled successfully or not. - */ - virtual bool HandlePanGesture(const AccessibilityGestureEvent& panEvent); - - /** - * Change the accessibility status when Accessibility feature(screen-reader) turned on or off. - * @return whether the status is changed or not. - */ - virtual bool ChangeAccessibilityStatus(); - - /** - * Clear the accessibility focus from the current focused actor. - * @return whether the focus is cleared or not. - */ - virtual bool ClearAccessibilityFocus(); - - /** - * Perform the accessibility action associated with a scroll event. - * @param touchEvent The touch point (and time) of the event. - * @return whether the focus is cleared or not. - */ - virtual bool AccessibilityActionScroll( Dali::TouchEvent& touchEvent ); - - /** - * Perform the accessibility action to move focus to the previous focusable actor (by one finger flick up). - * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionPrevious(bool allowEndFeedback); - - /** - * Perform the accessibility action to move focus to the next focusable actor (by one finger flick down). - * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionNext(bool allowEndFeedback); - - /** - * Perform the accessibility action to move focus to the previous focusable actor (by one finger flick left). - * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionReadPrevious(bool allowEndFeedback); - - /** - * Perform the accessibility action to move focus to the next focusable actor (by one finger flick right). - * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionReadNext(bool allowEndFeedback); - - /** - * Perform the accessibility action to focus and read the actor (by one finger tap or move). - * @param allowReadAgain true if the action read again the same object (i.e. read action) - * false if the action just read when the focus object is changed (i.e. over action) - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionRead(bool allowReadAgain); - - /** - * Perform the accessibility action to activate the current focused actor (by one finger double tap). - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionActivate(); - - /** - * Perform the accessibility action to change the value when the current focused actor is a slider - * (by double finger down and move up and right). - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionUp(); - - /** - * Perform the accessibility action to change the value when the current focused actor is a slider - * (by double finger down and move down and left). - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionDown(); - - /** - * Perform the accessibility action to navigate back (by two fingers circle draw). - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionBack(); - - /** - * Perform the accessibility action to scroll up the list and focus on the first item on the list - * after the scrolling and read the item (by two finger swipe up). - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionScrollUp(); - - /** - * Perform the accessibility action to scroll down the list and focus on the first item on the list - * after the scrolling and read the item (by two finger swipe down). - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionScrollDown(); - - /** - * Perform the accessibility action to scroll left to the previous page (by two finger swipe left). - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionPageLeft(); - - /** - * Perform the accessibility action to scroll right to the next page (by two finger swipe right). - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionPageRight(); - - /** - * Perform the accessibility action to scroll up to the previous page (by one finger swipe left and right). - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionPageUp(); - - /** - * Perform the accessibility action to scroll down to the next page (by one finger swipe right and left). - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionPageDown(); - - /** - * Perform the accessibility action to move the focus to the first item on the screen - * (by one finger swipe up and down). - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionMoveToFirst(); - - /** - * Perform the accessibility action to move the focus to the last item on the screen - * (by one finger swipe down and up). - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionMoveToLast(); - - /** - * Perform the accessibility action to move the focus to the first item on the top - * and read from the top item continuously (by three fingers single tap). - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionReadFromTop(); - - /** - * Perform the accessibility action to move the focus to and read from the next item - * continuously (by three fingers double tap). - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionReadFromNext(); - - /** - * Perform the accessibility action to move the focus to do the zooming (by one finger triple tap). - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionZoom(); - - /** - * Perform the accessibility action to pause/resume the current read out (by two fingers single tap). - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionReadPauseResume(); - - /** - * Perform the accessibility action to start/stop the current action (by two fingers double tap). - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionStartStop(); - - /** - * Perform the accessibility action to mouse move (by one finger tap & hold and move). - * @param touchEvent touch event structure - * @return whether the accessibility action is performed or not. - */ - virtual bool AccessibilityActionTouch(const TouchEvent& touchEvent); - - /** - * This function is connected to the TtsPlayer StateChangeSignal. - * It is called when the TTS players state changes. - * @param previousState The previous state of the TTS player (for comparison) - * @param currentState The current state of the TTS player - */ - void TtsStateChanged( const Dali::TtsPlayer::State previousState, const Dali::TtsPlayer::State currentState ); - -private: - - // Undefined - AccessibilityManager(const AccessibilityManager&); - - AccessibilityManager& operator=(const AccessibilityManager& rhs); - -private: - - Toolkit::AccessibilityManager::FocusChangedSignalType mFocusChangedSignal; ///< The signal to notify the focus change - Toolkit::AccessibilityManager::FocusOvershotSignalType mFocusOvershotSignal; ///< The signal to notify the focus overshooted - Toolkit::AccessibilityManager::FocusedActorActivatedSignalType mFocusedActorActivatedSignal; ///< The signal to notify the activation of focused actor - - // Action signals. - AccessibilityActionSignalType mStatusChangedSignal; - AccessibilityActionSignalType mActionNextSignal; - AccessibilityActionSignalType mActionPreviousSignal; - AccessibilityActionSignalType mActionActivateSignal; - AccessibilityActionSignalType mActionOverSignal; - AccessibilityActionSignalType mActionReadSignal; - AccessibilityActionSignalType mActionReadNextSignal; - AccessibilityActionSignalType mActionReadPreviousSignal; - AccessibilityActionSignalType mActionUpSignal; - AccessibilityActionSignalType mActionDownSignal; - AccessibilityActionSignalType mActionClearFocusSignal; - AccessibilityActionSignalType mActionBackSignal; - AccessibilityActionSignalType mActionScrollUpSignal; - AccessibilityActionSignalType mActionScrollDownSignal; - AccessibilityActionSignalType mActionPageLeftSignal; - AccessibilityActionSignalType mActionPageRightSignal; - AccessibilityActionSignalType mActionPageUpSignal; - AccessibilityActionSignalType mActionPageDownSignal; - AccessibilityActionSignalType mActionMoveToFirstSignal; - AccessibilityActionSignalType mActionMoveToLastSignal; - AccessibilityActionSignalType mActionReadFromTopSignal; - AccessibilityActionSignalType mActionReadFromNextSignal; - AccessibilityActionSignalType mActionZoomSignal; - AccessibilityActionSignalType mActionReadIndicatorInformationSignal; - AccessibilityActionSignalType mActionReadPauseResumeSignal; - AccessibilityActionSignalType mActionStartStopSignal; + AccessibilityActionSignalType mStatusChangedSignal; + AccessibilityActionSignalType mActionNextSignal; + AccessibilityActionSignalType mActionPreviousSignal; + AccessibilityActionSignalType mActionActivateSignal; + AccessibilityActionSignalType mActionOverSignal; + AccessibilityActionSignalType mActionReadSignal; + AccessibilityActionSignalType mActionReadNextSignal; + AccessibilityActionSignalType mActionReadPreviousSignal; + AccessibilityActionSignalType mActionUpSignal; + AccessibilityActionSignalType mActionDownSignal; + AccessibilityActionSignalType mActionClearFocusSignal; + AccessibilityActionSignalType mActionBackSignal; + AccessibilityActionSignalType mActionScrollUpSignal; + AccessibilityActionSignalType mActionScrollDownSignal; + AccessibilityActionSignalType mActionPageLeftSignal; + AccessibilityActionSignalType mActionPageRightSignal; + AccessibilityActionSignalType mActionPageUpSignal; + AccessibilityActionSignalType mActionPageDownSignal; + AccessibilityActionSignalType mActionMoveToFirstSignal; + AccessibilityActionSignalType mActionMoveToLastSignal; + AccessibilityActionSignalType mActionReadFromTopSignal; + AccessibilityActionSignalType mActionReadFromNextSignal; + AccessibilityActionSignalType mActionZoomSignal; + AccessibilityActionSignalType mActionReadIndicatorInformationSignal; + AccessibilityActionSignalType mActionReadPauseResumeSignal; + AccessibilityActionSignalType mActionStartStopSignal; AccessibilityActionScrollSignalType mActionScrollSignal; - - FocusIDContainer mFocusIDContainer; ///< The container to look up actor ID by focus order - IDAdditionalInfoContainer mIDAdditionalInfoContainer; ///< The container to look up additional information by actor ID - FocusIDPair mCurrentFocusActor; ///< The focus order and actor ID of current focused actor - Actor mCurrentGesturedActor; ///< The actor that will handle the gesture - Actor mFocusIndicatorActor; ///< The focus indicator actor shared by all the focusable actors for highlight - Vector2 mPreviousPosition; ///< The previous pan position; useful for calculating velocity for Gesture::Finished events - unsigned int mRecursiveFocusMoveCounter; ///< The counter to count the number of recursive focus movement attempted before the focus movement is successful. - - bool mIsWrapped:1; ///< Whether the focus movement is wrapped around or not - bool mIsFocusWithinGroup:1; ///< Whether the focus movement is limited to the current focus group or not - bool mIsEndcapFeedbackEnabled:1; ///< Whether the endcap feedback need to be played when the focus leaves the end or vice versa - bool mIsEndcapFeedbackPlayed:1; ///< Whether the endcap feedback was played or not - bool mIsAccessibilityTtsEnabled:1; ///< Whether accessibility feature(screen-reader) turned on/off - bool mTtsCreated:1; ///< Whether the TTS Player has been accessed - bool mIsFocusIndicatorEnabled:1; ///< Whether indicator should be shown / hidden. It could be enabled when TTS enabled or 'Tab' key operated. - bool mContinuousPlayMode:1; ///< Keeps track of whether or not we are in continuous play mode - + Toolkit::AccessibilityManager::FocusChangedSignalType mFocusChangedSignal; + Toolkit::AccessibilityManager::FocusOvershotSignalType mFocusOvershotSignal; + Toolkit::AccessibilityManager::FocusedActorActivatedSignalType mFocusedActorActivatedSignal; }; } // namespace Internal diff --git a/dali-toolkit/internal/controls/alignment/alignment-impl.cpp b/dali-toolkit/internal/controls/alignment/alignment-impl.cpp index 6641d26..8827959 100644 --- a/dali-toolkit/internal/controls/alignment/alignment-impl.cpp +++ b/dali-toolkit/internal/controls/alignment/alignment-impl.cpp @@ -24,6 +24,9 @@ #include #include +// INTERNAL INCLUDES +#include + namespace Dali { @@ -296,6 +299,10 @@ Alignment::Alignment( Toolkit::Alignment::Type horizontal, Toolkit::Alignment::T mScaling( Toolkit::Alignment::ScaleNone ), mPadding( 0.f, 0.f, 0.f, 0.f ) { + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::FILLER ) ); + } ); } Alignment::~Alignment() diff --git a/dali-toolkit/internal/controls/alignment/alignment-impl.h b/dali-toolkit/internal/controls/alignment/alignment-impl.h index 83f5301..2ce0c95 100644 --- a/dali-toolkit/internal/controls/alignment/alignment-impl.h +++ b/dali-toolkit/internal/controls/alignment/alignment-impl.h @@ -21,6 +21,7 @@ // INTERNAL INCLUDES #include #include +#include namespace Dali { diff --git a/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp b/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp index 14f179b..258ac03 100644 --- a/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp +++ b/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp @@ -35,6 +35,7 @@ #include #include #include +#include namespace Dali { @@ -157,6 +158,10 @@ BloomView::BloomView() mImageSaturationPropertyIndex(Property::INVALID_INDEX), mActivated( false ) { + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::ANIMATION ) ); + } ); } BloomView::BloomView( const unsigned int blurNumSamples, const float blurBellCurveWidth, const Pixel::Format renderTargetPixelFormat, diff --git a/dali-toolkit/internal/controls/buttons/button-impl.cpp b/dali-toolkit/internal/controls/buttons/button-impl.cpp index 1af6848..1460d7b 100644 --- a/dali-toolkit/internal/controls/buttons/button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/button-impl.cpp @@ -1319,6 +1319,22 @@ Padding Button::GetForegroundPadding() return mForegroundPadding; } +std::string Button::AccessibleImpl::GetNameRaw() +{ + auto slf = Toolkit::Button::DownCast( self ); + return slf.GetProperty( Toolkit::Button::Property::LABEL ); +} + +Dali::Accessibility::States Button::AccessibleImpl::CalculateStates() +{ + auto tmp = Control::Impl::AccessibleImpl::CalculateStates(); + tmp[Dali::Accessibility::State::SELECTABLE] = true; + auto slf = Toolkit::Button::DownCast( self ); + tmp[Dali::Accessibility::State::ENABLED] = !slf.GetProperty( Toolkit::Button::Property::DISABLED ); + tmp[Dali::Accessibility::State::CHECKED] = slf.GetProperty( Toolkit::Button::Property::SELECTED ); + return tmp; +} + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/controls/buttons/button-impl.h b/dali-toolkit/internal/controls/buttons/button-impl.h index 0915d3e..437b4bf 100644 --- a/dali-toolkit/internal/controls/buttons/button-impl.h +++ b/dali-toolkit/internal/controls/buttons/button-impl.h @@ -26,6 +26,7 @@ #include #include #include +#include namespace Dali { @@ -540,6 +541,15 @@ private: // Actions bool mClickActionPerforming; ///< Used to manage signal emissions during action + +protected: + struct AccessibleImpl : public Control::Impl::AccessibleImpl + { + using Control::Impl::AccessibleImpl::AccessibleImpl; + + Dali::Accessibility::States CalculateStates() override; + std::string GetNameRaw() override; + }; }; } // namespace Internal diff --git a/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp b/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp index 9554ccb..938c4e8 100644 --- a/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp @@ -75,6 +75,10 @@ CheckBoxButton::CheckBoxButton() : Button() { SetTogglableButton( true ); + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new AccessibleImpl( actor, Dali::Accessibility::Role::CHECK_BOX ) ); + } ); } CheckBoxButton::~CheckBoxButton() @@ -86,6 +90,25 @@ void CheckBoxButton::OnInitialize() Button::OnInitialize(); } +Dali::Accessibility::States CheckBoxButton::AccessibleImpl::CalculateStates() +{ + auto tmp = Button::AccessibleImpl::CalculateStates(); + auto slf = Toolkit::Button::DownCast( self ); + if( slf.GetProperty( Toolkit::Button::Property::SELECTED ) ) + tmp[Dali::Accessibility::State::CHECKED] = true; + return tmp; +} + +void CheckBoxButton::OnStateChange( State newState ) +{ + // TODO: replace it with OnPropertySet hook once Button::Property::SELECTED will be consistently used + if (Dali::Accessibility::IsUp() && (newState == SELECTED_STATE || newState == UNSELECTED_STATE)) + { + Dali::Accessibility::Accessible::Get(Self())->EmitStateChanged( + Dali::Accessibility::State::CHECKED, newState == SELECTED_STATE ? 1 : 0, 0 + ); + } +} } // namespace Internal diff --git a/dali-toolkit/internal/controls/buttons/check-box-button-impl.h b/dali-toolkit/internal/controls/buttons/check-box-button-impl.h index aa99068..5a5b487 100644 --- a/dali-toolkit/internal/controls/buttons/check-box-button-impl.h +++ b/dali-toolkit/internal/controls/buttons/check-box-button-impl.h @@ -77,7 +77,14 @@ private: // Undefined CheckBoxButton& operator=( const CheckBoxButton& ); - +protected: + struct AccessibleImpl : public Button::AccessibleImpl + { + using Button::AccessibleImpl::AccessibleImpl; + + Dali::Accessibility::States CalculateStates() override; + }; + void OnStateChange( State newState ) override; }; } // namespace Internal diff --git a/dali-toolkit/internal/controls/buttons/push-button-impl.cpp b/dali-toolkit/internal/controls/buttons/push-button-impl.cpp index f263489..333c6d1 100644 --- a/dali-toolkit/internal/controls/buttons/push-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/push-button-impl.cpp @@ -100,6 +100,10 @@ PushButton::PushButton() : Button(), mIconAlignment( RIGHT ) { + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new AccessibleImpl( actor, Dali::Accessibility::Role::PUSH_BUTTON ) ); + } ); } PushButton::~PushButton() @@ -242,6 +246,25 @@ Property::Value PushButton::GetProperty( BaseObject* object, Property::Index pro return value; } +Dali::Accessibility::States PushButton::AccessibleImpl::CalculateStates() +{ + auto tmp = Button::AccessibleImpl::CalculateStates(); + auto slf = Toolkit::Button::DownCast( self ); + tmp[Dali::Accessibility::State::PRESSED] = slf.GetProperty( Toolkit::Button::Property::SELECTED ); + return tmp; +} + +void PushButton::OnStateChange( State newState ) +{ + // TODO: replace it with OnPropertySet hook once Button::Property::SELECTED will be consistently used + if (Dali::Accessibility::IsUp() && (newState == SELECTED_STATE || newState == UNSELECTED_STATE)) + { + Dali::Accessibility::Accessible::Get(Self())->EmitStateChanged( + Dali::Accessibility::State::PRESSED, newState == SELECTED_STATE ? 1 : 0, 0 + ); + } +} + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/controls/buttons/push-button-impl.h b/dali-toolkit/internal/controls/buttons/push-button-impl.h index 8e11d79..8cd0ea3 100644 --- a/dali-toolkit/internal/controls/buttons/push-button-impl.h +++ b/dali-toolkit/internal/controls/buttons/push-button-impl.h @@ -127,6 +127,15 @@ private: private: IconAlignment mIconAlignment; ///< The alignment of the icon against the label. + +protected: + struct AccessibleImpl : public Button::AccessibleImpl + { + using Button::AccessibleImpl::AccessibleImpl; + + Dali::Accessibility::States CalculateStates() override; + }; + void OnStateChange( State newState ) override; }; } // namespace Internal diff --git a/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp b/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp index bbd151a..ffa52b4 100644 --- a/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp @@ -67,6 +67,10 @@ Dali::Toolkit::RadioButton RadioButton::New() RadioButton::RadioButton() { SetTogglableButton(true); + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new AccessibleImpl( actor, Dali::Accessibility::Role::RADIO_BUTTON ) ); + } ); } RadioButton::~RadioButton() @@ -104,6 +108,23 @@ void RadioButton::OnStateChange( State newState ) } } } + // TODO: replace it with OnPropertySet hook once Button::Property::SELECTED will be consistently used + if (Dali::Accessibility::IsUp() && (newState == SELECTED_STATE || newState == UNSELECTED_STATE)) + { + Dali::Accessibility::Accessible::Get(Self())->EmitStateChanged( + Dali::Accessibility::State::CHECKED, newState == SELECTED_STATE ? 1 : 0, 0 + ); + } +} + +Dali::Accessibility::States RadioButton::AccessibleImpl::CalculateStates() +{ + auto tmp = Button::AccessibleImpl::CalculateStates(); + auto slf = Toolkit::Button::DownCast( self ); + if( slf.GetProperty( Toolkit::Button::Property::SELECTED ) ) + tmp[Dali::Accessibility::State::CHECKED] = true; + tmp[Dali::Accessibility::State::SELECTABLE] = true; + return tmp; } } // namespace Internal diff --git a/dali-toolkit/internal/controls/buttons/radio-button-impl.h b/dali-toolkit/internal/controls/buttons/radio-button-impl.h index 944162b..e13d499 100644 --- a/dali-toolkit/internal/controls/buttons/radio-button-impl.h +++ b/dali-toolkit/internal/controls/buttons/radio-button-impl.h @@ -85,6 +85,14 @@ private: // Undefined RadioButton& operator=( const RadioButton& origin ); + +protected: + struct AccessibleImpl : public Button::AccessibleImpl + { + using Button::AccessibleImpl::AccessibleImpl; + + Dali::Accessibility::States CalculateStates() override; + }; }; } // namespace Internal diff --git a/dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp b/dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp old mode 100755 new mode 100644 index 6aaf423..25e3856 --- a/dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp @@ -97,6 +97,10 @@ ToggleButton::ToggleButton() { DALI_LOG_INFO( gLogButtonFilter, Debug::General, "ToggleButton::Constructor\n" ); SetTogglableButton( false ); + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new AccessibleImpl( actor, Dali::Accessibility::Role::TOGGLE_BUTTON ) ); + } ); } ToggleButton::~ToggleButton() @@ -373,6 +377,17 @@ void ToggleButton::OnPressed() RelayoutRequest(); } +void ToggleButton::OnStateChange( State newState ) +{ + // TODO: replace it with OnPropertySet hook once Button::Property::SELECTED will be consistently used + if (Dali::Accessibility::IsUp() && (newState == SELECTED_STATE || newState == UNSELECTED_STATE)) + { + Dali::Accessibility::Accessible::Get(Self())->EmitStateChanged( + Dali::Accessibility::State::CHECKED, newState == SELECTED_STATE ? 1 : 0, 0 + ); + } +} + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/controls/buttons/toggle-button-impl.h b/dali-toolkit/internal/controls/buttons/toggle-button-impl.h index 2c4f753..3826c7b 100644 --- a/dali-toolkit/internal/controls/buttons/toggle-button-impl.h +++ b/dali-toolkit/internal/controls/buttons/toggle-button-impl.h @@ -163,6 +163,8 @@ private: std::vector mToggleDisabledSelectedVisuals; ///< Save all disabled selected visuals. std::vector mToggleTooltips; ///< Toggle tooltips. unsigned int mCurrentToggleIndex; ///< The index of state. +protected: + void OnStateChange( State newState ) override; }; } // namespace Internal diff --git a/dali-toolkit/internal/controls/control/control-data-impl.cpp b/dali-toolkit/internal/controls/control/control-data-impl.cpp index 72fd212..18445e0 100755 --- a/dali-toolkit/internal/controls/control/control-data-impl.cpp +++ b/dali-toolkit/internal/controls/control/control-data-impl.cpp @@ -26,6 +26,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include @@ -38,6 +44,18 @@ #include #include #include +#include +#include + +namespace +{ + const std::string READING_INFO_TYPE_NAME = "name"; + const std::string READING_INFO_TYPE_ROLE = "role"; + const std::string READING_INFO_TYPE_DESCRIPTION = "description"; + const std::string READING_INFO_TYPE_STATE = "state"; + const std::string READING_INFO_TYPE_ATTRIBUTE_NAME = "reading_info_type"; + const std::string READING_INFO_TYPE_SEPARATOR = "|"; +} namespace Dali { @@ -171,17 +189,67 @@ void MoveVisual( RegisteredVisualContainer::Iterator sourceIter, RegisteredVisua * @return true if action has been accepted by this control */ const char* ACTION_ACCESSIBILITY_ACTIVATED = "accessibilityActivated"; +const char* ACTION_ACCESSIBILITY_READING_SKIPPED = "ReadingSkipped"; +const char* ACTION_ACCESSIBILITY_READING_CANCELLED = "ReadingCancelled"; +const char* ACTION_ACCESSIBILITY_READING_STOPPED = "ReadingStopped"; + static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes ) { bool ret = false; - if( object && ( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_ACTIVATED ) ) ) + if( object && + ( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_ACTIVATED ) || + actionName == "activate" ) ) + { + Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) ); + if( control ) + { + // if cast succeeds there is an implementation so no need to check + if (!DevelControl::AccessibilityActivateSignal( control ).Empty()) { + DevelControl::AccessibilityActivateSignal( control ).Emit(); + ret = true; + } + else + ret = Internal::GetImplementation( control ).OnAccessibilityActivated(); + } + } + else if( object && ( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_SKIPPED ) ) ) + { + Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) ); + if( control ) + { + // if cast succeeds there is an implementation so no need to check + if (!DevelControl::AccessibilityReadingSkippedSignal( control ).Empty()) + { + DevelControl::AccessibilityReadingSkippedSignal( control ).Emit(); + ret = true; + } + } + } + else if( object && ( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_CANCELLED ) ) ) { Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) ); if( control ) { // if cast succeeds there is an implementation so no need to check - ret = Internal::GetImplementation( control ).OnAccessibilityActivated(); + if (!DevelControl::AccessibilityReadingCancelledSignal( control ).Empty()) + { + DevelControl::AccessibilityReadingCancelledSignal( control ).Emit(); + ret = true; + } + } + } + else if( object && ( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_STOPPED ) ) ) + { + Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) ); + if( control ) + { + // if cast succeeds there is an implementation so no need to check + if (!DevelControl::AccessibilityReadingStoppedSignal( control ).Empty()) + { + DevelControl::AccessibilityReadingStoppedSignal( control ).Emit(); + ret = true; + } } } @@ -204,6 +272,9 @@ const char* SIGNAL_TAPPED = "tapped"; const char* SIGNAL_PANNED = "panned"; const char* SIGNAL_PINCHED = "pinched"; const char* SIGNAL_LONG_PRESSED = "longPressed"; +const char* SIGNAL_GET_NAME = "getName"; +const char* SIGNAL_GET_DESCRIPTION = "getDescription"; +const char* SIGNAL_DO_GESTURE = "doGesture"; static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ) { Dali::BaseHandle handle( object ); @@ -247,6 +318,19 @@ static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tra controlImpl.EnableGestureDetection( Gesture::LongPress ); controlImpl.GetLongPressGestureDetector().DetectedSignal().Connect( tracker, functor ); } + else if( 0 == strcmp( signalName.c_str(), SIGNAL_GET_NAME ) ) + { + DevelControl::AccessibilityGetNameSignal( control ).Connect( tracker, functor ); + } + else if( 0 == strcmp( signalName.c_str(), SIGNAL_GET_DESCRIPTION ) ) + { + DevelControl::AccessibilityGetDescriptionSignal( control ).Connect( tracker, functor ); + } + else if( 0 == strcmp( signalName.c_str(), SIGNAL_DO_GESTURE ) ) + { + DevelControl::AccessibilityDoGestureSignal( control ).Connect( tracker, functor ); + } + } return connected; } @@ -270,8 +354,15 @@ SignalConnectorType registerSignal4( typeRegistration, SIGNAL_TAPPED, &DoConnect SignalConnectorType registerSignal5( typeRegistration, SIGNAL_PANNED, &DoConnectSignal ); SignalConnectorType registerSignal6( typeRegistration, SIGNAL_PINCHED, &DoConnectSignal ); SignalConnectorType registerSignal7( typeRegistration, SIGNAL_LONG_PRESSED, &DoConnectSignal ); +SignalConnectorType registerSignal8( typeRegistration, SIGNAL_GET_NAME, &DoConnectSignal ); +SignalConnectorType registerSignal9( typeRegistration, SIGNAL_GET_DESCRIPTION, &DoConnectSignal ); +SignalConnectorType registerSignal10( typeRegistration, SIGNAL_DO_GESTURE, &DoConnectSignal ); -TypeAction registerAction( typeRegistration, ACTION_ACCESSIBILITY_ACTIVATED, &DoAction ); +TypeAction registerAction1( typeRegistration, "activate", &DoAction ); +TypeAction registerAction2( typeRegistration, ACTION_ACCESSIBILITY_ACTIVATED, &DoAction ); +TypeAction registerAction3( typeRegistration, ACTION_ACCESSIBILITY_READING_SKIPPED, &DoAction ); +TypeAction registerAction4( typeRegistration, ACTION_ACCESSIBILITY_READING_CANCELLED, &DoAction ); +TypeAction registerAction5( typeRegistration, ACTION_ACCESSIBILITY_READING_STOPPED, &DoAction ); DALI_TYPE_REGISTRATION_END() @@ -311,6 +402,13 @@ const PropertyRegistration Control::Impl::PROPERTY_11( typeRegistration, "leftFo const PropertyRegistration Control::Impl::PROPERTY_12( typeRegistration, "rightFocusableActorId", Toolkit::DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID,Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); const PropertyRegistration Control::Impl::PROPERTY_13( typeRegistration, "upFocusableActorId", Toolkit::DevelControl::Property::UP_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); const PropertyRegistration Control::Impl::PROPERTY_14( typeRegistration, "downFocusableActorId", Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); +const PropertyRegistration Control::Impl::PROPERTY_15( typeRegistration, "accessibilityAttributes", Toolkit::DevelControl::Property::ACCESSIBILITY_ATTRIBUTES, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); +const PropertyRegistration Control::Impl::PROPERTY_16( typeRegistration, "accessibilityName", Toolkit::DevelControl::Property::ACCESSIBILITY_NAME, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); +const PropertyRegistration Control::Impl::PROPERTY_17( typeRegistration, "accessibilityDescription", Toolkit::DevelControl::Property::ACCESSIBILITY_DESCRIPTON, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); +const PropertyRegistration Control::Impl::PROPERTY_18( typeRegistration, "accessibilityTranslationDomain", Toolkit::DevelControl::Property::ACCESSIBILITY_TRANSLATION_DOMAIN, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); +const PropertyRegistration Control::Impl::PROPERTY_19( typeRegistration, "accessibilityRole", Toolkit::DevelControl::Property::ACCESSIBILITY_ROLE, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); +const PropertyRegistration Control::Impl::PROPERTY_20( typeRegistration, "accessibilityHighlightable", Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); +const PropertyRegistration Control::Impl::PROPERTY_21( typeRegistration, "accessibilityAnimated", Toolkit::DevelControl::Property::ACCESSIBILITY_ANIMATED, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); Control::Impl::Impl( Control& controlImpl ) : mControlImpl( controlImpl ), @@ -330,6 +428,9 @@ Control::Impl::Impl( Control& controlImpl ) mKeyInputFocusLostSignal(), mResourceReadySignal(), mVisualEventSignal(), + mAccessibilityGetNameSignal(), + mAccessibilityGetDescriptionSignal(), + mAccessibilityDoGestureSignal(), mPinchGestureDetector(), mPanGestureDetector(), mTapGestureDetector(), @@ -343,10 +444,27 @@ Control::Impl::Impl( Control& controlImpl ) mIsKeyboardFocusGroup( false ), mIsAutofillEnabled( false ) { + Dali::Accessibility::Accessible::RegisterControlAccessibilityGetter( + []( Dali::Actor actor ) -> Dali::Accessibility::Accessible* { + return Control::Impl::GetAccessibilityObject( actor ); + } ); + + accessibilityConstructor = []( Dali::Actor actor ) -> std::unique_ptr< Dali::Accessibility::Accessible > { + return std::unique_ptr< Dali::Accessibility::Accessible >( new AccessibleImpl( actor, + Dali::Accessibility::Role::UNKNOWN ) ); + }; + + size_t len = static_cast(Dali::Accessibility::RelationType::LAST_DEFINED); + mAccessibilityRelations.reserve(len); + for (auto i = 0u; i < len; ++i) + { + mAccessibilityRelations.push_back({}); + } } Control::Impl::~Impl() { + AccessibilityDeregister(); // All gesture detectors will be destroyed so no need to disconnect. delete mStartingPinchScale; } @@ -818,6 +936,20 @@ void Control::Impl::DoAction( Dali::Property::Index visualIndex, Dali::Property: } } +void Control::Impl::AppendAccessibilityAttribute( const std::string& key, + const std::string value ) +{ + Property::Value* val = mAccessibilityAttributes.Find( key ); + if( val ) + { + mAccessibilityAttributes[key] = Property::Value( value ); + } + else + { + mAccessibilityAttributes.Insert( key, value ); + } +} + void Control::Impl::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value ) { Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) ); @@ -891,6 +1023,76 @@ void Control::Impl::SetProperty( BaseObject* object, Property::Index index, cons } break; + case Toolkit::DevelControl::Property::ACCESSIBILITY_NAME: + { + std::string name; + if( value.Get( name ) ) + { + controlImpl.mImpl->mAccessibilityName = name; + controlImpl.mImpl->mAccessibilityNameSet = true; + } + else + { + controlImpl.mImpl->mAccessibilityNameSet = false; + } + } + break; + + case Toolkit::DevelControl::Property::ACCESSIBILITY_DESCRIPTON: + { + std::string txt; + if( value.Get( txt ) ) + { + controlImpl.mImpl->mAccessibilityDescription = txt; + controlImpl.mImpl->mAccessibilityDescriptionSet = true; + } + else + { + controlImpl.mImpl->mAccessibilityDescriptionSet = false; + } + } + break; + + case Toolkit::DevelControl::Property::ACCESSIBILITY_TRANSLATION_DOMAIN: + { + std::string txt; + if( value.Get( txt ) ) + { + controlImpl.mImpl->mAccessibilityTranslationDomain = txt; + controlImpl.mImpl->mAccessibilityTranslationDomainSet = true; + } + else + { + controlImpl.mImpl->mAccessibilityTranslationDomainSet = false; + } + } + break; + + case Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE: + { + bool highlightable; + if( value.Get( highlightable ) ) + { + controlImpl.mImpl->mAccessibilityHighlightable = highlightable; + controlImpl.mImpl->mAccessibilityHighlightableSet = true; + } + else + { + controlImpl.mImpl->mAccessibilityHighlightableSet = false; + } + } + break; + + case Toolkit::DevelControl::Property::ACCESSIBILITY_ROLE: + { + Dali::Accessibility::Role val; + if( value.Get( val ) ) + { + controlImpl.mImpl->mAccessibilityRole = val; + } + } + break; + case Toolkit::DevelControl::Property::UP_FOCUSABLE_ACTOR_ID: { int focusId; @@ -985,6 +1187,17 @@ void Control::Impl::SetProperty( BaseObject* object, Property::Index index, cons break; } + case Toolkit::DevelControl::Property::ACCESSIBILITY_ATTRIBUTES: + { + value.Get( controlImpl.mImpl->mAccessibilityAttributes ); + break; + } + + case Toolkit::DevelControl::Property::ACCESSIBILITY_ANIMATED: + { + value.Get( controlImpl.mImpl->mAccessibilityAnimated ); + break; + } } } } @@ -1031,6 +1244,48 @@ Property::Value Control::Impl::GetProperty( BaseObject* object, Property::Index break; } + case Toolkit::DevelControl::Property::ACCESSIBILITY_NAME: + { + if (controlImpl.mImpl->mAccessibilityNameSet) + { + value = controlImpl.mImpl->mAccessibilityName; + } + break; + } + + case Toolkit::DevelControl::Property::ACCESSIBILITY_DESCRIPTON: + { + if (controlImpl.mImpl->mAccessibilityDescriptionSet) + { + value = controlImpl.mImpl->mAccessibilityDescription; + } + break; + } + + case Toolkit::DevelControl::Property::ACCESSIBILITY_TRANSLATION_DOMAIN: + { + if (controlImpl.mImpl->mAccessibilityTranslationDomainSet) + { + value = controlImpl.mImpl->mAccessibilityTranslationDomain; + } + break; + } + + case Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE: + { + if (controlImpl.mImpl->mAccessibilityHighlightableSet) + { + value = controlImpl.mImpl->mAccessibilityHighlightable; + } + break; + } + + case Toolkit::DevelControl::Property::ACCESSIBILITY_ROLE: + { + value = Property::Value(controlImpl.mImpl->mAccessibilityRole); + break; + } + case Toolkit::DevelControl::Property::UP_FOCUSABLE_ACTOR_ID: { value = controlImpl.mImpl->mUpFocusableActorId; @@ -1084,12 +1339,105 @@ Property::Value Control::Impl::GetProperty( BaseObject* object, Property::Index value = map; break; } + + case Toolkit::DevelControl::Property::ACCESSIBILITY_ATTRIBUTES: + { + value = controlImpl.mImpl->mAccessibilityAttributes; + break; + } + + case Toolkit::DevelControl::Property::ACCESSIBILITY_ANIMATED: + { + value = controlImpl.mImpl->mAccessibilityAnimated; + break; + } } } return value; } +void Control::Impl::RemoveAccessibilityAttribute( const std::string& key ) +{ + Property::Value* val = mAccessibilityAttributes.Find( key ); + if( val ) + mAccessibilityAttributes[key] = Property::Value(); +} + +void Control::Impl::ClearAccessibilityAttributes() +{ + mAccessibilityAttributes.Clear(); +} + +void Control::Impl::SetAccessibilityReadingInfoType( const Dali::Accessibility::ReadingInfoTypes types ) +{ + std::string value; + if ( types[ Dali::Accessibility::ReadingInfoType::NAME ] ) + { + value += READING_INFO_TYPE_NAME; + } + if ( types[ Dali::Accessibility::ReadingInfoType::ROLE ] ) + { + if( !value.empty() ) + { + value += READING_INFO_TYPE_SEPARATOR; + } + value += READING_INFO_TYPE_ROLE; + } + if ( types[ Dali::Accessibility::ReadingInfoType::DESCRIPTION ] ) + { + if( !value.empty() ) + { + value += READING_INFO_TYPE_SEPARATOR; + } + value += READING_INFO_TYPE_DESCRIPTION; + } + if ( types[ Dali::Accessibility::ReadingInfoType::STATE ] ) + { + if( !value.empty() ) + { + value += READING_INFO_TYPE_SEPARATOR; + } + value += READING_INFO_TYPE_STATE; + } + AppendAccessibilityAttribute( READING_INFO_TYPE_ATTRIBUTE_NAME, value ); +} + +Dali::Accessibility::ReadingInfoTypes Control::Impl::GetAccessibilityReadingInfoType() const +{ + std::string value; + auto place = mAccessibilityAttributes.Find( READING_INFO_TYPE_ATTRIBUTE_NAME ); + if( place ) + { + place->Get( value ); + } + + if ( value.empty() ) + { + return {}; + } + + Dali::Accessibility::ReadingInfoTypes types; + + if ( value.find( READING_INFO_TYPE_NAME ) != std::string::npos ) + { + types[ Dali::Accessibility::ReadingInfoType::NAME ] = true; + } + if ( value.find( READING_INFO_TYPE_ROLE ) != std::string::npos ) + { + types[ Dali::Accessibility::ReadingInfoType::ROLE ] = true; + } + if ( value.find( READING_INFO_TYPE_DESCRIPTION ) != std::string::npos ) + { + types[ Dali::Accessibility::ReadingInfoType::DESCRIPTION ] = true; + } + if ( value.find( READING_INFO_TYPE_STATE ) != std::string::npos ) + { + types[ Dali::Accessibility::ReadingInfoType::STATE ] = true; + } + + return types; +} void Control::Impl::CopyInstancedProperties( RegisteredVisualContainer& visuals, Dictionary& instancedProperties ) { @@ -1432,6 +1780,404 @@ Toolkit::AutofillContainer Control::Impl::GetAutofillContainer() return mAutofillContainer; } + +Dali::Accessibility::Accessible *Control::Impl::GetAccessibilityObject() +{ + if( !accessibilityObject ) + accessibilityObject = accessibilityConstructor( mControlImpl.Self() ); + return accessibilityObject.get(); +} + +Dali::Accessibility::Accessible *Control::Impl::GetAccessibilityObject(Dali::Actor actor) +{ + if( actor ) + { + auto q = Dali::Toolkit::Control::DownCast( actor ); + if( q ) + { + auto q2 = static_cast< Internal::Control* >( &q.GetImplementation() ); + return q2->mImpl->GetAccessibilityObject(); + } + } + return nullptr; +} + +Control::Impl::AccessibleImpl::AccessibleImpl(Dali::Actor self, Dali::Accessibility::Role role, bool modal) + : self(self), modal(modal) +{ + auto control = Dali::Toolkit::Control::DownCast(self); + + Internal::Control& internalControl = Toolkit::Internal::GetImplementation( control ); + Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( internalControl ); + if( controlImpl.mAccessibilityRole == Dali::Accessibility::Role::UNKNOWN ) + controlImpl.mAccessibilityRole = role; +} + +std::string Control::Impl::AccessibleImpl::GetName() +{ + auto control = Dali::Toolkit::Control::DownCast(self); + + Internal::Control& internalControl = Toolkit::Internal::GetImplementation( control ); + Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( internalControl ); + + if (!controlImpl.mAccessibilityGetNameSignal.Empty()) { + std::string ret; + controlImpl.mAccessibilityGetNameSignal.Emit(ret); + return ret; + } + + if (controlImpl.mAccessibilityNameSet) + return controlImpl.mAccessibilityName; + + return GetNameRaw(); +} + +std::string Control::Impl::AccessibleImpl::GetNameRaw() +{ + return self.GetName(); +} + +std::string Control::Impl::AccessibleImpl::GetDescription() +{ + auto control = Dali::Toolkit::Control::DownCast(self); + + Internal::Control& internalControl = Toolkit::Internal::GetImplementation( control ); + Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( internalControl ); + + if (!controlImpl.mAccessibilityGetDescriptionSignal.Empty()) { + std::string ret; + controlImpl.mAccessibilityGetDescriptionSignal.Emit(ret); + return ret; + } + + if (controlImpl.mAccessibilityDescriptionSet) + return controlImpl.mAccessibilityDescription; + + return GetDescriptionRaw(); +} + +std::string Control::Impl::AccessibleImpl::GetDescriptionRaw() +{ + return ""; +} + +Dali::Accessibility::Accessible* Control::Impl::AccessibleImpl::GetParent() +{ + return Dali::Accessibility::Accessible::Get( self.GetParent() ); +} + +size_t Control::Impl::AccessibleImpl::GetChildCount() +{ + return self.GetChildCount(); +} + +Dali::Accessibility::Accessible* Control::Impl::AccessibleImpl::GetChildAtIndex( size_t index ) +{ + return Dali::Accessibility::Accessible::Get( self.GetChildAt( static_cast< unsigned int >( index ) ) ); +} + +size_t Control::Impl::AccessibleImpl::GetIndexInParent() +{ + auto s = self; + auto parent = s.GetParent(); + DALI_ASSERT_ALWAYS( parent && "can't call GetIndexInParent on object without parent" ); + auto count = parent.GetChildCount(); + for( auto i = 0u; i < count; ++i ) + { + auto c = parent.GetChildAt( i ); + if( c == s ) + return i; + } + DALI_ASSERT_ALWAYS( false && "object isn't child of it's parent" ); + return static_cast(-1); +} + +Dali::Accessibility::Role Control::Impl::AccessibleImpl::GetRole() +{ + return self.GetProperty( Toolkit::DevelControl::Property::ACCESSIBILITY_ROLE ); +} + +Dali::Accessibility::States Control::Impl::AccessibleImpl::CalculateStates() +{ + Dali::Accessibility::States s; + s[Dali::Accessibility::State::FOCUSABLE] = self.IsKeyboardFocusable(); + s[Dali::Accessibility::State::FOCUSED] = Toolkit::KeyboardFocusManager::Get().GetCurrentFocusActor() == self; + if(self.GetProperty( Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE ).GetType() == Property::NONE ) + s[Dali::Accessibility::State::HIGHLIGHTABLE] = true; + else + s[Dali::Accessibility::State::HIGHLIGHTABLE] = self.GetProperty( Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE ).Get< bool >(); + s[Dali::Accessibility::State::HIGHLIGHTED] = GetCurrentlyHighlightedActor() == self; + s[Dali::Accessibility::State::ENABLED] = true; + s[Dali::Accessibility::State::SENSITIVE] = true; + s[Dali::Accessibility::State::ANIMATED] = self.GetProperty( Toolkit::DevelControl::Property::ACCESSIBILITY_ANIMATED ).Get< bool >(); + s[Dali::Accessibility::State::VISIBLE] = self.IsVisible(); + if( modal ) + { + s[Dali::Accessibility::State::MODAL] = true; + } + s[Dali::Accessibility::State::SHOWING] = !self.GetProperty( Dali::DevelActor::Property::CULLED ).Get< bool >(); + return s; +} + +Dali::Accessibility::States Control::Impl::AccessibleImpl::GetStates() +{ + return CalculateStates(); +} + +Dali::Accessibility::Attributes Control::Impl::AccessibleImpl::GetAttributes() +{ + std::unordered_map< std::string, std::string > attribute_map; + auto q = Dali::Toolkit::Control::DownCast( self ); + auto w = + q.GetProperty( Dali::Toolkit::DevelControl::Property::ACCESSIBILITY_ATTRIBUTES ); + auto z = w.GetMap(); + + if( z ) + { + auto map_size = z->Count(); + + for( unsigned int i = 0; i < map_size; i++ ) + { + auto map_key = z->GetKeyAt( i ); + if( map_key.type == Property::Key::STRING ) + { + std::string map_value; + if( z->GetValue( i ).Get( map_value ) ) + { + attribute_map.emplace( std::move( map_key.stringKey ), + std::move( map_value ) ); + } + } + } + } + + return attribute_map; +} + +Dali::Accessibility::ComponentLayer Control::Impl::AccessibleImpl::GetLayer() +{ + return Dali::Accessibility::ComponentLayer::WINDOW; +} + +Dali::Rect<> Control::Impl::AccessibleImpl::GetExtents( Dali::Accessibility::CoordType ctype ) +{ + Vector2 screenPosition = + self.GetProperty( Dali::DevelActor::Property::SCREEN_POSITION ) + .Get< Vector2 >(); + Vector3 size = self.GetCurrentSize() * self.GetCurrentWorldScale(); + bool positionUsesAnchorPoint = + self.GetProperty( Dali::DevelActor::Property::POSITION_USES_ANCHOR_POINT ) + .Get< bool >(); + Vector3 anchorPointOffSet = + size * ( positionUsesAnchorPoint ? self.GetCurrentAnchorPoint() + : AnchorPoint::TOP_LEFT ); + Vector2 position = Vector2( screenPosition.x - anchorPointOffSet.x, + screenPosition.y - anchorPointOffSet.y ); + + return { position.x, position.y, size.x, size.y }; +} + +int16_t Control::Impl::AccessibleImpl::GetMdiZOrder() { return 0; } +double Control::Impl::AccessibleImpl::GetAlpha() { return 0; } + +bool Control::Impl::AccessibleImpl::GrabFocus() +{ + return Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( self ); +} + +const char* const FOCUS_BORDER_IMAGE_PATH = DALI_IMAGE_DIR "keyboard_focus.9.png"; + +static Dali::Actor CreateHighlightIndicatorActor() +{ + // Create the default if it hasn't been set and one that's shared by all the + // keyboard focusable actors const char* const FOCUS_BORDER_IMAGE_PATH = + // DALI_IMAGE_DIR "keyboard_focus.9.png"; + auto actor = Toolkit::ImageView::New( FOCUS_BORDER_IMAGE_PATH ); + actor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + DevelControl::AppendAccessibilityAttribute( actor, "highlight", "" ); + actor.SetProperty( Toolkit::DevelControl::Property::ACCESSIBILITY_ANIMATED, true); + + return actor; +} + +bool Control::Impl::AccessibleImpl::GrabHighlight() +{ + auto old = GetCurrentlyHighlightedActor(); + + if( !Dali::Accessibility::IsUp() ) + return false; + if( self == old ) + return true; + if( old ) + { + auto c = dynamic_cast< Dali::Accessibility::Component* >( GetAccessibilityObject( old ) ); + if( c ) + c->ClearHighlight(); + } + auto highlight = GetHighlightActor(); + if ( !highlight ) + { + highlight = CreateHighlightIndicatorActor(); + SetHighlightActor( highlight ); + } + highlight.SetParentOrigin( ParentOrigin::CENTER ); + highlight.SetAnchorPoint( AnchorPoint::CENTER ); + highlight.SetZ( 1.0f ); + highlight.SetPosition( 0.0f, 0.0f ); + + self.Add( highlight ); + SetCurrentlyHighlightedActor( self ); + EmitHighlighted( true ); + + return true; +} + + + +bool Control::Impl::AccessibleImpl::ClearHighlight() +{ + if( !Dali::Accessibility::IsUp() ) + return false; + if( GetCurrentlyHighlightedActor() == self ) + { + self.Remove( GetHighlightActor() ); + SetCurrentlyHighlightedActor( {} ); + EmitHighlighted( false ); + return true; + } + return false; +} + +int Control::Impl::AccessibleImpl::GetHighlightIndex() +{ + return 0; +} + +std::string Control::Impl::AccessibleImpl::GetActionName( size_t index ) +{ + if ( index >= GetActionCount() ) return ""; + Dali::TypeInfo type; + self.GetTypeInfo( type ); + DALI_ASSERT_ALWAYS( type && "no TypeInfo object" ); + return type.GetActionName( index ); +} +std::string Control::Impl::AccessibleImpl::GetLocalizedActionName( size_t index ) +{ + // TODO: add localization + return GetActionName( index ); +} +std::string Control::Impl::AccessibleImpl::GetActionDescription( size_t index ) +{ + return ""; +} +size_t Control::Impl::AccessibleImpl::GetActionCount() +{ + Dali::TypeInfo type; + self.GetTypeInfo( type ); + DALI_ASSERT_ALWAYS( type && "no TypeInfo object" ); + return type.GetActionCount(); +} +std::string Control::Impl::AccessibleImpl::GetActionKeyBinding( size_t index ) +{ + return ""; +} +bool Control::Impl::AccessibleImpl::DoAction( size_t index ) +{ + std::string actionName = GetActionName( index ); + return self.DoAction( actionName, {} ); +} +bool Control::Impl::AccessibleImpl::DoAction(const std::string& name) +{ + return self.DoAction( name, {} ); +} + +bool Control::Impl::AccessibleImpl::DoGesture(const Dali::Accessibility::GestureInfo &gestureInfo) +{ + auto control = Dali::Toolkit::Control::DownCast(self); + + Internal::Control& internalControl = Toolkit::Internal::GetImplementation( control ); + Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( internalControl ); + + if (!controlImpl.mAccessibilityDoGestureSignal.Empty()) { + auto ret = std::make_pair(gestureInfo, false); + controlImpl.mAccessibilityDoGestureSignal.Emit(ret); + return ret.second; + } + + return false; +} + +std::vector Control::Impl::AccessibleImpl::GetRelationSet() +{ + auto control = Dali::Toolkit::Control::DownCast(self); + + Internal::Control& internalControl = Toolkit::Internal::GetImplementation( control ); + Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( internalControl ); + + std::vector ret; + + auto &v = controlImpl.mAccessibilityRelations; + for (auto i = 0u; i < v.size(); ++i) + { + if ( v[i].empty() ) + continue; + + ret.emplace_back( Accessibility::Relation{ static_cast(i), v[i] } ); + } + + return ret; +} + +void Control::Impl::PositionOrSizeChangedCallback( PropertyNotification &p ) +{ + auto self = Dali::Actor::DownCast(p.GetTarget()); + if (Dali::Accessibility::IsUp() && !self.GetProperty( Toolkit::DevelControl::Property::ACCESSIBILITY_ANIMATED ).Get< bool >()) + { + auto extents = DevelActor::CalculateScreenExtents( self ); + Dali::Accessibility::Accessible::Get( self )->EmitBoundsChanged( extents ); + } +} + +void Control::Impl::CulledChangedCallback( PropertyNotification &p) +{ + if (Dali::Accessibility::IsUp()) + { + auto self = Dali::Actor::DownCast(p.GetTarget()); + Dali::Accessibility::Accessible::Get(self)->EmitShowing( !self.GetProperty( DevelActor::Property::CULLED ).Get() ); + } +} + +void Control::Impl::AccessibilityRegister() +{ + if (!accessibilityNotificationSet) + { + accessibilityNotificationPosition = mControlImpl.Self().AddPropertyNotification( Actor::Property::POSITION, StepCondition( 0.01f ) ); + accessibilityNotificationPosition.SetNotifyMode( PropertyNotification::NotifyOnChanged ); + accessibilityNotificationPosition.NotifySignal().Connect( &Control::Impl::PositionOrSizeChangedCallback ); + + accessibilityNotificationSize = mControlImpl.Self().AddPropertyNotification( Actor::Property::SIZE, StepCondition( 0.01f ) ); + accessibilityNotificationSize.SetNotifyMode( PropertyNotification::NotifyOnChanged ); + accessibilityNotificationSize.NotifySignal().Connect( &Control::Impl::PositionOrSizeChangedCallback ); + + accessibilityNotificationCulled = mControlImpl.Self().AddPropertyNotification( DevelActor::Property::CULLED, LessThanCondition( 0.5f ) ); + accessibilityNotificationCulled.SetNotifyMode( PropertyNotification::NotifyOnChanged ); + accessibilityNotificationCulled.NotifySignal().Connect( &Control::Impl::CulledChangedCallback ); + + accessibilityNotificationSet = true; + } +} + +void Control::Impl::AccessibilityDeregister() +{ + if (accessibilityNotificationSet) + { + accessibilityNotificationPosition = {}; + accessibilityNotificationSize = {}; + accessibilityNotificationCulled = {}; + accessibilityNotificationSet = false; + } +} + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/controls/control/control-data-impl.h b/dali-toolkit/internal/controls/control/control-data-impl.h index 561460f..c2d2711 100755 --- a/dali-toolkit/internal/controls/control/control-data-impl.h +++ b/dali-toolkit/internal/controls/control/control-data-impl.h @@ -20,9 +20,12 @@ // EXTERNAL INCLUDES #include +#include #include #include #include +#include +#include #include // INTERNAL INCLUDES @@ -31,10 +34,14 @@ #include #include #include -#include -#include #include +#include +#include +#include #include +#include +#include +#include namespace Dali { @@ -335,6 +342,44 @@ public: bool FilterKeyEvent( const KeyEvent& event ); /** + * @brief Adds accessibility attribute + * @param[in] key Attribute name to set + * @param[in] value Attribute value to set + * + * Attribute is added if not existed previously or updated + * if existed. + */ + void AppendAccessibilityAttribute( const std::string& key, + const std::string value ); + + /** + * @brief Removes accessibility attribute + * @param[in] key Attribute name to remove + * + * Function does nothing if attribute doesn't exist. + */ + void RemoveAccessibilityAttribute( const std::string& key ); + + /** + * @brief Removes all accessibility attributes + */ + void ClearAccessibilityAttributes(); + + /** + * @brief Sets reading info type attributes + * @param[in] types info type attributes to set + * + * This function sets, which part of object will be read out + * by screen-reader. + */ + void SetAccessibilityReadingInfoType( const Dali::Accessibility::ReadingInfoTypes types ); + + /** + * @brief Gets currently active reading info type attributes + */ + Dali::Accessibility::ReadingInfoTypes GetAccessibilityReadingInfoType() const; + + /** * @copydoc DevelControl::VisualEventSignal() */ DevelControl::VisualEventSignalType& VisualEventSignal(); @@ -419,6 +464,7 @@ public: Control& mControlImpl; DevelControl::State mState; std::string mSubStateName; + Property::Map mAccessibilityAttributes; int mLeftFocusableActorId; ///< Actor ID of Left focusable control. int mRightFocusableActorId; ///< Actor ID of Right focusable control. @@ -436,6 +482,31 @@ public: Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusLostSignal; Toolkit::Control::ResourceReadySignalType mResourceReadySignal; DevelControl::VisualEventSignalType mVisualEventSignal; + Toolkit::Control::AccessibilityActivateSignalType mAccessibilityActivateSignal; + Toolkit::Control::AccessibilityReadingSkippedSignalType mAccessibilityReadingSkippedSignal; + Toolkit::Control::AccessibilityReadingCancelledSignalType mAccessibilityReadingCancelledSignal; + Toolkit::Control::AccessibilityReadingStoppedSignalType mAccessibilityReadingStoppedSignal; + + Toolkit::Control::AccessibilityGetNameSignalType mAccessibilityGetNameSignal; + Toolkit::Control::AccessibilityGetDescriptionSignalType mAccessibilityGetDescriptionSignal; + Toolkit::Control::AccessibilityDoGestureSignalType mAccessibilityDoGestureSignal; + + std::string mAccessibilityName; + bool mAccessibilityNameSet = false; + + std::string mAccessibilityDescription; + bool mAccessibilityDescriptionSet = false; + + std::string mAccessibilityTranslationDomain; + bool mAccessibilityTranslationDomainSet = false; + + bool mAccessibilityHighlightable = false; + bool mAccessibilityHighlightableSet = false; + + Dali::Accessibility::Role mAccessibilityRole = Dali::Accessibility::Role::UNKNOWN; + + std::vector> mAccessibilityRelations; + bool mAccessibilityAnimated = false; // Gesture Detection PinchGestureDetector mPinchGestureDetector; @@ -473,6 +544,74 @@ public: static const PropertyRegistration PROPERTY_12; static const PropertyRegistration PROPERTY_13; static const PropertyRegistration PROPERTY_14; + static const PropertyRegistration PROPERTY_15; + static const PropertyRegistration PROPERTY_16; + static const PropertyRegistration PROPERTY_17; + static const PropertyRegistration PROPERTY_18; + static const PropertyRegistration PROPERTY_19; + static const PropertyRegistration PROPERTY_20; + static const PropertyRegistration PROPERTY_21; + + /** + * The method acquires Accessible handle from Actor object + * @param actor Actor object + * @return handle to Accessible object + */ + static Dali::Accessibility::Accessible *GetAccessibilityObject(Dali::Actor actor); + Dali::Accessibility::Accessible *GetAccessibilityObject(); + + void AccessibilityRegister(); + void AccessibilityDeregister(); + + struct AccessibleImpl : public virtual Dali::Accessibility::Accessible, + public virtual Dali::Accessibility::Component, + public virtual Dali::Accessibility::Collection, + public virtual Dali::Accessibility::Action + { + Dali::Actor self; + bool modal = false, root = false; + + AccessibleImpl(Dali::Actor self, Dali::Accessibility::Role role, bool modal = false); + + std::string GetName() override; + virtual std::string GetNameRaw(); + std::string GetDescription() override; + virtual std::string GetDescriptionRaw(); + Dali::Accessibility::Accessible* GetParent() override; + size_t GetChildCount() override; + Dali::Accessibility::Accessible* GetChildAtIndex( size_t index ) override; + size_t GetIndexInParent() override; + Dali::Accessibility::Role GetRole() override; + Dali::Accessibility::States GetStates() override; + Dali::Accessibility::Attributes GetAttributes() override; + Dali::Rect<> GetExtents( Dali::Accessibility::CoordType ctype ) override; + Dali::Accessibility::ComponentLayer GetLayer() override; + int16_t GetMdiZOrder() override; + bool GrabFocus() override; + double GetAlpha() override; + bool GrabHighlight() override; + bool ClearHighlight() override; + int GetHighlightIndex() override; + + std::string GetActionName( size_t index ) override; + std::string GetLocalizedActionName( size_t index ) override; + std::string GetActionDescription( size_t index ) override; + size_t GetActionCount() override; + std::string GetActionKeyBinding(size_t index) override; + bool DoAction(size_t index) override; + bool DoAction(const std::string& name) override; + bool DoGesture(const Dali::Accessibility::GestureInfo &gestureInfo) override; + std::vector GetRelationSet() override; + + virtual Dali::Accessibility::States CalculateStates(); + }; + + std::function< std::unique_ptr< Dali::Accessibility::Accessible >( Actor ) > accessibilityConstructor; + std::unique_ptr< Dali::Accessibility::Accessible > accessibilityObject; + Dali::PropertyNotification accessibilityNotificationPosition, accessibilityNotificationSize, accessibilityNotificationCulled; + bool accessibilityNotificationSet = false; + static void PositionOrSizeChangedCallback( PropertyNotification& ); + static void CulledChangedCallback( PropertyNotification& ); }; diff --git a/dali-toolkit/internal/controls/effects-view/effects-view-impl.cpp b/dali-toolkit/internal/controls/effects-view/effects-view-impl.cpp index 0c34673..e0e3ad7 100644 --- a/dali-toolkit/internal/controls/effects-view/effects-view-impl.cpp +++ b/dali-toolkit/internal/controls/effects-view/effects-view-impl.cpp @@ -36,6 +36,7 @@ #include #include #include +#include namespace Dali { @@ -147,6 +148,10 @@ EffectsView::EffectsView() mEnabled( false ), mRefreshOnDemand( EFFECTS_VIEW_REFRESH_ON_DEMAND ) { + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::FILLER ) ); + } ); } EffectsView::~EffectsView() diff --git a/dali-toolkit/internal/controls/flex-container/flex-container-impl.cpp b/dali-toolkit/internal/controls/flex-container/flex-container-impl.cpp index 485cd59..901bed8 100755 --- a/dali-toolkit/internal/controls/flex-container/flex-container-impl.cpp +++ b/dali-toolkit/internal/controls/flex-container/flex-container-impl.cpp @@ -28,6 +28,9 @@ #include #include +// INTERNAL INCLUDES +#include + using namespace Dali; namespace @@ -822,6 +825,10 @@ FlexContainer::FlexContainer() mAlignContent( Toolkit::FlexContainer::ALIGN_FLEX_START ) { SetKeyboardNavigationSupport( true ); + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::FILLER ) ); + } ); } void FlexContainer::OnInitialize() diff --git a/dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp b/dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp index d83ed24..6acf066 100644 --- a/dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp +++ b/dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp @@ -36,6 +36,7 @@ // INTERNAL INCLUDES #include #include +#include // TODO: // pixel format / size - set from JSON @@ -142,6 +143,10 @@ GaussianBlurView::GaussianBlurView() mActivated( false ) { SetBlurBellCurveWidth(GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_BELL_CURVE_WIDTH); + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::FILLER ) ); + } ); } GaussianBlurView::GaussianBlurView( const unsigned int numSamples, diff --git a/dali-toolkit/internal/controls/image-view/image-view-impl.cpp b/dali-toolkit/internal/controls/image-view/image-view-impl.cpp old mode 100755 new mode 100644 index 5a0aa91..686def4 --- a/dali-toolkit/internal/controls/image-view/image-view-impl.cpp +++ b/dali-toolkit/internal/controls/image-view/image-view-impl.cpp @@ -32,6 +32,7 @@ #include #include #include +#include namespace Dali { @@ -68,6 +69,10 @@ ImageView::ImageView() mImageSize(), mImageVisualPaddingSetByTransform( false ) { + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::IMAGE ) ); + } ); } ImageView::~ImageView() diff --git a/dali-toolkit/internal/controls/magnifier/magnifier-impl.cpp b/dali-toolkit/internal/controls/magnifier/magnifier-impl.cpp index f4ad54f..b3fc6be 100644 --- a/dali-toolkit/internal/controls/magnifier/magnifier-impl.cpp +++ b/dali-toolkit/internal/controls/magnifier/magnifier-impl.cpp @@ -33,6 +33,7 @@ #include #include #include +#include namespace Dali { @@ -148,6 +149,11 @@ Magnifier::Magnifier() mActorSize(Vector3::ZERO), mMagnificationFactor(1.0f) { + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::FILLER ) ); + } ); + } void Magnifier::SetSourceActor(Actor actor) diff --git a/dali-toolkit/internal/controls/model3d-view/model3d-view-impl.cpp b/dali-toolkit/internal/controls/model3d-view/model3d-view-impl.cpp index 3830f62..0440d0e 100644 --- a/dali-toolkit/internal/controls/model3d-view/model3d-view-impl.cpp +++ b/dali-toolkit/internal/controls/model3d-view/model3d-view-impl.cpp @@ -31,6 +31,7 @@ // INTERNAL INCLUDES #include +#include namespace Dali { @@ -284,6 +285,11 @@ Model3dView::Model3dView() mCameraFOV = Math::PI_OVER_180 * 45.f; mControlSize = Vector2(100.,100.); + + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::IMAGE ) ); + } ); } Model3dView::~Model3dView() diff --git a/dali-toolkit/internal/controls/navigation-view/navigation-view-impl.cpp b/dali-toolkit/internal/controls/navigation-view/navigation-view-impl.cpp index 5ddf48c..34c4b16 100644 --- a/dali-toolkit/internal/controls/navigation-view/navigation-view-impl.cpp +++ b/dali-toolkit/internal/controls/navigation-view/navigation-view-impl.cpp @@ -22,6 +22,7 @@ #include // INTERNAL INCLUDES +#include namespace Dali { @@ -48,6 +49,10 @@ DALI_TYPE_REGISTRATION_END() NavigationView::NavigationView() : Control(ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ) { + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::FILLER ) ); + } ); } NavigationView::~NavigationView() diff --git a/dali-toolkit/internal/controls/page-turn-view/page-turn-view-impl.cpp b/dali-toolkit/internal/controls/page-turn-view/page-turn-view-impl.cpp index 7a00f87..97753f0 100644 --- a/dali-toolkit/internal/controls/page-turn-view/page-turn-view-impl.cpp +++ b/dali-toolkit/internal/controls/page-turn-view/page-turn-view-impl.cpp @@ -32,6 +32,7 @@ #include #include #include +#include using namespace Dali; @@ -362,6 +363,10 @@ PageTurnView::PageTurnView( PageFactory& pageFactory, const Vector2& viewPageSiz mPagePanStartedSignal(), mPagePanFinishedSignal() { + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::PAGE_TAB_LIST ) ); + } ); } PageTurnView::~PageTurnView() diff --git a/dali-toolkit/internal/controls/popup/confirmation-popup-impl.cpp b/dali-toolkit/internal/controls/popup/confirmation-popup-impl.cpp index 43758cb..2e8bfae 100644 --- a/dali-toolkit/internal/controls/popup/confirmation-popup-impl.cpp +++ b/dali-toolkit/internal/controls/popup/confirmation-popup-impl.cpp @@ -1,4 +1,4 @@ -/* +#include /* * Copyright (c) 2015 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,6 +24,9 @@ #include #include +// INTERNAL INCLUDES +#include + namespace Dali { @@ -99,6 +102,10 @@ ConfirmationPopup::ConfirmationPopup() mControlSignals.reserve( MAXIMUM_NUMBER_OF_CONTROLS ); mControlSignalNames[ Toolkit::ConfirmationPopup::CONTROL_OK ] = DEFAULT_CONNECT_SIGNAL_NAME; mControlSignalNames[ Toolkit::ConfirmationPopup::CONTROL_CANCEL ] = DEFAULT_CONNECT_SIGNAL_NAME; + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::DIALOG, true ) ); + } ); } ConfirmationPopup::~ConfirmationPopup() diff --git a/dali-toolkit/internal/controls/popup/popup-impl.cpp b/dali-toolkit/internal/controls/popup/popup-impl.cpp index cde648a..44da4dd 100644 --- a/dali-toolkit/internal/controls/popup/popup-impl.cpp +++ b/dali-toolkit/internal/controls/popup/popup-impl.cpp @@ -37,10 +37,10 @@ #include #include #include -#include #include #include #include +#include using namespace Dali; @@ -263,6 +263,10 @@ Popup::Popup() mTailRightImage( DEFAULT_TAIL_RIGHT_IMAGE_PATH ) { SetKeyboardNavigationSupport( true ); + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::DIALOG, true ) ); + } ); } void Popup::OnInitialize() @@ -333,6 +337,8 @@ void Popup::OnInitialize() Popup::~Popup() { + if( DevelControl::GetBoundAccessibilityObject( Self() ) ) + Accessibility::Bridge::GetCurrentBridge()->RemovePopup( DevelControl::GetBoundAccessibilityObject( Self() ) ); mEntryAnimationData.Clear(); mExitAnimationData.Clear(); } @@ -1573,12 +1579,21 @@ bool Popup::OnDialogTouched( Actor actor, const TouchData& touch ) return true; } +void Popup::OnStageDisconnection() +{ + auto p = Dali::Accessibility::Accessible::Get(Self()); + Accessibility::Bridge::GetCurrentBridge()->RemovePopup( p ); + Control::OnStageDisconnection(); +} + void Popup::OnStageConnection( int depth ) { mLayoutDirty = true; RelayoutRequest(); Control::OnStageConnection( depth ); + auto p = Dali::Accessibility::Accessible::Get(Self()); + Accessibility::Bridge::GetCurrentBridge()->AddPopup( p ); } void Popup::OnChildAdd( Actor& child ) diff --git a/dali-toolkit/internal/controls/popup/popup-impl.h b/dali-toolkit/internal/controls/popup/popup-impl.h index 6b2c19a..67c107f 100755 --- a/dali-toolkit/internal/controls/popup/popup-impl.h +++ b/dali-toolkit/internal/controls/popup/popup-impl.h @@ -438,6 +438,7 @@ private: * Called when the popup is directly or indirectly parented to the stage. */ virtual void OnStageConnection( int depth ); + void OnStageDisconnection() override; /** * From Control; called after a child has been added to the owning actor. diff --git a/dali-toolkit/internal/controls/progress-bar/progress-bar-impl.cpp b/dali-toolkit/internal/controls/progress-bar/progress-bar-impl.cpp old mode 100755 new mode 100644 index 2b89fed..6446bfe --- a/dali-toolkit/internal/controls/progress-bar/progress-bar-impl.cpp +++ b/dali-toolkit/internal/controls/progress-bar/progress-bar-impl.cpp @@ -114,6 +114,10 @@ ProgressBar::ProgressBar() mSecondaryProgressValue( DEFAULT_VALUE ), mIndeterminate( false ) { + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new AccessibleImpl( actor, Dali::Accessibility::Role::PROGRESS_BAR ) ); + } ); } ProgressBar::~ProgressBar() @@ -589,6 +593,29 @@ void ProgressBar::OnStageConnection( int depth ) } } +double ProgressBar::AccessibleImpl::GetMinimum() { return DEFAULT_LOWER_BOUND; } + +double ProgressBar::AccessibleImpl::GetCurrent() +{ + auto p = Toolkit::ProgressBar::DownCast( self ); + return p.GetProperty( Toolkit::ProgressBar::Property::PROGRESS_VALUE ) + .Get< float >(); +} + +double ProgressBar::AccessibleImpl::GetMaximum() { return DEFAULT_UPPER_BOUND; } + +bool ProgressBar::AccessibleImpl::SetCurrent( double current ) +{ + if( current < GetMinimum() || current > GetMaximum() ) + return false; + auto p = Toolkit::ProgressBar::DownCast( self ); + p.SetProperty( Toolkit::ProgressBar::Property::PROGRESS_VALUE, + static_cast< float >( current ) ); + return true; +} + +double ProgressBar::AccessibleImpl::GetMinimumIncrement() { return 0.001; } + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/controls/progress-bar/progress-bar-impl.h b/dali-toolkit/internal/controls/progress-bar/progress-bar-impl.h old mode 100755 new mode 100644 index 5b0ffd2..c2c2f22 --- a/dali-toolkit/internal/controls/progress-bar/progress-bar-impl.h +++ b/dali-toolkit/internal/controls/progress-bar/progress-bar-impl.h @@ -24,6 +24,7 @@ #include #include #include +#include namespace Dali { @@ -256,6 +257,18 @@ private: float mProgressValue; ///< Current value of ProgressBar float mSecondaryProgressValue; ///< Current loading value of ProgressBar bool mIndeterminate; ///< Whether the progress state is determined or not + +protected: + struct AccessibleImpl : public Control::Impl::AccessibleImpl, + public virtual Dali::Accessibility::Value + { + using Control::Impl::AccessibleImpl::AccessibleImpl; + double GetMinimum() override; + double GetCurrent() override; + double GetMaximum() override; + bool SetCurrent( double ) override; + double GetMinimumIncrement() override; + }; }; } // namespace Internal diff --git a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp old mode 100755 new mode 100644 index cd8438e..befb423 --- a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp +++ b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp @@ -204,6 +204,10 @@ ScrollBar::ScrollBar(Toolkit::ScrollBar::Direction direction) mIsPanning(false), mIndicatorFirstShow(true) { + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new AccessibleImpl( actor, Dali::Accessibility::Role::SCROLL_BAR ) ); + } ); } ScrollBar::~ScrollBar() @@ -857,6 +861,50 @@ Toolkit::ScrollBar ScrollBar::New(Toolkit::ScrollBar::Direction direction) return handle; } +double ScrollBar::AccessibleImpl::GetMinimum() +{ + auto p = Toolkit::ScrollBar::DownCast( self ); + Handle scrollableHandle = GetImpl( p ).mScrollableObject.GetBaseHandle(); + return scrollableHandle ? scrollableHandle.GetCurrentProperty< float >( GetImpl( p ).mPropertyMinScrollPosition ) : 0.0f; +} + +double ScrollBar::AccessibleImpl::GetCurrent() +{ + auto p = Toolkit::ScrollBar::DownCast( self ); + Handle scrollableHandle = GetImpl( p ).mScrollableObject.GetBaseHandle(); + return scrollableHandle ? scrollableHandle.GetCurrentProperty< float >( GetImpl( p ).mPropertyScrollPosition ) : 0.0f; +} + +double ScrollBar::AccessibleImpl::GetMaximum() +{ + auto p = Toolkit::ScrollBar::DownCast( self ); + Handle scrollableHandle = GetImpl( p ).mScrollableObject.GetBaseHandle(); + return scrollableHandle ? scrollableHandle.GetCurrentProperty< float >( GetImpl( p ).mPropertyMaxScrollPosition ) : 1.0f; +} + +bool ScrollBar::AccessibleImpl::SetCurrent( double current ) +{ + if( current < GetMinimum() || current > GetMaximum() ) + return false; + + auto value_before = GetCurrent(); + + auto p = Toolkit::ScrollBar::DownCast( self ); + Handle scrollableHandle = GetImpl( p ).mScrollableObject.GetBaseHandle(); + if( !scrollableHandle ) + return false; + scrollableHandle.SetProperty( GetImpl( p ).mPropertyScrollPosition, static_cast< float >( current ) ); + + auto value_after = GetCurrent(); + + if( ( current != value_before ) && ( value_before == value_after ) ) + return false; + + return true; +} + +double ScrollBar::AccessibleImpl::GetMinimumIncrement() { return 1.0; } + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h old mode 100755 new mode 100644 index a46808cd..c28e3f1 --- a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h +++ b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h @@ -29,6 +29,7 @@ // INTERNAL INCLUDES #include #include +#include namespace Dali { @@ -285,9 +286,9 @@ private: WeakHandleBase mScrollableObject; ///< Object to be scrolled - Property::Index mPropertyScrollPosition; ///< Index of scroll position property owned by the object to be scrolled - Property::Index mPropertyMinScrollPosition; ///< Index of minimum scroll position property owned by the object to be scrolled - Property::Index mPropertyMaxScrollPosition; ///< Index of maximum scroll position property owned by the object to be scrolled + Property::Index mPropertyScrollPosition = 0; ///< Index of scroll position property owned by the object to be scrolled + Property::Index mPropertyMinScrollPosition = 0; ///< Index of minimum scroll position property owned by the object to be scrolled + Property::Index mPropertyMaxScrollPosition = 1; ///< Index of maximum scroll position property owned by the object to be scrolled Property::Index mPropertyScrollContentSize; ///< Index of scroll content size property owned by the object to be scrolled float mIndicatorShowDuration; ///< The duration of scroll indicator show animation @@ -319,6 +320,18 @@ private: bool mIsPanning : 1; ///< Whether the scroll bar is being panned. bool mIndicatorFirstShow : 1; ///< True if the indicator has never been shown + +protected: + struct AccessibleImpl : public Control::Impl::AccessibleImpl, + public virtual Dali::Accessibility::Value + { + using Control::Impl::AccessibleImpl::AccessibleImpl; + double GetMinimum() override; + double GetCurrent() override; + double GetMaximum() override; + bool SetCurrent( double ) override; + double GetMinimumIncrement() override; + }; }; } // namespace Internal diff --git a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-base-impl.cpp b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-base-impl.cpp index ffc7570..1a5c766 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-base-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-base-impl.cpp @@ -33,13 +33,6 @@ namespace Internal // ScrollBase /////////////////////////////////////////////////////////////////////////////////////////////////// -ScrollBase::ScrollBase() -: Scrollable(), - mParent(NULL), - mDelay(0.0f) -{ -} - ScrollBase::ScrollBase( ControlBehaviour behaviourFlags ) : Scrollable( behaviourFlags ), mParent(NULL), diff --git a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-base-impl.h b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-base-impl.h index aa34f20..9780e78 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-base-impl.h +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-base-impl.h @@ -187,9 +187,9 @@ protected: protected: /** - * Construct a new ScrollBase. + * Removed default costructor. */ - ScrollBase(); + ScrollBase() = delete; /** * @brief Construct a new ScrollBase. diff --git a/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp b/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp index 6cd2e67..e3b381c 100644 --- a/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp @@ -22,6 +22,7 @@ // INTERNAL INCLUDES #include +#include using namespace Dali; @@ -78,21 +79,6 @@ const Vector2 OVERSHOOT_DEFAULT_SIZE( 720.0f, 42.0f ); // Scrollable /////////////////////////////////////////////////////////////////////////////////////////////////// -// Scrollable controls are not layout containers so they dont need size negotiation.. -// we dont want size negotiation while scrolling if we can avoid it -Scrollable::Scrollable() -: Control( ControlBehaviour( DISABLE_SIZE_NEGOTIATION ) ), - mOvershootEffectColor( DEFAULT_OVERSHOOT_COLOUR ), - mOvershootAnimationSpeed ( DEFAULT_OVERSHOOT_ANIMATION_SPEED ), - mOvershootSize( OVERSHOOT_DEFAULT_SIZE ), - mScrollToAlphaFunction( AlphaFunction::EASE_OUT ), - mScrollStartedSignal(), - mScrollUpdatedSignal(), - mScrollCompletedSignal(), - mOvershootEnabled(true) -{ -} - Scrollable::Scrollable( ControlBehaviour behaviourFlags ) : Control( ControlBehaviour( behaviourFlags ) ), mOvershootEffectColor( DEFAULT_OVERSHOOT_COLOUR ), @@ -104,6 +90,10 @@ Scrollable::Scrollable( ControlBehaviour behaviourFlags ) mScrollCompletedSignal(), mOvershootEnabled(true) { + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::SCROLL_PANE ) ); + } ); } Scrollable::~Scrollable() diff --git a/dali-toolkit/internal/controls/scrollable/scrollable-impl.h b/dali-toolkit/internal/controls/scrollable/scrollable-impl.h index 9ffdc8e..72f710a 100644 --- a/dali-toolkit/internal/controls/scrollable/scrollable-impl.h +++ b/dali-toolkit/internal/controls/scrollable/scrollable-impl.h @@ -176,9 +176,9 @@ public: //Signals protected: /** - * Construct a new Scrollable. + * Removed default constructor. */ - Scrollable(); + Scrollable() = delete; /** * @brief Construct a new Scrollable. diff --git a/dali-toolkit/internal/controls/shadow-view/shadow-view-impl.cpp b/dali-toolkit/internal/controls/shadow-view/shadow-view-impl.cpp index 0233991..8ac3376 100644 --- a/dali-toolkit/internal/controls/shadow-view/shadow-view-impl.cpp +++ b/dali-toolkit/internal/controls/shadow-view/shadow-view-impl.cpp @@ -34,6 +34,7 @@ #include #include #include +#include // TODO: // pixel format / size - set from JSON @@ -131,6 +132,10 @@ ShadowView::ShadowView( float downsampleWidthScale, float downsampleHeightScale mDownsampleWidthScale(downsampleWidthScale), mDownsampleHeightScale(downsampleHeightScale) { + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::FILLER ) ); + } ); } ShadowView::~ShadowView() diff --git a/dali-toolkit/internal/controls/slider/slider-impl.cpp b/dali-toolkit/internal/controls/slider/slider-impl.cpp old mode 100755 new mode 100644 index 275995d..b4ed78d --- a/dali-toolkit/internal/controls/slider/slider-impl.cpp +++ b/dali-toolkit/internal/controls/slider/slider-impl.cpp @@ -158,6 +158,10 @@ Slider::Slider() mShowValue( false ), mSnapToMarks( false ) { + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new AccessibleImpl( actor, Dali::Accessibility::Role::SLIDER ) ); + } ); } Slider::~Slider() @@ -1407,6 +1411,39 @@ Property::Value Slider::GetProperty( BaseObject* object, Property::Index propert return value; } +double Slider::AccessibleImpl::GetMinimum() +{ + auto p = Toolkit::Slider::DownCast( self ); + return p.GetProperty( Toolkit::Slider::Property::LOWER_BOUND ).Get< float >(); +} + +double Slider::AccessibleImpl::GetCurrent() +{ + auto p = Toolkit::Slider::DownCast( self ); + return p.GetProperty( Toolkit::Slider::Property::VALUE ).Get< float >(); +} + +double Slider::AccessibleImpl::GetMaximum() +{ + auto p = Toolkit::Slider::DownCast( self ); + return p.GetProperty( Toolkit::Slider::Property::UPPER_BOUND ).Get< float >(); +} + +bool Slider::AccessibleImpl::SetCurrent( double current ) +{ + if( current < GetMinimum() || current > GetMaximum() ) + return false; + auto p = Toolkit::Slider::DownCast( self ); + p.SetProperty( Toolkit::Slider::Property::VALUE, static_cast< float >( current ) ); + return true; +} + +double Slider::AccessibleImpl::GetMinimumIncrement() +{ + auto p = Toolkit::Slider::DownCast( self ); + return p.GetProperty( Toolkit::Slider::Property::MARK_TOLERANCE ).Get< float >(); +} + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/controls/slider/slider-impl.h b/dali-toolkit/internal/controls/slider/slider-impl.h old mode 100755 new mode 100644 index bbae4d5..5a97dfc --- a/dali-toolkit/internal/controls/slider/slider-impl.h +++ b/dali-toolkit/internal/controls/slider/slider-impl.h @@ -28,6 +28,7 @@ #include #include #include +#include namespace Dali { @@ -744,17 +745,29 @@ private: Vector2 mTrackRegion; ///< Size of track region Vector2 mHandleSize; ///< Size of the handle - float mLowerBound; ///< Lower bound on value - float mUpperBound; ///< Upper bound on value - float mValue; ///< Current value of slider + float mLowerBound = 0.0f; ///< Lower bound on value + float mUpperBound = 1.0f; ///< Upper bound on value + float mValue = 0.0f; ///< Current value of slider - float mMarkTolerance; ///< Tolerance in percentage of slider width for which to snap to marks + float mMarkTolerance = 0.05f; ///< Tolerance in percentage of slider width for which to snap to marks int mValuePrecision; ///< The precision to use for outputting the value bool mShowPopup : 1, ///< Show the popup or not mShowValue : 1, ///< Whether to display the value number or not on the handle mSnapToMarks : 1; ///< Turn on or off snapping to marks + +protected: + struct AccessibleImpl : public Control::Impl::AccessibleImpl, + public virtual Dali::Accessibility::Value + { + using Control::Impl::AccessibleImpl::AccessibleImpl; + double GetMinimum() override; + double GetCurrent() override; + double GetMaximum() override; + bool SetCurrent( double ) override; + double GetMinimumIncrement() override; + }; }; } // namespace Internal diff --git a/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp b/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp index 70bd49d..2be8d4c 100644 --- a/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp +++ b/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp @@ -35,6 +35,7 @@ #include #include #include +#include namespace //Unnamed namespace { @@ -137,6 +138,11 @@ SuperBlurView::SuperBlurView( unsigned int blurLevels ) mGaussianBlurView.assign( blurLevels, Toolkit::GaussianBlurView() ); mBlurredImage.assign( blurLevels, FrameBuffer() ); mRenderers.assign( blurLevels+1, Dali::Renderer() ); + + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::FILLER ) ); + } ); } SuperBlurView::~SuperBlurView() diff --git a/dali-toolkit/internal/controls/table-view/table-view-impl.cpp b/dali-toolkit/internal/controls/table-view/table-view-impl.cpp index abb9eea..8878dc6 100755 --- a/dali-toolkit/internal/controls/table-view/table-view-impl.cpp +++ b/dali-toolkit/internal/controls/table-view/table-view-impl.cpp @@ -28,6 +28,9 @@ #include #include +// INTERNAL INCLUDES +#include + using namespace Dali; namespace @@ -1112,6 +1115,10 @@ TableView::TableView( unsigned int initialRows, unsigned int initialColumns ) { SetKeyboardNavigationSupport( true ); ResizeContainers( initialRows, initialColumns ); + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::TABLE ) ); + } ); } void TableView::OnInitialize() diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp index e4f245d..436c9ff 100755 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -515,9 +515,9 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P if( impl.mController ) { - // The line spacing isn't supported by the TextEditor. Since it's supported - // by the TextLabel for now it must be ignored. The property is being shadowed - // locally so its value isn't affected. + // The line spacing isn't supported by the TextEditor. Since it's + // supported by the TextEditor for now it must be ignored. The + // property is being shadowed locally so its value isn't affected. const float lineSpacing = value.Get(); impl.mLineSpacing = lineSpacing; // set it to 0.0 due to missing implementation @@ -1173,6 +1173,11 @@ InputMethodContext TextEditor::GetInputMethodContext() return mInputMethodContext; } +Text::ControllerPtr TextEditor::getController() +{ + return mController; +} + bool TextEditor::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ) { Dali::BaseHandle handle( object ); @@ -1571,6 +1576,30 @@ void TextEditor::RequestTextRelayout() RelayoutRequest(); } +void TextEditor::TextInserted( unsigned int position, unsigned int length, const std::string &content ) +{ + if( Accessibility::IsUp() ) + { + Control::Impl::GetAccessibilityObject( Self() )->EmitTextInserted( position, length, content ); + } +} + +void TextEditor::TextDeleted( unsigned int position, unsigned int length, const std::string &content ) +{ + if( Accessibility::IsUp() ) + { + Control::Impl::GetAccessibilityObject( Self() )->EmitTextDeleted( position, length, content ); + } +} + +void TextEditor::CaretMoved( unsigned int position ) +{ + if( Accessibility::IsUp() ) + { + Control::Impl::GetAccessibilityObject( Self() )->EmitTextCaretMoved( position ); + } +} + void TextEditor::TextChanged() { Dali::Toolkit::TextEditor handle( GetOwner() ); @@ -1869,6 +1898,10 @@ TextEditor::TextEditor() mScrollBarEnabled( false ), mScrollStarted( false ) { + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new AccessibleImpl( actor, Dali::Accessibility::Role::ENTRY ) ); + } ); } TextEditor::~TextEditor() @@ -1882,6 +1915,212 @@ TextEditor::~TextEditor() } } +std::string TextEditor::AccessibleImpl::GetName() +{ + auto slf = Toolkit::TextEditor::DownCast( self ); + return slf.GetProperty( Toolkit::TextEditor::Property::TEXT ) + .Get< std::string >(); +} + +std::string TextEditor::AccessibleImpl::GetText( size_t startOffset, + size_t endOffset ) +{ + if( endOffset <= startOffset ) + return {}; + + auto slf = Toolkit::TextEditor::DownCast( self ); + auto txt = + slf.GetProperty( Toolkit::TextEditor::Property::TEXT ).Get< std::string >(); + + if( startOffset > txt.size() || endOffset > txt.size() ) + return {}; + + return txt.substr( startOffset, endOffset - startOffset ); +} + +size_t TextEditor::AccessibleImpl::GetCharacterCount() +{ + auto slf = Toolkit::TextEditor::DownCast( self ); + auto txt = + slf.GetProperty( Toolkit::TextEditor::Property::TEXT ).Get< std::string >(); + + return txt.size(); +} + +size_t TextEditor::AccessibleImpl::GetCaretOffset() +{ + auto slf = Toolkit::TextEditor::DownCast( self ); + return Dali::Toolkit::GetImpl( slf ).getController()->GetCursorPosition(); +} + +bool TextEditor::AccessibleImpl::SetCaretOffset(size_t offset) +{ + auto slf = Toolkit::TextEditor::DownCast( self ); + auto txt = slf.GetProperty( Toolkit::TextEditor::Property::TEXT ).Get< std::string >(); + if (offset > txt.size()) + return false; + + auto& slfImpl = Dali::Toolkit::GetImpl( slf ); + slfImpl.getController()->ResetCursorPosition( offset ); + slfImpl.RequestTextRelayout(); + return true; +} + +Dali::Accessibility::Range TextEditor::AccessibleImpl::GetTextAtOffset( + size_t offset, Dali::Accessibility::TextBoundary boundary ) +{ + auto slf = Toolkit::TextEditor::DownCast( self ); + auto txt = slf.GetProperty( Toolkit::TextEditor::Property::TEXT ).Get< std::string >(); + auto txt_size = txt.size(); + + auto range = Dali::Accessibility::Range{}; + + switch(boundary) + { + case Dali::Accessibility::TextBoundary::CHARACTER: + { + if (offset < txt_size) + { + range.content = txt[offset]; + range.startOffset = offset; + range.endOffset = offset + 1; + } + } + break; + case Dali::Accessibility::TextBoundary::WORD: + case Dali::Accessibility::TextBoundary::LINE: + { + auto txt_c_string = txt.c_str(); + auto breaks = std::vector< char >( txt_size, 0 ); + if(boundary == Dali::Accessibility::TextBoundary::WORD) + Accessibility::Accessible::FindWordSeparationsUtf8((const utf8_t *) txt_c_string, txt_size, "", breaks.data()); + else + Accessibility::Accessible::FindLineSeparationsUtf8((const utf8_t *) txt_c_string, txt_size, "", breaks.data()); + auto index = 0u; + auto counter = 0u; + while( index < txt_size && counter <= offset ) + { + auto start = index; + if(breaks[index]) + { + while(breaks[index]) + index++; + counter++; + } + else + { + if (boundary == Dali::Accessibility::TextBoundary::WORD) + index++; + if (boundary == Dali::Accessibility::TextBoundary::LINE) + counter++; + } + if ((counter - 1) == offset) + { + range.content = txt.substr(start, index - start + 1); + range.startOffset = start; + range.endOffset = index + 1; + } + if (boundary == Dali::Accessibility::TextBoundary::LINE) + index++; + } + } + break; + case Dali::Accessibility::TextBoundary::SENTENCE: + { + /* not supported by efl */ + } + break; + case Dali::Accessibility::TextBoundary::PARAGRAPH: + { + /* Paragraph is not supported by libunibreak library */ + } + break; + default: + break; + } + + return range; +} + +Dali::Accessibility::Range +TextEditor::AccessibleImpl::GetSelection( size_t selectionNum ) +{ + // Since DALi supports only one selection indexes higher than 0 are ignored + if( selectionNum > 0 ) + return {}; + + auto slf = Toolkit::TextEditor::DownCast( self ); + auto ctrl = Dali::Toolkit::GetImpl( slf ).getController(); + std::string ret; + ctrl->RetrieveSelection( ret ); + auto r = ctrl->GetSelectionIndexes(); + + return { static_cast(r.first), static_cast(r.second), ret }; +} + +bool TextEditor::AccessibleImpl::RemoveSelection( size_t selectionNum ) +{ + // Since DALi supports only one selection indexes higher than 0 are ignored + if( selectionNum > 0 ) + return false; + + auto slf = Toolkit::TextEditor::DownCast( self ); + Dali::Toolkit::GetImpl( slf ).getController()->SetSelection( 0, 0 ); + return true; +} + +bool TextEditor::AccessibleImpl::SetSelection( size_t selectionNum, + size_t startOffset, + size_t endOffset ) +{ + // Since DALi supports only one selection indexes higher than 0 are ignored + if( selectionNum > 0 ) + return false; + + auto slf = Toolkit::TextEditor::DownCast( self ); + Dali::Toolkit::GetImpl( slf ).getController()->SetSelection( startOffset, + endOffset ); + return true; +} + +bool TextEditor::AccessibleImpl::CopyText( size_t startPosition, + size_t endPosition ) +{ + if( endPosition <= startPosition ) + return false; + + auto slf = Toolkit::TextEditor::DownCast( self ); + auto txt = slf.GetProperty( Toolkit::TextEditor::Property::TEXT ).Get(); + Dali::Toolkit::GetImpl( slf ).getController()->CopyStringToClipboard( txt.substr(startPosition, endPosition - startPosition) ); + + return true; +} + +bool TextEditor::AccessibleImpl::CutText( size_t startPosition, + size_t endPosition ) +{ + if( endPosition <= startPosition ) + return false; + + auto slf = Toolkit::TextEditor::DownCast( self ); + auto txt = slf.GetProperty( Toolkit::TextEditor::Property::TEXT ).Get(); + Dali::Toolkit::GetImpl( slf ).getController()->CopyStringToClipboard( txt.substr(startPosition, endPosition - startPosition) ); + + slf.SetProperty( Toolkit::TextEditor::Property::TEXT, + txt.substr( 0, startPosition ) + txt.substr( endPosition - startPosition, txt.size())); + + return true; +} + +Dali::Accessibility::States TextEditor::AccessibleImpl::CalculateStates() +{ + auto states = Control::Impl::AccessibleImpl::CalculateStates(); + using namespace Dali::Accessibility; + states[State::EDITABLE] = true; + + return states; +} + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.h b/dali-toolkit/internal/controls/text-controls/text-editor-impl.h index 5595e18..d4a38be 100755 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.h @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #include #include +#include #include // INTERNAL INCLUDES @@ -33,6 +34,7 @@ #include #include #include +#include namespace Dali { @@ -177,6 +179,21 @@ private: // From Control // From EditableControlInterface /** + * @copydoc Text::ControlInterface::TextInserted() + */ + virtual void TextInserted( unsigned int position, unsigned int length, const std::string &content ); + + /** + * @copydoc Text::ControlInterface::TextDeleted() + */ + virtual void TextDeleted( unsigned int position, unsigned int length, const std::string &content ); + + /** + * @copydoc Text::ControlInterface::CaretMoved() + */ + virtual void CaretMoved( unsigned int position ); + + /** * @copydoc Text::ControlInterface::TextChanged() */ virtual void TextChanged(); @@ -196,6 +213,8 @@ private: // From Control */ virtual void AddDecoration( Actor& actor, bool needsClipping ); + Text::ControllerPtr getController(); + private: // Implementation /** @@ -311,6 +330,29 @@ private: // Data bool mScrollAnimationEnabled:1; bool mScrollBarEnabled:1; bool mScrollStarted:1; + + struct AccessibleImpl : public Control::Impl::AccessibleImpl, + public virtual Dali::Accessibility::Text, + public virtual Dali::Accessibility::EditableText + { + using Control::Impl::AccessibleImpl::AccessibleImpl; + + std::string GetName() override; + std::string GetText( size_t startOffset, size_t endOffset ) override; + size_t GetCharacterCount() override; + size_t GetCaretOffset() override; + bool SetCaretOffset(size_t offset) override; + Dali::Accessibility::Range + GetTextAtOffset( size_t offset, + Dali::Accessibility::TextBoundary boundary ) override; + Dali::Accessibility::Range GetSelection( size_t selectionNum ) override; + bool RemoveSelection( size_t selectionNum ) override; + bool SetSelection( size_t selectionNum, size_t startOffset, + size_t endOffset ) override; + bool CopyText( size_t startPosition, size_t endPosition ) override; + bool CutText( size_t startPosition, size_t endPosition ) override; + Dali::Accessibility::States CalculateStates() override; + }; }; } // namespace Internal diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index c40f71e..af1633f 100755 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -1446,6 +1446,8 @@ void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container ) } } +Text::ControllerPtr TextField::getController() { return mController; } + void TextField::RenderText( Text::Controller::UpdateTextType updateTextType ) { Actor renderableActor; @@ -1644,6 +1646,30 @@ void TextField::RequestTextRelayout() RelayoutRequest(); } +void TextField::TextInserted( unsigned int position, unsigned int length, const std::string &content ) +{ + if( Accessibility::IsUp() ) + { + Control::Impl::GetAccessibilityObject( Self() )->EmitTextInserted( position, length, content ); + } +} + +void TextField::TextDeleted( unsigned int position, unsigned int length, const std::string &content ) +{ + if( Accessibility::IsUp() ) + { + Control::Impl::GetAccessibilityObject( Self() )->EmitTextDeleted( position, length, content ); + } +} + +void TextField::CaretMoved( unsigned int position ) +{ + if( Accessibility::IsUp() ) + { + Control::Impl::GetAccessibilityObject( Self() )->EmitTextCaretMoved( position ); + } +} + void TextField::TextChanged() { Dali::Toolkit::TextField handle( GetOwner() ); @@ -1832,6 +1858,10 @@ TextField::TextField() mExceedPolicy( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), mHasBeenStaged( false ) { + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new AccessibleImpl( actor, Dali::Accessibility::Role::ENTRY ) ); + } ); } TextField::~TextField() @@ -1844,6 +1874,210 @@ TextField::~TextField() } } +std::string TextField::AccessibleImpl::GetName() +{ + auto slf = Toolkit::TextField::DownCast( self ); + return slf.GetProperty( Toolkit::TextField::Property::TEXT ).Get< std::string >(); +} + +std::string TextField::AccessibleImpl::GetText( size_t startOffset, + size_t endOffset ) +{ + if( endOffset <= startOffset ) + return {}; + + auto slf = Toolkit::TextField::DownCast( self ); + auto txt = + slf.GetProperty( Toolkit::TextField::Property::TEXT ).Get< std::string >(); + + if( startOffset > txt.size() || endOffset > txt.size() ) + return {}; + + return txt.substr( startOffset, endOffset - startOffset ); +} + +size_t TextField::AccessibleImpl::GetCharacterCount() +{ + auto slf = Toolkit::TextField::DownCast( self ); + auto txt = + slf.GetProperty( Toolkit::TextField::Property::TEXT ).Get< std::string >(); + + return txt.size(); +} + +size_t TextField::AccessibleImpl::GetCaretOffset() +{ + auto slf = Toolkit::TextField::DownCast( self ); + return Dali::Toolkit::GetImpl( slf ).getController()->GetCursorPosition(); +} + +bool TextField::AccessibleImpl::SetCaretOffset(size_t offset) +{ + auto slf = Toolkit::TextField::DownCast( self ); + auto txt = slf.GetProperty( Toolkit::TextField::Property::TEXT ).Get< std::string >(); + if (offset > txt.size()) + return false; + + auto& slfImpl = Dali::Toolkit::GetImpl( slf ); + slfImpl.getController()->ResetCursorPosition( offset ); + slfImpl.RequestTextRelayout(); + return true; +} + +Dali::Accessibility::Range TextField::AccessibleImpl::GetTextAtOffset( + size_t offset, Dali::Accessibility::TextBoundary boundary ) +{ + auto slf = Toolkit::TextField::DownCast( self ); + auto txt = slf.GetProperty( Toolkit::TextField::Property::TEXT ).Get< std::string >(); + auto txt_size = txt.size(); + + auto range = Dali::Accessibility::Range{}; + + switch(boundary) + { + case Dali::Accessibility::TextBoundary::CHARACTER: + { + if (offset < txt_size) + { + range.content = txt[offset]; + range.startOffset = offset; + range.endOffset = offset + 1; + } + } + break; + case Dali::Accessibility::TextBoundary::WORD: + case Dali::Accessibility::TextBoundary::LINE: + { + auto txt_c_string = txt.c_str(); + auto breaks = std::vector< char >( txt_size, 0 ); + if(boundary == Dali::Accessibility::TextBoundary::WORD) + Accessibility::Accessible::FindWordSeparationsUtf8((const utf8_t *) txt_c_string, txt_size, "", breaks.data()); + else + Accessibility::Accessible::FindLineSeparationsUtf8((const utf8_t *) txt_c_string, txt_size, "", breaks.data()); + auto index = 0u; + auto counter = 0u; + while( index < txt_size && counter <= offset ) + { + auto start = index; + if(breaks[index]) + { + while(breaks[index]) + index++; + counter++; + } + else + { + if (boundary == Dali::Accessibility::TextBoundary::WORD) + index++; + if (boundary == Dali::Accessibility::TextBoundary::LINE) + counter++; + } + if ((counter - 1) == offset) + { + range.content = txt.substr(start, index - start + 1); + range.startOffset = start; + range.endOffset = index + 1; + } + if (boundary == Dali::Accessibility::TextBoundary::LINE) + index++; + } + } + break; + case Dali::Accessibility::TextBoundary::SENTENCE: + { + /* not supported by efl */ + } + break; + case Dali::Accessibility::TextBoundary::PARAGRAPH: + { + /* Paragraph is not supported by libunibreak library */ + } + break; + default: + break; + } + + return range; +} + +Dali::Accessibility::Range +TextField::AccessibleImpl::GetSelection( size_t selectionNum ) +{ + // Since DALi supports only one selection indexes higher than 0 are ignored + if( selectionNum > 0 ) + return {}; + + auto slf = Toolkit::TextField::DownCast( self ); + auto ctrl = Dali::Toolkit::GetImpl( slf ).getController(); + std::string ret; + ctrl->RetrieveSelection( ret ); + auto r = ctrl->GetSelectionIndexes(); + + return { static_cast(r.first), static_cast(r.second), ret }; +} + +bool TextField::AccessibleImpl::RemoveSelection( size_t selectionNum ) +{ + // Since DALi supports only one selection indexes higher than 0 are ignored + if( selectionNum > 0 ) + return false; + + auto slf = Toolkit::TextField::DownCast( self ); + Dali::Toolkit::GetImpl( slf ).getController()->SetSelection( 0, 0 ); + return true; +} + +bool TextField::AccessibleImpl::SetSelection( size_t selectionNum, + size_t startOffset, + size_t endOffset ) +{ + // Since DALi supports only one selection indexes higher than 0 are ignored + if( selectionNum > 0 ) + return false; + + auto slf = Toolkit::TextField::DownCast( self ); + Dali::Toolkit::GetImpl( slf ).getController()->SetSelection( startOffset, + endOffset ); + return true; +} + +bool TextField::AccessibleImpl::CopyText( size_t startPosition, + size_t endPosition ) +{ + if( endPosition <= startPosition ) + return false; + + auto slf = Toolkit::TextField::DownCast( self ); + auto txt = slf.GetProperty( Toolkit::TextField::Property::TEXT ).Get(); + Dali::Toolkit::GetImpl( slf ).getController()->CopyStringToClipboard( txt.substr(startPosition, endPosition - startPosition) ); + + return true; +} + +bool TextField::AccessibleImpl::CutText( size_t startPosition, + size_t endPosition ) +{ + if( endPosition <= startPosition ) + return false; + + auto slf = Toolkit::TextField::DownCast( self ); + auto txt = slf.GetProperty( Toolkit::TextField::Property::TEXT ).Get(); + Dali::Toolkit::GetImpl( slf ).getController()->CopyStringToClipboard( txt.substr(startPosition, endPosition - startPosition) ); + + slf.SetProperty( Toolkit::TextField::Property::TEXT, + txt.substr( 0, startPosition ) + txt.substr( endPosition - startPosition, txt.size())); + + return true; +} + +Dali::Accessibility::States TextField::AccessibleImpl::CalculateStates() +{ + auto states = Control::Impl::AccessibleImpl::CalculateStates(); + using namespace Dali::Accessibility; + states[State::EDITABLE] = true; + return states; +} + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.h b/dali-toolkit/internal/controls/text-controls/text-field-impl.h index 7f0a5d9..0cae2a3 100755 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.h @@ -31,6 +31,7 @@ #include #include #include +#include namespace Dali { @@ -108,6 +109,8 @@ public: */ void SelectWholeText(); + Text::ControllerPtr getController(); + private: // From Control /** @@ -180,6 +183,21 @@ private: // From Control // From EditableControlInterface /** + * @copydoc Text::ControlInterface::TextInserted() + */ + virtual void TextInserted( unsigned int position, unsigned int length, const std::string &content ); + + /** + * @copydoc Text::ControlInterface::TextDeleted() + */ + virtual void TextDeleted( unsigned int position, unsigned int length, const std::string &content ); + + /** + * @copydoc Text::ControlInterface::CaretMoved() + */ + virtual void CaretMoved( unsigned int position ); + + /** * @copydoc Text::ControlInterface::TextChanged() */ virtual void TextChanged(); @@ -293,6 +311,30 @@ private: // Data int mRenderingBackend; int mExceedPolicy; bool mHasBeenStaged:1; + +protected: + struct AccessibleImpl : public Control::Impl::AccessibleImpl, + public virtual Dali::Accessibility::Text, + public virtual Dali::Accessibility::EditableText + { + using Control::Impl::AccessibleImpl::AccessibleImpl; + + std::string GetName() override; + std::string GetText( size_t startOffset, size_t endOffset ) override; + size_t GetCharacterCount() override; + size_t GetCaretOffset() override; + bool SetCaretOffset(size_t offset) override; + Dali::Accessibility::Range + GetTextAtOffset( size_t offset, + Dali::Accessibility::TextBoundary boundary ) override; + Dali::Accessibility::Range GetSelection( size_t selectionNum ) override; + bool RemoveSelection( size_t selectionNum ) override; + bool SetSelection( size_t selectionNum, size_t startOffset, + size_t endOffset ) override; + bool CopyText( size_t startPosition, size_t endPosition ) override; + bool CutText( size_t startPosition, size_t endPosition ) override; + Dali::Accessibility::States CalculateStates() override; + }; }; } // namespace Internal diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp index c521817..802982b 100755 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -566,6 +566,8 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr } } +Text::ControllerPtr TextLabel::getController() { return mController; } + Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index index ) { Property::Value value; @@ -1102,12 +1104,174 @@ TextLabel::TextLabel() mRenderingBackend( DEFAULT_RENDERING_BACKEND ), mTextUpdateNeeded( false ) { + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new AccessibleImpl( actor, Dali::Accessibility::Role::LABEL ) ); + } ); } TextLabel::~TextLabel() { } +std::string TextLabel::AccessibleImpl::GetNameRaw() +{ + auto slf = Toolkit::TextLabel::DownCast( self ); + return slf.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get< std::string >(); +} + +std::string TextLabel::AccessibleImpl::GetText( size_t startOffset, + size_t endOffset ) +{ + if( endOffset <= startOffset ) + return {}; + + auto slf = Toolkit::TextLabel::DownCast( self ); + auto txt = + slf.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get< std::string >(); + + if( startOffset > txt.size() || endOffset > txt.size() ) + return {}; + + return txt.substr( startOffset, endOffset - startOffset ); +} + +size_t TextLabel::AccessibleImpl::GetCharacterCount() +{ + auto slf = Toolkit::TextLabel::DownCast( self ); + auto txt = + slf.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get< std::string >(); + + return txt.size(); +} + +size_t TextLabel::AccessibleImpl::GetCaretOffset() +{ + return {}; +} + +bool TextLabel::AccessibleImpl::SetCaretOffset(size_t offset) +{ + return {}; +} + +Dali::Accessibility::Range TextLabel::AccessibleImpl::GetTextAtOffset( + size_t offset, Dali::Accessibility::TextBoundary boundary ) +{ + auto slf = Toolkit::TextLabel::DownCast( self ); + auto txt = slf.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get< std::string >(); + auto txt_size = txt.size(); + + auto range = Dali::Accessibility::Range{}; + + switch(boundary) + { + case Dali::Accessibility::TextBoundary::CHARACTER: + { + if (offset < txt_size) + { + range.content = txt[offset]; + range.startOffset = offset; + range.endOffset = offset + 1; + } + } + break; + case Dali::Accessibility::TextBoundary::WORD: + case Dali::Accessibility::TextBoundary::LINE: + { + auto txt_c_string = txt.c_str(); + auto breaks = std::vector< char >( txt_size, 0 ); + if(boundary == Dali::Accessibility::TextBoundary::WORD) + Accessibility::Accessible::FindWordSeparationsUtf8((const utf8_t *) txt_c_string, txt_size, "", breaks.data()); + else + Accessibility::Accessible::FindLineSeparationsUtf8((const utf8_t *) txt_c_string, txt_size, "", breaks.data()); + auto index = 0u; + auto counter = 0u; + while( index < txt_size && counter <= offset ) + { + auto start = index; + if(breaks[index]) + { + while(breaks[index]) + index++; + counter++; + } + else + { + if (boundary == Dali::Accessibility::TextBoundary::WORD) + index++; + if (boundary == Dali::Accessibility::TextBoundary::LINE) + counter++; + } + if ((counter - 1) == offset) + { + range.content = txt.substr(start, index - start + 1); + range.startOffset = start; + range.endOffset = index + 1; + } + if (boundary == Dali::Accessibility::TextBoundary::LINE) + index++; + } + } + break; + case Dali::Accessibility::TextBoundary::SENTENCE: + { + /* not supported by efl */ + } + break; + case Dali::Accessibility::TextBoundary::PARAGRAPH: + { + /* Paragraph is not supported by libunibreak library */ + } + break; + default: + break; + } + + return range; +} + +Dali::Accessibility::Range +TextLabel::AccessibleImpl::GetSelection( size_t selectionNum ) +{ + // Since DALi supports only one selection indexes higher than 0 are ignored + if( selectionNum > 0 ) + return {}; + + auto slf = Toolkit::TextLabel::DownCast( self ); + auto ctrl = Dali::Toolkit::GetImpl( slf ).getController(); + std::string ret; + ctrl->RetrieveSelection( ret ); + auto r = ctrl->GetSelectionIndexes(); + + return { static_cast(r.first), static_cast(r.second), ret }; +} + +bool TextLabel::AccessibleImpl::RemoveSelection( size_t selectionNum ) +{ + // Since DALi supports only one selection indexes higher than 0 are ignored + if( selectionNum > 0 ) + return false; + + auto slf = Toolkit::TextLabel::DownCast( self ); + Dali::Toolkit::GetImpl( slf ).getController()->SetSelection( 0, 0 ); + return true; +} + +bool TextLabel::AccessibleImpl::SetSelection( size_t selectionNum, + size_t startOffset, + size_t endOffset ) +{ + // Since DALi supports only one selection indexes higher than 0 are ignored + if( selectionNum > 0 ) + return false; + + auto slf = Toolkit::TextLabel::DownCast( self ); + Dali::Toolkit::GetImpl( slf ).getController()->SetSelection( startOffset, + endOffset ); + return true; +} + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.h b/dali-toolkit/internal/controls/text-controls/text-label-impl.h index 85e94ab..994453a 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.h @@ -30,6 +30,7 @@ #include #include #include +#include namespace Dali @@ -73,6 +74,8 @@ public: */ static Property::Value GetProperty( BaseObject* object, Property::Index index ); + Text::ControllerPtr getController(); + private: // From Control /** @@ -151,6 +154,26 @@ private: // Data int mRenderingBackend; bool mTextUpdateNeeded:1; + +protected: + struct AccessibleImpl : public Control::Impl::AccessibleImpl, + public virtual Dali::Accessibility::Text + { + using Control::Impl::AccessibleImpl::AccessibleImpl; + + std::string GetText( size_t startOffset, size_t endOffset ) override; + size_t GetCharacterCount() override; + size_t GetCaretOffset() override; + bool SetCaretOffset(size_t offset) override; + Dali::Accessibility::Range + GetTextAtOffset( size_t offset, + Dali::Accessibility::TextBoundary boundary ) override; + Dali::Accessibility::Range GetSelection( size_t selectionNum ) override; + bool RemoveSelection( size_t selectionNum ) override; + bool SetSelection( size_t selectionNum, size_t startOffset, + size_t endOffset ) override; + std::string GetNameRaw() override; + }; }; } // namespace Internal diff --git a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp index 10e7f78..b281055 100644 --- a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp @@ -43,6 +43,7 @@ #include #include #include +#include namespace Dali { @@ -886,11 +887,14 @@ TextSelectionPopup::TextSelectionPopup( TextSelectionPopupCallbackInterface* cal mPopupShowing( false ), mButtonsChanged( false ) { + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::DIALOG, true ) ); + } ); } TextSelectionPopup::~TextSelectionPopup() -{ -} +{} } // namespace Internal diff --git a/dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.cpp index 358ace6..45c1a66 100644 --- a/dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.cpp @@ -30,6 +30,7 @@ #include #include #include +#include namespace Dali { @@ -385,6 +386,12 @@ TextSelectionToolbar::TextSelectionToolbar() mDividerIndexes(), mFirstScrollEnd( false ) { + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) + { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::TOOL_BAR, true ) ); + } + ); } TextSelectionToolbar::~TextSelectionToolbar() diff --git a/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp b/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp index 441b640..3ce659c 100644 --- a/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp +++ b/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp @@ -25,6 +25,7 @@ // INTERNAL INCLUDES #include +#include namespace Dali { @@ -288,6 +289,10 @@ ToolBar::ToolBar() mInitializing( false ), mControls() { + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::TOOL_BAR, true ) ); + } ); } ToolBar::~ToolBar() diff --git a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp index dfd441b..edd650a 100755 --- a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp +++ b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp @@ -33,6 +33,7 @@ // INTERNAL INCLUDES #include #include +#include namespace Dali { @@ -138,6 +139,12 @@ VideoView::VideoView() mIsUnderlay( true ) { mVideoPlayer = Dali::VideoPlayer::New(); + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) + { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::VIDEO, true ) ); + } + ); } VideoView::~VideoView() diff --git a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp index 18bd7a0..61cb481 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp @@ -21,7 +21,6 @@ // EXTERNAL INCLUDES #include // for strcmp #include -#include #include #include #include @@ -40,10 +39,10 @@ #include #include #include -#include #include #include #include +#include namespace Dali { @@ -746,11 +745,6 @@ Actor KeyboardFocusManager::GetFocusIndicatorActor() void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) { - AccessibilityAdaptor accessibilityAdaptor = AccessibilityAdaptor::Get(); - bool isAccessibilityEnabled = accessibilityAdaptor.IsEnabled(); - - Toolkit::AccessibilityManager accessibilityManager = Toolkit::AccessibilityManager::Get(); - std::string keyName = event.keyPressedName; if( mIsFocusIndicatorShown == UNKNOWN ) @@ -764,7 +758,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) { if (keyName == "Left") { - if(!isAccessibilityEnabled) + if(!mIsFocusIndicatorShown) { if(mIsFocusIndicatorShown == HIDE) { @@ -781,13 +775,15 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) } else { - // Move the accessibility focus backward - accessibilityManager.MoveFocusBackward(); + // Move the focus towards left + MoveFocus(Toolkit::Control::KeyboardFocus::LEFT); } + + isFocusStartableKey = true; } else if (keyName == "Right") { - if(!isAccessibilityEnabled) + if(!mIsFocusIndicatorShown) { if( mIsFocusIndicatorShown == HIDE ) { @@ -802,13 +798,13 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) } else { - // Move the accessibility focus forward - accessibilityManager.MoveFocusForward(); + // Move the focus towards right + MoveFocus(Toolkit::Control::KeyboardFocus::RIGHT); } isFocusStartableKey = true; } - else if (keyName == "Up" && !isAccessibilityEnabled) + else if (keyName == "Up") { if( mIsFocusIndicatorShown == HIDE ) { @@ -823,7 +819,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) isFocusStartableKey = true; } - else if (keyName == "Down" && !isAccessibilityEnabled) + else if (keyName == "Down") { if( mIsFocusIndicatorShown == HIDE ) { @@ -838,7 +834,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) isFocusStartableKey = true; } - else if (keyName == "Prior" && !isAccessibilityEnabled) + else if (keyName == "Prior") { if( mIsFocusIndicatorShown == HIDE ) { @@ -853,7 +849,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) isFocusStartableKey = true; } - else if (keyName == "Next" && !isAccessibilityEnabled) + else if (keyName == "Next") { if( mIsFocusIndicatorShown == HIDE ) { @@ -868,7 +864,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) isFocusStartableKey = true; } - else if (keyName == "Tab" && !isAccessibilityEnabled) + else if (keyName == "Tab") { if( mIsFocusIndicatorShown == HIDE ) { @@ -884,7 +880,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) isFocusStartableKey = true; } - else if (keyName == "space" && !isAccessibilityEnabled) + else if (keyName == "space") { if( mIsFocusIndicatorShown == HIDE ) { @@ -894,7 +890,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) isFocusStartableKey = true; } - else if (keyName == "" && !isAccessibilityEnabled) + else if (keyName == "") { // Check the fake key event for evas-plugin case if( mIsFocusIndicatorShown == HIDE ) @@ -905,11 +901,11 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) isFocusStartableKey = true; } - else if (keyName == "Backspace" && !isAccessibilityEnabled) + else if (keyName == "Backspace") { // Emit signal to go back to the previous view??? } - else if (keyName == "Escape" && !isAccessibilityEnabled) + else if (keyName == "Escape") { } } @@ -917,7 +913,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) { if (keyName == "Return") { - if((mIsFocusIndicatorShown == HIDE) && !isAccessibilityEnabled) + if( mIsFocusIndicatorShown == HIDE ) { // Show focus indicator mIsFocusIndicatorShown = SHOW; @@ -925,16 +921,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) else { // The focused actor has enter pressed on it - Actor actor; - if( !isAccessibilityEnabled ) - { - actor = GetCurrentFocusActor(); - } - else - { - actor = accessibilityManager.GetCurrentFocusActor(); - } - + Actor actor = GetCurrentFocusActor(); if( actor ) { DoKeyboardEnter( actor ); @@ -945,7 +932,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) } } - if(isFocusStartableKey && ( mIsFocusIndicatorShown == SHOW ) && !isAccessibilityEnabled) + if( isFocusStartableKey && mIsFocusIndicatorShown == SHOW ) { Actor actor = GetCurrentFocusActor(); if( actor ) @@ -962,6 +949,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) // Let's try to move the initial focus MoveFocus(Toolkit::Control::KeyboardFocus::RIGHT); } + } } diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index e333be2..e9dc341 100755 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -33,6 +33,7 @@ #include #include #include +#include namespace { @@ -191,6 +192,12 @@ bool Controller::Impl::ProcessInputEvents() GetCursorPosition( mEventData->mPrimaryCursorPosition, cursorInfo ); + + if( NULL != mEditableControlInterface ) + { + mEditableControlInterface->CaretMoved( mEventData->mPrimaryCursorPosition ); + } + if( mEventData->mUpdateCursorHookPosition ) { // Update the cursor hook position. Used to move the cursor with the keys 'up' and 'down'. @@ -1942,6 +1949,18 @@ void Controller::Impl::RetrieveSelection( std::string& selectedText, bool delete } } +void Controller::Impl::SetSelection( int start, int end ) +{ + mEventData->mLeftSelectionPosition = start; + mEventData->mRightSelectionPosition = end; + mEventData->mUpdateCursorPosition = true; +} + +std::pair< int, int > Controller::Impl::GetSelectionIndexes() const +{ + return { mEventData->mLeftSelectionPosition, mEventData->mRightSelectionPosition }; +} + void Controller::Impl::ShowClipboard() { if( mClipboard ) @@ -1963,7 +1982,7 @@ void Controller::Impl::SetClipboardHideEnable(bool enable) mClipboardHideEnabled = enable; } -bool Controller::Impl::CopyStringToClipboard( std::string& source ) +bool Controller::Impl::CopyStringToClipboard( const std::string& source ) { //Send string to clipboard return ( mClipboard && mClipboard.SetItem( source ) ); diff --git a/dali-toolkit/internal/text/text-controller-impl.h b/dali-toolkit/internal/text/text-controller-impl.h index 5527870..a2d7071 100755 --- a/dali-toolkit/internal/text/text-controller-impl.h +++ b/dali-toolkit/internal/text/text-controller-impl.h @@ -625,13 +625,17 @@ struct Controller::Impl */ void RetrieveSelection( std::string& selectedText, bool deleteAfterRetrieval ); + void SetSelection( int start, int end ); + + std::pair< int, int > GetSelectionIndexes() const; + void ShowClipboard(); void HideClipboard(); void SetClipboardHideEnable(bool enable); - bool CopyStringToClipboard( std::string& source ); + bool CopyStringToClipboard( const std::string& source ); void SendSelectionToClipboard( bool deleteAfterSending ); diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp old mode 100755 new mode 100644 index 5ca9858..e97a391 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -819,6 +819,31 @@ void Controller::UpdateAfterFontChange( const std::string& newDefaultFont ) } } +void Controller::RetrieveSelection( std::string& selectedText ) const +{ + mImpl->RetrieveSelection( selectedText, false ); +} + +void Controller::SetSelection( int start, int end ) +{ + mImpl->SetSelection( start, end ); +} + +std::pair< int, int > Controller::GetSelectionIndexes() const +{ + return mImpl->GetSelectionIndexes(); +} + +void Controller::CopyStringToClipboard( const std::string& source ) +{ + mImpl->CopyStringToClipboard( source ); +} + +void Controller::SendSelectionToClipboard( bool deleteAfterSending ) +{ + mImpl->SendSelectionToClipboard( deleteAfterSending ); +} + // public : Default style & Input style void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily ) @@ -3539,13 +3564,17 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ // Insert at current cursor position. Vector& modifyText = mImpl->mModel->mLogicalModel->mText; + auto pos = modifyText.End(); if( cursorIndex < numberOfCharactersInModel ) { - modifyText.Insert( modifyText.Begin() + cursorIndex, utf32Characters.Begin(), utf32Characters.Begin() + maxSizeOfNewText ); + pos = modifyText.Begin() + cursorIndex; } - else + unsigned int realPos = pos - modifyText.Begin(); + modifyText.Insert( pos, utf32Characters.Begin(), utf32Characters.Begin() + maxSizeOfNewText ); + + if( NULL != mImpl->mEditableControlInterface ) { - modifyText.Insert( modifyText.End(), utf32Characters.Begin(), utf32Characters.Begin() + maxSizeOfNewText ); + mImpl->mEditableControlInterface->TextInserted( realPos, maxSizeOfNewText, text ); } // Mark the first paragraph to be updated. @@ -3705,6 +3734,13 @@ bool Controller::RemoveText( int cursorOffset, currentText.Erase( first, last ); + if( NULL != mImpl->mEditableControlInterface ) + { + std::string utf8; + Utf32ToUtf8( first, numberOfCharacters, utf8 ); + mImpl->mEditableControlInterface->TextDeleted( cursorIndex, numberOfCharacters, utf8 ); + } + // Cursor position retreat oldCursorIndex = cursorIndex; @@ -4303,6 +4339,14 @@ void Controller::ResetCursorPosition( CharacterIndex cursorIndex ) } } +CharacterIndex Controller::GetCursorPosition() +{ + if( !mImpl->mEventData ) + return 0; + + return mImpl->mEventData->mPrimaryCursorPosition; +} + void Controller::ResetScrollPosition() { if( NULL != mImpl->mEventData ) diff --git a/dali-toolkit/internal/text/text-controller.h b/dali-toolkit/internal/text/text-controller.h old mode 100755 new mode 100644 index 18ff68e..f93de21 --- a/dali-toolkit/internal/text/text-controller.h +++ b/dali-toolkit/internal/text/text-controller.h @@ -650,6 +650,38 @@ public: // Update. */ void UpdateAfterFontChange( const std::string& newDefaultFont ); + /** + * @brief The method acquires currently selected text + * @param selectedText variable to place selected text in + */ + void RetrieveSelection( std::string& selectedText ) const; + + /** + * @brief The method sets selection in given range + * @param start index of first character + * @param end index of first character after selection + */ + void SetSelection( int start, int end ); + + /** + * @brief This method retrieve indexes of current selection + * + * @return a pair, where first element is left index of selection and second is the right one + */ + std::pair< int, int > GetSelectionIndexes() const; + + /** + * Place string in system clipboard + * @param source std::string + */ + void CopyStringToClipboard( const std::string& source ); + + /** + * Place currently selected text in system clipboard + * @param deleteAfterSending flag pointing if text should be deleted after sending to clipboard + */ + void SendSelectionToClipboard( bool deleteAfterSending ); + public: // Default style & Input style /** @@ -1488,6 +1520,19 @@ public: // Text-input Event Queuing. */ bool ShouldClearFocusOnEscape() const; + /** + * @brief Used to reset the cursor position after setting a new text. + * + * @param[in] cursorIndex Where to place the cursor. + */ + void ResetCursorPosition( CharacterIndex cursorIndex ); + + /** + * @brief The method acquires current position of cursor + * @return unsigned value with cursor position + */ + CharacterIndex GetCursorPosition(); + protected: // Inherit from Text::Decorator::ControllerInterface. /** @@ -1632,13 +1677,6 @@ private: // Helpers. void ClearStyleData(); /** - * @brief Used to reset the cursor position after setting a new text. - * - * @param[in] cursorIndex Where to place the cursor. - */ - void ResetCursorPosition( CharacterIndex cursorIndex ); - - /** * @brief Used to reset the scroll position after setting a new text. */ void ResetScrollPosition(); diff --git a/dali-toolkit/internal/text/text-editable-control-interface.h b/dali-toolkit/internal/text/text-editable-control-interface.h index e54704c..f2a86d5 100644 --- a/dali-toolkit/internal/text/text-editable-control-interface.h +++ b/dali-toolkit/internal/text/text-editable-control-interface.h @@ -46,6 +46,21 @@ public: {} /** + * @brief Called to signal that text has been inserted. + */ + virtual void TextInserted( unsigned int position, unsigned int length, const std::string &content ) = 0; + + /** + * @brief Called to signal that text has been deleted. + */ + virtual void TextDeleted( unsigned int position, unsigned int length, const std::string &content ) = 0; + + /** + * @brief Called to signal that caret (cursor position) has been moved. + */ + virtual void CaretMoved( unsigned int position ) = 0; + + /** * @brief Called to signal that text has been inserted or deleted. */ virtual void TextChanged() = 0; diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp old mode 100755 new mode 100644 index c469d1c..354c460 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -25,9 +25,12 @@ #include #include #include +#include #include +#include #include #include +#include // INTERNAL INCLUDES #include @@ -44,6 +47,12 @@ #include #include #include +#include +#include + +#include +#include +#include namespace Dali { @@ -352,7 +361,11 @@ void Control::KeyboardEnter() bool Control::OnAccessibilityActivated() { - return false; // Accessibility activation is not handled by default + if( Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( Self() ) ) + { + return OnKeyboardEnter(); + } + return false; } bool Control::OnKeyboardEnter() @@ -467,6 +480,17 @@ void Control::Initialize() { SetKeyboardNavigationSupport( true ); } + + Dali::TypeInfo type; + Self().GetTypeInfo( type ); + if (type) + { + auto typeName = type.GetName(); + DevelControl::AppendAccessibilityAttribute( Self(), "t", typeName ); + } + + if (Accessibility::IsUp()) + mImpl->AccessibilityRegister(); } void Control::OnInitialize() @@ -523,6 +547,17 @@ void Control::EmitKeyInputFocusSignal( bool focusGained ) { Dali::Toolkit::Control handle( GetOwner() ); + if( Accessibility::IsUp() ) + { + auto self = mImpl->GetAccessibilityObject( Self() ); + self->EmitFocused( focusGained ); + auto parent = self->GetParent(); + if( parent && !self->GetStates()[Dali::Accessibility::State::MANAGES_DESCENDANTS] ) + { + parent->EmitActiveDescendantChanged( parent, self ); + } + } + if ( focusGained ) { // signals are allocated dynamically when someone connects @@ -561,12 +596,19 @@ void Control::OnStageConnection( int depth ) CreateClippingRenderer( *this ); // Request to be laid out when the control is connected to the Stage. - // Signal that a Relayout may be needed + if( Accessibility::IsUp() ) + { + mImpl->AccessibilityRegister(); + } } void Control::OnStageDisconnection() { + if( Accessibility::IsUp() ) + { + mImpl->AccessibilityDeregister(); + } mImpl->OnStageDisconnection(); } @@ -596,10 +638,49 @@ void Control::OnPropertySet( Property::Index index, Property::Value propertyValu { // If the clipping mode has been set, we may need to create a renderer. // Only do this if we are already on-stage as the OnStageConnection will handle the off-stage clipping controls. - if( ( index == Actor::Property::CLIPPING_MODE ) && Self().OnStage() ) + switch( index ) { - // Note: This method will handle whether creation of the renderer is required. - CreateClippingRenderer( *this ); + case Actor::Property::CLIPPING_MODE: + { + if( Self().OnStage() ) + { + // Note: This method will handle whether creation of the renderer is required. + CreateClippingRenderer( *this ); + } + break; + } + case Actor::Property::VISIBLE: + { + if( Dali::Accessibility::IsUp() ) + { + Dali::Accessibility::Accessible::Get(Self())->EmitVisible( Self().GetProperty( Actor::Property::VISIBLE ).Get() ); + } + break; + } + case Toolkit::DevelControl::Property::ACCESSIBILITY_NAME: + { + if( Dali::Accessibility::IsUp() ) + { + Dali::Accessibility::Accessible::Get(Self())->Emit( Dali::Accessibility::ObjectPropertyChangeEvent::NAME ); + } + break; + } + case Toolkit::DevelControl::Property::ACCESSIBILITY_ROLE: + { + if( Dali::Accessibility::IsUp() ) + { + Dali::Accessibility::Accessible::Get(Self())->Emit( Dali::Accessibility::ObjectPropertyChangeEvent::ROLE ); + } + break; + } + case Toolkit::DevelControl::Property::ACCESSIBILITY_DESCRIPTON: + { + if( Dali::Accessibility::IsUp() ) + { + Dali::Accessibility::Accessible::Get(Self())->Emit( Dali::Accessibility::ObjectPropertyChangeEvent::DESCRIPTION ); + } + break; + } } } diff --git a/dali-toolkit/public-api/controls/control-impl.h b/dali-toolkit/public-api/controls/control-impl.h index f2e4402..08240aa 100644 --- a/dali-toolkit/public-api/controls/control-impl.h +++ b/dali-toolkit/public-api/controls/control-impl.h @@ -680,7 +680,6 @@ public: private: Impl* mImpl; /// @endcond - }; /** diff --git a/dali-toolkit/public-api/controls/control.cpp b/dali-toolkit/public-api/controls/control.cpp index d9b2f8f..ee95b95 100644 --- a/dali-toolkit/public-api/controls/control.cpp +++ b/dali-toolkit/public-api/controls/control.cpp @@ -30,7 +30,6 @@ namespace Dali namespace Toolkit { - Control Control::New() { return Internal::Control::New(); diff --git a/dali-toolkit/public-api/controls/control.h b/dali-toolkit/public-api/controls/control.h index ed68e15..17a0786 100644 --- a/dali-toolkit/public-api/controls/control.h +++ b/dali-toolkit/public-api/controls/control.h @@ -27,6 +27,7 @@ #include #include #include +#include // INTERNAL INCLUDES #include @@ -175,6 +176,29 @@ public: /// @brief ResourceReady signal type. @SINCE_1_2.60 typedef Signal ResourceReadySignalType; + /// @brief AccessibilityActivate signal type. + typedef Signal< void ( ) > AccessibilityActivateSignalType; + + /// @brief AccessibilityReadingSkipped signal type. + typedef Signal< void ( ) > AccessibilityReadingSkippedSignalType; + + /// @brief AccessibilityReadingCancelled signal type. + typedef Signal< void ( ) > AccessibilityReadingCancelledSignalType; + + /// @brief AccessibilityReadingStopped signal type. + typedef Signal< void ( ) > AccessibilityReadingStoppedSignalType; + + /// @brief AccessibilityGetName signal type. + typedef Signal< void ( std::string& ) > AccessibilityGetNameSignalType; + + /// @brief AccessibilityGetDescription signal type. + typedef Signal< void ( std::string& ) > AccessibilityGetDescriptionSignalType; + + /// @brief AccessibilityDoGesture signal type. + typedef Signal< void ( std::pair& ) > AccessibilityDoGestureSignalType; + + using RelationsCollection = std::vector>; + public: // Creation & Destruction /** @@ -450,7 +474,6 @@ public: * @note A RelayoutRequest is queued by Control before this signal is emitted */ ResourceReadySignalType& ResourceReadySignal(); - public: // Intended for control developers /** @@ -523,7 +546,6 @@ public: // Templates for Deriving Classes DALI_ASSERT_DEBUG(dynamic_cast(&CustomActor(internal).GetImplementation())); } } - }; /** diff --git a/dali-toolkit/public-api/controls/text-controls/text-field.h b/dali-toolkit/public-api/controls/text-controls/text-field.h index 133b2c7..68f433d 100644 --- a/dali-toolkit/public-api/controls/text-controls/text-field.h +++ b/dali-toolkit/public-api/controls/text-controls/text-field.h @@ -148,7 +148,7 @@ public: /** * @brief The line vertical alignment. * @details Name "verticalAlignment", type Property::STRING type VerticalAlignment::Type (Property::INTEGER) - * Values "TOP", "CENTER", "BOTTOM". + * Values "TOP", "CENTER", "BOTTOM". * @note Return type is Property::STRING * @SINCE_1_0.0 */