-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Windows] Avoid Carousel changes the current position when window is resized #22222
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
953eacc
Added repro sample
jsuarezruiz 88be40d
Added UI Test
jsuarezruiz de47196
Fix the issue
jsuarezruiz d38b71a
Added pending snapshot
jsuarezruiz b5e9a80
Merge branch 'main' into fix-22000
jsuarezruiz a8be4be
Run added test on all the platforms
jsuarezruiz 519e771
More changes
jsuarezruiz ca94d66
Updated sample
jsuarezruiz cf8b9f5
Added snapshots
jsuarezruiz 82010c3
Updated test
jsuarezruiz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/Controls/samples/Controls.Sample.UITests/Issues/Issue22000.xaml
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,42 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Maui.Controls.Sample.Issues.Issue22000"> | ||
<Grid | ||
RowDefinitions="Auto, *, Auto"> | ||
<Grid.Resources> | ||
|
||
<DataTemplate x:Key="SampleItemTemplate"> | ||
<Grid | ||
RowDefinitions="Auto, Auto" | ||
BackgroundColor="{Binding Color, Mode=OneWay}"> | ||
<Label | ||
TextColor="White" | ||
Text="{Binding Title, Mode=OneWay}" | ||
FontAttributes="Bold" /> | ||
<Label | ||
Grid.Row="1" | ||
TextColor="White" | ||
Text="{Binding Description, Mode=OneWay}" /> | ||
</Grid> | ||
</DataTemplate> | ||
|
||
</Grid.Resources> | ||
<Label | ||
AutomationId="WaitForStubControl" | ||
Text="Tap the Button several times to resize the CarouselView. If the CurrentItem not change, the test has passed."/> | ||
<CarouselView | ||
x:Name="TestCarouselView" | ||
Grid.Row="1" | ||
ItemTemplate="{StaticResource SampleItemTemplate}" | ||
Loop="False" | ||
HeightRequest="250" | ||
HorizontalOptions="Center"/> | ||
<Button | ||
AutomationId="UpdateSizeButton" | ||
Grid.Row="2" | ||
Text="Update Size" | ||
Clicked="OnUpdateSizeClicked"/> | ||
</Grid> | ||
</ContentPage> |
62 changes: 62 additions & 0 deletions
62
src/Controls/samples/Controls.Sample.UITests/Issues/Issue22000.xaml.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 Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Graphics; | ||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[Issue(IssueTracker.Github, 22000, "[Windows] Carousel changes the current position when window is resized", PlatformAffected.UWP)] | ||
public partial class Issue22000 : ContentPage | ||
{ | ||
readonly Random _random; | ||
|
||
public Issue22000() | ||
{ | ||
InitializeComponent(); | ||
|
||
_random = new Random(); | ||
|
||
var exampleItems = new List<Issue22000Model> | ||
{ | ||
new Issue22000Model( "First", "First CarouselView item", Colors.Red ), | ||
new Issue22000Model( "Second", "Second CarouselView item", Colors.LightBlue ), | ||
new Issue22000Model( "Third", "Third CarouselView item", Colors.Pink ), | ||
new Issue22000Model( "Fourth", "Fourth CarouselView item", Colors.GreenYellow ), | ||
new Issue22000Model( "Fifth", "Fifth CarouselView item", Colors.Purple ), | ||
}; | ||
|
||
TestCarouselView.ItemsSource = exampleItems; | ||
|
||
UpdateCarouselViewSize(); | ||
} | ||
|
||
void OnUpdateSizeClicked(object sender, EventArgs e) | ||
{ | ||
UpdateCarouselViewSize(); | ||
} | ||
|
||
void UpdateCarouselViewSize() | ||
{ | ||
var currentWidth = TestCarouselView.WidthRequest; | ||
|
||
if (currentWidth == 400) | ||
TestCarouselView.WidthRequest = 300; | ||
else | ||
TestCarouselView.WidthRequest = 200; | ||
} | ||
} | ||
|
||
class Issue22000Model | ||
{ | ||
public Issue22000Model(string title, string description, Color color) | ||
{ | ||
Title = title; | ||
Description = description; | ||
Color = color; | ||
} | ||
|
||
public string Title { get; set; } | ||
public string Description { get; set; } | ||
public Color Color { get; set; } | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.AppiumTests.Issues | ||
{ | ||
public class Issue22000 : _IssuesUITest | ||
{ | ||
public Issue22000(TestDevice device) : base(device) { } | ||
|
||
public override string Issue => "[Windows] Carousel changes the current position when window is resized"; | ||
|
||
[Test] | ||
[Category(UITestCategories.CarouselView)] | ||
public async Task ResizeCarouselViewKeepsIndex() | ||
{ | ||
App.WaitForElement("WaitForStubControl"); | ||
|
||
for (int i = 0; i < 10; i++) | ||
{ | ||
App.Click("UpdateSizeButton"); | ||
} | ||
|
||
await Task.Delay(500); | ||
|
||
VerifyScreenshot(); | ||
} | ||
} | ||
} |
Binary file added
BIN
+42.8 KB
src/Controls/tests/UITests/snapshots/android/ResizeCarouselViewKeepsIndex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+47.1 KB
src/Controls/tests/UITests/snapshots/ios/ResizeCarouselViewKeepsIndex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.5 KB
src/Controls/tests/UITests/snapshots/windows/ResizeCarouselViewKeepsIndex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.