Skip to content

Commit 7bc65bf

Browse files
committed
- add tests to make sure we validate regression
1 parent cb33ada commit 7bc65bf

File tree

6 files changed

+121
-0
lines changed

6 files changed

+121
-0
lines changed
135 KB
Loading
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
x:Class="Maui.Controls.Sample.Issues.Issue28098"
5+
xmlns:local="clr-namespace:Maui.Controls.Sample.Issues"
6+
Title="Issue28098">
7+
<ContentPage.BindingContext>
8+
<local:MainPageViewModel x:Name="_viewModel"/>
9+
</ContentPage.BindingContext>
10+
<StackLayout Margin="20">
11+
<Button Clicked="Button_Clicked"
12+
AutomationId="Button"
13+
Text="Button"/>
14+
<CarouselView WidthRequest="350"
15+
HeightRequest="570"
16+
HorizontalOptions="Fill"
17+
VerticalOptions="Fill"
18+
ItemsSource="{Binding Items}"
19+
Loop="False">
20+
<CarouselView.ItemTemplate>
21+
<DataTemplate>
22+
<StackLayout>
23+
<Image Source="dotnet_bot.png"
24+
WidthRequest="200"
25+
HeightRequest="200"
26+
Aspect="AspectFill"/>
27+
<Label Padding="10"
28+
VerticalOptions="Center"
29+
HorizontalOptions="Center"
30+
Text="{Binding Name}"/>
31+
</StackLayout>
32+
</DataTemplate>
33+
</CarouselView.ItemTemplate>
34+
</CarouselView>
35+
36+
</StackLayout>
37+
</ContentPage>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using System.Collections.ObjectModel;
2+
3+
namespace Maui.Controls.Sample.Issues;
4+
5+
[Issue(IssueTracker.Github, 28098, "Returning back from navigation to MainPage would result in a blank screen", PlatformAffected.iOS)]
6+
public partial class Issue28098 : ContentPage
7+
{
8+
public Issue28098()
9+
{
10+
InitializeComponent();
11+
}
12+
13+
protected override void OnAppearing()
14+
{
15+
base.OnAppearing();
16+
_viewModel.OnAppearing();
17+
}
18+
private async void Button_Clicked(object sender, EventArgs e)
19+
{
20+
await Navigation.PushModalAsync(new ActionPage());
21+
}
22+
}
23+
24+
public class ActionPage : ContentPage
25+
{
26+
public ActionPage()
27+
{
28+
var button = new Button { Text = "GoBack", AutomationId = "BackButton" };
29+
button.Clicked += async (s, e) => await Navigation.PopModalAsync();
30+
Content = button;
31+
}
32+
}
33+
34+
public class MainPageViewModel
35+
{
36+
public Command LoadItemsCommand { get; }
37+
public ObservableCollection<Item> Items { get; }
38+
39+
public void OnAppearing()
40+
{
41+
LoadItemsCommand.Execute(null);
42+
}
43+
44+
void ExecuteLoadItemsCommand()
45+
{
46+
Items.Clear();
47+
Items.Add(new Item() { Name = "Item1" });
48+
Items.Add(new Item() { Name = "Item2" });
49+
}
50+
public MainPageViewModel()
51+
{
52+
Items = new ObservableCollection<Item>();
53+
54+
LoadItemsCommand = new Command(() => ExecuteLoadItemsCommand());
55+
}
56+
}
57+
58+
public class Item
59+
{
60+
public string Name { get; set; }
61+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using NUnit.Framework;
2+
using UITest.Appium;
3+
using UITest.Core;
4+
5+
namespace Microsoft.Maui.TestCases.Tests.Issues;
6+
public class Issue28098 : _IssuesUITest
7+
{
8+
public override string Issue => "Returning back from navigation to MainPage would result in a blank screen";
9+
public Issue28098(TestDevice device) : base(device)
10+
{
11+
}
12+
13+
[Test]
14+
[Category(UITestCategories.Picker)]
15+
public void BlankScreenOnNavigationBack()
16+
{
17+
App.WaitForElement("Button");
18+
App.Tap("Button");
19+
App.WaitForElement("BackButton");
20+
App.Tap("BackButton");
21+
VerifyScreenshot();
22+
}
23+
}
37.2 KB
Loading
131 KB
Loading

0 commit comments

Comments
 (0)