lock cannot have a null argument and sometime the Clipboard.Contents is null.

This commit is contained in:
BDisp
2022-09-18 01:26:52 +01:00
parent e821435bac
commit 17b98ad294
3 changed files with 983 additions and 1014 deletions

View File

@@ -8,16 +8,14 @@ namespace Terminal.Gui.Core {
[AutoInitShutdown]
public void Contents_Gets_Sets ()
{
lock (Clipboard.Contents) {
var clipText = "This is a clipboard unit test.";
Clipboard.Contents = clipText;
var clipText = "This is a clipboard unit test.";
Clipboard.Contents = clipText;
Application.Iteration += () => Application.RequestStop ();
Application.Iteration += () => Application.RequestStop ();
Application.Run ();
Application.Run ();
Assert.Equal (clipText, Clipboard.Contents);
}
Assert.Equal (clipText, Clipboard.Contents);
}
[Fact]
@@ -55,23 +53,21 @@ namespace Terminal.Gui.Core {
[AutoInitShutdown]
public void TrySetClipboardData_Sets_The_OS_Clipboard ()
{
lock (Clipboard.Contents) {
var clipText = "Trying to set the OS clipboard.";
if (Clipboard.IsSupported) {
Assert.True (Clipboard.TrySetClipboardData (clipText));
} else {
Assert.False (Clipboard.TrySetClipboardData (clipText));
}
var clipText = "Trying to set the OS clipboard.";
if (Clipboard.IsSupported) {
Assert.True (Clipboard.TrySetClipboardData (clipText));
} else {
Assert.False (Clipboard.TrySetClipboardData (clipText));
}
Application.Iteration += () => Application.RequestStop ();
Application.Iteration += () => Application.RequestStop ();
Application.Run ();
Application.Run ();
if (Clipboard.IsSupported) {
Assert.Equal (clipText, Clipboard.Contents);
} else {
Assert.NotEqual (clipText, Clipboard.Contents);
}
if (Clipboard.IsSupported) {
Assert.Equal (clipText, Clipboard.Contents);
} else {
Assert.NotEqual (clipText, Clipboard.Contents);
}
}
@@ -79,122 +75,119 @@ namespace Terminal.Gui.Core {
[AutoInitShutdown]
public void Contents_Gets_From_OS_Clipboard ()
{
lock (Clipboard.Contents) {
var clipText = "This is a clipboard unit test to get clipboard from OS.";
var exit = false;
var getClipText = "";
var clipText = "This is a clipboard unit test to get clipboard from OS.";
var exit = false;
var getClipText = "";
Application.Iteration += () => {
if (RuntimeInformation.IsOSPlatform (OSPlatform.Windows)) {
// using (Process clipExe = new Process {
// StartInfo = new ProcessStartInfo {
// RedirectStandardInput = true,
// FileName = "clip"
// }
// }) {
// clipExe.Start ();
// clipExe.StandardInput.Write (clipText);
// clipExe.StandardInput.Close ();
// var result = clipExe.WaitForExit (500);
// if (result) {
// clipExe.WaitForExit ();
// }
// }
Application.Iteration += () => {
if (RuntimeInformation.IsOSPlatform (OSPlatform.Windows)) {
// using (Process clipExe = new Process {
// StartInfo = new ProcessStartInfo {
// RedirectStandardInput = true,
// FileName = "clip"
// }
// }) {
// clipExe.Start ();
// clipExe.StandardInput.Write (clipText);
// clipExe.StandardInput.Close ();
// var result = clipExe.WaitForExit (500);
// if (result) {
// clipExe.WaitForExit ();
// }
// }
using (Process pwsh = new Process {
StartInfo = new ProcessStartInfo {
FileName = "powershell",
Arguments = $"-command \"Set-Clipboard -Value \\\"{clipText}\\\"\""
}
}) {
pwsh.Start ();
pwsh.WaitForExit ();
using (Process pwsh = new Process {
StartInfo = new ProcessStartInfo {
FileName = "powershell",
Arguments = $"-command \"Set-Clipboard -Value \\\"{clipText}\\\"\""
}
getClipText = Clipboard.Contents.ToString ();
}) {
pwsh.Start ();
pwsh.WaitForExit ();
}
getClipText = Clipboard.Contents.ToString ();
} else if (RuntimeInformation.IsOSPlatform (OSPlatform.OSX)) {
using (Process copy = new Process {
StartInfo = new ProcessStartInfo {
RedirectStandardInput = true,
FileName = "pbcopy"
}
}) {
copy.Start ();
copy.StandardInput.Write (clipText);
copy.StandardInput.Close ();
copy.WaitForExit ();
} else if (RuntimeInformation.IsOSPlatform (OSPlatform.OSX)) {
using (Process copy = new Process {
StartInfo = new ProcessStartInfo {
RedirectStandardInput = true,
FileName = "pbcopy"
}
getClipText = Clipboard.Contents.ToString ();
}) {
copy.Start ();
copy.StandardInput.Write (clipText);
copy.StandardInput.Close ();
copy.WaitForExit ();
}
getClipText = Clipboard.Contents.ToString ();
} else if (RuntimeInformation.IsOSPlatform (OSPlatform.Linux)) {
if (Is_WSL_Platform ()) {
try {
using (Process bash = new Process {
StartInfo = new ProcessStartInfo {
FileName = "powershell.exe",
Arguments = $"-noprofile -command \"Set-Clipboard -Value \\\"{clipText}\\\"\""
}
}) {
bash.Start ();
bash.WaitForExit ();
} else if (RuntimeInformation.IsOSPlatform (OSPlatform.Linux)) {
if (Is_WSL_Platform ()) {
try {
using (Process bash = new Process {
StartInfo = new ProcessStartInfo {
FileName = "powershell.exe",
Arguments = $"-noprofile -command \"Set-Clipboard -Value \\\"{clipText}\\\"\""
}
}) {
bash.Start ();
bash.WaitForExit ();
}
//using (Process clipExe = new Process {
// StartInfo = new ProcessStartInfo {
// RedirectStandardInput = true,
// FileName = "clip.exe"
// }
//}) {
// clipExe.Start ();
// clipExe.StandardInput.Write (clipText);
// clipExe.StandardInput.Close ();
// clipExe.WaitForExit ();
// //var result = clipExe.WaitForExit (500);
// //if (result) {
// // clipExe.WaitForExit ();
// //}
//}
} catch {
exit = true;
}
if (!exit) {
getClipText = Clipboard.Contents.ToString ();
}
Application.RequestStop ();
return;
}
if (exit = xclipExists () == false) {
// xclip doesn't exist then exit.
Application.RequestStop ();
return;
}
using (Process bash = new Process {
StartInfo = new ProcessStartInfo {
FileName = "bash",
Arguments = $"-c \"xclip -sel clip -i\"",
RedirectStandardInput = true,
}
}) {
bash.Start ();
bash.StandardInput.Write (clipText);
bash.StandardInput.Close ();
bash.WaitForExit ();
//using (Process clipExe = new Process {
// StartInfo = new ProcessStartInfo {
// RedirectStandardInput = true,
// FileName = "clip.exe"
// }
//}) {
// clipExe.Start ();
// clipExe.StandardInput.Write (clipText);
// clipExe.StandardInput.Close ();
// clipExe.WaitForExit ();
// //var result = clipExe.WaitForExit (500);
// //if (result) {
// // clipExe.WaitForExit ();
// //}
//}
} catch {
exit = true;
}
if (!exit) {
getClipText = Clipboard.Contents.ToString ();
}
Application.RequestStop ();
return;
}
if (exit = xclipExists () == false) {
// xclip doesn't exist then exit.
Application.RequestStop ();
return;
}
Application.RequestStop ();
};
Application.Run ();
if (!exit) {
Assert.Equal (clipText, getClipText);
using (Process bash = new Process {
StartInfo = new ProcessStartInfo {
FileName = "bash",
Arguments = $"-c \"xclip -sel clip -i\"",
RedirectStandardInput = true,
}
}) {
bash.Start ();
bash.StandardInput.Write (clipText);
bash.StandardInput.Close ();
bash.WaitForExit ();
}
if (!exit) {
getClipText = Clipboard.Contents.ToString ();
}
}
Application.RequestStop ();
};
Application.Run ();
if (!exit) {
Assert.Equal (clipText, getClipText);
}
}

View File

@@ -584,42 +584,38 @@ namespace Terminal.Gui.Views {
[InitShutdown]
public void Copy_Or_Cut_And_Paste_With_Selection ()
{
lock (Clipboard.Contents) {
_textField.SelectedStart = 20;
_textField.CursorPosition = 24;
_textField.Copy ();
Assert.Equal ("text", _textField.SelectedText);
Assert.Equal ("TAB to jump between text fields.", _textField.Text);
_textField.Paste ();
Assert.Equal ("TAB to jump between text fields.", _textField.Text);
_textField.SelectedStart = 20;
_textField.Cut ();
_textField.Paste ();
Assert.Equal ("TAB to jump between text fields.", _textField.Text);
}
_textField.SelectedStart = 20;
_textField.CursorPosition = 24;
_textField.Copy ();
Assert.Equal ("text", _textField.SelectedText);
Assert.Equal ("TAB to jump between text fields.", _textField.Text);
_textField.Paste ();
Assert.Equal ("TAB to jump between text fields.", _textField.Text);
_textField.SelectedStart = 20;
_textField.Cut ();
_textField.Paste ();
Assert.Equal ("TAB to jump between text fields.", _textField.Text);
}
[Fact]
[InitShutdown]
public void Copy_Or_Cut_And_Paste_With_No_Selection ()
{
lock (Clipboard.Contents) {
_textField.SelectedStart = 20;
_textField.CursorPosition = 24;
_textField.Copy ();
Assert.Equal ("text", _textField.SelectedText);
Assert.Equal ("TAB to jump between text fields.", _textField.Text);
_textField.SelectedStart = -1;
_textField.Paste ();
Assert.Equal ("TAB to jump between texttext fields.", _textField.Text);
_textField.SelectedStart = 24;
_textField.Cut ();
Assert.Null (_textField.SelectedText);
Assert.Equal ("TAB to jump between text fields.", _textField.Text);
_textField.SelectedStart = -1;
_textField.Paste ();
Assert.Equal ("TAB to jump between texttext fields.", _textField.Text);
}
_textField.SelectedStart = 20;
_textField.CursorPosition = 24;
_textField.Copy ();
Assert.Equal ("text", _textField.SelectedText);
Assert.Equal ("TAB to jump between text fields.", _textField.Text);
_textField.SelectedStart = -1;
_textField.Paste ();
Assert.Equal ("TAB to jump between texttext fields.", _textField.Text);
_textField.SelectedStart = 24;
_textField.Cut ();
Assert.Null (_textField.SelectedText);
Assert.Equal ("TAB to jump between text fields.", _textField.Text);
_textField.SelectedStart = -1;
_textField.Paste ();
Assert.Equal ("TAB to jump between texttext fields.", _textField.Text);
}
[Fact]
@@ -644,14 +640,12 @@ namespace Terminal.Gui.Views {
[InitShutdown]
public void Paste_Always_Clear_The_SelectedText ()
{
lock (Clipboard.Contents) {
_textField.SelectedStart = 20;
_textField.CursorPosition = 24;
_textField.Copy ();
Assert.Equal ("text", _textField.SelectedText);
_textField.Paste ();
Assert.Null (_textField.SelectedText);
}
_textField.SelectedStart = 20;
_textField.CursorPosition = 24;
_textField.Copy ();
Assert.Equal ("text", _textField.SelectedText);
_textField.Paste ();
Assert.Null (_textField.SelectedText);
}
[Fact]
@@ -901,209 +895,207 @@ namespace Terminal.Gui.Views {
[AutoInitShutdown]
public void KeyBindings_Command ()
{
lock (Clipboard.Contents) {
var tf = new TextField ("This is a test.") { Width = 20 };
Assert.Equal (15, tf.Text.Length);
Assert.Equal (15, tf.CursorPosition);
Assert.False (tf.ReadOnly);
var tf = new TextField ("This is a test.") { Width = 20 };
Assert.Equal (15, tf.Text.Length);
Assert.Equal (15, tf.CursorPosition);
Assert.False (tf.ReadOnly);
Assert.True (tf.ProcessKey (new KeyEvent (Key.DeleteChar, new KeyModifiers ())));
Assert.Equal ("This is a test.", tf.Text);
tf.CursorPosition = 0;
Assert.True (tf.ProcessKey (new KeyEvent (Key.DeleteChar, new KeyModifiers ())));
Assert.Equal ("his is a test.", tf.Text);
tf.ReadOnly = true;
Assert.True (tf.ProcessKey (new KeyEvent (Key.D | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("his is a test.", tf.Text);
Assert.True (tf.ProcessKey (new KeyEvent (Key.Delete, new KeyModifiers ())));
Assert.Equal ("his is a test.", tf.Text);
tf.ReadOnly = false;
tf.CursorPosition = 1;
Assert.True (tf.ProcessKey (new KeyEvent (Key.Backspace, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
tf.CursorPosition = 5;
Assert.True (tf.ProcessKey (new KeyEvent (Key.Home | Key.ShiftMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("is is", tf.SelectedText);
tf.CursorPosition = 5;
tf.SelectedStart = -1;
Assert.Null (tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.Home | Key.ShiftMask | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("is is", tf.SelectedText);
tf.CursorPosition = 5;
tf.SelectedStart = -1;
Assert.Null (tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.A | Key.ShiftMask | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("is is", tf.SelectedText);
tf.CursorPosition = 5;
tf.SelectedStart = -1;
Assert.Null (tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.End | Key.ShiftMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (" a test.", tf.SelectedText);
tf.CursorPosition = 5;
tf.SelectedStart = -1;
Assert.Null (tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.End | Key.ShiftMask | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (" a test.", tf.SelectedText);
tf.CursorPosition = 5;
tf.SelectedStart = -1;
Assert.Null (tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.E | Key.ShiftMask | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (" a test.", tf.SelectedText);
tf.CursorPosition = 5;
tf.SelectedStart = -1;
Assert.Null (tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.Home, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (0, tf.CursorPosition);
tf.CursorPosition = 5;
Assert.Null (tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.Home | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (0, tf.CursorPosition);
tf.CursorPosition = 5;
Assert.Null (tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.A | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (0, tf.CursorPosition);
tf.CursorPosition = 5;
tf.SelectedStart = -1;
Assert.Null (tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorLeft | Key.ShiftMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("s", tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorUp | Key.ShiftMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("is", tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorRight | Key.ShiftMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("s", tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorDown | Key.ShiftMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Null (tf.SelectedText);
tf.CursorPosition = 7;
tf.SelectedStart = -1;
Assert.Null (tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorLeft | Key.ShiftMask | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("a", tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorUp | Key.ShiftMask | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("is a", tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent ((Key)((int)'B' + Key.ShiftMask | Key.AltMask), new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("is is a", tf.SelectedText);
tf.CursorPosition = 3;
tf.SelectedStart = -1;
Assert.Null (tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorRight | Key.ShiftMask | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("is ", tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorDown | Key.ShiftMask | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("is a ", tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent ((Key)((int)'F' + Key.ShiftMask | Key.AltMask), new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("is a test.", tf.SelectedText);
Assert.Equal (13, tf.CursorPosition);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Null (tf.SelectedText);
Assert.Equal (12, tf.CursorPosition);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (11, tf.CursorPosition);
Assert.True (tf.ProcessKey (new KeyEvent (Key.End, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (13, tf.CursorPosition);
tf.CursorPosition = 0;
Assert.True (tf.ProcessKey (new KeyEvent (Key.End | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (13, tf.CursorPosition);
tf.CursorPosition = 0;
Assert.True (tf.ProcessKey (new KeyEvent (Key.E | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (13, tf.CursorPosition);
tf.CursorPosition = 0;
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (1, tf.CursorPosition);
Assert.True (tf.ProcessKey (new KeyEvent (Key.F | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (2, tf.CursorPosition);
tf.CursorPosition = 9;
tf.ReadOnly = true;
Assert.True (tf.ProcessKey (new KeyEvent (Key.K | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
tf.ReadOnly = false;
Assert.True (tf.ProcessKey (new KeyEvent (Key.K | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.Equal ("est.", Clipboard.Contents);
Assert.True (tf.ProcessKey (new KeyEvent (Key.Z | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.True (tf.ProcessKey (new KeyEvent (Key.Y | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.True (tf.ProcessKey (new KeyEvent (Key.Backspace | Key.AltMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.True (tf.ProcessKey (new KeyEvent (Key.Y | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorLeft | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.Equal (8, tf.CursorPosition);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorUp | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.Equal (6, tf.CursorPosition);
Assert.True (tf.ProcessKey (new KeyEvent ((Key)((int)'B' + Key.AltMask), new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.Equal (3, tf.CursorPosition);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorRight | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.Equal (6, tf.CursorPosition);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorDown | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.Equal (8, tf.CursorPosition);
Assert.True (tf.ProcessKey (new KeyEvent ((Key)((int)'F' + Key.AltMask), new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.Equal (9, tf.CursorPosition);
Assert.True (tf.Used);
Assert.True (tf.ProcessKey (new KeyEvent (Key.InsertChar, new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.Equal (9, tf.CursorPosition);
Assert.False (tf.Used);
tf.SelectedStart = 3;
tf.CursorPosition = 7;
Assert.Equal ("is a", tf.SelectedText);
Assert.Equal ("est.", Clipboard.Contents);
Assert.True (tf.ProcessKey (new KeyEvent (Key.C | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.Equal ("is a", Clipboard.Contents);
Assert.True (tf.ProcessKey (new KeyEvent (Key.X | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is t", tf.Text);
Assert.Equal ("is a", Clipboard.Contents);
Assert.True (tf.ProcessKey (new KeyEvent (Key.V | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.Equal ("is a", Clipboard.Contents);
Assert.Equal (7, tf.CursorPosition);
Assert.True (tf.ProcessKey (new KeyEvent (Key.K | Key.AltMask, new KeyModifiers ())));
Assert.Equal (" t", tf.Text);
Assert.Equal ("is is a", Clipboard.Contents);
tf.Text = "TAB to jump between text fields.";
Assert.Equal (0, tf.CursorPosition);
Assert.True (tf.ProcessKey (new KeyEvent (Key.DeleteChar | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("to jump between text fields.", tf.Text);
tf.CursorPosition = tf.Text.Length;
Assert.True (tf.ProcessKey (new KeyEvent (Key.Backspace | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("to jump between text ", tf.Text);
Assert.True (tf.ProcessKey (new KeyEvent (Key.T | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("to jump between text ", tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.D | Key.CtrlMask | Key.ShiftMask, new KeyModifiers ())));
Assert.Equal ("", tf.Text);
}
Assert.True (tf.ProcessKey (new KeyEvent (Key.DeleteChar, new KeyModifiers ())));
Assert.Equal ("This is a test.", tf.Text);
tf.CursorPosition = 0;
Assert.True (tf.ProcessKey (new KeyEvent (Key.DeleteChar, new KeyModifiers ())));
Assert.Equal ("his is a test.", tf.Text);
tf.ReadOnly = true;
Assert.True (tf.ProcessKey (new KeyEvent (Key.D | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("his is a test.", tf.Text);
Assert.True (tf.ProcessKey (new KeyEvent (Key.Delete, new KeyModifiers ())));
Assert.Equal ("his is a test.", tf.Text);
tf.ReadOnly = false;
tf.CursorPosition = 1;
Assert.True (tf.ProcessKey (new KeyEvent (Key.Backspace, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
tf.CursorPosition = 5;
Assert.True (tf.ProcessKey (new KeyEvent (Key.Home | Key.ShiftMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("is is", tf.SelectedText);
tf.CursorPosition = 5;
tf.SelectedStart = -1;
Assert.Null (tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.Home | Key.ShiftMask | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("is is", tf.SelectedText);
tf.CursorPosition = 5;
tf.SelectedStart = -1;
Assert.Null (tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.A | Key.ShiftMask | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("is is", tf.SelectedText);
tf.CursorPosition = 5;
tf.SelectedStart = -1;
Assert.Null (tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.End | Key.ShiftMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (" a test.", tf.SelectedText);
tf.CursorPosition = 5;
tf.SelectedStart = -1;
Assert.Null (tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.End | Key.ShiftMask | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (" a test.", tf.SelectedText);
tf.CursorPosition = 5;
tf.SelectedStart = -1;
Assert.Null (tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.E | Key.ShiftMask | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (" a test.", tf.SelectedText);
tf.CursorPosition = 5;
tf.SelectedStart = -1;
Assert.Null (tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.Home, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (0, tf.CursorPosition);
tf.CursorPosition = 5;
Assert.Null (tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.Home | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (0, tf.CursorPosition);
tf.CursorPosition = 5;
Assert.Null (tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.A | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (0, tf.CursorPosition);
tf.CursorPosition = 5;
tf.SelectedStart = -1;
Assert.Null (tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorLeft | Key.ShiftMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("s", tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorUp | Key.ShiftMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("is", tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorRight | Key.ShiftMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("s", tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorDown | Key.ShiftMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Null (tf.SelectedText);
tf.CursorPosition = 7;
tf.SelectedStart = -1;
Assert.Null (tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorLeft | Key.ShiftMask | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("a", tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorUp | Key.ShiftMask | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("is a", tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent ((Key)((int)'B' + Key.ShiftMask | Key.AltMask), new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("is is a", tf.SelectedText);
tf.CursorPosition = 3;
tf.SelectedStart = -1;
Assert.Null (tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorRight | Key.ShiftMask | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("is ", tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorDown | Key.ShiftMask | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("is a ", tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent ((Key)((int)'F' + Key.ShiftMask | Key.AltMask), new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal ("is a test.", tf.SelectedText);
Assert.Equal (13, tf.CursorPosition);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Null (tf.SelectedText);
Assert.Equal (12, tf.CursorPosition);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (11, tf.CursorPosition);
Assert.True (tf.ProcessKey (new KeyEvent (Key.End, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (13, tf.CursorPosition);
tf.CursorPosition = 0;
Assert.True (tf.ProcessKey (new KeyEvent (Key.End | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (13, tf.CursorPosition);
tf.CursorPosition = 0;
Assert.True (tf.ProcessKey (new KeyEvent (Key.E | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (13, tf.CursorPosition);
tf.CursorPosition = 0;
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (1, tf.CursorPosition);
Assert.True (tf.ProcessKey (new KeyEvent (Key.F | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.Equal (2, tf.CursorPosition);
tf.CursorPosition = 9;
tf.ReadOnly = true;
Assert.True (tf.ProcessKey (new KeyEvent (Key.K | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
tf.ReadOnly = false;
Assert.True (tf.ProcessKey (new KeyEvent (Key.K | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.Equal ("est.", Clipboard.Contents);
Assert.True (tf.ProcessKey (new KeyEvent (Key.Z | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.True (tf.ProcessKey (new KeyEvent (Key.Y | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.True (tf.ProcessKey (new KeyEvent (Key.Backspace | Key.AltMask, new KeyModifiers ())));
Assert.Equal ("is is a test.", tf.Text);
Assert.True (tf.ProcessKey (new KeyEvent (Key.Y | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorLeft | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.Equal (8, tf.CursorPosition);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorUp | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.Equal (6, tf.CursorPosition);
Assert.True (tf.ProcessKey (new KeyEvent ((Key)((int)'B' + Key.AltMask), new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.Equal (3, tf.CursorPosition);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorRight | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.Equal (6, tf.CursorPosition);
Assert.True (tf.ProcessKey (new KeyEvent (Key.CursorDown | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.Equal (8, tf.CursorPosition);
Assert.True (tf.ProcessKey (new KeyEvent ((Key)((int)'F' + Key.AltMask), new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.Equal (9, tf.CursorPosition);
Assert.True (tf.Used);
Assert.True (tf.ProcessKey (new KeyEvent (Key.InsertChar, new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.Equal (9, tf.CursorPosition);
Assert.False (tf.Used);
tf.SelectedStart = 3;
tf.CursorPosition = 7;
Assert.Equal ("is a", tf.SelectedText);
Assert.Equal ("est.", Clipboard.Contents);
Assert.True (tf.ProcessKey (new KeyEvent (Key.C | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.Equal ("is a", Clipboard.Contents);
Assert.True (tf.ProcessKey (new KeyEvent (Key.X | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is t", tf.Text);
Assert.Equal ("is a", Clipboard.Contents);
Assert.True (tf.ProcessKey (new KeyEvent (Key.V | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("is is a t", tf.Text);
Assert.Equal ("is a", Clipboard.Contents);
Assert.Equal (7, tf.CursorPosition);
Assert.True (tf.ProcessKey (new KeyEvent (Key.K | Key.AltMask, new KeyModifiers ())));
Assert.Equal (" t", tf.Text);
Assert.Equal ("is is a", Clipboard.Contents);
tf.Text = "TAB to jump between text fields.";
Assert.Equal (0, tf.CursorPosition);
Assert.True (tf.ProcessKey (new KeyEvent (Key.DeleteChar | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("to jump between text fields.", tf.Text);
tf.CursorPosition = tf.Text.Length;
Assert.True (tf.ProcessKey (new KeyEvent (Key.Backspace | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("to jump between text ", tf.Text);
Assert.True (tf.ProcessKey (new KeyEvent (Key.T | Key.CtrlMask, new KeyModifiers ())));
Assert.Equal ("to jump between text ", tf.SelectedText);
Assert.True (tf.ProcessKey (new KeyEvent (Key.D | Key.CtrlMask | Key.ShiftMask, new KeyModifiers ())));
Assert.Equal ("", tf.Text);
}
[Fact]

File diff suppressed because it is too large Load Diff