Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c9a8b0d
Initial changes to set the MainPage and reset the App
jsuarezruiz Feb 16, 2024
6d2c63f
More changes
jsuarezruiz Feb 19, 2024
014bcef
More changes
jsuarezruiz Feb 19, 2024
d2ca570
More changes
jsuarezruiz Feb 19, 2024
67f2e4f
Merge branch 'main' into fix-20614
jsuarezruiz Feb 20, 2024
6fe6a9f
More changes
jsuarezruiz Feb 20, 2024
6c7d03d
More changes to reset the App
jsuarezruiz Feb 21, 2024
8ab133e
Merge branch 'main' into fix-20614
jsuarezruiz Feb 27, 2024
2da4d09
Merge branch 'main' into fix-20614
jsuarezruiz Mar 5, 2024
63952eb
Merge branch 'main' into fix-20614
jsuarezruiz Mar 12, 2024
bd5a4e2
Merge branch 'main' into fix-20614
jsuarezruiz Mar 15, 2024
4e831eb
More changes
jsuarezruiz Mar 18, 2024
e23f488
Updated iOS snapshots
jsuarezruiz Mar 19, 2024
0a71397
Updated Windows snapshots
jsuarezruiz Mar 19, 2024
3595110
Updated Android snapshots
jsuarezruiz Mar 19, 2024
c3b3453
more snapshots
jsuarezruiz Mar 20, 2024
ac09bc8
More iOS snapshots
jsuarezruiz Mar 20, 2024
a494277
More Android snapshots
jsuarezruiz Mar 20, 2024
59459bb
Merge branch 'main' into fix-20614
jsuarezruiz Mar 20, 2024
66c7b76
Avoid reset the mainpage in some specific tests
jsuarezruiz Mar 21, 2024
d73b49e
Navigate to issues directly from MainPage
jsuarezruiz Mar 26, 2024
c0a9215
More changes
jsuarezruiz Mar 26, 2024
2ee9b64
Updated
jsuarezruiz Mar 26, 2024
ae9a20b
Merge branch 'main' into fix-20614
jsuarezruiz Apr 4, 2024
5b50164
Fix build errors
jsuarezruiz Apr 5, 2024
fd5f1e2
More fixes
jsuarezruiz Apr 5, 2024
dc48304
Merge branch 'main' into fix-20614
jsuarezruiz Apr 5, 2024
877b3be
Merge branch 'main' into fix-20614
jsuarezruiz Apr 8, 2024
882bc66
More fixes
jsuarezruiz Apr 8, 2024
3e9e103
Update more snapshots
jsuarezruiz Apr 8, 2024
3bcbe41
More fixes
jsuarezruiz Apr 8, 2024
d422fde
More fixes
jsuarezruiz Apr 8, 2024
9e2a296
More fixes
jsuarezruiz Apr 9, 2024
b4357a3
More fixes
jsuarezruiz Apr 9, 2024
9cfa3e5
Always reset the orientation
jsuarezruiz Apr 9, 2024
08fc395
Fix test
jsuarezruiz Apr 9, 2024
e18af1b
Merge branch 'main' into fix-20614
jsuarezruiz Apr 9, 2024
beeeee9
Update snapshots
jsuarezruiz Apr 9, 2024
c09dfed
Fix wrong snapshot
jsuarezruiz Apr 9, 2024
6710653
More fixes
jsuarezruiz Apr 10, 2024
03b2c63
Merge branch 'main' into fix-20614
jsuarezruiz Apr 16, 2024
eaf778a
Fix merge error
jsuarezruiz Apr 16, 2024
31b7bc2
Updated snapshots
jsuarezruiz Apr 18, 2024
30b27a2
Merge branch 'main' into fix-20614
jsuarezruiz Apr 25, 2024
144d22b
More fixes
jsuarezruiz Apr 25, 2024
899abac
More changes
jsuarezruiz Apr 25, 2024
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
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
using System;
using System.Threading.Tasks;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Internals;

