diff --git a/src/UniGetUI.Avalonia/Views/SidebarView.axaml b/src/UniGetUI.Avalonia/Views/SidebarView.axaml index 6a2afb1b96..e97bf88a5f 100644 --- a/src/UniGetUI.Avalonia/Views/SidebarView.axaml +++ b/src/UniGetUI.Avalonia/Views/SidebarView.axaml @@ -97,7 +97,7 @@ FontSize="9" FontWeight="Bold" Foreground="{DynamicResource TextOnAccentFillColorPrimaryBrush}" - HorizontalAlignment="Center" + TextAlignment="Center" VerticalAlignment="Center"/> _session.Dispatch(() => + { + if (!Application.Current!.Styles.OfType().Any()) + Application.Current.Styles.Add(new FluentTheme()); + + var vm = new SidebarViewModel { UpdatesBadgeCount = count }; + var view = new SidebarView { DataContext = vm }; + var window = new Window { Width = 300, Height = 700, Content = view }; + window.SetRenderScaling(scaling); + window.Show(); + window.UpdateLayout(); + Dispatcher.UIThread.RunJobs(); + + ListBoxItem updates = view.FindControl("NavListBox")!.Items.OfType() + .Single(item => (string?)item.Tag == "Updates"); + TextBlock text = updates.GetVisualDescendants().OfType().Single(block => block.Text == vm.UpdatesBadgeText); + var badge = (Border)text.Parent!; + TextLine line = text.TextLayout.TextLines.Single(); + + double textLeft = text.TranslatePoint(new Point(line.Start, 0), badge)!.Value.X; + double textRight = textLeft + line.WidthIncludingTrailingWhitespace; + + Assert.True(badge.IsEffectivelyVisible); + Assert.Equal(badge.Bounds.Width - textRight, textLeft, 0.01); + window.Close(); + }, CancellationToken.None); +}