Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@

<Grid Margin="10" HeightRequest="100" BackgroundColor="LightBlue">

<Button Text="Bottom Button" IsVisible="{Binding InputTransparent, Source={Reference testButton}}" Clicked="ClickSuccess" HorizontalOptions="Center" VerticalOptions="Center" />
<Button Text="Bottom Button" IsVisible="{Binding InputTransparent, Source={Reference testButton}, Converter={StaticResource NegativeConverter}}" Clicked="ClickFail" HorizontalOptions="Center" VerticalOptions="Center" />
<Button Text="Bottom Button" Clicked="ClickBottom" HorizontalOptions="Center" VerticalOptions="Center" Background="Red" />

<Grid x:Name="rootLayout">
<Grid x:Name="nestedLayout">
<Grid x:Name="nestedLayout" ColumnDefinitions="2*,1*">
<Button x:Name="testButton" Text="Test Button" Clicked="ClickSuccess" HorizontalOptions="Center" VerticalOptions="Center" />
</Grid>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,11 @@ void ClickSuccess(object sender, EventArgs e)
Debug.WriteLine("Success; That should have worked, and it did!");
DisplayAlert("Success", "That should have worked, and it did!", "OK");
}

void ClickBottom(object sender, EventArgs e)
{
Debug.WriteLine("Click; You clicked a bottom button.");
DisplayAlert("Click", "You clicked a bottom button.", "OK");
}
}
}
36 changes: 33 additions & 3 deletions src/Controls/tests/TestCases.Shared.Tests/Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -720,13 +720,43 @@ public enum ImageLoading

public enum InputTransparency
{
Default,
IsFalse,
IsTrue,
// Single Control
ButtonNotSet,
Button,
TransButtonInputBlocked,
// Button
ButtonOverlay,
TransButtonOverlay,
// Image
ImageOverlayInputBlocked,
TransImageOverlay,
ImageBackOverlayInputBlocked,
TransImageBackOverlay,
// Label
LabelOverlayInputBlocked,
TransLabelOverlay,
// ActivityIndicator
ActivityIndicatorOverlayInputBlocked,
TransActivityIndicatorOverlay,
// ProgressBar
ProgressBarOverlayInputBlocked,
TransProgressBarOverlay,
// Layout
LayoutOverlayInputBlocked,
TransLayoutOverlay,
TransLayoutOverlayWithButton,
CascadeTransLayoutOverlay,
CascadeTransLayoutOverlayWithButton,
// CollectionView
CollectionViewItemLayoutOverlay,
CollectionViewItemTransLayoutOverlay,
CollectionViewItemButtonOverlay,
CollectionViewItemTransButtonOverlay,
// ListView
ListViewItemLayoutOverlay,
ListViewItemTransLayoutOverlay,
ListViewItemButtonOverlay,
ListViewItemTransButtonOverlay,
}

public static class InputTransparencyMatrix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ protected override void NavigateToGallery()
}

[Test]
public void InputTransparencySimple([Values] Test.InputTransparency test) => RunTest(test.ToString());
public void InputTransparencySimple([Values] Test.InputTransparency test) =>
RunTest(test.ToString(), !test.ToString().EndsWith("InputBlocked"));

[Test]
[Combinatorial]
Expand All @@ -40,10 +41,10 @@ public void InputTransparencyWhenRootIsNotTransparentMatrix([Values] bool rootCa
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);
RunTest(key, clickable || passthru);
}

void RunTest(string test, bool? clickable = null, bool? passthru = null)
static void RunTest(string test, bool updatable)
{
var remote = new EventViewContainerRemote(UITestContext, test);
remote.GoTo(test.ToString());
Expand All @@ -55,23 +56,11 @@ void RunTest(string test, bool? clickable = null, bool? passthru = null)

var textAfterClick = remote.GetEventLabel().GetText();

if (clickable is null || passthru is null)
{
// some tests are really basic so have no need for fancy checks
ClassicAssert.AreEqual($"Event: {test} (SUCCESS 1)", textAfterClick);
}
else if (clickable == true || passthru == true)
if (updatable)
{
// if the button is clickable or taps pass through to the base button
ClassicAssert.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
ClassicAssert.AreEqual($"Event: {test} (SUCCESS 1)", textAfterClick);
}
else
{
// sometimes nothing can happen, so try test that
Expand Down
45 changes: 44 additions & 1 deletion src/Controls/tests/TestCases.Shared.Tests/Tests/_ViewUITests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,49 @@ public virtual void _IsVisible()

ClassicAssert.AreEqual(0, viewPost.Count);
}
}

[Test]
public virtual void _InputTransparent()
{
var remote = new LayeredViewContainerRemote (UITestContext, Test.VisualElement.InputTransparent);
remote.GoTo ();

var hiddenButtonClickedLabelTextPre = remote.GetLayeredLabel ().Text;
Assert.AreEqual ("Hidden Button (Not Clicked)", hiddenButtonClickedLabelTextPre);

remote.TapHiddenButton ();

var hiddenButtonClickedLabelTextPost = remote.GetLayeredLabel ().Text;
var hiddenButtonClicked = hiddenButtonClickedLabelTextPost == "Hidden Button (Clicked)";

// // Allow tests to continue by dismissing DatePicker that should not show
// // Remove when InputTransparency works
// if (!hiddenButtonClicked && PlatformViewType == PlatformViews.DatePicker)
// remote.DismissPopOver ();

Assert.True (hiddenButtonClicked);
}

[Test]
public virtual void _NotInputTransparent()
{
var remote = new LayeredViewContainerRemote (UITestContext, Test.VisualElement.NotInputTransparent);
remote.GoTo ();

var hiddenButtonClickedLabelTextPre = remote.GetLayeredLabel ().Text;
Assert.AreEqual ("Hidden Button (Not Clicked)", hiddenButtonClickedLabelTextPre);

remote.TapHiddenButton ();

var hiddenButtonClickedLabelTextPost = remote.GetLayeredLabel ().Text;
var hiddenButtonClicked = hiddenButtonClickedLabelTextPost == "Hidden Button (Not Clicked)";

// // Allow tests to continue by dismissing DatePicker that should not show
// // Remove when InputTransparency works
// if (!hiddenButtonClicked && PlatformViewType == PlatformViews.DatePicker)
// remote.DismissPopOver ();

Assert.True (hiddenButtonClicked);
}
}
}
Loading