Skip to content

Commit

Permalink
- disconnect handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
PureWeen committed Nov 14, 2022
1 parent a8222d6 commit ef2ca75
Showing 1 changed file with 36 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,32 +43,48 @@ public async Task SoftInputModeSetOnApplicationPropagatesToWindowHandlers()

await InvokeOnMainThreadAsync(() =>
{
// Setup application stub
var app = MauiContext.Services.GetService<IApplication>() as SoftInputModeApplication;
app.Handler = app.ToHandler(MauiContext);
var handlers = new List<IElementHandler>();
// Setup window
var windowHandler = (SoftInputWindowHandlerStub)app.Window.ToHandler(MauiContext);
app.Window.Handler = windowHandler;
try
{
// Setup application stub
var app = MauiContext.Services.GetService<IApplication>() as SoftInputModeApplication;
app.Handler = app.ToHandler(MauiContext);
handlers.Add(app.Handler);
// Setup window
var windowHandler = (SoftInputWindowHandlerStub)app.Window.ToHandler(MauiContext);
app.Window.Handler = windowHandler;
handlers.Insert(0, app.Window.Handler);
// Validate that the Soft Input initializes to AdjustPan
Assert.Equal(ASoftInput.AdjustPan, windowHandler.LastASoftInputSet);
// Validate that the Soft Input initializes to AdjustPan
Assert.Equal(ASoftInput.AdjustPan, windowHandler.LastASoftInputSet);
// Set to Resize
Controls.PlatformConfiguration.AndroidSpecific.Application.SetWindowSoftInputModeAdjust(
app,
Controls.PlatformConfiguration.AndroidSpecific.WindowSoftInputModeAdjust.Resize);
// Set to Resize
Controls.PlatformConfiguration.AndroidSpecific.Application.SetWindowSoftInputModeAdjust(
app,
Controls.PlatformConfiguration.AndroidSpecific.WindowSoftInputModeAdjust.Resize);
// Validate the mapper on the window handler is called with correct value
Assert.Equal(ASoftInput.AdjustResize, windowHandler.LastASoftInputSet);
// Validate the mapper on the window handler is called with correct value
Assert.Equal(ASoftInput.AdjustResize, windowHandler.LastASoftInputSet);
// Set to Pan
Controls.PlatformConfiguration.AndroidSpecific.Application.SetWindowSoftInputModeAdjust(
app,
Controls.PlatformConfiguration.AndroidSpecific.WindowSoftInputModeAdjust.Pan);
// Set to Pan
Controls.PlatformConfiguration.AndroidSpecific.Application.SetWindowSoftInputModeAdjust(
app,
Controls.PlatformConfiguration.AndroidSpecific.WindowSoftInputModeAdjust.Pan);
// Validate the mapper on the window handler is called with correct value
Assert.Equal(ASoftInput.AdjustPan, windowHandler.LastASoftInputSet);
// Validate the mapper on the window handler is called with correct value
Assert.Equal(ASoftInput.AdjustPan, windowHandler.LastASoftInputSet);
}
finally
{
foreach (var handler in handlers)
{
handler.DisconnectHandler();
}
}
});
}

Expand Down

0 comments on commit ef2ca75

Please sign in to comment.