Fix all tests.

This commit is contained in:
BDisp
2024-03-25 17:36:35 +00:00
parent ed697a21cd
commit 41971a6e5a
40 changed files with 1529 additions and 1161 deletions

View File

@@ -31,8 +31,9 @@ public class ScrollViewTests
sv.ShowHorizontalScrollIndicator = true;
sv.ShowVerticalScrollIndicator = true;
Application.Top.Add (sv);
Application.Begin (Application.Top);
var top = new Toplevel ();
top.Add (sv);
Application.Begin (top);
Assert.Equal (new Rectangle (0, 0, 10, 10), sv.Bounds);
@@ -138,8 +139,9 @@ public class ScrollViewTests
{
var sv = new ScrollView { Width = 10, Height = 10 };
Application.Top.Add (sv);
Application.Begin (Application.Top);
var top = new Toplevel ();
top.Add (sv);
Application.Begin (top);
Assert.True (sv.AutoHideScrollBars);
Assert.False (sv.ShowHorizontalScrollIndicator);
@@ -186,8 +188,9 @@ public class ScrollViewTests
KeepContentAlwaysInViewport = false
};
var bottomLabel = new Label { X = 15, Y = 15, Text = "At 15,15" };
Application.Top.Add (topLabel, sv, bottomLabel);
Application.Begin (Application.Top);
var top = new Toplevel ();
top.Add (topLabel, sv, bottomLabel);
Application.Begin (top);
TestHelpers.AssertDriverContentsWithFrameAre (
@"
@@ -445,8 +448,9 @@ public class ScrollViewTests
Width = 10, Height = 10, ContentSize = new (50, 50), ContentOffset = new (25, 25)
};
Application.Top.Add (sv);
Application.Begin (Application.Top);
var top = new Toplevel ();
top.Add (sv);
Application.Begin (top);
Assert.Equal(new(-25,-25),sv.ContentOffset);
Assert.Equal(new(50,50),sv.ContentSize);
@@ -477,8 +481,9 @@ public class ScrollViewTests
{
var sv = new ScrollView { Width = 10, Height = 10, ContentSize = new (50, 50) };
Application.Top.Add (sv);
Application.Begin (Application.Top);
var top = new Toplevel ();
top.Add (sv);
Application.Begin (top);
Assert.Equal (50, sv.ContentSize.Width);
Assert.Equal (50, sv.ContentSize.Height);
@@ -543,8 +548,9 @@ public class ScrollViewTests
scrollView.Add (view);
var win = new Window { X = 1, Y = 1, Width = 20, Height = 14 };
win.Add (scrollView);
Application.Top.Add (win);
Application.Begin (Application.Top);
var top = new Toplevel ();
top.Add (win);
Application.Begin (top);
var expected = @"
┌──────────────────┐
@@ -568,7 +574,7 @@ public class ScrollViewTests
Assert.Equal (new Rectangle (1, 1, 21, 14), pos);
Assert.True (scrollView.OnKeyDown (Key.CursorRight));
Application.Top.Draw ();
top.Draw ();
expected = @"
┌──────────────────┐
@@ -592,7 +598,7 @@ public class ScrollViewTests
Assert.Equal (new Rectangle (1, 1, 21, 14), pos);
Assert.True (scrollView.OnKeyDown (Key.CursorRight));
Application.Top.Draw ();
top.Draw ();
expected = @"
┌──────────────────┐
@@ -616,7 +622,7 @@ public class ScrollViewTests
Assert.Equal (new Rectangle (1, 1, 21, 14), pos);
Assert.True (scrollView.OnKeyDown (Key.CursorRight));
Application.Top.Draw ();
top.Draw ();
expected = @"
┌──────────────────┐
@@ -640,7 +646,7 @@ public class ScrollViewTests
Assert.Equal (new Rectangle (1, 1, 21, 14), pos);
Assert.True (scrollView.OnKeyDown (Key.CursorRight));
Application.Top.Draw ();
top.Draw ();
expected = @"
┌──────────────────┐
@@ -664,7 +670,7 @@ public class ScrollViewTests
Assert.Equal (new Rectangle (1, 1, 21, 14), pos);
Assert.True (scrollView.OnKeyDown (Key.CursorRight));
Application.Top.Draw ();
top.Draw ();
expected = @"
┌──────────────────┐
@@ -688,7 +694,7 @@ public class ScrollViewTests
Assert.Equal (new Rectangle (1, 1, 21, 14), pos);
Assert.True (scrollView.OnKeyDown (Key.CursorRight));
Application.Top.Draw ();
top.Draw ();
expected = @"
┌──────────────────┐
@@ -712,7 +718,7 @@ public class ScrollViewTests
Assert.Equal (new Rectangle (1, 1, 21, 14), pos);
Assert.True (scrollView.OnKeyDown (Key.CursorRight));
Application.Top.Draw ();
top.Draw ();
expected = @"
┌──────────────────┐
@@ -735,7 +741,7 @@ public class ScrollViewTests
Assert.Equal (new Rectangle (1, 1, 21, 14), pos);
Assert.True (scrollView.OnKeyDown (Key.End.WithCtrl));
Application.Top.Draw ();
top.Draw ();
expected = @"
┌──────────────────┐
@@ -759,7 +765,7 @@ public class ScrollViewTests
Assert.True (scrollView.OnKeyDown (Key.Home.WithCtrl));
Assert.True (scrollView.OnKeyDown (Key.CursorDown));
Application.Top.Draw ();
top.Draw ();
expected = @"
┌──────────────────┐
@@ -782,7 +788,7 @@ public class ScrollViewTests
Assert.Equal (new Rectangle (1, 1, 21, 14), pos);
Assert.True (scrollView.OnKeyDown (Key.CursorDown));
Application.Top.Draw ();
top.Draw ();
expected = @"
┌──────────────────┐
@@ -805,7 +811,7 @@ public class ScrollViewTests
Assert.Equal (new Rectangle (1, 1, 21, 14), pos);
Assert.True (scrollView.OnKeyDown (Key.CursorDown));
Application.Top.Draw ();
top.Draw ();
expected = @"
┌──────────────────┐
@@ -828,7 +834,7 @@ public class ScrollViewTests
Assert.Equal (new Rectangle (1, 1, 21, 14), pos);
Assert.True (scrollView.OnKeyDown (Key.End));
Application.Top.Draw ();
top.Draw ();
expected = @"
┌──────────────────┐
@@ -870,8 +876,9 @@ public class ScrollViewTests
sv.Add (new CustomButton ("█", $"Button {i}", 20, 3) { Y = i * 3 });
}
Application.Top.Add (sv);
Application.Begin (Application.Top);
var top = new Toplevel ();
top.Add (sv);
Application.Begin (top);
TestHelpers.AssertDriverContentsWithFrameAre (
@"
@@ -1052,8 +1059,9 @@ public class ScrollViewTests
new View { Y = 51, Width = Dim.Fill (), Height = Dim.Fill (), Id = "View2" }
);
Application.Top.Add (sv);
Application.Begin (Application.Top);
var top = new Toplevel ();
top.Add (sv);
Application.Begin (top);
Assert.Equal (4, sv.Subviews.Count);
Assert.Equal (2, sv.Subviews [0].Subviews.Count);