From 7bbcd90e7f511db33185e9b5d135cd529b50fa83 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Sun, 10 Jul 2016 01:00:41 -0400 Subject: [PATCH] Fixed designer support tests to be able to load assets. Fixed Cairo bitmaps to correctly construct with new design. --- src/Gtk/Avalonia.Cairo/Media/Imaging/BitmapImpl.cs | 2 +- tests/Avalonia.DesignerSupport.Tests/Checker.cs | 12 ++++++++---- .../DesignerSupportTests.cs | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Gtk/Avalonia.Cairo/Media/Imaging/BitmapImpl.cs b/src/Gtk/Avalonia.Cairo/Media/Imaging/BitmapImpl.cs index fd98cd1d71..5c1e5e7d96 100644 --- a/src/Gtk/Avalonia.Cairo/Media/Imaging/BitmapImpl.cs +++ b/src/Gtk/Avalonia.Cairo/Media/Imaging/BitmapImpl.cs @@ -12,7 +12,7 @@ namespace Avalonia.Cairo.Media.Imaging public class BitmapImpl : Gdk.Pixbuf, IBitmapImpl { public BitmapImpl(Gdk.Pixbuf pixbuf) - :base(pixbuf, 0, 0, pixbuf.Width, pixbuf.Height) + :base(pixbuf.SaveToBuffer("png")) { } diff --git a/tests/Avalonia.DesignerSupport.Tests/Checker.cs b/tests/Avalonia.DesignerSupport.Tests/Checker.cs index 510f26b309..9d761689e7 100644 --- a/tests/Avalonia.DesignerSupport.Tests/Checker.cs +++ b/tests/Avalonia.DesignerSupport.Tests/Checker.cs @@ -14,9 +14,9 @@ namespace Avalonia.DesignerSupport.Tests private string _appDir; private IntPtr _window; - public void DoCheck(string outputDir, string xamlText) + public void DoCheck(string baseAsset, string xamlText) { - _appDir = Path.GetFullPath(outputDir); + _appDir = new FileInfo(baseAsset).Directory.FullName; AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; foreach (var asm in Directory.GetFiles(_appDir).Where(f => f.ToLower().EndsWith(".dll") || f.ToLower().EndsWith(".exe"))) try @@ -29,8 +29,12 @@ namespace Avalonia.DesignerSupport.Tests var dic = new Dictionary(); var api = new DesignerApi(dic) { OnResize = OnResize, OnWindowCreated = OnWindowCreated }; LookupStaticMethod("Avalonia.DesignerSupport.DesignerAssist", "Init").Invoke(null, new object[] { dic }); - - api.UpdateXaml(xamlText); + + api.UpdateXaml2(new DesignerApiXamlFileInfo + { + Xaml = xamlText, + AssemblyPath = baseAsset + }.Dictionary); if (_window == IntPtr.Zero) throw new Exception("Something went wrong"); diff --git a/tests/Avalonia.DesignerSupport.Tests/DesignerSupportTests.cs b/tests/Avalonia.DesignerSupport.Tests/DesignerSupportTests.cs index e11c35c530..7ee7a2527e 100644 --- a/tests/Avalonia.DesignerSupport.Tests/DesignerSupportTests.cs +++ b/tests/Avalonia.DesignerSupport.Tests/DesignerSupportTests.cs @@ -12,8 +12,8 @@ namespace Avalonia.DesignerSupport.Tests public class DesignerSupportTests { [Theory, - InlineData(@"..\..\..\Avalonia.DesignerSupport.TestApp\bin\$BUILD", @"..\..\..\Avalonia.DesignerSupport.TestApp\MainWindow.xaml"), - InlineData(@"..\..\..\..\samples\ControlCatalog.Desktop\bin\$BUILD", @"..\..\..\..\samples\ControlCatalog\MainWindow.xaml")] + InlineData(@"..\..\..\Avalonia.DesignerSupport.TestApp\bin\$BUILD\Avalonia.DesignerSupport.TestApp.exe", @"..\..\..\Avalonia.DesignerSupport.TestApp\MainWindow.xaml"), + InlineData(@"..\..\..\..\samples\ControlCatalog.Desktop\bin\$BUILD\ControlCatalog.dll", @"..\..\..\..\samples\ControlCatalog\MainWindow.xaml")] public void DesgignerApiShoudBeOperational(string outputDir, string xamlFile) { var xaml = File.ReadAllText(xamlFile);