Skip to content

Commit 7e739e6

Browse files
committed
Mark some tests as manual, fix ColorParse tests with invalid decimal point
1 parent 91a4744 commit 7e739e6

File tree

4 files changed

+42
-18
lines changed

4 files changed

+42
-18
lines changed

src/Eto/Drawing/Color.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -535,16 +535,16 @@ public static bool TryParse(string value, out Color color, ColorStyles style)
535535

536536
if (alphaIsFloat && i == alphaIndex)
537537
{
538-
if (!double.TryParse(array[i], out fnum))
538+
if (!double.TryParse(array[i], NumberStyles.Number, CultureInfo.InvariantCulture, out fnum))
539539
goto invalid;
540540
if (!isPercent)
541541
fnum *= 255;
542542
}
543-
else if (uint.TryParse(array[i], out var num))
543+
else if (uint.TryParse(array[i],NumberStyles.Number, CultureInfo.InvariantCulture, out var num))
544544
{
545545
fnum = num;
546546
}
547-
else if (double.TryParse(array[i], out fnum))
547+
else if (double.TryParse(array[i], NumberStyles.Number, CultureInfo.InvariantCulture, out fnum))
548548
{
549549
if (!isPercent)
550550
fnum *= 255;

test/Eto.Test/UnitTests/Drawing/ColorTests.cs

+26-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using System;
2+
using System.Globalization;
3+
using System.Threading;
24
using Eto.Drawing;
35
using NUnit.Framework;
46

@@ -158,18 +160,40 @@ public void ColorToCmykShouldNotHaveNan(uint rgb)
158160
[TestCase("4294967295", 255, 255, 255, 255, ColorStyles.AlphaLast)] // #FFFFFFFF
159161
[TestCase("16777215", 255, 0, 255, 255, ColorStyles.AlphaLast)] // #FFFFFF
160162
[TestCase("305419896", 120, 18, 52, 86, ColorStyles.AlphaLast)] // #12345678 A = 78
161-
public void ColorShouldParse(string text, int a, int r, int g, int b, ColorStyles? style = null)
163+
164+
[TestCase("#0000", 0, 0, 0, 0, ColorStyles.AlphaLast, true)]
165+
[TestCase("#1234", 68, 17, 34, 51, ColorStyles.AlphaLast, true)]
166+
[TestCase("#00000000", 0, 0, 0, 0, ColorStyles.AlphaLast, true)]
167+
[TestCase("#12345678", 120, 18, 52, 86, ColorStyles.AlphaLast, true)]
168+
[TestCase("0, 0, 0, 0", 0, 0, 0, 0, ColorStyles.AlphaLast, true)]
169+
[TestCase("12, 34, 56, 78", 78, 12, 34, 56, ColorStyles.AlphaLast, true)]
170+
[TestCase("255, 255, 255, 255", 255, 255, 255, 255, ColorStyles.AlphaLast, true)]
171+
[TestCase("rgba(12,34,56,0.3)", 76, 12, 34, 56, ColorStyles.AlphaLast, true)]
172+
[TestCase("rgba(50%,20%,100%,0.3)", 76, 127, 51, 255, ColorStyles.AlphaLast, true)]
173+
[TestCase("rgba(50%,20.5%,100%,0.3)", 76, 127, 52, 255, ColorStyles.AlphaLast, true)]
174+
[TestCase("0", 0, 0, 0, 0, ColorStyles.AlphaLast, true)]
175+
[TestCase("4294967295", 255, 255, 255, 255, ColorStyles.AlphaLast, true)] // #FFFFFFFF
176+
[TestCase("16777215", 255, 0, 255, 255, ColorStyles.AlphaLast, true)] // #FFFFFF
177+
[TestCase("305419896", 120, 18, 52, 86, ColorStyles.AlphaLast, true)] // #12345678 A = 78
178+
public void ColorShouldParse(string text, int a, int r, int g, int b, ColorStyles? style = null, bool? useDifferentCulture = null)
162179
{
180+
var systemCulture = CultureInfo.CurrentCulture;
181+
bool shouldSwitchCulture = useDifferentCulture != null && useDifferentCulture.Value;
182+
if (shouldSwitchCulture)
183+
Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");
163184
Color color;
164185
var result = style == null ? Color.TryParse(text, out color) : Color.TryParse(text, out color, style.Value);
186+
187+
Thread.CurrentThread.CurrentCulture = systemCulture;
188+
165189
Assert.IsTrue(result, "#1 - Color could not be parsed from text");
166190

167191
Assert.AreEqual(a, color.Ab, "#2.1 - Alpha component is incorrect");
168192
Assert.AreEqual(r, color.Rb, "#2.2 - Red component is incorrect");
169193
Assert.AreEqual(g, color.Gb, "#2.3 - Green component is incorrect");
170194
Assert.AreEqual(b, color.Bb, "#2.4 - Blue component is incorrect");
171195
}
172-
196+
173197
[TestCase("#0000", 0, 0, 0, 0, ColorStyles.ShortHex)]
174198
[TestCase("#1234", 17, 34, 51, 68, ColorStyles.ShortHex)]
175199
[TestCase("#FFFF", 255, 255, 255, 255, ColorStyles.ShortHex)]

test/Eto.Test/UnitTests/Forms/ApplicationTests.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ public void ReinitializingWithCurrentPlatformShouldThrowException()
2525
_ = new Application(Platform.Instance);
2626
});
2727
}
28-
29-
[TestCase(-1)]
30-
[TestCase(10)]
31-
[TestCase(1000)]
28+
29+
[TestCase(-1), ManualTest]
30+
[TestCase(10), ManualTest]
31+
[TestCase(1000), ManualTest]
3232
public void RunIterationShouldAllowBlocking(int delay)
3333
{
3434
int count = 0;
@@ -40,7 +40,7 @@ public void RunIterationShouldAllowBlocking(int delay)
4040
{
4141
form = new Form();
4242
form.Closed += (sender, e) => running = false;
43-
43+
form.Title = "RunIterationShouldAllowBlocking (" + nameof(delay) + ": " + delay + ")";
4444
var stopButton = new Button { Text = "Stop" };
4545
stopButton.Click += (sender, e) =>
4646
{
@@ -61,7 +61,7 @@ public void RunIterationShouldAllowBlocking(int delay)
6161

6262
layout.Padding = 10;
6363
layout.DefaultSpacing = new Size(4, 4);
64-
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 });
64+
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 });
6565
layout.Add(new DropDown { DataStore = new[] { "Item 1", "Item 2", "Item 3" } });
6666
layout.Add(new TextBox());
6767
layout.Add(new DateTimePicker());

