Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File scoped namespaces #1700

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Switch to file-scoped namespaces
5f4ff16b4bad507c09bd180091ebbb2df3872279
61 changes: 30 additions & 31 deletions UITests/AxeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,43 +20,42 @@
using System.Diagnostics;
using System.Linq;

namespace UITests
namespace UITests;

public class AxeHelper
{
public class AxeHelper
public static IScanner AccessibilityScanner;

internal static void InitializeAxe()
{
public static IScanner AccessibilityScanner;
var processes = Process.GetProcessesByName("WinUIGallery");
Assert.IsTrue(processes.Length > 0);

internal static void InitializeAxe()
{
var processes = Process.GetProcessesByName("WinUIGallery");
Assert.IsTrue(processes.Length > 0);
var config = Config.Builder.ForProcessId(processes[0].Id).Build();

var config = Config.Builder.ForProcessId(processes[0].Id).Build();
AccessibilityScanner = ScannerFactory.CreateScanner(config);
}

AccessibilityScanner = ScannerFactory.CreateScanner(config);
}
public static void AssertNoAccessibilityErrors()
{
// Bug 1474: Disabling Rules NameReasonableLength and BoundingRectangleNotNull temporarily
var testResult = AccessibilityScanner.Scan(null).WindowScanOutputs.SelectMany(output => output.Errors)
.Where(rule => rule.Rule.ID != RuleId.NameIsInformative)
.Where(rule => rule.Rule.ID != RuleId.NameExcludesControlType)
.Where(rule => rule.Rule.ID != RuleId.NameExcludesLocalizedControlType)
.Where(rule => rule.Rule.ID != RuleId.SiblingUniqueAndFocusable)
.Where(rule => rule.Rule.ID != RuleId.NameReasonableLength)
.Where(rule => rule.Rule.ID != RuleId.BoundingRectangleNotNull)
.Where(rule => rule.Rule.ID != RuleId.BoundingRectangleNotNullListViewXAML)
.Where(rule => rule.Rule.ID != RuleId.BoundingRectangleNotNullTextBlockXAML)
.Where(rule => rule.Rule.ID != RuleId.NameNotNull)
.Where(rule => rule.Rule.ID != RuleId.ChromiumComponentsShouldUseWebScanner);

public static void AssertNoAccessibilityErrors()
if (testResult.Any())
{
// Bug 1474: Disabling Rules NameReasonableLength and BoundingRectangleNotNull temporarily
var testResult = AccessibilityScanner.Scan(null).WindowScanOutputs.SelectMany(output => output.Errors)
.Where(rule => rule.Rule.ID != RuleId.NameIsInformative)
.Where(rule => rule.Rule.ID != RuleId.NameExcludesControlType)
.Where(rule => rule.Rule.ID != RuleId.NameExcludesLocalizedControlType)
.Where(rule => rule.Rule.ID != RuleId.SiblingUniqueAndFocusable)
.Where(rule => rule.Rule.ID != RuleId.NameReasonableLength)
.Where(rule => rule.Rule.ID != RuleId.BoundingRectangleNotNull)
.Where(rule => rule.Rule.ID != RuleId.BoundingRectangleNotNullListViewXAML)
.Where(rule => rule.Rule.ID != RuleId.BoundingRectangleNotNullTextBlockXAML)
.Where(rule => rule.Rule.ID != RuleId.NameNotNull)
.Where(rule => rule.Rule.ID != RuleId.ChromiumComponentsShouldUseWebScanner);

if (testResult.Any())
{
var mappedResult = testResult.Select(result =>
"Element " + result.Element.Properties["ControlType"] + " violated rule '" + result.Rule.Description + "'.");
Assert.Fail("Failed with the following accessibility errors \r\n" + string.Join("\r\n", mappedResult));
}
var mappedResult = testResult.Select(result =>
"Element " + result.Element.Properties["ControlType"] + " violated rule '" + result.Rule.Description + "'.");
Assert.Fail("Failed with the following accessibility errors \r\n" + string.Join("\r\n", mappedResult));
}
}
}
}
30 changes: 14 additions & 16 deletions UITests/SampleTestTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,22 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Appium.Windows;

namespace UITests
namespace UITests;

[TestClass]
public class SampleTestTemplate : TestBase
{
[TestClass]
public class SampleTestTemplate : TestBase
{

private static WindowsElement element1 = null;
private static WindowsElement element2 = null;
private static WindowsElement element1 = null;
private static WindowsElement element2 = null;

public static void ClassInitialize(TestContext context)
{
OpenControlPage("MyControlPage");
Thread.Sleep(1000);
element1 = Session.FindElementByAccessibilityId("Element Locator");
Assert.IsNotNull(element1);
element2 = Session.FindElementByAccessibilityId("Element Locator");
Assert.IsNotNull(element2);
}
public static void ClassInitialize(TestContext context)
{
OpenControlPage("MyControlPage");
Thread.Sleep(1000);
element1 = Session.FindElementByAccessibilityId("Element Locator");
Assert.IsNotNull(element1);
element2 = Session.FindElementByAccessibilityId("Element Locator");
Assert.IsNotNull(element2);
}
}

Loading