Exemplo n.º 1
0
        protected void AssertVisual(string expectedHash, VisualElement root, int width = 1920, int height = 1080)
        {
            var testMethod     = new StackTrace().GetFrame(1)?.GetMethod();
            var testMethodName = $"{testMethod?.ReflectedType?.Name}_{testMethod?.Name}";

            var surface = new IxenSurface(root);

            surface.ComputeLayout(width, height);
            SKBitmap bitmap = surface.RenderToBitmap();

            byte[] md5hash = _md5.ComputeHash(bitmap.Bytes);
            string hash    = Convert.ToHexString(md5hash).ToLower();

            string fileExpectedPath = Path.Combine(_outputRendersDir, $"{testMethodName}_EXPECTED.png");
            string fileErrorPath    = Path.Combine(_outputRendersDir, $"{testMethodName}_NOK.png");

            if (expectedHash == hash)
            {
                File.Delete(fileErrorPath);
                if (!File.Exists(fileExpectedPath))
                {
                    DumpBitmapToFile(fileExpectedPath, bitmap);
                }
            }
            else
            {
                DumpBitmapToFile(fileErrorPath, bitmap);

                Assert.Fail();
            }
        }
Exemplo n.º 2
0
        public IxenWindow(IxenSurface ixenSurface)
        {
            _pixelBuffer = new PixelBuffer();
            _ixenSurface = ixenSurface;
            _windowPtr   = WindowApi.CreateWindow(_ixenSurface.InitOptions.Title, _ixenSurface.InitOptions.Width, _ixenSurface.InitOptions.Height);

            if (_windowPtr == IntPtr.Zero)
            {
                throw new Exception("Could not initialize WIN32 Window");
            }
        }
Exemplo n.º 3
0
        public static int CreateWindow(IxenSurface surface)
        {
            var window = new IxenWindow(surface);

            return(window.Show());
        }