-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathOpacityTests.cs
More file actions
37 lines (33 loc) · 1.02 KB
/
OpacityTests.cs
File metadata and controls
37 lines (33 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System.Collections;
using System.Linq;
using System.Threading.Tasks;
using NUnit.Framework;
namespace Microsoft.Maui.Controls.Compatibility.Platform.iOS.UnitTests
{
[TestFixture]
public class OpacityTests : PlatformTestFixture
{
static readonly double TestOpacity = 0.4;
static IEnumerable TestCases
{
get
{
foreach (var element in BasicViews)
{
element.Opacity = TestOpacity;
yield return CreateTestCase(element);
}
}
}
[Test, Category("Opacity"), TestCaseSource(nameof(TestCases))]
[Description("VisualElement opacity should match renderer opacity")]
public async Task OpacityConsistent(View view)
{
var expected = view.Opacity;
var actual = await GetRendererProperty(view, r => r.NativeView.Alpha, requiresLayout: true);
// Deliberately casting this to double because Within doesn't seem to grasp nfloat
// If you write this the other way around (casting expected to an nfloat), it fails
Assert.That((double)actual, Is.EqualTo(expected).Within(0.001d));
}
}
}