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
45 changes: 21 additions & 24 deletions src/Controls/tests/TestCases.HostApp/CoreViews/CorePageView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Maui.Controls.Sample
{
internal class CorePageView : ListView
internal class CorePageView : CollectionView
{
internal class GalleryPageFactory
{
Expand Down Expand Up @@ -87,43 +87,40 @@ public CorePageView(Page rootPage)

var template = new DataTemplate(() =>
{
var cell = new TextCell();
cell.ContextActions.Add(new MenuItem
var cell = new Grid();

var label = new Label
{
Text = "Select Visual",
Command = new Command(async () =>
{
var buttons = typeof(VisualMarker).GetProperties().Select(p => p.Name);
var selection = await rootPage.DisplayActionSheet("Select Visual", "Cancel", null, buttons.ToArray());
if (cell.BindingContext is GalleryPageFactory pageFactory)
{
var page = pageFactory.Realize();
if (typeof(VisualMarker).GetProperty(selection)?.GetValue(null) is IVisual visual)
{
page.Visual = visual;
}
await PushPage(page);
}
})
});
FontSize = 14,
VerticalOptions = LayoutOptions.Center,
Margin = new Thickness(6)
};

label.SetBinding(Label.TextProperty, "Title");
label.SetBinding(Label.AutomationIdProperty, "TitleAutomationId");

cell.Add(label);

return cell;
});

template.SetBinding(TextCell.TextProperty, "Title");
template.SetBinding(TextCell.AutomationIdProperty, "TitleAutomationId");

ItemTemplate = template;
ItemsSource = _pages;
SelectionMode = SelectionMode.Single;

ItemSelected += (sender, args) =>
SelectionChanged += (sender, args) =>
{
if (SelectedItem == null)
{
return;
}

var item = args.SelectedItem;
var selection = args.CurrentSelection;

if (selection.Count == 0)
return;

var item = args.CurrentSelection[0];
if (item is GalleryPageFactory page)
{
var realize = page.Realize();
Expand Down
51 changes: 31 additions & 20 deletions src/Controls/tests/TestCases.HostApp/CoreViews/CoreRootPage.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
namespace Maui.Controls.Sample
{
internal class CoreRootPage : Microsoft.Maui.Controls.ContentPage
internal class CoreRootPage : ContentPage
{
public CoreRootPage(Microsoft.Maui.Controls.Page rootPage)
public CoreRootPage(Page rootPage)
{
Title = "Controls TestCases";

var corePageView = new CorePageView(rootPage);

var searchBar = new Microsoft.Maui.Controls.Entry()
var searchBar = new Entry()
{
AutomationId = "SearchBar"
};
Expand All @@ -18,11 +18,11 @@ 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 () =>
{
if (!string.IsNullOrEmpty(searchBar.Text))
{
Expand All @@ -35,26 +35,37 @@ public CoreRootPage(Microsoft.Maui.Controls.Page rootPage)
})
};

var stackLayout = new Microsoft.Maui.Controls.StackLayout()
var rootLayout = new Grid();
rootLayout.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
rootLayout.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
rootLayout.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
rootLayout.RowDefinitions.Add(new RowDefinition { Height = GridLength.Star });


rootLayout.Add(testCasesButton);
Grid.SetRow(testCasesButton, 0);

rootLayout.Add(searchBar);
Grid.SetRow(searchBar, 1);

var gcButton = new Button
{
Children = {
testCasesButton,
searchBar,
new Microsoft.Maui.Controls.Button {
Text = "Click to Force GC",
Command = new Microsoft.Maui.Controls.Command(() => {
GC.Collect ();
GC.WaitForPendingFinalizers ();
GC.Collect ();
})
},
corePageView
}
Text = "Click to Force GC",
Command = new Command(() => {
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
})
};
rootLayout.Add(gcButton);
Grid.SetRow(gcButton, 2);

rootLayout.Add(corePageView);
Grid.SetRow(corePageView, 3);

AutomationId = "Gallery";

Content = stackLayout;
Content = rootLayout;
}
}
}
105 changes: 65 additions & 40 deletions src/Controls/tests/TestCases.HostApp/TestCases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Maui.Controls.Sample
{
public static class TestCases
{
public class TestCaseScreen : TableView
public class TestCaseScreen : CollectionView
{
public static Dictionary<string, Action> PageToAction = new Dictionary<string, Action>(StringComparer.OrdinalIgnoreCase);

Expand Down Expand Up @@ -44,18 +44,6 @@ void CheckInternetAndLoadPage(Type type)
}
}


static TextCell MakeIssueCell(string text, string detail, Action tapped)
{
PageToAction[text] = tapped;
if (detail != null)
PageToAction[detail] = tapped;

var cell = new TextCell { Text = text, Detail = detail };
cell.Tapped += (s, e) => tapped();
return cell;
}

Action ActivatePageAndNavigate(IssueAttribute issueAttribute, Type type)
{
Action navigationAction = null;
Expand Down Expand Up @@ -148,7 +136,6 @@ public bool Matches(string filter)
}

readonly List<IssueModel> _issues;
TableSection _section;

void VerifyNoDuplicates()
{
Expand All @@ -170,8 +157,6 @@ public TestCaseScreen()
{
AutomationId = "TestCasesIssueList";

Intent = TableIntent.Settings;

var assembly = typeof(TestCases).Assembly;

#if NATIVE_AOT
Expand Down Expand Up @@ -245,17 +230,17 @@ public void FilterIssues(string filter = null)

PageToAction.Clear();

var issueCells = Enumerable.Empty<TextCell>();
var issues = Enumerable.Empty<IssueModel>();

if (!_filterBugzilla)
{
var bugzillaIssueCells =
from issueModel in _issues
where issueModel.IssueTracker == IssueTracker.Bugzilla && issueModel.Matches(filter)
orderby issueModel.IssueNumber descending
select MakeIssueCell(issueModel.Name, issueModel.Description, issueModel.Action);
select issueModel;

issueCells = issueCells.Concat(bugzillaIssueCells);
issues = issues.Concat(bugzillaIssueCells);
}

if (!_filterGitHub)
Expand All @@ -264,9 +249,9 @@ orderby issueModel.IssueNumber descending
from issueModel in _issues
where issueModel.IssueTracker == IssueTracker.Github && issueModel.Matches(filter)
orderby issueModel.IssueNumber descending
select MakeIssueCell(issueModel.Name, issueModel.Description, issueModel.Action);
select issueModel;

issueCells = issueCells.Concat(githubIssueCells);
issues = issues.Concat(githubIssueCells);
}

if (!_filterManual)
Expand All @@ -275,9 +260,9 @@ orderby issueModel.IssueNumber descending
from issueModel in _issues
where issueModel.IssueTracker == IssueTracker.ManualTest && issueModel.Matches(filter)
orderby issueModel.IssueNumber descending
select MakeIssueCell(issueModel.Name, issueModel.Description, issueModel.Action);
select issueModel;

issueCells = issueCells.Concat(manualIssueCells);
issues = issues.Concat(manualIssueCells);
}

if (!_filterNone)
Expand All @@ -286,24 +271,53 @@ orderby issueModel.IssueNumber descending
from issueModel in _issues
where issueModel.IssueTracker == IssueTracker.None && issueModel.Matches(filter)
orderby issueModel.IssueNumber descending, issueModel.Description
select MakeIssueCell(issueModel.Name, issueModel.Description, issueModel.Action);
select issueModel;

issueCells = issueCells.Concat(untrackedIssueCells);
issues = issues.Concat(untrackedIssueCells);
}

if (_section != null)
ItemTemplate = new DataTemplate(() =>
{
Root.Remove(_section);
}
var grid = new Grid
{
Padding = 10,
RowDefinitions =
{
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Star }
}
};

_section = new TableSection("Bug Repro");
var tapGestureRecognizer = new TapGestureRecognizer();
tapGestureRecognizer.Tapped += (sender, args) =>
{
var issueModel = (IssueModel)grid.BindingContext;
issueModel.Action?.Invoke();
};
grid.GestureRecognizers.Add(tapGestureRecognizer);

foreach (var issueCell in issueCells)
{
_section.Add(issueCell);
}
var titleLabel = new Label
{
FontSize = 14,
FontAttributes = FontAttributes.Bold,
};
titleLabel.SetBinding(Label.TextProperty, "IssueNumber");

var descriptionLabel = new Label
{
FontSize = 12,
};
descriptionLabel.SetBinding(Label.TextProperty, "Description");

Root.Add(_section);
grid.Add(titleLabel);
Grid.SetRow(titleLabel, 0);
grid.Add(descriptionLabel);
Grid.SetRow(descriptionLabel, 1);

return grid;
});

ItemsSource = issues;
}

HashSet<string> _exemptNames = new HashSet<string> { };
Expand All @@ -316,7 +330,13 @@ from issueModel in _issues
public static NavigationPage GetTestCases()
{
TestCaseScreen testCaseScreen = null;
var rootLayout = new StackLayout();
var rootLayout = new Grid();

rootLayout.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
rootLayout.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
rootLayout.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
rootLayout.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
rootLayout.RowDefinitions.Add(new RowDefinition { Height = GridLength.Star });

var testCasesRoot = new ContentPage
{
Expand Down Expand Up @@ -352,7 +372,6 @@ public static NavigationPage GetTestCases()
System.Diagnostics.Debug.WriteLine(e.Message);
Console.WriteLine(e.Message);
}

})
};

Expand All @@ -364,14 +383,21 @@ public static NavigationPage GetTestCases()
};

rootLayout.Children.Add(leaveTestCasesButton);
Grid.SetRow(leaveTestCasesButton, 0);

rootLayout.Children.Add(searchBar);
rootLayout.Children.Add(searchButton);
Grid.SetRow(searchBar, 1);

testCaseScreen = new TestCaseScreen();
rootLayout.Children.Add(searchButton);
Grid.SetRow(searchButton, 2);

rootLayout.Children.Add(CreateTrackerFilter(testCaseScreen));
var trackerFilter = CreateTrackerFilter(testCaseScreen);
rootLayout.Children.Add(trackerFilter);
Grid.SetRow(trackerFilter, 3);

testCaseScreen = new TestCaseScreen();
rootLayout.Children.Add(testCaseScreen);
Grid.SetRow(testCaseScreen, 4);

searchBar.TextChanged += (sender, args) => SearchBarOnTextChanged(sender, args, testCaseScreen);

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

}
Loading