-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
65 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
UnitTests/UnitTests.UWP/UI/Triggers/Test_ControlSizeTrigger.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Microsoft.Toolkit.Uwp; | ||
using Microsoft.Toolkit.Uwp.UI.Triggers; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System.Threading.Tasks; | ||
using Windows.UI.Xaml.Controls; | ||
|
||
namespace UnitTests.UWP.UI.Triggers | ||
{ | ||
[TestClass] | ||
[TestCategory("Test_ControlSizeTrigger")] | ||
public class Test_ControlSizeTrigger : VisualUITestBase | ||
{ | ||
[DataTestMethod] | ||
[DataRow(450, 450, true)] | ||
[DataRow(400, 400, true)] | ||
[DataRow(500, 500, false)] | ||
[DataRow(399, 400, false)] | ||
[DataRow(400, 399, false)] | ||
public async Task ControlSizeTriggerTest(double width, double height, bool expectedResult) | ||
{ | ||
await App.DispatcherQueue.EnqueueAsync(() => | ||
{ | ||
Grid grid = CreateGrid(width, height); | ||
var trigger = new ControlSizeTrigger(); | ||
|
||
trigger.TargetElement = grid; | ||
trigger.MaxHeight = 500; | ||
trigger.MinHeight = 400; | ||
trigger.MaxWidth = 500; | ||
trigger.MinWidth = 400; | ||
|
||
Assert.AreEqual(expectedResult, trigger.IsActive); | ||
}); | ||
} | ||
|
||
private Grid CreateGrid(double width, double height) | ||
{ | ||
var grid = new Grid() | ||
{ | ||
Height = height, | ||
Width = width | ||
}; | ||
grid.Measure(new Windows.Foundation.Size(1000, 1000)); | ||
grid.Arrange(new Windows.Foundation.Rect(0, 0, 1000, 1000)); | ||
grid.UpdateLayout(); | ||
|
||
return grid; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters