-
Notifications
You must be signed in to change notification settings - Fork 724
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(NativeFramePresenter): [Android] Don't detach pages in the backs…
…tack The behavior is now similar to the one from the iOS NativeFramePresenter, which keeps all pages loaded and stacked on top of each other. The behavior can be altered by using `FeatureConfiguration.NativeFramePresenter.AndroidUnloadInactivePages`, which is set to false by default.
- Loading branch information
1 parent
f38ccd3
commit 7253faf
Showing
3 changed files
with
95 additions
and
3 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_NativeFrame.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,78 @@ | ||
#if __ANDROID__ | ||
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Private.Infrastructure; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml; | ||
using System.Threading.Tasks; | ||
using System.Diagnostics; | ||
|
||
namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Controls | ||
{ | ||
[TestClass] | ||
public class Given_NativeFrame | ||
{ | ||
[TestMethod] | ||
[RunsOnUIThread] | ||
public async Task When_NavigateForward() | ||
{ | ||
var style = Windows.UI.Xaml.Application.Current.Resources["NativeDefaultFrame"] as Style; | ||
Assert.IsNotNull(style); | ||
|
||
var SUT = new Frame() { | ||
Style = style | ||
}; | ||
|
||
TestServices.WindowHelper.WindowContent = SUT; | ||
|
||
int GetAllMyPages() | ||
=> SUT.EnumerateAllChildren(v => v is MyPage).Count(); | ||
|
||
/// Actively waiting for pages to be stacked is | ||
/// required as NativeFramePresenter.UpdateStack awaits | ||
/// for animations to finish, and there's no way to determine | ||
/// from the Frame PoV that the animation is finished. | ||
async Task WaitForPages(int count) | ||
{ | ||
var sw = Stopwatch.StartNew(); | ||
|
||
while(sw.Elapsed < TimeSpan.FromSeconds(5)) | ||
{ | ||
await TestServices.WindowHelper.WaitForIdle(); | ||
|
||
if (GetAllMyPages() == count) | ||
{ | ||
break; | ||
} | ||
} | ||
|
||
Assert.AreEqual(count, GetAllMyPages()); | ||
} | ||
|
||
await WaitForPages(0); | ||
|
||
SUT.Navigate(typeof(MyPage)); | ||
|
||
await WaitForPages(1); | ||
|
||
SUT.Navigate(typeof(MyPage)); | ||
|
||
await WaitForPages(2); | ||
|
||
SUT.GoBack(); | ||
|
||
await WaitForPages(1); | ||
} | ||
} | ||
|
||
partial class MyPage : Page | ||
{ | ||
} | ||
} | ||
#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