test(postit): run all Avalonia UI tests in the shared collection fixture
Replace [AvaloniaFact]/[AvaloniaTheory] and direct GetOrStartForAssembly dispatches with ui.RunAsync in AvaloniaUiCollection, avoiding a second headless session that could hang PodcastBroadcasterTests. Add a synchronous RunAsync overload and update MessagingSessionTests contact-preference assertions for the audio-only capabilities announced on Linux desktop. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
4493ac0149
commit
8ab3c02ebc
27 changed files with 443 additions and 332 deletions
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
### Fixed
|
||||
|
||||
* [PostIt.Tests] Run every Avalonia UI test in the shared `AvaloniaUiCollection` fixture: replace `[AvaloniaFact]`/`[AvaloniaTheory]` and direct `GetOrStartForAssembly` dispatches, which started a second headless session alongside the fixture's and could hang `PodcastBroadcasterTests`, with `ui.RunAsync` (new synchronous overload). Update contact-preference assertions in `MessagingSessionTests` for the audio-only capabilities the Linux desktop announces.
|
||||
|
||||
* [PostIt/Podcasts] Reuse the replay playback controls for live video on desktop and Android, remove the duplicate play/pause button, and retain seeking only for replays. Report resume failures and cover playback controls with targeted tests.
|
||||
|
||||
* [PostIt] Restore selectable error notification messages and update blog and rendez-vous tests for the current layouts and address editor.
|
||||
|
|
|
|||
|
|
@ -69,8 +69,8 @@ CRUD creent et manipulent leurs propres commandes par identifiant.
|
|||
## Isolation des tests PostIt
|
||||
|
||||
L'assemblee `src/PostIt/PostIt.Tests` execute ses collections xUnit sans
|
||||
parallelisme. Les tests `[AvaloniaFact]`/`[AvaloniaTheory]` reinitialisent le
|
||||
runtime Avalonia entre tests ; des tests ordinaires utilisent aussi
|
||||
parallelisme. Les tests UI reinitialisent l'application Avalonia entre
|
||||
dispatchs ; des tests ordinaires utilisent aussi
|
||||
`App.Current` et les delegates statiques de `Platform`. Leur execution
|
||||
concurrente peut creer le dispatcher sur un autre thread ou utiliser une
|
||||
application appartenant a un test headless en cours, avec une erreur de
|
||||
|
|
@ -80,16 +80,31 @@ Conserver provisoirement cette isolation dans `Fixtures/TestApp.cs`. Les tests q
|
|||
intentionnellement plusieurs operations concurrentes peuvent toujours le faire
|
||||
dans leur propre methode ; les autres assemblees de tests ne sont pas affectees.
|
||||
|
||||
### Migration progressive vers une fixture UI
|
||||
### Fixture UI partagee
|
||||
|
||||
La collection `[Collection(AvaloniaUiCollection.Name)]` fournit
|
||||
Tous les tests UI de PostIt appartiennent a la collection
|
||||
`[Collection(AvaloniaUiCollection.Name)]`, qui fournit
|
||||
`AvaloniaUiFixture` par injection de constructeur. La fixture possede sa
|
||||
session `HeadlessUnitTestSession`, initialise le runtime sur son thread UI et
|
||||
arrete ce thread a la fin de la collection. Les tests migres utilisent `[Fact]`
|
||||
ou `[Theory]`, pas `[AvaloniaFact]` : la fixture assure elle-meme le dispatch.
|
||||
arrete ce thread a la fin de la collection. Les tests utilisent `[Fact]` ou
|
||||
`[Theory]`, jamais `[AvaloniaFact]`/`[AvaloniaTheory]` ni
|
||||
`HeadlessUnitTestSession.GetOrStartForAssembly` : ces deux mecanismes
|
||||
demarreraient une seconde session headless concurrente de celle de la fixture.
|
||||
|
||||
`RunAsync` execute du code sur le thread UI. `WithWindowAsync` cree le contenu
|
||||
et la fenetre sur ce thread, affiche la fenetre, effectue le layout, puis la
|
||||
`RunAsync` execute du code sur le thread UI, avec un corps synchrone (`Action`)
|
||||
ou asynchrone (`Func<Task>`) ; un test UI enveloppe tout son corps dans un seul
|
||||
appel :
|
||||
|
||||
```csharp
|
||||
[Fact]
|
||||
public Task Settings_page_binds() => ui.RunAsync(() =>
|
||||
{
|
||||
var window = new Window { Content = new SettingsPage() };
|
||||
// ...
|
||||
}, TestContext.Current.CancellationToken);
|
||||
```
|
||||
|
||||
`WithWindowAsync` cree le contenu et la fenetre sur ce thread, affiche la fenetre, effectue le layout, puis la
|
||||
ferme et detache ses bindings en `finally`, meme si une assertion echoue :
|
||||
|
||||
```csharp
|
||||
|
|
@ -109,13 +124,12 @@ public sealed class ExampleTests(AvaloniaUiFixture ui)
|
|||
}
|
||||
```
|
||||
|
||||
Le pilote est `SubscriptionsPageTests`. Le thread est conserve pour la
|
||||
collection, mais l'application reste isolee **par dispatch** : conserver une
|
||||
application unique des maintenant changerait l'isolation des anciens tests
|
||||
Le thread est conserve pour la collection, mais l'application reste isolee
|
||||
**par dispatch** : conserver une application unique changerait l'isolation des tests
|
||||
et risquerait de partager navigation, services et preferences. Ne pas conserver
|
||||
de controles entre dispatchs dans les tests metier. La protection globale
|
||||
contre le parallelisme reste necessaire tant que les autres consommateurs
|
||||
d'Avalonia et de l'etat statique ne sont pas migres.
|
||||
contre le parallelisme reste necessaire : des tests ordinaires, hors de la
|
||||
collection, utilisent encore `App.Current` et l'etat statique de `Platform`.
|
||||
|
||||
## EF Core en test
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using Avalonia.Threading;
|
||||
using PostIt.ViewModels;
|
||||
using PostIt.Views;
|
||||
|
|
@ -8,10 +7,12 @@ using PostIt.Views;
|
|||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class ActivityNavigationTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public class ActivityNavigationTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
[AvaloniaFact]
|
||||
public async Task Activity_recreation_restores_fresh_pages_and_back_navigation()
|
||||
[Fact]
|
||||
public Task Activity_recreation_restores_fresh_pages_and_back_navigation()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var app = Assert.IsType<App>(Application.Current);
|
||||
var previousView = app.View;
|
||||
|
|
@ -57,5 +58,5 @@ public class ActivityNavigationTests
|
|||
window.Close();
|
||||
app.AttachMainWindow(previousView ?? new MainView());
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
using Avalonia;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using PostIt.Services;
|
||||
using PostIt.ViewModels;
|
||||
|
|
@ -29,7 +28,8 @@ namespace PostIt.Tests;
|
|||
/// any async command before asserting.</para>
|
||||
/// </summary>
|
||||
[Trait("Category", "non-reg")]
|
||||
public class AddCircleMemberDialogTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public class AddCircleMemberDialogTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
/// <summary>
|
||||
/// Stand-in <see cref="IUserDirectory"/> that returns an
|
||||
|
|
@ -120,8 +120,9 @@ public class AddCircleMemberDialogTests
|
|||
/// Click the "Fermer" button on the dialog and assert the
|
||||
/// nav stack shrinks by exactly one.
|
||||
/// </summary>
|
||||
[AvaloniaFact]
|
||||
public async Task Close_button_pops_dialog_off_nav_stack()
|
||||
[Fact]
|
||||
public Task Close_button_pops_dialog_off_nav_stack()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
// Arrange: stack starts at 2 (CirclesPage + dialog).
|
||||
var context = await Mount();
|
||||
|
|
@ -149,5 +150,5 @@ public class AddCircleMemberDialogTests
|
|||
Assert.True(window.NavRoot.NavigationStack.Count == stackBefore - 1,
|
||||
$"Click on 'Fermer' must shrink the nav stack by one. Before: {stackBefore}, after: {window.NavRoot.NavigationStack.Count}.");
|
||||
Assert.IsType<CirclesPage>(window.NavRoot.NavigationStack[^1]);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System.Text.Json;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using Avalonia.Threading;
|
||||
using Avalonia.VisualTree;
|
||||
using PostIt.Services;
|
||||
|
|
@ -14,7 +13,8 @@ using Yavsc.Api.Client;
|
|||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class AdministrationAccessTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public class AdministrationAccessTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
[Fact]
|
||||
public async Task Profile_quota_failure_keeps_the_consumption_visible_without_enabling_profile_changes()
|
||||
|
|
@ -119,8 +119,9 @@ public class AdministrationAccessTests
|
|||
Assert.Equal(1, vm.UserPage);
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Administration_displays_both_tabs_and_selected_user_usage()
|
||||
[Fact]
|
||||
public Task Administration_displays_both_tabs_and_selected_user_usage()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
await using var api = new ProfileTransport("Administrator");
|
||||
var session = new SessionStatusViewModel { Api = api };
|
||||
|
|
@ -149,7 +150,7 @@ public class AdministrationAccessTests
|
|||
{
|
||||
window.Close();
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[Fact]
|
||||
public async Task Administration_denies_moderators_without_requesting_private_data()
|
||||
|
|
@ -220,8 +221,9 @@ public class AdministrationAccessTests
|
|||
Assert.True(vm.IsProfileLoaded);
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task My_profile_privacy_checkbox_is_two_way_and_disabled_before_loading()
|
||||
[Fact]
|
||||
public Task My_profile_privacy_checkbox_is_two_way_and_disabled_before_loading()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
await using var api = new ProfileTransport("Performer") { HideIpAddressInCalls = true };
|
||||
var vm = new UserProfilePageViewModel(api);
|
||||
|
|
@ -246,7 +248,7 @@ public class AdministrationAccessTests
|
|||
{
|
||||
window.Close();
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[Fact]
|
||||
public async Task Profile_read_failure_prevents_saving_a_default_call_privacy_preference()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ using System.ComponentModel.DataAnnotations;
|
|||
using System.Text.Json;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using Avalonia.Threading;
|
||||
using Avalonia.VisualTree;
|
||||
using PostIt.ViewModels;
|
||||
|
|
@ -13,7 +12,8 @@ using Yavsc.Api.Client;
|
|||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class AdministrationToolsTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public class AdministrationToolsTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
[Fact]
|
||||
public async Task Payment_purge_requires_confirmation_reports_counts_and_clears_on_logout()
|
||||
|
|
@ -40,10 +40,11 @@ public class AdministrationToolsTests
|
|||
Assert.Empty(vm.PaymentPurgeReport);
|
||||
}
|
||||
|
||||
[AvaloniaTheory]
|
||||
[Theory]
|
||||
[InlineData(400, 800)]
|
||||
[InlineData(800, 400)]
|
||||
public void All_administration_tabs_and_typed_forms_are_accessible_in_portrait_and_landscape(int width, int height)
|
||||
public Task All_administration_tabs_and_typed_forms_are_accessible_in_portrait_and_landscape(int width, int height)
|
||||
=> ui.RunAsync(() =>
|
||||
{
|
||||
var vm = new AdministrationPageViewModel();
|
||||
var page = new AdministrationPage { DataContext = vm };
|
||||
|
|
@ -71,7 +72,7 @@ public class AdministrationToolsTests
|
|||
box => box.DataContext is AdministrationFieldViewModel field && field.Name == "ToSend");
|
||||
}
|
||||
finally { window.Close(); }
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[Fact]
|
||||
public void Client_form_retains_every_scalar_field_and_validates_numeric_input()
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ using Avalonia;
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Templates;
|
||||
using Avalonia.Headless;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Logging;
|
||||
using Avalonia.Threading;
|
||||
|
|
@ -22,7 +21,8 @@ using SkiaSharp;
|
|||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class BlogReaderTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public class BlogReaderTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
private static BlogPostDto Post(string article = "Texte du billet.") => new()
|
||||
{
|
||||
|
|
@ -106,8 +106,9 @@ public class BlogReaderTests
|
|||
Assert.Equal(expected, vm.CanOpenExternal);
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Reader_hides_editor_and_wires_hyperlinks_to_the_application()
|
||||
[Fact]
|
||||
public Task Reader_hides_editor_and_wires_hyperlinks_to_the_application()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var vm = CreateViewModel();
|
||||
await vm.InitializeAsync();
|
||||
|
|
@ -138,16 +139,17 @@ public class BlogReaderTests
|
|||
{
|
||||
window.Close();
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaTheory]
|
||||
[Theory]
|
||||
[InlineData(360, 800, false)]
|
||||
[InlineData(1000, 420, true)]
|
||||
[InlineData(1000, 280, true)]
|
||||
[InlineData(600, 600, true)]
|
||||
[InlineData(599, 600, false)]
|
||||
[InlineData(601, 600, true)]
|
||||
public async Task Blog_layout_uses_columns_from_the_square_window_threshold(int width, int height, bool wide)
|
||||
public Task Blog_layout_uses_columns_from_the_square_window_threshold(int width, int height, bool wide)
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var vm = CreateViewModel();
|
||||
await vm.InitializeAsync();
|
||||
|
|
@ -226,10 +228,11 @@ public class BlogReaderTests
|
|||
{
|
||||
window.Close();
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Resizing_between_portrait_and_landscape_preserves_the_editor_and_draft()
|
||||
[Fact]
|
||||
public Task Resizing_between_portrait_and_landscape_preserves_the_editor_and_draft()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var vm = CreateViewModel();
|
||||
await vm.InitializeAsync();
|
||||
|
|
@ -272,10 +275,11 @@ public class BlogReaderTests
|
|||
{
|
||||
window.Close();
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Image_http_failure_is_logged_with_its_url_and_is_not_swallowed()
|
||||
[Fact]
|
||||
public Task Image_http_failure_is_logged_with_its_url_and_is_not_swallowed()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
const string url = "https://org.example.test/files/paul/absent.jpg";
|
||||
using var client = new HttpClient(new BlogResourceServiceTests.StubHandler(
|
||||
|
|
@ -294,7 +298,7 @@ public class BlogReaderTests
|
|||
{
|
||||
Logger.Sink = previousSink;
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
private sealed class RecordingLogSink : ILogSink
|
||||
{
|
||||
|
|
@ -306,8 +310,9 @@ public class BlogReaderTests
|
|||
=> Entries.Add((area, values));
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Long_reading_content_scrolls_and_clears_when_selection_is_removed()
|
||||
[Fact]
|
||||
public Task Long_reading_content_scrolls_and_clears_when_selection_is_removed()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var vm = CreateViewModel();
|
||||
await vm.InitializeAsync();
|
||||
|
|
@ -335,7 +340,7 @@ public class BlogReaderTests
|
|||
{
|
||||
window.Close();
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[Theory]
|
||||
[InlineData("https://yavsc.pschneider.fr/files/paul/blogs/14/IMG-20260923-WA0001.jpg")]
|
||||
|
|
@ -397,8 +402,9 @@ public class BlogReaderTests
|
|||
}
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Clicking_a_user_video_pushes_a_dedicated_video_viewmodel()
|
||||
[Fact]
|
||||
public Task Clicking_a_user_video_pushes_a_dedicated_video_viewmodel()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
using var client = new HttpClient(new BlogResourceServiceTests.StubHandler(request =>
|
||||
{
|
||||
|
|
@ -433,19 +439,21 @@ public class BlogReaderTests
|
|||
{
|
||||
app.DataTemplates.Remove(template);
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public void Video_viewmodel_resolves_to_the_shared_page_with_a_platform_video_surface_slot()
|
||||
[Fact]
|
||||
public Task Video_viewmodel_resolves_to_the_shared_page_with_a_platform_video_surface_slot()
|
||||
=> ui.RunAsync(() =>
|
||||
{
|
||||
var vm = new VideoPageViewModel(new Uri("https://org.example.test/files/paul/clip.mp4"), "video/mp4");
|
||||
var page = Assert.IsType<VideoPage>(new ViewLocator().Build(vm));
|
||||
Assert.NotNull(page.FindControl<ContentControl>("VideoSurface"));
|
||||
Assert.Null(page.FindControl<Button>("PlayButton"));
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Video_page_observes_platform_lifecycle_only_while_navigated()
|
||||
[Fact]
|
||||
public Task Video_page_observes_platform_lifecycle_only_while_navigated()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var nav = new NavigationPage();
|
||||
await nav.PushAsync(new ContentPage());
|
||||
|
|
@ -461,7 +469,7 @@ public class BlogReaderTests
|
|||
status.Text = "No longer active";
|
||||
Platform.SuspendPlayback();
|
||||
Assert.Equal("No longer active", status.Text);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[Fact]
|
||||
public async Task Broken_resource_reports_an_error_and_releases_busy_state()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using Avalonia.Headless.XUnit;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Media.Imaging;
|
||||
using PostIt.Views.Chat;
|
||||
|
|
@ -10,12 +9,14 @@ using Yavsc.Abstract.Chat.Calls;
|
|||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class CallTransportRoutingTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public sealed class CallTransportRoutingTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
[AvaloniaTheory]
|
||||
[Theory]
|
||||
[InlineData(CallTransports.LanSrtp)]
|
||||
[InlineData(CallTransports.WebRtc)]
|
||||
public async Task Incoming_calls_are_handled_only_by_the_matching_transport(string transport)
|
||||
public Task Incoming_calls_are_handled_only_by_the_matching_transport(string transport)
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
await using var lan = new LanCallViewModel(signaling);
|
||||
|
|
@ -35,10 +36,11 @@ public sealed class CallTransportRoutingTests
|
|||
Assert.Equal([call.Id], signaling.EndedCalls);
|
||||
Assert.False(lan.Busy);
|
||||
Assert.False(webRtc.Busy);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Audio_page_keeps_srtp_avatar_call_and_received_video_available_without_camera_controls()
|
||||
[Fact]
|
||||
public Task Audio_page_keeps_srtp_avatar_call_and_received_video_available_without_camera_controls()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
await using var lan = new LanCallViewModel(signaling, loadAvatar: (_, _) => Task.FromResult<Bitmap?>(null))
|
||||
|
|
@ -60,10 +62,11 @@ public sealed class CallTransportRoutingTests
|
|||
Assert.Same(lan.RemoteVideo, video.Content);
|
||||
}
|
||||
finally { window.Close(); }
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Audio_page_shows_static_image_and_hides_video_and_srtp_controls()
|
||||
[Fact]
|
||||
public Task Audio_page_shows_static_image_and_hides_video_and_srtp_controls()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
await using var webRtc = new WebRtcCallViewModel(signaling);
|
||||
|
|
@ -88,10 +91,11 @@ public sealed class CallTransportRoutingTests
|
|||
Assert.Same(webRtc.RemoteAvatar, displayedAvatar.Source);
|
||||
}
|
||||
finally { window.Close(); }
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Unknown_transport_is_rejected_once_without_starting_either_call()
|
||||
[Fact]
|
||||
public Task Unknown_transport_is_rejected_once_without_starting_either_call()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
await using var lan = new LanCallViewModel(signaling);
|
||||
|
|
@ -105,12 +109,13 @@ public sealed class CallTransportRoutingTests
|
|||
Assert.Equal([call.Id], signaling.EndedCalls);
|
||||
Assert.False(lan.Busy);
|
||||
Assert.False(webRtc.Busy);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaTheory]
|
||||
[Theory]
|
||||
[InlineData(CallTransports.LanSrtp)]
|
||||
[InlineData(CallTransports.WebRtc)]
|
||||
public async Task Chat_updates_both_rooms_and_disconnects_the_active_transport(string transport)
|
||||
public Task Chat_updates_both_rooms_and_disconnects_the_active_transport(string transport)
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
var chat = new ChatViewModel(settings: new Settings());
|
||||
|
|
@ -136,7 +141,7 @@ public sealed class CallTransportRoutingTests
|
|||
signaling.Invite(call);
|
||||
Assert.False(lan.Incoming);
|
||||
Assert.False(webRtc.Incoming);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
private static async Task WaitAsync(Func<bool> condition)
|
||||
{
|
||||
|
|
@ -145,8 +150,9 @@ public sealed class CallTransportRoutingTests
|
|||
while (!condition()) await Task.Delay(10, timeout.Token);
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Selecting_a_room_member_prepares_both_transports_without_inviting()
|
||||
[Fact]
|
||||
public Task Selecting_a_room_member_prepares_both_transports_without_inviting()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
await using var lan = new LanCallViewModel(signaling);
|
||||
|
|
@ -177,12 +183,13 @@ public sealed class CallTransportRoutingTests
|
|||
chat.SelectedRoom = "Other";
|
||||
Assert.Null(chat.SelectedUser);
|
||||
Assert.False(chat.OpenCallCommand.CanExecute(null));
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaTheory]
|
||||
[Theory]
|
||||
[InlineData(CallTransports.LanSrtp)]
|
||||
[InlineData(CallTransports.WebRtc)]
|
||||
public async Task Leaving_text_chat_preserves_invitation_and_leaving_call_page_ends_it(string transport)
|
||||
public Task Leaving_text_chat_preserves_invitation_and_leaving_call_page_ends_it(string transport)
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
await using var lan = new LanCallViewModel(signaling);
|
||||
|
|
@ -211,7 +218,7 @@ public sealed class CallTransportRoutingTests
|
|||
Assert.False(webRtc.Busy);
|
||||
}
|
||||
finally { window.Close(); }
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
private sealed class Signaling : IWebRtcCallSignaling
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,6 +38,12 @@ public sealed class AvaloniaUiFixture : IAsyncLifetime
|
|||
}, ct);
|
||||
}
|
||||
|
||||
public Task RunAsync(Action action, CancellationToken ct) => RunAsync(() =>
|
||||
{
|
||||
action();
|
||||
return Task.CompletedTask;
|
||||
}, ct);
|
||||
|
||||
public Task WithWindowAsync(Func<Control> createContent, Func<Window, Task> test, CancellationToken ct,
|
||||
double width = 800, double height = 600) => RunAsync(async () =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using Avalonia.Headless.XUnit;
|
||||
using PostIt.Services;
|
||||
using PostIt.ViewModels;
|
||||
using Yavsc.Abstract.Models.Messaging;
|
||||
|
|
@ -7,7 +6,8 @@ using Yavsc.Api.Client;
|
|||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class HomePageNotificationsTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public class HomePageNotificationsTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
[Fact]
|
||||
public async Task Refresh_loads_public_notifications_from_the_business_host()
|
||||
|
|
@ -70,8 +70,9 @@ public class HomePageNotificationsTests
|
|||
Assert.False(vm.IsLoadingNotifications);
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Login_and_logout_reload_notifications_and_discard_in_flight_private_data()
|
||||
[Fact]
|
||||
public Task Login_and_logout_reload_notifications_and_discard_in_flight_private_data()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var tokenPath = Path.Combine(Path.GetTempPath(), $"postit-notifications-{Guid.NewGuid():N}.json");
|
||||
var settings = new Settings();
|
||||
|
|
@ -123,7 +124,7 @@ public class HomePageNotificationsTests
|
|||
{
|
||||
File.Delete(tokenPath);
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[Fact]
|
||||
public async Task Anonymous_dismiss_removes_the_notification_without_an_api_call()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using Avalonia.Media.Imaging;
|
||||
using PostIt.Helpers;
|
||||
using PostIt.Services;
|
||||
|
|
@ -10,10 +9,12 @@ using Yavsc.Abstract.Chat.Calls;
|
|||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class LanCallViewModelTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public sealed class LanCallViewModelTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
[AvaloniaFact]
|
||||
public async Task Calls_restore_shared_devices_and_persist_choices_and_network_address()
|
||||
[Fact]
|
||||
public Task Calls_restore_shared_devices_and_persist_choices_and_network_address()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var path = Path.Combine(Path.GetTempPath(), $"postit-call-preferences-{Guid.NewGuid():N}.json");
|
||||
var previousDevices = Platform.GetLanCallDevices;
|
||||
|
|
@ -67,10 +68,11 @@ public sealed class LanCallViewModelTests
|
|||
}
|
||||
}
|
||||
finally { Platform.GetLanCallDevices = previousDevices; File.Delete(path); }
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Call_preference_save_failures_are_reported_without_losing_the_choice()
|
||||
[Fact]
|
||||
public Task Call_preference_save_failures_are_reported_without_losing_the_choice()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var path = Path.Combine(Path.GetTempPath(), $"postit-call-preferences-{Guid.NewGuid():N}");
|
||||
Directory.CreateDirectory(path);
|
||||
|
|
@ -85,10 +87,11 @@ public sealed class LanCallViewModelTests
|
|||
Assert.True(settings.IsDirty);
|
||||
}
|
||||
finally { Directory.Delete(path); }
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Missing_saved_network_address_requires_a_new_selection_and_does_not_restore_consent()
|
||||
[Fact]
|
||||
public Task Missing_saved_network_address_requires_a_new_selection_and_does_not_restore_consent()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var path = Path.Combine(Path.GetTempPath(), $"postit-call-preferences-{Guid.NewGuid():N}.json");
|
||||
try
|
||||
|
|
@ -100,7 +103,7 @@ public sealed class LanCallViewModelTests
|
|||
Assert.Equal("not-a-local-address", settings.LanCallAddress);
|
||||
}
|
||||
finally { File.Delete(path); }
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
private static CallSession Session() => new(Guid.NewGuid(), "General", "alice", "bob", false,
|
||||
DateTimeOffset.UtcNow.AddMinutes(1), CallTransports.LanSrtp);
|
||||
|
|
@ -117,10 +120,11 @@ public sealed class LanCallViewModelTests
|
|||
return vm;
|
||||
}
|
||||
|
||||
[AvaloniaTheory]
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public async Task Call_without_camera_sends_own_avatar_and_microphone_and_cleans_up(bool caller)
|
||||
public Task Call_without_camera_sends_own_avatar_and_microphone_and_cleans_up(bool caller)
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
var media = new FakeMedia();
|
||||
|
|
@ -158,10 +162,11 @@ public sealed class LanCallViewModelTests
|
|||
await vm.HangupAsync();
|
||||
Assert.True(media.Disposed);
|
||||
Assert.False(File.Exists(imagePath));
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Unavailable_own_avatar_ends_call_without_opening_media_or_camera()
|
||||
[Fact]
|
||||
public Task Unavailable_own_avatar_ends_call_without_opening_media_or_camera()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
var created = false;
|
||||
|
|
@ -182,10 +187,11 @@ public sealed class LanCallViewModelTests
|
|||
Assert.Empty(signaling.Sent);
|
||||
Assert.Contains("avatar est indisponible", vm.Status);
|
||||
Assert.Contains(signaling.Call.Id, signaling.EndedCalls);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Hangup_cancels_pending_avatar_download_without_opening_media()
|
||||
[Fact]
|
||||
public Task Hangup_cancels_pending_avatar_download_without_opening_media()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
var loading = false;
|
||||
|
|
@ -213,13 +219,14 @@ public sealed class LanCallViewModelTests
|
|||
Assert.False(vm.Busy);
|
||||
Assert.Empty(signaling.Sent);
|
||||
Assert.Contains(signaling.Call.Id, signaling.EndedCalls);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaTheory]
|
||||
[Theory]
|
||||
[InlineData("8.8.8.8")]
|
||||
[InlineData("2001:db8::1")]
|
||||
[InlineData("fd00::1")]
|
||||
public async Task Public_or_private_ip_can_be_selected_for_an_explicitly_consented_direct_call(string address)
|
||||
public Task Public_or_private_ip_can_be_selected_for_an_explicitly_consented_direct_call(string address)
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
await using var vm = Configure(signaling, (_, _) => throw new Exception("No media before acceptance"));
|
||||
|
|
@ -228,10 +235,11 @@ public sealed class LanCallViewModelTests
|
|||
await vm.InviteCommand.ExecuteAsync(null);
|
||||
Assert.Equal(1, signaling.Invites);
|
||||
Assert.True(vm.Busy);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task No_capture_starts_before_explicit_acceptance_and_endpoint_exchange()
|
||||
[Fact]
|
||||
public Task No_capture_starts_before_explicit_acceptance_and_endpoint_exchange()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
var media = new FakeMedia();
|
||||
|
|
@ -256,10 +264,11 @@ public sealed class LanCallViewModelTests
|
|||
Assert.False(vm.Busy);
|
||||
Assert.Null(vm.LocalVideo);
|
||||
Assert.Contains(signaling.Call.Id, signaling.EndedCalls);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Caller_waits_for_consent_and_interruption_releases_media_without_reconnecting()
|
||||
[Fact]
|
||||
public Task Caller_waits_for_consent_and_interruption_releases_media_without_reconnecting()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
var media = new FakeMedia();
|
||||
|
|
@ -277,10 +286,11 @@ public sealed class LanCallViewModelTests
|
|||
Assert.False(vm.Busy);
|
||||
Assert.Null(vm.RemoteVideo);
|
||||
Assert.Contains("interrompue", vm.Status);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Missing_disclosure_consent_or_devices_blocks_the_invitation()
|
||||
[Fact]
|
||||
public Task Missing_disclosure_consent_or_devices_blocks_the_invitation()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
await using var vm = Configure(signaling, (_, _) => throw new Exception("Must not capture"));
|
||||
|
|
@ -294,10 +304,11 @@ public sealed class LanCallViewModelTests
|
|||
Assert.Equal(0, signaling.Invites);
|
||||
Assert.Contains("camera", vm.Status);
|
||||
Assert.False(vm.Busy);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Refusal_never_creates_media_and_late_signals_cannot_restart_capture()
|
||||
[Fact]
|
||||
public Task Refusal_never_creates_media_and_late_signals_cannot_restart_capture()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
var created = 0;
|
||||
|
|
@ -310,10 +321,11 @@ public sealed class LanCallViewModelTests
|
|||
await Task.Delay(30, TestContext.Current.CancellationToken);
|
||||
Assert.Equal(0, created);
|
||||
Assert.False(vm.Busy);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Platform_devices_and_factory_are_used_and_backgrounding_ends_capture()
|
||||
[Fact]
|
||||
public Task Platform_devices_and_factory_are_used_and_backgrounding_ends_capture()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var previousDevices = Platform.GetLanCallDevices;
|
||||
var previousFactory = Platform.CreateLanCallMedia;
|
||||
|
|
@ -361,10 +373,11 @@ public sealed class LanCallViewModelTests
|
|||
Platform.GetLanCallDevices = previousDevices;
|
||||
Platform.CreateLanCallMedia = previousFactory;
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Hangup_cancels_pending_native_start_without_waiting_for_startup_timeout()
|
||||
[Fact]
|
||||
public Task Hangup_cancels_pending_native_start_without_waiting_for_startup_timeout()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
var media = new FakeMedia { DelayStartup = true };
|
||||
|
|
@ -378,10 +391,11 @@ public sealed class LanCallViewModelTests
|
|||
Assert.True(media.Disposed);
|
||||
Assert.False(vm.Busy);
|
||||
Assert.Contains(signaling.Call.Id, signaling.EndedCalls);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Media_failure_ends_the_call_and_disposes_capture()
|
||||
[Fact]
|
||||
public Task Media_failure_ends_the_call_and_disposes_capture()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
var media = new FakeMedia();
|
||||
|
|
@ -394,7 +408,7 @@ public sealed class LanCallViewModelTests
|
|||
Assert.False(vm.Busy);
|
||||
Assert.Contains("test media failure", vm.Status);
|
||||
Assert.Contains(signaling.Call.Id, signaling.EndedCalls);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
private static async Task WaitAsync(Func<bool> condition)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Yavsc.Api.Client;
|
||||
|
|
@ -50,10 +49,12 @@ namespace PostIt.Tests;
|
|||
/// </list>
|
||||
/// </summary>
|
||||
[Trait("Category", "non-reg")]
|
||||
public class MainPageButtonsTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public class MainPageButtonsTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
[AvaloniaFact]
|
||||
public async Task Blog_toolbar_uses_page_view_model_in_home_navigation_and_tracks_changes()
|
||||
[Fact]
|
||||
public Task Blog_toolbar_uses_page_view_model_in_home_navigation_and_tracks_changes()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var home = new HomePageViewModel();
|
||||
var root = new MainView { DataContext = home };
|
||||
|
|
@ -90,7 +91,7 @@ public class MainPageButtonsTests
|
|||
{
|
||||
window.Close();
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Fake <see cref="YavscApiClient"/> that throws on any
|
||||
|
|
@ -190,8 +191,9 @@ public class MainPageButtonsTests
|
|||
return stackBefore;
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Acl_button_click_pushes_a_page_onto_nav_stack()
|
||||
[Fact]
|
||||
public Task Acl_button_click_pushes_a_page_onto_nav_stack()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
// Arrange: a VM whose SelectedPost is non-null so
|
||||
// CanManageAcl evaluates to true and the button is
|
||||
|
|
@ -221,10 +223,11 @@ public class MainPageButtonsTests
|
|||
var pushed = window.NavRoot.NavigationStack.Last();
|
||||
Assert.NotNull(pushed);
|
||||
Assert.IsAssignableFrom<Page>(pushed);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Circles_button_click_pushes_a_page_onto_nav_stack()
|
||||
[Fact]
|
||||
public Task Circles_button_click_pushes_a_page_onto_nav_stack()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
// Arrange: OpenCircles has no CanExecute guard today —
|
||||
// any click should fire it and push the page.
|
||||
|
|
@ -243,10 +246,11 @@ public class MainPageButtonsTests
|
|||
var pushed = window.NavRoot.NavigationStack.Last();
|
||||
Assert.NotNull(pushed);
|
||||
Assert.IsAssignableFrom<Page>(pushed);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public void Signature_dev_button_click_pushes_a_page_onto_nav_stack()
|
||||
[Fact]
|
||||
public Task Signature_dev_button_click_pushes_a_page_onto_nav_stack()
|
||||
=> ui.RunAsync(() =>
|
||||
{
|
||||
// Arrange: the "[DEV] Signature" button is bound to the
|
||||
// BlogsViewModel.OpenSignatureDevCommand [RelayCommand].
|
||||
|
|
@ -272,5 +276,5 @@ public class MainPageButtonsTests
|
|||
var pushed = window.NavRoot.NavigationStack.Last();
|
||||
Assert.NotNull(pushed);
|
||||
Assert.IsAssignableFrom<Page>(pushed);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using Avalonia.VisualTree;
|
||||
using Yavsc.Blogspot;
|
||||
using Yavsc.Api.Client;
|
||||
|
|
@ -10,7 +9,7 @@ namespace PostIt.Tests;
|
|||
/// <summary>
|
||||
/// Headless UI tests for the "Save" flow in <see cref="BlogsPage"/>.
|
||||
/// The pattern is the one <c>SessionStatusBannerTests</c>
|
||||
/// established: <c>[AvaloniaFact]</c>, a <see cref="Window"/>
|
||||
/// established: the <see cref="AvaloniaUiFixture"/> collection, a <see cref="Window"/>
|
||||
/// hosting the page (via a <see cref="Frame"/> because
|
||||
/// <c>MainPage</c> is a <c>ContentPage</c>), then drive the
|
||||
/// controls through their public surface and assert on what
|
||||
|
|
@ -30,10 +29,12 @@ namespace PostIt.Tests;
|
|||
/// buffer that the XAML binds to and the Save command consumes.</para>
|
||||
/// </summary>
|
||||
[Trait("Category", "non-reg")]
|
||||
public class MainPageSaveTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public class MainPageSaveTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
[AvaloniaFact]
|
||||
public async Task Typing_a_title_then_clicking_Save_sends_that_title_in_the_post_body()
|
||||
[Fact]
|
||||
public Task Typing_a_title_then_clicking_Save_sends_that_title_in_the_post_body()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
// Arrange: VM with a recording API client, mounted in a
|
||||
// headless window via a Frame (MainPage is a ContentPage,
|
||||
|
|
@ -84,5 +85,5 @@ public class MainPageSaveTests
|
|||
Assert.Equal("blogspot", path);
|
||||
var sent = Assert.IsType<BlogPostDto>(body);
|
||||
Assert.Equal(typed, sent.Title);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ using Avalonia;
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Headless;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.LogicalTree;
|
||||
using Avalonia.Threading;
|
||||
|
|
@ -17,13 +16,15 @@ using PostIt.Views.Blogs;
|
|||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class MarkdownEditorScrollTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public class MarkdownEditorScrollTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
private static readonly string LongArticle =
|
||||
string.Join("\n\n", Enumerable.Range(1, 100).Select(i => $"Paragraph {i}: article content."));
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Landscape_keyboard_preserves_controls_and_restores_editor_layout()
|
||||
[Fact]
|
||||
public Task Landscape_keyboard_preserves_controls_and_restores_editor_layout()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var root = new MainView();
|
||||
var page = new BlogsPage { DataContext = new BlogsViewModel { IsEditing = true, DraftArticle = LongArticle } };
|
||||
|
|
@ -73,10 +74,11 @@ public class MarkdownEditorScrollTests
|
|||
{
|
||||
CloseWindow(window, page.ArticleEditor);
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public void Keyboard_padding_preserves_system_bar_insets_and_restores_them()
|
||||
[Fact]
|
||||
public Task Keyboard_padding_preserves_system_bar_insets_and_restores_them()
|
||||
=> ui.RunAsync(() =>
|
||||
{
|
||||
var root = new MainView();
|
||||
var window = new Window { Width = 600, Height = 800, Content = root };
|
||||
|
|
@ -105,12 +107,13 @@ public class MarkdownEditorScrollTests
|
|||
{
|
||||
window.Close();
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaTheory]
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public void Resizing_keeps_the_focused_caret_visible_without_changing_selection(bool focused)
|
||||
public Task Resizing_keeps_the_focused_caret_visible_without_changing_selection(bool focused)
|
||||
=> ui.RunAsync(() =>
|
||||
{
|
||||
var editor = new MarkdownEditorControl { MarkdownText = LongArticle };
|
||||
var other = new TextBox();
|
||||
|
|
@ -164,10 +167,11 @@ public class MarkdownEditorScrollTests
|
|||
{
|
||||
CloseWindow(window, editor);
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public void Repeated_touch_requests_keyboard_without_losing_focus_and_read_only_does_not()
|
||||
[Fact]
|
||||
public Task Repeated_touch_requests_keyboard_without_losing_focus_and_read_only_does_not()
|
||||
=> ui.RunAsync(() =>
|
||||
{
|
||||
var editor = new MarkdownEditorControl { MarkdownText = LongArticle };
|
||||
var window = new Window { Width = 600, Height = 400, Content = editor };
|
||||
|
|
@ -213,12 +217,13 @@ public class MarkdownEditorScrollTests
|
|||
Platform.ShowSoftKeyboard = previous;
|
||||
CloseWindow(window, editor);
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaTheory]
|
||||
[Theory]
|
||||
[InlineData(false)]
|
||||
[InlineData(true)]
|
||||
public void Long_article_scrolls_to_the_end_and_adapts_to_resizing(bool preview)
|
||||
public Task Long_article_scrolls_to_the_end_and_adapts_to_resizing(bool preview)
|
||||
=> ui.RunAsync(() =>
|
||||
{
|
||||
var editor = new MarkdownEditorControl
|
||||
{
|
||||
|
|
@ -247,12 +252,13 @@ public class MarkdownEditorScrollTests
|
|||
{
|
||||
CloseWindow(window, editor);
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaTheory]
|
||||
[Theory]
|
||||
[InlineData(false)]
|
||||
[InlineData(true)]
|
||||
public void Blog_page_bounds_the_article_viewport(bool preview)
|
||||
public Task Blog_page_bounds_the_article_viewport(bool preview)
|
||||
=> ui.RunAsync(() =>
|
||||
{
|
||||
var page = new BlogsPage { DataContext = new PostIt.ViewModels.BlogsViewModel { IsEditing = true } };
|
||||
var editor = page.GetLogicalDescendants().OfType<MarkdownEditorControl>().Single();
|
||||
|
|
@ -282,12 +288,13 @@ public class MarkdownEditorScrollTests
|
|||
{
|
||||
CloseWindow(window, editor);
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaTheory]
|
||||
[Theory]
|
||||
[InlineData(false)]
|
||||
[InlineData(true)]
|
||||
public void Short_article_needs_no_vertical_scrollbar(bool preview)
|
||||
public Task Short_article_needs_no_vertical_scrollbar(bool preview)
|
||||
=> ui.RunAsync(() =>
|
||||
{
|
||||
var editor = new MarkdownEditorControl
|
||||
{
|
||||
|
|
@ -310,7 +317,7 @@ public class MarkdownEditorScrollTests
|
|||
{
|
||||
CloseWindow(window, editor);
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
private static void CloseWindow(Window window, MarkdownEditorControl editor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using Avalonia.Headless.XUnit;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Threading;
|
||||
using Avalonia.VisualTree;
|
||||
|
|
@ -19,7 +18,8 @@ using Yavsc.Abstract.Chat.Calls;
|
|||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class MessagingSessionTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public sealed class MessagingSessionTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
[Fact]
|
||||
public void Only_explicit_settings_application_raises_Applied_after_successful_save()
|
||||
|
|
@ -79,8 +79,9 @@ public sealed class MessagingSessionTests
|
|||
=> await PostIt.Android.Tests.ChatServiceEpochTests.VerifyAsync();
|
||||
#endif
|
||||
|
||||
[AvaloniaFact]
|
||||
public void Settings_page_binds_opt_in_and_hides_it_on_other_platforms()
|
||||
[Fact]
|
||||
public Task Settings_page_binds_opt_in_and_hides_it_on_other_platforms()
|
||||
=> ui.RunAsync(() =>
|
||||
{
|
||||
var settings = new Settings();
|
||||
var page = new SettingsPage { DataContext = settings };
|
||||
|
|
@ -105,7 +106,7 @@ public sealed class MessagingSessionTests
|
|||
Assert.False(checkbox.IsChecked);
|
||||
}
|
||||
finally { window.Close(); }
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[Fact]
|
||||
public void Background_chat_service_are_opt_in_and_saved_only_after_persistence()
|
||||
|
|
@ -192,8 +193,9 @@ public sealed class MessagingSessionTests
|
|||
finally { File.Delete(path); }
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Disconnect_cancels_an_in_flight_chat_handshake_instead_of_waiting_for_network_timeout()
|
||||
[Fact]
|
||||
public Task Disconnect_cancels_an_in_flight_chat_handshake_instead_of_waiting_for_network_timeout()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder();
|
||||
builder.WebHost.UseUrls("http://127.0.0.1:0");
|
||||
|
|
@ -234,7 +236,7 @@ public sealed class MessagingSessionTests
|
|||
File.Delete(path);
|
||||
await server.StopAsync();
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[Theory]
|
||||
[InlineData("alice", "https://api.example.test/api/v1/", true)]
|
||||
|
|
@ -262,10 +264,11 @@ public sealed class MessagingSessionTests
|
|||
finally { File.Delete(path); }
|
||||
}
|
||||
|
||||
[AvaloniaTheory]
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public async Task Session_uses_one_chat_connection_and_logout_disables_service_before_token_purge(bool connectOnLogin)
|
||||
public Task Session_uses_one_chat_connection_and_logout_disables_service_before_token_purge(bool connectOnLogin)
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder();
|
||||
builder.WebHost.UseUrls("http://127.0.0.1:0");
|
||||
|
|
@ -322,7 +325,7 @@ public sealed class MessagingSessionTests
|
|||
$"Connections={counter.Count}, transport={transport.Connection.State}, chat={chat.Status.Message}");
|
||||
Assert.Equal(2, await transport.Connection.InvokeAsync<int>("ConnectionCount"));
|
||||
Assert.Equal(new[] { "first", "second" }, counter.RejoinedRooms);
|
||||
Assert.Equal(new ContactPreferences(true, false, true), counter.ContactPreferences);
|
||||
Assert.Equal(Announced(true, false, true), counter.ContactPreferences);
|
||||
|
||||
Platform.SuspendPlayback();
|
||||
Assert.True(chat.IsConnected);
|
||||
|
|
@ -354,10 +357,11 @@ public sealed class MessagingSessionTests
|
|||
File.Delete(path + ".settings");
|
||||
await server.StopAsync();
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Headless_transport_restores_account_rooms_and_the_later_ui_reuses_its_socket()
|
||||
[Fact]
|
||||
public Task Headless_transport_restores_account_rooms_and_the_later_ui_reuses_its_socket()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder();
|
||||
builder.WebHost.UseUrls("http://127.0.0.1:0");
|
||||
|
|
@ -386,7 +390,7 @@ public sealed class MessagingSessionTests
|
|||
await using (var transport = new ChatHubConnection(api))
|
||||
{
|
||||
await transport.StartAsync(TestContext.Current.CancellationToken);
|
||||
Assert.Equal(new ContactPreferences(true, false, false),
|
||||
Assert.Equal(Announced(true, false, false),
|
||||
server.Services.GetRequiredService<ConnectionCounter>().ContactPreferences);
|
||||
await transport.JoinAsync("SavedRoom", TestContext.Current.CancellationToken);
|
||||
Assert.Single(settings.ChatRoomsByAccount);
|
||||
|
|
@ -397,7 +401,7 @@ public sealed class MessagingSessionTests
|
|||
await using var resumedApi = new YavscApiClient(restored, store);
|
||||
await using var resumed = new ChatHubConnection(resumedApi);
|
||||
await resumed.StartAsync(TestContext.Current.CancellationToken);
|
||||
Assert.Equal(new ContactPreferences(true, false, false),
|
||||
Assert.Equal(Announced(true, false, false),
|
||||
server.Services.GetRequiredService<ConnectionCounter>().ContactPreferences);
|
||||
Assert.Equal(2, await resumed.Connection.InvokeAsync<int>("ConnectionCount"));
|
||||
Assert.Equal("SavedRoom", Assert.Single(resumed.JoinedRooms).Name);
|
||||
|
|
@ -438,7 +442,11 @@ public sealed class MessagingSessionTests
|
|||
File.Delete(path + ".settings");
|
||||
await server.StopAsync();
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
// The Linux desktop also announces its audio-only WebRTC and SRTP call support.
|
||||
private static ContactPreferences Announced(bool audio, bool video, bool messages) =>
|
||||
new(audio, video, messages, OperatingSystem.IsLinux(), OperatingSystem.IsLinux());
|
||||
|
||||
private static TokenStore CreateStore(string path)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using System.Net.Http;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using Avalonia.VisualTree;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using PostIt.ViewModels;
|
||||
|
|
@ -48,7 +47,8 @@ namespace PostIt.Tests;
|
|||
/// (platform-dependent) picker.</para>
|
||||
/// </summary>
|
||||
[Trait("Category", "non-reg")]
|
||||
public class MyFilesPageHeadlessTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public class MyFilesPageHeadlessTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
private static (MyFilesPage page, MyFilesViewModel vm, StubFsApi api) CreatePage()
|
||||
{
|
||||
|
|
@ -94,8 +94,9 @@ public class MyFilesPageHeadlessTests
|
|||
.OfType<Button>()
|
||||
.FirstOrDefault(b => b.Content is string s && s == content);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Download_button_on_a_file_row_is_bound_armed_and_fires_on_click()
|
||||
[Fact]
|
||||
public Task Download_button_on_a_file_row_is_bound_armed_and_fires_on_click()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var (page, vm, api) = await MountAsync();
|
||||
|
||||
|
|
@ -127,10 +128,11 @@ public class MyFilesPageHeadlessTests
|
|||
}
|
||||
Assert.True(recorded,
|
||||
"Clicking Télécharger must invoke GET fs/file/{id} on the API client.");
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Delete_button_on_a_file_row_is_bound_armed_and_fires_on_click()
|
||||
[Fact]
|
||||
public Task Delete_button_on_a_file_row_is_bound_armed_and_fires_on_click()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var (page, vm, api) = await MountAsync();
|
||||
|
||||
|
|
@ -157,7 +159,7 @@ public class MyFilesPageHeadlessTests
|
|||
}
|
||||
Assert.True(recorded,
|
||||
"Clicking Supprimer must invoke DELETE fs/{path} on the API client.");
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
private sealed class StubFsApi : IYavscApiClient
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using PostIt.Models;
|
||||
using PostIt.Views;
|
||||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class NotificationModalTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public class NotificationModalTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
[AvaloniaFact]
|
||||
public void Error_message_is_selectable_in_the_notification_modal()
|
||||
[Fact]
|
||||
public Task Error_message_is_selectable_in_the_notification_modal()
|
||||
=> ui.RunAsync(() =>
|
||||
{
|
||||
var root = new MainView();
|
||||
var window = new Window { Content = root };
|
||||
|
|
@ -27,5 +28,5 @@ public class NotificationModalTests
|
|||
{
|
||||
window.Close();
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using PostIt.Services;
|
||||
using PostIt.ViewModels;
|
||||
using PostIt.Views;
|
||||
|
|
@ -9,7 +8,8 @@ using Yavsc.Api.Client;
|
|||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class PerformerDonationSettingsTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public sealed class PerformerDonationSettingsTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("performer@payments.example", "performer@payments.example")]
|
||||
|
|
@ -21,8 +21,9 @@ public sealed class PerformerDonationSettingsTests
|
|||
Assert.Equal(expected, vm.BuildPerformerProfileSettings().DonationPayPalEmail);
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Performer_editor_loads_displays_edits_and_saves_the_private_recipient()
|
||||
[Fact]
|
||||
public Task Performer_editor_loads_displays_edits_and_saves_the_private_recipient()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var tokenPath = Path.Combine(Path.GetTempPath(), "postit-donation-" + Guid.NewGuid().ToString("N") + ".json");
|
||||
try
|
||||
|
|
@ -46,7 +47,7 @@ public sealed class PerformerDonationSettingsTests
|
|||
{
|
||||
if (File.Exists(tokenPath)) File.Delete(tokenPath);
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
private sealed class PerformerApi(string tokenPath) : YavscApiClient(new Settings
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System.Net;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using Avalonia.Headless;
|
||||
using Avalonia.Controls;
|
||||
using PostIt.Services;
|
||||
|
|
@ -11,7 +10,8 @@ using Yavsc.Api.Client;
|
|||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "not-ending")]
|
||||
public sealed class PodcastBroadcasterTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public sealed class PodcastBroadcasterTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("stop")]
|
||||
|
|
@ -20,7 +20,7 @@ public sealed class PodcastBroadcasterTests
|
|||
[InlineData("failure")]
|
||||
[InlineData("broadcast")]
|
||||
public Task Camera_can_be_previewed_without_creating_a_broadcast_and_is_released_before_next_capture(string action)
|
||||
=> HeadlessUnitTestSession.GetOrStartForAssembly(typeof(PodcastBroadcasterTests).Assembly).Dispatch(async () =>
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var path = Path.Combine(Path.GetTempPath(), $"postit-local-preview-{Guid.NewGuid():N}");
|
||||
var previousDevices = Platform.GetPodcastCaptureDevices;
|
||||
|
|
@ -97,7 +97,6 @@ public sealed class PodcastBroadcasterTests
|
|||
Assert.Null(vm.CapturePreview);
|
||||
if (action == "failure") Assert.Contains("Camera disconnected", vm.Status);
|
||||
if (action != "broadcast") Assert.Equal(0, transport.CreateCount);
|
||||
return true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
@ -113,7 +112,7 @@ public sealed class PodcastBroadcasterTests
|
|||
|
||||
[Fact]
|
||||
public Task Leaving_the_page_during_preview_start_disposes_the_late_camera_without_showing_it()
|
||||
=> HeadlessUnitTestSession.GetOrStartForAssembly(typeof(PodcastBroadcasterTests).Assembly).Dispatch(async () =>
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var path = Path.Combine(Path.GetTempPath(), $"postit-preview-race-{Guid.NewGuid():N}");
|
||||
var previous = Platform.CreatePodcastPreviewAsync;
|
||||
|
|
@ -140,7 +139,6 @@ public sealed class PodcastBroadcasterTests
|
|||
Assert.True(preview.Disposed);
|
||||
Assert.Null(vm.CapturePreview);
|
||||
Assert.False(vm.IsPreviewing);
|
||||
return true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
@ -181,7 +179,7 @@ public sealed class PodcastBroadcasterTests
|
|||
|
||||
[Fact]
|
||||
public Task Shared_page_exposes_running_capture_preview_and_clears_it_before_disposal()
|
||||
=> HeadlessUnitTestSession.GetOrStartForAssembly(typeof(PodcastBroadcasterTests).Assembly).Dispatch(async () =>
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var tokenPath = Path.Combine(Path.GetTempPath(), $"postit-preview-{Guid.NewGuid():N}.json");
|
||||
var devices = Platform.GetPodcastCaptureDevices;
|
||||
|
|
@ -230,7 +228,6 @@ public sealed class PodcastBroadcasterTests
|
|||
Assert.Null(vm.CapturePreview);
|
||||
Assert.Null(host.Content);
|
||||
Assert.True(capture!.Stopped);
|
||||
return true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
@ -243,8 +240,9 @@ public sealed class PodcastBroadcasterTests
|
|||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Shared_page_uses_platform_devices_and_requests_permissions_before_creating_server_broadcast()
|
||||
[Fact]
|
||||
public Task Shared_page_uses_platform_devices_and_requests_permissions_before_creating_server_broadcast()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var tokenPath = Path.Combine(Path.GetTempPath(), $"postit-podcast-{Guid.NewGuid():N}.json");
|
||||
var devices = Platform.GetPodcastCaptureDevices;
|
||||
|
|
@ -289,7 +287,7 @@ public sealed class PodcastBroadcasterTests
|
|||
File.Delete(tokenPath);
|
||||
File.Delete(tokenPath + ".settings");
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[Fact]
|
||||
public async Task Prepared_broadcast_starts_the_existing_emission_instead_of_creating_another()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using Avalonia.Headless.XUnit;
|
||||
using PostIt.Services;
|
||||
using PostIt.ViewModels;
|
||||
using Yavsc.Api.Client;
|
||||
|
|
@ -8,10 +7,12 @@ using Yavsc.Abstract.Streaming;
|
|||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class PodcastPreferencesTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public sealed class PodcastPreferencesTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
[AvaloniaFact]
|
||||
public async Task Detection_selection_and_title_survive_settings_reload_without_detecting_again()
|
||||
[Fact]
|
||||
public Task Detection_selection_and_title_survive_settings_reload_without_detecting_again()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var path = Path.Combine(Path.GetTempPath(), $"postit-preferences-{Guid.NewGuid():N}.json");
|
||||
var previous = Platform.GetPodcastCaptureDevices;
|
||||
|
|
@ -78,7 +79,7 @@ public sealed class PodcastPreferencesTests
|
|||
File.Delete(path + ".tokens");
|
||||
}
|
||||
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
private sealed class PreferencesApi(Settings settings, TokenStore store) : YavscApiClient(settings, store)
|
||||
{
|
||||
|
|
@ -90,8 +91,9 @@ public sealed class PodcastPreferencesTests
|
|||
}
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Failed_save_is_reported_without_losing_the_title()
|
||||
[Fact]
|
||||
public Task Failed_save_is_reported_without_losing_the_title()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var path = Path.Combine(Path.GetTempPath(), $"postit-preferences-{Guid.NewGuid():N}");
|
||||
Directory.CreateDirectory(path);
|
||||
|
|
@ -106,5 +108,5 @@ public sealed class PodcastPreferencesTests
|
|||
Assert.True(settings.IsDirty);
|
||||
}
|
||||
finally { Directory.Delete(path); File.Delete(path + ".tokens"); }
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ using System.Runtime.InteropServices;
|
|||
using LibVLCSharp.Shared;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Headless;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using Avalonia.Interactivity;
|
||||
using PostIt.Services;
|
||||
using Yavsc.Abstract.Streaming;
|
||||
|
|
@ -15,7 +14,8 @@ namespace PostIt.Tests;
|
|||
[Trait("DependsOn", "Native")]
|
||||
[Trait("Speed", "Slow")]
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class PodcastReplayTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public sealed class PodcastReplayTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
private static readonly Guid Id = Guid.NewGuid();
|
||||
private readonly CancellationToken _ct = TestContext.Current.CancellationToken;
|
||||
|
|
@ -70,7 +70,7 @@ public sealed class PodcastReplayTests
|
|||
|
||||
[Fact]
|
||||
public Task Desktop_overlay_has_real_position_pause_and_duration_controls()
|
||||
=> HeadlessUnitTestSession.GetOrStartForAssembly(typeof(PodcastReplayTests).Assembly).Dispatch(() =>
|
||||
=> ui.RunAsync(() =>
|
||||
{
|
||||
var overlay = new PostIt.Controls.ReplayControls();
|
||||
var window = new Window { Content = overlay, Width = 640, Height = 360 };
|
||||
|
|
@ -84,19 +84,21 @@ public sealed class PodcastReplayTests
|
|||
finally { window.Close(); }
|
||||
}, _ct);
|
||||
|
||||
[AvaloniaTheory]
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public void Desktop_controls_show_seeking_only_for_replay(bool replay)
|
||||
public Task Desktop_controls_show_seeking_only_for_replay(bool replay)
|
||||
=> ui.RunAsync(() =>
|
||||
{
|
||||
var controls = new PostIt.Controls.ReplayControls(replay);
|
||||
Assert.NotNull(controls.FindControl<Button>("ToggleButton"));
|
||||
Assert.Equal(replay, controls.FindControl<Slider>("PositionSlider")!.IsVisible);
|
||||
Assert.Equal(replay, controls.FindControl<TextBlock>("TimeLabel")!.IsVisible);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact(Skip = "Set POSTIT_TEST_REPLAY to a local MP4 and install LibVLC.", SkipUnless = nameof(HasNativeFixture))]
|
||||
public async Task Desktop_live_controls_pause_and_resume_the_player()
|
||||
[Fact(Skip = "Set POSTIT_TEST_REPLAY to a local MP4 and install LibVLC.", SkipUnless = nameof(HasNativeFixture))]
|
||||
public Task Desktop_live_controls_pause_and_resume_the_player()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
Core.Initialize();
|
||||
using var vlc = new LibVLC("--vout=dummy", "--aout=dummy", "--no-xlib");
|
||||
|
|
@ -123,7 +125,7 @@ public sealed class PodcastReplayTests
|
|||
await WaitForPlayback(true);
|
||||
}
|
||||
finally { player.Stop(); }
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[Fact]
|
||||
public async Task Ranges_use_authenticated_factory_with_bounded_exact_content_and_no_token_in_URL()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using Avalonia.Headless.XUnit;
|
||||
using PostIt.Services;
|
||||
using PostIt.ViewModels;
|
||||
using Yavsc.Abstract.Identity;
|
||||
|
|
@ -8,10 +7,12 @@ using Yavsc.Api.Client;
|
|||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class PodcastScheduleTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public sealed class PodcastScheduleTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
[AvaloniaFact]
|
||||
public async Task Late_obs_credentials_are_not_displayed_after_selection_changes_or_navigation()
|
||||
[Fact]
|
||||
public Task Late_obs_credentials_are_not_displayed_after_selection_changes_or_navigation()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var path = Path.Combine(Path.GetTempPath(), $"postit-obs-late-{Guid.NewGuid():N}.json");
|
||||
var store = new TokenStore(path);
|
||||
|
|
@ -41,10 +42,11 @@ public sealed class PodcastScheduleTests
|
|||
Assert.Empty(vm.ObsStreamKey);
|
||||
}
|
||||
finally { File.Delete(path); File.Delete(path + ".settings"); }
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Obs_activation_is_owned_displays_credentials_and_clears_them_on_navigation_and_revocation()
|
||||
[Fact]
|
||||
public Task Obs_activation_is_owned_displays_credentials_and_clears_them_on_navigation_and_revocation()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var path = Path.Combine(Path.GetTempPath(), $"postit-obs-{Guid.NewGuid():N}.json");
|
||||
var store = new TokenStore(path);
|
||||
|
|
@ -85,10 +87,11 @@ public sealed class PodcastScheduleTests
|
|||
await vm.DeactivateAsync();
|
||||
}
|
||||
finally { File.Delete(path); File.Delete(path + ".settings"); }
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Preparation_and_editing_send_schedule_and_optional_announcement_without_capture()
|
||||
[Fact]
|
||||
public Task Preparation_and_editing_send_schedule_and_optional_announcement_without_capture()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var tokenPath = Path.Combine(Path.GetTempPath(), $"postit-plan-{Guid.NewGuid():N}.json");
|
||||
var store = new TokenStore(tokenPath);
|
||||
|
|
@ -138,7 +141,7 @@ public sealed class PodcastScheduleTests
|
|||
Assert.Equal("Nouveau titre", vm.Title);
|
||||
}
|
||||
finally { File.Delete(tokenPath); File.Delete(tokenPath + ".settings"); }
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
private sealed class ScheduleApi(TokenStore store, string settingsPath)
|
||||
: YavscApiClient(new Settings(settingsPath), store), IYavscApiClient
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ using System.Net;
|
|||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using Avalonia;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using PostIt.Helpers;
|
||||
using PostIt.Services;
|
||||
|
|
@ -45,7 +44,8 @@ namespace PostIt.Tests;
|
|||
/// talking to it.</para>
|
||||
/// </summary>
|
||||
[Trait("Category", "non-reg")]
|
||||
public class PostAclDialogTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public class PostAclDialogTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="HttpMessageHandler"/> that replies 200 with
|
||||
|
|
@ -157,8 +157,9 @@ public class PostAclDialogTests
|
|||
/// hence two HTTP requests total: GET /blogacl and GET
|
||||
/// /circle).
|
||||
/// </summary>
|
||||
[AvaloniaFact]
|
||||
public async Task LoadAsync_runs_once_on_DataContext_changed()
|
||||
[Fact]
|
||||
public Task LoadAsync_runs_once_on_DataContext_changed()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
// Arrange
|
||||
var (window, aclClient, circleClient, handler) = Mount();
|
||||
|
|
@ -197,7 +198,7 @@ public class PostAclDialogTests
|
|||
|
||||
// And the VM's idempotency gate has flipped.
|
||||
Assert.True(vm.Loaded);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// The fix exposes a guard on the VM too: a second call to
|
||||
|
|
@ -206,8 +207,9 @@ public class PostAclDialogTests
|
|||
/// DataContextChanged-firing-twice case (DataContext
|
||||
/// overwritten mid-life, edge cases in dialog re-use).
|
||||
/// </summary>
|
||||
[AvaloniaFact]
|
||||
public async Task LoadAsync_is_idempotent()
|
||||
[Fact]
|
||||
public Task LoadAsync_is_idempotent()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
// Arrange
|
||||
var (_, aclClient, circleClient, handler) = Mount();
|
||||
|
|
@ -221,7 +223,7 @@ public class PostAclDialogTests
|
|||
// Assert: the second call short-circuited on _loaded.
|
||||
Assert.Equal(1, handler.RequestCount);
|
||||
Assert.True(vm.Loaded);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[Fact]
|
||||
public async Task LoadAsync_keeps_acl_from_blogpostdto_and_only_loads_circles()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using Avalonia.Threading;
|
||||
using Avalonia.VisualTree;
|
||||
using Yavsc.Blogspot;
|
||||
|
|
@ -11,7 +10,8 @@ using PostIt.Views.Blogs;
|
|||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class PostItViewModelTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public class PostItViewModelTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
[Fact]
|
||||
public void Draft_modified_tracks_title_body_and_attachments_not_publication()
|
||||
|
|
@ -33,8 +33,9 @@ public class PostItViewModelTests
|
|||
Assert.True(vm.IsDraftModified);
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Save_keeps_selection_and_editor_open_and_resets_highlight()
|
||||
[Fact]
|
||||
public Task Save_keeps_selection_and_editor_open_and_resets_highlight()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var recorder = new CallRecorder();
|
||||
var vm = new BlogsViewModel(new BlogApiClient(new RecordingYavscApiClient(recorder),
|
||||
|
|
@ -81,7 +82,7 @@ public class PostItViewModelTests
|
|||
{
|
||||
window.Close();
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[Fact]
|
||||
public async Task Failed_save_preserves_draft_attachments_and_modified_state()
|
||||
|
|
@ -101,8 +102,9 @@ public class PostItViewModelTests
|
|||
Assert.False(vm.IsBusy);
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public void Published_badge_tracks_post_publication_state()
|
||||
[Fact]
|
||||
public Task Published_badge_tracks_post_publication_state()
|
||||
=> ui.RunAsync(() =>
|
||||
{
|
||||
var post = new BlogPostDto { Id = 42, Title = "Test post", IsPublished = true };
|
||||
var page = new BlogsPage();
|
||||
|
|
@ -130,7 +132,7 @@ public class PostItViewModelTests
|
|||
{
|
||||
window.Close();
|
||||
}
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[Fact]
|
||||
public void SearchCommand_filters_posts_by_title_article_or_author()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using PostIt.ViewModels;
|
||||
using PostIt.ViewModels.Commands;
|
||||
using PostIt.Views.Commands;
|
||||
|
|
@ -9,10 +8,12 @@ using Yavsc.Api.Client;
|
|||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public class RdvPageHeadlessTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public class RdvPageHeadlessTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
[AvaloniaFact]
|
||||
public void Suggested_address_panel_is_hidden_by_default()
|
||||
[Fact]
|
||||
public Task Suggested_address_panel_is_hidden_by_default()
|
||||
=> ui.RunAsync(() =>
|
||||
{
|
||||
var page = CreatePage(out _);
|
||||
|
||||
|
|
@ -23,10 +24,11 @@ public class RdvPageHeadlessTests
|
|||
Assert.NotNull(progress);
|
||||
Assert.False(panel!.IsVisible);
|
||||
Assert.False(progress!.IsVisible);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Suggested_address_panel_and_spinner_follow_viewmodel_state()
|
||||
[Fact]
|
||||
public Task Suggested_address_panel_and_spinner_follow_viewmodel_state()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var page = CreatePage(out var vm);
|
||||
var panel = page.FindControl<StackPanel>("SuggestedAddressPanel")!;
|
||||
|
|
@ -47,7 +49,7 @@ public class RdvPageHeadlessTests
|
|||
Assert.True(panel.IsVisible);
|
||||
Assert.False(progress.IsVisible);
|
||||
Assert.True(applyButton.IsVisible);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
private static AddressEditorPage CreatePage(out PhysicalAddressViewModel vm)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using Avalonia.Threading;
|
||||
using PostIt.ViewModels;
|
||||
using PostIt.Views;
|
||||
|
|
@ -11,7 +10,8 @@ using Yavsc.Api.Client;
|
|||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class ResourceUsageReliefPageTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public sealed class ResourceUsageReliefPageTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
private static ResourceUsageSummary Usage(string id, decimal consumption, decimal credits = 0m) => new()
|
||||
{
|
||||
|
|
@ -20,11 +20,12 @@ public sealed class ResourceUsageReliefPageTests
|
|||
RemainingConsumption = Math.Max(0m, 1000m - consumption)
|
||||
};
|
||||
|
||||
[AvaloniaTheory]
|
||||
[Theory]
|
||||
[InlineData("Moderator")]
|
||||
[InlineData("administrator")]
|
||||
[InlineData("Performer")]
|
||||
public async Task Nonadministrators_cannot_load_or_erase_or_open_the_page(string role)
|
||||
public Task Nonadministrators_cannot_load_or_erase_or_open_the_page(string role)
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
await using var profile = new AdministrationAccessTests.ProfileTransport(role);
|
||||
var session = new SessionStatusViewModel { Api = profile };
|
||||
|
|
@ -40,10 +41,11 @@ public sealed class ResourceUsageReliefPageTests
|
|||
var administration = new AdministrationPageViewModel(null, session: session);
|
||||
await administration.OpenResourceUsageReliefCommand.ExecuteAsync(null);
|
||||
Assert.Contains("Administrator", administration.StatusMessage);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Page_loads_only_exhausted_users_and_confirmed_remission_updates_the_result()
|
||||
[Fact]
|
||||
public Task Page_loads_only_exhausted_users_and_confirmed_remission_updates_the_result()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
await using var profile = new AdministrationAccessTests.ProfileTransport("Administrator");
|
||||
var session = new SessionStatusViewModel { Api = profile };
|
||||
|
|
@ -77,9 +79,9 @@ public sealed class ResourceUsageReliefPageTests
|
|||
Assert.Contains("alice", vm.StatusMessage);
|
||||
Assert.Contains("GET https://example.invalid/api/v1/resource-usage/admin", transport.Requests);
|
||||
Assert.Contains("POST https://example.invalid/api/v1/resource-usage/admin/alice/erase", transport.Requests);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaTheory]
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData("0")]
|
||||
[InlineData("-1")]
|
||||
|
|
@ -88,7 +90,8 @@ public sealed class ResourceUsageReliefPageTests
|
|||
[InlineData("1,000.00")]
|
||||
[InlineData("NaN")]
|
||||
[InlineData("1e2")]
|
||||
public async Task Invalid_amounts_never_reach_the_API(string amount)
|
||||
public Task Invalid_amounts_never_reach_the_API(string amount)
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
await using var profile = new AdministrationAccessTests.ProfileTransport("Administrator");
|
||||
var session = new SessionStatusViewModel { Api = profile };
|
||||
|
|
@ -102,10 +105,11 @@ public sealed class ResourceUsageReliefPageTests
|
|||
Assert.NotEmpty(vm.AmountError);
|
||||
await vm.EraseCommand.ExecuteAsync(null);
|
||||
Assert.Null(transport.Erasure);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Changing_target_or_amount_or_refreshing_invalidates_confirmation()
|
||||
[Fact]
|
||||
public Task Changing_target_or_amount_or_refreshing_invalidates_confirmation()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
await using var profile = new AdministrationAccessTests.ProfileTransport("Administrator");
|
||||
var session = new SessionStatusViewModel { Api = profile };
|
||||
|
|
@ -127,10 +131,11 @@ public sealed class ResourceUsageReliefPageTests
|
|||
Assert.False(vm.ConfirmErasure);
|
||||
Assert.Empty(vm.PointsText);
|
||||
Assert.Equal("bob", vm.SelectedUsage?.UserId);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Failure_requires_a_fresh_snapshot_before_retry()
|
||||
[Fact]
|
||||
public Task Failure_requires_a_fresh_snapshot_before_retry()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
await using var profile = new AdministrationAccessTests.ProfileTransport("Administrator");
|
||||
var session = new SessionStatusViewModel { Api = profile };
|
||||
|
|
@ -152,10 +157,11 @@ public sealed class ResourceUsageReliefPageTests
|
|||
vm.PointsText = "100";
|
||||
vm.ConfirmErasure = true;
|
||||
Assert.True(vm.EraseCommand.CanExecute(null));
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Logout_clears_private_data_and_a_late_response_cannot_restore_it()
|
||||
[Fact]
|
||||
public Task Logout_clears_private_data_and_a_late_response_cannot_restore_it()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
await using var profile = new AdministrationAccessTests.ProfileTransport("Administrator");
|
||||
var session = new SessionStatusViewModel { Api = profile };
|
||||
|
|
@ -171,12 +177,13 @@ public sealed class ResourceUsageReliefPageTests
|
|||
Assert.Null(vm.SelectedUsage);
|
||||
Assert.False(vm.IsAdministrator);
|
||||
Assert.False(vm.EraseCommand.CanExecute(null));
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaTheory]
|
||||
[Theory]
|
||||
[InlineData(400, 800)]
|
||||
[InlineData(800, 400)]
|
||||
public async Task Page_displays_target_preview_and_explicit_confirmation_and_disposes_on_exit(int width, int height)
|
||||
public Task Page_displays_target_preview_and_explicit_confirmation_and_disposes_on_exit(int width, int height)
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
await using var profile = new AdministrationAccessTests.ProfileTransport("Administrator");
|
||||
var session = new SessionStatusViewModel { Api = profile };
|
||||
|
|
@ -205,7 +212,7 @@ public sealed class ResourceUsageReliefPageTests
|
|||
Assert.False(vm.IsAdministrator);
|
||||
Assert.Empty(vm.Users);
|
||||
Assert.False(vm.ConfirmErasure);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
private sealed class Transport : IYavscApiClient
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,15 +11,17 @@ namespace PostIt.Tests;
|
|||
[Trait("DependsOn", "Native")]
|
||||
[Trait("Speed", "Slow")]
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class WebRtcCallViewModelTests
|
||||
[Collection(AvaloniaUiCollection.Name)]
|
||||
public sealed class WebRtcCallViewModelTests(AvaloniaUiFixture ui)
|
||||
{
|
||||
private static readonly CallIceServer[] Turn = [new(["turn:localhost:3478"], "temporary", "password")];
|
||||
private const string Sdp = "v=0\r\no=- 1 1 IN IP4 127.0.0.1\r\nc=IN IP4 0.0.0.0\r\nm=video 9 UDP/TLS/RTP/SAVPF 96\r\n";
|
||||
|
||||
[AvaloniaTheory]
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public async Task Outgoing_waits_for_acceptance_and_passes_server_policy_to_native_engine(bool relay)
|
||||
public Task Outgoing_waits_for_acceptance_and_passes_server_policy_to_native_engine(bool relay)
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling(relay);
|
||||
var media = new Media();
|
||||
|
|
@ -42,12 +44,13 @@ public sealed class WebRtcCallViewModelTests
|
|||
Assert.Null(vm.LocalVideo);
|
||||
Assert.False(vm.Busy);
|
||||
Assert.Contains(signaling.Call.Id, signaling.EndedCalls);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaTheory]
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public async Task Audio_call_uses_only_microphone_and_monitors_audio(bool outgoing)
|
||||
public Task Audio_call_uses_only_microphone_and_monitors_audio(bool outgoing)
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling(true);
|
||||
var media = new Media();
|
||||
|
|
@ -71,10 +74,11 @@ public sealed class WebRtcCallViewModelTests
|
|||
Assert.Null(vm.RemoteVideo);
|
||||
media.Report(new("connected", "relay", 20, 0));
|
||||
await WaitAsync(() => vm.Status.Contains("Audio WebRTC etabli"));
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Accepted_mode_mismatch_ends_call_without_opening_media()
|
||||
[Fact]
|
||||
public Task Accepted_mode_mismatch_ends_call_without_opening_media()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling(true);
|
||||
var media = new Media();
|
||||
|
|
@ -84,10 +88,11 @@ public sealed class WebRtcCallViewModelTests
|
|||
await WaitAsync(() => !vm.Busy);
|
||||
Assert.Null(media.Configuration);
|
||||
Assert.Single(signaling.EndedCalls);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Audio_call_loads_the_remote_avatar_without_blocking_hangup()
|
||||
[Fact]
|
||||
public Task Audio_call_loads_the_remote_avatar_without_blocking_hangup()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling(true);
|
||||
var media = new Media();
|
||||
|
|
@ -109,10 +114,11 @@ public sealed class WebRtcCallViewModelTests
|
|||
Assert.False(vm.Busy);
|
||||
Assert.Null(vm.RemoteAvatar);
|
||||
Assert.Equal("", vm.AvatarStatus);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Incoming_relay_needs_acceptance_but_never_requires_IP_disclosure()
|
||||
[Fact]
|
||||
public Task Incoming_relay_needs_acceptance_but_never_requires_IP_disclosure()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling(true);
|
||||
var media = new Media();
|
||||
|
|
@ -126,10 +132,11 @@ public sealed class WebRtcCallViewModelTests
|
|||
Assert.False(media.Configuration!.Caller);
|
||||
media.Report(new("connected", "relay", 20, 20));
|
||||
await WaitAsync(() => vm.Status.Contains("IP masquee"));
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Direct_call_without_consent_ends_before_any_capture()
|
||||
[Fact]
|
||||
public Task Direct_call_without_consent_ends_before_any_capture()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling(false);
|
||||
var media = new Media();
|
||||
|
|
@ -139,12 +146,13 @@ public sealed class WebRtcCallViewModelTests
|
|||
Assert.False(vm.Busy);
|
||||
Assert.Contains("consentez", vm.Status);
|
||||
Assert.Single(signaling.EndedCalls);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaTheory]
|
||||
[Theory]
|
||||
[InlineData(false)]
|
||||
[InlineData(true)]
|
||||
public async Task Missing_TURN_or_policy_downgrade_never_creates_a_native_engine(bool downgrade)
|
||||
public Task Missing_TURN_or_policy_downgrade_never_creates_a_native_engine(bool downgrade)
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling(true);
|
||||
var created = false;
|
||||
|
|
@ -160,15 +168,16 @@ public sealed class WebRtcCallViewModelTests
|
|||
await WaitAsync(() => !vm.Busy);
|
||||
Assert.False(created);
|
||||
Assert.Single(signaling.EndedCalls);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaTheory]
|
||||
[Theory]
|
||||
[InlineData("hangup")]
|
||||
[InlineData("interrupted")]
|
||||
[InlineData("ended")]
|
||||
[InlineData("background")]
|
||||
[InlineData("dispose")]
|
||||
public async Task All_termination_paths_cancel_in_progress_native_startup(string reason)
|
||||
public Task All_termination_paths_cancel_in_progress_native_startup(string reason)
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling(true);
|
||||
var media = new Media { DelayStartup = true };
|
||||
|
|
@ -188,13 +197,14 @@ public sealed class WebRtcCallViewModelTests
|
|||
Assert.False(vm.Busy);
|
||||
Assert.Null(vm.RemoteVideo);
|
||||
Assert.True(media.StartupCancelled);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaTheory]
|
||||
[Theory]
|
||||
[InlineData("host")]
|
||||
[InlineData("srflx")]
|
||||
[InlineData(null)]
|
||||
public async Task Nonrelay_selected_path_is_rejected_and_media_is_stopped(string? candidateType)
|
||||
public Task Nonrelay_selected_path_is_rejected_and_media_is_stopped(string? candidateType)
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling(true);
|
||||
var media = new Media();
|
||||
|
|
@ -205,10 +215,11 @@ public sealed class WebRtcCallViewModelTests
|
|||
media.Report(new("connected", candidateType, 20, 20));
|
||||
await WaitAsync(() => media.Disposed);
|
||||
Assert.Contains("chemin ICE", vm.Status);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Leaking_candidate_is_not_sent_and_fails_closed()
|
||||
[Fact]
|
||||
public Task Leaking_candidate_is_not_sent_and_fails_closed()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
var signaling = new Signaling(true);
|
||||
var media = new Media();
|
||||
|
|
@ -221,7 +232,7 @@ public sealed class WebRtcCallViewModelTests
|
|||
await WaitAsync(() => media.Disposed);
|
||||
Assert.Empty(signaling.Sent);
|
||||
Assert.Contains("candidat", vm.Status);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
//[AvaloniaFact]
|
||||
public async Task Native_failure_is_visible_and_ends_the_server_call()
|
||||
|
|
@ -260,9 +271,10 @@ public sealed class WebRtcCallViewModelTests
|
|||
public static bool NativeMediaAvailable => OperatingSystem.IsLinux() &&
|
||||
Environment.GetEnvironmentVariable("POSTIT_TEST_NATIVE_WEBRTC") == "1";
|
||||
|
||||
[AvaloniaFact(Skip = "Requires Linux GStreamer/libnice and POSTIT_TEST_NATIVE_WEBRTC=1",
|
||||
[Fact(Skip = "Requires Linux GStreamer/libnice and POSTIT_TEST_NATIVE_WEBRTC=1",
|
||||
SkipUnless = nameof(NativeMediaAvailable))]
|
||||
public async Task Linux_native_adapters_render_remote_bitmaps_and_receive_audio_in_both_directions()
|
||||
public Task Linux_native_adapters_render_remote_bitmaps_and_receive_audio_in_both_directions()
|
||||
=> ui.RunAsync(async () =>
|
||||
{
|
||||
await using var caller = new LinuxWebRtcMedia();
|
||||
await using var callee = new LinuxWebRtcMedia();
|
||||
|
|
@ -291,7 +303,7 @@ public sealed class WebRtcCallViewModelTests
|
|||
}
|
||||
Assert.Equal(640, ((Bitmap)((Image)caller.RemoteVideo).Source!).PixelSize.Width);
|
||||
Assert.Equal(360, ((Bitmap)((Image)callee.RemoteVideo).Source!).PixelSize.Height);
|
||||
}
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
private static WebRtcCallViewModel Configure(Signaling signaling, Media media) => new(signaling, () => media)
|
||||
{ Camera = new("Camera", "camera"), Microphone = new("Mic", "default"), Target = "bob", Room = "General" };
|
||||
|
|
|
|||
Loading…
Reference in a new issue