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