[Android] Fix MeasureOverride taking NaN;Nan is input failure

This commit is contained in:
Jerome Laban 2019-11-24 21:43:55 -05:00
Родитель 35835d4bc5
Коммит 7915d2570e
2 изменённых файлов: 33 добавлений и 0 удалений

Просмотреть файл

@ -98,6 +98,24 @@ namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Controls
});
}
[TestMethod]
public async Task MeasureOverride_With_Nan_In_Grid()
{
await Dispatch(() =>
{
var grid = new Grid();
var SUT = new MyControl02();
SUT.Content = new Grid();
grid.Children.Add(SUT);
SUT.BaseAvailableSize = new Size(double.NaN, double.NaN);
grid.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
Assert.AreEqual(new Size(double.PositiveInfinity, double.PositiveInfinity), SUT.MeasureOverrides.Last());
Assert.AreEqual(new Size(0, 0), SUT.DesiredSize);
});
}
#if __WASM__
// TODO Android does not handle measure invalidation properly
[TestMethod]
@ -135,4 +153,17 @@ namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Controls
return base.MeasureOverride(BaseAvailableSize ?? availableSize);
}
}
public partial class MyControl02 : ContentControl
{
public List<Size> MeasureOverrides { get; } = new List<Size>();
public Size? BaseAvailableSize;
protected override Size MeasureOverride(Size availableSize)
{
MeasureOverrides.Add(availableSize);
return base.MeasureOverride(BaseAvailableSize ?? availableSize);
}
}
}

Просмотреть файл

@ -269,6 +269,8 @@ namespace Windows.UI.Xaml.Controls
var frameworkElement = view as IFrameworkElement;
var ret = default(Size);
// NaN values are accepted as input for MeasureOverride, but are treated as Infinity.
slotSize = slotSize.NumberOrDefault(MaxSize);
if (frameworkElement?.Visibility == Visibility.Collapsed)
{