Inheritance: BasePattern
示例#1
0
 public GuiTextBox(AutomationElement textbox)
 {
     tbAutoEl = textbox;
     AutomationId = textbox.Current.AutomationId;
     Name = textbox.Current.Name;
     value = tbAutoEl.GetPattern<ValuePattern>(ValuePattern.Pattern);
 }
示例#2
0
        // -------------------------------------------------------------------
        // Call ValuePattern.SetValue("123456789") on control whose limit is set to 1 character
        // -------------------------------------------------------------------
        private void TS_SetValueOversize(ValuePattern valuePattern, CheckType checkType)
        {
            bool isReadOnly = valuePattern.Current.IsReadOnly;
            bool isPassword = m_le.Current.IsPassword;
            string value = "123456789";
            IntPtr _hwnd = Helpers.CastNativeWindowHandleToIntPtr(m_le);
            NativeMethods.HWND hwnd = NativeMethods.HWND.Cast(_hwnd);
            IntPtr wParam = new IntPtr(1);
            IntPtr result;

            int    lastWin32Error    = Marshal.GetLastWin32Error();
            int    resultInt;

            IntPtr resultSendMessage = UnsafeNativeMethods.SendMessageTimeout(hwnd, NativeMethods.EM_LIMITTEXT, wParam, IntPtr.Zero, 1, 10000, out result);
            if (resultSendMessage == IntPtr.Zero)
            {
                throw new InvalidOperationException("SendMessageTimeout() timed out");
            }
            resultInt = unchecked((int)(long)result);

            try
            {
                valuePattern.SetValue(value);
            }
            catch (InvalidOperationException)
            {
                Comment("As expected, unable to set value of control limited to 1 character with a string \"123456789\"");
            }
            catch (UnauthorizedAccessException actualException)
            {
                if (isPassword == true)
                {
                    Comment("As expected, unable to set value of password control (UnauthorizedAccessException)");
                    m_TestStep++;
                    return;
                }
                else
                    TestException(null, actualException, "TS_SetValue", checkType);
            }
            catch (Exception actualException)
            {
                if (Library.IsCriticalException(actualException))
                    throw;

                TestException(null, actualException, "TS_SetValue", checkType);
            }

            Comment("Successfully called ValuePattern.SetValue(\"A\"), must be control that is not numeric-only");
            m_TestStep++;
        }
示例#3
0
        // -------------------------------------------------------------------
        // Call ValuePattern.SetValue(Non-numeric value) raising ArgumentException for numeric-only fields
        // -------------------------------------------------------------------
        private void TS_SetValueAlpha(ValuePattern valuePattern, CheckType checkType)
        {
            bool isReadOnly = valuePattern.Current.IsReadOnly;
            bool isPassword = m_le.Current.IsPassword;
            string value = "A";
            IntPtr hwnd = Helpers.CastNativeWindowHandleToIntPtr(m_le);

            try
            {
                valuePattern.SetValue(value);
            }
            catch (ArgumentException)
            {
                Comment("As expected, unable to set value of numeric only control with an alpha numeric string ('A')");
                m_TestStep++;
                return;
            }
            catch (InvalidOperationException actualException)
            {
                if (isReadOnly == true)
                {
                    Comment("As expected, unable to set value of read-only control (InvalidOperationException)");
                    m_TestStep++;
                    return;
                }
                else
                    TestException(null, actualException, "TS_SetValue", checkType);
            }
            catch (UnauthorizedAccessException actualException)
            {
                if (isPassword == true)
                {
                    Comment("As expected, unable to set value of password control (UnauthorizedAccessException)");
                    m_TestStep++;
                    return;
                }
                else
                    TestException(null, actualException, "TS_SetValue", checkType);
            }
            catch (Exception actualException)
            {
                if (Library.IsCriticalException(actualException))
                    throw;

                TestException(null, actualException, "TS_SetValue", checkType);
            }

            Comment("Successfully called ValuePattern.SetValue(\"A\"), must be control that is not numeric-only");
            m_TestStep++;
        }
