Skip to content

Commit

Permalink
feat: Add AsyncAssert helper + improve other helpers usage + apply co…
Browse files Browse the repository at this point in the history
…de review changes
  • Loading branch information
dr1rrb committed Oct 18, 2023
1 parent 32e2efc commit 959216c
Show file tree
Hide file tree
Showing 12 changed files with 1,561 additions and 317 deletions.
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PropertyGroup>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>$(NoWarn);CS1998</NoWarn>
<NoWarn>$(NoWarn);CS1998</NoWarn><!--Lacks await in async-->
</PropertyGroup>

<PropertyGroup Condition="'$(TF_BUILD)' == 'true' or '$(GITHUB_ACTIONS)'=='true'">
Expand Down
1 change: 1 addition & 0 deletions src/TestApp/shared/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ private static void InitializeLogging()
builder.AddFilter("Uno.UI.RemoteControl", LogLevel.Debug);
builder.AddFilter("Uno.UI.RuntimeTests.Internal.Helpers", LogLevel.Debug); // DevServer and SecondaryApp
builder.AddFilter("Uno.UI.RuntimeTests.HotReloadHelper", LogLevel.Trace); // Helper used by tests in secondary app instances (non debuggable)
builder.AddFilter("Uno.UI.RuntimeTests.UnitTestsControl", LogLevel.Information); // Dumps the runner status
// Generic Xaml events
// builder.AddFilter("Windows.UI.Xaml", LogLevel.Debug );
Expand Down
4 changes: 2 additions & 2 deletions src/TestApp/shared/HotReloadTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ public async Task Is_UIHotReload_Enabled(CancellationToken ct)

await UIHelper.Load(new HotReloadTests_Subject(), ct);

Assert.AreEqual("Original text", UIHelper.FindChildren<TextBlock>().Single().Text);
Assert.AreEqual("Original text", UIHelper.GetChild<TextBlock>().Text);

await using var _ = await HotReloadHelper.UpdateServerFile<HotReloadTests_Subject>("Original text", "Updated text", ct);

await TestHelper.WaitFor(() => UIHelper.FindChildren<TextBlock>().Single().Text, "Updated text", ct);
await AsyncAssert.AreEqual("Updated text", () => UIHelper.GetChild<TextBlock>().Text, ct);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ namespace Uno.UI.RuntimeTests.Engine;
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
public sealed class RuntimeTestsSourceProjectAttribute : Attribute
{
// Note: This is somehow a duplicate of the Uno.UI.RemoteControl.ProjectConfigurationAttribute but it allows us to have the attribute even in release ==>> TODO: which is needed anyway ???
// and also to be defined on the assembly that is compiling the runtime test engine (instead on the app head only) which allows us to use it in HotReloadTestHelper without having any dependency on the app type.
// Note: This is somehow a duplicate of the Uno.UI.RemoteControl.ProjectConfigurationAttribute but it allows us to have the attribute
// to be defined on the assembly that is compiling the runtime test engine (instead on the app head only)
// which allows us to use it in HotReloadTestHelper without having any dependency on the app type.

public string ProjectFullPath { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ private void ReportTestResult(params TestCaseResult[] results)
UpdateUI(result);
}
});
#if HAS_UNO
foreach (var result in results)
{
_log?.Info($"Test completed '{result.TestName}'='{result.TestResult}'");
}
#endif

void UpdateUI(TestCaseResult result)
{
Expand Down Expand Up @@ -726,13 +732,12 @@ private async Task ExecuteTestsForInstance(
try
{
var testCases = tests.SelectMany(t => t.GetCases(ct)).ToList();
#pragma warning disable CS0162 // Code not reachable
if (!SecondaryApp.IsSupported && secondaryApp.IgnoreIfNotSupported && !config.IsRunningIgnored)
{
foreach (var testCase in testCases)
{
ReportTestResult(
instance.GetType().Name,
testCase.ToString(),
TimeSpan.Zero,
TestResult.Skipped,
null,
Expand All @@ -741,7 +746,6 @@ private async Task ExecuteTestsForInstance(

return;
}
#pragma warning restore CS0162

config = config with { Filter = $"{testClassInfo.Type.FullName} & ({config.Filter})" };

Expand All @@ -751,7 +755,6 @@ private async Task ExecuteTestsForInstance(
ReportTestResult(result);
}


if (results.Length != testCases.Count)
{
ReportTestResult(
Expand Down
1,179 changes: 1,179 additions & 0 deletions src/Uno.UI.RuntimeTests.Engine.Library/Library/Helpers/AsyncAssert.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#if !UNO_RUNTIMETESTS_DISABLE_LIBRARY
#nullable enable

#if !IS_UNO_RUNTIMETEST_PROJECT
#pragma warning disable
#endif

using System;
using System.Collections.Generic;
using System.Text;

#if !HAS_UNO_DEVSERVER
namespace Uno.UI.RemoteControl
{
public partial class RemoteControlClient
{
public static RemoteControlClient? Instance => null;
}
}

namespace Uno.UI.RemoteControl.HotReload.Messages
{
public partial class UpdateFile
{
public string FilePath { get; set; } = string.Empty;
public string OldText { get; set; } = string.Empty;
public string NewText { get; set; } = string.Empty;
}
}
#endif
#endif
Loading

0 comments on commit 959216c

Please sign in to comment.