Skip to content

Commit

Permalink
fix: Revert "Keep track of current view type even if content is set t…
Browse files Browse the repository at this point in the history
…o null"
  • Loading branch information
jeromelaban committed Jan 21, 2021
1 parent 5c4862e commit 882662a
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 140 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

#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;
Expand All @@ -12,14 +12,12 @@
using Windows.UI.Xaml;
using System.Threading.Tasks;
using System.Diagnostics;
using Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Controls.FramePages;

namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Controls
{
[TestClass]
public class Given_NativeFrame
{
#if __ANDROID__
[TestMethod]
[RunsOnUIThread]
public async Task When_NavigateForward()
Expand Down Expand Up @@ -71,48 +69,10 @@ async Task WaitForPages(int count)

await WaitForPages(1);
}
#endif
[TestMethod]
[RunsOnUIThread]
public async Task When_ContentIsNullAndNavigate()
{
#if !NETFX_CORE
var style = Windows.UI.Xaml.Application.Current.Resources["NativeDefaultFrame"] as Style;
Assert.IsNotNull(style);

var SUT = new Frame()
{
Style = style
};
#else
var SUT = new Frame();
#endif

TestServices.WindowHelper.WindowContent = SUT;

SUT.Navigate(typeof(FirstPage));

var firstPage = SUT.Content as FirstPage;

Assert.IsNotNull(firstPage.FirstTextBlock);
Assert.AreEqual("Page The First", firstPage.FirstTextBlock.Text);

SUT.Content = null;
SUT.BackStack?.Clear();


SUT.Navigate(typeof(SecondPage));
var secondPage = SUT.Content as SecondPage;

Assert.IsNotNull(SUT.BackStack.FirstOrDefault());
Assert.AreEqual(typeof(FirstPage), SUT.BackStack.FirstOrDefault().SourcePageType);

Assert.IsNotNull(secondPage.SecondTextBlock);
Assert.AreEqual("Page The Second", secondPage.SecondTextBlock.Text);
}
}

partial class MyPage : Page
{
}
}
#endif
10 changes: 0 additions & 10 deletions src/Uno.UI.RuntimeTests/Uno.UI.RuntimeTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,6 @@
</ProjectReference>
</ItemGroup>

<ItemGroup>
<None Remove="Tests\Windows_UI_Xaml_Controls\FramePages\FirstPage.xaml" />
<None Remove="Tests\Windows_UI_Xaml_Controls\FramePages\SecondPage.xaml" />
</ItemGroup>

<ItemGroup>
<UpToDateCheckInput Remove="Tests\Windows_UI_Xaml_Controls\FramePages\FirstPage.xaml" />
<UpToDateCheckInput Remove="Tests\Windows_UI_Xaml_Controls\FramePages\SecondPage.xaml" />
</ItemGroup>

<ItemGroup>
<Compile Include="Tests\Windows_UI_Xaml_Controls\HtmlElementAttributeTests\Given_HtmlElementAttribute.Wasm.cs" />
</ItemGroup>
Expand Down
11 changes: 11 additions & 0 deletions src/Uno.UI/UI/Xaml/Controls/Frame/Frame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ public Frame()

internal PageStackEntry CurrentEntry { get; set; }

protected override void OnContentChanged(object oldValue, object newValue)
{
base.OnContentChanged(oldValue, newValue);

// Make sure we void CurrentEntry when someone sets Frame.Content = null;
if (newValue == null)
{
CurrentEntry = null;
}
}

#region BackStackDepth DependencyProperty

public int BackStackDepth
Expand Down

0 comments on commit 882662a

Please sign in to comment.