PageRenderTime 242ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/IronPython_Main/Languages/IronPython/Samples/tests/Puzzle/WinClass.cs

#
C# | 223 lines | 141 code | 30 blank | 52 comment | 4 complexity | 63ab85ab310729d1fb12fb0b5ed65d8b MD5 | raw file
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception, CPL-1.0, CC-BY-SA-3.0, BSD-3-Clause, ISC, AGPL-3.0, LGPL-2.1, Apache-2.0
  1. /* ****************************************************************************
  2. *
  3. * Copyright (c) Microsoft Corporation.
  4. *
  5. * This source code is subject to terms and conditions of the Apache License, Version 2.0. A
  6. * copy of the license can be found in the License.html file at the root of this distribution. If
  7. * you cannot locate the Apache License, Version 2.0, please send an email to
  8. * ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
  9. * by the terms of the Apache License, Version 2.0.
  10. *
  11. * You must not remove this notice, or any other, from this software.
  12. *
  13. *
  14. * ***************************************************************************/
  15. using System;
  16. using System.Collections.Generic;
  17. using System.Text;
  18. using MS.Internal.Mita.Foundation.Controls;
  19. using MS.Internal.Mita.Foundation;
  20. using MS.Internal.Mita.Foundation.Waiters;
  21. using System.Windows.Automation;
  22. using System.Threading;
  23. using System.Windows.Forms;
  24. class WinClass:Window
  25. {
  26. public WinClass(UIObject ui):base(ui)
  27. {
  28. }
  29. public void Test_about()
  30. {
  31. UICondition uICondition = UICondition.Create("@Name='about'", new Object[0]);
  32. UIObject uIObject = this.Descendants.Find(uICondition);
  33. Window obj = new Window(uIObject);
  34. UICondition uICondition2 = UICondition.Create("@Name='Tile Size'", new Object[0]);
  35. obj.Click();
  36. Thread.Sleep(300);
  37. UIObject result = this.Children.Find(uICondition2);
  38. }
  39. public void Test_options()
  40. {
  41. UICondition uICondition = UICondition.Create("@Name='options'", new Object[0]);
  42. UIObject uIObject = this.Descendants.Find(uICondition);
  43. Window obj = new Window(uIObject);
  44. UICondition uI2 = UICondition.Create("@Name='Tile Size'",new Object[0]);
  45. UICondition uI50 = UICondition.Create("@Name='50%'",new Object[0]);
  46. UICondition uI100 = UICondition.Create("@Name='100%'", new Object[0]);
  47. UICondition uI75 = UICondition.Create("@Name='75%'", new Object[0]);
  48. obj.Click();
  49. UIObject uITileSize = this.Descendants.Find(uI2);
  50. UIObject uIo75 = this.Descendants.Find(uI75);
  51. UIObject uIo100 = this.Descendants.Find(uI100);
  52. Window obj75 = new Window(uIo75);
  53. obj75.Click();
  54. Thread.Sleep(200);
  55. Window obj100 = new Window(uIo100);
  56. obj100.Click();
  57. UIObject uIo50 = this.Descendants.Find(uI50);
  58. Thread.Sleep(200);
  59. Window obj50= new Window(uIo50);
  60. obj50.Click();
  61. Thread.Sleep(200);
  62. //UICondition uICache = UICondition.Create("@Name='Allow caching'", new Object[0]);
  63. //UIObject uIoCache = this.Descendants.Find(uICache);
  64. //Window objCache = new Window(uIoCache);
  65. //objCache.Click();
  66. //Thread.Sleep(200);
  67. UICondition uIClsCa = UICondition.Create("@Name='Clear Cache'", new Object[0]);
  68. UIObject uIoClsCa = this.Descendants.Find(uIClsCa);
  69. Window objClsCa = new Window(uIoClsCa);
  70. objClsCa.Click();
  71. Thread.Sleep(200);
  72. }
  73. public void Test_load()
  74. {
  75. UICondition uICondition = UICondition.Create("@Name='load'", new Object[0]);
  76. UIObject uIObject = this.Descendants.Find(uICondition);
  77. Window obj = new Window(uIObject);
  78. obj.Click();
  79. UICondition uIButton1 = UICondition.Create("@Name='Seattle (default game)\n(327, 714)\nAerial - Zoom Level 11 - 3x3'", new Object[0]);
  80. UIObject uIoButton1 = this.Descendants.Find(uIButton1);
  81. Window objButton1 = new Window(uIoButton1);
  82. objButton1.Click();
  83. Thread.Sleep(100);
  84. UICondition uIButton2 = UICondition.Create("@Name='New York\n(1205, 1538)\nRoad - Zoom Level 12 - 3x3'", new Object[0]);
  85. UIObject uIoButton2 = this.Descendants.Find(uIButton2);
  86. Window objButton2 = new Window(uIoButton2);
  87. objButton2.Click();
  88. Thread.Sleep(100);
  89. UICondition uIButton3 = UICondition.Create("@Name='World\n(0, 0)\nHybrid - Zoom Level 2 - 4x4'", new Object[0]);
  90. UIObject uIoButton3 = this.Descendants.Find(uIButton3);
  91. Window objButton3 = new Window(uIoButton3);
  92. objButton3.Click();
  93. Thread.Sleep(100);
  94. UICondition uIButton4 = UICondition.Create("@Name='North America\n(2, 5)\nAerial - Zoom Level 4 - 3x3'", new Object[0]);
  95. UIObject uIoButton4 = this.Descendants.Find(uIButton4);
  96. Window objButton4 = new Window(uIoButton4);
  97. objButton4.Click();
  98. Thread.Sleep(100);
  99. UICondition uILoad = UICondition.Create("@Name='Load Puzzle'", new Object[0]);
  100. UIObject uIoLoad = this.Descendants.Find(uILoad);
  101. Window objLoad = new Window(uIoLoad);
  102. objLoad.Click();
  103. }
  104. public void Test_play()
  105. {
  106. UICondition uIToStart = UICondition.Create("@Name='Shuffle\nto\nStart'", new Object[0]);
  107. for (int i = 0; i < 1000; i++)
  108. {
  109. if (this.Descendants.Contains(uIToStart))
  110. {
  111. break;
  112. }
  113. Thread.Sleep(100);
  114. }
  115. UIObject uIoStart = this.Descendants.Find(uIToStart);
  116. Window objStart = new Window(uIoStart);
  117. objStart.Click();
  118. play_puzzle();
  119. }
  120. public void play_puzzle()
  121. {
  122. int i;
  123. UICollection<UIObject> UICoPane;
  124. UICondition uIpane = UICondition.Create("@ControlType=Pane", new Object[0]);
  125. UIObject uIopane = this.Children.Find(uIpane);
  126. //UICondition uIpane = UICondition.Create("@ControlType=ControlType.Pane", new Object[0]);
  127. UICoPane = uIopane.Children.FindMultiple(uIpane);
  128. int Dim = UICoPane.Count;
  129. //foreach (UIObject i in UICoPane)
  130. //{
  131. // Window objpuzzle = new Window(i);
  132. // objpuzzle.Click();
  133. //}
  134. for(int aa = 0; aa < 40; aa++)
  135. {
  136. Random rand = new Random(Environment.TickCount);
  137. i = rand.Next(Dim);
  138. //Console.Write(i.ToString()+" : ");
  139. //Console.WriteLine(UICoPane.Count.ToString()+" : "+aa.ToString());
  140. Window objpuzzle = new Window(UICoPane[i]);
  141. objpuzzle.Click();
  142. Thread.Sleep(200);
  143. }
  144. }
  145. public void Test_exit()
  146. {
  147. UICondition uICexit = UICondition.Create("@Name='exit'", new Object[0]);
  148. UIObject uIoExit = this.Descendants.Find(uICexit);
  149. Window objexit = new Window(uIoExit);
  150. //http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=27142
  151. //UIProperty u = UIProperty.Get("ClassName");
  152. //UICondition uIcondition2 = UICondition.Create(u,"#32770");
  153. //WindowOpenedWaiter wait2 = new WindowOpenedWaiter(uIcondition2);
  154. //objexit.Click();
  155. //wait2.Wait(5000);
  156. //UIObject ui2 = this.Children.Find(uIcondition2);
  157. //UIObject uiyes = ui2.Children.Find(UICondition.Create("@Name='Yes'", new Object[0]));
  158. //Window winyes = new Window(uiyes);
  159. //Thread.Sleep(1000);
  160. //winyes.Click();
  161. }
  162. public void Test_create()
  163. {
  164. UICondition uICcreate = UICondition.Create("@Name='create'", new Object[0]);
  165. UIObject uIoCreate = this.Descendants.Find(uICcreate);
  166. Window objcreate = new Window(uIoCreate);
  167. objcreate.Click();
  168. UICondition uI3x3 = UICondition.Create("@Name='3x3'", new Object[0]);
  169. UIObject uIo3x3 = this.Descendants.Find(uI3x3);
  170. UICondition uI4x4 = UICondition.Create("@Name='4x4'", new Object[0]);
  171. UIObject uIo4x4 = this.Descendants.Find(uI4x4);
  172. MS.Internal.Mita.Foundation.Controls.RadioButton radioButton3 = new MS.Internal.Mita.Foundation.Controls.RadioButton(uIo3x3);
  173. MS.Internal.Mita.Foundation.Controls.RadioButton radioButton4 = new MS.Internal.Mita.Foundation.Controls.RadioButton(uIo4x4);
  174. if (radioButton3.IsSelected)
  175. {
  176. radioButton4.Select();
  177. }
  178. //http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=27142
  179. //UICondition uICcreate2 = UICondition.Create("@Name='Create'", new Object[0]);
  180. //UIObject uIoCreate2 = this.Descendants.Find(uICcreate2);
  181. //Window objcreate2 = new Window(uIoCreate2);
  182. //UIProperty u = UIProperty.Get("ClassName");
  183. //UICondition uIcondition2 = UICondition.Create(u, "#32770");
  184. //WindowOpenedWaiter wait2 = new WindowOpenedWaiter(uIcondition2);
  185. //objcreate2.Click();
  186. //wait2.Wait(5000);
  187. //UIObject ui2 = this.Children.Find(uIcondition2);
  188. //UIObject uiyes = ui2.Children.Find(UICondition.Create("@Name='Yes'", new Object[0]));
  189. //Window winyes = new Window(uiyes);
  190. //Thread.Sleep(300);
  191. //winyes.Click();
  192. }
  193. }