ScrollBarTest.cs 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460
  1. //
  2. // Copyright (c) 2005 Novell, Inc.
  3. //
  4. // Authors:
  5. // Hisham Mardam Bey ([email protected])
  6. // Ritvik Mayank ([email protected])
  7. //
  8. //
  9. using System;
  10. using NUnit.Framework;
  11. using System.Windows.Forms;
  12. using System.Drawing;
  13. using System.Collections;
  14. namespace MonoTests.System.Windows.Forms
  15. {
  16. public class MyScrollBar : HScrollBar
  17. {
  18. private ArrayList results = new ArrayList ();
  19. public MyScrollBar () : base ()
  20. {}
  21. protected override void OnBackColorChanged (EventArgs e)
  22. {
  23. results.Add ("OnBackColorChanged");
  24. base.OnBackColorChanged (e);
  25. }
  26. protected override void OnBackgroundImageChanged (EventArgs e)
  27. {
  28. results.Add ("OnBackgroundImageChanged");
  29. base.OnBackgroundImageChanged (e);
  30. }
  31. protected override void OnClick (EventArgs e)
  32. {
  33. results.Add ("OnClick");
  34. base.OnClick (e);
  35. }
  36. protected override void OnDoubleClick (EventArgs e)
  37. {
  38. results.Add ("OnDoubleClick");
  39. base.OnDoubleClick (e);
  40. }
  41. protected override void OnFontChanged (EventArgs e)
  42. {
  43. results.Add ("OnFontChanged");
  44. base.OnFontChanged (e);
  45. }
  46. protected override void OnForeColorChanged (EventArgs e)
  47. {
  48. results.Add ("OnForeColorChanged");
  49. base.OnForeColorChanged (e);
  50. }
  51. protected override void OnImeModeChanged (EventArgs e)
  52. {
  53. results.Add ("OnImeModeChanged");
  54. base.OnImeModeChanged (e);
  55. }
  56. protected override void OnMouseDown (MouseEventArgs e)
  57. {
  58. results.Add ("OnMouseDown");
  59. base.OnMouseDown (e);
  60. }
  61. protected override void OnMouseMove (MouseEventArgs e)
  62. {
  63. results.Add ("OnMouseMove");
  64. base.OnMouseMove (e);
  65. }
  66. protected override void OnMouseEnter (EventArgs e)
  67. {
  68. results.Add ("OnMouseEnter");
  69. base.OnMouseEnter (e);
  70. }
  71. protected override void OnMouseLeave (EventArgs e)
  72. {
  73. results.Add ("OnMouseLeave");
  74. base.OnMouseLeave (e);
  75. }
  76. protected override void OnMouseHover (EventArgs e)
  77. {
  78. results.Add ("OnMouseHover");
  79. base.OnMouseHover (e);
  80. }
  81. protected override void OnMouseUp (MouseEventArgs e)
  82. {
  83. results.Add ("OnMouseUp");
  84. base.OnMouseUp (e);
  85. }
  86. protected override void OnHandleCreated (EventArgs e)
  87. {
  88. results.Add ("OnHandleCreated");
  89. base.OnHandleCreated (e);
  90. }
  91. protected override void OnBindingContextChanged (EventArgs e)
  92. {
  93. results.Add ("OnBindingContextChanged");
  94. base.OnBindingContextChanged (e);
  95. }
  96. protected override void OnInvalidated (InvalidateEventArgs e)
  97. {
  98. results.Add("OnInvalidated");
  99. base.OnInvalidated (e);
  100. }
  101. protected override void OnResize (EventArgs e)
  102. {
  103. results.Add("OnResize");
  104. base.OnResize (e);
  105. }
  106. protected override void OnSizeChanged (EventArgs e)
  107. {
  108. results.Add("OnSizeChanged");
  109. base.OnSizeChanged (e);
  110. }
  111. protected override void OnLayout (LayoutEventArgs e)
  112. {
  113. results.Add("OnLayout");
  114. base.OnLayout (e);
  115. }
  116. protected override void OnVisibleChanged (EventArgs e)
  117. {
  118. results.Add("OnVisibleChanged");
  119. base.OnVisibleChanged (e);
  120. }
  121. protected override void OnScroll (ScrollEventArgs e)
  122. {
  123. results.Add("OnScroll");
  124. base.OnScroll (e);
  125. }
  126. protected override void OnTextChanged (EventArgs e)
  127. {
  128. results.Add("OnTextChanged");
  129. base.OnTextChanged (e);
  130. }
  131. protected override void OnValueChanged (EventArgs e)
  132. {
  133. results.Add("OnValueChanged");
  134. base.OnValueChanged (e);
  135. }
  136. protected override void OnPaint (PaintEventArgs e)
  137. {
  138. results.Add("OnPaint");
  139. base.OnPaint (e);
  140. }
  141. public ArrayList Results {
  142. get { return results; }
  143. }
  144. public void MoveMouse ()
  145. {
  146. Message m;
  147. m = new Message ();
  148. m.Msg = (int)WndMsg.WM_NCHITTEST;
  149. m.HWnd = this.Handle;
  150. m.WParam = (IntPtr)0x0;
  151. m.LParam = (IntPtr)0x1c604ea;
  152. this.WndProc(ref m);
  153. m.Msg = (int)WndMsg.WM_SETCURSOR;
  154. m.HWnd = this.Handle;
  155. m.WParam = (IntPtr)0x100448;
  156. m.LParam = (IntPtr)0x2000001;
  157. this.WndProc(ref m);
  158. m.Msg = (int)WndMsg.WM_MOUSEFIRST;
  159. m.HWnd = this.Handle;
  160. m.WParam = (IntPtr)0x0;
  161. m.LParam = (IntPtr)0x14000b;
  162. this.WndProc(ref m);
  163. m.Msg = (int)WndMsg.WM_MOUSEHOVER;
  164. m.HWnd = this.Handle;
  165. m.WParam = (IntPtr)0x0;
  166. m.LParam = (IntPtr)0x14000b;
  167. this.WndProc(ref m);
  168. }
  169. public void MouseClick()
  170. {
  171. Message m;
  172. m = new Message();
  173. m.Msg = (int)WndMsg.WM_LBUTTONDOWN;
  174. m.HWnd = this.Handle;
  175. m.WParam = (IntPtr)0x01;
  176. m.LParam = (IntPtr)0x9004f;
  177. this.WndProc(ref m);
  178. m = new Message();
  179. m.Msg = (int)WndMsg.WM_LBUTTONUP;
  180. m.HWnd = this.Handle;
  181. m.WParam = (IntPtr)0x01;
  182. m.LParam = (IntPtr)0x9004f;
  183. this.WndProc(ref m);
  184. }
  185. public void MouseDoubleClick ()
  186. {
  187. MouseClick ();
  188. MouseClick ();
  189. }
  190. public void MouseRightDown()
  191. {
  192. Message m;
  193. m = new Message();
  194. m.Msg = (int)WndMsg.WM_RBUTTONDOWN;
  195. m.HWnd = this.Handle;
  196. m.WParam = (IntPtr)0x01;
  197. m.LParam = (IntPtr)0x9004f;
  198. this.WndProc(ref m);
  199. }
  200. public void MouseRightUp()
  201. {
  202. Message m;
  203. m = new Message();
  204. m.Msg = (int)WndMsg.WM_RBUTTONUP;
  205. m.HWnd = this.Handle;
  206. m.WParam = (IntPtr)0x01;
  207. m.LParam = (IntPtr)0x9004f;
  208. this.WndProc(ref m);
  209. }
  210. public void ScrollNow ()
  211. {
  212. Message m;
  213. m = new Message ();
  214. m.Msg = 8468;
  215. m.HWnd = this.Handle;
  216. m.WParam = (IntPtr)0x1;
  217. m.LParam = (IntPtr)0x1a051a;
  218. this.WndProc(ref m);
  219. m.Msg = 233;
  220. m.HWnd = this.Handle;
  221. m.WParam = (IntPtr)0x1;
  222. m.LParam = (IntPtr)0x12eb34;
  223. this.WndProc(ref m);
  224. }
  225. }
  226. [TestFixture]
  227. public class ScrollBarTest
  228. {
  229. [Test]
  230. [Category ("NotWorking")]
  231. public void PubPropTest ()
  232. {
  233. MyScrollBar myscrlbar = new MyScrollBar ();
  234. // B
  235. myscrlbar.BackColor = Color.Red;
  236. Assert.AreEqual (255, myscrlbar.BackColor.R, "B2");
  237. myscrlbar.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
  238. Assert.AreEqual (16, myscrlbar.BackgroundImage.Height, "B3");
  239. // F
  240. Assert.AreEqual ("ControlText", myscrlbar.ForeColor.Name, "F1");
  241. // I
  242. //Assert.AreEqual (ImeMode.Disable, myscrlbar.ImeMode, "I1");
  243. // L
  244. Assert.AreEqual (10, myscrlbar.LargeChange, "L1");
  245. // M
  246. Assert.AreEqual (100, myscrlbar.Maximum, "M1");
  247. Assert.AreEqual (0, myscrlbar.Minimum, "M2");
  248. myscrlbar.Maximum = 300;
  249. myscrlbar.Minimum = 100;
  250. Assert.AreEqual (300, myscrlbar.Maximum, "M3");
  251. Assert.AreEqual (100, myscrlbar.Minimum, "M4");
  252. // S
  253. Assert.AreEqual (null, myscrlbar.Site, "S1");
  254. Assert.AreEqual (1, myscrlbar.SmallChange, "S2");
  255. myscrlbar.SmallChange = 10;
  256. Assert.AreEqual (10, myscrlbar.SmallChange, "S3");
  257. // T
  258. Assert.AreEqual (false, myscrlbar.TabStop, "T1");
  259. myscrlbar.TabStop = true;
  260. Assert.AreEqual (true, myscrlbar.TabStop, "T2");
  261. Assert.AreEqual ("", myscrlbar.Text, "T3");
  262. myscrlbar.Text = "MONO SCROLLBAR";
  263. Assert.AreEqual ("MONO SCROLLBAR", myscrlbar.Text, "T4");
  264. // V
  265. Assert.AreEqual (100, myscrlbar.Value, "V1");
  266. myscrlbar.Value = 150;
  267. Assert.AreEqual (150, myscrlbar.Value, "V2");
  268. }
  269. [Test]
  270. [ExpectedException (typeof (ArgumentException))]
  271. public void ExceptionValueTest ()
  272. {
  273. MyScrollBar myscrlbar = new MyScrollBar ();
  274. myscrlbar.Minimum = 10;
  275. myscrlbar.Maximum = 20;
  276. myscrlbar.Value = 9;
  277. myscrlbar.Value = 21;
  278. }
  279. [Test]
  280. [ExpectedException (typeof (ArgumentException))]
  281. public void ExceptionSmallChangeTest ()
  282. {
  283. MyScrollBar myscrlbar = new MyScrollBar ();
  284. myscrlbar.SmallChange = -1;
  285. }
  286. [Test]
  287. [ExpectedException (typeof (ArgumentException))]
  288. public void ExceptionLargeChangeTest ()
  289. {
  290. MyScrollBar myscrlbar = new MyScrollBar ();
  291. myscrlbar.LargeChange = -1;
  292. }
  293. [Test]
  294. public void PubMethodTest ()
  295. {
  296. MyScrollBar myscrlbar = new MyScrollBar ();
  297. myscrlbar.Text = "New HScrollBar";
  298. Assert.AreEqual ("MonoTests.System.Windows.Forms.MyScrollBar, Minimum: 0, Maximum: 100, Value: 0",
  299. myscrlbar.ToString (), "T5");
  300. }
  301. }
  302. [TestFixture]
  303. public class ScrollBarEventTest
  304. {
  305. static bool eventhandled = false;
  306. public void ScrollBar_EventHandler (object sender,EventArgs e)
  307. {
  308. eventhandled = true;
  309. }
  310. public void ScrollBarMouse_EventHandler (object sender,MouseEventArgs e)
  311. {
  312. eventhandled = true;
  313. }
  314. public void ScrollBarScroll_EventHandler (object sender,ScrollEventArgs e)
  315. {
  316. eventhandled = true;
  317. }
  318. public void ScrollBarPaint_EventHandler (object sender,PaintEventArgs e)
  319. {
  320. eventhandled = true;
  321. }
  322. [Test]
  323. public void BackColorChangedTest ()
  324. {
  325. Form myform = new Form ();
  326. myform.Visible = true;
  327. ScrollBar myHscrlbar = new HScrollBar ();
  328. myform.Controls.Add (myHscrlbar);
  329. myHscrlbar.BackColorChanged += new EventHandler (ScrollBar_EventHandler);
  330. myHscrlbar.BackColor = Color.Red;
  331. Assert.AreEqual (true, eventhandled, "B4");
  332. eventhandled = false;
  333. myform.Dispose ();
  334. }
  335. [Test]
  336. public void BackgroundImageChangedTest ()
  337. {
  338. Form myform = new Form ();
  339. myform.Visible = true;
  340. ScrollBar myHscrlbar = new HScrollBar ();
  341. myform.Controls.Add (myHscrlbar);
  342. myHscrlbar.BackgroundImageChanged += new EventHandler (ScrollBar_EventHandler);
  343. myHscrlbar.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
  344. Assert.AreEqual (true, eventhandled, "B5");
  345. eventhandled = false;
  346. myform.Dispose ();
  347. }
  348. [Test]
  349. public void FontChangedTest ()
  350. {
  351. Form myform = new Form ();
  352. myform.Visible = true;
  353. ScrollBar myHscrlbar = new HScrollBar ();
  354. myform.Controls.Add (myHscrlbar);
  355. myHscrlbar.Font = new Font (FontFamily.GenericMonospace, 10);
  356. myHscrlbar.FontChanged += new EventHandler (ScrollBar_EventHandler);
  357. FontDialog myFontDialog = new FontDialog();
  358. myHscrlbar.Font = myFontDialog.Font;
  359. Assert.AreEqual (true, eventhandled, "F2");
  360. eventhandled = false;
  361. myform.Dispose ();
  362. }
  363. [Test]
  364. public void ForeColorChangedTest ()
  365. {
  366. Form myform = new Form ();
  367. myform.Visible = true;
  368. ScrollBar myHscrlbar = new HScrollBar ();
  369. myform.Controls.Add (myHscrlbar);
  370. myHscrlbar.ForeColorChanged += new EventHandler (ScrollBar_EventHandler);
  371. myHscrlbar.ForeColor = Color.Azure;
  372. Assert.AreEqual (true, eventhandled, "F3");
  373. eventhandled = false;
  374. myform.Dispose ();
  375. }
  376. [Test]
  377. public void ImeModehangedTest ()
  378. {
  379. Form myform = new Form ();
  380. myform.Visible = true;
  381. ScrollBar myHscrlbar = new HScrollBar ();
  382. myform.Controls.Add (myHscrlbar);
  383. myHscrlbar.ImeModeChanged += new EventHandler (ScrollBar_EventHandler);
  384. myHscrlbar.ImeMode = ImeMode.Katakana;
  385. Assert.AreEqual (true, eventhandled, "I2");
  386. eventhandled = false;
  387. myform.Dispose ();
  388. }
  389. [Test]
  390. public void MouseDownTest ()
  391. {
  392. Form myform = new Form ();
  393. myform.Visible = true;
  394. MyScrollBar myHscrlbar = new MyScrollBar ();
  395. myform.Controls.Add (myHscrlbar);
  396. myHscrlbar.MouseDown += new MouseEventHandler (ScrollBarMouse_EventHandler);
  397. myHscrlbar.MouseRightDown ();
  398. Assert.AreEqual (true, eventhandled, "M5");
  399. eventhandled = false;
  400. myform.Dispose ();
  401. }
  402. [Test]
  403. public void MouseMoveTest ()
  404. {
  405. Form myform = new Form ();
  406. myform.Visible = true;
  407. MyScrollBar myHscrlbar = new MyScrollBar ();
  408. myform.Controls.Add (myHscrlbar);
  409. myHscrlbar.MouseMove += new MouseEventHandler (ScrollBarMouse_EventHandler);
  410. myHscrlbar.MoveMouse ();
  411. Assert.AreEqual (true, eventhandled, "M6");
  412. eventhandled = false;
  413. myform.Dispose ();
  414. }
  415. [Test]
  416. public void MouseUpTest ()
  417. {
  418. Form myform = new Form ();
  419. myform.Visible = true;
  420. MyScrollBar myHscrlbar = new MyScrollBar ();
  421. myform.Controls.Add (myHscrlbar);
  422. myHscrlbar.MouseUp += new MouseEventHandler (ScrollBarMouse_EventHandler);
  423. myHscrlbar.MouseRightUp ();
  424. Assert.AreEqual (true, eventhandled, "M7");
  425. eventhandled = false;
  426. myform.Dispose ();
  427. }
  428. [Test]
  429. [Category ("NotWorking")]
  430. public void ScrollTest ()
  431. {
  432. Form myform = new Form ();
  433. myform.Visible = true;
  434. MyScrollBar myHscrlbar = new MyScrollBar ();
  435. myform.Controls.Add (myHscrlbar);
  436. myHscrlbar.Scroll += new ScrollEventHandler (ScrollBarScroll_EventHandler);
  437. myHscrlbar.ScrollNow ();
  438. Assert.AreEqual (true, eventhandled, "S4");
  439. eventhandled = false;
  440. myform.Dispose ();
  441. }
  442. [Test]
  443. public void TextChangedTest ()
  444. {
  445. Form myform = new Form ();
  446. myform.Visible = true;
  447. MyScrollBar myHscrlbar = new MyScrollBar ();
  448. myform.Controls.Add (myHscrlbar);
  449. myHscrlbar.TextChanged += new EventHandler (ScrollBar_EventHandler);
  450. myHscrlbar.Text = "foo";
  451. Assert.AreEqual (true, eventhandled, "T6");
  452. eventhandled = false;
  453. myform.Dispose ();
  454. }
  455. [Test]
  456. public void ValueChangeTest ()
  457. {
  458. Form myform = new Form ();
  459. myform.Visible = true;
  460. MyScrollBar myHscrlbar = new MyScrollBar ();
  461. myform.Controls.Add (myHscrlbar);
  462. myHscrlbar.Value = 40 ;
  463. myHscrlbar.ValueChanged += new EventHandler (ScrollBar_EventHandler);
  464. myHscrlbar.Value = 50 ;
  465. Assert.AreEqual (true, eventhandled, "V3");
  466. eventhandled = false;
  467. myform.Dispose ();
  468. }
  469. }
  470. public class MyHScrollBar : HScrollBar
  471. {
  472. public MyHScrollBar () : base ()
  473. {
  474. }
  475. public Size MyDefaultSize {
  476. get { return DefaultSize; }
  477. }
  478. public CreateParams MyCreateParams {
  479. get { return CreateParams; }
  480. }
  481. }
  482. [TestFixture]
  483. public class MyHScrollBarTest
  484. {
  485. [Test]
  486. public void ProtectedTest ()
  487. {
  488. MyHScrollBar msbar = new MyHScrollBar ();
  489. Assert.AreEqual (80, msbar.MyDefaultSize.Width, "D1");
  490. // this is environment dependent.
  491. //Assert.AreEqual (21, msbar.MyDefaultSize.Height, "D2");
  492. }
  493. }
  494. public class MyVScrollBar : VScrollBar
  495. {
  496. public MyVScrollBar () : base ()
  497. {
  498. }
  499. public Size MyDefaultSize {
  500. get { return DefaultSize; }
  501. }
  502. public CreateParams MyCreateParams {
  503. get { return CreateParams; }
  504. }
  505. }
  506. [TestFixture]
  507. public class MyVScrollBarTest
  508. {
  509. [Test]
  510. public void PubMethodTest ()
  511. {
  512. MyVScrollBar msbar = new MyVScrollBar ();
  513. Assert.AreEqual (RightToLeft.No, msbar.RightToLeft, "R1");
  514. }
  515. [Test]
  516. public void ProtMethodTest ()
  517. {
  518. MyVScrollBar msbar = new MyVScrollBar ();
  519. // This is environment dependent.
  520. //Assert.AreEqual (21, msbar.MyDefaultSize.Width, "D3");
  521. Assert.AreEqual (80, msbar.MyDefaultSize.Height, "D4");
  522. }
  523. }
  524. [TestFixture]
  525. [Ignore("Tests too strict")]
  526. public class HScrollBarTestEventsOrder
  527. {
  528. public string [] ArrayListToString (ArrayList arrlist)
  529. {
  530. string [] retval = new string [arrlist.Count];
  531. for (int i = 0; i < arrlist.Count; i++)
  532. retval[i] = (string)arrlist[i];
  533. return retval;
  534. }
  535. [Test]
  536. public void CreateEventsOrder ()
  537. {
  538. string[] EventsWanted = {
  539. "OnHandleCreated",
  540. "OnBindingContextChanged",
  541. "OnBindingContextChanged"
  542. };
  543. Form myform = new Form ();
  544. myform.Visible = true;
  545. MyScrollBar s = new MyScrollBar ();
  546. myform.Controls.Add (s);
  547. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  548. myform.Dispose ();
  549. }
  550. [Test]
  551. public void BackColorChangedEventsOrder ()
  552. {
  553. string[] EventsWanted = {
  554. "OnHandleCreated",
  555. "OnBindingContextChanged",
  556. "OnBindingContextChanged",
  557. "OnBackColorChanged",
  558. "OnInvalidated"
  559. };
  560. Form myform = new Form ();
  561. myform.Visible = true;
  562. MyScrollBar s = new MyScrollBar ();
  563. myform.Controls.Add (s);
  564. s.BackColor = Color.Aqua;
  565. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  566. myform.Dispose ();
  567. }
  568. [Test]
  569. public void BackgroundImageChangedEventsOrder ()
  570. {
  571. string[] EventsWanted = {
  572. "OnHandleCreated",
  573. "OnBindingContextChanged",
  574. "OnBindingContextChanged",
  575. "OnBackgroundImageChanged",
  576. "OnInvalidated"
  577. };
  578. Form myform = new Form ();
  579. myform.Visible = true;
  580. MyScrollBar s = new MyScrollBar ();
  581. myform.Controls.Add (s);
  582. s.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
  583. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  584. myform.Dispose ();
  585. }
  586. [Test, Ignore ("Need to send proper Click / DoubleClick")]
  587. public void ClickEventsOrder ()
  588. {
  589. string[] EventsWanted = {
  590. "OnHandleCreated",
  591. "OnBindingContextChanged",
  592. "OnBindingContextChanged"
  593. };
  594. Form myform = new Form ();
  595. myform.Visible = true;
  596. MyScrollBar s = new MyScrollBar ();
  597. myform.Controls.Add (s);
  598. s.MouseClick ();
  599. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  600. myform.Dispose ();
  601. }
  602. [Test, Ignore ("Need to send proper Click / DoubleClick")]
  603. public void DoubleClickEventsOrder ()
  604. {
  605. string[] EventsWanted = {
  606. "OnHandleCreated",
  607. "OnBindingContextChanged",
  608. "OnBindingContextChanged"
  609. };
  610. Form myform = new Form ();
  611. myform.Visible = true;
  612. MyScrollBar s = new MyScrollBar ();
  613. myform.Controls.Add (s);
  614. s.MouseDoubleClick ();
  615. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  616. myform.Dispose ();
  617. }
  618. [Test]
  619. public void FontChangedEventsOrder ()
  620. {
  621. string[] EventsWanted = {
  622. "OnHandleCreated",
  623. "OnBindingContextChanged",
  624. "OnBindingContextChanged"
  625. };
  626. Form myform = new Form ();
  627. myform.Visible = true;
  628. MyScrollBar s = new MyScrollBar ();
  629. myform.Controls.Add (s);
  630. FontDialog myFontDialog = new FontDialog();
  631. s.Font = myFontDialog.Font;
  632. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  633. myform.Dispose ();
  634. }
  635. [Test]
  636. public void ForeColorChangedEventsOrder ()
  637. {
  638. string[] EventsWanted = {
  639. "OnHandleCreated",
  640. "OnBindingContextChanged",
  641. "OnBindingContextChanged",
  642. "OnForeColorChanged",
  643. "OnInvalidated"
  644. };
  645. Form myform = new Form ();
  646. myform.Visible = true;
  647. MyScrollBar s = new MyScrollBar ();
  648. myform.Controls.Add (s);
  649. s.ForeColor = Color.Aqua;
  650. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  651. myform.Dispose ();
  652. }
  653. [Test]
  654. public void ImeModeChangedChangedEventsOrder ()
  655. {
  656. string[] EventsWanted = {
  657. "OnHandleCreated",
  658. "OnBindingContextChanged",
  659. "OnBindingContextChanged",
  660. "OnImeModeChanged"
  661. };
  662. Form myform = new Form ();
  663. myform.Visible = true;
  664. MyScrollBar s = new MyScrollBar ();
  665. myform.Controls.Add (s);
  666. s.ImeMode = ImeMode.Katakana;
  667. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  668. myform.Dispose ();
  669. }
  670. [Test]
  671. public void MouseDownEventsOrder ()
  672. {
  673. string[] EventsWanted = {
  674. "OnHandleCreated",
  675. "OnBindingContextChanged",
  676. "OnBindingContextChanged",
  677. "OnMouseDown"
  678. };
  679. Form myform = new Form ();
  680. myform.Visible = true;
  681. MyScrollBar s = new MyScrollBar ();
  682. myform.Controls.Add (s);
  683. s.MouseRightDown ();
  684. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  685. myform.Dispose ();
  686. }
  687. [Test]
  688. public void MouseMoveEventsOrder ()
  689. {
  690. string[] EventsWanted = {
  691. "OnHandleCreated",
  692. "OnBindingContextChanged",
  693. "OnBindingContextChanged",
  694. "OnMouseMove",
  695. "OnMouseHover"
  696. };
  697. Form myform = new Form ();
  698. myform.Visible = true;
  699. MyScrollBar s = new MyScrollBar ();
  700. myform.Controls.Add (s);
  701. s.MoveMouse ();
  702. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  703. myform.Dispose ();
  704. }
  705. [Test]
  706. public void MouseUpEventsOrder ()
  707. {
  708. string[] EventsWanted = {
  709. "OnHandleCreated",
  710. "OnBindingContextChanged",
  711. "OnBindingContextChanged",
  712. "OnMouseUp"
  713. };
  714. Form myform = new Form ();
  715. myform.Visible = true;
  716. MyScrollBar s = new MyScrollBar ();
  717. myform.Controls.Add (s);
  718. s.MouseRightUp ();
  719. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  720. myform.Dispose ();
  721. }
  722. [Test]
  723. public void PaintEventsOrder ()
  724. {
  725. string[] EventsWanted = {
  726. "OnHandleCreated",
  727. "OnBindingContextChanged",
  728. "OnBindingContextChanged",
  729. "OnInvalidated"
  730. };
  731. Form myform = new Form ();
  732. myform.Visible = true;
  733. MyScrollBar s = new MyScrollBar ();
  734. myform.Controls.Add (s);
  735. s.Visible = true;
  736. s.Refresh ();
  737. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  738. myform.Dispose ();
  739. }
  740. [Test]
  741. public void ScrollEventsOrder ()
  742. {
  743. string[] EventsWanted = {
  744. "OnHandleCreated",
  745. "OnBindingContextChanged",
  746. "OnBindingContextChanged",
  747. "OnScroll",
  748. "OnValueChanged"
  749. };
  750. Form myform = new Form ();
  751. myform.Visible = true;
  752. MyScrollBar s = new MyScrollBar ();
  753. myform.Controls.Add (s);
  754. s.ScrollNow ();
  755. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  756. myform.Dispose ();
  757. }
  758. [Test]
  759. public void TextChangedEventsOrder ()
  760. {
  761. string[] EventsWanted = {
  762. "OnHandleCreated",
  763. "OnBindingContextChanged",
  764. "OnBindingContextChanged",
  765. "OnTextChanged"
  766. };
  767. Form myform = new Form ();
  768. myform.Visible = true;
  769. MyScrollBar s = new MyScrollBar ();
  770. myform.Controls.Add (s);
  771. s.Text = "foobar";
  772. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  773. myform.Dispose ();
  774. }
  775. [Test]
  776. public void ValueChangedEventsOrder ()
  777. {
  778. string[] EventsWanted = {
  779. "OnHandleCreated",
  780. "OnBindingContextChanged",
  781. "OnBindingContextChanged",
  782. "OnValueChanged"
  783. };
  784. Form myform = new Form ();
  785. myform.Visible = true;
  786. MyScrollBar s = new MyScrollBar ();
  787. myform.Controls.Add (s);
  788. s.Value = 10;
  789. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  790. myform.Dispose ();
  791. }
  792. }
  793. public class MyScrollBar2 : HScrollBar
  794. {
  795. protected ArrayList results = new ArrayList ();
  796. public MyScrollBar2 () : base ()
  797. {
  798. this.HandleCreated += new EventHandler (HandleCreated_Handler);
  799. this.BackColorChanged += new EventHandler (BackColorChanged_Handler);
  800. this.BackgroundImageChanged += new EventHandler (BackgroundImageChanged_Handler);
  801. this.BindingContextChanged += new EventHandler (BindingContextChanged_Handler);
  802. this.Click += new EventHandler (Click_Handler);
  803. this.DoubleClick += new EventHandler (DoubleClick_Handler);
  804. this.FontChanged += new EventHandler (FontChanged_Handler);
  805. this.ForeColorChanged += new EventHandler (ForeColorChanged_Handler);
  806. this.ImeModeChanged += new EventHandler (ImeModeChanged_Handler);
  807. this.MouseDown += new MouseEventHandler (MouseDown_Handler);
  808. this.MouseMove += new MouseEventHandler (MouseMove_Handler);
  809. this.MouseUp += new MouseEventHandler (MouseUp_Handler);
  810. this.Invalidated += new InvalidateEventHandler (Invalidated_Handler);
  811. this.Resize += new EventHandler (Resize_Handler);
  812. this.SizeChanged += new EventHandler (SizeChanged_Handler);
  813. this.Layout += new LayoutEventHandler (Layout_Handler);
  814. this.VisibleChanged += new EventHandler (VisibleChanged_Handler);
  815. this.Paint += new PaintEventHandler (Paint_Handler);
  816. this.Scroll += new ScrollEventHandler (Scroll_Handler);
  817. this.TextChanged += new EventHandler (TextChanged_Handler);
  818. this.ValueChanged += new EventHandler (ValueChanged_Handler);
  819. }
  820. protected void HandleCreated_Handler (object sender, EventArgs e)
  821. {
  822. results.Add ("HandleCreated");
  823. }
  824. protected void BackColorChanged_Handler (object sender, EventArgs e)
  825. {
  826. results.Add ("BackColorChanged");
  827. }
  828. protected void BackgroundImageChanged_Handler (object sender, EventArgs e)
  829. {
  830. results.Add ("BackgroundImageChanged");
  831. }
  832. protected void Click_Handler (object sender, EventArgs e)
  833. {
  834. results.Add ("Click");
  835. }
  836. protected void DoubleClick_Handler (object sender, EventArgs e)
  837. {
  838. results.Add ("DoubleClick");
  839. }
  840. protected void FontChanged_Handler (object sender, EventArgs e)
  841. {
  842. results.Add ("FontChanged");
  843. }
  844. protected void ForeColorChanged_Handler (object sender, EventArgs e)
  845. {
  846. results.Add ("ForeColorChanged");
  847. }
  848. protected void ImeModeChanged_Handler (object sender, EventArgs e)
  849. {
  850. results.Add ("ImeModeChanged");
  851. }
  852. protected void MouseDown_Handler (object sender, MouseEventArgs e)
  853. {
  854. results.Add ("MouseDown");
  855. }
  856. protected void MouseMove_Handler (object sender, MouseEventArgs e)
  857. {
  858. results.Add ("MouseMove");
  859. }
  860. protected void MouseUp_Handler (object sender, MouseEventArgs e)
  861. {
  862. results.Add ("MouseUp");
  863. }
  864. protected void BindingContextChanged_Handler (object sender, EventArgs e)
  865. {
  866. results.Add ("BindingContextChanged");
  867. }
  868. protected void Invalidated_Handler (object sender, InvalidateEventArgs e)
  869. {
  870. results.Add("Invalidated");
  871. }
  872. protected void Resize_Handler (object sender, EventArgs e)
  873. {
  874. results.Add("Resize");
  875. }
  876. protected void SizeChanged_Handler (object sender, EventArgs e)
  877. {
  878. results.Add("SizeChanged");
  879. }
  880. protected void Layout_Handler (object sender, LayoutEventArgs e)
  881. {
  882. results.Add("Layout");
  883. }
  884. protected void VisibleChanged_Handler (object sender, EventArgs e)
  885. {
  886. results.Add("VisibleChanged");
  887. }
  888. protected void Paint_Handler (object sender, PaintEventArgs e)
  889. {
  890. results.Add("Paint");
  891. }
  892. protected void Scroll_Handler (object sender, ScrollEventArgs e)
  893. {
  894. results.Add ("Scroll");
  895. }
  896. protected void TextChanged_Handler (object sender, EventArgs e)
  897. {
  898. results.Add ("TextChanged");
  899. }
  900. protected void ValueChanged_Handler (object sender, EventArgs e)
  901. {
  902. results.Add ("ValueChanged");
  903. }
  904. public ArrayList Results {
  905. get { return results; }
  906. }
  907. public void MoveMouse ()
  908. {
  909. Message m;
  910. m = new Message ();
  911. m.Msg = (int)WndMsg.WM_NCHITTEST;
  912. m.HWnd = this.Handle;
  913. m.WParam = (IntPtr)0x0;
  914. m.LParam = (IntPtr)0x1c604ea;
  915. this.WndProc(ref m);
  916. m.Msg = (int)WndMsg.WM_SETCURSOR;
  917. m.HWnd = this.Handle;
  918. m.WParam = (IntPtr)0x100448;
  919. m.LParam = (IntPtr)0x2000001;
  920. this.WndProc(ref m);
  921. m.Msg = (int)WndMsg.WM_MOUSEFIRST;
  922. m.HWnd = this.Handle;
  923. m.WParam = (IntPtr)0x0;
  924. m.LParam = (IntPtr)0x14000b;
  925. this.WndProc(ref m);
  926. m.Msg = (int)WndMsg.WM_MOUSEHOVER;
  927. m.HWnd = this.Handle;
  928. m.WParam = (IntPtr)0x0;
  929. m.LParam = (IntPtr)0x14000b;
  930. this.WndProc(ref m);
  931. }
  932. public void MouseRightDown()
  933. {
  934. Message m;
  935. m = new Message();
  936. m.Msg = (int)WndMsg.WM_RBUTTONDOWN;
  937. m.HWnd = this.Handle;
  938. m.WParam = (IntPtr)0x01;
  939. m.LParam = (IntPtr)0x9004f;
  940. this.WndProc(ref m);
  941. }
  942. public void MouseClick()
  943. {
  944. Message m;
  945. m = new Message();
  946. m.Msg = (int)WndMsg.WM_LBUTTONDOWN;
  947. m.HWnd = this.Handle;
  948. m.WParam = (IntPtr)0x01;
  949. m.LParam = (IntPtr)0x9004f;
  950. this.WndProc(ref m);
  951. m = new Message();
  952. m.Msg = (int)WndMsg.WM_LBUTTONUP;
  953. m.HWnd = this.Handle;
  954. m.WParam = (IntPtr)0x01;
  955. m.LParam = (IntPtr)0x9004f;
  956. this.WndProc(ref m);
  957. }
  958. public void MouseDoubleClick ()
  959. {
  960. MouseClick ();
  961. MouseClick ();
  962. }
  963. public void MouseRightUp()
  964. {
  965. Message m;
  966. m = new Message();
  967. m.Msg = (int)WndMsg.WM_RBUTTONUP;
  968. m.HWnd = this.Handle;
  969. m.WParam = (IntPtr)0x01;
  970. m.LParam = (IntPtr)0x9004f;
  971. this.WndProc(ref m);
  972. }
  973. public void ScrollNow ()
  974. {
  975. Message m;
  976. m = new Message ();
  977. m.Msg = 8468;
  978. m.HWnd = this.Handle;
  979. m.WParam = (IntPtr)0x1;
  980. m.LParam = (IntPtr)0x1a051a;
  981. this.WndProc(ref m);
  982. m.Msg = 233;
  983. m.HWnd = this.Handle;
  984. m.WParam = (IntPtr)0x1;
  985. m.LParam = (IntPtr)0x12eb34;
  986. this.WndProc(ref m);
  987. }
  988. }
  989. [TestFixture]
  990. [Ignore("Tests too strict")]
  991. public class HScrollBarTestEventsOrder2
  992. {
  993. public string [] ArrayListToString (ArrayList arrlist)
  994. {
  995. string [] retval = new string [arrlist.Count];
  996. for (int i = 0; i < arrlist.Count; i++)
  997. retval[i] = (string)arrlist[i];
  998. return retval;
  999. }
  1000. [Test]
  1001. public void CreateEventsOrder ()
  1002. {
  1003. string[] EventsWanted = {
  1004. "HandleCreated",
  1005. "BindingContextChanged",
  1006. "BindingContextChanged"
  1007. };
  1008. Form myform = new Form ();
  1009. myform.Visible = true;
  1010. MyScrollBar2 s = new MyScrollBar2 ();
  1011. myform.Controls.Add (s);
  1012. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  1013. myform.Dispose ();
  1014. }
  1015. [Test]
  1016. public void BackColorChangedEventsOrder ()
  1017. {
  1018. string[] EventsWanted = {
  1019. "HandleCreated",
  1020. "BindingContextChanged",
  1021. "BindingContextChanged",
  1022. "Invalidated",
  1023. "BackColorChanged"
  1024. };
  1025. Form myform = new Form ();
  1026. myform.Visible = true;
  1027. MyScrollBar2 s = new MyScrollBar2 ();
  1028. myform.Controls.Add (s);
  1029. s.BackColor = Color.Aqua;
  1030. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  1031. myform.Dispose ();
  1032. }
  1033. [Test]
  1034. public void BackgroundImageChangedEventsOrder ()
  1035. {
  1036. string[] EventsWanted = {
  1037. "HandleCreated",
  1038. "BindingContextChanged",
  1039. "BindingContextChanged",
  1040. "Invalidated",
  1041. "BackgroundImageChanged"
  1042. };
  1043. Form myform = new Form ();
  1044. myform.Visible = true;
  1045. MyScrollBar2 s = new MyScrollBar2 ();
  1046. myform.Controls.Add (s);
  1047. s.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
  1048. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  1049. myform.Dispose ();
  1050. }
  1051. [Test, Ignore ("Need to send proper Click / DoubleClick")]
  1052. public void ClickEventsOrder ()
  1053. {
  1054. string[] EventsWanted = {
  1055. "HandleCreated",
  1056. "BindingContextChanged",
  1057. "BindingContextChanged"
  1058. };
  1059. Form myform = new Form ();
  1060. myform.Visible = true;
  1061. MyScrollBar2 s = new MyScrollBar2 ();
  1062. myform.Controls.Add (s);
  1063. s.MouseClick ();
  1064. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  1065. myform.Dispose ();
  1066. }
  1067. [Test, Ignore ("Need to send proper Click / DoubleClick")]
  1068. public void DoubleClickEventsOrder ()
  1069. {
  1070. string[] EventsWanted = {
  1071. "HandleCreated",
  1072. "BindingContextChanged",
  1073. "BindingContextChanged"
  1074. };
  1075. Form myform = new Form ();
  1076. myform.Visible = true;
  1077. MyScrollBar2 s = new MyScrollBar2 ();
  1078. myform.Controls.Add (s);
  1079. s.MouseDoubleClick ();
  1080. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  1081. myform.Dispose ();
  1082. }
  1083. [Test]
  1084. public void FontChangedEventsOrder ()
  1085. {
  1086. string[] EventsWanted = {
  1087. "HandleCreated",
  1088. "BindingContextChanged",
  1089. "BindingContextChanged"
  1090. };
  1091. Form myform = new Form ();
  1092. myform.Visible = true;
  1093. MyScrollBar2 s = new MyScrollBar2 ();
  1094. myform.Controls.Add (s);
  1095. FontDialog myFontDialog = new FontDialog();
  1096. s.Font = myFontDialog.Font;
  1097. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  1098. myform.Dispose ();
  1099. }
  1100. [Test]
  1101. public void ForeColorChangedEventsOrder ()
  1102. {
  1103. string[] EventsWanted = {
  1104. "HandleCreated",
  1105. "BindingContextChanged",
  1106. "BindingContextChanged",
  1107. "Invalidated",
  1108. "ForeColorChanged"
  1109. };
  1110. Form myform = new Form ();
  1111. myform.Visible = true;
  1112. MyScrollBar2 s = new MyScrollBar2 ();
  1113. myform.Controls.Add (s);
  1114. s.ForeColor = Color.Aqua;
  1115. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  1116. myform.Dispose ();
  1117. }
  1118. [Test]
  1119. public void ImeModeChangedChangedEventsOrder ()
  1120. {
  1121. string[] EventsWanted = {
  1122. "HandleCreated",
  1123. "BindingContextChanged",
  1124. "BindingContextChanged",
  1125. "ImeModeChanged"
  1126. };
  1127. Form myform = new Form ();
  1128. myform.Visible = true;
  1129. MyScrollBar2 s = new MyScrollBar2 ();
  1130. myform.Controls.Add (s);
  1131. s.ImeMode = ImeMode.Katakana;
  1132. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  1133. myform.Dispose ();
  1134. }
  1135. [Test]
  1136. public void MouseDownEventsOrder ()
  1137. {
  1138. string[] EventsWanted = {
  1139. "HandleCreated",
  1140. "BindingContextChanged",
  1141. "BindingContextChanged",
  1142. "MouseDown"
  1143. };
  1144. Form myform = new Form ();
  1145. myform.Visible = true;
  1146. MyScrollBar2 s = new MyScrollBar2 ();
  1147. myform.Controls.Add (s);
  1148. s.MouseRightDown ();
  1149. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  1150. myform.Dispose ();
  1151. }
  1152. [Test]
  1153. public void MouseMoveEventsOrder ()
  1154. {
  1155. string[] EventsWanted = {
  1156. "HandleCreated",
  1157. "BindingContextChanged",
  1158. "BindingContextChanged",
  1159. "MouseMove"
  1160. };
  1161. Form myform = new Form ();
  1162. myform.Visible = true;
  1163. MyScrollBar2 s = new MyScrollBar2 ();
  1164. myform.Controls.Add (s);
  1165. s.MoveMouse ();
  1166. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  1167. myform.Dispose ();
  1168. }
  1169. [Test]
  1170. public void MouseUpEventsOrder ()
  1171. {
  1172. string[] EventsWanted = {
  1173. "HandleCreated",
  1174. "BindingContextChanged",
  1175. "BindingContextChanged",
  1176. "MouseUp"
  1177. };
  1178. Form myform = new Form ();
  1179. myform.Visible = true;
  1180. MyScrollBar2 s = new MyScrollBar2 ();
  1181. myform.Controls.Add (s);
  1182. s.MouseRightUp ();
  1183. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  1184. myform.Dispose ();
  1185. }
  1186. [Test]
  1187. public void PaintEventsOrder ()
  1188. {
  1189. string[] EventsWanted = {
  1190. "HandleCreated",
  1191. "BindingContextChanged",
  1192. "BindingContextChanged",
  1193. "Invalidated"
  1194. };
  1195. Form myform = new Form ();
  1196. myform.Visible = true;
  1197. MyScrollBar2 s = new MyScrollBar2 ();
  1198. myform.Controls.Add (s);
  1199. s.Visible = true;
  1200. s.Refresh ();
  1201. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  1202. myform.Dispose ();
  1203. }
  1204. [Test]
  1205. public void ScrollEventsOrder ()
  1206. {
  1207. string[] EventsWanted = {
  1208. "HandleCreated",
  1209. "BindingContextChanged",
  1210. "BindingContextChanged",
  1211. "Scroll",
  1212. "ValueChanged"
  1213. };
  1214. Form myform = new Form ();
  1215. myform.Visible = true;
  1216. MyScrollBar2 s = new MyScrollBar2 ();
  1217. myform.Controls.Add (s);
  1218. s.ScrollNow ();
  1219. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  1220. myform.Dispose ();
  1221. }
  1222. [Test]
  1223. public void TextChangedEventsOrder ()
  1224. {
  1225. string[] EventsWanted = {
  1226. "HandleCreated",
  1227. "BindingContextChanged",
  1228. "BindingContextChanged",
  1229. "TextChanged"
  1230. };
  1231. Form myform = new Form ();
  1232. myform.Visible = true;
  1233. MyScrollBar2 s = new MyScrollBar2 ();
  1234. myform.Controls.Add (s);
  1235. s.Text = "foobar";
  1236. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  1237. myform.Dispose ();
  1238. }
  1239. [Test]
  1240. public void ValueChangedEventsOrder ()
  1241. {
  1242. string[] EventsWanted = {
  1243. "HandleCreated",
  1244. "BindingContextChanged",
  1245. "BindingContextChanged",
  1246. "ValueChanged"
  1247. };
  1248. Form myform = new Form ();
  1249. myform.Visible = true;
  1250. MyScrollBar2 s = new MyScrollBar2 ();
  1251. myform.Controls.Add (s);
  1252. s.Value = 10;
  1253. Assert.AreEqual (EventsWanted, ArrayListToString (s.Results));
  1254. myform.Dispose ();
  1255. }
  1256. }
  1257. }