2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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.
20 using ElmSharp.Accessible;
22 namespace ElmSharp.Test
24 class AccessibilityRelationTest : TestCaseBase
26 public override string TestName => "AccessibilityRelationTest";
27 public override string TestDescription => "Accessibility Relation API test";
29 public override void Run(Window win)
31 Conformant conformant = new Conformant(win);
34 Box box = new Box(win);
36 conformant.SetContent(box);
38 Button button1 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "LabelledBy" };
39 Label label1 = new Label(win) { Text = "LabelFor" };
47 ((IAccessibleObject)button1).AppendRelation(new LabelledBy() { Target = label1 });
48 ((IAccessibleObject)label1).AppendRelation(new LabelFor() { Target = button1 });
50 button1.Clicked += (s, e) =>
52 ((IAccessibleObject)button1).RemoveRelation(new LabelledBy() { Target = label1 });
53 ((IAccessibleObject)label1).RemoveRelation(new LabelFor() { Target = button1 });
56 Label label8 = new Label(win) { WeightX = 1, AlignmentX = -1, Text = "ControlledBy" };
57 Button button3 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "ControllerFor" };
65 ((IAccessibleObject)label8).AppendRelation(new ControlledBy() { Target = button3 });
66 ((IAccessibleObject)button3).AppendRelation(new ControllerFor() { Target = label8 });
68 button3.Clicked += (s, e) =>
70 ((IAccessibleObject)label8).RemoveRelation(new ControlledBy() { Target = button3 });
71 ((IAccessibleObject)button3).RemoveRelation(new ControllerFor() { Target = label8 });
74 Box box2 = new Box(win) { WeightX = 1, AlignmentX = -1};
75 Label label2 = new Label(win) { Text = "Group" };
76 Button button4 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "Member" };
82 ((IAccessibleObject)label2).AppendRelation(new LabelFor() { Target = box2 });
83 ((IAccessibleObject)label2).AppendRelation(new MemberOf() { Target = box2 });
84 ((IAccessibleObject)box2).AppendRelation(new LabelledBy() { Target = label2 });
85 ((IAccessibleObject)button4).AppendRelation(new MemberOf() { Target = box2 });
88 box2.PackEnd(button4);
91 button4.Clicked += (s, e) =>
93 ((IAccessibleObject)label2).RemoveRelation(new LabelFor() { Target = box2 });
94 ((IAccessibleObject)label2).RemoveRelation(new MemberOf() { Target = box2 });
95 ((IAccessibleObject)box2).RemoveRelation(new LabelledBy() { Target = label2 });
96 ((IAccessibleObject)button4).RemoveRelation(new MemberOf() { Target = box2 });
99 Button button6 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "Xbutton" };
100 Label label3 = new Label(win) { Text = "Tooltip of Xbutton" };
105 ((IAccessibleObject)label3).AppendRelation(new TooltipFor() { Target = button6 });
107 box.PackEnd(button6);
110 button6.Clicked += (s, e) =>
112 ((IAccessibleObject)label3).RemoveRelation(new TooltipFor() { Target = button6 });
115 Box box3 = new Box(win) { WeightX = 1, AlignmentX = -1};
116 Label label4 = new Label(win) { Text = "Child of inner box" };
117 Button button7 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "child of inner box" };
123 ((IAccessibleObject)box3).AppendRelation(new ParentOf() { Target = label4 });
124 ((IAccessibleObject)box3).AppendRelation(new ParentOf() { Target = button7 });
125 ((IAccessibleObject)label4).AppendRelation(new ChildOf() { Target = box3 });
126 ((IAccessibleObject)button7).AppendRelation(new ChildOf() { Target = box3 });
128 box3.PackEnd(label4);
129 box3.PackEnd(button7);
132 button7.Clicked += (s, e) =>
134 ((IAccessibleObject)box3).RemoveRelation(new ParentOf() { Target = label4 });
135 ((IAccessibleObject)box3).RemoveRelation(new ParentOf() { Target = button7 });
136 ((IAccessibleObject)label4).RemoveRelation(new ChildOf() { Target = box3 });
137 ((IAccessibleObject)button7).RemoveRelation(new ChildOf() { Target = box3 });
140 Label label6 = new Label(win) { Text = "Extended" };
141 Button button12 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "Not Extended" };
146 ((IAccessibleObject)label6).AppendRelation(new Extended() { Target = button12 });
148 box.PackEnd(button12);
151 button12.Clicked += (s, e) =>
153 ((IAccessibleObject)label6).RemoveRelation(new Extended() { Target = button12 });
156 Button button8 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "FlowsTo" };
157 Button button9 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "FlowsFrom" };
162 ((IAccessibleObject)button8).AppendRelation(new FlowsTo() { Target = button9 });
163 ((IAccessibleObject)button9).AppendRelation(new FlowsFrom() { Target = button8 });
165 box.PackEnd(button8);
166 box.PackEnd(button9);
168 button8.Clicked += (s, e) =>
170 ((IAccessibleObject)button8).RemoveRelation(new FlowsTo() { Target = button9 });
173 button9.Clicked += (s, e) =>
175 ((IAccessibleObject)button9).RemoveRelation(new FlowsFrom() { Target = button8 });
178 Button button10 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "EmbeddedBy" };
182 ((IAccessibleObject)button10).AppendRelation(new EmbeddedBy() { Target = box });
183 ((IAccessibleObject)box).AppendRelation(new Embeds() { Target = button10 });
185 box.PackEnd(button10);
187 button10.Clicked += (s, e) =>
189 ((IAccessibleObject)button10).RemoveRelation(new EmbeddedBy() { Target = box });
190 ((IAccessibleObject)box).RemoveRelation(new Embeds() { Target = button10 });
193 Button button11 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "popup" };
197 Popup popup = new Popup(win)
199 Orientation = PopupOrientation.Top,
202 popup.Append("Popup!!");
204 ((IAccessibleObject)popup).AppendRelation(new PopupFor() { Target = button11 });
205 ((IAccessibleObject)popup).AppendRelation(new SubwindowOf() { Target = box });
206 ((IAccessibleObject)box).AppendRelation(new ParentWindowOf() { Target = popup });
208 popup.OutsideClicked += (s, e) =>
214 button11.Clicked += (s, e) =>
219 box.PackEnd(button11);
221 Button button13 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "Remove Popup Relation"};
225 box.PackEnd(button13);
227 button13.Clicked += (s, e) =>
229 ((IAccessibleObject)popup).RemoveRelation(new PopupFor() { Target = button11 });
230 ((IAccessibleObject)popup).RemoveRelation(new SubwindowOf() { Target = box });
231 ((IAccessibleObject)box).RemoveRelation(new ParentWindowOf() { Target = popup });
234 Label label7 = new Label(win) { WeightX = 1, AlignmentX = -1,
235 Text = "This is Test for Accessibility Relation Append Test"};
238 ((IAccessibleObject)label7).AppendRelation(new DescriptionFor() { Target = box });
239 ((IAccessibleObject)box).AppendRelation(new DescribedBy() { Target = label7 });
243 Button button14 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "Remove Description Relation"};
245 box.PackEnd(button14);
247 button14.Clicked += (s, e) =>
249 ((IAccessibleObject)label7).RemoveRelation(new DescriptionFor() { Target = box });
250 ((IAccessibleObject)box).RemoveRelation(new DescribedBy() { Target = label7 });