Skip to content

Commit

Permalink
- fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PureWeen committed Jan 31, 2023
1 parent 5f38a5c commit 9752979
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ internal static async void SetupMenu(

if (loadTasks.Count > 0)
await Task.WhenAll(loadTasks);

foreach (var menuItem in menuItems)
menuItem.Dispose();
}

internal static void SetMenuItemTitle(IMenuItem menuItem, string title)
Expand All @@ -147,8 +144,13 @@ internal static async Task SetMenuItemIcon(IMenuItem menuItem, ImageSource sourc
source,
context.Context);

if (menuItem.IsAlive() && result is not null)
menuItem.SetIcon(result.Value);
if (menuItem.IsAlive())
{
if (result is not null)
menuItem.SetIcon(result.Value);
else
menuItem.SetIcon(null);
}
}

public static BottomSheetDialog CreateMoreBottomSheet(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,16 @@ await CreateHandlerAndAddToWindow<ShellRenderer>(shell, async (handler) =>
var menuItem2 = menu.GetItem(1);
var menuItem2Icon = menuItem2.Icon;

shell.CurrentItem.Items.Insert(1, new Tab() { Items = { new ContentPage() }, Title = "Tab 2", Icon = "purple.png" });
shell.CurrentItem.Items.Insert(1, new Tab() { Items = { new ContentPage() }, Title = "Tab 2", Icon = "green.png" });

// let the change propagate
await AssertionExtensions.Wait(() => bottomView.Menu.GetItem(1).Icon != menuItem2Icon);

menu = bottomView.Menu;
Assert.Equal(menuItem1, menu.GetItem(0));
Assert.Equal(menuItem2, menu.GetItem(1));

menu.GetItem(1).Icon.AssertColorAtCenter(Android.Graphics.Color.Purple);
menu.GetItem(1).Icon.AssertColorAtCenter(Android.Graphics.Color.Green);
menu.GetItem(2).Icon.AssertColorAtCenter(Android.Graphics.Color.Red);
});
}
Expand Down

0 comments on commit 9752979

Please sign in to comment.