diff --git a/UITests/UITests.App/App.xaml b/UITests/UITests.App/App.xaml
index 74e9cd2df91..1b9cedbffb7 100644
--- a/UITests/UITests.App/App.xaml
+++ b/UITests/UITests.App/App.xaml
@@ -1,7 +1,4 @@
-
-
-
+
diff --git a/UITests/UITests.App/App.xaml.cs b/UITests/UITests.App/App.xaml.cs
index 23f5035b6d5..8a2c5f4ddda 100644
--- a/UITests/UITests.App/App.xaml.cs
+++ b/UITests/UITests.App/App.xaml.cs
@@ -3,6 +3,9 @@
// See the LICENSE file in the project root for more information.
using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.UI.Xaml;
@@ -13,6 +16,8 @@ namespace UITests.App
{
public sealed partial class App
{
+ internal Dictionary TestPages { get; } = new Dictionary();
+
public App()
{
this.InitializeComponent();
@@ -26,6 +31,21 @@ public App()
/// Details about the launch request and process.
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
+ var pages = Assembly.GetExecutingAssembly().GetTypes()
+ .Where(t => t.IsSubclassOf(typeof(Page)));
+
+ foreach (var page in pages)
+ {
+ try
+ {
+ TestPages.Add(page.Name, page);
+ }
+ catch (ArgumentException ex)
+ {
+ throw new Exception("Two or more test pages share a name.", ex);
+ }
+ }
+
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
@@ -53,7 +73,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
- rootFrame.Navigate(typeof(MainPage), e.Arguments);
+ rootFrame.Navigate(typeof(MainTestHost), e.Arguments);
}
// Ensure the current window is active
diff --git a/UITests/UITests.App/MainPage.xaml.cs b/UITests/UITests.App/MainPage.xaml.cs
deleted file mode 100644
index b44c1291f46..00000000000
--- a/UITests/UITests.App/MainPage.xaml.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-namespace UITests.App
-{
- public sealed partial class MainPage
- {
- public MainPage()
- {
- InitializeComponent();
- }
-
- private void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
- {
- textBlock.Text = "Clicked";
- }
- }
-}
diff --git a/UITests/UITests.App/MainPage.xaml b/UITests/UITests.App/MainTestHost.xaml
similarity index 59%
rename from UITests/UITests.App/MainPage.xaml
rename to UITests/UITests.App/MainTestHost.xaml
index d38db07e3e3..d48168bfd81 100644
--- a/UITests/UITests.App/MainPage.xaml
+++ b/UITests/UITests.App/MainTestHost.xaml
@@ -1,5 +1,5 @@
+
+
+
+
-
-
-
+
+
+
+
diff --git a/UITests/UITests.App/MainTestHost.xaml.cs b/UITests/UITests.App/MainTestHost.xaml.cs
new file mode 100644
index 00000000000..230a54d5931
--- /dev/null
+++ b/UITests/UITests.App/MainTestHost.xaml.cs
@@ -0,0 +1,46 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Collections.Generic;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Input;
+
+namespace UITests.App
+{
+ ///
+ /// MainPage hosting all other test pages.
+ ///
+ public sealed partial class MainTestHost
+ {
+ private readonly Dictionary pageMap;
+
+ public MainTestHost()
+ {
+ InitializeComponent();
+ pageMap = ((App)Application.Current).TestPages;
+ }
+
+ private void PageName_KeyDown(object sender, KeyRoutedEventArgs e)
+ {
+ if (e.Key == Windows.System.VirtualKey.Enter && sender is TextBox s)
+ {
+ OpenPage(s.Text);
+ }
+ }
+
+ private void OpenPage(string pageName)
+ {
+ try
+ {
+ navigationFrame.Navigate(pageMap[pageName]);
+ }
+ catch (KeyNotFoundException ex)
+ {
+ throw new Exception("Cannot find page.", ex);
+ }
+ }
+ }
+}
diff --git a/UITests/UITests.App/UITests.App.csproj b/UITests/UITests.App/UITests.App.csproj
index 48fc8de5936..2b00af8784c 100644
--- a/UITests/UITests.App/UITests.App.csproj
+++ b/UITests/UITests.App/UITests.App.csproj
@@ -27,6 +27,7 @@
SHA256trueTrue
+ true
@@ -130,8 +131,8 @@
App.xaml
-
- MainPage.xaml
+
+ MainTestHost.xaml
@@ -155,7 +156,7 @@
MSBuild:CompileDesigner
-
+ MSBuild:CompileDesigner
@@ -252,4 +253,5 @@
-->
-
+
+
\ No newline at end of file
diff --git a/UITests/UITests.Tests.MSTest/MSTestInterop.cs b/UITests/UITests.Tests.MSTest/MSTestInterop.cs
index dc1740ba15e..bf26a116446 100644
--- a/UITests/UITests.Tests.MSTest/MSTestInterop.cs
+++ b/UITests/UITests.Tests.MSTest/MSTestInterop.cs
@@ -11,6 +11,7 @@ namespace UITests.Tests
// TAEF has a different terms for the same concepts as compared with MSTest.
// In order to allow both to use the same test files, we'll define these helper classes
// to translate TAEF into MSTest.
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1649:File name should match first type name", Justification = "Shim helpers")]
public static class Log
{
public static void Comment(string format, params object[] args)
@@ -41,6 +42,7 @@ private static void LogMessage(string format, object[] args)
}
}
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Shim helpers.")]
public static class LogController
{
public static void InitializeLogging()
@@ -49,6 +51,7 @@ public static void InitializeLogging()
}
}
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Shim helpers.")]
public static class Verify
{
// TODO: implement
diff --git a/UITests/UITests.Tests.MSTest/UITests.Tests.MSTest.csproj b/UITests/UITests.Tests.MSTest/UITests.Tests.MSTest.csproj
index 67a02acf40f..e451ea73ecd 100644
--- a/UITests/UITests.Tests.MSTest/UITests.Tests.MSTest.csproj
+++ b/UITests/UITests.Tests.MSTest/UITests.Tests.MSTest.csproj
@@ -13,6 +13,8 @@
x86Exefalse
+
+ true
@@ -27,5 +29,5 @@
-
+
\ No newline at end of file
diff --git a/UITests/UITests.Tests.Shared/Controls/TextBoxMaskTest.cs b/UITests/UITests.Tests.Shared/Controls/TextBoxMaskTest.cs
new file mode 100644
index 00000000000..afb4c5d749a
--- /dev/null
+++ b/UITests/UITests.Tests.Shared/Controls/TextBoxMaskTest.cs
@@ -0,0 +1,56 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using Microsoft.Windows.Apps.Test.Foundation.Controls;
+using Windows.UI.Xaml.Tests.MUXControls.InteractionTests.Common;
+using Windows.UI.Xaml.Tests.MUXControls.InteractionTests.Infra;
+
+#if USING_TAEF
+using WEX.Logging.Interop;
+using WEX.TestExecution;
+using WEX.TestExecution.Markup;
+#else
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+#endif
+
+namespace UITests.Tests
+{
+ [TestClass]
+ public class TextBoxMaskTest : UITestBase
+ {
+ [ClassInitialize]
+ [TestProperty("RunAs", "User")]
+ [TestProperty("Classification", "ScenarioTestSuite")]
+ [TestProperty("Platform", "Any")]
+ public static void ClassInitialize(TestContext testContext)
+ {
+ TestEnvironment.Initialize(testContext, WinUICsUWPSampleApp);
+ }
+
+ [ClassCleanup]
+ public static void ClassCleanup()
+ {
+ TestEnvironment.AssemblyCleanupWorker(WinUICsUWPSampleApp);
+ }
+
+ [TestMethod]
+ [TestPage("TextBoxMaskTestPage")]
+ public void TestTextBoxMaskBinding_Property()
+ {
+ var initialValue = FindElement.ById("InitialValueTextBlock").GetText();
+ var textBox = FindElement.ById("TextBox");
+
+ Verify.AreEqual(initialValue, textBox.GetText());
+
+ var changeButton = FindElement.ById