//---------------------------------------------------------------------------
        // Helper for GetBoundingRectangles() test cases
        //---------------------------------------------------------------------------
        internal void GetBoundingRectanglesHelper(SampleText sampleText, TargetRangeType callingRangeType, bool isMultiLine, ScrollLocation scrollLocation, GetBoundRectResult boundRectResults)
        {
            Rect autoElement;
            Rect[] boundRects = new Rect[0];
            TextPatternRange callingRange;

            // Pre-Condition Control must supports multi-line = <<expectedResult>>
            TS_IsMultiLine(isMultiLine, CheckType.IncorrectElementConfiguration);

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

            // Pre-Condition Create calling range = <<callingRangeType>>
            TS_CreateRange(out callingRange, callingRangeType, null, false, CheckType.Verification);

            // Pre-Condition Scroll viewport to <<ScrollLocation>>
            TS_ScrollViewPort(scrollLocation, false, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Get Automation Element Bounding Rectangle
            TS_GetAutomationElementBoundingRectangle(out autoElement);

            // Call GetBoundingRectangles()
            TS_GetBoundingRectanglesLite(callingRange, ref boundRects, false, null, CheckType.Verification);

            // Valdiate Bounding Rectangles <<getResult>>
            TS_VerifyWithinRects(autoElement, boundRects, boundRectResults, CheckType.Verification);

        }
Esempio n. 2
0
 /// ---------------------------------------------------------------------------
 /// <summary>Parses values for enum</summary>
 /// ---------------------------------------------------------------------------
 static public string ParseType(GetBoundRectResult value)
 {
     return ParseType(value.GetType().ToString(), value.ToString());
 }
        static void TS_VerifyWithinRects(Rect outerRect, Rect[] innerRects, GetBoundRectResult getBoundRectResult, CheckType checkType)
        {
            double areaOuter = 0;
            double areaInner = 0;

            // Sanity check... are any of our inners outside our outer?
            for (int i = 0; i < innerRects.Length; i++)
            {
                if ((innerRects[i].Top < outerRect.Top)
                 || (innerRects[i].Left < outerRect.Left)
                 || (innerRects[i].Right > outerRect.Right)
                 || (innerRects[i].Bottom > outerRect.Bottom))
                {
                    ThrowMe(checkType, "InnerRect " + innerRects[i].ToString(CultureInfo.InvariantCulture) +
                            " incorrectly outside autoElement.BoundRect " + outerRect.ToString(CultureInfo.InvariantCulture));
                }
                else
                {
                    areaInner += (innerRects[i].Bottom - innerRects[i].Top) * (innerRects[i].Right - innerRects[i].Left);

                    Comment("Bounding Rectangle # " + i + " (" + innerRects[i].ToString(CultureInfo.InvariantCulture) +
                            ") within autoElement.BoundRect " + outerRect.ToString(CultureInfo.InvariantCulture));
                }
            }

            // Now, lets split some hairs
            areaOuter = (outerRect.Bottom - outerRect.Top) * (outerRect.Right - outerRect.Left);
            Comment("Inner area = " + areaInner);
            Comment("Outer area = " + areaOuter);

            // Now, validate results
            switch (getBoundRectResult)
            {
                case GetBoundRectResult.SubsetOfAutoElementBoundRect:
                    if (areaInner < areaOuter)
                        Comment("Inner rectangle(s) is/are expected size, i.e. a small portion of the outer rectangle");
                    else if (innerRects.Length == 0)
                        ThrowMe(checkType, "Was not expecting an EMPTY array of bounding rectangles");
                    else
                        ThrowMe(checkType, "Unexpected state for test");
                    break;
                case GetBoundRectResult.EmptyArray:
                    if (innerRects.Length == 0)
                        Comment("Empty array of bounding rectangles, as expected");
                    else 
                        ThrowMe(checkType, "Was not expecting an a NON-EMPTY array of bounding rectangles");
                    break;
                default:
                    throw new ArgumentException("TS_VerifyWithinRects() has no support for " + ParseType(getBoundRectResult));
            }

            m_TestStep++;
        }
Esempio n. 4
0
 static public string Parse(GetBoundRectResult value)
 {
     switch (value)
     {
         case GetBoundRectResult.SubsetOfAutoElementBoundRect: return "boundRect(s) are a subset of autoElement boundRect";
         case GetBoundRectResult.EmptyArray: return "empty array of bounding rectangles";
         default:
             throw new ArgumentException("Parse() has no support for " + ParseType(value));
     }
 }