Skip to content
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
44 changes: 44 additions & 0 deletions samples/AvaloniaSample/VisualTest/VirtualizationTest/View.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<UserControl
x:Class="AvaloniaSample.VisualTest.VirtualizationTest.View"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:lvc="using:LiveChartsCore.SkiaSharpView.Avalonia">

<TabControl x:Name="tabs">
<TabItem Header="page 1">
<ScrollViewer>
<StackPanel Orientation="Vertical">
<Rectangle Height="3000" Width="100" Fill="Red"/>
<lvc:CartesianChart x:Name="chart1" Height="300">
<lvc:CartesianChart.Series>
<lvc:XamlLineSeries
SeriesName="Mary"
Values="{lvc:Values FromString='5, 10, 8, 4'}"/>
<lvc:XamlColumnSeries
SeriesName="Ana"
Values="{lvc:Values FromString='4, 7, 3, 8'}"/>
</lvc:CartesianChart.Series>
</lvc:CartesianChart>
</StackPanel>
</ScrollViewer>
</TabItem>
<TabItem Header="page 2">
<ScrollViewer>
<StackPanel Orientation="Vertical">
<Rectangle Height="3000" Width="100" Fill="Red"/>
<lvc:CartesianChart x:Name="chart2" Height="300">
<lvc:CartesianChart.Series>
<lvc:XamlLineSeries
SeriesName="Mary"
Values="{lvc:Values FromString='5, 10, 8, 4'}"/>
<lvc:XamlColumnSeries
SeriesName="Ana"
Values="{lvc:Values FromString='4, 7, 3, 8'}"/>
</lvc:CartesianChart.Series>
</lvc:CartesianChart>
</StackPanel>
</ScrollViewer>
</TabItem>
</TabControl>

</UserControl>
24 changes: 24 additions & 0 deletions samples/AvaloniaSample/VisualTest/VirtualizationTest/View.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using LiveChartsCore.SkiaSharpView.Avalonia;

namespace AvaloniaSample.VisualTest.VirtualizationTest;

public partial class View : UserControl
{
public View()
{
InitializeComponent();
}

public CartesianChart Chart1 => this.Find<CartesianChart>("chart1")!;
public CartesianChart Chart2 => this.Find<CartesianChart>("chart2")!;
public void OpenTab1() => this.Find<TabControl>("tabs")!.SelectedIndex = 0;
public void OpenTab2() => this.Find<TabControl>("tabs")!.SelectedIndex = 1;
public void ScrollToChart() => ((ScrollViewer)this.Find<TabControl>("tabs")!.SelectedContent!).ScrollToEnd();

private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
37 changes: 37 additions & 0 deletions tests/SharedUITests/AvaloniaTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#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<Samples.VisualTest.VirtualizationTest.View>();

// 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);
Comment thread
beto-rodriguez marked this conversation as resolved.
Comment thread
beto-rodriguez marked this conversation as resolved.
Comment thread
beto-rodriguez marked this conversation as resolved.
}
}

#endif
Loading