forked from dotnet/maui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
114 additions
and
0 deletions.
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 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 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 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"); | ||
} | ||
|
||
} | ||
} |