ConsoleDriverTests.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using Xunit;
  6. using Xunit.Abstractions;
  7. // Alias Console to MockConsole so we don't accidentally use Console
  8. using Console = Terminal.Gui.FakeConsole;
  9. namespace Terminal.Gui.DriverTests {
  10. public class ConsoleDriverTests {
  11. readonly ITestOutputHelper output;
  12. public ConsoleDriverTests (ITestOutputHelper output)
  13. {
  14. this.output = output;
  15. }
  16. [Theory]
  17. [InlineData (typeof (FakeDriver))]
  18. //[InlineData (typeof (NetDriver))]
  19. //[InlineData (typeof (CursesDriver))]
  20. //[InlineData (typeof (WindowsDriver))]
  21. public void Init_Inits (Type driverType)
  22. {
  23. var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
  24. Application.Init (driver);
  25. driver.Init (() => { });
  26. Assert.Equal (80, Console.BufferWidth);
  27. Assert.Equal (25, Console.BufferHeight);
  28. // MockDriver is always 80x25
  29. Assert.Equal (Console.BufferWidth, driver.Cols);
  30. Assert.Equal (Console.BufferHeight, driver.Rows);
  31. driver.End ();
  32. // Shutdown must be called to safely clean up Application if Init has been called
  33. Application.Shutdown ();
  34. }
  35. [Theory]
  36. [InlineData (typeof (FakeDriver))]
  37. //[InlineData (typeof (NetDriver))]
  38. //[InlineData (typeof (CursesDriver))]
  39. //[InlineData (typeof (WindowsDriver))]
  40. public void End_Cleans_Up (Type driverType)
  41. {
  42. var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
  43. Application.Init (driver);
  44. driver.Init (() => { });
  45. Console.ForegroundColor = ConsoleColor.Red;
  46. Assert.Equal (ConsoleColor.Red, Console.ForegroundColor);
  47. Console.BackgroundColor = ConsoleColor.Green;
  48. Assert.Equal (ConsoleColor.Green, Console.BackgroundColor);
  49. driver.Move (2, 3);
  50. Assert.Equal (2, Console.CursorLeft);
  51. Assert.Equal (3, Console.CursorTop);
  52. driver.End ();
  53. Assert.Equal (0, Console.CursorLeft);
  54. Assert.Equal (0, Console.CursorTop);
  55. Assert.Equal (ConsoleColor.Gray, Console.ForegroundColor);
  56. Assert.Equal (ConsoleColor.Black, Console.BackgroundColor);
  57. // Shutdown must be called to safely clean up Application if Init has been called
  58. Application.Shutdown ();
  59. }
  60. [Theory]
  61. [InlineData (typeof (FakeDriver))]
  62. public void FakeDriver_Only_Sends_Keystrokes_Through_MockKeyPresses (Type driverType)
  63. {
  64. var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
  65. Application.Init (driver);
  66. var top = Application.Top;
  67. var view = new View ();
  68. var count = 0;
  69. var wasKeyPressed = false;
  70. view.KeyPress += (s, e) => {
  71. wasKeyPressed = true;
  72. };
  73. top.Add (view);
  74. Application.Iteration += () => {
  75. count++;
  76. if (count == 10) Application.RequestStop ();
  77. };
  78. Application.Run ();
  79. Assert.False (wasKeyPressed);
  80. // Shutdown must be called to safely clean up Application if Init has been called
  81. Application.Shutdown ();
  82. }
  83. [Theory]
  84. [InlineData (typeof (FakeDriver))]
  85. public void FakeDriver_MockKeyPresses (Type driverType)
  86. {
  87. var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
  88. Application.Init (driver);
  89. var text = "MockKeyPresses";
  90. var mKeys = new Stack<ConsoleKeyInfo> ();
  91. foreach (var r in text.Reverse ()) {
  92. var ck = char.IsLetter (r) ? (ConsoleKey)char.ToUpper (r) : (ConsoleKey)r;
  93. var cki = new ConsoleKeyInfo (r, ck, false, false, false);
  94. mKeys.Push (cki);
  95. }
  96. Console.MockKeyPresses = mKeys;
  97. var top = Application.Top;
  98. var view = new View ();
  99. var rText = "";
  100. var idx = 0;
  101. view.KeyPress += (s, e) => {
  102. Assert.Equal (text [idx], (char)e.KeyEvent.Key);
  103. rText += (char)e.KeyEvent.Key;
  104. Assert.Equal (rText, text.Substring (0, idx + 1));
  105. e.Handled = true;
  106. idx++;
  107. };
  108. top.Add (view);
  109. Application.Iteration += () => {
  110. if (mKeys.Count == 0) Application.RequestStop ();
  111. };
  112. Application.Run ();
  113. Assert.Equal ("MockKeyPresses", rText);
  114. // Shutdown must be called to safely clean up Application if Init has been called
  115. Application.Shutdown ();
  116. }
  117. //[Theory]
  118. //[InlineData (typeof (FakeDriver))]
  119. //public void FakeDriver_MockKeyPresses_Press_AfterTimeOut (Type driverType)
  120. //{
  121. // var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
  122. // Application.Init (driver);
  123. // // Simulating pressing of QuitKey after a short period of time
  124. // uint quitTime = 100;
  125. // Func<MainLoop, bool> closeCallback = (MainLoop loop) => {
  126. // // Prove the scenario is using Application.QuitKey correctly
  127. // output.WriteLine ($" {quitTime}ms elapsed; Simulating keypresses...");
  128. // FakeConsole.PushMockKeyPress (Key.F);
  129. // FakeConsole.PushMockKeyPress (Key.U);
  130. // FakeConsole.PushMockKeyPress (Key.C);
  131. // FakeConsole.PushMockKeyPress (Key.K);
  132. // return false;
  133. // };
  134. // output.WriteLine ($"Add timeout to simulate key presses after {quitTime}ms");
  135. // _ = Application.MainLoop.AddTimeout (TimeSpan.FromMilliseconds (quitTime), closeCallback);
  136. // // If Top doesn't quit within abortTime * 5 (500ms), this will force it
  137. // uint abortTime = quitTime * 5;
  138. // Func<MainLoop, bool> forceCloseCallback = (MainLoop loop) => {
  139. // Application.RequestStop ();
  140. // Assert.Fail ($" failed to Quit after {abortTime}ms. Force quit.");
  141. // return false;
  142. // };
  143. // output.WriteLine ($"Add timeout to force quit after {abortTime}ms");
  144. // _ = Application.MainLoop.AddTimeout (TimeSpan.FromMilliseconds (abortTime), forceCloseCallback);
  145. // Key key = Key.Unknown;
  146. // Application.Top.KeyPress += (e) => {
  147. // key = e.KeyEvent.Key;
  148. // output.WriteLine ($" Application.Top.KeyPress: {key}");
  149. // e.Handled = true;
  150. // };
  151. // int iterations = 0;
  152. // Application.Iteration += () => {
  153. // output.WriteLine ($" iteration {++iterations}");
  154. // if (Console.MockKeyPresses.Count == 0) {
  155. // output.WriteLine ($" No more MockKeyPresses; RequestStop");
  156. // Application.RequestStop ();
  157. // }
  158. // };
  159. // Application.Run ();
  160. // // Shutdown must be called to safely clean up Application if Init has been called
  161. // Application.Shutdown ();
  162. //}
  163. [Theory]
  164. [InlineData (typeof (FakeDriver))]
  165. public void TerminalResized_Simulation (Type driverType)
  166. {
  167. var driver = (FakeDriver)Activator.CreateInstance (driverType);
  168. Application.Init (driver);
  169. var wasTerminalResized = false;
  170. Application.Resized = (e) => {
  171. wasTerminalResized = true;
  172. Assert.Equal (120, e.Cols);
  173. Assert.Equal (40, e.Rows);
  174. };
  175. Assert.Equal (80, Console.BufferWidth);
  176. Assert.Equal (25, Console.BufferHeight);
  177. // MockDriver is by default 80x25
  178. Assert.Equal (Console.BufferWidth, driver.Cols);
  179. Assert.Equal (Console.BufferHeight, driver.Rows);
  180. Assert.False (wasTerminalResized);
  181. // MockDriver will now be sets to 120x40
  182. driver.SetBufferSize (120, 40);
  183. Assert.Equal (120, Application.Driver.Cols);
  184. Assert.Equal (40, Application.Driver.Rows);
  185. Assert.True (wasTerminalResized);
  186. // MockDriver will still be 120x40
  187. wasTerminalResized = false;
  188. Application.EnableConsoleScrolling = true;
  189. driver.SetWindowSize (40, 20);
  190. Assert.Equal (120, Application.Driver.Cols);
  191. Assert.Equal (40, Application.Driver.Rows);
  192. Assert.Equal (120, Console.BufferWidth);
  193. Assert.Equal (40, Console.BufferHeight);
  194. Assert.Equal (40, Console.WindowWidth);
  195. Assert.Equal (20, Console.WindowHeight);
  196. Assert.True (wasTerminalResized);
  197. Application.Shutdown ();
  198. }
  199. [Theory]
  200. [InlineData (typeof (FakeDriver))]
  201. public void EnableConsoleScrolling_Is_False_Left_And_Top_Is_Always_Zero (Type driverType)
  202. {
  203. var driver = (FakeDriver)Activator.CreateInstance (driverType);
  204. Application.Init (driver);
  205. Assert.False (Application.EnableConsoleScrolling);
  206. Assert.Equal (0, Console.WindowLeft);
  207. Assert.Equal (0, Console.WindowTop);
  208. driver.SetWindowPosition (5, 5);
  209. Assert.Equal (0, Console.WindowLeft);
  210. Assert.Equal (0, Console.WindowTop);
  211. Application.Shutdown ();
  212. }
  213. [Theory]
  214. [InlineData (typeof (FakeDriver))]
  215. public void EnableConsoleScrolling_Is_True_Left_Cannot_Be_Greater_Than_WindowWidth (Type driverType)
  216. {
  217. var driver = (FakeDriver)Activator.CreateInstance (driverType);
  218. Application.Init (driver);
  219. Application.EnableConsoleScrolling = true;
  220. Assert.True (Application.EnableConsoleScrolling);
  221. driver.SetWindowPosition (81, 25);
  222. Assert.Equal (0, Console.WindowLeft);
  223. Assert.Equal (0, Console.WindowTop);
  224. Application.Shutdown ();
  225. }
  226. [Theory]
  227. [InlineData (typeof (FakeDriver))]
  228. public void EnableConsoleScrolling_Is_True_Left_Cannot_Be_Greater_Than_BufferWidth_Minus_WindowWidth (Type driverType)
  229. {
  230. var driver = (FakeDriver)Activator.CreateInstance (driverType);
  231. Application.Init (driver);
  232. Application.EnableConsoleScrolling = true;
  233. Assert.True (Application.EnableConsoleScrolling);
  234. driver.SetWindowPosition (81, 25);
  235. Assert.Equal (0, Console.WindowLeft);
  236. Assert.Equal (0, Console.WindowTop);
  237. // MockDriver will now be sets to 120x25
  238. driver.SetBufferSize (120, 25);
  239. Assert.Equal (120, Application.Driver.Cols);
  240. Assert.Equal (25, Application.Driver.Rows);
  241. Assert.Equal (120, Console.BufferWidth);
  242. Assert.Equal (25, Console.BufferHeight);
  243. Assert.Equal (80, Console.WindowWidth);
  244. Assert.Equal (25, Console.WindowHeight);
  245. driver.SetWindowPosition (121, 25);
  246. Assert.Equal (40, Console.WindowLeft);
  247. Assert.Equal (0, Console.WindowTop);
  248. driver.SetWindowSize (90, 25);
  249. Assert.Equal (120, Application.Driver.Cols);
  250. Assert.Equal (25, Application.Driver.Rows);
  251. Assert.Equal (120, Console.BufferWidth);
  252. Assert.Equal (25, Console.BufferHeight);
  253. Assert.Equal (90, Console.WindowWidth);
  254. Assert.Equal (25, Console.WindowHeight);
  255. driver.SetWindowPosition (121, 25);
  256. Assert.Equal (30, Console.WindowLeft);
  257. Assert.Equal (0, Console.WindowTop);
  258. Application.Shutdown ();
  259. }
  260. [Theory]
  261. [InlineData (typeof (FakeDriver))]
  262. public void EnableConsoleScrolling_Is_True_Top_Cannot_Be_Greater_Than_WindowHeight (Type driverType)
  263. {
  264. var driver = (FakeDriver)Activator.CreateInstance (driverType);
  265. Application.Init (driver);
  266. Application.EnableConsoleScrolling = true;
  267. Assert.True (Application.EnableConsoleScrolling);
  268. driver.SetWindowPosition (80, 26);
  269. Assert.Equal (0, Console.WindowLeft);
  270. Assert.Equal (0, Console.WindowTop);
  271. Application.Shutdown ();
  272. }
  273. [Theory]
  274. [InlineData (typeof (FakeDriver))]
  275. public void EnableConsoleScrolling_Is_True_Top_Cannot_Be_Greater_Than_BufferHeight_Minus_WindowHeight (Type driverType)
  276. {
  277. var driver = (FakeDriver)Activator.CreateInstance (driverType);
  278. Application.Init (driver);
  279. Application.EnableConsoleScrolling = true;
  280. Assert.True (Application.EnableConsoleScrolling);
  281. driver.SetWindowPosition (80, 26);
  282. Assert.Equal (0, Console.WindowLeft);
  283. Assert.Equal (0, Console.WindowTop);
  284. // MockDriver will now be sets to 80x40
  285. driver.SetBufferSize (80, 40);
  286. Assert.Equal (80, Application.Driver.Cols);
  287. Assert.Equal (40, Application.Driver.Rows);
  288. Assert.Equal (80, Console.BufferWidth);
  289. Assert.Equal (40, Console.BufferHeight);
  290. Assert.Equal (80, Console.WindowWidth);
  291. Assert.Equal (25, Console.WindowHeight);
  292. Assert.Equal (0, Console.WindowLeft);
  293. Assert.Equal (0, Console.WindowTop);
  294. driver.SetWindowPosition (80, 40);
  295. Assert.Equal (0, Console.WindowLeft);
  296. Assert.Equal (15, Console.WindowTop);
  297. driver.SetWindowSize (80, 20);
  298. Assert.Equal (80, Application.Driver.Cols);
  299. Assert.Equal (40, Application.Driver.Rows);
  300. Assert.Equal (80, Console.BufferWidth);
  301. Assert.Equal (40, Console.BufferHeight);
  302. Assert.Equal (80, Console.WindowWidth);
  303. Assert.Equal (20, Console.WindowHeight);
  304. Assert.Equal (0, Console.WindowLeft);
  305. Assert.Equal (15, Console.WindowTop);
  306. driver.SetWindowPosition (80, 41);
  307. Assert.Equal (0, Console.WindowLeft);
  308. Assert.Equal (20, Console.WindowTop);
  309. Application.Shutdown ();
  310. }
  311. [Fact, AutoInitShutdown]
  312. public void AddRune_On_Clip_Left_Or_Right_Replace_Previous_Or_Next_Wide_Rune_With_Space ()
  313. {
  314. var tv = new TextView () {
  315. Width = Dim.Fill (),
  316. Height = Dim.Fill (),
  317. Text = @"これは広いルーンラインです。
  318. これは広いルーンラインです。
  319. これは広いルーンラインです。
  320. これは広いルーンラインです。
  321. これは広いルーンラインです。
  322. これは広いルーンラインです。
  323. これは広いルーンラインです。
  324. これは広いルーンラインです。"
  325. };
  326. var win = new Window ("ワイドルーン") { Width = Dim.Fill (), Height = Dim.Fill () };
  327. win.Add (tv);
  328. Application.Top.Add (win);
  329. var lbl = new Label ("ワイドルーン。");
  330. var dg = new Dialog ("テスト", 14, 4, new Button ("選ぶ"));
  331. dg.Add (lbl);
  332. Application.Begin (Application.Top);
  333. Application.Begin (dg);
  334. ((FakeDriver)Application.Driver).SetBufferSize (30, 10);
  335. var expected = @"
  336. ┌ ワイドルーン ──────────────┐
  337. │これは広いルーンラインです。│
  338. │これは広いルーンラインです。│
  339. │これは ┌ テスト ────┐ です。│
  340. │これは │ワイドルーン│ です。│
  341. │これは │ [ 選ぶ ] │ です。│
  342. │これは └────────────┘ です。│
  343. │これは広いルーンラインです。│
  344. │これは広いルーンラインです。│
  345. └────────────────────────────┘
  346. ";
  347. var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
  348. Assert.Equal (new Rect (0, 0, 30, 10), pos);
  349. }
  350. [Fact, AutoInitShutdown]
  351. public void Write_Do_Not_Change_On_ProcessKey ()
  352. {
  353. var win = new Window ();
  354. Application.Begin (win);
  355. ((FakeDriver)Application.Driver).SetBufferSize (20, 8);
  356. System.Threading.Tasks.Task.Run (() => {
  357. System.Threading.Tasks.Task.Delay (500).Wait ();
  358. Application.MainLoop.Invoke (() => {
  359. var lbl = new Label ("Hello World") { X = Pos.Center () };
  360. var dlg = new Dialog ("Test", new Button ("Ok"));
  361. dlg.Add (lbl);
  362. Application.Begin (dlg);
  363. var expected = @"
  364. ┌──────────────────┐
  365. │┌ Test ─────────┐ │
  366. ││ Hello World │ │
  367. ││ │ │
  368. ││ │ │
  369. ││ [ Ok ] │ │
  370. │└───────────────┘ │
  371. └──────────────────┘
  372. ";
  373. var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
  374. Assert.Equal (new Rect (0, 0, 20, 8), pos);
  375. Assert.True (dlg.ProcessKey (new KeyEvent (Key.Tab, new KeyModifiers ())));
  376. dlg.Redraw (dlg.Bounds);
  377. expected = @"
  378. ┌──────────────────┐
  379. │┌ Test ─────────┐ │
  380. ││ Hello World │ │
  381. ││ │ │
  382. ││ │ │
  383. ││ [ Ok ] │ │
  384. │└───────────────┘ │
  385. └──────────────────┘
  386. ";
  387. pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
  388. Assert.Equal (new Rect (0, 0, 20, 8), pos);
  389. win.RequestStop ();
  390. });
  391. });
  392. Application.Run (win);
  393. Application.Shutdown ();
  394. }
  395. [Theory]
  396. [InlineData (0x0000001F, 0x241F)]
  397. [InlineData (0x0000007F, 0x247F)]
  398. [InlineData (0x0000009F, 0x249F)]
  399. [InlineData (0x0001001A, 0x1001A)]
  400. public void MakePrintable_Converts_Control_Chars_To_Proper_Unicode (uint code, uint expected)
  401. {
  402. var actual = ConsoleDriver.MakePrintable (code);
  403. Assert.Equal (expected, actual.Value);
  404. }
  405. [Theory]
  406. [InlineData (0x20)]
  407. [InlineData (0x7E)]
  408. [InlineData (0xA0)]
  409. [InlineData (0x010020)]
  410. public void MakePrintable_Does_Not_Convert_Ansi_Chars_To_Unicode (uint code)
  411. {
  412. var actual = ConsoleDriver.MakePrintable (code);
  413. Assert.Equal (code, actual.Value);
  414. }
  415. private static object packetLock = new object ();
  416. /// <summary>
  417. /// Sometimes when using remote tools EventKeyRecord sends 'virtual keystrokes'.
  418. /// These are indicated with the wVirtualKeyCode of 231. When we see this code
  419. /// then we need to look to the unicode character (UnicodeChar) instead of the key
  420. /// when telling the rest of the framework what button was pressed. For full details
  421. /// see: https://github.com/gui-cs/Terminal.Gui/issues/2008
  422. /// </summary>
  423. [Theory, AutoInitShutdown]
  424. [ClassData (typeof (PacketTest))]
  425. public void TestVKPacket (uint unicodeCharacter, bool shift, bool alt, bool control, uint initialVirtualKey, uint initialScanCode, Key expectedRemapping, uint expectedVirtualKey, uint expectedScanCode)
  426. {
  427. var modifiers = new ConsoleModifiers ();
  428. if (shift) modifiers |= ConsoleModifiers.Shift;
  429. if (alt) modifiers |= ConsoleModifiers.Alt;
  430. if (control) modifiers |= ConsoleModifiers.Control;
  431. var mappedConsoleKey = ConsoleKeyMapping.GetConsoleKeyFromKey (unicodeCharacter, modifiers, out uint scanCode, out uint outputChar);
  432. if ((scanCode > 0 || mappedConsoleKey == 0) && mappedConsoleKey == initialVirtualKey) Assert.Equal (mappedConsoleKey, initialVirtualKey);
  433. else Assert.Equal (mappedConsoleKey, outputChar < 0xff ? outputChar & 0xff | 0xff << 8 : outputChar);
  434. Assert.Equal (scanCode, initialScanCode);
  435. var keyChar = ConsoleKeyMapping.GetKeyCharFromConsoleKey (mappedConsoleKey, modifiers, out uint consoleKey, out scanCode);
  436. //if (scanCode > 0 && consoleKey == keyChar && consoleKey > 48 && consoleKey > 57 && consoleKey < 65 && consoleKey > 91) {
  437. if (scanCode > 0 && keyChar == 0 && consoleKey == mappedConsoleKey) Assert.Equal (0, (double)keyChar);
  438. else Assert.Equal (keyChar, unicodeCharacter);
  439. Assert.Equal (consoleKey, expectedVirtualKey);
  440. Assert.Equal (scanCode, expectedScanCode);
  441. var top = Application.Top;
  442. top.KeyPress += (s, e) => {
  443. var after = ShortcutHelper.GetModifiersKey (e.KeyEvent);
  444. Assert.Equal (expectedRemapping, after);
  445. e.Handled = true;
  446. Application.RequestStop ();
  447. };
  448. var iterations = -1;
  449. Application.Iteration += () => {
  450. iterations++;
  451. if (iterations == 0) Application.Driver.SendKeys ((char)mappedConsoleKey, ConsoleKey.Packet, shift, alt, control);
  452. };
  453. lock (packetLock) {
  454. Application.Run ();
  455. Application.Shutdown ();
  456. }
  457. }
  458. public class PacketTest : IEnumerable, IEnumerable<object []> {
  459. public IEnumerator<object []> GetEnumerator ()
  460. {
  461. lock (packetLock) {
  462. yield return new object [] { 'a', false, false, false, 'A', 30, Key.a, 'A', 30 };
  463. yield return new object [] { 'A', true, false, false, 'A', 30, Key.A | Key.ShiftMask, 'A', 30 };
  464. yield return new object [] { 'A', true, true, false, 'A', 30, Key.A | Key.ShiftMask | Key.AltMask, 'A', 30 };
  465. yield return new object [] { 'A', true, true, true, 'A', 30, Key.A | Key.ShiftMask | Key.AltMask | Key.CtrlMask, 'A', 30 };
  466. yield return new object [] { 'z', false, false, false, 'Z', 44, Key.z, 'Z', 44 };
  467. yield return new object [] { 'Z', true, false, false, 'Z', 44, Key.Z | Key.ShiftMask, 'Z', 44 };
  468. yield return new object [] { 'Z', true, true, false, 'Z', 44, Key.Z | Key.ShiftMask | Key.AltMask, 'Z', 44 };
  469. yield return new object [] { 'Z', true, true, true, 'Z', 44, Key.Z | Key.ShiftMask | Key.AltMask | Key.CtrlMask, 'Z', 44 };
  470. yield return new object [] { '英', false, false, false, '\0', 0, (Key)'英', '\0', 0 };
  471. yield return new object [] { '英', true, false, false, '\0', 0, (Key)'英' | Key.ShiftMask, '\0', 0 };
  472. yield return new object [] { '英', true, true, false, '\0', 0, (Key)'英' | Key.ShiftMask | Key.AltMask, '\0', 0 };
  473. yield return new object [] { '英', true, true, true, '\0', 0, (Key)'英' | Key.ShiftMask | Key.AltMask | Key.CtrlMask, '\0', 0 };
  474. yield return new object [] { '+', false, false, false, 187, 26, (Key)'+', 187, 26 };
  475. yield return new object [] { '*', true, false, false, 187, 26, (Key)'*' | Key.ShiftMask, 187, 26 };
  476. yield return new object [] { '+', true, true, false, 187, 26, (Key)'+' | Key.ShiftMask | Key.AltMask, 187, 26 };
  477. yield return new object [] { '+', true, true, true, 187, 26, (Key)'+' | Key.ShiftMask | Key.AltMask | Key.CtrlMask, 187, 26 };
  478. yield return new object [] { '1', false, false, false, '1', 2, Key.D1, '1', 2 };
  479. yield return new object [] { '!', true, false, false, '1', 2, (Key)'!' | Key.ShiftMask, '1', 2 };
  480. yield return new object [] { '1', true, true, false, '1', 2, Key.D1 | Key.ShiftMask | Key.AltMask, '1', 2 };
  481. yield return new object [] { '1', true, true, true, '1', 2, Key.D1 | Key.ShiftMask | Key.AltMask | Key.CtrlMask, '1', 2 };
  482. yield return new object [] { '1', false, true, true, '1', 2, Key.D1 | Key.AltMask | Key.CtrlMask, '1', 2 };
  483. yield return new object [] { '2', false, false, false, '2', 3, Key.D2, '2', 3 };
  484. yield return new object [] { '"', true, false, false, '2', 3, (Key)'"' | Key.ShiftMask, '2', 3 };
  485. yield return new object [] { '2', true, true, false, '2', 3, Key.D2 | Key.ShiftMask | Key.AltMask, '2', 3 };
  486. yield return new object [] { '2', true, true, true, '2', 3, Key.D2 | Key.ShiftMask | Key.AltMask | Key.CtrlMask, '2', 3 };
  487. yield return new object [] { '@', false, true, true, '2', 3, (Key)'@' | Key.AltMask | Key.CtrlMask, '2', 3 };
  488. yield return new object [] { '3', false, false, false, '3', 4, Key.D3, '3', 4 };
  489. yield return new object [] { '#', true, false, false, '3', 4, (Key)'#' | Key.ShiftMask, '3', 4 };
  490. yield return new object [] { '3', true, true, false, '3', 4, Key.D3 | Key.ShiftMask | Key.AltMask, '3', 4 };
  491. yield return new object [] { '3', true, true, true, '3', 4, Key.D3 | Key.ShiftMask | Key.AltMask | Key.CtrlMask, '3', 4 };
  492. yield return new object [] { '£', false, true, true, '3', 4, (Key)'£' | Key.AltMask | Key.CtrlMask, '3', 4 };
  493. yield return new object [] { '4', false, false, false, '4', 5, Key.D4, '4', 5 };
  494. yield return new object [] { '$', true, false, false, '4', 5, (Key)'$' | Key.ShiftMask, '4', 5 };
  495. yield return new object [] { '4', true, true, false, '4', 5, Key.D4 | Key.ShiftMask | Key.AltMask, '4', 5 };
  496. yield return new object [] { '4', true, true, true, '4', 5, Key.D4 | Key.ShiftMask | Key.AltMask | Key.CtrlMask, '4', 5 };
  497. yield return new object [] { '§', false, true, true, '4', 5, (Key)'§' | Key.AltMask | Key.CtrlMask, '4', 5 };
  498. yield return new object [] { '5', false, false, false, '5', 6, Key.D5, '5', 6 };
  499. yield return new object [] { '%', true, false, false, '5', 6, (Key)'%' | Key.ShiftMask, '5', 6 };
  500. yield return new object [] { '5', true, true, false, '5', 6, Key.D5 | Key.ShiftMask | Key.AltMask, '5', 6 };
  501. yield return new object [] { '5', true, true, true, '5', 6, Key.D5 | Key.ShiftMask | Key.AltMask | Key.CtrlMask, '5', 6 };
  502. yield return new object [] { '€', false, true, true, '5', 6, (Key)'€' | Key.AltMask | Key.CtrlMask, '5', 6 };
  503. yield return new object [] { '6', false, false, false, '6', 7, Key.D6, '6', 7 };
  504. yield return new object [] { '&', true, false, false, '6', 7, (Key)'&' | Key.ShiftMask, '6', 7 };
  505. yield return new object [] { '6', true, true, false, '6', 7, Key.D6 | Key.ShiftMask | Key.AltMask, '6', 7 };
  506. yield return new object [] { '6', true, true, true, '6', 7, Key.D6 | Key.ShiftMask | Key.AltMask | Key.CtrlMask, '6', 7 };
  507. yield return new object [] { '6', false, true, true, '6', 7, Key.D6 | Key.AltMask | Key.CtrlMask, '6', 7 };
  508. yield return new object [] { '7', false, false, false, '7', 8, Key.D7, '7', 8 };
  509. yield return new object [] { '/', true, false, false, '7', 8, (Key)'/' | Key.ShiftMask, '7', 8 };
  510. yield return new object [] { '7', true, true, false, '7', 8, Key.D7 | Key.ShiftMask | Key.AltMask, '7', 8 };
  511. yield return new object [] { '7', true, true, true, '7', 8, Key.D7 | Key.ShiftMask | Key.AltMask | Key.CtrlMask, '7', 8 };
  512. yield return new object [] { '{', false, true, true, '7', 8, (Key)'{' | Key.AltMask | Key.CtrlMask, '7', 8 };
  513. yield return new object [] { '8', false, false, false, '8', 9, Key.D8, '8', 9 };
  514. yield return new object [] { '(', true, false, false, '8', 9, (Key)'(' | Key.ShiftMask, '8', 9 };
  515. yield return new object [] { '8', true, true, false, '8', 9, Key.D8 | Key.ShiftMask | Key.AltMask, '8', 9 };
  516. yield return new object [] { '8', true, true, true, '8', 9, Key.D8 | Key.ShiftMask | Key.AltMask | Key.CtrlMask, '8', 9 };
  517. yield return new object [] { '[', false, true, true, '8', 9, (Key)'[' | Key.AltMask | Key.CtrlMask, '8', 9 };
  518. yield return new object [] { '9', false, false, false, '9', 10, Key.D9, '9', 10 };
  519. yield return new object [] { ')', true, false, false, '9', 10, (Key)')' | Key.ShiftMask, '9', 10 };
  520. yield return new object [] { '9', true, true, false, '9', 10, Key.D9 | Key.ShiftMask | Key.AltMask, '9', 10 };
  521. yield return new object [] { '9', true, true, true, '9', 10, Key.D9 | Key.ShiftMask | Key.AltMask | Key.CtrlMask, '9', 10 };
  522. yield return new object [] { ']', false, true, true, '9', 10, (Key)']' | Key.AltMask | Key.CtrlMask, '9', 10 };
  523. yield return new object [] { '0', false, false, false, '0', 11, Key.D0, '0', 11 };
  524. yield return new object [] { '=', true, false, false, '0', 11, (Key)'=' | Key.ShiftMask, '0', 11 };
  525. yield return new object [] { '0', true, true, false, '0', 11, Key.D0 | Key.ShiftMask | Key.AltMask, '0', 11 };
  526. yield return new object [] { '0', true, true, true, '0', 11, Key.D0 | Key.ShiftMask | Key.AltMask | Key.CtrlMask, '0', 11 };
  527. yield return new object [] { '}', false, true, true, '0', 11, (Key)'}' | Key.AltMask | Key.CtrlMask, '0', 11 };
  528. yield return new object [] { '\'', false, false, false, 219, 12, (Key)'\'', 219, 12 };
  529. yield return new object [] { '?', true, false, false, 219, 12, (Key)'?' | Key.ShiftMask, 219, 12 };
  530. yield return new object [] { '\'', true, true, false, 219, 12, (Key)'\'' | Key.ShiftMask | Key.AltMask, 219, 12 };
  531. yield return new object [] { '\'', true, true, true, 219, 12, (Key)'\'' | Key.ShiftMask | Key.AltMask | Key.CtrlMask, 219, 12 };
  532. yield return new object [] { '«', false, false, false, 221, 13, (Key)'«', 221, 13 };
  533. yield return new object [] { '»', true, false, false, 221, 13, (Key)'»' | Key.ShiftMask, 221, 13 };
  534. yield return new object [] { '«', true, true, false, 221, 13, (Key)'«' | Key.ShiftMask | Key.AltMask, 221, 13 };
  535. yield return new object [] { '«', true, true, true, 221, 13, (Key)'«' | Key.ShiftMask | Key.AltMask | Key.CtrlMask, 221, 13 };
  536. yield return new object [] { 'á', false, false, false, 'á', 0, (Key)'á', 'A', 30 };
  537. yield return new object [] { 'Á', true, false, false, 'Á', 0, (Key)'Á' | Key.ShiftMask, 'A', 30 };
  538. yield return new object [] { 'à', false, false, false, 'à', 0, (Key)'à', 'A', 30 };
  539. yield return new object [] { 'À', true, false, false, 'À', 0, (Key)'À' | Key.ShiftMask, 'A', 30 };
  540. yield return new object [] { 'é', false, false, false, 'é', 0, (Key)'é', 'E', 18 };
  541. yield return new object [] { 'É', true, false, false, 'É', 0, (Key)'É' | Key.ShiftMask, 'E', 18 };
  542. yield return new object [] { 'è', false, false, false, 'è', 0, (Key)'è', 'E', 18 };
  543. yield return new object [] { 'È', true, false, false, 'È', 0, (Key)'È' | Key.ShiftMask, 'E', 18 };
  544. yield return new object [] { 'í', false, false, false, 'í', 0, (Key)'í', 'I', 23 };
  545. yield return new object [] { 'Í', true, false, false, 'Í', 0, (Key)'Í' | Key.ShiftMask, 'I', 23 };
  546. yield return new object [] { 'ì', false, false, false, 'ì', 0, (Key)'ì', 'I', 23 };
  547. yield return new object [] { 'Ì', true, false, false, 'Ì', 0, (Key)'Ì' | Key.ShiftMask, 'I', 23 };
  548. yield return new object [] { 'ó', false, false, false, 'ó', 0, (Key)'ó', 'O', 24 };
  549. yield return new object [] { 'Ó', true, false, false, 'Ó', 0, (Key)'Ó' | Key.ShiftMask, 'O', 24 };
  550. yield return new object [] { 'ò', false, false, false, 'Ó', 0, (Key)'ò', 'O', 24 };
  551. yield return new object [] { 'Ò', true, false, false, 'Ò', 0, (Key)'Ò' | Key.ShiftMask, 'O', 24 };
  552. yield return new object [] { 'ú', false, false, false, 'ú', 0, (Key)'ú', 'U', 22 };
  553. yield return new object [] { 'Ú', true, false, false, 'Ú', 0, (Key)'Ú' | Key.ShiftMask, 'U', 22 };
  554. yield return new object [] { 'ù', false, false, false, 'ù', 0, (Key)'ù', 'U', 22 };
  555. yield return new object [] { 'Ù', true, false, false, 'Ù', 0, (Key)'Ù' | Key.ShiftMask, 'U', 22 };
  556. yield return new object [] { 'ö', false, false, false, 'ó', 0, (Key)'ö', 'O', 24 };
  557. yield return new object [] { 'Ö', true, false, false, 'Ó', 0, (Key)'Ö' | Key.ShiftMask, 'O', 24 };
  558. yield return new object [] { '<', false, false, false, 226, 86, (Key)'<', 226, 86 };
  559. yield return new object [] { '>', true, false, false, 226, 86, (Key)'>' | Key.ShiftMask, 226, 86 };
  560. yield return new object [] { '<', true, true, false, 226, 86, (Key)'<' | Key.ShiftMask | Key.AltMask, 226, 86 };
  561. yield return new object [] { '<', true, true, true, 226, 86, (Key)'<' | Key.ShiftMask | Key.AltMask | Key.CtrlMask, 226, 86 };
  562. yield return new object [] { 'ç', false, false, false, 192, 39, (Key)'ç', 192, 39 };
  563. yield return new object [] { 'Ç', true, false, false, 192, 39, (Key)'Ç' | Key.ShiftMask, 192, 39 };
  564. yield return new object [] { 'ç', true, true, false, 192, 39, (Key)'ç' | Key.ShiftMask | Key.AltMask, 192, 39 };
  565. yield return new object [] { 'ç', true, true, true, 192, 39, (Key)'ç' | Key.ShiftMask | Key.AltMask | Key.CtrlMask, 192, 39 };
  566. yield return new object [] { '¨', false, true, true, 187, 26, (Key)'¨' | Key.AltMask | Key.CtrlMask, 187, 26 };
  567. yield return new object [] { (uint)Key.PageUp, false, false, false, 33, 73, Key.PageUp, 33, 73 };
  568. yield return new object [] { (uint)Key.PageUp, true, false, false, 33, 73, Key.PageUp | Key.ShiftMask, 33, 73 };
  569. yield return new object [] { (uint)Key.PageUp, true, true, false, 33, 73, Key.PageUp | Key.ShiftMask | Key.AltMask, 33, 73 };
  570. yield return new object [] { (uint)Key.PageUp, true, true, true, 33, 73, Key.PageUp | Key.ShiftMask | Key.AltMask | Key.CtrlMask, 33, 73 };
  571. }
  572. }
  573. IEnumerator IEnumerable.GetEnumerator () => GetEnumerator ();
  574. }
  575. }
  576. }