-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathInputTransparencyGalleryTests.cs
More file actions
104 lines (86 loc) · 3.66 KB
/
InputTransparencyGalleryTests.cs
File metadata and controls
104 lines (86 loc) · 3.66 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
using Maui.Controls.Sample;
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;
namespace Microsoft.Maui.AppiumTests
{
public class InputTransparencyGalleryTests : CoreGalleryBasePageTest
{
const string ButtonGallery = "Input Transparency Gallery";
public InputTransparencyGalleryTests(TestDevice device)
: base(device)
{
}
protected override void NavigateToGallery()
{
App.NavigateToGallery(ButtonGallery);
}
[Test]
public void InputTransparencySimple([Values] Test.InputTransparency test) => RunTest(test.ToString());
[Test]
[Combinatorial]
public void InputTransparencyWhenRootIsTransparentMatrix([Values] bool rootCascade, [Values] bool nestedTrans, [Values] bool nestedCascade, [Values] bool trans)
{
var (clickable, passthru) = Test.InputTransparencyMatrix.States[(true, rootCascade, nestedTrans, nestedCascade, trans)];
var key = Test.InputTransparencyMatrix.GetKey(true, rootCascade, nestedTrans, nestedCascade, trans, clickable, passthru);
RunTest(key, clickable, passthru);
}
[Test]
[Combinatorial]
public void InputTransparencyWhenRootIsNotTransparentMatrix([Values] bool rootCascade, [Values] bool nestedTrans, [Values] bool nestedCascade, [Values] bool trans)
{
var (clickable, passthru) = Test.InputTransparencyMatrix.States[(false, rootCascade, nestedTrans, nestedCascade, trans)];
var key = Test.InputTransparencyMatrix.GetKey(false, rootCascade, nestedTrans, nestedCascade, trans, clickable, passthru);
RunTest(key, clickable, passthru);
}
[Test]
[Combinatorial]
public void ScrollViewInputTransparencySimpleMatrix([Values] bool rootTrans, [Values] bool rootCascade, [Values] bool trans)
{
var (clickable, passthru) = Test.InputTransparencyMatrix.SimpleStates[(rootTrans, rootCascade, trans)];
var key = Test.InputTransparencyMatrix.GetSimpleKey("ScrollView", rootTrans, rootCascade, trans, clickable, passthru);
RunTest(key, clickable, passthru);
}
[Test]
[Combinatorial]
public void ContentViewInputTransparencySimpleMatrix([Values] bool rootTrans, [Values] bool rootCascade, [Values] bool trans)
{
var (clickable, passthru) = Test.InputTransparencyMatrix.SimpleStates[(rootTrans, rootCascade, trans)];
var key = Test.InputTransparencyMatrix.GetSimpleKey("ContentView", rootTrans, rootCascade, trans, clickable, passthru);
RunTest(key, clickable, passthru);
}
void RunTest(string test, bool? clickable = null, bool? passthru = null)
{
var remote = new EventViewContainerRemote(UITestContext, test);
remote.GoTo(test.ToString());
var textBeforeClick = remote.GetEventLabel().GetText();
Assert.AreEqual($"Event: {test} (none)", textBeforeClick);
remote.TapView();
var textAfterClick = remote.GetEventLabel().GetText();
if (clickable is null || passthru is null)
{
// some tests are really basic so have no need for fancy checks
Assert.AreEqual($"Event: {test} (SUCCESS 1)", textAfterClick);
}
else if (clickable == true || passthru == true)
{
// if the button is clickable or taps pass through to the base button
Assert.AreEqual($"Event: {test} (SUCCESS 1)", textAfterClick);
}
else if (Device == TestDevice.Android)
{
// TODO: Android is broken with everything passing through so we just use that
// to test the bottom button was clickable
// https://github.com/dotnet/maui/issues/10252
Assert.AreEqual($"Event: {test} (SUCCESS 1)", textAfterClick);
}
else
{
// sometimes nothing can happen, so try test that
Task.Delay(500).Wait(); // just make sure that nothing happened
textAfterClick = remote.GetEventLabel().GetText();
Assert.AreEqual($"Event: {test} (none)", textBeforeClick);
}
}
}
}