Ejemplo n.º 1
0
 private void Diagonal(IAppRect target, IAppRect scroller)
 => _app.DragCoordinates(target.X + 5, target.Bottom - 5, scroller.Right - 20, scroller.Y + 10);
Ejemplo n.º 2
0
 private static float Item(IAppRect sut, int index) => sut.Y + (index * _itemHeight) + 25;
Ejemplo n.º 3
0
 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));
Ejemplo n.º 4
0
 public static float GetBottom(this IAppRect rect)
 {
     return(rect.Y + rect.Height);
 }
Ejemplo n.º 5
0
 /// <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);
Ejemplo n.º 6
0
 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);
Ejemplo n.º 7
0
 /// <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);
Ejemplo n.º 8
0
 // 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);
Ejemplo n.º 9
0
 private void Tap(IAppRect target)
 => _app.TapCoordinates(target.X + 2, target.Y + 2);
Ejemplo n.º 10
0
 /// <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);
Ejemplo n.º 11
0
 public static IAppRect UnapplyScale(this IAppRect rect, float scale) => rect.ApplyScale(1f / scale);
Ejemplo n.º 12
0
 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);
Ejemplo n.º 13
0
 public static void AreNotEqual(FileInfo expected, FileInfo actual, IAppRect rect, [CallerLineNumber] int line = 0)
 => AreNotEqualImpl(expected, rect.ToRectangle(), actual, rect.ToRectangle(), line);
Ejemplo n.º 14
0
 public static IAppRect InflateBy(this IAppRect rect, float thickness) => rect.DeflateBy(-thickness);
Ejemplo n.º 15
0
 private void TranslateX(IAppRect target, IAppRect scroller)
 => _app.DragCoordinates(target.X + 5, target.Bottom - 5, scroller.Right - 20, target.Bottom - 5);
Ejemplo n.º 16
0
        /// <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));
        }
Ejemplo n.º 17
0
 private void TranslateY(IAppRect target, IAppRect scroller)
 => _app.DragCoordinates(target.X + 5, target.Bottom - 5, target.X + 5, scroller.Y + 10);
Ejemplo n.º 18
0
        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.");
        }
Ejemplo n.º 19
0
 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);
Ejemplo n.º 20
0
 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));
Ejemplo n.º 21
0
 public static float GetRight(this IAppRect rect)
 {
     return(rect.X + rect.Width);
 }
Ejemplo n.º 22
0
 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));
Ejemplo n.º 23
0
 public static Rectangle ToRectangle(this IAppRect rect)
 {
     return(new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height));
 }
Ejemplo n.º 24
0
 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);