Files
Terminal.Gui/Tests/UnitTests/Views/ScrollSliderTests.cs
Tig acb5979e6c Cleans up/Refactors View.Subviews (#3962)
* Subview clean up

* New Add/Remove event pattern

* Using Logging

* cleanup

* Subview -> SubView

* Test code cleanup. Killed many warnings.

* Fix tznind feedback

* Refactored AllViewTest helpers

* Moved keyboard tests to parallel

* Moved mouse tests to parallel

* Moved view tests to parallel

* Test code cleanup. Killed many warnings.

* dupe test

* Some mouse tests can't run in parallel because MouseGrabView

* Made SpinnerView more testable

* Moved more tests

* SubViews to IReadOnlyCollection<View>

* SubViews to IReadOnlyCollection<View> 2

* scrollbar tests

* shortcut tests

* Use InternalSubViews vs. _subviews

* Nuked View.IsAdded.
Added View.SuperViewChanged.

* API doc updats

* Unit Test tweak

* Unit Test tweak
2025-03-08 15:42:17 -07:00

341 lines
7.3 KiB
C#

using UnitTests;
using Xunit.Abstractions;
namespace Terminal.Gui.ViewsTests;
public class ScrollSliderTests (ITestOutputHelper output)
{
[Theory]
[SetupFakeDriver]
[InlineData (
3,
10,
1,
0,
Orientation.Vertical,
@"
┌───┐
│███│
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└───┘")]
[InlineData (
10,
1,
3,
0,
Orientation.Horizontal,
@"
┌──────────┐
│███ │
└──────────┘")]
[InlineData (
3,
10,
3,
0,
Orientation.Vertical,
@"
┌───┐
│███│
│███│
│███│
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└───┘")]
[InlineData (
3,
10,
5,
0,
Orientation.Vertical,
@"
┌───┐
│███│
│███│
│███│
│███│
│███│
│ │
│ │
│ │
│ │
│ │
└───┘")]
[InlineData (
3,
10,
5,
1,
Orientation.Vertical,
@"
┌───┐
│ │
│███│
│███│
│███│
│███│
│███│
│ │
│ │
│ │
│ │
└───┘")]
[InlineData (
3,
10,
5,
4,
Orientation.Vertical,
@"
┌───┐
│ │
│ │
│ │
│ │
│███│
│███│
│███│
│███│
│███│
│ │
└───┘")]
[InlineData (
3,
10,
5,
5,
Orientation.Vertical,
@"
┌───┐
│ │
│ │
│ │
│ │
│ │
│███│
│███│
│███│
│███│
│███│
└───┘")]
[InlineData (
3,
10,
5,
6,
Orientation.Vertical,
@"
┌───┐
│ │
│ │
│ │
│ │
│ │
│███│
│███│
│███│
│███│
│███│
└───┘")]
[InlineData (
3,
10,
10,
0,
Orientation.Vertical,
@"
┌───┐
│███│
│███│
│███│
│███│
│███│
│███│
│███│
│███│
│███│
│███│
└───┘")]
[InlineData (
3,
10,
10,
5,
Orientation.Vertical,
@"
┌───┐
│███│
│███│
│███│
│███│
│███│
│███│
│███│
│███│
│███│
│███│
└───┘")]
[InlineData (
3,
10,
11,
0,
Orientation.Vertical,
@"
┌───┐
│███│
│███│
│███│
│███│
│███│
│███│
│███│
│███│
│███│
│███│
└───┘")]
[InlineData (
10,
3,
5,
0,
Orientation.Horizontal,
@"
┌──────────┐
│█████ │
│█████ │
│█████ │
└──────────┘")]
[InlineData (
10,
3,
5,
1,
Orientation.Horizontal,
@"
┌──────────┐
│ █████ │
│ █████ │
│ █████ │
└──────────┘")]
[InlineData (
10,
3,
5,
4,
Orientation.Horizontal,
@"
┌──────────┐
│ █████ │
│ █████ │
│ █████ │
└──────────┘")]
[InlineData (
10,
3,
5,
5,
Orientation.Horizontal,
@"
┌──────────┐
│ █████│
│ █████│
│ █████│
└──────────┘")]
[InlineData (
10,
3,
5,
6,
Orientation.Horizontal,
@"
┌──────────┐
│ █████│
│ █████│
│ █████│
└──────────┘")]
[InlineData (
10,
3,
10,
0,
Orientation.Horizontal,
@"
┌──────────┐
│██████████│
│██████████│
│██████████│
└──────────┘")]
[InlineData (
10,
3,
10,
5,
Orientation.Horizontal,
@"
┌──────────┐
│██████████│
│██████████│
│██████████│
└──────────┘")]
[InlineData (
10,
3,
11,
0,
Orientation.Horizontal,
@"
┌──────────┐
│██████████│
│██████████│
│██████████│
└──────────┘")]
public void Draws_Correctly (int superViewportWidth, int superViewportHeight, int sliderSize, int position, Orientation orientation, string expected)
{
var super = new Window
{
Id = "super",
Width = superViewportWidth + 2,
Height = superViewportHeight + 2
};
var scrollSlider = new ScrollSlider
{
Orientation = orientation,
Size = sliderSize,
//Position = position,
};
Assert.Equal (sliderSize, scrollSlider.Size);
super.Add (scrollSlider);
scrollSlider.Position = position;
super.Layout ();
super.Draw ();
_ = DriverAssert.AssertDriverContentsWithFrameAre (expected, output);
}
}