示例#1
0
        /// <summary>
        /// Specify which control or form we should use for the relative position.
        /// </summary>
        /// <param name="control">
        ///   A <see cref="ControlTester"/>.
        /// </param>
        public void UseOn(ControlTester control)
        {
            if (mouseControl == null)
            {
                Win32.Point position;
                Win32.GetCursorPos(out position);
                originalPosition = new Point(position.x, position.y);
            }

            if (control == null)
            {
                throw new ArgumentNullException("control");
            }

            mouseControl = new MouseControl(control);

            PositionUnit = GraphicsUnit.Pixel;

            // Block any user input while we are active.
            if (!restoreUserInput)
            {
                if (!Win32.BlockInput(true))
                {
                    //TODO Bart De Boeck : Waarom is dit nodig ? Zie ook in Dispose().
                    //throw new Win32Exception();
                }

                restoreUserInput = true;
            }
        }
示例#2
0
 public ControlTester(ControlTester tester, int index)
 {
     if (index < 0)
     {
         throw new Exception("Should not have index < 0");
     }
     this.index = index;
     form       = tester.form;
     formName   = tester.formName;
     name       = tester.name;
 }
示例#3
0
文件: Command.cs 项目: sillsdev/wesay
        protected ControlTester GetTester()
        {
            ControlTester tester = new ControlTester(control);

            Type testerType = (Type)testerTypes[tester.Control.GetType()];

            if (testerType == null)
            {
                return(tester);
            }

            return((ControlTester)Activator.CreateInstance(testerType, new object[] { control }));
        }
示例#4
0
        /// <summary>
        /// Initializes the KeyboardController, blocks user input, and sets
        /// the focus on the specified control.
        /// </summary>
        /// <param name="control">The ControlTester to use the keyboard on.</param>
        public void UseOn(ControlTester control)
        {
            if (control == null)
            {
                throw new ArgumentNullException("control");
            }

            keyboardControl = new KeyboardControl(control);

            if (!restoreUserInput)
            {
                //if this next line returns false, I used to throw an exception...
                Win32.BlockInput(true);
                restoreUserInput = true;
            }
        }
