using System.Windows;
using System.Windows.Automation;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
using Titano.App.Infrastructure;
using Titano.App.Tests.Windows;
using Titano.Core.Localization;
using Titano.Testing;
using Titano.Ui.Controls;
using Titano.Ui.Theming;
using Titano.Uploader.DesignTime;
using Titano.Uploader.Shell;
using Titano.Uploader.Uploads;
namespace Titano.App.Tests.Uploader;
///
/// The uploader window on the --capture sample data, shown off screen: icon-only buttons and queue rows are
/// named for screen readers, rows take keyboard focus, no field shows an error before use, disabled controls say
/// why, and in a right-to-left language the window mirrors while paths, file names and the media glyph do not.
///
[WindowsOnly]
[Serial]
[Timeout(120_000)]
public sealed class UploaderScreenSmokeTests
{
[Test]
public Task EveryScreenIsNamedFocusableAndCalm() => ScreenHost.RunAsync(async () =>
{
UiLanguage.Apply("en");
using var screen = await UploaderScreen.OpenAsync();
var vm = screen.ViewModel;
screen.Sample.ShowConnect();
await screen.SettleAsync();
Assert.Equal(FlowDirection.LeftToRight, screen.Window.FlowDirection);
Assert.False(vm.Connect.HasErrors, "the address is not marked before a sign-in");
Assert.Null(vm.Connect.PasswordError);
Assert.Null(vm.Connect.ErrorText);
foreach (var box in screen.Visible())
Assert.False(Validation.GetHasError(box), $"{AutomationProperties.GetName(box)} shows an error before use");
Assert.False(screen.Named("PasswordErrorRing").IsVisible, "the password box shows no error before use");
screen.AssertIconButtonsNamed("connect");
// Enter signs in from the form, not from the settings panel drawn over it.
var signIn = screen.Visible