using System.Windows; using System.Windows.Automation; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using Titano.App.Jobs; using Titano.App.Sections; using Titano.App.Shell; using Titano.App.Tests.Windows; using Titano.Core.Localization; using Titano.Testing; using Titano.Ui.Controls; namespace Titano.App.Tests.Jobs; /// The Jobs screen on the capture sample: keyboard reach, names for screen readers, counts and the table's columns. [WindowsOnly] [Serial] [Timeout(300_000)] public sealed class JobsScreenSmokeTests { [Test] public Task RowsAreReachableNamedAndLinedUpWithTheHeader() => ScreenHost.RunAsync(async () => { await using var app = await ScreenSmokeTests.SampleApp.StartAsync(); var shell = app.Shell; await app.Sample.FillAsync(); await shell.Jobs.ReloadAsync(); shell.Navigate(SectionKey.Jobs); await app.ExpectAsync("jobs"); var jobs = shell.Jobs; // The rail badge, the status strip and the Running chip count the same jobs. var running = jobs.Chips.Single(c => c.Filter == JobFilter.Running).Count; Assert.Greater(running, 0); Assert.Equal(running, jobs.Badge); Assert.Equal(Loc.Plural("Shell.Status.Jobs", running), shell.JobsText); // The capture engine starts no workers: there is no "Workers n / 0" to show. Assert.False(jobs.HasWorkers); // Tab reaches every row button: the rows take no focus, the list passes Tab on to their content. var list = app.FindAll().Single(l => l.Name == "JobList"); Assert.Equal(KeyboardNavigationMode.Continue, KeyboardNavigation.GetTabNavigation(list)); var items = app.FindAll().Where(i => i.DataContext is JobRowViewModel && i.IsVisible).ToList(); Assert.True(items.Count > 3, "several rows are on screen"); foreach (var item in items) { var row = (JobRowViewModel)item.DataContext; // A row reads as its job and state; its buttons and its log toggle name the job. Assert.Equal(row.AccessibleName, AutomationProperties.GetName(item)); Assert.Equal(row.StateText, AutomationProperties.GetItemStatus(item)); var buttons = Descendants