mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
Merge branch 'develop' into splitcontainer
This commit is contained in:
@@ -24,7 +24,6 @@ namespace Terminal.Gui.ApplicationTests {
|
||||
Assert.Null (Application.Driver);
|
||||
Assert.Null (Application.Top);
|
||||
Assert.Null (Application.Current);
|
||||
Assert.Throws<ArgumentNullException> (() => Application.HeightAsBuffer == true);
|
||||
Assert.Null (Application.MainLoop);
|
||||
Assert.Null (Application.Iteration);
|
||||
Assert.Null (Application.RootMouseEvent);
|
||||
|
||||
@@ -85,7 +85,34 @@ namespace Terminal.Gui.DriverTests {
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Make_Asserts_IfNotInit ()
|
||||
public void Implicit_Assign_NoDriver ()
|
||||
{
|
||||
|
||||
var attr = new Attribute ();
|
||||
|
||||
var fg = new Color ();
|
||||
fg = Color.Red;
|
||||
|
||||
var bg = new Color ();
|
||||
bg = Color.Blue;
|
||||
|
||||
// Test conversion to int
|
||||
attr = new Attribute (fg, bg);
|
||||
int value_implicit = (int)attr.Value;
|
||||
Assert.False (attr.Initialized);
|
||||
|
||||
Assert.Equal (-1, value_implicit);
|
||||
Assert.False (attr.Initialized);
|
||||
|
||||
// Test conversion from int
|
||||
attr = -1;
|
||||
Assert.Equal (-1, attr.Value);
|
||||
Assert.False (attr.Initialized);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Make_SetsNotInitialized_NoDriver ()
|
||||
{
|
||||
var fg = new Color ();
|
||||
fg = Color.Red;
|
||||
@@ -93,7 +120,9 @@ namespace Terminal.Gui.DriverTests {
|
||||
var bg = new Color ();
|
||||
bg = Color.Blue;
|
||||
|
||||
Assert.Throws<InvalidOperationException> (() => Attribute.Make (fg, bg));
|
||||
var a = Attribute.Make (fg, bg);
|
||||
|
||||
Assert.False (a.Initialized);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -109,8 +138,8 @@ namespace Terminal.Gui.DriverTests {
|
||||
var bg = new Color ();
|
||||
bg = Color.Blue;
|
||||
|
||||
var attr = Attribute.Make (fg, bg);
|
||||
|
||||
var attr = Attribute.Make (fg, bg);
|
||||
Assert.True (attr.Initialized);
|
||||
Assert.Equal (fg, attr.Foreground);
|
||||
Assert.Equal (bg, attr.Background);
|
||||
|
||||
@@ -119,7 +148,23 @@ namespace Terminal.Gui.DriverTests {
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Get_Asserts_IfNotInit ()
|
||||
public void Make_Creates_NoDriver ()
|
||||
{
|
||||
|
||||
var fg = new Color ();
|
||||
fg = Color.Red;
|
||||
|
||||
var bg = new Color ();
|
||||
bg = Color.Blue;
|
||||
|
||||
var attr = Attribute.Make (fg, bg);
|
||||
Assert.False (attr.Initialized);
|
||||
Assert.Equal (fg, attr.Foreground);
|
||||
Assert.Equal (bg, attr.Background);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Get_Asserts_NoDriver ()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException> (() => Attribute.Get ());
|
||||
}
|
||||
@@ -163,5 +208,24 @@ namespace Terminal.Gui.DriverTests {
|
||||
Assert.Equal (Color.Red, fg);
|
||||
Assert.Equal (Color.Green, bg);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsValid_Tests ()
|
||||
{
|
||||
var attr = new Attribute ();
|
||||
Assert.True (attr.HasValidColors);
|
||||
|
||||
attr = new Attribute (Color.Red, Color.Green);
|
||||
Assert.True (attr.HasValidColors);
|
||||
|
||||
attr = new Attribute (Color.Red, Color.Invalid);
|
||||
Assert.False (attr.HasValidColors);
|
||||
|
||||
attr = new Attribute (Color.Invalid, Color.Green);
|
||||
Assert.False (attr.HasValidColors);
|
||||
|
||||
attr = new Attribute (Color.Invalid, Color.Invalid);
|
||||
Assert.False (attr.HasValidColors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,5 +35,14 @@ namespace Terminal.Gui.DriverTests {
|
||||
Application.Shutdown ();
|
||||
}
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void ColorScheme_New ()
|
||||
{
|
||||
var scheme = new ColorScheme ();
|
||||
var lbl = new Label ();
|
||||
lbl.ColorScheme = scheme;
|
||||
lbl.Redraw (lbl.Bounds);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -319,7 +319,7 @@ namespace Terminal.Gui.DriverTests {
|
||||
|
||||
Application.Shutdown ();
|
||||
}
|
||||
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void AddRune_On_Clip_Left_Or_Right_Replace_Previous_Or_Next_Wide_Rune_With_Space ()
|
||||
{
|
||||
@@ -441,7 +441,7 @@ namespace Terminal.Gui.DriverTests {
|
||||
}
|
||||
|
||||
private static object packetLock = new object ();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sometimes when using remote tools EventKeyRecord sends 'virtual keystrokes'.
|
||||
/// These are indicated with the wVirtualKeyCode of 231. When we see this code
|
||||
@@ -487,6 +487,7 @@ namespace Terminal.Gui.DriverTests {
|
||||
if (iterations == 0) Application.Driver.SendKeys ((char)mappedConsoleKey, ConsoleKey.Packet, shift, alt, control);
|
||||
};
|
||||
|
||||
|
||||
lock (packetLock) {
|
||||
Application.Run ();
|
||||
Application.Shutdown ();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Terminal.Gui;
|
||||
using Xunit;
|
||||
|
||||
namespace Terminal.Gui.DriverTests {
|
||||
|
||||
@@ -696,7 +696,7 @@ namespace Terminal.Gui.TopLevelTests {
|
||||
((FakeDriver)Application.Driver).SetBufferSize (40, 15);
|
||||
MessageBox.Query ("About", "Hello Word", "Ok");
|
||||
|
||||
} else if (iterations == 1) TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
} else if (iterations == 1) TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
File
|
||||
┌ Window ──────────────────────────────┐
|
||||
│ │
|
||||
@@ -712,7 +712,7 @@ namespace Terminal.Gui.TopLevelTests {
|
||||
│ │
|
||||
└──────────────────────────────────────┘
|
||||
CTRL-N New ", output);
|
||||
else if (iterations == 2) {
|
||||
else if (iterations == 2) {
|
||||
Assert.Null (Application.MouseGrabView);
|
||||
// Grab the mouse
|
||||
ReflectionTools.InvokePrivate (
|
||||
@@ -815,8 +815,8 @@ else if (iterations == 2) {
|
||||
|
||||
Assert.Null (Application.MouseGrabView);
|
||||
|
||||
} else if (iterations == 8) Application.RequestStop ();
|
||||
else if (iterations == 9) Application.RequestStop ();
|
||||
} else if (iterations == 8) Application.RequestStop ();
|
||||
else if (iterations == 9) Application.RequestStop ();
|
||||
};
|
||||
|
||||
Application.Run ();
|
||||
@@ -956,7 +956,7 @@ else if (iterations == 9) Application.RequestStop ();
|
||||
|
||||
Assert.Null (Application.MouseGrabView);
|
||||
|
||||
} else if (iterations == 8) Application.RequestStop ();
|
||||
} else if (iterations == 8) Application.RequestStop ();
|
||||
};
|
||||
|
||||
Application.Run ();
|
||||
@@ -974,5 +974,42 @@ else if (iterations == 9) Application.RequestStop ();
|
||||
exception = Record.Exception (() => ((FakeDriver)Application.Driver).SetBufferSize (10, 0));
|
||||
Assert.Null (exception);
|
||||
}
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void OnEnter_OnLeave_Triggered_On_Application_Begin_End ()
|
||||
{
|
||||
var isEnter = false;
|
||||
var isLeave = false;
|
||||
var v = new View ();
|
||||
v.Enter += (_) => isEnter = true;
|
||||
v.Leave += (_) => isLeave = true;
|
||||
var top = Application.Top;
|
||||
top.Add (v);
|
||||
|
||||
Assert.False (v.CanFocus);
|
||||
var exception = Record.Exception (() => top.OnEnter (top));
|
||||
Assert.Null (exception);
|
||||
exception = Record.Exception (() => top.OnLeave (top));
|
||||
Assert.Null (exception);
|
||||
|
||||
v.CanFocus = true;
|
||||
Application.Begin (top);
|
||||
|
||||
Assert.True (isEnter);
|
||||
Assert.False (isLeave);
|
||||
|
||||
isEnter = false;
|
||||
var d = new Dialog ();
|
||||
var rs = Application.Begin (d);
|
||||
|
||||
Assert.False (isEnter);
|
||||
Assert.True (isLeave);
|
||||
|
||||
isLeave = false;
|
||||
Application.End (rs);
|
||||
|
||||
Assert.True (isEnter);
|
||||
Assert.False (isLeave);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,12 +7,12 @@
|
||||
<IsPackable>false</IsPackable>
|
||||
<UseDataCollector />
|
||||
<!-- Version numbers are automatically updated by gitversion when a release is released -->
|
||||
<!-- In the source tree the version will always be 1.0 for all projects. -->
|
||||
<!-- In the source tree the version will always be 2.0 for all projects. -->
|
||||
<!-- Do not modify these. -->
|
||||
<AssemblyVersion>1.0</AssemblyVersion>
|
||||
<FileVersion>1.0</FileVersion>
|
||||
<Version>1.0</Version>
|
||||
<InformationalVersion>1.0</InformationalVersion>
|
||||
<AssemblyVersion>2.0</AssemblyVersion>
|
||||
<FileVersion>2.0</FileVersion>
|
||||
<Version>2.0</Version>
|
||||
<InformationalVersion>2.0</InformationalVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
|
||||
@@ -6,9 +6,16 @@ using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Terminal.Gui;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Terminal.Gui.ViewTests {
|
||||
public class AutocompleteTests {
|
||||
readonly ITestOutputHelper output;
|
||||
|
||||
public AutocompleteTests (ITestOutputHelper output)
|
||||
{
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Test_GenerateSuggestions_Simple ()
|
||||
@@ -151,5 +158,84 @@ namespace Terminal.Gui.ViewTests {
|
||||
Assert.Empty (tv.Autocomplete.Suggestions);
|
||||
Assert.Equal (3, tv.Autocomplete.AllSuggestions.Count);
|
||||
}
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void CursorLeft_CursorRight_Mouse_Button_Pressed_Does_Not_Show_Popup ()
|
||||
{
|
||||
var tv = new TextView () {
|
||||
Width = 50,
|
||||
Height = 5,
|
||||
Text = "This a long line and against TextView."
|
||||
};
|
||||
tv.Autocomplete.AllSuggestions = Regex.Matches (tv.Text.ToString (), "\\w+")
|
||||
.Select (s => s.Value)
|
||||
.Distinct ().ToList ();
|
||||
var top = Application.Top;
|
||||
top.Add (tv);
|
||||
Application.Begin (top);
|
||||
|
||||
|
||||
for (int i = 0; i < 7; i++) {
|
||||
Assert.True (tv.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ())));
|
||||
Application.Refresh ();
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
This a long line and against TextView.", output);
|
||||
}
|
||||
|
||||
Assert.True (tv.MouseEvent (new MouseEvent () {
|
||||
X = 6,
|
||||
Y = 0,
|
||||
Flags = MouseFlags.Button1Pressed
|
||||
}));
|
||||
Application.Refresh ();
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
This a long line and against TextView.", output);
|
||||
|
||||
Assert.True (tv.ProcessKey (new KeyEvent (Key.g, new KeyModifiers ())));
|
||||
Application.Refresh ();
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
This ag long line and against TextView.
|
||||
against ", output);
|
||||
|
||||
Assert.True (tv.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ())));
|
||||
Application.Refresh ();
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
This ag long line and against TextView.
|
||||
against ", output);
|
||||
|
||||
Assert.True (tv.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ())));
|
||||
Application.Refresh ();
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
This ag long line and against TextView.
|
||||
against ", output);
|
||||
|
||||
Assert.True (tv.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ())));
|
||||
Application.Refresh ();
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
This ag long line and against TextView.", output);
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Assert.True (tv.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ())));
|
||||
Application.Refresh ();
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
This ag long line and against TextView.", output);
|
||||
}
|
||||
|
||||
Assert.True (tv.ProcessKey (new KeyEvent (Key.Backspace, new KeyModifiers ())));
|
||||
Application.Refresh ();
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
This a long line and against TextView.", output);
|
||||
|
||||
Assert.True (tv.ProcessKey (new KeyEvent (Key.n, new KeyModifiers ())));
|
||||
Application.Refresh ();
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
This an long line and against TextView.
|
||||
and ", output);
|
||||
|
||||
Assert.True (tv.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ())));
|
||||
Application.Refresh ();
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
This an long line and against TextView.", output);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1602,8 +1602,8 @@ Y
|
||||
// Calling the Text constructor.
|
||||
lbl = new Label (text);
|
||||
}
|
||||
lbl.ColorScheme = new ColorScheme ();
|
||||
lbl.Redraw (lbl.Bounds);
|
||||
Application.Top.Add (lbl);
|
||||
Application.Top.Redraw (Application.Top.Bounds);
|
||||
|
||||
// should have the initial text
|
||||
Assert.Equal ('t', driver.Contents [0, 0, 0]);
|
||||
|
||||
Reference in New Issue
Block a user