Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests] Ignore flaky android device tests #18905

Merged
merged 2 commits into from Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
123 changes: 0 additions & 123 deletions src/Controls/tests/DeviceTests/Elements/Modal/ModalTests.Android.cs
Expand Up @@ -63,128 +63,5 @@ public async Task DontPushModalPagesWhenWindowIsDeactivated()
await OnLoadedAsync(modalPage);
});
}

[Theory]
[InlineData(WindowSoftInputModeAdjust.Resize)]
[InlineData(WindowSoftInputModeAdjust.Pan)]
public async Task ModalPageMarginCorrectAfterKeyboardOpens(WindowSoftInputModeAdjust panSize)
{
SetupBuilder();

var navPage = new NavigationPage(new ContentPage());
var window = new Window(navPage);
await CreateHandlerAndAddToWindow<IWindowHandler>(window,
async (handler) =>
{
Entry testEntry = null;
try
{
window.UpdateWindowSoftInputModeAdjust(panSize.ToPlatform());
VerticalStackLayout layout = new VerticalStackLayout();
List<Entry> entries = new List<Entry>();
ContentPage modalPage = new ContentPage()
{
Content = layout
};

// Add enough entries into the stack layout so that we can
// guarantee we'll have entries that would be covered by the keyboard
for (int i = 0; i < 30; i++)
{
var entry = new Entry();

if (i == 0)
{
// This just lets us visually verify where
// the first entry is located
entry.Text = "First Entry";
}

entries.Add(entry);
layout.Add(entry);
}

await navPage.CurrentPage.Navigation.PushModalAsync(modalPage);
await OnNavigatedToAsync(modalPage);

// Locate the lowest visible entry
var pageBoundingBox = modalPage.GetBoundingBox();
testEntry = entries[0];

// Ensure that the keyboard is closed before we start
await AssertionExtensions.HideKeyboardForView(testEntry, message: "Ensure that the keyboard is closed before we start");

foreach (var entry in entries)
{
var entryLocation = entry.GetLocationOnScreen();
var entryBox = entry.GetBoundingBox();

// Locate the lowest visible entry
if ((entryLocation.Value.Y + (entryBox.Height * 2)) > pageBoundingBox.Height)
break;

testEntry = entry;
}

// determine the screen dimensions with no keyboard open
var rootPageOffsetY = navPage.CurrentPage.GetLocationOnScreen().Value.Y;
var modalOffsetY = modalPage.GetLocationOnScreen().Value.Y;
var originalModalPageSize = modalPage.GetBoundingBox();

await AssertionExtensions.ShowKeyboardForView(testEntry, message: "Show keyboard for entry");

// Type text into the entries
testEntry.Text = "Typing";

// Wait for the size of the screen to settle after the keyboard has opened
bool offsetMatchesWhenKeyboardOpened = await AssertionExtensions.Wait(() =>
{
var keyboardOpenRootPageOffsetY = navPage.CurrentPage.GetLocationOnScreen().Value.Y;
var keyboardOpenModalOffsetY = modalPage.GetLocationOnScreen().Value.Y;

var originalDiff = Math.Abs(rootPageOffsetY - modalOffsetY);
var openDiff = Math.Abs(keyboardOpenRootPageOffsetY - keyboardOpenModalOffsetY);

return Math.Abs(originalDiff - openDiff) <= 0.2;
});

Assert.True(offsetMatchesWhenKeyboardOpened, "Modal page has an invalid offset when open");

foreach (var entry in entries)
{
var entryBox = entry.GetLocationOnScreen();

if (entryBox.Value.Y > 0)
{
await AssertionExtensions.HideKeyboardForView(testEntry, message: "Close Keyboard to see if sizes adjust back");
break;
}
}

// Wait for the size of the screen to settle after the keyboard has closed
bool offsetMatchesWhenKeyboardClosed = await AssertionExtensions.Wait(() =>
{
var keyboardClosedRootPageOffsetY = navPage.CurrentPage.GetLocationOnScreen().Value.Y;
var keyboardClosedModalOffsetY = modalPage.GetLocationOnScreen().Value.Y;

return rootPageOffsetY == keyboardClosedRootPageOffsetY &&
modalOffsetY == keyboardClosedModalOffsetY;
});

Assert.True(offsetMatchesWhenKeyboardClosed, "Modal page failed to return to expected offset");

// Make sure that everything has returned to the initial size once the keyboard has closed
var finalModalPageSize = modalPage.GetBoundingBox();
Assert.Equal(originalModalPageSize, finalModalPageSize);
}
finally
{
window.UpdateWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize.ToPlatform());

if (testEntry?.Handler is IPlatformViewHandler testEntryHandler)
testEntryHandler.PlatformView.HideSoftInput();
}
});
}
}
}

This file was deleted.