示例#5
0
        public override void Execute(Speed speed)
        {
            SlowDownAndPaint(speed);

            ControlTester tester = GetTester();

            try
            {
                MethodInfo methodInfo =
                    tester.GetType().GetMethod(Action,
                                               BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                methodInfo.Invoke(tester, new object[] { Args });
            }
            catch (Exception e)
            {
                throw new FormsTestAssertionException(
                          string.Format("Line Number {0} : {1} : {2}", LineNumber, e.Message, e.StackTrace));
            }

            SlowDownAndPaint(speed);
        }
示例#6
0
		/// <summary>
		/// Initializes the KeyboardController, blocks user input, and sets
		/// the focus on the specified control.
		/// </summary>
		/// <param name="control">The ControlTester to use the keyboard on.</param>
		public void UseOn(ControlTester control)
		{
			if(control == null)
			{
				throw new ArgumentNullException("control");
			}

			keyboardControl = new KeyboardControl(control);

			if(!restoreUserInput)
			{
				//if this next line returns false, I used to throw an exception...
				Win32.BlockInput(true);
				restoreUserInput = true;
			}
		}
示例#7
0
 /// <summary>
 /// Creates a ControlTester from a ControlTester and an index where the
 /// original tester's name is not unique.
 /// </summary>
 /// <remarks>
 /// It is best to use the overloaded Constructor that requires just the name 
 /// parameter if possible.
 /// </remarks>
 /// <param name="tester">The ControlTester.</param>
 /// <param name="index">The index to test.</param>
 public ListViewTester(ControlTester tester, int index)
     : base(tester, index)
 {
 }
示例#8
0
	/// <summary>
	/// Creates a ControlTester from a ControlTester and an index where the
	/// original tester's name is not unique.
	/// </summary>
	/// <remarks>
	/// It is best to use the overloaded Constructor that requires just the name
	/// parameter if possible.
	/// </remarks>
	/// <param name="tester">The ControlTester.</param>
	/// <param name="index">The index to test.</param>
	public RichTextBoxTester(ControlTester tester, int index)
	  : base(tester, index)
	{
	}
示例#9
0
		internal MouseControl(ControlTester controlTester)
		{
			this.controlTester = controlTester;
		}
示例#10
0
        ///<summary>
        /// Verifies the text of the named control matches the expected text.
        ///</summary>
        public void VerifyText(string controlName, string expectedText)
        {
            ControlTester anyControl = new ControlTester(controlName, targetForm.Properties);

            Assert.AreEqual(expectedText, anyControl.Text);
        }
示例#11
0
 /// <summary>
 /// Creates a keyboard controller and sets the focus on the control
 /// indicated by the supplied ControlTester.
 /// </summary>
 /// <param name="controlTester">The ControlTester to use the keyboard
 /// on.</param>
 public KeyboardController(ControlTester controlTester)
 {
     UseOn(controlTester);
 }
示例#12
0
 /// <summary>
 /// Creates a ControlTester from a ControlTester and an index where the
 /// original tester's name is not unique.
 /// </summary>
 /// <remarks>
 /// It is best to use the overloaded Constructor that requires just the name
 /// parameter if possible.
 /// </remarks>
 /// <param name="tester">The ControlTester.</param>
 /// <param name="index">The index to test.</param>
 public TreeViewTester(ControlTester tester, int index) : base(tester, index)
 {
 }
示例#13
0
		private void ClickStarOfLexemeForm()
		{
			ControlTester t = new ControlTester(GetNameOfLexicalFormAnnotationControl(), _window);
			t.Click();
			GetEditControl(Field.FieldNames.EntryLexicalForm.ToString());
		}
示例#14
0
		private static void PressCtrlN(ControlTester t)
		{
			using (KeyboardController kc = new KeyboardController(t))
			{
				kc.Press("^n"); // Ctrl+N
			}
		}
示例#15
0
 /// <summary>
 /// Creates a ControlTester from a ControlTester and an index where the
 /// original tester's name is not unique.
 /// </summary>
 /// <remarks>
 /// It is best to use the overloaded Constructor that requires just the name
 /// parameter if possible.
 /// </remarks>
 /// <param name="tester">The ControlTester.</param>
 /// <param name="index">The index to test.</param>
 public TabControlTester(ControlTester tester, int index) : base(tester, index)
 {
 }
示例#16
0
 /// <summary>
 /// Creates a ControlTester from a ControlTester and an index where the
 /// original tester's name is not unique.
 /// </summary>
 /// <remarks>
 /// It is best to use the overloaded Constructor that requires just the name
 /// parameter if possible.
 /// </remarks>
 /// <param name="tester">The ControlTester.</param>
 /// <param name="index">The index to test.</param>
 public ComboBoxTester(ControlTester tester, int index) : base(tester, index)
 {
 }
示例#17
0
 /// <summary>
 /// Creates a ControlTester from a ControlTester and an index where the
 /// original tester's name is not unique.
 /// </summary>
 /// <remarks>
 /// It is best to use the overloaded Constructor that requires just the name
 /// parameter if possible.
 /// </remarks>
 /// <param name="tester">The ControlTester.</param>
 /// <param name="index">The index to test.</param>
 public ToolBarTester(ControlTester tester, int index) : base(tester, index)
 {
 }
示例#18
0
		/// <summary>
		/// Creates a ControlTester from a ControlTester and an index where the
		/// original tester's name is not unique.
		/// </summary>
		/// <remarks>
		/// It is best to use the overloaded Constructor that requires just the name
		/// parameter if possible.
		/// </remarks>
		/// <param name="tester">The ControlTester.</param>
		/// <param name="index">The index to test.</param>
		public LabelTester(ControlTester tester, int index) : base(tester, index)
		{
		}
示例#19
0
 /// <summary>
 /// Creates a ControlTester from a ControlTester and an index where the
 /// original tester's name is not unique.
 /// </summary>
 /// <remarks>
 /// It is best to use the overloaded Constructor that requires just the name
 /// parameter if possible.
 /// </remarks>
 /// <param name="tester">The ControlTester.</param>
 /// <param name="index">The index to test.</param>
 public LabelTester(ControlTester tester, int index) : base(tester, index)
 {
 }
示例#20
0
		/// <summary>
		/// Creates a ControlTester from a ControlTester and an index where the
		/// original tester's name is not unique.
		/// </summary>
		/// <remarks>
		/// It is best to use the overloaded Constructor that requires just the name
		/// parameter if possible.
		/// </remarks>
		/// <param name="tester">The ControlTester.</param>
		/// <param name="index">The index to test.</param>
		public ToolBarTester(ControlTester tester, int index) : base(tester, index)
		{
		}
示例#21
0
 public CheckBoxTester(ControlTester <CheckBox, CheckBoxTester> tester, int index) : base(tester, index)
 {
 }
示例#22
0
 /// <summary>
 /// Creates a ControlTester from a ControlTester and an index where the
 /// original tester's name is not unique.
 /// </summary>
 /// <remarks>
 /// It is best to use the overloaded Constructor that requires just the name
 /// parameter if possible.
 /// </remarks>
 /// <param name="tester">The ControlTester.</param>
 /// <param name="index">The index to test.</param>
 public ButtonTester(ControlTester tester, int index) : base(tester, index)
 {
 }
示例#23
0
		/// <summary>
		///   Creates and initialises a new instance of the class for the specified <see cref="ControlTester"/>.
		/// </summary>
		/// <param name="controlTester">
		///   A <see cref="ControlTester"/>.
		/// </param>
		/// <remarks>
		///   The <see cref="Position">mouse position</see> is relative to the <see cref="Control"/> managed by
		///   the <paramref name="controlTester"/>.
		///   <para>
		///   While the <b>MouseController</b> is active, user keyboard and mouse input is disabled.  For this
		///   reason the <b>MouseController</b> should be disposed of when the testing is concluded.
		///   </para>
		/// </remarks>
		/// <example>
		/// <code>
		/// using (MouseController mouse = new MouseControler(myTestControl))
		/// {
		///   mouse.Position = new PointF(1,1);
		///   mouse.Press(MouseButtons.Middle);
		/// }
		/// </code>
		/// </example>
		public MouseController(ControlTester controlTester)
		{
			UseOn(controlTester);
		}
示例#24
0
		/// <summary>
		/// Creates a ControlTester from a ControlTester and an index where the
		/// original tester's name is not unique.
		/// </summary>
		/// <remarks>
		/// It is best to use the overloaded Constructor that requires just the name
		/// parameter if possible.
		/// </remarks>
		/// <param name="tester">The ControlTester.</param>
		/// <param name="index">The index to test.</param>
		public RadioButtonTester(ControlTester tester, int index) : base(tester, index)
		{
		}
示例#25
0
		/// <summary>
		/// Specify which control or form we should use for the relative position.
		/// </summary>
		/// <param name="control">
		///   A <see cref="ControlTester"/>.
		/// </param>
		public void UseOn(ControlTester control)
		{
			if(mouseControl == null)
			{
				Win32.Point position;
				Win32.GetCursorPos(out position);
				originalPosition = new Point(position.x, position.y);
			}

			if(control == null)
			{
				throw new ArgumentNullException("control");
			}

			mouseControl = new MouseControl(control);

			PositionUnit = GraphicsUnit.Pixel;

			// Block any user input while we are active.
			if(!restoreUserInput)
			{
				if(!Win32.BlockInput(true))
				{
					//TODO Bart De Boeck : Waarom is dit nodig ? Zie ook in Dispose().
					//throw new Win32Exception();
				}

				restoreUserInput = true;
			}
		}
示例#26
0
		/// <summary>
		/// Creates a ControlTester from a ControlTester and an index where the
		/// original tester's name is not unique.
		/// </summary>
		/// <remarks>
		/// It is best to use the overloaded Constructor that requires just the name
		/// parameter if possible.
		/// </remarks>
		/// <param name="tester">The ControlTester.</param>
		/// <param name="index">The index to test.</param>
		public TreeViewTester(ControlTester tester, int index) : base(tester, index)
		{
		}
示例#27
0
 internal KeyboardControl(ControlTester controlTester)
 {
     this.controlTester = controlTester;
 }
示例#28
0
		/// <summary>
		/// Creates a ControlTester from a ControlTester and an index where the
		/// original tester's name is not unique.
		/// </summary>
		/// <remarks>
		/// It is best to use the overloaded Constructor that requires just the name
		/// parameter if possible.
		/// </remarks>
		/// <param name="tester">The ControlTester.</param>
		/// <param name="index">The index to test.</param>
		public ComboBoxTester(ControlTester tester, int index) : base(tester, index)
		{
		}
示例#29
0
 public RichTextBoxTester(ControlTester <RichTextBox, RichTextBoxTester> tester, int index) : base(tester, index)
 {
 }
示例#30
0
 /// <summary>
 /// Creates a keyboard controller and sets the focus on the control
 /// indicated by the supplied ControlTester.
 /// </summary>
 /// <param name="controlTester">The ControlTester to use the keyboard
 /// on.</param>
 public KeyboardController(ControlTester controlTester) : this(new OldSendKeysFactory())
 {
     UseOn(controlTester);
 }
示例#31
0
文件: Command.cs 项目: bbriggs/wesay
		protected ControlTester GetTester()
		{
			ControlTester tester = new ControlTester(control);

			Type testerType = (Type) testerTypes[tester.Control.GetType()];
			if(testerType == null)
			{
				return tester;
			}

			return (ControlTester) Activator.CreateInstance(testerType, new object[] {control});
		}
示例#32
0
 /// <summary>
 ///   Creates and initialises a new instance of the class for the specified <see cref="ControlTester"/>.
 /// </summary>
 /// <param name="controlTester">
 ///   A <see cref="ControlTester"/>.
 /// </param>
 /// <remarks>
 ///   The <see cref="Position">mouse position</see> is relative to the <see cref="Control"/> managed by
 ///   the <paramref name="controlTester"/>.
 ///   <para>
 ///   While the <b>MouseController</b> is active, user keyboard and mouse input is disabled.  For this
 ///   reason the <b>MouseController</b> should be disposed of when the testing is concluded.
 ///   </para>
 /// </remarks>
 /// <example>
 /// <code>
 /// using (MouseController mouse = new MouseControler(myTestControl))
 /// {
 ///   mouse.Position = new PointF(1,1);
 ///   mouse.Press(MouseButtons.Middle);
 /// }
 /// </code>
 /// </example>
 public MouseController(ControlTester controlTester)
 {
     UseOn(controlTester);
 }
示例#33
0
		internal KeyboardControl(ControlTester controlTester)
		{
			this.controlTester = controlTester;
		}
示例#34
0
		/// <summary>
		/// Creates a ControlTester from a ControlTester and an index where the
		/// original tester's name is not unique.
		/// </summary>
		/// <remarks>
		/// It is best to use the overloaded Constructor that requires just the name
		/// parameter if possible.
		/// </remarks>
		/// <param name="tester">The ControlTester.</param>
		/// <param name="index">The index to test.</param>
		public TabControlTester(ControlTester tester, int index) : base(tester, index)
		{
		}
示例#35
0
 internal MouseControl(ControlTester controlTester)
 {
     this.controlTester = controlTester;
 }
示例#36
0
		/// <summary>
		/// Creates a keyboard controller and sets the focus on the control
		/// indicated by the supplied ControlTester.
		/// </summary>
		/// <param name="controlTester">The ControlTester to use the keyboard
		/// on.</param>
		public KeyboardController(ControlTester controlTester)
		{
			UseOn(controlTester);
		}
示例#37
0
 /// <summary>
 /// Creates a ControlTester from a ControlTester and an index where the
 /// original tester's name is not unique.
 /// </summary>
 /// <remarks>
 /// It is best to use the overloaded Constructor that requires just the name
 /// parameter if possible.
 /// </remarks>
 /// <param name="tester">The ControlTester.</param>
 /// <param name="index">The index to test.</param>
 public CheckedListBoxTester(ControlTester tester, int index) : base(tester, index)
 {
 }
示例#38
0
 public ControlTester(ControlTester <T, TThis> tester, int index) : base(tester, index)
 {
 }
示例#39
0
		public ControlTester(ControlTester tester, int index)
		{
			if(index < 0)
			{
				throw new Exception("Should not have index < 0");
			}
			this.index = index;
			form = tester.form;
			formName = tester.formName;
			name = tester.name;
		}
示例#40
0
		/// <summary>
		/// Creates a ControlTester from a ControlTester and an index where the
		/// original tester's name is not unique.
		/// </summary>
		/// <remarks>
		/// It is best to use the overloaded Constructor that requires just the name
		/// parameter if possible.
		/// </remarks>
		/// <param name="tester">The ControlTester.</param>
		/// <param name="index">The index to test.</param>
		public CheckBoxTester(ControlTester tester, int index) : base(tester, index)
		{
		}
示例#41
0
 /// <summary>
 /// Creates a ControlTester from a ControlTester and an index where the
 /// original tester's name is not unique.
 /// </summary>
 /// <remarks>
 /// It is best to use the overloaded Constructor that requires just the name
 /// parameter if possible.
 /// </remarks>
 /// <param name="tester">The ControlTester.</param>
 /// <param name="index">The index to test.</param>
 public TextBoxTester(ControlTester tester, int index) : base(tester, index)
 {
 }
示例#42
0
 /// <summary>
 /// Creates a ControlTester from a ControlTester and an index where the
 /// original tester's name is not unique.
 /// </summary>
 /// <remarks>
 /// It is best to use the overloaded Constructor that requires just the name
 /// parameter if possible.
 /// </remarks>
 /// <param name="tester">The ControlTester.</param>
 /// <param name="index">The index to test.</param>
 public ListViewTester(ControlTester tester, int index) : base(tester, index)
 {
 }
 public override void Setup()
 {
     _form = new MainForm();
     _form.Show();
     _ctrl = new ControlTester("ctlSceneView");
 }