Skip to content

Commit

Permalink
chore: Add test helpers
Browse files Browse the repository at this point in the history
(cherry picked from commit d1f4148)
  • Loading branch information
davidjohnoliver authored and mergify-bot committed Nov 2, 2021
1 parent 2d4f9eb commit fd48a94
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,11 @@ internal static class FrameworkElementExtensions
/// </summary>
public static Rect GetOnScreenBounds(this FrameworkElement element)
=> element.TransformToVisual(null).TransformBounds(new Rect(0, 0, element.ActualWidth, element.ActualHeight));

/// <summary>
/// Get bounds of <paramref name="element"/> relative to <paramref name="relativeTo"/>.
/// </summary>
public static Rect GetRelativeBounds(this FrameworkElement element, FrameworkElement relativeTo)
=> element.TransformToVisual(relativeTo).TransformBounds(new Rect(0, 0, element.ActualWidth, element.ActualHeight));
}
}
23 changes: 23 additions & 0 deletions src/Uno.UI.RuntimeTests/Helpers/TestsResourceHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Uno.Disposables;
using Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Controls;

namespace Uno.UI.RuntimeTests.Helpers
{
internal static class TestsResourceHelper
{
private static TestsResources _testsResources;

/// <summary>
/// Get resource defined in TestsResources.xaml (templates, styles etc)
/// </summary>
public static T GetResource<T>(string resourceName)
{
_testsResources ??= new TestsResources();
return (T)_testsResources[resourceName];
}
}
}

0 comments on commit fd48a94

Please sign in to comment.