Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark some tests as manual, fix ColorParse tests with invalid point #2434

Merged
merged 1 commit into from
Mar 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Eto/Drawing/Color.cs
Original file line number Diff line number Diff line change
Expand Up @@ -535,16 +535,16 @@ public static bool TryParse(string value, out Color color, ColorStyles style)

if (alphaIsFloat && i == alphaIndex)
{
if (!double.TryParse(array[i], out fnum))
if (!double.TryParse(array[i], NumberStyles.Number, CultureInfo.InvariantCulture, out fnum))
goto invalid;
if (!isPercent)
fnum *= 255;
}
else if (uint.TryParse(array[i], out var num))
else if (uint.TryParse(array[i],NumberStyles.Number, CultureInfo.InvariantCulture, out var num))
{
fnum = num;
}
else if (double.TryParse(array[i], out fnum))
else if (double.TryParse(array[i], NumberStyles.Number, CultureInfo.InvariantCulture, out fnum))
{
if (!isPercent)
fnum *= 255;
Expand Down
27 changes: 25 additions & 2 deletions test/Eto.Test/UnitTests/Drawing/ColorTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Globalization;
using System.Threading;
using Eto.Drawing;
using NUnit.Framework;

Expand Down Expand Up @@ -158,18 +160,39 @@ public void ColorToCmykShouldNotHaveNan(uint rgb)
[TestCase("4294967295", 255, 255, 255, 255, ColorStyles.AlphaLast)] // #FFFFFFFF
[TestCase("16777215", 255, 0, 255, 255, ColorStyles.AlphaLast)] // #FFFFFF
[TestCase("305419896", 120, 18, 52, 86, ColorStyles.AlphaLast)] // #12345678 A = 78
public void ColorShouldParse(string text, int a, int r, int g, int b, ColorStyles? style = null)

[TestCase("#0000", 0, 0, 0, 0, ColorStyles.AlphaLast, true)]
[TestCase("#1234", 68, 17, 34, 51, ColorStyles.AlphaLast, true)]
[TestCase("#00000000", 0, 0, 0, 0, ColorStyles.AlphaLast, true)]
[TestCase("#12345678", 120, 18, 52, 86, ColorStyles.AlphaLast, true)]
[TestCase("0, 0, 0, 0", 0, 0, 0, 0, ColorStyles.AlphaLast, true)]
[TestCase("12, 34, 56, 78", 78, 12, 34, 56, ColorStyles.AlphaLast, true)]
[TestCase("255, 255, 255, 255", 255, 255, 255, 255, ColorStyles.AlphaLast, true)]
[TestCase("rgba(12,34,56,0.3)", 76, 12, 34, 56, ColorStyles.AlphaLast, true)]
[TestCase("rgba(50%,20%,100%,0.3)", 76, 127, 51, 255, ColorStyles.AlphaLast, true)]
[TestCase("rgba(50%,20.5%,100%,0.3)", 76, 127, 52, 255, ColorStyles.AlphaLast, true)]
[TestCase("0", 0, 0, 0, 0, ColorStyles.AlphaLast, true)]
[TestCase("4294967295", 255, 255, 255, 255, ColorStyles.AlphaLast, true)] // #FFFFFFFF
[TestCase("16777215", 255, 0, 255, 255, ColorStyles.AlphaLast, true)] // #FFFFFF
[TestCase("305419896", 120, 18, 52, 86, ColorStyles.AlphaLast, true)] // #12345678 A = 78
public void ColorShouldParse(string text, int a, int r, int g, int b, ColorStyles? style = null, bool? useDifferentCulture = null)
{
var systemCulture = CultureInfo.CurrentCulture;
bool shouldSwitchCulture = useDifferentCulture != null && useDifferentCulture.Value;
Thread.CurrentThread.CurrentCulture = new CultureInfo(shouldSwitchCulture ? "de-DE" : "en-US");
Color color;
var result = style == null ? Color.TryParse(text, out color) : Color.TryParse(text, out color, style.Value);

Thread.CurrentThread.CurrentCulture = systemCulture;

Assert.IsTrue(result, "#1 - Color could not be parsed from text");

Assert.AreEqual(a, color.Ab, "#2.1 - Alpha component is incorrect");
Assert.AreEqual(r, color.Rb, "#2.2 - Red component is incorrect");
Assert.AreEqual(g, color.Gb, "#2.3 - Green component is incorrect");
Assert.AreEqual(b, color.Bb, "#2.4 - Blue component is incorrect");
}

[TestCase("#0000", 0, 0, 0, 0, ColorStyles.ShortHex)]
[TestCase("#1234", 17, 34, 51, 68, ColorStyles.ShortHex)]
[TestCase("#FFFF", 255, 255, 255, 255, ColorStyles.ShortHex)]
Expand Down
12 changes: 6 additions & 6 deletions test/Eto.Test/UnitTests/Forms/ApplicationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public void ReinitializingWithCurrentPlatformShouldThrowException()
_ = new Application(Platform.Instance);
});
}

