-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set Views used for CarouselView to Match Parent (#21662)
* Call NotifyDataSetChanged when CarV dims change * - set layout parameters on container view to match parent so it always tries to fill the container * - remove test from winui * - don't run test on windows
- Loading branch information
Showing
4 changed files
with
118 additions
and
50 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
src/Controls/samples/Controls.Sample.UITests/Issues/Issue21609.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.Maui.Controls; | ||
|
||
namespace Maui.Controls.Sample.Issues; | ||
|
||
[Issue(IssueTracker.Github, 21609, "Changing the dimensions of the CarouselView doesn't update Item Dimensions")] | ||
public class Issue21609 : TestContentPage | ||
{ | ||
protected override void Init() | ||
{ | ||
if (OperatingSystem.IsWindows()) | ||
{ | ||
Content = new Label() { Text = "This Test currently doesn't work on windows" }; | ||
return; | ||
} | ||
|
||
var carV = new CarouselView() | ||
{ | ||
HeightRequest = 200, | ||
WidthRequest = 200, | ||
ItemTemplate = new DataTemplate(() => | ||
{ | ||
return new Image() { Source = "dotnet_bot.png", AutomationId = "DotnetBot" }; | ||
}) | ||
}; | ||
|
||
carV.ItemsSource = new[] { 1 }; | ||
|
||
var changeSize = new Button() | ||
{ | ||
Text = "Click me and the dimensions of the CarouselView Should Change", | ||
AutomationId = "ChangeCarouselViewDimensions", | ||
Command = new Command(() => | ||
{ | ||
if (carV.HeightRequest == 200) | ||
{ | ||
carV.WidthRequest = carV.HeightRequest = 100; | ||
} | ||
else | ||
{ | ||
carV.WidthRequest = carV.HeightRequest = 200; | ||
} | ||
}) | ||
}; | ||
|
||
var innerVSL = new VerticalStackLayout() | ||
{ | ||
carV | ||
}; | ||
|
||
innerVSL.HeightRequest = 200; | ||
Content = new VerticalStackLayout() | ||
{ | ||
innerVSL, | ||
changeSize | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,21 @@ | ||
//using System; | ||
//using System.ComponentModel; | ||
//using System.Runtime.CompilerServices; | ||
using System; | ||
using System.ComponentModel; | ||
using System.Runtime.CompilerServices; | ||
|
||
//namespace Microsoft.Maui.Controls.Internals | ||
//{ | ||
// [EditorBrowsable(EditorBrowsableState.Never)] | ||
// public static class NumericExtensions | ||
// { | ||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
// public static double Clamp(this double self, double min, double max) | ||
// { | ||
// if (max < min) | ||
// { | ||
// return max; | ||
// } | ||
// else if (self < min) | ||
// { | ||
// return min; | ||
// } | ||
// else if (self > max) | ||
// { | ||
// return max; | ||
// } | ||
namespace Microsoft.Maui.Controls | ||
{ | ||
static class NumericExtensions | ||
{ | ||
const double Tolerance = 0.001; | ||
|
||
// return self; | ||
// } | ||
public static bool IsCloseTo(this double sizeA, double sizeB) | ||
{ | ||
if (Math.Abs(sizeA - sizeB) > Tolerance) | ||
{ | ||
return false; | ||
} | ||
|
||
// [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
// public static int Clamp(this int self, int min, int max) | ||
// { | ||
// if (max < min) | ||
// { | ||
// return max; | ||
// } | ||
// else if (self < min) | ||
// { | ||
// return min; | ||
// } | ||
// else if (self > max) | ||
// { | ||
// return max; | ||
// } | ||
|
||
// return self; | ||
// } | ||
// } | ||
//} | ||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Drawing; | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.AppiumTests.Issues; | ||
|
||
public class Issue21609 : _IssuesUITest | ||
{ | ||
public Issue21609(TestDevice device) : base(device) { } | ||
|
||
public override string Issue => "Changing the dimensions of the CarouselView doesn't update Item Dimensions"; | ||
|
||
[Test] | ||
public void ChangingDimensionsOfCarouselViewDoesntUpdateItemDimensions() | ||
{ | ||
// This test is currently not passing on windows | ||
// the 3rd size doesn't match the first one | ||
this.IgnoreIfPlatform(TestDevice.Windows); | ||
|
||
App.WaitForElement("ChangeCarouselViewDimensions"); | ||
var imageInitial = App.WaitForElement("DotnetBot").GetRect(); | ||
App.Click("ChangeCarouselViewDimensions"); | ||
var imageAfterSizeChange = App.WaitForElement("DotnetBot").GetRect(); | ||
App.Click("ChangeCarouselViewDimensions"); | ||
var imageAfterSizeChangedBacktoInitial = App.WaitForElement("DotnetBot").GetRect(); | ||
|
||
Assert.AreEqual(imageInitial, imageAfterSizeChangedBacktoInitial); | ||
Assert.AreNotEqual(imageInitial, imageAfterSizeChange); | ||
} | ||
} |