mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
ComboBox cursonDownKey nullref fix (#1472)
* added null guard to fix null ref when pressing keyDown inside combobox Improved an error message when view cannot be found * Added a unit test to ensure combobox can process all key events Found and fixed a new nullref * Found a new bug when source is already present and combobox is added to a top view * searchSet is auto initialized to new List() now to make the code a little bit safer
This commit is contained in:
24
UnitTests/ComboBoxTests.cs
Normal file
24
UnitTests/ComboBoxTests.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Terminal.Gui;
|
||||
using Xunit;
|
||||
|
||||
namespace UnitTests {
|
||||
public class ComboBoxTests {
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void EnsureKeyEventsDoNotCauseExceptions ()
|
||||
{
|
||||
var comboBox = new ComboBox ("0");
|
||||
|
||||
var source = Enumerable.Range (0, 15).Select (x => x.ToString ()).ToArray ();
|
||||
comboBox.SetSource(source);
|
||||
|
||||
Application.Top.Add(comboBox);
|
||||
|
||||
foreach (var key in (Key [])Enum.GetValues (typeof(Key))) {
|
||||
comboBox.ProcessKey (new KeyEvent (key, new KeyModifiers ()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user