Skip to content

Commit

Permalink
Merge pull request #905 from unoplatform/mergify/bp/release/stable/4.…
Browse files Browse the repository at this point in the history
…2/pr-902

fix: Ensure bindings are set once presenter has owner set (backport #902)
  • Loading branch information
jeromelaban committed Nov 6, 2023
2 parents 8099e1b + 5a344ec commit bcd2753
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
19 changes: 18 additions & 1 deletion src/Uno.Toolkit.RuntimeTests/Tests/NavigationBarTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using Uno.Toolkit.UI;
using Uno.UI.RuntimeTests;
using Windows.System;

using Windows.Foundation;
#if __IOS__
using UIKit;
#endif
Expand Down Expand Up @@ -40,6 +40,23 @@ namespace Uno.Toolkit.RuntimeTests.Tests
[RunsOnUIThread]
internal partial class NavigationBarTests
{
#if !(__ANDROID__ || __IOS__)
[TestMethod]
public async Task NavigationBar_Renders_MainCommand()
{
var mainCommand = new AppBarButton();
var navigationBar = new NavigationBar { Content = "Title", MainCommandMode = MainCommandMode.Action, MainCommand = mainCommand };
var content = new Grid { Children = { navigationBar } };

await UnitTestUIContentHelperEx.SetContentAndWait(content);


Assert.IsTrue(mainCommand.ActualHeight > 0, "MainCommand.ActualHeight is not greater than 0");
Assert.IsTrue(mainCommand.ActualWidth > 0, "MainCommand.ActualWidth is not greater than 0");
}

#endif

[TestMethod]
[DataRow(MainCommandMode.Back, DisplayName = nameof(MainCommandMode.Back))]
[DataRow(MainCommandMode.Action, DisplayName = nameof(MainCommandMode.Action))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public void SetOwner(NavigationBar? owner)
return;
}

_weakNavBar = new WeakReference<NavigationBar?>(owner);
_weakNavBar = new WeakReference<NavigationBar?>(owner);
SetBindings();
}
protected override void OnApplyTemplate()
{
Expand Down

0 comments on commit bcd2753

Please sign in to comment.