private void Diagonal(IAppRect target, IAppRect scroller) => _app.DragCoordinates(target.X + 5, target.Bottom - 5, scroller.Right - 20, scroller.Y + 10);
private static float Item(IAppRect sut, int index) => sut.Y + (index * _itemHeight) + 25;
public void AssertScreenshotsAreNotEqual(FileInfo expected, FileInfo actual, IAppRect rect) => AssertScreenshotsAreNotEqual(expected, actual, new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height));
public static float GetBottom(this IAppRect rect) { return(rect.Y + rect.Height); }
/// <summary> /// Asserts that two screenshots are equal to each other inside the area of the nominated rect to within the given pixel error /// (ie, the A, R, G, or B values cumulatively differ by more than the permitted error for any pixel). /// </summary> public static void AreAlmostEqual(FileInfo expected, IAppRect expectedRect, FileInfo actual, IAppRect actualRect, int permittedPixelError) => AreAlmostEqual( expected, new Rectangle((int)expectedRect.X, (int)expectedRect.Y, (int)expectedRect.Width, (int)expectedRect.Height), actual, new Rectangle((int)actualRect.X, (int)actualRect.Y, (int)actualRect.Width, (int)actualRect.Height), permittedPixelError);
public static void AreEqual(ScreenshotInfo expected, IAppRect expectedRect, ScreenshotInfo actual, IAppRect actualRect, double expectedToActualScale = 1, PixelTolerance tolerance = default, [CallerLineNumber] int line = 0) => AreEqualImpl(expected, expectedRect.ToRectangle(), actual, actualRect.ToRectangle(), expectedToActualScale, tolerance, line);
/// <summary> /// Get point within <paramref name="rect"/> from normalized relative coordinates. /// </summary> /// <param name="pointNormalizedRelative">The point of interest, relative to the <paramref name="rect"/>'s origin and normalized (0 - 1).</param> /// <returns>The point of interest in (unscaled) screen coordinates.</returns> public static PointF GetPointInRect(this IAppRect rect, PointF pointNormalizedRelative) => new PointF(rect.X + pointNormalizedRelative.X * rect.Width, rect.Y + pointNormalizedRelative.Y * rect.Height);
// Press over and move out to release private void ReleaseOut(IAppRect target) => _app.DragCoordinates(target.X + 2, target.Y + 2, target.X, target.Y - 30);
private void Tap(IAppRect target) => _app.TapCoordinates(target.X + 2, target.Y + 2);
/// <summary> /// Asserts that two screenshots are equal to each other inside the area of the nominated rect to within the given pixel error /// (ie, the A, R, G, or B values cumulatively differ by more than the permitted error for any pixel). /// </summary> public static void AreAlmostEqual(FileInfo expected, IAppRect expectedRect, FileInfo actual, IAppRect actualRect, int permittedPixelError, [CallerLineNumber] int line = 0) => AreEqualImpl(expected, expectedRect.ToRectangle(), actual, actualRect.ToRectangle(), 1, PixelTolerance.Cummulative(permittedPixelError), line);
public static IAppRect UnapplyScale(this IAppRect rect, float scale) => rect.ApplyScale(1f / scale);
public static void AreEqual(FileInfo expected, IAppRect expectedRect, FileInfo actual, IAppRect actualRect, [CallerLineNumber] int line = 0) => AreEqualImpl(expected, expectedRect.ToRectangle(), actual, actualRect.ToRectangle(), 1, PixelTolerance.None, line);
public static void AreNotEqual(FileInfo expected, FileInfo actual, IAppRect rect, [CallerLineNumber] int line = 0) => AreNotEqualImpl(expected, rect.ToRectangle(), actual, rect.ToRectangle(), line);
public static IAppRect InflateBy(this IAppRect rect, float thickness) => rect.DeflateBy(-thickness);
private void TranslateX(IAppRect target, IAppRect scroller) => _app.DragCoordinates(target.X + 5, target.Bottom - 5, scroller.Right - 20, target.Bottom - 5);
/// <summary> /// Get the center of <paramref name="rect"/> adjusted for the display scale, appropriate for screenshot analysis. /// </summary> protected PointF GetScaledCenter(IAppRect rect) { var scale = (float)GetDisplayScreenScaling(); return(new PointF(rect.CenterX * scale, rect.CenterY * scale)); }
private void TranslateY(IAppRect target, IAppRect scroller) => _app.DragCoordinates(target.X + 5, target.Bottom - 5, target.X + 5, scroller.Y + 10);
private static PointF GetPixelPositionWithColor(ScreenshotInfo screenshotInfo, IAppRect boundingRect, Color expectedColor) { var bitmap = screenshotInfo.GetBitmap(); for (var x = boundingRect.X; x < boundingRect.Right; x++) { for (var y = boundingRect.Y; y < boundingRect.Bottom; y++) { var pixel = bitmap.GetPixel((int)x, (int)y); if (pixel.ToArgb() == expectedColor.ToArgb()) { return(new PointF(x, y)); } } } throw new InvalidOperationException($"Color {expectedColor} was not found."); }
public static void AreAlmostEqual(ScreenshotInfo expected, IAppRect expectedRect, ScreenshotInfo actual, IAppRect actualRect, int permittedPixelError, double expectedToActualScale = 1, [CallerLineNumber] int line = 0) => AreEqualImpl(expected, expectedRect.ToRectangle(), actual, actualRect.ToRectangle(), expectedToActualScale, PixelTolerance.Cummulative(permittedPixelError), line);
public static void AreEqual(FileInfo expected, FileInfo actual, IAppRect rect) => AreEqual(expected, actual, new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height));
public static float GetRight(this IAppRect rect) { return(rect.X + rect.Width); }
public static void AreNotEqual(FileInfo expected, IAppRect expectedRect, FileInfo actual, IAppRect actualRect) => AreNotEqual( expected, new Rectangle((int)expectedRect.X, (int)expectedRect.Y, (int)expectedRect.Width, (int)expectedRect.Height), actual, new Rectangle((int)actualRect.X, (int)actualRect.Y, (int)actualRect.Width, (int)actualRect.Height));
public static Rectangle ToRectangle(this IAppRect rect) { return(new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height)); }
public static void AreEqual(ScreenshotInfo expected, ScreenshotInfo actual, IAppRect rect, double expectedToActualScale = 1, [CallerLineNumber] int line = 0) => AreEqualImpl(expected, rect.ToRectangle(), actual, rect.ToRectangle(), expectedToActualScale, PixelTolerance.None, line);