mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-27 00:07:58 +01:00
* Tons of API doc updates * Removed stale test * Removed stale tests * Fixed Skipped Shadow test 1 * Fixed Skipped Shadow test 2 * Fixed Skipped Shadow test 3 * Removed stale test * Removed stale test2 * Explicit unregister of event handler on Application.Driver!.ClearedContents * Added Toplevels to dict * code cleanup * spelling error * Removed stale test3 * Removed stale test4 * Removed stale test5 * added script * tweaked script * tweaked script * Created StressTests project; moved some tests * Created IntegrationTests project; moved some tests * New yml * made old yml just unit tests * Tweaked Button_IsDefault_Raises_Accepted_Correctly * tweaked script * cleaned up ymls * tweakled up ymls * stress tests... * stress tests on ubuntu only * Fixed WindowsDriver in InvokeLeakTest * Fixed WindowsDriver in InvokeLeakTest2 * Added Directory.Packages.props. Added Directory.Build.props * Shortened StressTest time * Removed dupe file. * DemoFiles * Moved all tests to ./Tests dir. * Fixed release build issue * Fixed .sln file * Fixed .sl* files * Fixing ymls * Fixing interation tests * Create link to the file TestHelpers. * Created Tests/UnitTestsParallelizable. Moved all obviously parallelizable tests. Updated yml. * fixing logs * fixing logs2 * fixing logs3 * don't require stress to pass for PRs * Fix a failure? * tweaked script * Coudl this be it? * Moved tons of tests to parallelizable * Fixed some stuff * Script to find duplicate tests * Testing workflows * Updated to v4 * Fix RelativeBasePath issue * Replace powershell to pwsh * Add ignore projects. * Removed dupe unit tests * Code cleanup of tests * Cleaned up test warnings * yml tweak * Moved setter * tweak ymls * just randomly throwing spaghetti at a wall * Enable runing 5 test runners in par * Turned off DEBUG_DISPOSABLE for par tests * RunningUnitTests=true * code cleanup (forcing more Action runs) * DISABLE_DEBUG_IDISPOSABLE * Added View.DebugIDisposable. False by default. * Remobed bogus tareet * Remobed bogus tareet2 * fixed warning * added api doc * fixed warning * fixed warning * fixed warning2 * fixed warning3 * fixed warning4 --------- Co-authored-by: BDisp <bd.bdisp@gmail.com>
119 lines
4.3 KiB
C#
119 lines
4.3 KiB
C#
namespace Terminal.Gui.DrawingTests;
|
|
|
|
public class GradientFillTests
|
|
{
|
|
private readonly Gradient _gradient;
|
|
|
|
public GradientFillTests ()
|
|
{
|
|
// Define the colors of the gradient stops
|
|
List<Color> stops = new List<Color>
|
|
{
|
|
new (255, 0), // Red
|
|
new (0, 0, 255) // Blue
|
|
};
|
|
|
|
// Define the number of steps between each color
|
|
List<int> steps = new() { 10 }; // 10 steps between Red -> Blue
|
|
|
|
_gradient = new (stops, steps);
|
|
}
|
|
|
|
[Fact]
|
|
public void TestGradientFillCorners_AtOrigin ()
|
|
{
|
|
var area = new Rectangle (0, 0, 10, 10);
|
|
var gradientFill = new GradientFill (area, _gradient, GradientDirection.Diagonal);
|
|
|
|
// Test the corners
|
|
var topLeft = new Point (0, 0);
|
|
var topRight = new Point (area.Width - 1, 0);
|
|
var bottomLeft = new Point (0, area.Height - 1);
|
|
var bottomRight = new Point (area.Width - 1, area.Height - 1);
|
|
|
|
Color topLeftColor = gradientFill.GetColor (topLeft);
|
|
Color topRightColor = gradientFill.GetColor (topRight);
|
|
Color bottomLeftColor = gradientFill.GetColor (bottomLeft);
|
|
Color bottomRightColor = gradientFill.GetColor (bottomRight);
|
|
|
|
// Expected colors
|
|
var expectedTopLeftColor = new Color (255, 0); // Red
|
|
var expectedBottomRightColor = new Color (0, 0, 255); // Blue
|
|
|
|
Assert.Equal (expectedTopLeftColor, topLeftColor);
|
|
Assert.Equal (expectedBottomRightColor, bottomRightColor);
|
|
}
|
|
|
|
[Fact]
|
|
public void TestGradientFillCorners_NotAtOrigin ()
|
|
{
|
|
var area = new Rectangle (5, 5, 10, 10);
|
|
var gradientFill = new GradientFill (area, _gradient, GradientDirection.Diagonal);
|
|
|
|
// Test the corners
|
|
var topLeft = new Point (5, 5);
|
|
var topRight = new Point (area.Right - 1, 5);
|
|
var bottomLeft = new Point (5, area.Bottom - 1);
|
|
var bottomRight = new Point (area.Right - 1, area.Bottom - 1);
|
|
|
|
Color topLeftColor = gradientFill.GetColor (topLeft);
|
|
Color topRightColor = gradientFill.GetColor (topRight);
|
|
Color bottomLeftColor = gradientFill.GetColor (bottomLeft);
|
|
Color bottomRightColor = gradientFill.GetColor (bottomRight);
|
|
|
|
// Expected colors
|
|
var expectedTopLeftColor = new Color (255, 0); // Red
|
|
var expectedBottomRightColor = new Color (0, 0, 255); // Blue
|
|
|
|
Assert.Equal (expectedTopLeftColor, topLeftColor);
|
|
Assert.Equal (expectedBottomRightColor, bottomRightColor);
|
|
}
|
|
|
|
[Fact]
|
|
public void TestGradientFillColorTransition ()
|
|
{
|
|
var area = new Rectangle (0, 0, 10, 10);
|
|
var gradientFill = new GradientFill (area, _gradient, GradientDirection.Diagonal);
|
|
|
|
for (var row = 0; row < area.Height; row++)
|
|
{
|
|
var previousRed = 255;
|
|
var previousBlue = 0;
|
|
|
|
for (var col = 0; col < area.Width; col++)
|
|
{
|
|
var point = new Point (col, row);
|
|
Color color = gradientFill.GetColor (point);
|
|
|
|
// Check if the current color is 'more blue' and 'less red' as it goes right and down
|
|
Assert.True (color.R <= previousRed, $"Failed at ({col}, {row}): {color.R} > {previousRed}");
|
|
Assert.True (color.B >= previousBlue, $"Failed at ({col}, {row}): {color.B} < {previousBlue}");
|
|
|
|
// Update the previous color values for the next iteration
|
|
previousRed = color.R;
|
|
previousBlue = color.B;
|
|
}
|
|
}
|
|
|
|
for (var col = 0; col < area.Width; col++)
|
|
{
|
|
var previousRed = 255;
|
|
var previousBlue = 0;
|
|
|
|
for (var row = 0; row < area.Height; row++)
|
|
{
|
|
var point = new Point (col, row);
|
|
Color color = gradientFill.GetColor (point);
|
|
|
|
// Check if the current color is 'more blue' and 'less red' as it goes right and down
|
|
Assert.True (color.R <= previousRed, $"Failed at ({col}, {row}): {color.R} > {previousRed}");
|
|
Assert.True (color.B >= previousBlue, $"Failed at ({col}, {row}): {color.B} < {previousBlue}");
|
|
|
|
// Update the previous color values for the next iteration
|
|
previousRed = color.R;
|
|
previousBlue = color.B;
|
|
}
|
|
}
|
|
}
|
|
}
|