Merge pull request #1895 from BDisp/textview-scrollto-unit-texts

Proves that the ScrollTo and CursorPosition methods work as expected.
This commit is contained in:
Tig Kindel
2022-07-26 08:41:54 -04:00
committed by GitHub

View File

@@ -5725,5 +5725,47 @@ line.
tv.ProcessKey (new KeyEvent (Key.p, new KeyModifiers ()));
}
[Fact]
[AutoInitShutdown]
public void MoveDown_By_Setting_CursorPosition ()
{
var tv = new TextView {
Width = 10,
Height = 5
};
// add 100 lines of wide text to view
for (int i = 0; i < 100; i++)
tv.Text += new string ('x', 100) + (i == 99 ? "" : Environment.NewLine);
Assert.Equal (new Point (0, 0), tv.CursorPosition);
tv.CursorPosition = new Point (5, 50);
Assert.Equal (new Point (5, 50), tv.CursorPosition);
tv.CursorPosition = new Point (200, 200);
Assert.Equal (new Point (100, 99), tv.CursorPosition);
}
[Fact]
[AutoInitShutdown]
public void ScrollTo_CursorPosition ()
{
var tv = new TextView {
Width = 10,
Height = 5
};
// add 100 lines of wide text to view
for (int i = 0; i < 100; i++)
tv.Text += new string ('x', 100) + (i == 99 ? "" : Environment.NewLine);
Assert.Equal (new Point (0, 0), tv.CursorPosition);
tv.ScrollTo (50);
Assert.Equal (new Point (0, 0), tv.CursorPosition);
tv.CursorPosition = new Point (tv.LeftColumn, tv.TopRow);
Assert.Equal (new Point (0, 50), tv.CursorPosition);
}
}
}