2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 // Need to override adaptor classes for toolkit test harness, so include
19 // test harness headers before dali headers.
20 #include <dali-toolkit-test-suite-utils.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/devel-api/controls/control-devel.h>
26 #include <dali/devel-api/adaptor-framework/accessibility.h>
27 #include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
28 #include <dali/devel-api/atspi-interfaces/accessible.h>
30 #include <automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/dbus-wrapper.h>
32 void utc_dali_toolkit_accessibility_accessible_startup(void)
34 test_return_value = TET_UNDEF;
35 DBusWrapper::Install(std::unique_ptr<DBusWrapper>(new TestDBusWrapper));
38 void utc_dali_toolkit_accessibility_accessible_cleanup(void)
40 test_return_value = TET_PASS;
43 int utcDaliAccessibilityCheckBoxButtonGetStates(void)
45 ToolkitTestApplication application;
47 auto check_box_button = Toolkit::CheckBoxButton::New();
48 auto q = Dali::Accessibility::Accessible::Get( check_box_button );
50 auto states = q->GetStates();
51 DALI_TEST_EQUALS( (int) states[ Dali::Accessibility::State::SELECTABLE ], (int) true, TEST_LOCATION );
56 int utcDaliAccessibilityCheckLabelText(void)
58 ToolkitTestApplication application;
60 auto check_box_button = Toolkit::CheckBoxButton::New();
61 //check_box_button.SetLabelText( "button" );
62 check_box_button.SetProperty(Toolkit::Button::Property::LABEL, "button");
63 auto q = Dali::Accessibility::Accessible::Get( check_box_button );
65 DALI_TEST_EQUALS( q->GetName(), "button", TEST_LOCATION );
70 int UtcDaliAccessibilityCheckShowingState(void)
72 ToolkitTestApplication application;
74 auto parentButton = Toolkit::PushButton::New();
75 parentButton.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
76 parentButton.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
77 parentButton.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
78 parentButton.SetProperty(Actor::Property::POSITION, Dali::Vector2(0.0f, 0.0f));
79 parentButton.SetProperty(Actor::Property::SIZE, Dali::Vector2(200.0f, 200.0f));
80 application.GetScene().Add( parentButton );
82 // Toatally inside of parent
83 auto buttonA = Toolkit::PushButton::New();
84 buttonA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
85 buttonA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
86 buttonA.SetProperty(Actor::Property::POSITION, Dali::Vector2(0.0f, 0.0f));
87 buttonA.SetProperty(Actor::Property::SIZE, Dali::Vector2(100.0f, 100.0f));
88 parentButton.Add(buttonA);
90 // Toatally outside of parent
91 auto buttonB = Toolkit::PushButton::New();
92 buttonB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
93 buttonB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
94 buttonB.SetProperty(Actor::Property::POSITION, Dali::Vector2(300.0f, 300.0f));
95 buttonB.SetProperty(Actor::Property::SIZE, Dali::Vector2(100.0f, 100.0f));
96 parentButton.Add(buttonB);
98 // Partially inside of parent
99 auto buttonC = Toolkit::PushButton::New();
100 buttonC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
101 buttonC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
102 buttonC.SetProperty(Actor::Property::POSITION, Dali::Vector2(100.0f,100.0f));
103 buttonC.SetProperty(Actor::Property::SIZE, Dali::Vector2(200.0f, 200.0f));
104 parentButton.Add(buttonC);
106 application.SendNotification();
107 application.Render(16);
109 auto q = Dali::Accessibility::Accessible::Get(buttonA);
111 auto states = q->GetStates();
112 DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) true, TEST_LOCATION);
114 q = Dali::Accessibility::Accessible::Get(buttonB);
116 states = q->GetStates();
117 DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) false, TEST_LOCATION);
119 q = Dali::Accessibility::Accessible::Get(buttonC);
121 states = q->GetStates();
122 DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) true, TEST_LOCATION);
124 // Make SHOWING object invisible
125 buttonC.SetProperty(Actor::Property::VISIBLE, false);
127 application.SendNotification();
128 application.Render(16);
130 states = q->GetStates();
131 DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) false, TEST_LOCATION);
133 // Make SHOWING parent invisible
134 parentButton.SetProperty(Actor::Property::VISIBLE, false);
136 application.SendNotification();
137 application.Render(16);
139 q = Dali::Accessibility::Accessible::Get(buttonA);
141 states = q->GetStates();
142 DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) false, TEST_LOCATION);
147 int utcDaliAccessibilityHidden(void)
149 ToolkitTestApplication application;
151 auto parent = Toolkit::Control::New();
152 auto* parentAccessible = Accessibility::Accessible::Get(parent);
153 auto control = Toolkit::Control::New();
154 auto* controlAccessible = Accessibility::Accessible::Get(control);
159 DALI_TEST_CHECK(parentAccessible && controlAccessible);
160 DALI_TEST_CHECK(!controlAccessible->IsHidden());
161 DALI_TEST_CHECK(!control.GetProperty<bool>(Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN));
162 DALI_TEST_EQUALS(parentAccessible->GetChildCount(), 1u, TEST_LOCATION);
163 DALI_TEST_EQUALS(parentAccessible->GetChildAtIndex(0), controlAccessible, TEST_LOCATION);
165 control.SetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN, true);
168 DALI_TEST_CHECK(controlAccessible->IsHidden());
169 DALI_TEST_CHECK(control.GetProperty<bool>(Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN));
170 DALI_TEST_EQUALS(parentAccessible->GetChildCount(), 0u, TEST_LOCATION);
175 int utcDaliAutomationId(void)
177 ToolkitTestApplication application;
178 Dali::Property::Index automationIdIndex = Toolkit::DevelControl::Property::AUTOMATION_ID;
179 std::string automationIdKey = "automationId";
180 std::string automationIdValue = "test123";
182 auto control = Toolkit::Control::New();
183 auto* controlAccessible = Accessibility::Accessible::Get(control);
185 // Check that there is no automationId initially
186 DALI_TEST_CHECK(control.GetProperty<std::string>(automationIdIndex).empty());
187 auto attributes = controlAccessible->GetAttributes();
188 DALI_TEST_CHECK(attributes.find(automationIdKey) == attributes.end());
191 control.SetProperty(automationIdIndex, automationIdValue);
193 // Check that automationId is set
194 DALI_TEST_EQUALS(control.GetProperty<std::string>(automationIdIndex), automationIdValue, TEST_LOCATION);
195 attributes = controlAccessible->GetAttributes();
196 DALI_TEST_CHECK(attributes.find(automationIdKey) != attributes.end());
197 DALI_TEST_EQUALS(attributes[automationIdKey], automationIdValue, TEST_LOCATION);
199 // Unset automationId
200 control.SetProperty(automationIdIndex, "");
202 // Check that there is no automationId
203 DALI_TEST_CHECK(control.GetProperty<std::string>(automationIdIndex).empty());
204 attributes = controlAccessible->GetAttributes();
205 DALI_TEST_CHECK(attributes.find(automationIdKey) == attributes.end());