Skip to content

Commit

Permalink
b/368413719 Handle resize even when window is minimized (#1487)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpassing authored Sep 20, 2024
1 parent d413d80 commit 07ea522
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ private TerminalForm()

internal static TerminalForm Create()
{
var form = new TerminalForm();
var form = new TerminalForm()
{
Size = new Size(800, 600)
};

//
// When run in a headless environment, the terminal
Expand Down Expand Up @@ -332,6 +335,43 @@ public void CaretStyle_WhenChanged_ThenRaisesEvent()
Assert.IsTrue(themeChangeEventRaised);
}
}

//---------------------------------------------------------------------
// Dimensions.
//---------------------------------------------------------------------

[Test]
public void Dimensions()
{
using (var form = TerminalForm.Create())
{
form.Show();

Assert.Greater(form.VirtualTerminal.Dimensions.Width, 80);
Assert.Greater(form.VirtualTerminal.Dimensions.Height, 20);

form.Close();
}
}

[Test]
public void Dimensions_WhenMinimized_ThenDimensionsAreKept()
{
using (var form = TerminalForm.Create())
{
form.Show();

var dimensions = form.VirtualTerminal.Dimensions;

form.WindowState = FormWindowState.Minimized;
Assert.AreEqual(dimensions, form.VirtualTerminal.Dimensions);

form.WindowState = FormWindowState.Normal;
Assert.AreEqual(dimensions, form.VirtualTerminal.Dimensions);

form.Close();
}
}
}

public static class VirtualTerminalAssert
Expand Down
5 changes: 3 additions & 2 deletions sources/Google.Solutions.Terminal.TestApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ public static void Main(string[] argv)
{
Width = 800,
Height = 600,
Text = "Terminal TestApp"
})
{
var control = new VirtualTerminal()
{
Dock = DockStyle.Fill,
ForeColor = Color.Beige,
BackColor = Color.DarkGray
ForeColor = Color.LightGray,
BackColor = Color.Black
};

f.Controls.Add(control);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,11 @@ protected override void OnResize(EventArgs e)
{
if (this.Width == 0 || this.Height == 0)
{
throw new ArgumentException("Size cannot be zero");
//
// This happens when the window is being minimized.
// We can ignore that.
//
return;
}

//
Expand Down

0 comments on commit 07ea522

Please sign in to comment.