This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Ordering children while adding #8231
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3d88f4f
Ordering children while adding
memsranga c70f783
Abstract OrderElement
memsranga 3c8d1cc
Re-order on runtime child addition and Tests
memsranga dbb71a4
Runtime addition ensures Z Index
memsranga 4e1c18a
Stop performance measurement on return
jfversluis d1c95f6
Update VisualElementPackager.cs
jfversluis b7a1449
Merge branch '5.0.0' into Issue8129
jsuarezruiz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue8129.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Xamarin.Forms.CustomAttributes; | ||
using Xamarin.Forms.Internals; | ||
using System; | ||
|
||
#if UITEST | ||
using Xamarin.Forms.Core.UITests; | ||
using Xamarin.UITest; | ||
using NUnit.Framework; | ||
#endif | ||
|
||
namespace Xamarin.Forms.Controls.Issues | ||
{ | ||
[Preserve(AllMembers = true)] | ||
[Issue(IssueTracker.Github, 8129, "[Bug] Adding children to iOS VisualElementPackager has O(N^2) performance and thrashes the native layer", PlatformAffected.iOS)] | ||
public class Issue8129 : TestContentPage | ||
{ | ||
protected override void Init() | ||
{ | ||
Title = "Page with too many elements (2000) Tests"; | ||
|
||
var grid = new Grid(); | ||
var stackLayout = new StackLayout(); | ||
|
||
var addChildrenCommand = new Command((parameter) => | ||
{ | ||
Enumerable | ||
.Range(0, 2000) | ||
.Select(_ => new Label() { HeightRequest = 200, Text = $"I am Label #{_}" }) | ||
.ForEach(x => stackLayout.Children.Add(x)); | ||
}); | ||
|
||
var addChildrenButton = new Button | ||
{ | ||
Text = "Add 2000 Labels", | ||
Command = addChildrenCommand | ||
}; | ||
|
||
var addZChildrenButton = new Button | ||
{ | ||
Text = "Add BoxView on Top", | ||
Command = new Command((parameter) => | ||
{ | ||
grid.AddChild(new BoxView | ||
{ | ||
HeightRequest = 300, | ||
WidthRequest = 300, | ||
BackgroundColor = Color.Green | ||
}, 0, 0, 1, 3); | ||
}) | ||
}; | ||
grid.AddChild(addChildrenButton, 0, 0); | ||
grid.AddChild(addZChildrenButton, 0, 1); | ||
grid.AddChild(stackLayout, 0, 2); | ||
|
||
Content = grid; | ||
} | ||
#if UITEST | ||
[Test] | ||
public void AddTooManyContentsTest() | ||
{ | ||
RunningApp.WaitForElement(q => q.Button("Add 2000 Labels")); | ||
RunningApp.Screenshot("Before adding 2000 Labels"); | ||
RunningApp.Tap(q => q.Button("Add 2000 Labels")); | ||
RunningApp.WaitForElement(q => q.Marked("I am Label #1")); | ||
RunningApp.Screenshot("After adding 2000 Labels"); | ||
} | ||
|
||
[Test] | ||
public void ZIndexAfterAddingContentsTest() | ||
{ | ||
RunningApp.WaitForElement(q => q.Button("Add BoxView on Top")); | ||
RunningApp.Screenshot("Before adding BoxView on Top"); | ||
RunningApp.Tap(q => q.Button("Add BoxView on Top")); | ||
RunningApp.WaitForNoElement(q => q.Button("Add BoxView on Top")); | ||
RunningApp.Screenshot("After adding BoxView on Top"); | ||
} | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add some tests validating the logic to order and ensure the order of the elements?