示例#4
0
        // -------------------------------------------------------------------
        // Call ValuePattern.SetValue()
        // -------------------------------------------------------------------
        private void TS_SetValue(ValuePattern valuePattern, CheckType checkType)
        {
            bool isReadOnly = valuePattern.Current.IsReadOnly;
            bool isPassword = m_le.Current.IsPassword;
            string value = "1";
            IntPtr hwnd = Helpers.CastNativeWindowHandleToIntPtr(m_le);

            try
            {
                valuePattern.SetValue(value);
            }
            catch (ElementNotEnabledException actualException)
            {
                if (SafeNativeMethods.IsWindowEnabled(hwnd) == false)
                    Comment("As expected, unable to set value of disabled control");
                else
                    TestException(null, actualException, "TS_SetValue", checkType);
            }
            catch (InvalidOperationException actualException)
            {
                if (isReadOnly == true)
                {
                    Comment("As expected, unable to set value of read-only control (InvalidOperationException)");
                    m_TestStep++;
                    return;
                }
                else
                    TestException(null, actualException, "TS_SetValue", checkType);
            }
            catch (UnauthorizedAccessException actualException)
            {
                if (isPassword == true)
                {
                    Comment("As expected, unable to set value of password control (UnauthorizedAccessException)");
                    m_TestStep++;
                    return;
                }
                else
                    TestException(null, actualException, "TS_SetValue", checkType);
            }
            catch (Exception actualException)
            {
                if (Library.IsCriticalException(actualException))
                    throw;

                TestException(null, actualException, "TS_SetValue", checkType);
            }

            Comment("Successfully called ValuePattern.SetValue(" + value + ")");
            m_TestStep++;
        }
示例#5
0
        // -------------------------------------------------------------------
        // Get ValuePattern.Value property
        // -------------------------------------------------------------------
        private void TS_Value(ValuePattern valuePattern, CheckType checkType)
        {
            bool isPassword = m_le.Current.IsPassword;
            string value = "";

            try
            {
                value = valuePattern.Current.Value;
            }
            catch (Exception actualException)
            {
                InvalidOperationException ex = new InvalidOperationException();

                if (Library.IsCriticalException(actualException))
                    throw;

                TestException(ex.GetType(), actualException, "TS_Value", checkType);
            }

            Comment("ValuePattern.Value = " + value);
            m_TestStep++;
        }
示例#6
0
        // -------------------------------------------------------------------
        // Conduct move / count scenario (iterating by textunit)
        // -------------------------------------------------------------------
        private void TS_GetValuePattern(out ValuePattern valuePattern, CheckType checkType)
        {

            valuePattern = null; 
            
            try
            {
                valuePattern = m_le.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern;

            }
            catch (Exception actualException)
            {
                if (Library.IsCriticalException(actualException))
                    throw;

                TestException(null, actualException, "TS_GetValuePattern", checkType);
            }

            if (valuePattern == null)
                ThrowMe(checkType, "Unable to acquire ValuePattern for this control");
            else
                Comment("Successfully acquired ValuePattern for this control" );

            m_TestStep++;
        }
示例#7
0
 public GuiCell(AutomationElement autoEl, string columnName)
 {
     cell = autoEl;
     _owningColumnName = columnName;
     _value = cell.GetPattern<ValuePattern>(ValuePattern.Pattern);
 }
示例#8
0
 /// -------------------------------------------------------------------
 /// <summary></summary>
 /// -------------------------------------------------------------------
 internal ValueWrapper(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
     :
     base(element, testSuite, priority, typeOfControl, typeOfPattern, dirResults, testEvents, commands)
 {
     _pattern = (ValuePattern)GetPattern(m_le, m_useCurrent, ValuePattern.Pattern);
 }
示例#9
0
 private CustomCommandResponse Execute(ValuePattern valuePattern, string assemblyFile, string typeName, MethodInfo method, object[] arguments)
 {
     var commandSerializer = new CustomCommandSerializer();
     string serializedCommand = commandSerializer.Serialize(new FileInfo(assemblyFile).Name, typeName, method.Name, arguments);
     valuePattern.SetValue(serializedCommand);
     ActionPerformed(Action.WindowMessage);
     string value = valuePattern.Current.Value;
     return new CustomCommandResponse(commandSerializer.ToObject(value));
 }
示例#10
0
			internal ValuePatternInformation (ValuePattern pattern, bool cache)
			{
				this.pattern = pattern;
				this.cache = cache;
			}
示例#11
0
 internal ValuePatternInformation(ValuePattern pattern, bool cache)
 {
     this.pattern = pattern;
     this.cache   = cache;
 }