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>
25 #include <dali/devel-api/adaptor-framework/accessibility.h>
26 #include <dali/devel-api/adaptor-framework/accessibility-impl.h>
28 #include <automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/dbus-wrapper.h>
30 void utc_dali_toolkit_accessibility_accessible_startup(void)
32 test_return_value = TET_UNDEF;
33 DBusWrapper::Install(std::unique_ptr<DBusWrapper>(new TestDBusWrapper));
36 void utc_dali_toolkit_accessibility_accessible_cleanup(void)
38 test_return_value = TET_PASS;
41 int utcDaliAccessibilityCheckBoxButtonGetStates(void)
43 ToolkitTestApplication application;
45 auto check_box_button = Toolkit::CheckBoxButton::New();
46 auto q = Dali::Accessibility::Accessible::Get( check_box_button );
48 auto states = q->GetStates();
49 DALI_TEST_EQUALS( (int) states[ Dali::Accessibility::State::SELECTABLE ], (int) true, TEST_LOCATION );
54 int utcDaliAccessibilityCheckLabelText(void)
56 ToolkitTestApplication application;
58 auto check_box_button = Toolkit::CheckBoxButton::New();
59 //check_box_button.SetLabelText( "button" );
60 check_box_button.SetProperty(Toolkit::Button::Property::LABEL, "button");
61 auto q = Dali::Accessibility::Accessible::Get( check_box_button );
63 DALI_TEST_EQUALS( q->GetName(), "button", TEST_LOCATION );
68 int UtcDaliAccessibilityCheckShowingState(void)
70 ToolkitTestApplication application;
72 auto parentButton = Toolkit::PushButton::New();
73 parentButton.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
74 parentButton.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
75 parentButton.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
76 parentButton.SetProperty(Actor::Property::POSITION, Dali::Vector2(0.0f, 0.0f));
77 parentButton.SetProperty(Actor::Property::SIZE, Dali::Vector2(200.0f, 200.0f));
78 application.GetScene().Add( parentButton );
80 // Toatally inside of parent
81 auto buttonA = Toolkit::PushButton::New();
82 buttonA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
83 buttonA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
84 buttonA.SetProperty(Actor::Property::POSITION, Dali::Vector2(0.0f, 0.0f));
85 buttonA.SetProperty(Actor::Property::SIZE, Dali::Vector2(100.0f, 100.0f));
86 parentButton.Add(buttonA);
88 // Toatally outside of parent
89 auto buttonB = Toolkit::PushButton::New();
90 buttonB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
91 buttonB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
92 buttonB.SetProperty(Actor::Property::POSITION, Dali::Vector2(300.0f, 300.0f));
93 buttonB.SetProperty(Actor::Property::SIZE, Dali::Vector2(100.0f, 100.0f));
94 parentButton.Add(buttonB);
96 // Partially inside of parent
97 auto buttonC = Toolkit::PushButton::New();
98 buttonC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
99 buttonC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
100 buttonC.SetProperty(Actor::Property::POSITION, Dali::Vector2(100.0f,100.0f));
101 buttonC.SetProperty(Actor::Property::SIZE, Dali::Vector2(200.0f, 200.0f));
102 parentButton.Add(buttonC);
104 application.SendNotification();
105 application.Render(16);
107 auto q = Dali::Accessibility::Accessible::Get(buttonA);
109 auto states = q->GetStates();
110 DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) true, TEST_LOCATION);
112 q = Dali::Accessibility::Accessible::Get(buttonB);
114 states = q->GetStates();
115 DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) false, TEST_LOCATION);
117 q = Dali::Accessibility::Accessible::Get(buttonC);
119 states = q->GetStates();
120 DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) true, TEST_LOCATION);
122 // Make SHOWING object invisible
123 buttonC.SetProperty(Actor::Property::VISIBLE, false);
125 application.SendNotification();
126 application.Render(16);
128 states = q->GetStates();
129 DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) false, TEST_LOCATION);