test are still ok!
This commit is contained in:
parent
a450be6f24
commit
beeac58628
27 changed files with 170 additions and 258 deletions
|
|
@ -73,7 +73,7 @@ public class AddCircleMemberDialogTests
|
|||
return context;
|
||||
}
|
||||
/// <summary>
|
||||
/// Mount a real <see cref="MainWindow"/>, build a minimal
|
||||
/// Mount a real <see cref="MainView"/>, build a minimal
|
||||
/// DI graph, push <see cref="CirclesPage"/> then the
|
||||
/// <see cref="AddCircleMemberDialog"/> on top of it.
|
||||
/// Returns the stack size so the test can pin the delta.
|
||||
|
|
@ -98,10 +98,9 @@ public class AddCircleMemberDialogTests
|
|||
services.AddTransient<AddCircleMemberDialogViewModel>();
|
||||
var sp = services.BuildServiceProvider();
|
||||
|
||||
context.Window = new MainWindow();
|
||||
context.Window = new MainView();
|
||||
context.App = (PostIt.App)Application.Current!;
|
||||
context.App.AttachMainWindow(context.Window);
|
||||
context.Window.Show();
|
||||
|
||||
context.page = sp.GetRequiredService<CirclesPage>();
|
||||
context.Window.NavRoot.PushAsync(context.page).GetAwaiter().GetResult();
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public class AndroidAppLaunchTests
|
|||
_output = output;
|
||||
}
|
||||
|
||||
// FIXME [Fact]
|
||||
[Fact]
|
||||
public void PostIt_starts_and_draws_a_first_frame_on_the_emulator()
|
||||
{
|
||||
if (!IsPackageInstalledOnAnyDevice())
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ public class MainPageButtonsTests
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mount a real <see cref="MainWindow"/> (as
|
||||
/// Mount a real <see cref="MainView"/> (as
|
||||
/// <c>SessionStatusBannerTests</c> does), push a
|
||||
/// <see cref="MainPage"/> with the given VM onto
|
||||
/// <c>NavRoot</c>. <c>PushAsync</c> is awaited (via
|
||||
|
|
@ -109,13 +109,12 @@ public class MainPageButtonsTests
|
|||
/// realised and <c>KeyPressQwerty</c> has a real
|
||||
/// <see cref="TopLevel"/> to dispatch against.
|
||||
/// </summary>
|
||||
private static (MainWindow window, MainPage page) MountMainPage(MainViewModel vm)
|
||||
private static (MainView window, MainPage page) MountMainPage(MainViewModel vm)
|
||||
{
|
||||
var window = new MainWindow();
|
||||
var window = new MainView();
|
||||
var page = new MainPage { DataContext = vm };
|
||||
var app = (PostIt.App)Application.Current!;
|
||||
app.AttachMainWindow(window);
|
||||
window.Show();
|
||||
window.NavRoot.PushAsync(page).GetAwaiter().GetResult();
|
||||
return (window, page);
|
||||
}
|
||||
|
|
@ -125,7 +124,7 @@ public class MainPageButtonsTests
|
|||
/// supported headless pattern (cf. CalculatorTests in the
|
||||
/// Avalonia.Samples repo). Returns the nav-stack count
|
||||
/// before the click so the caller can assert on the delta.
|
||||
/// KeyPressQwerty is dispatched on the <see cref="MainWindow"/>
|
||||
/// KeyPressQwerty is dispatched on the <see cref="MainView"/>
|
||||
/// itself — it is the <see cref="TopLevel"/> that owns the
|
||||
/// headless implementation, and routing the key through any
|
||||
/// descendant TopLevel (e.g. one obtained via
|
||||
|
|
@ -134,7 +133,7 @@ public class MainPageButtonsTests
|
|||
/// because the descendant does not carry the
|
||||
/// <c>PlatformHandle</c> the harness expects.
|
||||
/// </summary>
|
||||
private static int ClickAndCapture(MainWindow window, Button button)
|
||||
private static int ClickAndCapture(MainView window, Button button)
|
||||
{
|
||||
var stackBefore = window.NavRoot.NavigationStack.Count;
|
||||
button.Command?.Execute(button.CommandParameter);
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ public class PostAclDialogTests
|
|||
/// rebinding the global DI mid-test would trample the
|
||||
/// Settings singleton the rest of the harness depends on.
|
||||
/// </summary>
|
||||
private static (MainWindow window, BlogAclApiClient aclClient, CircleApiClient circleClient, CountingHttpHandler handler) Mount()
|
||||
private static (MainView window, BlogAclApiClient aclClient, CircleApiClient circleClient, CountingHttpHandler handler) Mount()
|
||||
{
|
||||
var handler = new CountingHttpHandler();
|
||||
var settings = new Settings();
|
||||
|
|
@ -138,10 +138,9 @@ public class PostAclDialogTests
|
|||
// CountingHttpHandler.
|
||||
GC.KeepAlive(sp);
|
||||
|
||||
var window = new MainWindow();
|
||||
var window = new MainView();
|
||||
var app = (App)Application.Current!;
|
||||
app.AttachMainWindow(window);
|
||||
window.Show();
|
||||
|
||||
return (window, aclClient, circleClient, handler);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace PostIt.Tests;
|
|||
|
||||
/// <summary>
|
||||
/// UI tests for <see cref="SessionStatusBanner"/>. Mounted inside
|
||||
/// a real <see cref="MainWindow"/> via the headless Avalonia
|
||||
/// a real <see cref="MainView"/> via the headless Avalonia
|
||||
/// platform declared in <c>TestApp.cs</c>.
|
||||
///
|
||||
/// <para>The pattern is the one that <c>UnitTest1.MainPage_Should_Load</c>
|
||||
|
|
@ -34,9 +34,8 @@ public class SessionStatusBannerTests
|
|||
[AvaloniaFact]
|
||||
public void Banner_renders_three_buttons_in_the_visual_tree()
|
||||
{
|
||||
var window = new MainWindow();
|
||||
var window = new MainView();
|
||||
window.SessionBanner.DataContext = new SessionStatusViewModel();
|
||||
window.Show();
|
||||
|
||||
var buttons = window.SessionBanner.GetVisualDescendants()
|
||||
.OfType<Button>()
|
||||
|
|
@ -55,11 +54,10 @@ public class SessionStatusBannerTests
|
|||
[AvaloniaFact]
|
||||
public void Banner_login_button_is_visible_when_logged_out()
|
||||
{
|
||||
var window = new MainWindow();
|
||||
var window = new MainView();
|
||||
var vm = new SessionStatusViewModel();
|
||||
Assert.True(vm.IsLoggedOut); // VM default
|
||||
window.SessionBanner.DataContext = vm;
|
||||
window.Show();
|
||||
|
||||
var login = window.SessionBanner.GetVisualDescendants()
|
||||
.OfType<Button>()
|
||||
|
|
@ -73,11 +71,10 @@ public class SessionStatusBannerTests
|
|||
[AvaloniaFact]
|
||||
public void Banner_logout_button_is_hidden_when_logged_out()
|
||||
{
|
||||
var window = new MainWindow();
|
||||
var window = new MainView();
|
||||
var vm = new SessionStatusViewModel();
|
||||
Assert.False(vm.IsLoggedIn); // VM default
|
||||
window.SessionBanner.DataContext = vm;
|
||||
window.Show();
|
||||
|
||||
var logout = window.SessionBanner.GetVisualDescendants()
|
||||
.OfType<Button>()
|
||||
|
|
@ -89,9 +86,8 @@ public class SessionStatusBannerTests
|
|||
[AvaloniaFact]
|
||||
public void Banner_settings_button_is_visible_regardless_of_session()
|
||||
{
|
||||
var window = new MainWindow();
|
||||
var window = new MainView();
|
||||
window.SessionBanner.DataContext = new SessionStatusViewModel();
|
||||
window.Show();
|
||||
|
||||
var settings = window.SessionBanner.GetVisualDescendants()
|
||||
.OfType<Button>()
|
||||
|
|
@ -106,9 +102,8 @@ public class SessionStatusBannerTests
|
|||
[AvaloniaFact]
|
||||
public void Banner_session_label_reflects_DataContext()
|
||||
{
|
||||
var window = new MainWindow();
|
||||
var window = new MainView();
|
||||
window.SessionBanner.DataContext = new SessionStatusViewModel();
|
||||
window.Show();
|
||||
|
||||
var label = window.SessionBanner.GetVisualDescendants()
|
||||
.OfType<TextBlock>()
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ namespace PostIt.Tests;
|
|||
|
||||
internal class TestAppContext
|
||||
{
|
||||
public MainWindow? Window {get; set; }
|
||||
public MainView? Window {get; set; }
|
||||
public CirclesPage? page {get; set; }
|
||||
public AddCircleMemberDialog? dialog { get; set; }
|
||||
public App? App { get; internal set; }
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ public class MainPageTests
|
|||
[AvaloniaFact]
|
||||
public void MainPage_Should_Load()
|
||||
{
|
||||
var window = new MainWindow();
|
||||
window.Show();
|
||||
var window = new MainView();
|
||||
Assert.NotNull(window);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue