Merge "CanvasView: Change CanvasRenderer::GetSize() method to const" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-internal / utc-Dali-Accessibility-Accessible.cpp
1 /**
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
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>
21
22 #include <dali.h>
23 #include <dali-toolkit/dali-toolkit.h>
24
25 #include <dali/devel-api/adaptor-framework/accessibility.h>
26 #include <dali/devel-api/adaptor-framework/accessibility-impl.h>
27
28 #include <automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/dbus-wrapper.h>
29
30 void utc_dali_toolkit_accessibility_accessible_startup(void)
31 {
32   test_return_value = TET_UNDEF;
33   DBusWrapper::Install(std::unique_ptr<DBusWrapper>(new TestDBusWrapper));
34 }
35
36 void utc_dali_toolkit_accessibility_accessible_cleanup(void)
37 {
38   test_return_value = TET_PASS;
39 }
40
41 int utcDaliAccessibilityCheckBoxButtonGetStates(void)
42 {
43   ToolkitTestApplication application;
44
45   auto check_box_button = Toolkit::CheckBoxButton::New();
46   auto q = Dali::Accessibility::Accessible::Get( check_box_button );
47   DALI_TEST_CHECK( q );
48   auto states = q->GetStates();
49   DALI_TEST_EQUALS( (int) states[ Dali::Accessibility::State::SELECTABLE ], (int) true, TEST_LOCATION );
50
51   END_TEST;
52 }
53
54 int utcDaliAccessibilityCheckLabelText(void)
55 {
56   ToolkitTestApplication application;
57
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 );
62   DALI_TEST_CHECK( q );
63   DALI_TEST_EQUALS( q->GetName(), "button", TEST_LOCATION );
64
65   END_TEST;
66 }
67
68 int UtcDaliAccessibilityCheckShowingState(void)
69 {
70   ToolkitTestApplication application;
71
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 );
79
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);
87
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);
95
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);
103
104   application.SendNotification();
105   application.Render(16);
106
107   auto q = Dali::Accessibility::Accessible::Get(buttonA);
108   DALI_TEST_CHECK(q);
109   auto states = q->GetStates();
110   DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) true, TEST_LOCATION);
111
112   q = Dali::Accessibility::Accessible::Get(buttonB);
113   DALI_TEST_CHECK(q);
114   states = q->GetStates();
115   DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) false, TEST_LOCATION);
116
117   q = Dali::Accessibility::Accessible::Get(buttonC);
118   DALI_TEST_CHECK(q);
119   states = q->GetStates();
120   DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) true, TEST_LOCATION);
121
122   // Make SHOWING object invisible
123   buttonC.SetProperty(Actor::Property::VISIBLE, false);
124
125   application.SendNotification();
126   application.Render(16);
127
128   states = q->GetStates();
129   DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) false, TEST_LOCATION);
130
131   END_TEST;
132 }