[TestCase(-1)]
[TestCase(10)]
[TestCase(1000)]
[TestCase(-1), ManualTest]
[TestCase(10), ManualTest]
[TestCase(1000), ManualTest]
public void RunIterationShouldAllowBlocking(int delay)
{
int count = 0;
Expand All @@ -40,7 +40,7 @@ public void RunIterationShouldAllowBlocking(int delay)
{
form = new Form();
form.Closed += (sender, e) => running = false;

form.Title = "RunIterationShouldAllowBlocking (" + nameof(delay) + ": " + delay + ")";
var stopButton = new Button { Text = "Stop" };
stopButton.Click += (sender, e) =>
{
Expand All @@ -61,7 +61,7 @@ public void RunIterationShouldAllowBlocking(int delay)

layout.Padding = 10;
layout.DefaultSpacing = new Size(4, 4);
layout.Add(new Label { Text = "The controls in this form should\nbe functional while test is running,\nand count should increase without moving the mouse.", TextAlignment = TextAlignment.Center });
layout.Add(new Label { Text = "The controls in this form should\nbe functional while test is running,\nand count should increase without moving the mouse.\nControls should be non-interactable during the delay.", TextAlignment = TextAlignment.Center });
layout.Add(new DropDown { DataStore = new[] { "Item 1", "Item 2", "Item 3" } });
layout.Add(new TextBox());
layout.Add(new DateTimePicker());
Expand Down
14 changes: 7 additions & 7 deletions test/Eto.Test/UnitTests/Forms/PrintingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace Eto.Test.UnitTests.Forms
[TestFixture]
public class PrintingTests : TestBase
{
[TestCase(10)]
[TestCase(1000)]
[TestCase(10), ManualTest]
[TestCase(1000), ManualTest]
[InvokeOnUI]
public void PrintControl(int count)
{
Expand All @@ -31,8 +31,8 @@ public void PrintControl(int count)
ctl.Print();
}

[TestCase(10)]
[TestCase(1000)]
[TestCase(10), ManualTest]
[TestCase(1000), ManualTest]
[InvokeOnUI]
public void PrintControlPreview(int count)
{
Expand Down Expand Up @@ -67,7 +67,7 @@ public void PrintControlPreview(int count)
doc.Dispose();
}

[Test]
[Test, ManualTest]
[InvokeOnUI]
public void PrintPreviewWithGraphics()
{
Expand All @@ -78,7 +78,7 @@ public void PrintPreviewWithGraphics()
doc.Dispose();
}

[Test]
[Test, ManualTest]
[InvokeOnUI]
public void PrintWithGraphics()
{
Expand All @@ -89,7 +89,7 @@ public void PrintWithGraphics()
doc.Dispose();
}

[Test]
[Test, ManualTest]
[InvokeOnUI]
public void PrintDialogWithoutDocument()
{
Expand Down