//---------------------------------------------------------------------------
        // Helper for RangeFromChild() test cases
        //---------------------------------------------------------------------------
        internal void RangeFromChildHelper(SampleText sampleText, bool requiresChildren, AutoElementType autoElementArgument, Type expectedException)
        {
            string actualText = "";
            AutomationElement[] autoElements = null;

            //Pre-Condition Verify text is expected value <<sampleText>>
            TS_SetText(sampleText, out actualText, CheckType.IncorrectElementConfiguration);

            //Pre-Condition Verify range children c<<requiresChildren>>
            TS_VerifyChildren(requiresChildren, CheckType.IncorrectElementConfiguration);

            //Pre-Condition Acquire automation element(s)
            TS_GetAutomationElement(ref autoElements, autoElementArgument, CheckType.Verification);

            // Iterate through each AutomationElement, calling RangeFromChild (<<expectedException>> for any expected errors)
            TS_EnumerateChildren(autoElements, true, expectedException, CheckType.Verification);
        }
Beispiel #2
0
 ///---------------------------------------------------------------------------
 /// <summary>Parses values for enum</summary>
 ///---------------------------------------------------------------------------
 static public string ParseType(AutoElementType value)
 {
     return ParseType(value.GetType().ToString(), value.ToString());
 }
        internal void TS_GetAutomationElement(ref AutomationElement[] autoElements, AutoElementType autoElementArgument, CheckType checkType)
        {
            TextPatternRange documentRange = Pattern_DocumentRange(CheckType.Verification);

            switch (autoElementArgument)
            {
                case AutoElementType.DifferentFromPattern:
                    autoElements = new AutomationElement[1];
                    autoElements[0] = TreeWalker.ControlViewWalker.GetParent(m_le);
                    if (autoElements[0] == null)
                        ThrowMe(checkType, "Unable to get parent AutomationElement of TextPattern's AutomationElement");
                    break;
                case AutoElementType.Null:
                    autoElements = null;
                    break;
                case AutoElementType.SameAsPattern:
                    autoElements = new AutomationElement[1];
                    autoElements[0] = m_le;
                    break;
                case AutoElementType.UseChildren:
                    // Assumption: we don't get to this point without verifying there *ARE* children
                    Range_GetChildren(documentRange, ref autoElements, checkType);
                    break;
                default:
                    throw new ArgumentException("TS_GetAutomationElement() has no support for " + ParseType(autoElementArgument));
            }

            Comment("Acquired automation element(s) " + Parse(autoElementArgument));
            m_TestStep++;
        }
Beispiel #4
0
 static public string Parse(AutoElementType value)
 {
     switch (value)
     {
         case AutoElementType.SameAsPattern: return "that contains this pattern";
         case AutoElementType.DifferentFromPattern: return "different than autoElement that contains this pattern";
         case AutoElementType.Null: return "equal to null ";
         case AutoElementType.UseChildren: return "from TextPattern.Children proeprty";
         default:
             throw new ArgumentException("Parse() has no support for " + ParseType(value));
     }
 }