Skip to content

Commit 6737f23

Browse files
Added device test
1 parent fc07068 commit 6737f23

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/Controls/src/Core/View/View.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Microsoft.Maui.Controls
1717
/// This is the base class for <see cref="Layout"/> and most of the controls.
1818
/// Because <see cref="View" /> ultimately inherits from <see cref="BindableObject" />, application developers can use the Model-View-ViewModel architecture, as well as XAML, to develop portable user interfaces.
1919
/// </remarks>
20-
public partial class View : VisualElement, IViewController, IGestureController, IGestureRecognizers, IView, IPropertyMapperView, IHotReloadableView, IControlsView
20+
public partial class View : VisualElement, IViewController, IGestureController, IGestureRecognizers, IView, IPropertyMapperView, IHotReloadableView, IControlsView, IViewWithWindow
2121
{
2222
protected internal IGestureController GestureController => this;
2323

@@ -282,6 +282,7 @@ bool ValidateGesture(IGestureRecognizer gesture)
282282
Thickness IView.Margin => Margin;
283283
partial void HandlerChangedPartial();
284284
GestureManager _gestureManager;
285+
IWindow? IViewWithWindow.Window => Window;
285286

286287
private protected override void OnHandlerChangedCore()
287288
{

src/Controls/tests/DeviceTests/Elements/View/ViewTests.Android.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using Microsoft.Maui.Platform;
1717
using Xunit;
1818
using Xunit.Sdk;
19+
using Microsoft.Maui.Devices;
1920

2021
namespace Microsoft.Maui.DeviceTests
2122
{
@@ -81,8 +82,7 @@ await CreateHandlerAndAddToWindow(grid, (LayoutHandler handler) =>
8182

8283
// This fails sometimes due to the way we arrange the content based on coordinates instead of size
8384
// Assert.Equal(expectedWidth, pxFrame.Width);
84-
Assert.True(pxFrame.Left == lastRight);
85-
85+
Assert.True(pxFrame.Left == lastRight, $"ColumnCount: {columnCount} Expected Left {lastRight} but got {pxFrame.Left} for child {i} Device Info: {DeviceDisplay.Current.MainDisplayInfo}");
8686
lastRight = pxFrame.Right;
8787
}
8888
});

src/Controls/tests/DeviceTests/Stubs/WindowHandlerStub.Android.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ public class WindowHandlerStub : ElementHandler<IWindow, AActivity>, IWindowHand
1717
[nameof(IWindow.Content)] = MapContent
1818
};
1919

20+
public static CommandMapper<IWindow, IWindowHandler> CommandMapper = new(ElementCommandMapper)
21+
{
22+
[nameof(IWindow.RequestDisplayDensity)] = WindowHandler.MapRequestDisplayDensity,
23+
};
24+
2025
public AView PlatformViewUnderTest { get; private set; }
2126

2227
void UpdateContent()
@@ -50,7 +55,7 @@ protected override void DisconnectHandler(AActivity platformView)
5055
}
5156

5257
public WindowHandlerStub()
53-
: base(WindowMapper)
58+
: base(WindowMapper, CommandMapper)
5459
{
5560
}
5661

0 commit comments

Comments
 (0)