ButtonTests.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. using System.ComponentModel;
  2. using Xunit.Abstractions;
  3. namespace Terminal.Gui.ViewsTests;
  4. public class ButtonTests (ITestOutputHelper output)
  5. {
  6. // Test that Title and Text are the same
  7. [Fact]
  8. public void Text_Mirrors_Title ()
  9. {
  10. var view = new Button ();
  11. view.Title = "Hello";
  12. Assert.Equal ("Hello", view.Title);
  13. Assert.Equal ("Hello", view.TitleTextFormatter.Text);
  14. Assert.Equal ("Hello", view.Text);
  15. Assert.Equal ($"{CM.Glyphs.LeftBracket} Hello {CM.Glyphs.RightBracket}", view.TextFormatter.Text);
  16. view.Dispose ();
  17. }
  18. [Fact]
  19. public void Title_Mirrors_Text ()
  20. {
  21. var view = new Button ();
  22. view.Text = "Hello";
  23. Assert.Equal ("Hello", view.Text);
  24. Assert.Equal ($"{CM.Glyphs.LeftBracket} Hello {CM.Glyphs.RightBracket}", view.TextFormatter.Text);
  25. Assert.Equal ("Hello", view.Title);
  26. Assert.Equal ("Hello", view.TitleTextFormatter.Text);
  27. view.Dispose ();
  28. }
  29. [Theory]
  30. [InlineData ("01234", 0, 0, 0, 0)]
  31. [InlineData ("01234", 1, 0, 1, 0)]
  32. [InlineData ("01234", 0, 1, 0, 1)]
  33. [InlineData ("01234", 1, 1, 1, 1)]
  34. [InlineData ("01234", 10, 1, 10, 1)]
  35. [InlineData ("01234", 10, 3, 10, 3)]
  36. [InlineData ("0_1234", 0, 0, 0, 0)]
  37. [InlineData ("0_1234", 1, 0, 1, 0)]
  38. [InlineData ("0_1234", 0, 1, 0, 1)]
  39. [InlineData ("0_1234", 1, 1, 1, 1)]
  40. [InlineData ("0_1234", 10, 1, 10, 1)]
  41. [InlineData ("0_12你", 10, 3, 10, 3)]
  42. [InlineData ("0_12你", 0, 0, 0, 0)]
  43. [InlineData ("0_12你", 1, 0, 1, 0)]
  44. [InlineData ("0_12你", 0, 1, 0, 1)]
  45. [InlineData ("0_12你", 1, 1, 1, 1)]
  46. [InlineData ("0_12你", 10, 1, 10, 1)]
  47. [InlineData ("0_12你", 10, 3, 10, 3)]
  48. public void Button_AbsoluteSize_Text (string text, int width, int height, int expectedWidth, int expectedHeight)
  49. {
  50. var btn1 = new Button
  51. {
  52. Text = text,
  53. Width = width,
  54. Height = height,
  55. };
  56. Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.Frame.Size);
  57. Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.Viewport.Size);
  58. Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.GetContentSize ());
  59. Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.TextFormatter.Size);
  60. btn1.Dispose ();
  61. }
  62. [Theory]
  63. [InlineData (0, 0, 0, 0)]
  64. [InlineData (1, 0, 1, 0)]
  65. [InlineData (0, 1, 0, 1)]
  66. [InlineData (1, 1, 1, 1)]
  67. [InlineData (10, 1, 10, 1)]
  68. [InlineData (10, 3, 10, 3)]
  69. public void Button_AbsoluteSize_DefaultText (int width, int height, int expectedWidth, int expectedHeight)
  70. {
  71. var btn1 = new Button
  72. {
  73. Width = width,
  74. Height = height,
  75. };
  76. Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.Frame.Size);
  77. Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.Viewport.Size);
  78. Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.TextFormatter.Size);
  79. btn1.Dispose ();
  80. }
  81. [Fact]
  82. public void Button_HotKeyChanged_EventFires ()
  83. {
  84. var btn = new Button { Text = "_Yar" };
  85. object sender = null;
  86. KeyChangedEventArgs args = null;
  87. btn.HotKeyChanged += (s, e) =>
  88. {
  89. sender = s;
  90. args = e;
  91. };
  92. btn.HotKeyChanged += (s, e) =>
  93. {
  94. sender = s;
  95. args = e;
  96. };
  97. btn.HotKey = KeyCode.R;
  98. Assert.Same (btn, sender);
  99. Assert.Equal (KeyCode.Y, args.OldKey);
  100. Assert.Equal (KeyCode.R, args.NewKey);
  101. btn.HotKey = KeyCode.R;
  102. Assert.Same (btn, sender);
  103. Assert.Equal (KeyCode.Y, args.OldKey);
  104. Assert.Equal (KeyCode.R, args.NewKey);
  105. btn.Dispose ();
  106. }
  107. [Fact]
  108. public void Button_HotKeyChanged_EventFires_WithNone ()
  109. {
  110. var btn = new Button ();
  111. object sender = null;
  112. KeyChangedEventArgs args = null;
  113. btn.HotKeyChanged += (s, e) =>
  114. {
  115. sender = s;
  116. args = e;
  117. };
  118. btn.HotKey = KeyCode.R;
  119. Assert.Same (btn, sender);
  120. Assert.Equal (KeyCode.Null, args.OldKey);
  121. Assert.Equal (KeyCode.R, args.NewKey);
  122. btn.Dispose ();
  123. }
  124. [Fact]
  125. [SetupFakeDriver]
  126. public void Constructors_Defaults ()
  127. {
  128. var btn = new Button ();
  129. Assert.Equal (string.Empty, btn.Text);
  130. btn.BeginInit ();
  131. btn.EndInit ();
  132. btn.SetRelativeLayout (new (100, 100));
  133. Assert.Equal ($"{CM.Glyphs.LeftBracket} {CM.Glyphs.RightBracket}", btn.TextFormatter.Text);
  134. Assert.False (btn.IsDefault);
  135. Assert.Equal (Alignment.Center, btn.TextAlignment);
  136. Assert.Equal ('_', btn.HotKeySpecifier.Value);
  137. Assert.True (btn.CanFocus);
  138. Assert.Equal (new (0, 0, 4, 1), btn.Viewport);
  139. Assert.Equal (new (0, 0, 4, 1), btn.Frame);
  140. Assert.Equal ($"{CM.Glyphs.LeftBracket} {CM.Glyphs.RightBracket}", btn.TextFormatter.Text);
  141. Assert.False (btn.IsDefault);
  142. Assert.Equal (Alignment.Center, btn.TextAlignment);
  143. Assert.Equal ('_', btn.HotKeySpecifier.Value);
  144. Assert.True (btn.CanFocus);
  145. Assert.Equal (new (0, 0, 4, 1), btn.Viewport);
  146. Assert.Equal (new (0, 0, 4, 1), btn.Frame);
  147. Assert.Equal (string.Empty, btn.Title);
  148. Assert.Equal (KeyCode.Null, btn.HotKey);
  149. btn.Draw ();
  150. var expected = @$"
  151. {CM.Glyphs.LeftBracket} {CM.Glyphs.RightBracket}
  152. ";
  153. TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
  154. btn.Dispose ();
  155. btn = new () { Text = "_Test", IsDefault = true };
  156. Assert.Equal (new (10, 1), btn.TextFormatter.Size);
  157. btn.BeginInit ();
  158. btn.EndInit ();
  159. Assert.Equal ('_', btn.HotKeySpecifier.Value);
  160. Assert.Equal (Key.T, btn.HotKey);
  161. Assert.Equal ("_Test", btn.Text);
  162. Assert.Equal (
  163. $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} Test {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}",
  164. btn.TextFormatter.Format ()
  165. );
  166. Assert.True (btn.IsDefault);
  167. Assert.Equal (Alignment.Center, btn.TextAlignment);
  168. Assert.True (btn.CanFocus);
  169. btn.SetRelativeLayout (new (100, 100));
  170. // 0123456789012345678901234567890123456789
  171. // [* Test *]
  172. Assert.Equal ('_', btn.HotKeySpecifier.Value);
  173. Assert.Equal (10, btn.TextFormatter.Format ().Length);
  174. Assert.Equal (new (10, 1), btn.TextFormatter.Size);
  175. Assert.Equal (new (10, 1), btn.GetContentSize ());
  176. Assert.Equal (new (0, 0, 10, 1), btn.Viewport);
  177. Assert.Equal (new (0, 0, 10, 1), btn.Frame);
  178. Assert.Equal (KeyCode.T, btn.HotKey);
  179. btn.Dispose ();
  180. btn = new () { X = 1, Y = 2, Text = "_abc", IsDefault = true };
  181. btn.BeginInit ();
  182. btn.EndInit ();
  183. Assert.Equal ("_abc", btn.Text);
  184. Assert.Equal (Key.A, btn.HotKey);
  185. Assert.Equal (
  186. $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} abc {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}",
  187. btn.TextFormatter.Format ()
  188. );
  189. Assert.True (btn.IsDefault);
  190. Assert.Equal (Alignment.Center, btn.TextAlignment);
  191. Assert.Equal ('_', btn.HotKeySpecifier.Value);
  192. Assert.True (btn.CanFocus);
  193. Application.Driver.ClearContents ();
  194. btn.Draw ();
  195. expected = @$"
  196. {CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} abc {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}
  197. ";
  198. TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
  199. Assert.Equal (new (0, 0, 9, 1), btn.Viewport);
  200. Assert.Equal (new (1, 2, 9, 1), btn.Frame);
  201. btn.Dispose ();
  202. }
  203. [Fact]
  204. public void HotKeyChange_Works ()
  205. {
  206. var clicked = false;
  207. var btn = new Button { Text = "_Test" };
  208. btn.Accept += (s, e) => clicked = true;
  209. Assert.Equal (KeyCode.T, btn.HotKey);
  210. Assert.True (btn.NewKeyDownEvent (Key.T));
  211. Assert.True (clicked);
  212. clicked = false;
  213. Assert.True (btn.NewKeyDownEvent (Key.T.WithAlt));
  214. Assert.True (clicked);
  215. clicked = false;
  216. btn.HotKey = KeyCode.E;
  217. Assert.True (btn.NewKeyDownEvent (Key.E.WithAlt));
  218. Assert.True (clicked);
  219. }
  220. /// <summary>
  221. /// This test demonstrates how to change the activation key for Button as described in the README.md keyboard
  222. /// handling section
  223. /// </summary>
  224. [Fact]
  225. [AutoInitShutdown]
  226. public void KeyBindingExample ()
  227. {
  228. var pressed = 0;
  229. var btn = new Button { Text = "Press Me" };
  230. btn.Accept += (s, e) => pressed++;
  231. // The Button class supports the Default and Accept command
  232. Assert.Contains (Command.HotKey, btn.GetSupportedCommands ());
  233. Assert.Contains (Command.Accept, btn.GetSupportedCommands ());
  234. var top = new Toplevel ();
  235. top.Add (btn);
  236. Application.Begin (top);
  237. // default keybinding is Space which results in keypress
  238. Application.OnKeyDown (new ((KeyCode)' '));
  239. Assert.Equal (1, pressed);
  240. // remove the default keybinding (Space)
  241. btn.KeyBindings.Clear (Command.HotKey);
  242. btn.KeyBindings.Clear (Command.Accept);
  243. // After clearing the default keystroke the Space button no longer does anything for the Button
  244. Application.OnKeyDown (new ((KeyCode)' '));
  245. Assert.Equal (1, pressed);
  246. // Set a new binding of b for the click (Accept) event
  247. btn.KeyBindings.Add (Key.B, Command.HotKey);
  248. btn.KeyBindings.Add (Key.B, Command.Accept);
  249. // now pressing B should call the button click event
  250. Application.OnKeyDown (Key.B);
  251. Assert.Equal (2, pressed);
  252. // now pressing Shift-B should NOT call the button click event
  253. Application.OnKeyDown (Key.B.WithShift);
  254. Assert.Equal (2, pressed);
  255. // now pressing Alt-B should NOT call the button click event
  256. Application.OnKeyDown (Key.B.WithAlt);
  257. Assert.Equal (2, pressed);
  258. // now pressing Shift-Alt-B should NOT call the button click event
  259. Application.OnKeyDown (Key.B.WithAlt.WithShift);
  260. Assert.Equal (2, pressed);
  261. top.Dispose ();
  262. }
  263. [Fact]
  264. [AutoInitShutdown]
  265. public void KeyBindings_Command ()
  266. {
  267. var clicked = false;
  268. var btn = new Button { Text = "_Test" };
  269. btn.Accept += (s, e) => clicked = true;
  270. var top = new Toplevel ();
  271. top.Add (btn);
  272. Application.Begin (top);
  273. // Hot key. Both alone and with alt
  274. Assert.Equal (KeyCode.T, btn.HotKey);
  275. Assert.True (btn.NewKeyDownEvent (Key.T));
  276. Assert.True (clicked);
  277. clicked = false;
  278. Assert.True (btn.NewKeyDownEvent (Key.T.WithAlt));
  279. Assert.True (clicked);
  280. clicked = false;
  281. Assert.True (btn.NewKeyDownEvent (btn.HotKey));
  282. Assert.True (clicked);
  283. clicked = false;
  284. Assert.True (btn.NewKeyDownEvent (btn.HotKey));
  285. Assert.True (clicked);
  286. clicked = false;
  287. // IsDefault = false
  288. // Space and Enter should work
  289. Assert.False (btn.IsDefault);
  290. Assert.True (btn.NewKeyDownEvent (Key.Enter));
  291. Assert.True (clicked);
  292. clicked = false;
  293. // IsDefault = true
  294. // Space and Enter should work
  295. btn.IsDefault = true;
  296. Assert.True (btn.NewKeyDownEvent (Key.Enter));
  297. Assert.True (clicked);
  298. clicked = false;
  299. // Toplevel does not handle Enter, so it should get passed on to button
  300. Assert.True (Application.Top.NewKeyDownEvent (Key.Enter));
  301. Assert.True (clicked);
  302. clicked = false;
  303. // Direct
  304. Assert.True (btn.NewKeyDownEvent (Key.Enter));
  305. Assert.True (clicked);
  306. clicked = false;
  307. Assert.True (btn.NewKeyDownEvent (Key.Space));
  308. Assert.True (clicked);
  309. clicked = false;
  310. Assert.True (btn.NewKeyDownEvent (new ((KeyCode)'T')));
  311. Assert.True (clicked);
  312. clicked = false;
  313. // Change hotkey:
  314. btn.Text = "Te_st";
  315. Assert.True (btn.NewKeyDownEvent (btn.HotKey));
  316. Assert.True (clicked);
  317. clicked = false;
  318. top.Dispose ();
  319. }
  320. [Fact]
  321. public void HotKey_Command_Accepts ()
  322. {
  323. var button = new Button ();
  324. var accepted = false;
  325. button.Accept += ButtonOnAccept;
  326. button.InvokeCommand (Command.HotKey);
  327. Assert.True (accepted);
  328. button.Dispose ();
  329. return;
  330. void ButtonOnAccept (object sender, CancelEventArgs e) { accepted = true; }
  331. }
  332. [Fact]
  333. public void Accept_Cancel_Event_OnAccept_Returns_True ()
  334. {
  335. var button = new Button ();
  336. var acceptInvoked = false;
  337. button.Accept += ButtonAccept;
  338. bool? ret = button.InvokeCommand (Command.Accept);
  339. Assert.True (ret);
  340. Assert.True (acceptInvoked);
  341. button.Dispose ();
  342. return;
  343. void ButtonAccept (object sender, CancelEventArgs e)
  344. {
  345. acceptInvoked = true;
  346. e.Cancel = true;
  347. }
  348. }
  349. [Fact]
  350. public void Setting_Empty_Text_Sets_HoKey_To_KeyNull ()
  351. {
  352. var super = new View ();
  353. var btn = new Button { Text = "_Test" };
  354. super.Add (btn);
  355. super.BeginInit ();
  356. super.EndInit ();
  357. Assert.Equal ("_Test", btn.Text);
  358. Assert.Equal (KeyCode.T, btn.HotKey);
  359. btn.Text = string.Empty;
  360. Assert.Equal ("", btn.Text);
  361. Assert.Equal (KeyCode.Null, btn.HotKey);
  362. btn.Text = string.Empty;
  363. Assert.Equal ("", btn.Text);
  364. Assert.Equal (KeyCode.Null, btn.HotKey);
  365. btn.Text = "Te_st";
  366. Assert.Equal ("Te_st", btn.Text);
  367. Assert.Equal (KeyCode.S, btn.HotKey);
  368. super.Dispose ();
  369. }
  370. [Fact]
  371. public void TestAssignTextToButton ()
  372. {
  373. View b = new Button { Text = "heya" };
  374. Assert.Equal ("heya", b.Text);
  375. Assert.Contains ("heya", b.TextFormatter.Text);
  376. b.Text = "heyb";
  377. Assert.Equal ("heyb", b.Text);
  378. Assert.Contains ("heyb", b.TextFormatter.Text);
  379. // with cast
  380. Assert.Equal ("heyb", ((Button)b).Text);
  381. b.Dispose ();
  382. }
  383. [Fact]
  384. [AutoInitShutdown]
  385. public void Update_Only_On_Or_After_Initialize ()
  386. {
  387. var btn = new Button { X = Pos.Center (), Y = Pos.Center (), Text = "Say Hello 你" };
  388. var win = new Window { Width = Dim.Fill (), Height = Dim.Fill () };
  389. win.Add (btn);
  390. var top = new Toplevel ();
  391. top.Add (win);
  392. Assert.False (btn.IsInitialized);
  393. Application.Begin (top);
  394. ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
  395. Assert.True (btn.IsInitialized);
  396. Assert.Equal ("Say Hello 你", btn.Text);
  397. Assert.Equal ($"{CM.Glyphs.LeftBracket} {btn.Text} {CM.Glyphs.RightBracket}", btn.TextFormatter.Text);
  398. Assert.Equal (new (0, 0, 16, 1), btn.Viewport);
  399. var btnTxt = $"{CM.Glyphs.LeftBracket} {btn.Text} {CM.Glyphs.RightBracket}";
  400. var expected = @$"
  401. ┌────────────────────────────┐
  402. │ │
  403. │ {btnTxt} │
  404. │ │
  405. └────────────────────────────┘
  406. ";
  407. Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
  408. Assert.Equal (new (0, 0, 30, 5), pos);
  409. top.Dispose ();
  410. }
  411. [Fact]
  412. [AutoInitShutdown]
  413. public void Update_Parameterless_Only_On_Or_After_Initialize ()
  414. {
  415. var btn = new Button { X = Pos.Center (), Y = Pos.Center (), Text = "Say Hello 你" };
  416. var win = new Window { Width = Dim.Fill (), Height = Dim.Fill () };
  417. win.Add (btn);
  418. var top = new Toplevel ();
  419. top.Add (win);
  420. Assert.False (btn.IsInitialized);
  421. Application.Begin (top);
  422. ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
  423. Assert.True (btn.IsInitialized);
  424. Assert.Equal ("Say Hello 你", btn.Text);
  425. Assert.Equal ($"{CM.Glyphs.LeftBracket} {btn.Text} {CM.Glyphs.RightBracket}", btn.TextFormatter.Text);
  426. Assert.Equal (new (0, 0, 16, 1), btn.Viewport);
  427. var btnTxt = $"{CM.Glyphs.LeftBracket} {btn.Text} {CM.Glyphs.RightBracket}";
  428. var expected = @$"
  429. ┌────────────────────────────┐
  430. │ │
  431. │ {btnTxt} │
  432. │ │
  433. └────────────────────────────┘
  434. ";
  435. Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
  436. Assert.Equal (new (0, 0, 30, 5), pos);
  437. top.Dispose ();
  438. }
  439. [Theory]
  440. [InlineData (MouseFlags.Button1Pressed, MouseFlags.Button1Released, MouseFlags.Button1Clicked)]
  441. [InlineData (MouseFlags.Button2Pressed, MouseFlags.Button2Released, MouseFlags.Button2Clicked)]
  442. [InlineData (MouseFlags.Button3Pressed, MouseFlags.Button3Released, MouseFlags.Button3Clicked)]
  443. [InlineData (MouseFlags.Button4Pressed, MouseFlags.Button4Released, MouseFlags.Button4Clicked)]
  444. public void WantContinuousButtonPressed_True_ButtonClick_Accepts (MouseFlags pressed, MouseFlags released, MouseFlags clicked)
  445. {
  446. var me = new MouseEvent ();
  447. var button = new Button ()
  448. {
  449. Width = 1,
  450. Height = 1,
  451. WantContinuousButtonPressed = true
  452. };
  453. var acceptCount = 0;
  454. button.Accept += (s, e) => acceptCount++;
  455. me.Flags = pressed;
  456. button.NewMouseEvent (me);
  457. Assert.Equal (1, acceptCount);
  458. me.Flags = released;
  459. button.NewMouseEvent (me);
  460. Assert.Equal (1, acceptCount);
  461. me.Flags = clicked;
  462. button.NewMouseEvent (me);
  463. Assert.Equal (1, acceptCount);
  464. button.Dispose ();
  465. }
  466. [Theory]
  467. [InlineData (MouseFlags.Button1Pressed, MouseFlags.Button1Released, MouseFlags.Button1Clicked)]
  468. [InlineData (MouseFlags.Button2Pressed, MouseFlags.Button2Released, MouseFlags.Button2Clicked)]
  469. [InlineData (MouseFlags.Button3Pressed, MouseFlags.Button3Released, MouseFlags.Button3Clicked)]
  470. [InlineData (MouseFlags.Button4Pressed, MouseFlags.Button4Released, MouseFlags.Button4Clicked)]
  471. public void WantContinuousButtonPressed_True_ButtonPressRelease_Accepts (MouseFlags pressed, MouseFlags released, MouseFlags clicked)
  472. {
  473. var me = new MouseEvent ();
  474. var button = new Button ()
  475. {
  476. Width = 1,
  477. Height = 1,
  478. WantContinuousButtonPressed = true
  479. };
  480. var acceptCount = 0;
  481. button.Accept += (s, e) => acceptCount++;
  482. me.Flags = pressed;
  483. button.NewMouseEvent (me);
  484. Assert.Equal (1, acceptCount);
  485. me.Flags = released;
  486. button.NewMouseEvent (me);
  487. Assert.Equal (1, acceptCount);
  488. button.Dispose ();
  489. }
  490. }