diff options
Diffstat (limited to 'ElmSharp.Test')
-rwxr-xr-x | ElmSharp.Test/ElmSharp.Test.csproj | 5 | ||||
-rw-r--r-- | ElmSharp.Test/TC/AccessibilityRelationTest.cs | 254 | ||||
-rw-r--r-- | ElmSharp.Test/TC/AccessibilityRoleTest.cs | 56 | ||||
-rw-r--r-- | ElmSharp.Test/TC/AccessibilityTest.cs | 286 | ||||
-rw-r--r-- | ElmSharp.Test/TC/Log.cs | 60 |
5 files changed, 660 insertions, 1 deletions
diff --git a/ElmSharp.Test/ElmSharp.Test.csproj b/ElmSharp.Test/ElmSharp.Test.csproj index 0333f12..ed2ba74 100755 --- a/ElmSharp.Test/ElmSharp.Test.csproj +++ b/ElmSharp.Test/ElmSharp.Test.csproj @@ -40,11 +40,14 @@ </PropertyGroup> <ItemGroup> <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="TC\AccessibilityRelationTest.cs" /> + <Compile Include="TC\AccessibilityTest.cs" /> <Compile Include="TC\BackgroundTest1.cs" /> <Compile Include="TC\BackgroundTest2.cs" /> <Compile Include="TC\BackgroundTest3.cs" /> <Compile Include="TC\GenListTest10.cs" /> <Compile Include="TC\LabelTest4.cs" /> + <Compile Include="TC\Log.cs" /> <Compile Include="TC\MultibuttonEntryTest1.cs" /> <Compile Include="TC\DateTimeSelectorTest2.cs" /> <Compile Include="TC\EntryTest2.cs" /> @@ -201,4 +204,4 @@ </FlavorProperties> </VisualStudio> </ProjectExtensions> -</Project>
\ No newline at end of file +</Project> diff --git a/ElmSharp.Test/TC/AccessibilityRelationTest.cs b/ElmSharp.Test/TC/AccessibilityRelationTest.cs new file mode 100644 index 0000000..53ccf2c --- /dev/null +++ b/ElmSharp.Test/TC/AccessibilityRelationTest.cs @@ -0,0 +1,254 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +using System; +using System.Linq; +using ElmSharp; +using ElmSharp.Accessible; + +namespace ElmSharp.Test +{ + class AccessibilityRelationTest : TestCaseBase + { + public override string TestName => "AccessibilityRelationTest"; + public override string TestDescription => "Accessibility Relation API test"; + + public override void Run(Window win) + { + Conformant conformant = new Conformant(win); + conformant.Show(); + + Box box = new Box(win); + box.Show(); + conformant.SetContent(box); + + Button button1 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "LabelledBy" }; + Label label1 = new Label(win) { Text = "LabelFor" }; + + button1.Show(); + label1.Show(); + + box.PackEnd(button1); + box.PackEnd(label1); + + ((IAccessibleObject)button1).AppendRelation(new LabelledBy() { Target = label1 }); + ((IAccessibleObject)label1).AppendRelation(new LabelFor() { Target = button1 }); + + button1.Clicked += (s, e) => + { + ((IAccessibleObject)button1).RemoveRelation(new LabelledBy() { Target = label1 }); + ((IAccessibleObject)label1).RemoveRelation(new LabelFor() { Target = button1 }); + }; + + Label label8 = new Label(win) { WeightX = 1, AlignmentX = -1, Text = "ControlledBy" }; + Button button3 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "ControllerFor" }; + + label8.Show(); + button3.Show(); + + box.PackEnd(label8); + box.PackEnd(button3); + + ((IAccessibleObject)label8).AppendRelation(new ControlledBy() { Target = button3 }); + ((IAccessibleObject)button3).AppendRelation(new ControllerFor() { Target = label8 }); + + button3.Clicked += (s, e) => + { + ((IAccessibleObject)label8).RemoveRelation(new ControlledBy() { Target = button3 }); + ((IAccessibleObject)button3).RemoveRelation(new ControllerFor() { Target = label8 }); + }; + + Box box2 = new Box(win) { WeightX = 1, AlignmentX = -1}; + Label label2 = new Label(win) { Text = "Group" }; + Button button4 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "Member" }; + + box2.Show(); + label2.Show(); + button4.Show(); + + ((IAccessibleObject)label2).AppendRelation(new LabelFor() { Target = box2 }); + ((IAccessibleObject)label2).AppendRelation(new MemberOf() { Target = box2 }); + ((IAccessibleObject)box2).AppendRelation(new LabelledBy() { Target = label2 }); + ((IAccessibleObject)button4).AppendRelation(new MemberOf() { Target = box2 }); + + box2.PackEnd(label2); + box2.PackEnd(button4); + box.PackEnd(box2); + + button4.Clicked += (s, e) => + { + ((IAccessibleObject)label2).RemoveRelation(new LabelFor() { Target = box2 }); + ((IAccessibleObject)label2).RemoveRelation(new MemberOf() { Target = box2 }); + ((IAccessibleObject)box2).RemoveRelation(new LabelledBy() { Target = label2 }); + ((IAccessibleObject)button4).RemoveRelation(new MemberOf() { Target = box2 }); + }; + + Button button6 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "Xbutton" }; + Label label3 = new Label(win) { Text = "Tooltip of Xbutton" }; + + button6.Show(); + label3.Show(); + + ((IAccessibleObject)label3).AppendRelation(new TooltipFor() { Target = button6 }); + + box.PackEnd(button6); + box.PackEnd(label3); + + button6.Clicked += (s, e) => + { + ((IAccessibleObject)label3).RemoveRelation(new TooltipFor() { Target = button6 }); + }; + + Box box3 = new Box(win) { WeightX = 1, AlignmentX = -1}; + Label label4 = new Label(win) { Text = "Child of inner box" }; + Button button7 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "child of inner box" }; + + box3.Show(); + label4.Show(); + button7.Show(); + + ((IAccessibleObject)box3).AppendRelation(new ParentOf() { Target = label4 }); + ((IAccessibleObject)box3).AppendRelation(new ParentOf() { Target = button7 }); + ((IAccessibleObject)label4).AppendRelation(new ChildOf() { Target = box3 }); + ((IAccessibleObject)button7).AppendRelation(new ChildOf() { Target = box3 }); + + box3.PackEnd(label4); + box3.PackEnd(button7); + box.PackEnd(box3); + + button7.Clicked += (s, e) => + { + ((IAccessibleObject)box3).RemoveRelation(new ParentOf() { Target = label4 }); + ((IAccessibleObject)box3).RemoveRelation(new ParentOf() { Target = button7 }); + ((IAccessibleObject)label4).RemoveRelation(new ChildOf() { Target = box3 }); + ((IAccessibleObject)button7).RemoveRelation(new ChildOf() { Target = box3 }); + }; + + Label label6 = new Label(win) { Text = "Extended" }; + Button button12 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "Not Extended" }; + + label6.Show(); + button12.Show(); + + ((IAccessibleObject)label6).AppendRelation(new Extended() { Target = button12 }); + + box.PackEnd(button12); + box.PackEnd(label6); + + button12.Clicked += (s, e) => + { + ((IAccessibleObject)label6).RemoveRelation(new Extended() { Target = button12 }); + }; + + Button button8 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "FlowsTo" }; + Button button9 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "FlowsFrom" }; + + button8.Show(); + button9.Show(); + + ((IAccessibleObject)button8).AppendRelation(new FlowsTo() { Target = button9 }); + ((IAccessibleObject)button9).AppendRelation(new FlowsFrom() { Target = button8 }); + + box.PackEnd(button8); + box.PackEnd(button9); + + button8.Clicked += (s, e) => + { + ((IAccessibleObject)button8).RemoveRelation(new FlowsTo() { Target = button9 }); + }; + + button9.Clicked += (s, e) => + { + ((IAccessibleObject)button9).RemoveRelation(new FlowsFrom() { Target = button8 }); + }; + + Button button10 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "EmbeddedBy" }; + + button10.Show(); + + ((IAccessibleObject)button10).AppendRelation(new EmbeddedBy() { Target = box }); + ((IAccessibleObject)box).AppendRelation(new Embeds() { Target = button10 }); + + box.PackEnd(button10); + + button10.Clicked += (s, e) => + { + ((IAccessibleObject)button10).RemoveRelation(new EmbeddedBy() { Target = box }); + ((IAccessibleObject)box).RemoveRelation(new Embeds() { Target = button10 }); + }; + + Button button11 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "popup" }; + + button11.Show(); + + Popup popup = new Popup(win) + { + Orientation = PopupOrientation.Top, + Timeout = 5 + }; + popup.Append("Popup!!"); + + ((IAccessibleObject)popup).AppendRelation(new PopupFor() { Target = button11 }); + ((IAccessibleObject)popup).AppendRelation(new SubwindowOf() { Target = box }); + ((IAccessibleObject)box).AppendRelation(new ParentWindowOf() { Target = popup }); + + popup.OutsideClicked += (s, e) => + { + popup.Hide(); + }; + + + button11.Clicked += (s, e) => + { + popup.Show(); + }; + + box.PackEnd(button11); + + Button button13 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "Remove Popup Relation"}; + + button13.Show(); + + box.PackEnd(button13); + + button13.Clicked += (s, e) => + { + ((IAccessibleObject)popup).RemoveRelation(new PopupFor() { Target = button11 }); + ((IAccessibleObject)popup).RemoveRelation(new SubwindowOf() { Target = box }); + ((IAccessibleObject)box).RemoveRelation(new ParentWindowOf() { Target = popup }); + }; + + Label label7 = new Label(win) { WeightX = 1, AlignmentX = -1, + Text = "This is Test for Accessibility Relation Append Test"}; + label7.Show(); + + ((IAccessibleObject)label7).AppendRelation(new DescriptionFor() { Target = box }); + ((IAccessibleObject)box).AppendRelation(new DescribedBy() { Target = label7 }); + + box.PackEnd(label7); + + Button button14 = new Button(win) { WeightX = 1, AlignmentX = -1, Text = "Remove Description Relation"}; + button14.Show(); + box.PackEnd(button14); + + button14.Clicked += (s, e) => + { + ((IAccessibleObject)label7).RemoveRelation(new DescriptionFor() { Target = box }); + ((IAccessibleObject)box).RemoveRelation(new DescribedBy() { Target = label7 }); + }; + } + } +} diff --git a/ElmSharp.Test/TC/AccessibilityRoleTest.cs b/ElmSharp.Test/TC/AccessibilityRoleTest.cs new file mode 100644 index 0000000..aeccbb6 --- /dev/null +++ b/ElmSharp.Test/TC/AccessibilityRoleTest.cs @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +using System; +using System.Linq; +using ElmSharp; +using ElmSharp.Accessible; + +namespace ElmSharp.Test +{ + class AccessibilityRoleTest : TestCaseBase + { + public override string TestName => "AccessibilityRoleTest"; + public override string TestDescription => "Accessibility Role API test"; + + public override void Run(Window win) + { + Conformant conformant = new Conformant(win); + conformant.Show(); + + Box box = new Box(win); + box.Show(); + + // AcceleratorLabel + Label acceleratorLabel = new Label(win) + { + Text = "AcceleratorLabel" + }; + + Label alertLabel = new Label(win) + { + Text = "Alert"; + }; + + Label Animation = new Label(win) + { + }; + + conformant.SetContent(conformant); + } + } +} + diff --git a/ElmSharp.Test/TC/AccessibilityTest.cs b/ElmSharp.Test/TC/AccessibilityTest.cs new file mode 100644 index 0000000..3072f1b --- /dev/null +++ b/ElmSharp.Test/TC/AccessibilityTest.cs @@ -0,0 +1,286 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +using System; +using System.Linq; +using ElmSharp; +using ElmSharp.Accessible; + +namespace ElmSharp.Test +{ + class AccessibilityTest : TestCaseBase + { + public override string TestName => "AccessibilityTest"; + public override string TestDescription => "Accessibility API test"; + + int sequence = 0; + Naviframe navi; + + Array accessRoleValues; + + public override void Run(Window window) + { + accessRoleValues = Enum.GetValues(typeof(AccessRole)); + + Conformant conformant = new Conformant(window); + conformant.Show(); + + navi = new Naviframe(window) + { + PreserveContentOnPop = true, + DefaultBackButtonEnabled = true + }; + + navi.Push(CreatePage(window, "Main page"), "first page"); + navi.Show(); + conformant.SetContent(navi); + } + + static string StatusStr(ReadingStatus status) + { + if (status == ReadingStatus.Unknown) + { + return "Unknown"; + } + else if (status == ReadingStatus.Cancelled) + { + return "Cancelled"; + } + else if (status == ReadingStatus.Stoppped) + { + return "Stopped"; + } + else if (status == ReadingStatus.Skipped) + { + return "Skipped"; + } + else + { + return "invalid"; + } + } + + Widget CreatePage(Window win, string pageName) + { + Box box = new Box(win); + ((IAccessibleObject)box).Name = pageName; + + box.Show(); + + Button abutton = new Button(win) + { + Text = "Accessibility-normal", + WeightX = 1, + AlignmentX = -1 + }; + ((IAccessibleObject)abutton).TranslationDomain = "kr"; + ((IAccessibleObject)abutton).Name = "Accessibility"; + ((IAccessibleObject)abutton).Description = "Description for Accessibility"; + + Label abutton_label = new Label(win) + { + WeightX = 1, + AlignmentX = -1 + }; + abutton_label.Text = + "domain : " + ((IAccessibleObject)abutton).TranslationDomain + + ", name : " + ((IAccessibleObject)abutton).Name + + ", desc : " + ((IAccessibleObject)abutton).Description; + + Button bbutton = new Button(win) + { + Text = "Accessibility-provider", + WeightX = 1, + AlignmentX = -1 + }; + ((IAccessibleObject)bbutton).NameProvider = (obj) => "Name-provider"; + ((IAccessibleObject)bbutton).DescriptionProvider = (obj) => "Description-provider"; + + Label bbutton_label = new Label(win) + { + WeightX = 1, + AlignmentX = -1 + }; + bbutton_label.Text = + "name : " + ((IAccessibleObject)bbutton).Name + + ", desc : " + ((IAccessibleObject)bbutton).Description; + + Button cbutton = new Button(win) + { + Text = "Readingtype,CanHighlight", + WeightX = 1, + AlignmentX = -1 + }; + ((IAccessibleObject)cbutton).ReadingInfoType = + ReadingInfoType.Name | ReadingInfoType.Role | ReadingInfoType.Description; + ((IAccessibleObject)cbutton).Name = "FooFoo"; + ((IAccessibleObject)cbutton).Role = AccessRole.Text; + ((IAccessibleObject)cbutton).Description = "FooFooButton"; + Label name_onoff_label = new Label(win) + { + Text = "ReadingInfoType.Name : " + + ((((IAccessibleObject)cbutton).ReadingInfoType & ReadingInfoType.Name) != 0 ? "on" : "off"), + WeightX = 1, + AlignmentX = -1 + }; + Label role_onoff_label = new Label(win) + { + Text = "ReadingInfoType.Role : " + + ((((IAccessibleObject)cbutton).ReadingInfoType & ReadingInfoType.Role) != 0 ? "on" : "off"), + WeightX = 1, + AlignmentX = -1 + }; + Label description_onoff_label = new Label(win) + { + Text = "ReadingInfoType.Description : " + + ((((IAccessibleObject)cbutton).ReadingInfoType & ReadingInfoType.Description) != 0 ? "on" : "off"), + WeightX = 1, + AlignmentX = -1 + }; + Label state_onoff_label = new Label(win) + { + Text = "ReadingInfoType.State : " + + ((((IAccessibleObject)cbutton).ReadingInfoType & ReadingInfoType.State) != 0 ? "on" : "off"), + WeightX = 1, + AlignmentX = -1 + }; + + Button saybutton = new Button(win) + { + Text = "HHGG with false", + WeightX = 1, + AlignmentX = -1 + }; + + Button saybutton2 = new Button(win) + { + Text = "HHGG with true", + WeightX = 1, + AlignmentX = -1 + }; + + int labelIndex = 0; + Button roleButton = new Button(win) + { + WeightX = 1, + AlignmentX = -1 + }; + + roleButton.Clicked += (s, e) => + { + if (labelIndex >= accessRoleValues.Length) + { + labelIndex = 0; + } + + IAccessibleObject obj = roleButton as IAccessibleObject; + AccessRole role = (AccessRole) accessRoleValues.GetValue(labelIndex); + obj.Role = role; + roleButton.Text = Enum.GetName(typeof(AccessRole), obj.Role); + + labelIndex++; + }; + + Label label = new Label(win) + { + Text = string.Format("{0} Apple", sequence++), + WeightX = 1, + AlignmentX = -1 + }; + ((IAccessibleObject)label).Name = "Apple"; + + Button push = new Button(win) + { + Text = "Push", + WeightX = 1, + AlignmentX = -1 + }; + ((IAccessibleObject)push).Name = "PushButton"; + + Button pop = new Button(win) + { + Text = "pop", + WeightX = 1, + AlignmentX = -1, + }; + ((IAccessibleObject)pop).Name = "PopButton"; + + abutton.Show(); + abutton_label.Show(); + bbutton.Show(); + bbutton_label.Show(); + cbutton.Show(); + name_onoff_label.Show(); + role_onoff_label.Show(); + description_onoff_label.Show(); + state_onoff_label.Show(); + saybutton.Show(); + saybutton2.Show(); + roleButton.Show(); + label.Show(); + push.Show(); + pop.Show(); + + push.Clicked += (s, e) => + { + NaviItem item = navi.Push(CreatePage(win, string.Format("Apple {0}", sequence -1)), string.Format("Page {0}", sequence -1)); + }; + + Label statusLog = new Label(win) + { + WeightX = 1, + AlignmentX = -1 + }; + statusLog.Show(); + + saybutton.Clicked += (s, e) => + { + AccessibleUtil.Say("The Hitchhiker's Guide to the Galaxy", false) + .ContinueWith(status => { statusLog.Text = StatusStr(status.Result); }); + }; + saybutton2.Clicked += (s, e) => + { + AccessibleUtil.Say("The Hitchhiker's Guide to the Galaxy", true) + .ContinueWith(status => { statusLog.Text = StatusStr(status.Result); }); + }; + + pop.Clicked += (s, e) => + { + var item = navi.NavigationStack.LastOrDefault(); + navi.Pop(); + }; + + box.PackEnd(abutton); + box.PackEnd(abutton_label); + box.PackEnd(bbutton); + box.PackEnd(bbutton_label); + box.PackEnd(cbutton); + box.PackEnd(name_onoff_label); + box.PackEnd(role_onoff_label); + box.PackEnd(description_onoff_label); + box.PackEnd(state_onoff_label); + box.PackEnd(saybutton); + box.PackEnd(saybutton2); + box.PackEnd(roleButton); + box.PackEnd(label); + box.PackEnd(push); + box.PackEnd(pop); + box.PackEnd(statusLog); + + return box; + } + } +} diff --git a/ElmSharp.Test/TC/Log.cs b/ElmSharp.Test/TC/Log.cs new file mode 100644 index 0000000..37313aa --- /dev/null +++ b/ElmSharp.Test/TC/Log.cs @@ -0,0 +1,60 @@ +using System; +using System.IO; +using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; + +namespace ElmSharp.Test +{ + internal static class Log + { + const string Library = "libdlog.so.0"; + const string TAG = "ElmSharp.Test"; + + public static void Debug(string message, + [CallerFilePath] string file = "", + [CallerMemberName] string func = "", + [CallerLineNumber] int line = 0) + { + Print(LogPriority.DLOG_DEBUG, TAG, message, file, func, line); + } + + public static void Info(string message, + [CallerFilePath] string file = "", + [CallerMemberName] string func = "", + [CallerLineNumber] int line = 0) + { + Print(LogPriority.DLOG_DEBUG, TAG, message, file, func, line); + } + + public static void Error(string message, + [CallerFilePath] string file = "", + [CallerMemberName] string func = "", + [CallerLineNumber] int line = 0) + { + Print(LogPriority.DLOG_DEBUG, TAG, message, file, func, line); + } + + internal enum LogPriority + { + DLOG_UNKNOWN = 0, + DLOG_DEFAULT, + DLOG_VERBOSE, + DLOG_DEBUG, + DLOG_INFO, + DLOG_WARN, + DLOG_ERROR, + DLOG_FATAL, + DLOG_SILENT, + DLOG_PRIO_MAX, + } + + private static void Print(LogPriority priority, string tag, string message, string file, string func, int line) + { + FileInfo finfo = new FileInfo(file); + Print(priority, tag, "%s: %s(%d) > %s", finfo.Name, func, line, message); + } + + [DllImportAttribute(Library, EntryPoint = "dlog_print")] + internal static extern int Print(LogPriority prio, string tag, string fmt, string file, string func, int line, string msg); + } +} |