Skip to content
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

Move 10234 to Appium #21471

Merged
merged 6 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public int PageId
#if UITEST && __IOS__

[Test]
[MovedToAppium]
public void ScrollCarouselViewAfterDispose()
{
RunningApp.WaitForElement("goToShow");
Expand Down
157 changes: 157 additions & 0 deletions src/Controls/samples/Controls.Sample.UITests/Issues/Issue10234.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Maui.Controls;

namespace Maui.Controls.Sample.Issues
{
[Issue(IssueTracker.None, 10234, "CarouselView disposed on iOS when navigating back in Shell", PlatformAffected.iOS)]
public class Issue10234Test : ContentPage
{
public Issue10234Test()
{
Content = new VerticalStackLayout()
{
Children =
{
new Button()
{
Text = "Go To Test",
AutomationId = "GoToTest",
Command = new Command(() => Application.Current.MainPage = new Issue10234())
}
}
};
}
}

public class Issue10234 : Shell
{
public Issue10234()
{
TabBar tabBar = new TabBar
{
Title = "Main",
Route = "main",
Items =
{
new Tab
{
Route = "tab1",
Title = "Tab 1",
Items =
{
new ShellContent()
{
ContentTemplate = new DataTemplate(() => new ContentPage
{
Content = new StackLayout
{
Children =
{
new Label { Text = "Hej" },
new Button {
AutomationId = "goToShow",
Text = "Show",
Command = new Command(async () => await GoToAsync("//photos?id=1"))
}
}
}
}),
}
}
}
}
};

TabBar photosTab = new TabBar()
{
Title = "Photos",
Route = "photos",
Items =
{
new ShellSection()
{
Items =
{
new ShellContent()
{
ContentTemplate = new DataTemplate(() => new PhotosPage()),
}
}
}
}
};

Items.Add(tabBar);
Items.Add(photosTab);
}

class PhotosPage : ContentPage
{

CarouselView Photos;
public PhotosPage()
{
Photos = new CarouselView
{
AutomationId = "carouselView",
ItemTemplate = new DataTemplate(
() =>
{
var image = new Image();
image.SetBinding(Image.SourceProperty, new Binding("."));
return image;
}
)
};

var grid = new Grid();
grid.RowDefinitions.Add(new RowDefinition());
grid.RowDefinitions.Add(new RowDefinition());
var btn = new Button
{
Text = "Go back",
AutomationId = "goToBack",
Command = new Command(async () => await Shell.Current.GoToAsync("//main"))
};
Grid.SetRow(Photos, 0);
Grid.SetRow(btn, 1);
grid.Children.Add(Photos);
grid.Children.Add(btn);
Content = grid;
}

public ObservableCollection<string> Items { get; set; }

public void LoadData()
{
var images = new List<string>();

images.Add("oasis.jpg");
images.Add("dotnet_bot.jpg");
images.Add("shopping_cart.jpg");
images.Add("groceries.png");


Items = new ObservableCollection<string>(images);
Photos.ItemsSource = Items;
}

protected override void OnAppearing()
{
base.OnAppearing();

LoadData();
}

public int PageId
{
get; set;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ public class Issue17347 : TestContentPage
protected override void Init()
{
var navPage = new NavigationPage(new MainPage());
var label = new Label() { Text = "NavigatedTo Has Not Fired" };
NavigatedTo += Issue16499_NavigatedTo;
Content = new VerticalStackLayout()
{
label
};

async void Issue16499_NavigatedTo(object sender, NavigatedToEventArgs e)
{
label.Text = "Navigated to Has Fired";
NavigatedTo -= Issue16499_NavigatedTo;

await Navigation.PushModalAsync(navPage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,26 @@

namespace Maui.Controls.Sample.Issues
{
[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 20439, "[iOS] Double dash in Entry or Editor crashes the app", PlatformAffected.iOS)]
public class Issue20439Test : ContentPage
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The runners don't really work with Shell right now so I changed this one to swap in the main page as part of the test

{
public Issue20439Test()
{
Content = new VerticalStackLayout()
{
Children =
{
new Button()
{
Text = "Go To Test",
AutomationId = "GoToTest",
Command = new Command(() => Application.Current.MainPage = new Issue20439())
}
}
};
}
}

public partial class Issue20439 : Shell
{
public Issue20439()
Expand Down
46 changes: 46 additions & 0 deletions src/Controls/tests/UITests/Tests/Issues/Issue10234.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.AppiumTests.Issues
{
public class Issue10234 : _IssuesUITest
{
public override string Issue => "CarouselView disposed on iOS when navigating back in Shell";

public Issue10234(TestDevice device) : base(device)
{
}

[Test]
public void ScrollCarouselViewAfterDispose()
{
this.IgnoreIfPlatforms(new TestDevice[] { TestDevice.Android, TestDevice.Mac, TestDevice.Windows });

try
{
_ = App.WaitForElement("GoToTest");
App.Click("GoToTest");
App.WaitForElement("goToShow");
App.Click("goToShow");
App.WaitForElement("goToBack");
ScrollNextItem();
App.Click("goToBack");
App.WaitForElement("goToShow");
App.Click("goToShow");
ScrollNextItem();
App.WaitForElement("goToBack");
App.Click("goToBack");
App.WaitForElement("goToShow");
}
finally{
Reset();
}
}

void ScrollNextItem()
{
App.ScrollRight("carouselView");
}
}
}
2 changes: 1 addition & 1 deletion src/Controls/tests/UITests/Tests/Issues/Issue17347.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void AppDoesntCrashWhenSettingNewTitleViewOnExistingPage()
{
try
{
App.WaitForElement("TitleViewLabel4", timeout: TimeSpan.FromSeconds(4));
App.WaitForElement("TitleViewLabel4", timeout: TimeSpan.FromSeconds(10));
}
finally
{
Expand Down
24 changes: 13 additions & 11 deletions src/Controls/tests/UITests/Tests/Issues/Issue17490.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@ public Issue17490(TestDevice device) : base(device)

public override string Issue => "Crash using Pinvoke.SetParent to create Window as Child";

[Test]
[Ignore("This broke with WinAPPSDK 1.4 and we currently don't have an alternative https://github.com/dotnet/maui/issues/20253")]
[Category(UITestCategories.Window)]
public void AppDoesntCrashWhenOpeningWinUIWindowParentedToCurrentWindow()
{
this.IgnoreIfPlatforms(new[]
{
TestDevice.Mac, TestDevice.iOS, TestDevice.Android
});
// I've commented this test out because nunit will still navigate to this test and then just not run any of the tests
// Just navigating to this test will crash WinUI so we want to just completely remove it
//[Test]
//[Ignore("This broke with WinAPPSDK 1.4 and we currently don't have an alternative https://github.com/dotnet/maui/issues/20253")]
//[Category(UITestCategories.Window)]
//public void AppDoesntCrashWhenOpeningWinUIWindowParentedToCurrentWindow()
//{
// this.IgnoreIfPlatforms(new[]
// {
// TestDevice.Mac, TestDevice.iOS, TestDevice.Android
// });

App.WaitForElement("SuccessLabel");
}
// App.WaitForElement("SuccessLabel");
//}
}
}
20 changes: 15 additions & 5 deletions src/Controls/tests/UITests/Tests/Issues/Issue20439.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,22 @@ public void ErrorShouldNotBeThrown()
{
this.IgnoreIfPlatforms(new TestDevice[] { TestDevice.Android, TestDevice.Mac, TestDevice.Windows });

_ = App.WaitForElement("entry");
App.Click("entry");
App.Click("button");
try
{
_ = App.WaitForElement("GoToTest");
App.Click("GoToTest");

_ = App.WaitForElement("entry");
App.Click("entry");
App.Click("button");

// The test passes if no crash is observed
App.FindElement("editor");
// The test passes if no crash is observed
App.FindElement("editor");
}
finally
{
Reset();
}
}
}
}