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); }