Skip to content

Commit

Permalink
Merge pull request #162 from unoplatform/dev/dr/unoSupport
Browse files Browse the repository at this point in the history
feat: Add partial construtor injection point in UnitTestControl + fix logging
  • Loading branch information
dr1rrb authored Jan 11, 2024
2 parents e3031e2 + 047f631 commit a2d6431
Showing 1 changed file with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#pragma warning disable
#endif
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
#pragma warning disable CA1848 // Use the LoggerMessage delegates

using System;
using System.Collections.Generic;
Expand All @@ -28,11 +29,6 @@
using Uno.UI.RuntimeTests.Engine;
using Uno.UI.RuntimeTests.Internal.Helpers;

#if HAS_UNO
using Uno.Foundation.Logging;
using Uno.Logging;
#endif

#if HAS_UNO_WINUI || WINDOWS_WINUI
using Windows.UI;
using Windows.UI.Core;
Expand Down Expand Up @@ -66,9 +62,7 @@ namespace Uno.UI.RuntimeTests;
public sealed partial class UnitTestsControl : UserControl
{
#pragma warning disable CS0109
#if HAS_UNO
private new readonly ILogger _log = Uno.Extensions.LogExtensionPoint.Log(typeof(UnitTestsControl));
#endif
#pragma warning restore CS0109

private Task? _runner;
Expand Down Expand Up @@ -116,8 +110,12 @@ public UnitTestsControl()
#if HAS_UNO
_applicationView = ApplicationView.GetForCurrentView();
#endif

ConstructPartial();
}

partial void ConstructPartial();

internal IEnumerable<TestCaseResult> Results => _testCases;

private static void OverrideDebugProviderAsserts()
Expand Down Expand Up @@ -262,9 +260,7 @@ private void StopRunningTests()

private async Task ReportMessage(string message, bool isRunning = true)
{
#if HAS_UNO
_log?.Info(message);
#endif
_log.LogInformation(message);

void Setter()
{
Expand Down Expand Up @@ -358,12 +354,11 @@ private void ReportTestResult(params TestCaseResult[] results)
UpdateUI(result);
}
});
#if HAS_UNO

foreach (var result in results)
{
_log?.Info($"Test completed '{result.TestName}'='{result.TestResult}'");
_log.LogInformation($"Test completed '{result.TestName}'='{result.TestResult}'");
}
#endif

void UpdateUI(TestCaseResult result)
{
Expand Down Expand Up @@ -536,10 +531,9 @@ private void EnableConfigPersistence()
testFilter.Text = config.Filter;
}
}
catch (Exception)
catch (Exception error)
{
// UNO MOVE
// _log.Error("Failed to restore runtime tests config", e);
_log.LogError(error, "Failed to restore runtime tests config.");
}
}

Expand Down

0 comments on commit a2d6431

Please sign in to comment.