fix(ui): own private broadcast close-out dialog
This commit is contained in:
@@ -11,6 +11,8 @@ public partial class KeepBroadcastDialog : Window
|
||||
public KeepBroadcastDialog(string title)
|
||||
{
|
||||
InitializeComponent();
|
||||
if (Application.Current?.MainWindow is { } owner && !ReferenceEquals(owner, this))
|
||||
Owner = owner;
|
||||
MessageText.Text = string.IsNullOrWhiteSpace(title)
|
||||
? "Your private broadcast is on YouTube as a private video. Keep it, or delete it?"
|
||||
: $"\u201c{title}\u201d is on YouTube as a private video. Keep it, or delete it?";
|
||||
|
||||
@@ -69,6 +69,45 @@ public sealed class TestStreamTests
|
||||
_app.Run(RunWindow);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void KeepBroadcastPrompt_IsOwnedAndReturnsControlToTheMainWindow()
|
||||
{
|
||||
_app.Run(RunKeepBroadcastPrompt);
|
||||
}
|
||||
|
||||
private void RunKeepBroadcastPrompt()
|
||||
{
|
||||
var tempDb = Path.Combine(Path.GetTempPath(), $"ytLlive-test-{Guid.NewGuid():N}.db");
|
||||
MainViewModel.LayoutPathOverride = tempDb;
|
||||
MainWindow? window = null;
|
||||
var previousMainWindow = Application.Current.MainWindow;
|
||||
try
|
||||
{
|
||||
using (var schema = new LayoutStore(tempDb)) { }
|
||||
SqliteConnection.ClearAllPools();
|
||||
|
||||
window = new MainWindow();
|
||||
Application.Current.MainWindow = window;
|
||||
window.Show();
|
||||
window.UpdateLayout();
|
||||
|
||||
var dialog = new KeepBroadcastDialog("Test broadcast");
|
||||
Assert.Same(window, dialog.Owner);
|
||||
dialog.Loaded += (_, _) => dialog.DialogResult = true;
|
||||
Assert.True(dialog.ShowDialog());
|
||||
Assert.True(window.IsEnabled);
|
||||
Assert.True(window.IsLoaded);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (window != null) window.Close();
|
||||
Application.Current.MainWindow = previousMainWindow;
|
||||
MainViewModel.LayoutPathOverride = null;
|
||||
SqliteConnection.ClearAllPools();
|
||||
try { File.Delete(tempDb); } catch { /* best-effort */ }
|
||||
}
|
||||
}
|
||||
|
||||
private void RunCoordinator()
|
||||
{
|
||||
var handler = new RecordingHandler();
|
||||
@@ -212,4 +251,4 @@ public sealed class TestStreamTests
|
||||
try { File.Delete(tempDb); } catch { /* best-effort cleanup */ }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user