Example #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;
            }
        }
Example #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;
 }
Example #3
0
        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 }));
        }
Example #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;
            }
        }
Example #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);
        }
Example #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;
			}
		}
Example #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)
 {
 }
Example #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)
	{
	}
Example #9
0
		internal MouseControl(ControlTester controlTester)
		{
			this.controlTester = controlTester;
		}
Example #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);
        }
Example #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);
 }
Example #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)
 {
 }
Example #13
0
		private void ClickStarOfLexemeForm()
		{
			ControlTester t = new ControlTester(GetNameOfLexicalFormAnnotationControl(), _window);
			t.Click();
			GetEditControl(Field.FieldNames.EntryLexicalForm.ToString());
		}
Example #14
0
		private static void PressCtrlN(ControlTester t)
		{
			using (KeyboardController kc = new KeyboardController(t))
			{
				kc.Press("^n"); // Ctrl+N
			}
		}
Example #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)
 {
 }
Example #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)
 {
 }
Example #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)
 {
 }
Example #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)
		{
		}
Example #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)
 {
 }
Example #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)
		{
		}
Example #21
0
 public CheckBoxTester(ControlTester <CheckBox, CheckBoxTester> tester, int index) : base(tester, index)
 {
 }
Example #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)
 {
 }
Example #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);
		}
Example #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)
		{
		}
Example #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;
			}
		}
Example #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)
		{
		}
Example #27
0
 internal KeyboardControl(ControlTester controlTester)
 {
     this.controlTester = controlTester;
 }
Example #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)
		{
		}
Example #29
0
 public RichTextBoxTester(ControlTester <RichTextBox, RichTextBoxTester> tester, int index) : base(tester, index)
 {
 }
Example #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);
 }
Example #31
0
		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});
		}
Example #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);
 }
Example #33
0
		internal KeyboardControl(ControlTester controlTester)
		{
			this.controlTester = controlTester;
		}
Example #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)
		{
		}
Example #35
0
 internal MouseControl(ControlTester controlTester)
 {
     this.controlTester = controlTester;
 }
Example #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);
		}
Example #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)
 {
 }
Example #38
0
 public ControlTester(ControlTester <T, TThis> tester, int index) : base(tester, index)
 {
 }
Example #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;
		}
Example #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)
		{
		}
Example #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)
 {
 }
Example #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");
 }