Skip to content

Commit

Permalink
Fix two bugs in BoundingRectangleNotNull rule (#144)
Browse files Browse the repository at this point in the history
- [BUG] BoundingRectangleNotNull rule should exclude non-focusable buttons that are children of sliders · Issue #139
- [BUG] False positive for BoundingRectangleNotNull for group elements in Edge · Issue #142
  • Loading branch information
RobGallo authored Sep 3, 2019
1 parent 186e9ad commit f2adece
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/Rules/Library/BoundingRectangleNotNull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ protected override Condition CreateCondition()
var sysmenubar = ControlType.MenuBar & StringProperties.AutomationID.Is("SystemMenuBar") & StringProperties.Name.Is("System");
var sysmenuitem = ControlType.MenuItem & Relationships.Parent(sysmenubar) & StringProperties.Name.Is("System");

// This exception is meant to apply to the non-Chromium version of Edge
var edgeGroups = ControlType.Group & StringProperties.Framework.Is(Framework.Edge);

// the Bounding rectangle property might be empty due to
// a non-existent property, or an invalid data format.
// If the Bounding rectangle property is not empty, it means all the above criteria were met successfully
Expand All @@ -41,6 +44,8 @@ protected override Condition CreateCondition()
// legitimately be null or all zeros when the thumb control is at the maximum or minimum value.
return IsNotOffScreen
& ~WPFScrollBarPageButtons
& ~NonFocusableSliderButtons
& ~edgeGroups
& ~sysmenubar
& ~sysmenuitem;
}
Expand Down
8 changes: 8 additions & 0 deletions src/Rules/PropertyConditions/ElementGroups.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ static class ElementGroups
public static Condition ExpectedToBeFocusable = CreateExpectedToBeFocusableCondition();
public static Condition ParentWPFDataItem = CreateParentWPFDataItemCondition();
public static Condition WPFScrollBarPageButtons = CreateWPFScrollBarPageButtons();
public static Condition NonFocusableSliderButtons = CreateNonFocusableSliderButtonsCondition();
public static Condition NameRequired = CreateNameRequiredCondition();
public static Condition NameOptional = CreateNameOptionalCondition();
public static Condition IsControlElementTrueRequired = CreateIsControlRequiredCondition();
Expand Down Expand Up @@ -156,6 +157,13 @@ private static Condition CreateWPFScrollBarPageButtons()
| AutomationID.Is("PageRight"));
}

private static Condition CreateNonFocusableSliderButtonsCondition()
{
return Button
& Parent(Slider)
& IsNotKeyboardFocusable;
}

private static bool IsParentWPFDataItem(IA11yElement e)
{
return e.GetUIFramework() == Core.Enums.Framework.WPF
Expand Down
25 changes: 20 additions & 5 deletions src/RulesTest/Library/BoundingRectangleNotNullTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Axe.Windows.Core.Enums;
using System.Drawing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using EvaluationCode = Axe.Windows.Rules.EvaluationCode;
Expand Down Expand Up @@ -85,16 +86,30 @@ public void BoundingRectangleNotNull_WPFScrollbarPageLeftButton_NotApplicable()
}

[TestMethod]
public void BoundingRectangleNotNull_WPFScrollbarPageRightButton_NotApplicable()
public void BoundingRectangleNotNull_NonFocusableSliderButton_NotApplicable()
{
using (var e = new MockA11yElement())
using (var parent = new MockA11yElement())
{
parent.ControlTypeId = ControlType.ScrollBar;
e.IsOffScreen = false;
parent.ControlTypeId = ControlType.Slider;
e.IsKeyboardFocusable = false;
e.ControlTypeId = ControlType.Button;
e.Framework = "WPF";
e.AutomationId = "PageRight";
parent.Children.Add(e);
e.Parent = parent;

Assert.IsFalse(Rule.Condition.Matches(e));
} // using
}

[TestMethod]
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;

Expand Down

0 comments on commit f2adece

Please sign in to comment.