public void TestAllDescendantsFalse() { using (var e = new MockA11yElement()) using (var child = new MockA11yElement()) using (var grandchild = new MockA11yElement()) { e.Children.Add(child); child.Children.Add(grandchild); child.ControlTypeId = ComboBox; var condition = AllDescendants(Axe.Windows.Rules.PropertyConditions.ControlType.ComboBox); Assert.IsFalse(condition.Matches(e)); }// using }
public void BoundingRectangleNotNull_EdgeGroup_NotApplicable() { using (var e = new MockA11yElement()) using (var parent = new MockA11yElement()) { parent.ControlTypeId = ControlType.Slider; e.Framework = Framework.Edge; e.ControlTypeId = ControlType.Group; parent.Children.Add(e); e.Parent = parent; Assert.IsFalse(Rule.Condition.Matches(e)); }// using }
public void TestChildCountLessThanOrEqualToTrue() { using (var e = new MockA11yElement()) { for (var i = 0; i < 5; ++i) { var child = new MockA11yElement(); e.Children.Add(child); } var condition = ChildCount() <= 5; Assert.IsTrue(condition.Matches(e)); } // using }
public void TestChildCountGreaterThanOrEqualToFalse() { using (var e = new MockA11yElement()) { for (var i = 0; i < 5; ++i) { var child = new MockA11yElement(); e.Children.Add(child); } var condition = ChildCount() >= 6; Assert.IsFalse(condition.Matches(e)); } // using }
public void TestTreeItemWithChildTreeItemWithExpandCollapsePattern() { var e = new MockA11yElement(); var ec = new MockA11yElement(); e.ControlTypeId = Axe.Windows.Core.Types.ControlType.UIA_TreeItemControlTypeId; ec.ControlTypeId = Axe.Windows.Core.Types.ControlType.UIA_TreeItemControlTypeId; e.Children.Add(ec); e.Patterns.Add(new Core.Bases.A11yPattern(e, PatternType.UIA_ExpandCollapsePatternId)); Assert.IsTrue(this.Rule.Condition.Matches(e)); Assert.IsTrue(Rule.PassesTest(e)); }
public void TestNoAncestorFalse() { using (var e = new MockA11yElement()) using (var parent = new MockA11yElement()) using (var grandparent = new MockA11yElement()) { e.Parent = parent; parent.Parent = grandparent; grandparent.ControlTypeId = ControlType.Tree; var condition = NoAncestor(Axe.Windows.Rules.PropertyConditions.ControlType.Tree); Assert.IsFalse(condition.Matches(e)); }// using }
public void ConditionMatch_NoLocalizedControlType_False() { var parent = new MockA11yElement(); var child = new MockA11yElement(); child.BoundingRectangle = new Rectangle(0, 0, 25, 25); child.IsContentElement = true; child.ControlTypeId = ControlType.ListItem; child.Name = "Alice"; child.Parent = parent; parent.Children.Add(child); Assert.IsFalse(Rule.Condition.Matches(child)); }
public void NameExcludesControlType_NotApplicableType() { var e = new MockA11yElement(); int[] types = { AppBar, Header, MenuBar, SemanticZoom, StatusBar, TitleBar }; foreach (var t in types) { e.ControlTypeId = t; e.Name = Rules.Misc.ControlTypeStrings.Dictionary[t]; Assert.IsFalse(Rule.Condition.Matches(e)); } // for each type }
public void BoundingRectangleNotNull_SystemMenu_NotApplicable() { using (var e = new MockA11yElement()) using (var parent = new MockA11yElement()) { parent.ControlTypeId = ControlType.MenuBar; parent.AutomationId = "SystemMenuBar"; e.ControlTypeId = ControlType.MenuItem; parent.Children.Add(e); e.Parent = parent; Assert.IsFalse(Rule.Condition.Matches(e)); }// using }
public void BoundingRectangleNotNull_NonFocusableSliderButton_NotApplicable() { using (var e = new MockA11yElement()) using (var parent = new MockA11yElement()) { parent.ControlTypeId = ControlType.Slider; e.IsKeyboardFocusable = false; e.ControlTypeId = ControlType.Button; parent.Children.Add(e); e.Parent = parent; Assert.IsFalse(Rule.Condition.Matches(e)); }// using }
public void TestNameIsReasonableLengthFalse() { using (var e = new MockA11yElement()) { StringBuilder s = new StringBuilder("*"); for (var i = 0; i < 10; ++i) { s.Append(s.ToString() + s.ToString()); } e.Name = s.ToString(); Assert.AreNotEqual(Rule.Evaluate(e), EvaluationCode.Pass); } // using }
public void ConditionMismatch_ExcludingUIExpandoButtonDirectUIControl_ReturnFalse() { var e = new MockA11yElement(); e.ControlTypeId = Axe.Windows.Core.Types.ControlType.UIA_ButtonControlTypeId; e.Framework = "DirectUI"; e.ClassName = "UIExpandoButton"; e.IsEnabled = true; e.IsOffScreen = false; e.IsContentElement = true; e.BoundingRectangle = new System.Drawing.Rectangle(0, 0, 100, 100); Assert.IsFalse(Rule.Condition.Matches(e)); }
public void ParentChildHaveDifferentNameSameLocalizedControlType_RuleError() { var e = new MockA11yElement(); e.Name = "name"; e.LocalizedControlType = "controltype"; var p = new MockA11yElement(); p.Name = "name1"; p.LocalizedControlType = "controltype"; e.Parent = p; Assert.IsTrue(Rule.PassesTest(e)); }
public void TestMinMaxCloseButtons() { using (var e = new MockA11yElement()) { string[] automationIDs = { "Minimize", "Maximize", "Close" }; e.ControlTypeId = Button; foreach (var automationID in automationIDs) { e.AutomationId = automationID; Assert.IsFalse(Misc.NameRequired.Matches(e)); } } // using }
public void TestExcludedClassNames_ClassNamesMatch() { string[] excludedClassNames = { "Popup", "ContextMenu" }; using (var e = new MockA11yElement()) { e.Framework = FrameworkId.WPF; e.ControlTypeId = Window; foreach (var className in excludedClassNames) { e.ClassName = className; Assert.IsFalse(Misc.NameRequired.Matches(e), className + " should be excluded"); } } // using }
public void TestExcludedClassNames_ClassNamesDoNotMatch() { string[] nonExcludedClassNames = { null, "NotPopup", "ContextMenuIsNotMyName" }; using (var e = new MockA11yElement()) { e.Framework = FrameworkId.WPF; e.ControlTypeId = Window; foreach (var className in nonExcludedClassNames) { e.ClassName = className; Assert.IsTrue(Misc.NameRequired.Matches(e), className + " should not be excluded"); } } // using }
public void NameExcludesLocalizedControlType_NotApplicableType() { var e = new MockA11yElement(); e.Name = "same"; e.LocalizedControlType = "same"; int[] types = { AppBar, Header, MenuBar, SemanticZoom, StatusBar, TitleBar }; foreach (var t in types) { e.ControlTypeId = t; Assert.IsFalse(Rule.Condition.Matches(e)); } // for each type }
public void TestChildCountConditionFalse() { using (var e = new MockA11yElement()) { for (var i = 0; i < 5; ++i) { var child = new MockA11yElement(); child.ControlTypeId = ComboBox; e.Children.Add(child); } var condition = ChildCount(Axe.Windows.Rules.PropertyConditions.ControlType.RadioButton) == 5; Assert.IsFalse(condition.Matches(e)); } // using }
public void TestAllChildrenTrue() { using (var e = new MockA11yElement()) { for (var i = 0; i < 5; ++i) { var child = new MockA11yElement(); child.ControlTypeId = ComboBox; e.Children.Add(child); } var condition = AllChildren(Axe.Windows.Rules.PropertyConditions.ControlType.ComboBox); Assert.IsTrue(condition.Matches(e)); } // using }
public void SiblingCount_NoMatch_IncorrectNumber() { var child1 = new MockA11yElement(); var child2 = new MockA11yElement(); var parent = new MockA11yElement(); parent.Children.Add(child1); parent.Children.Add(child2); child1.Parent = parent; child2.Parent = parent; var condition = Relationships.SiblingCount(Condition.True) == 3; Assert.IsFalse(condition.Matches(child1)); }
public void SiblingCount_Matches() { var child1 = new MockA11yElement(); var child2 = new MockA11yElement(); var parent = new MockA11yElement(); parent.Children.Add(child1); parent.Children.Add(child2); child1.Parent = parent; child2.Parent = parent; var condition = Relationships.SiblingCount(Condition.True) == 2; Assert.IsTrue(condition.Matches(child1)); }
public void TestChildOfSameTypeFalse() { using (var e = new MockA11yElement()) { e.ControlTypeId = ComboBox; for (var i = 0; i < 5; ++i) { e.Children.Add(new MockA11yElement()); } var condition = AnyChild(HasSameType); Assert.IsFalse(condition.Matches(e)); } // using }
public void TestChildCountNumberFalse() { using (var e = new MockA11yElement()) { for (var i = 0; i < 5; ++i) { var child = new MockA11yElement(); child.ControlTypeId = ComboBox; e.Children.Add(child); } var condition = ChildCount(AccessibilityInsights.Rules.PropertyConditions.ControlType.ComboBox) == 4; Assert.IsFalse(condition.Matches(e)); } // using }
public void TestNoChildTrue() { using (var e = new MockA11yElement()) { for (var i = 0; i < 5; ++i) { var child = new MockA11yElement(); child.ControlTypeId = ComboBox; e.Children.Add(child); } var condition = NoChild(AccessibilityInsights.Rules.PropertyConditions.ControlType.Button); Assert.IsTrue(condition.Matches(e)); } // using }
public void BoundingRectangleCompletelyObscuresContainer_Window_NotApplicable() { var e = new MockA11yElement(); var parent = new MockA11yElement(); e.BoundingRectangle = TestRect; parent.BoundingRectangle = TestRect; e.Parent = parent; Assert.IsTrue(Rule.Condition.Matches(e)); e.ControlTypeId = ControlType.Window; Assert.IsFalse(Rule.Condition.Matches(e)); }
public void WPFScrollBarPageButtons_NotPageUpOrPageDown_False() { using (var e = new MockA11yElement()) using (var parent = new MockA11yElement()) { parent.ControlTypeId = ControlType.ScrollBar; e.ControlTypeId = ControlType.Button; e.Framework = "WPF"; // e.AutomationId = "PageUp"; parent.Children.Add(e); e.Parent = parent; Assert.IsFalse(ElementGroups.WPFScrollBarPageButtons.Matches(e)); }// using }
public void BoundingRectangleCompletelyObscuresContainer_LeftFail() { var e = new MockA11yElement(); var parent = new MockA11yElement(); e.BoundingRectangle = new Rectangle(ValidRect.Left - 1, ValidRect.Top, ValidRect.Size.Width + 1, ValidRect.Size.Height); parent.BoundingRectangle = TestRect; e.Parent = parent; Assert.IsTrue(Rule.Condition.Matches(e)); Assert.AreEqual(EvaluationCode.Error, Rule.Evaluate(e)); }
public void ConditionMismatch_TreeControlWithTreeItem_ReturnFalse() { var e = new MockA11yElement(); var ec = new MockA11yElement(); e.ControlTypeId = Core.Types.ControlType.UIA_TreeControlTypeId; e.IsEnabled = true; e.IsOffScreen = false; e.IsKeyboardFocusable = false; e.BoundingRectangle = new System.Drawing.Rectangle(0, 0, 100, 100); ec.ControlTypeId = Core.Types.ControlType.UIA_TreeItemControlTypeId; e.Children.Add(ec); Assert.IsFalse(Rule.Condition.Matches(e)); }
public void BoundingRectangleCompletelyObscuresContainer_BottomPass() { var e = new MockA11yElement(); var parent = new MockA11yElement(); e.BoundingRectangle = new Rectangle(ErrorRect.Left, ErrorRect.Top, ErrorRect.Size.Width, ErrorRect.Size.Height - 2); parent.BoundingRectangle = TestRect; e.Parent = parent; Assert.IsTrue(Rule.Condition.Matches(e)); Assert.AreEqual(EvaluationCode.Pass, Rule.Evaluate(e)); }
public void ConditionMatch_ChildSplitButtonOfGroupControlWithoutSplitButtonSibling_ReturnTrue() { var e = new MockA11yElement(); var ep = new MockA11yElement(); e.ControlTypeId = Axe.Windows.Core.Types.ControlType.UIA_SplitButtonControlTypeId; ep.ControlTypeId = Axe.Windows.Core.Types.ControlType.UIA_GroupControlTypeId; e.Parent = ep; e.IsEnabled = true; e.IsOffScreen = false; e.IsContentElement = true; e.BoundingRectangle = new System.Drawing.Rectangle(0, 0, 100, 100); Assert.IsTrue(Rule.Condition.Matches(e)); }