diff --git a/.github/actions/comment-progress/action.yml b/.github/actions/comment-progress/action.yml index ae18ff5f5..cafc3e5f9 100644 --- a/.github/actions/comment-progress/action.yml +++ b/.github/actions/comment-progress/action.yml @@ -42,9 +42,9 @@ runs: }); content = content - .replace(new RegExp('#success', 'g'), '✅ passed') - .replace(new RegExp('#failure', 'g'), '❌ failed') - .replace(new RegExp('#cancelled', 'g'), '⚠️ cancelled'); + .replace(new RegExp('#success', 'g'), '✅') + .replace(new RegExp('#failure', 'g'), '❌') + .replace(new RegExp('#cancelled', 'g'), '⚠️'); let body = comment.data.body; diff --git a/.github/workflows/livecharts.yml b/.github/workflows/livecharts.yml index debbb4326..cfa33f068 100644 --- a/.github/workflows/livecharts.yml +++ b/.github/workflows/livecharts.yml @@ -19,7 +19,7 @@ jobs: id: create-comment with: content: | - Thanks for your contribution! + ### Thanks for your contribution! 🤗 (1 / 4) The build and test process is starting. This may take a while. You can find more details below as the process continues or at the [actions tab](https://github.com/Live-Charts/LiveCharts2/actions/runs/${{ github.run_id }}). @@ -100,16 +100,14 @@ jobs: comment_id: ${{ needs.report-progress-starting.outputs.comment_id }} content: | - --- - - All packages have been packed successfully! 📦✅ - You can download the NuGet packages for this build [here](${{ steps.merge.outputs.artifact-url }}). + ### Packing complete! 📦 (2 / 4) + You can download the NuGet packages for this build [here](${{ steps.merge.outputs.artifact-url }}). The packages will be available for 30 days, you can either [use them directly](https://stackoverflow.com/questions/43400069/add-a-package-with-a-local-package-file-in-dotnet), or wait for this PR to be merged to have them published to NuGet.org. - --- + ### Running tests 🧪 (3 / 4) - Tests will start now, you can monitor their progress below or at the [actions tab](https://github.com/Live-Charts/LiveCharts2/actions/runs/${{ github.run_id }}). + Tests are running now, you can monitor their progress below or at the [actions tab](https://github.com/Live-Charts/LiveCharts2/actions/runs/${{ github.run_id }}). test-core: runs-on: windows-2025 @@ -236,12 +234,12 @@ jobs: fail-fast: false matrix: include: - # not running, blazor issue? factos issue? tests issue? + # ToDo: find why not running. # - id: blazor # workloads: wasm-tools - id: avalonia-browser workloads: wasm-tools - # not running, uno issue? factos issue? tests issue? + # ToDo: find why not running. # - id: uno # tf: net10.0-browserwasm # workloads: wasm-tools android @@ -257,7 +255,7 @@ jobs: use-factos: true test-id: ${{ matrix.id }} workloads: ${{ matrix.workloads }} - # target-framework: ${{ matrix.tf }} + target-framework: ${{ matrix.tf }} comment_id: ${{ needs.report-progress-starting.outputs.comment_id }} test-android: @@ -271,7 +269,7 @@ jobs: - id: maui tf: net10.0-android workloads: maui-android - # disabled for now, in this uno version, idk why on android no tests are detected. + # ToDo: find why not running. # - id: uno # tf: net10.0-android # workloads: android @@ -297,8 +295,8 @@ jobs: fail-fast: false matrix: include: - # - id: avalonia-ios - # workloads: ios + - id: avalonia-ios + workloads: ios - id: maui tf: net10.0-ios workloads: maui @@ -358,11 +356,9 @@ jobs: with: comment_id: ${{ needs.report-progress-starting.outputs.comment_id }} content: | - ### Test Results Summary (Passed) ✅ :partying_face: + core #${{ needs.test-core.result }}, windows #${{ needs.test-windows.result }}, linux #${{ needs.test-linux.result }}, mac #${{ needs.test-mac.result }}, browser #${{ needs.test-browser.result }}, android #${{ needs.test-android.result }}, ios #${{ needs.test-ios.result }} - ${{ steps.report.outputs.skipped }} skipped. - ${{ steps.report.outputs.failed }} failed. - ${{ steps.report.outputs.passed }} passed! ✅ + ### Test Results Summary (Passed) ✅ (4 / 4) - name: Report tests failure if: ${{ always() && (contains(join(needs.*.result, ' '), 'failure') || contains(join(needs.*.result, ' '), 'cancelled')) }} @@ -370,12 +366,8 @@ jobs: with: comment_id: ${{ needs.report-progress-starting.outputs.comment_id }} content: | - ### Test Results Summary (Failure) ❌ :disappointed_relieved: - - | Core | Windows | Linux | Mac | Browser | Android | iOS | - |-------|---------|-------|-----|---------|---------|-----| - | #${{ needs.test-core.result }} | #${{ needs.test-windows.result }} | #${{ needs.test-linux.result }} | #${{ needs.test-mac.result }} | #${{ needs.test-browser.result }} | #${{ needs.test-android.result }} | #${{ needs.test-ios.result }} | + + Core #${{ needs.test-core.result }} | Windows #${{ needs.test-windows.result }} | Linux #${{ needs.test-linux.result }} | Mac #${{ needs.test-mac.result }} | Browser #${{ needs.test-browser.result }} | Android #${{ needs.test-android.result }} | iOS #${{ needs.test-ios.result }} - ${{ steps.report.outputs.skipped }} skipped. - ${{ steps.report.outputs.passed }} passed. - ${{ steps.report.outputs.failed }} failed. ❌ \ No newline at end of file + ### Test Results Summary (Failure) ❌ (4 / 4) + \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props index 716be58e8..59cf79c5d 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -32,6 +32,7 @@ false + $(NoWarn);NETSDK1198;NU1701;XC0022;XA0141;XAAADB0000;CS0067;CS0414;CS0108;CS0618;CS4014;CS8600;CS8601;CS8602;CS8603;CS8612;CS8618;CS8622;CS8625;CS8629;CS9264; 0.8.0 @@ -42,14 +43,14 @@ - false - true - 30 - false + default + default + 30 + false + $(NoWarnUITests) $(DefineConstants);UI_TESTING;XAML_UI_TESTING;AVALONIA_UI_TESTING diff --git a/samples/BlazorSample/BlazorSample.csproj b/samples/BlazorSample/BlazorSample.csproj index 113730193..3c190b396 100644 --- a/samples/BlazorSample/BlazorSample.csproj +++ b/samples/BlazorSample/BlazorSample.csproj @@ -42,6 +42,7 @@ + $(NoWarnUITests) $(DefineConstants);UI_TESTING;BLAZOR_UI_TESTING diff --git a/samples/EtoFormsSample/EtoFormsSample.csproj b/samples/EtoFormsSample/EtoFormsSample.csproj index b607f8d78..14809f8fa 100644 --- a/samples/EtoFormsSample/EtoFormsSample.csproj +++ b/samples/EtoFormsSample/EtoFormsSample.csproj @@ -47,6 +47,7 @@ + $(NoWarnUITests) $(DefineConstants);UI_TESTING;ETO_UI_TESTING diff --git a/samples/MauiSample/MauiSample.csproj b/samples/MauiSample/MauiSample.csproj index e3727dd0d..c5e3d7e9d 100644 --- a/samples/MauiSample/MauiSample.csproj +++ b/samples/MauiSample/MauiSample.csproj @@ -88,6 +88,7 @@ + $(NoWarnUITests) $(DefineConstants);UI_TESTING;XAML_UI_TESTING;MAUI_UI_TESTING diff --git a/samples/UnoPlatformSample/UnoPlatformSample/UnoPlatformSample.csproj b/samples/UnoPlatformSample/UnoPlatformSample/UnoPlatformSample.csproj index cf112e00a..76486172c 100644 --- a/samples/UnoPlatformSample/UnoPlatformSample/UnoPlatformSample.csproj +++ b/samples/UnoPlatformSample/UnoPlatformSample/UnoPlatformSample.csproj @@ -80,6 +80,7 @@ + $(NoWarnUITests) $(DefineConstants);UI_TESTING;XAML_UI_TESTING;UNO_UI_TESTING diff --git a/samples/WPFSample/WPFSample.csproj b/samples/WPFSample/WPFSample.csproj index ceec6cfd3..97e69dade 100644 --- a/samples/WPFSample/WPFSample.csproj +++ b/samples/WPFSample/WPFSample.csproj @@ -35,6 +35,7 @@ + $(NoWarnUITests) $(DefineConstants);UI_TESTING;XAML_UI_TESTING;WPF_UI_TESTING @@ -42,6 +43,15 @@ + + + $(DefineConstants);TEST_HA_VIEWS + + diff --git a/samples/WinFormsSample/WinFormsSample.csproj b/samples/WinFormsSample/WinFormsSample.csproj index 9f142e34a..6fe8a8870 100644 --- a/samples/WinFormsSample/WinFormsSample.csproj +++ b/samples/WinFormsSample/WinFormsSample.csproj @@ -26,6 +26,7 @@ + $(NoWarnUITests) $(DefineConstants);UI_TESTING;WINFORMS_UI_TESTING diff --git a/samples/WinUISample/WinUISample/WinUISample.csproj b/samples/WinUISample/WinUISample/WinUISample.csproj index e61833a5b..39c90658a 100644 --- a/samples/WinUISample/WinUISample/WinUISample.csproj +++ b/samples/WinUISample/WinUISample/WinUISample.csproj @@ -71,6 +71,7 @@ + $(NoWarnUITests) $(DefineConstants);UI_TESTING;XAML_UI_TESTING;WINUI_UI_TESTING diff --git a/src/LiveChartsCore/Motion/CoreMotionCanvas.cs b/src/LiveChartsCore/Motion/CoreMotionCanvas.cs index f1a74177e..ced97cf1b 100644 --- a/src/LiveChartsCore/Motion/CoreMotionCanvas.cs +++ b/src/LiveChartsCore/Motion/CoreMotionCanvas.cs @@ -120,6 +120,11 @@ internal CanvasZone[] Zones /// public object Sync { get; internal set => field = value ?? new object(); } = new(); + /// + /// Gets the name of the renderer associated with the current canvas instance. + /// + public string RendererName => s_rendererName ?? "unknown renderer"; + /// /// Draws the frame. /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/MotionCanvas.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/MotionCanvas.cs index 2e5bf674c..c9b4e2deb 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/MotionCanvas.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/MotionCanvas.cs @@ -52,9 +52,14 @@ static MotionCanvas() return new MotionCanvasComposer(renderMode, ticker); #else - IRenderMode renderMode = settings.UseGPU - ? throw new System.Exception("LiveCharts does not support hardware acceleration in WPF .Net Framework.") - : new CPURenderMode(); + if (settings.UseGPU) + { + System.Diagnostics.Trace.WriteLine( + "LiveCharts does not support hardware acceleration in WPF .Net Framework. " + + "Falling back to CPU rendering. To use GPU rendering, please migrate your project to .Net 6 or later."); + } + + IRenderMode renderMode = new CPURenderMode(); IFrameTicker ticker = settings.TryUseVSync ? new CompositionTargetTicker() diff --git a/tests/CoreTests/CoreTests.csproj b/tests/CoreTests/CoreTests.csproj index c5082922f..0ea7ad985 100644 --- a/tests/CoreTests/CoreTests.csproj +++ b/tests/CoreTests/CoreTests.csproj @@ -7,7 +7,7 @@ - $(NoWarn);MSTEST0037;MSTEST0023;CS0618 + $(NoWarnUITests);MSTEST0037;MSTEST0023;CS0618 diff --git a/tests/SharedUITests/AvaloniaTests.cs b/tests/SharedUITests/AvaloniaTests.cs deleted file mode 100644 index c8b6dce00..000000000 --- a/tests/SharedUITests/AvaloniaTests.cs +++ /dev/null @@ -1,37 +0,0 @@ -#if AVALONIA_UI_TESTING - -using Factos; -using SharedUITests.Helpers; -using Xunit; - -namespace SharedUITests; - -public class AvaloniaTests -{ - public AppController App => AppController.Current; - - // based on: - // https://github.com/Live-Charts/LiveCharts2/issues/1986 - // ensure charts load when avalonia virtualization is on. - [AppTestMethod] - public async Task TabControlScrollViewerRendersAfterTabSwitch() - { - var sut = await App.NavigateTo(); - - // open the second tab, scroll to end and ensure the chart is loaded. - sut.OpenTab2(); - await Task.Delay(1000); - sut.ScrollToChart(); - await Task.Delay(1000); - Assert.ChartIsLoaded(sut.Chart2); - - // now open the first tab, scroll to end and ensure the chart is loaded. - sut.OpenTab1(); - await Task.Delay(1000); - sut.ScrollToChart(); - await Task.Delay(1000); - Assert.ChartIsLoaded(sut.Chart1); - } -} - -#endif diff --git a/tests/SharedUITests/CartesianChartTests.cs b/tests/SharedUITests/CartesianChartTests.cs index 510c86fc7..85663dea8 100644 --- a/tests/SharedUITests/CartesianChartTests.cs +++ b/tests/SharedUITests/CartesianChartTests.cs @@ -21,6 +21,8 @@ public async Task ShouldLoad() } #if XAML_UI_TESTING + // xaml platforms tests. + [AppTestMethod] public async Task ShouldLoadTemplatedChart() { @@ -73,4 +75,49 @@ public async Task ShouldUnloadAndReload() #endif } #endif + +#if AVALONIA_UI_TESTING + // based on: + // https://github.com/Live-Charts/LiveCharts2/issues/1986 + // ensure charts load when avalonia virtualization is on. + + [AppTestMethod] + public async Task TabControlScrollViewerRendersAfterTabSwitch() + { + var sut = await App.NavigateTo(); + + // open the second tab, scroll to end and ensure the chart is loaded. + sut.OpenTab2(); + await Task.Delay(1000); + sut.ScrollToChart(); + await Task.Delay(1000); + Assert.ChartIsLoaded(sut.Chart2); + + // now open the first tab, scroll to end and ensure the chart is loaded. + sut.OpenTab1(); + await Task.Delay(1000); + sut.ScrollToChart(); + await Task.Delay(1000); + Assert.ChartIsLoaded(sut.Chart1); + } +#endif + +#if (WPF_UI_TESTING && TEST_HA_VIEWS) || MAUI_UI_TESTING || WINUI_UI_TESTING || (UNO_UI_TESTING && HAS_OS_LVC) + // native platforms where gpu is supported + + [AppTestMethod] + public async Task ShouldLoadHardwareAcceleratedView() + { + LiveChartsCore.LiveCharts.Configure(config => config.HasRenderingSettings(builder => builder.UseGPU = true)); + + var sut = await App.NavigateTo(); + await sut.Chart.WaitUntilChartRenders(); + + Assert.Contains("GPU", sut.Chart.CoreCanvas.RendererName); + Assert.ChartIsLoaded(sut.Chart); + + // restore default settings for other tests + LiveChartsCore.LiveCharts.Configure(config => config.HasRenderingSettings(builder => builder.UseGPU = false)); + } +#endif } diff --git a/tests/SharedUITests/PieChartTests.cs b/tests/SharedUITests/PieChartTests.cs index 943a0b055..07651bfc5 100644 --- a/tests/SharedUITests/PieChartTests.cs +++ b/tests/SharedUITests/PieChartTests.cs @@ -55,4 +55,23 @@ public async Task ShouldUnloadAndReload() #endif } #endif + +#if (WPF_UI_TESTING && TEST_HA_VIEWS) || MAUI_UI_TESTING || WINUI_UI_TESTING || (UNO_UI_TESTING && HAS_OS_LVC) + // native platforms where gpu is supported + + [AppTestMethod] + public async Task ShouldLoadHardwareAcceleratedView() + { + LiveChartsCore.LiveCharts.Configure(config => config.HasRenderingSettings(builder => builder.UseGPU = true)); + + var sut = await App.NavigateTo(); + await sut.Chart.WaitUntilChartRenders(); + + Assert.Contains("GPU", sut.Chart.CoreCanvas.RendererName); + Assert.ChartIsLoaded(sut.Chart); + + // restore default settings for other tests + LiveChartsCore.LiveCharts.Configure(config => config.HasRenderingSettings(builder => builder.UseGPU = false)); + } +#endif }