namespace Maui.Controls.Sample
{
[Preserve(AllMembers = true)]
internal class CoreRootPage : Microsoft.Maui.Controls.ContentPage
internal class CoreRootPage : ContentPage
{
public CoreRootPage(Microsoft.Maui.Controls.Page rootPage)
public CoreRootPage(Page rootPage)
{
Title = "Core Gallery";

var corePageView = new CorePageView(rootPage);

var searchBar = new Microsoft.Maui.Controls.Entry()
var resetCheckBox = new CheckBox
{
AutomationId = "ResetMainPage",
VerticalOptions = LayoutOptions.Center,
};
var resetLabel = new Label
{
Text = "Reset MainPage",
VerticalOptions = LayoutOptions.Center,
};
var resetLayout = new HorizontalStackLayout
{
resetCheckBox,
resetLabel
};
resetLayout.HorizontalOptions = LayoutOptions.End;
resetLayout.Margin = new Microsoft.Maui.Thickness(12);

var searchBar = new Entry()
{
AutomationId = "SearchBar"
};
Expand All @@ -22,31 +42,57 @@ public CoreRootPage(Microsoft.Maui.Controls.Page rootPage)
corePageView.FilterPages(e.NewTextValue);
};

var testCasesButton = new Microsoft.Maui.Controls.Button
var testCasesButton = new Button
{
Text = "Go to Test Cases",
AutomationId = "GoToTestButton",
Command = new Microsoft.Maui.Controls.Command(async () =>
Command = new Command(async () =>
{
bool resetMainPage = resetCheckBox.IsChecked;

if (!string.IsNullOrEmpty(searchBar.Text))
{
await corePageView.PushPage(searchBar.Text);
try
{
bool navigated = await corePageView.PushPage(searchBar.Text);

if (!navigated)
{
var testCaseScreen = new TestCases.TestCaseScreen(resetMainPage);
await Task.Delay(50); // Load all the issues before try to navigate.

if (TestCases.TestCaseScreen.PageToAction.ContainsKey(searchBar.Text?.Trim()))
{
TestCases.TestCaseScreen.PageToAction[searchBar.Text?.Trim()]();
}
else if (!testCaseScreen.TryToNavigateTo(searchBar.Text?.Trim()))
{
throw new Exception($"Unable to Navigate to {searchBar.Text}");
}
}
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine(e.Message);
Console.WriteLine(e.Message);
}
}
else
{
await Navigation.PushModalAsync(TestCases.GetTestCases());
await Navigation.PushModalAsync(TestCases.GetTestCases(resetMainPage));
}
})
};

var stackLayout = new Microsoft.Maui.Controls.StackLayout()
var stackLayout = new StackLayout()
{
Children = {
resetLayout,
testCasesButton,
searchBar,
new Microsoft.Maui.Controls.Button {
new Button {
Text = "Click to Force GC",
Command = new Microsoft.Maui.Controls.Command(() => {
Command = new Command(() => {
GC.Collect ();
GC.WaitForPendingFinalizers ();
GC.Collect ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,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.Issue16094">
<ScrollView>
<ScrollView
AutomationId="TestScrollView">
<VerticalStackLayout
Spacing="25"
Padding="30,0"
Expand Down
118 changes: 74 additions & 44 deletions src/Controls/samples/Controls.Sample.UITests/TestCases.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -30,59 +30,79 @@ static TextCell MakeIssueCell(string text, string detail, Action tapped)
return cell;
}

Action ActivatePageAndNavigate(IssueAttribute issueAttribute, Type type)
Action ActivatePageAndNavigate(IssueAttribute issueAttribute, Type type, bool reset = false)
{
Action navigationAction = null;

if (issueAttribute.NavigationBehavior == NavigationBehavior.PushAsync)
if (reset)
{
return async () =>
{
var page = ActivatePage(type);
TrackOnInsights(page);
await Navigation.PushAsync(page);
};
}

if (issueAttribute.NavigationBehavior == NavigationBehavior.PushModalAsync)
{
return async () =>
return () =>
{
var page = ActivatePage(type);
TrackOnInsights(page);
await Navigation.PushModalAsync(page);
Application.Current.MainPage = page;
};
}

if (issueAttribute.NavigationBehavior == NavigationBehavior.Default)
else
{
return async () =>
if (issueAttribute.NavigationBehavior == NavigationBehavior.PushAsync)
{
var page = ActivatePage(type);
TrackOnInsights(page);
if (page is ContentPage /*|| page is CarouselPage*/)
return async () =>
{
var page = ActivatePage(type);
TrackOnInsights(page);
await Navigation.PushAsync(page);
}
else if (page is Shell)
{
Application.Current.MainPage = page;
}
else
};
}

if (issueAttribute.NavigationBehavior == NavigationBehavior.PushModalAsync)
{
return async () =>
{
var page = ActivatePage(type);
TrackOnInsights(page);
await Navigation.PushModalAsync(page);
}
};
}
};
}

if (issueAttribute.NavigationBehavior == NavigationBehavior.SetApplicationRoot)
{
return () =>
if (issueAttribute.NavigationBehavior == NavigationBehavior.Default)
{
var page = ActivatePage(type);
TrackOnInsights(page);
Application.Current.MainPage = page;
};
return async () =>
{
var page = ActivatePage(type);
TrackOnInsights(page);

var navigation = Navigation;

if (page.NavigationProxy.Inner is null)
{
navigation = Application.Current.MainPage.Navigation;
}

if (page is ContentPage)
{
await navigation.PushAsync(page);
}
else if (page is Shell)
{
Application.Current.MainPage = page;
}
else
{
await navigation.PushModalAsync(page);
}
};
}

if (issueAttribute.NavigationBehavior == NavigationBehavior.SetApplicationRoot)
{
return () =>
{
var page = ActivatePage(type);
TrackOnInsights(page);
Application.Current.MainPage = page;
};
}
}

return navigationAction;
Expand Down Expand Up @@ -140,7 +160,7 @@ public bool Matches(string filter)
}
}

readonly List<IssueModel> _issues;
List<IssueModel> _issues;
TableSection _section;

void VerifyNoDuplicates()
Expand All @@ -159,14 +179,26 @@ void VerifyNoDuplicates()
});
}

public TestCaseScreen()
public TestCaseScreen(bool resetMainPage = false)
{
ResetMainPage = resetMainPage;

AutomationId = "TestCasesIssueList";

Intent = TableIntent.Settings;

UpdateIssues();
}

internal bool ResetMainPage { get; set; }

public void UpdateIssues()
{
var assembly = typeof(TestCases).Assembly;

if (_issues is not null)
_issues.Clear();

_issues =
(from type in assembly.GetTypes()
let attribute = type.GetCustomAttribute<IssueAttribute>()
Expand All @@ -178,7 +210,7 @@ public TestCaseScreen()
IssueTestNumber = attribute.IssueTestNumber,
Name = attribute.DisplayName,
Description = attribute.Description,
Action = ActivatePageAndNavigate(attribute, type)
Action = ActivatePageAndNavigate(attribute, type, ResetMainPage)
}).ToList();

VerifyNoDuplicates();
Expand Down Expand Up @@ -300,7 +332,7 @@ from issueModel in _issues
bool IsExempt(string name) => _exemptNames.Contains(name);
}

public static NavigationPage GetTestCases()
public static NavigationPage GetTestCases(bool resetMainPage = false)
{
TestCaseScreen testCaseScreen = null;
var rootLayout = new StackLayout();
Expand Down Expand Up @@ -339,7 +371,6 @@ public static NavigationPage GetTestCases()
System.Diagnostics.Debug.WriteLine(e.Message);
Console.WriteLine(e.Message);
}

})
};

Expand All @@ -354,7 +385,7 @@ public static NavigationPage GetTestCases()
rootLayout.Children.Add(searchBar);
rootLayout.Children.Add(searchButton);

testCaseScreen = new TestCaseScreen();
testCaseScreen = new TestCaseScreen(resetMainPage);

rootLayout.Children.Add(CreateTrackerFilter(testCaseScreen));

Expand Down Expand Up @@ -421,5 +452,4 @@ static void SearchBarOnTextChanged(object sender, TextChangedEventArgs textChang
cases.FilterIssues(filter);
}
}

}
Loading