-
Notifications
You must be signed in to change notification settings - Fork 2k
[Android] Crash removing item from CarouselView - fix #22107
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
22 changes: 22 additions & 0 deletions
22
src/Controls/samples/Controls.Sample.UITests/Issues/Issue19786.xaml
This file contains hidden or 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,22 @@ | ||
| <?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.Issue19786"> | ||
| <StackLayout> | ||
| <CarouselView Position="{Binding Position}" HeightRequest="200" ItemsSource="{Binding Items}"> | ||
| <CarouselView.ItemTemplate> | ||
| <DataTemplate> | ||
| <Frame Margin="10" WidthRequest="200" BackgroundColor="Red"> | ||
| <Label Text="{Binding .}"/> | ||
| </Frame> | ||
| </DataTemplate> | ||
| </CarouselView.ItemTemplate> | ||
| </CarouselView> | ||
|
|
||
| <Grid ColumnDefinitions="*,*,*"> | ||
| <Button AutomationId="addItemButton" Grid.Column="0" Text="Add item" Command="{Binding AddItemCommand}"/> | ||
| <Button AutomationId="goToNextItemButton" Grid.Column="1" Text="Go to next item" Command="{Binding GoToNextItemCommand}"/> | ||
| <Button AutomationId="removeLastItemButton" Grid.Column="2" Text="Remove last item" Command="{Binding RemoveItemCommand}"/> | ||
| </Grid> | ||
| </StackLayout> | ||
| </ContentPage> |
61 changes: 61 additions & 0 deletions
61
src/Controls/samples/Controls.Sample.UITests/Issues/Issue19786.xaml.cs
This file contains hidden or 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,61 @@ | ||
| using System.Collections.ObjectModel; | ||
| using Microsoft.Maui.Controls; | ||
| using Microsoft.Maui.Controls.Xaml; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues | ||
| { | ||
| [XamlCompilation(XamlCompilationOptions.Compile)] | ||
| [Issue(IssueTracker.Github, 19786, "[Android] Crash removing item from CarouselView", PlatformAffected.All)] | ||
| public partial class Issue19786 : ContentPage | ||
| { | ||
| public Command AddItemCommand { get; set; } | ||
| public Command RemoveItemCommand { get; set; } | ||
| public Command GoToNextItemCommand { get; set; } | ||
|
|
||
| private int _position; | ||
| public int Position | ||
| { | ||
| get => _position; | ||
| set | ||
| { | ||
| _position = value; | ||
| OnPropertyChanged(); | ||
| } | ||
| } | ||
|
|
||
| private ObservableCollection<string> _items = new(); | ||
| public ObservableCollection<string> Items | ||
| { | ||
| get => _items; | ||
| set | ||
| { | ||
| _items = value; | ||
| OnPropertyChanged(); | ||
| } | ||
| } | ||
|
|
||
| public Issue19786() | ||
| { | ||
| InitializeComponent(); | ||
|
|
||
| AddItemCommand = new Command(() => | ||
| { | ||
| Items.Add(Items.Count.ToString()); | ||
| }); | ||
|
|
||
| RemoveItemCommand = new Command(() => | ||
| { | ||
| if (Items.Count > 0) | ||
| Items.RemoveAt(Items.Count - 1); | ||
| }); | ||
|
|
||
| GoToNextItemCommand = new Command(() => | ||
| { | ||
| if (Position < Items.Count - 1) | ||
| Position++; | ||
| }); | ||
|
|
||
| BindingContext = this; | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.AppiumTests.Issues | ||
| { | ||
| public class Issue19786 : _IssuesUITest | ||
| { | ||
| public Issue19786(TestDevice device) : base(device) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "[Android] Crash removing item from CarouselView"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.CarouselView)] | ||
| public void RemovingItemsShouldNotCauseCrash() | ||
| { | ||
| _ = App.WaitForElement("addItemButton"); | ||
| App.Click("addItemButton"); | ||
| App.Click("addItemButton"); | ||
| App.Click("addItemButton"); | ||
| App.Click("goToNextItemButton"); | ||
| App.Click("goToNextItemButton"); | ||
| App.Click("removeLastItemButton"); | ||
| App.Click("removeLastItemButton"); | ||
| App.Click("removeLastItemButton"); | ||
| } | ||
|
|
||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.