-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
149 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/Rules/Library/ChromiumComponentsShouldUseWebScanner.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// 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.Bases; | ||
using Axe.Windows.Core.Enums; | ||
using Axe.Windows.Rules.Resources; | ||
using static Axe.Windows.Rules.PropertyConditions.Framework; | ||
|
||
namespace Axe.Windows.Rules.Library | ||
{ | ||
[RuleInfo(ID = RuleId.ChromiumComponentsShouldUseWebScanner)] | ||
class ChromiumComponentsShouldUseWebScanner : Rule | ||
{ | ||
public ChromiumComponentsShouldUseWebScanner() | ||
{ | ||
Info.Description = Descriptions.ChromiumComponentsShouldUseWebScanner; | ||
Info.HowToFix = HowToFix.ChromiumComponentsShouldUseWebScanner; | ||
Info.ErrorCode = EvaluationCode.Error; | ||
} | ||
|
||
public override bool PassesTest(IA11yElement e) | ||
{ | ||
return false; | ||
} | ||
|
||
protected override Condition CreateCondition() | ||
{ | ||
return Chrome; | ||
} | ||
} // class | ||
} // namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/RulesTest/Library/ChromiumComponentsShouldUseWebScannerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// 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.Bases; | ||
using Axe.Windows.Core.Enums; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Moq; | ||
|
||
namespace Axe.Windows.RulesTests.Library | ||
{ | ||
[TestClass] | ||
public class ChromiumComponentsShouldUseWebScannerTests | ||
{ | ||
private static readonly Rules.IRule Rule = new Rules.Library.ChromiumComponentsShouldUseWebScanner(); | ||
private Mock<IA11yElement> _elementMock; | ||
|
||
[TestInitialize] | ||
public void BeforeEach() | ||
{ | ||
_elementMock = new Mock<IA11yElement>(MockBehavior.Strict); | ||
} | ||
|
||
[TestMethod] | ||
public void Condition_FrameworkIsNotChrome_ReturnsFalse() | ||
{ | ||
string[] nonChromeValues = { FrameworkId.DirectUI, FrameworkId.InternetExplorer, FrameworkId.WinForm, FrameworkId.WPF, FrameworkId.XAML, FrameworkId.Win32, FrameworkId.Edge, "NotChrome" }; | ||
|
||
foreach (string nonChromeValue in nonChromeValues) | ||
{ | ||
_elementMock.Setup(m => m.Framework) | ||
.Returns(nonChromeValue) | ||
.Verifiable(); | ||
|
||
Assert.IsFalse(Rule.Condition.Matches(_elementMock.Object)); | ||
} | ||
|
||
_elementMock.Verify(m => m.Framework, Times.Exactly(nonChromeValues.Length)); | ||
} | ||
|
||
[TestMethod] | ||
public void Condition_FrameworkIsChrome_ReturnsTrue() | ||
{ | ||
_elementMock.Setup(m => m.Framework).Returns(FrameworkId.Chrome).Verifiable(); | ||
|
||
Assert.IsTrue(Rule.Condition.Matches(_elementMock.Object)); | ||
|
||
_elementMock.Verify(m => m.Framework, Times.Once()); | ||
} | ||
|
||
[TestMethod] | ||
public void PassesTest_ReturnsFalse() | ||
{ | ||
Assert.IsFalse(Rule.PassesTest(_elementMock.Object)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters