Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/Controls/tests/TestCases.HostApp/CoreViews/CorePageView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,25 @@ public Task<bool> NavigateToGalleryPage(string pageTitle)
return Task.FromResult(false);
}

/// <summary>
/// Attempts to retrieve a gallery page by title.
/// </summary>
/// <param name="pageTitle">The title of the gallery page to find.</param>
/// <returns>The Page instance if found; otherwise, null.</returns>
/// <remarks>
/// This method searches for a matching gallery page by title (case-insensitive).
/// If a match is found, it invokes the associated Realize factory to create the page.
/// </remarks>
public Page TryToGetGalleryPage(string pageTitle)
{
if (_titleToPage.TryGetValue(pageTitle.ToLowerInvariant(), out GalleryPageFactory pageFactory))
{
return pageFactory.Realize();
}

return null;
}

public async Task<bool> NavigateToTest(string pageTitle)
{
var testCaseScreen = new TestCases.TestCaseScreen();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TestPage : ContentPage

public TestPage(int index)
{
nextBtn = new Button { AutomationId = "Next Page", Text = "Next Page" };
nextBtn = new Button { AutomationId = $"Next Page {index}", Text = $"Next Page {index}" };
rmBtn = new Button { AutomationId = "Remove previous pages", Text = "Remove previous pages" };
popBtn = new Button { AutomationId = "Back", Text = "Back" };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ protected override void Init()
lstView = new ListView()
{
IsGroupingEnabled = true,
VerticalScrollBarVisibility = ScrollBarVisibility.Never,
HasUnevenRows = true,
ItemTemplate = new DataTemplate(typeof(MyViewCell)),
GroupHeaderTemplate = new DataTemplate(typeof(MyHeaderViewCell)),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ async void Issue18161_Loaded(object sender, EventArgs e)
{
// https://github.com/dotnet/maui/issues/13496
await Task.Yield();
#if MACCATALYST
await Task.Delay(500); // Add delay for MacCatalyst when page is loaded directly as window root
#endif
this.IsPresented = true;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Controls/tests/TestCases.HostApp/Issues/Issue19657.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue19657"
xmlns:local="clr-namespace:Maui.Controls.Sample"
xmlns:ns="clr-namespace:Maui.Controls.Sample.Issues">
<ScrollView>
<Grid x:Name="contentGrid">
Expand All @@ -20,7 +21,7 @@

<Label HorizontalOptions="Center" x:Name="WaitHere" Text="Check if the Carousel items all show up" AutomationId="WaitHere" Background="Red"/>

<CarouselView x:Name="carousel"
<local:CarouselView2 x:Name="carousel"
ItemTemplate="{StaticResource SampleItemTemplate}"
Loop="False"
HeightRequest="220"
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/tests/TestCases.HostApp/Issues/Issue7144.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public Issue7144()
return image;
});

CarouselView carouselView = new CarouselView
CarouselView2 carouselView = new CarouselView2
{
ItemsSource = Items,
Loop = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async void FillResults(GroupedData results, int items, bool clear)
if (!clear)
return;

await Task.Delay(1000);
await Task.Delay(1500);

results.Clear();
}
Expand Down
25 changes: 25 additions & 0 deletions src/Controls/tests/TestCases.HostApp/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,31 @@ public static Page CreateDefaultMainPage()
{
Page mainPage = null;
OverrideMainPage(ref mainPage);
#if MACCATALYST
// Check for startup test argument from environment variables (passed by test runner)
var testName = System.Environment.GetEnvironmentVariable("test");

if (!string.IsNullOrEmpty(testName))
{
// Try to get the test page directly from issues/test cases
var testCaseScreen = new TestCases.TestCaseScreen();
var testPage = testCaseScreen.TryToGetTestPage(testName);
if (testPage is not null)
{
// Return the actual test page
return testPage;
}

// If not found in test cases, try to get gallery page
var corePageView = new CorePageView(null);
var galleryPage = corePageView.TryToGetGalleryPage(testName);
if (galleryPage is not null)
{
// Return the gallery page
return galleryPage;
}
}
#endif
return mainPage ?? new CoreNavigationPage();
}
}
Expand Down
23 changes: 22 additions & 1 deletion src/Controls/tests/TestCases.HostApp/TestCases.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Linq;

namespace Maui.Controls.Sample
{
Expand Down Expand Up @@ -123,6 +124,7 @@ class IssueModel
public string Description { get; set; }
public bool IsInternetRequired { get; set; }
public Action Action { get; set; }
public Func<Page> PageFactory { get; set; }

public bool Matches(string filter)
{
Expand Down Expand Up @@ -195,7 +197,9 @@ public TestCaseScreen()
Name = attribute.DisplayName,
Description = attribute.Description,
IsInternetRequired = attribute.IsInternetRequired,
Action = ActivatePageAndNavigate(attribute, type)
Action = ActivatePageAndNavigate(attribute, type),
// PageFactory is used to retrieve the instance of the page.
PageFactory = () => ActivatePage(type)
}).ToList();
#endif

Expand Down Expand Up @@ -238,6 +242,23 @@ public bool TryToNavigateTo(string name)
return true;
}


/// <summary>
/// Attempts to retrieve a test page by name or description.
/// </summary>
/// <param name="name">The name or description of the test page to find.</param>
/// <returns>The Page instance if found; otherwise, null.</returns>
/// <remarks>
/// This method first searches for a matching issue by name (case-insensitive),
/// then by description if no match is found by name. If a match is found,
/// it invokes the associated PageFactory to create the page.
/// </remarks>
public Page TryToGetTestPage(string name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can try the exact match first:

var exactMatch = TestCases.FirstOrDefault(x => 
            string.Equals(x.Description, description, StringComparison.OrdinalIgnoreCase));

if not find it, the current partial match as fallback.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jsuarezruiz I have addressed the feedback in the latest commit.

{
var issue = _issues.SingleOrDefault(x => string.Equals(x.Description, name, StringComparison.OrdinalIgnoreCase));
return issue?.PageFactory?.Invoke();
}

public void FilterIssues(string filter = null)
{
filter = filter?.Trim();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class BorderUITests : CoreGalleryBasePageTest
{
const string BorderGallery = "Border Gallery";

public override string GalleryPageName => BorderGallery;

public BorderUITests(TestDevice device)
: base(device)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class ButtonUITests : _ViewUITests
{
const string ButtonGallery = "Button Gallery";

public override string GalleryPageName => ButtonGallery;

public ButtonUITests(TestDevice device)
: base(device)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,18 @@

namespace Microsoft.Maui.TestCases.Tests
{
public class CarouselViewUITests : UITest
public class CarouselViewUITests : _GalleryUITest
{
const string CarouselViewGallery = "CarouselView Gallery";

public override string GalleryPageName => CarouselViewGallery;

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

protected override bool ResetAfterEachTest => true;

public override void TestSetup()
{
base.TestSetup();
App.NavigateToGallery(CarouselViewGallery);
}

[Test]
[Category(UITestCategories.CarouselView)]
public void CarouselViewSetPosition()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class CheckBoxUITests : _ViewUITests
{
const string CheckBoxGallery = "CheckBox Gallery";

public override string GalleryPageName => CheckBoxGallery;

public CheckBoxUITests(TestDevice device)
: base(device)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class CollectionViewEmptyViewTests : CollectionViewUITests
{
protected override bool ResetAfterEachTest => true;

public override string GalleryPageName => CollectionViewGallery;

public CollectionViewEmptyViewTests(TestDevice device)
: base(device)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class CollectionViewGroupingTests : CollectionViewUITests
{
protected override bool ResetAfterEachTest => true;

public override string GalleryPageName => CollectionViewGallery;

public CollectionViewGroupingTests(TestDevice device)
: base(device)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ namespace Microsoft.Maui.TestCases.Tests
{
public abstract class CollectionViewUITests : CoreGalleryBasePageTest
{
const string CollectionViewGallery = "CollectionView Gallery";
public const string CollectionViewGallery = "CollectionView Gallery";

public override string GalleryPageName => CollectionViewGallery;

public CollectionViewUITests(TestDevice device)
: base(device)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ namespace Microsoft.Maui.TestCases.Tests
{
public class AlertsGalleryTests : CoreGalleryBasePageTest
{
const string AlertsGallery = "Alerts Gallery";

public override string GalleryPageName => AlertsGallery;

public AlertsGalleryTests(TestDevice device)
: base(device)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ namespace Microsoft.Maui.TestCases.Tests
[Category(UITestCategories.Fonts)]
public class FontsGalleryTests : CoreGalleryBasePageTest
{
const string FontsGallery = "Fonts Gallery";

public override string GalleryPageName => FontsGallery;

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

protected override void NavigateToGallery()
{
App.NavigateToGallery("Fonts Gallery");
App.NavigateToGallery(FontsGallery);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ namespace Microsoft.Maui.TestCases.Tests
[Category(UITestCategories.Image)]
public class ImageLoadingGalleryTests : CoreGalleryBasePageTest
{
const string ImageLoadingGallery = "Image Loading Gallery";

public override string GalleryPageName => ImageLoadingGallery;

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

protected override void NavigateToGallery()
{
App.NavigateToGallery("Image Loading Gallery");
App.NavigateToGallery(ImageLoadingGallery);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class InputTransparencyGalleryTests : CoreGalleryBasePageTest
{
const string ButtonGallery = "Input Transparency Gallery";

public override string GalleryPageName => ButtonGallery;

public InputTransparencyGalleryTests(TestDevice device)
: base(device)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Microsoft.Maui.TestCases.Tests
{
public abstract class CoreGalleryBasePageTest : UITest
public abstract class CoreGalleryBasePageTest : _GalleryUITest
{
public CoreGalleryBasePageTest(TestDevice device) : base(device) { }

Expand All @@ -16,7 +16,9 @@ protected override void FixtureSetup()
try
{
base.FixtureSetup();
#if MACCATALYST
NavigateToGallery();
#endif
break;
}
catch (Exception e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Microsoft.Maui.TestCases.Tests
public class DragAndDropUITests : CoreGalleryBasePageTest
{
const string DragAndDropGallery = "Drag and Drop Gallery";
public override string GalleryPageName => DragAndDropGallery;
public DragAndDropUITests(TestDevice device)
: base(device)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class EditorUITests : _ViewUITests
{
public const string EditorGallery = "Editor Gallery";

public override string GalleryPageName => EditorGallery;

public EditorUITests(TestDevice device)
: base(device)
{
Expand Down
Loading
Loading