mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
Merge branch 'v2_develop' into v2_menu-can-execute-false-fix_2787
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -59,6 +60,8 @@ namespace Terminal.Gui.ViewsTests {
|
||||
[Fact]
|
||||
public void KeyBindings_Command ()
|
||||
{
|
||||
CultureInfo cultureBackup = CultureInfo.CurrentCulture;
|
||||
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
|
||||
DateField df = new DateField (DateTime.Parse ("12/12/1971"));
|
||||
df.ReadOnly = true;
|
||||
Assert.True (df.ProcessKey (new KeyEvent (Key.DeleteChar, new KeyModifiers ())));
|
||||
@@ -93,6 +96,7 @@ namespace Terminal.Gui.ViewsTests {
|
||||
df.ReadOnly = false;
|
||||
Assert.True (df.ProcessKey (new KeyEvent (Key.D1, new KeyModifiers ())));
|
||||
Assert.Equal (" 12/02/1971", df.Text);
|
||||
CultureInfo.CurrentCulture = cultureBackup;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Terminal.Gui.ViewsTests {
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StatusBar_Contructor_Default ()
|
||||
public void StatusBar_Constructor_Default ()
|
||||
{
|
||||
var sb = new StatusBar ();
|
||||
|
||||
@@ -160,5 +160,43 @@ CTRL-O Open {CM.Glyphs.VLine} CTRL-Q Quit
|
||||
Assert.Equal ("~^A~ Save As", sb.Items [1].Title);
|
||||
Assert.Equal ("~^Q~ Quit", sb.Items [^1].Title);
|
||||
}
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void CanExecute_ProcessHotKey ()
|
||||
{
|
||||
Window win = null;
|
||||
var statusBar = new StatusBar (new StatusItem [] {
|
||||
new StatusItem (Key.CtrlMask | Key.N, "~^N~ New", New, CanExecuteNew),
|
||||
new StatusItem (Key.CtrlMask | Key.C, "~^C~ Close", Close, CanExecuteClose)
|
||||
});
|
||||
var top = Application.Top;
|
||||
top.Add (statusBar);
|
||||
|
||||
bool CanExecuteNew () => win == null;
|
||||
|
||||
void New ()
|
||||
{
|
||||
win = new Window ();
|
||||
}
|
||||
|
||||
bool CanExecuteClose () => win != null;
|
||||
|
||||
void Close ()
|
||||
{
|
||||
win = null;
|
||||
}
|
||||
|
||||
Application.Begin (top);
|
||||
|
||||
Assert.Null (win);
|
||||
Assert.True (CanExecuteNew ());
|
||||
Assert.False (CanExecuteClose ());
|
||||
|
||||
Assert.True (top.ProcessHotKey (new KeyEvent (Key.N | Key.CtrlMask, new KeyModifiers () { Alt = true })));
|
||||
Application.MainLoop.RunIteration ();
|
||||
Assert.NotNull (win);
|
||||
Assert.False (CanExecuteNew ());
|
||||
Assert.True (CanExecuteClose ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user