test/Eto.Test/UnitTests/Forms/PrintingTests.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ namespace Eto.Test.UnitTests.Forms
77
[TestFixture]
88
public class PrintingTests : TestBase
99
{
10-
[TestCase(10)]
11-
[TestCase(1000)]
10+
[TestCase(10), ManualTest]
11+
[TestCase(1000), ManualTest]
1212
[InvokeOnUI]
1313
public void PrintControl(int count)
1414
{
@@ -31,8 +31,8 @@ public void PrintControl(int count)
3131
ctl.Print();
3232
}
3333

34-
[TestCase(10)]
35-
[TestCase(1000)]
34+
[TestCase(10), ManualTest]
35+
[TestCase(1000), ManualTest]
3636
[InvokeOnUI]
3737
public void PrintControlPreview(int count)
3838
{
@@ -67,7 +67,7 @@ public void PrintControlPreview(int count)
6767
doc.Dispose();
6868
}
6969

70-
[Test]
70+
[Test, ManualTest]
7171
[InvokeOnUI]
7272
public void PrintPreviewWithGraphics()
7373
{
@@ -78,7 +78,7 @@ public void PrintPreviewWithGraphics()
7878
doc.Dispose();
7979
}
8080

81-
[Test]
81+
[Test, ManualTest]
8282
[InvokeOnUI]
8383
public void PrintWithGraphics()
8484
{
@@ -89,7 +89,7 @@ public void PrintWithGraphics()
8989
doc.Dispose();
9090
}
9191

92-
[Test]
92+
[Test, ManualTest]
9393
[InvokeOnUI]
9494
public void PrintDialogWithoutDocument()
9595
{

0 commit comments

Comments
 (0)