Skip to content

Commit

Permalink
Add test for resetting maxwidth/maxheight back to 0 allows resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
dotMorten committed Feb 25, 2024
1 parent 8756033 commit 94c639d
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions src/WinUIEx.Tests/WindowManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ await UITestHelper.RunWindowTest(async (window) =>
}

[TestMethod]
public async Task SetMaxWidth()
{
public async Task SetMaxWidth() =>
await UITestHelper.RunWindowTest(async (window) =>
{
window.Content = new Grid();
Expand All @@ -96,7 +95,21 @@ await UITestHelper.RunWindowTest(async (window) =>
await window.Content.LoadAsync();
Assert.AreEqual(500, window.AppWindow.Size.Width / window.Content.XamlRoot.RasterizationScale);
});
}

[TestMethod]
public async Task ResetMaxWidth() =>
await UITestHelper.RunWindowTest(async (window) =>
{
window.Content = new Grid();
var manager = WindowManager.Get(window);
manager.Width = 600;
manager.MaxWidth = 500;
await window.Content.LoadAsync();
Assert.AreEqual(500, window.AppWindow.Size.Width / window.Content.XamlRoot.RasterizationScale);
manager.MaxWidth = 0;
manager.Width = 600;
Assert.AreEqual(600, window.AppWindow.Size.Width / window.Content.XamlRoot.RasterizationScale);
});

[TestMethod]
public async Task SetMaxHeight() => await UITestHelper.RunWindowTest(async (window) =>
Expand All @@ -109,6 +122,22 @@ public async Task SetMaxHeight() => await UITestHelper.RunWindowTest(async (wind
Assert.AreEqual(500, window.AppWindow.Size.Height / window.Content.XamlRoot.RasterizationScale);
});


[TestMethod]
public async Task ResetMaxHeight() =>
await UITestHelper.RunWindowTest(async (window) =>
{
window.Content = new Grid();
var manager = WindowManager.Get(window);
manager.Height = 600;
manager.MaxHeight = 500;
await window.Content.LoadAsync();
Assert.AreEqual(500, window.AppWindow.Size.Height / window.Content.XamlRoot.RasterizationScale);
manager.MaxHeight = 0;
manager.Height = 600;
Assert.AreEqual(600, window.AppWindow.Size.Height / window.Content.XamlRoot.RasterizationScale);
});

[TestMethod]
[Timeout(5000)]
public async Task GetWindowState() => await UITestHelper.RunWindowTest(async (window) =>
Expand Down

0 comments on commit 94c639d

Please sign in to comment.