public override void TickTest() { base.TickTest(); if (GetTestStatus() == TestStatus.Complete || ResultsGathered) { if (!ResultsGathered) { ResultsGathered = true; try { // Gather results and merge PGO data Log.Info("Gathering profiling results to {0}", TestInstance.ClientApps[0].ArtifactPath); PGOPlatform.GatherResults(TestInstance.ClientApps[0].ArtifactPath); } catch (Exception Ex) { ProcessPGODataFailed = true; Log.Error("Error getting PGO results: {0}", Ex); } } return; } // Handle device screenshot update TimeSpan Delta = DateTime.Now - ScreenshotTime; ITargetDevice Device = TestInstance.ClientApps[0].Device; string ImageFilename; if (!String.IsNullOrEmpty(ScreenshotDirectory) && Delta >= ScreenshotInterval && Device != null && PGOPlatform.TakeScreenshot(Device, ScreenshotDirectory, out ImageFilename)) { ScreenshotTime = DateTime.Now; try { TimeSpan ImageTimestamp = DateTime.UtcNow - ScreenshotStartTime; string ImageOutputPath = Path.Combine(ScreenshotDirectory, ImageTimestamp.ToString().Replace(':', '-') + ".jpg"); ImageUtils.ResaveImageAsJpgWithScaleAndQuality(Path.Combine(ScreenshotDirectory, ImageFilename), ImageOutputPath, ScreenshotScale, ScreenshotQuality); } catch { // Just ignore errors. } finally { // Delete the temporary image file try { File.Delete(Path.Combine(ScreenshotDirectory, ImageFilename)); } catch { } } } }
public override void TickTest() { base.TickTest(); if (GetTestStatus() == TestStatus.Complete || ResultsGathered) { if (!ResultsGathered) { ResultsGathered = true; try { // Gather results and merge PGO data Log.Info("Gathering profiling results to {0}", TestInstance.ClientApps[0].ArtifactPath); PGOPlatform.GatherResults(TestInstance.ClientApps[0].ArtifactPath); } catch (Exception Ex) { ProcessPGODataFailed = true; Log.Error("Error getting PGO results: {0}", Ex); } } return; } // Handle device screenshot update TimeSpan Delta = DateTime.Now - ScreenshotTime; ITargetDevice Device = TestInstance.ClientApps[0].Device; string ImageFilename; if (!String.IsNullOrEmpty(ScreenshotDirectory) && Delta >= ScreenshotInterval && Device != null && PGOPlatform.TakeScreenshot(Device, ScreenshotDirectory, out ImageFilename)) { ScreenshotTime = DateTime.Now; if (!File.Exists(Path.Combine(ScreenshotDirectory, ImageFilename))) { Log.Info("PGOPlatform.TakeScreenshot returned true, but output image {0} does not exist! skipping", ImageFilename); } else if (new FileInfo(Path.Combine(ScreenshotDirectory, ImageFilename)).Length <= 0) { Log.Info("PGOPlatform.TakeScreenshot returned true, but output image {0} is size 0! skipping", ImageFilename); } else { try { TimeSpan ImageTimestamp = DateTime.UtcNow - ScreenshotStartTime; string ImageOutputPath = Path.Combine(ScreenshotDirectory, ImageTimestamp.ToString().Replace(':', '-') + ".jpg"); ImageUtils.ResaveImageAsJpgWithScaleAndQuality(Path.Combine(ScreenshotDirectory, ImageFilename), ImageOutputPath, ScreenshotScale, ScreenshotQuality); // Delete the temporary image file try { File.Delete(Path.Combine(ScreenshotDirectory, ImageFilename)); } catch (Exception e) { Log.Warning("Got Exception Deleting temp iamge: {0}", e.ToString()); } } catch (Exception e) { Log.Info("Got Exception Renaming PGO image {0}: {1}", ImageFilename, e.ToString()); TimeSpan ImageTimestamp = DateTime.UtcNow - ScreenshotStartTime; string CopyFileName = Path.Combine(ScreenshotDirectory, ImageTimestamp.ToString().Replace(':', '-') + ".bmp"); Log.Info("Copying unconverted image {0} to {1}", ImageFilename, CopyFileName); try { File.Copy(Path.Combine(ScreenshotDirectory, ImageFilename), CopyFileName); } catch (Exception e2) { Log.Warning("Got Exception copying un-converted screenshot image: {0}", e2.ToString()); } } } } }
public override void TickTest() { base.TickTest(); // Handle device screenshot update TimeSpan Delta = DateTime.Now - ScreenshotTime; ITargetDevice Device = TestInstance.ClientApps[0].Device; string ImageFilename; if (!String.IsNullOrEmpty(ScreenshotDirectory) && Delta >= ScreenshotInterval && Device != null && PGOPlatform.TakeScreenshot(Device, ScreenshotDirectory, out ImageFilename)) { ScreenshotTime = DateTime.Now; try { TimeSpan ImageTimestamp = DateTime.UtcNow - ScreenshotStartTime; string ImageOutputPath = Path.Combine(ScreenshotDirectory, ImageTimestamp.ToString().Replace(':', '-') + ".jpg"); ImageUtils.ResaveImageAsJpgWithScaleAndQuality(Path.Combine(ScreenshotDirectory, ImageFilename), ImageOutputPath, ScreenshotScale, ScreenshotQuality); } catch { // Just ignore errors. } finally { // Delete the temporary image file try { File.Delete(Path.Combine(ScreenshotDirectory, ImageFilename)); } catch { } } } }