public static void AssemblyInitialize(TestContext testContext, string certFileName) { if (!PlatformConfiguration.IsDevice(DeviceType.OneCore)) { // We need to make the process DPI aware so it properly handles scale factors other than 100%. // DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 only existed RS2 and up, so we'll fall back to // DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE below RS2. if (SetProcessDpiAwarenessContext( PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2) ? DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 : DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE) < 0) { throw new Exception("Failed to set process DPI awareness context! Error = " + Marshal.GetLastWin32Error()); } } #if USING_TAEF Log.Comment("TestContext.TestDeploymentDir = {0}", testContext.TestDeploymentDir); Log.Comment("TestContext.TestDir = {0}", testContext.TestDir); Log.Comment("TestContext.TestLogsDir = {0}", testContext.TestLogsDir); Log.Comment("TestContext.TestResultsDirectory = {0}", testContext.TestResultsDirectory); Log.Comment("TestContext.DeploymentDirectory = {0}", testContext.DeploymentDirectory); // Enable side-loading Log.Comment("Enable side loading apps"); TestAppInstallHelper.EnableSideloadingApps(); // Install the test app certificate if we're deploying the MUXControlsTestApp from the NuGet package. // If this is the MUXControlsTestApp from the OS repo, then it'll have been signed with a test cert // that doesn't need installation. Log.Comment("Installing the certificate for the test app"); TestAppInstallHelper.InstallAppxCert(testContext.TestDeploymentDir, certFileName); #endif }
private UIObject Launch(string deploymentDir) { UIObject coreWindow = null; if (_isPackaged) { // When running from MUXControls repo we want to install the app. // When running in TestMD we also want to install the app. #if USING_TAEF TestAppInstallHelper.InstallTestAppIfNeeded(deploymentDir, _packageName, _packageFamilyName, _appInstallerName); #else InstallTestAppIfNeeded(); #endif } Log.Comment("Launching app {0}", _appName); coreWindow = LaunchApp(); Verify.IsNotNull(coreWindow, "coreWindow"); Log.Comment("Waiting for the close-app invoker to be found to signal that the app has launched successfully..."); for (int retries = 0; retries < 5; ++retries) { UIObject obj; coreWindow.Descendants.TryFind(UICondition.Create("@AutomationId='__CloseAppInvoker'"), out obj); if (obj != null) { Log.Comment("Invoker found!"); break; } Log.Comment("Invoker not found. Sleeping for 500 ms before trying again..."); Thread.Sleep(500); } var unhandledExceptionReportingTextBox = new Edit(coreWindow.Descendants.Find(UICondition.Create("@AutomationId='__UnhandledExceptionReportingTextBox'"))); var valueChangedSource = new PropertyChangedEventSource(unhandledExceptionReportingTextBox, Scope.Element, UIProperty.Get("Value.Value")); valueChangedSource.Start(new TestAppCrashDetector()); Log.Comment("15056441 tracing, device family:" + Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily); return(coreWindow); }
private UIObject Launch(string deploymentDir) { UIObject coreWindow = null; // When running from MUXControls repo we want to install the app. // When running in TestMD we also want to install the app. // In CatGates, we install the test app as part of the deploy script, so we don't need to do anything here. #if BUILD_WINDOWS if (TestEnvironment.TestContext.Properties.Contains("RunFromTestMD")) { TestAppInstallHelper.InstallTestAppIfNeeded(deploymentDir, _packageName, _packageFullName); } #elif USING_TAEF TestAppInstallHelper.InstallTestAppIfNeeded(deploymentDir, _packageName, _packageFullName); #else BuildAndInstallTestAppIfNeeded(); #endif Log.Comment("Launching app {0}", _appName); coreWindow = LaunchApp(_packageName); Verify.IsNotNull(coreWindow, "coreWindow"); Log.Comment("Waiting for the close-app invoker to be found to signal that the app has launched successfully..."); for (int retries = 0; retries < 5; ++retries) { UIObject obj; coreWindow.Descendants.TryFind(UICondition.Create("@AutomationId='__CloseAppInvoker'"), out obj); if (obj != null) { Log.Comment("Invoker found!"); break; } Log.Comment("Invoker not found. Sleeping for 500 ms before trying again..."); Thread.Sleep(500); } var unhandledExceptionReportingTextBox = new Edit(coreWindow.Descendants.Find(UICondition.Create("@AutomationId='__UnhandledExceptionReportingTextBox'"))); var valueChangedSource = new PropertyChangedEventSource(unhandledExceptionReportingTextBox, Scope.Element, UIProperty.Get("Value.Value")); valueChangedSource.Start(new TestAppCrashDetector()); Log.Comment("15056441 tracing, device family:" + Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily); // On phone, we work around different scale factors between devices by configuring the test app to // lay out the test pages at the device's resolution, effectively giving us a scale factor of 1.0. if (PlatformConfiguration.IsDevice(DeviceType.Phone)) { Log.Comment("Enabling view scaling workaround on phone."); try { var viewScalingCheckBox = new CheckBox(coreWindow.Descendants.Find(UICondition.Create("@AutomationId='__ViewScalingCheckBox'"))); using (var waiter = viewScalingCheckBox.GetToggledWaiter()) { viewScalingCheckBox.Check(); } Log.Comment("15056441 Tracing: New checkbox state is " + viewScalingCheckBox.ToggleState); } catch (UIObjectNotFoundException) { Log.Error("Could not find the view scaling CheckBox."); TestEnvironment.LogDumpTree(UIObject.Root); throw; } } return(coreWindow); }