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 @@  + + + + - -