Exemplo n.º 1
0
        //---------------------------------------------------------------------------
        // Helper for RangeFromPoint() test cases
        //---------------------------------------------------------------------------
        internal void RangeFromPointHelper2(SampleText sampleText, bool isMultiLineExpected, TargetRangeType rangeType, BoundingRectangleLocation pointLocation, RangeCompare rangeCompare)
        {
            Point screenLocation;
            Rect[] boundRects = new Rect[0];
            TextPatternRange callingRange = null;
            TextPatternRange rangeFromPt = null;

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

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

            // Pre-Condition Create range equal to <<rangeType>>
            TS_CreateRange(out callingRange, rangeType, null, false, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Scroll range into view
            // Bug 1134054: TextPatternRange.ScrollIntoView fails to scroll horizontally on edit control
            // We need to make sure we scroll off the view so we can scroll back on it.
            // Otherwise the second scrollIntoView call may be a no-op...
            Range_ScrollIntoView(callingRange, false, null, CheckType.Verification);
            TS_ScrollIntoView(callingRange, true, null, CheckType.Verification);

            // Pre-Condition Call GetBoundingRectangles() on that range
            TS_GetBoundingRectangles(callingRange, ref boundRects, false, null, CheckType.Verification);

            // Pre-Condition Create a point <<pointLocation>> of bounding rect
            TS_CreatePoint(ref callingRange, boundRects, out screenLocation, pointLocation, CheckType.Verification);

            // Call RangeFromPoint on point without errors
            TS_RangeFromPoint(ref rangeFromPt, screenLocation, null, CheckType.Verification);

            // Verify that range returned is <<rangeCompare>>
            TS_CompareRanges(callingRange, rangeFromPt, rangeCompare, null, CheckType.Verification);
        }
Exemplo n.º 2
0
        internal void TS_CreatePoint(ref TextPatternRange range, Rect[] boundRects, out Point screenLocation, BoundingRectangleLocation boundRectLoc, CheckType checkType)
        {
            int rectIdx = 0;
            Rect autoElementRect = new Rect();
            Rect[] tempRects = new Rect[0];
            TextPatternRange documentRange = Pattern_DocumentRange(CheckType.Verification);

            screenLocation = new Point();

            // Sanity check
            Library.ValidateArgumentNonNull(range, "range argument cannot be null");

            if ((boundRects.Length == 0) && (boundRectLoc != BoundingRectangleLocation.OutsideAutomationElement))
            {
                throw new ArgumentException("TS_CreatePoint requires non-empty array of bounding rectangles");
            }

            // Finally, generate the point!
            switch (boundRectLoc)
            {
                case BoundingRectangleLocation.InsideTopLeft:
                    rectIdx = 0;
                    screenLocation.X = boundRects[rectIdx].Left + 1;
                    screenLocation.Y = boundRects[rectIdx].Top + 1;
                    break;
                case BoundingRectangleLocation.Middle:
                    screenLocation.X = (boundRects[rectIdx].Left + boundRects[rectIdx].Right) / 2;
                    screenLocation.Y = (boundRects[rectIdx].Top + boundRects[rectIdx].Bottom) / 2;
                    break;
                case BoundingRectangleLocation.InsideBottomRight:
                    rectIdx = boundRects.Length - 1;
                    screenLocation.X = boundRects[rectIdx].Right - 1;
                    screenLocation.Y = boundRects[rectIdx].Bottom - 1;
                    break;
                case BoundingRectangleLocation.OutsideBottomRight:
                    rectIdx = boundRects.Length - 1;
                    screenLocation.X = boundRects[rectIdx].Right + 1;
                    screenLocation.Y = boundRects[rectIdx].Bottom + 1;
                    break;
                case BoundingRectangleLocation.OutsideTopLeft:
                    rectIdx = 0;
                    screenLocation.X = boundRects[rectIdx].Left - 1;
                    screenLocation.Y = boundRects[rectIdx].Top - 1;
                    break;
                case BoundingRectangleLocation.OutsideAutomationElement:
                    // Get automation element bounding rectangle
                    GetAutomationElementBoundingRectangle(out autoElementRect);
                    screenLocation.X = autoElementRect.Left - 1;
                    screenLocation.Y = autoElementRect.Top - 1;
                    break;
                case BoundingRectangleLocation.FirstChar:
                    tempRects = null;
                    Range_GetBoundingRectangles(documentRange, ref tempRects, null, checkType);
                    if (tempRects.Length == 0)
                        ThrowMe(checkType, "TS_CreatePoint expects non-empy bounding rectangles array for document");
                    screenLocation.X = tempRects[0].Left + 1; // essentially top-left of first rect
                    screenLocation.Y = tempRects[0].Top + 1;
                    break;
                case BoundingRectangleLocation.FirstCharInRange:
                    rectIdx = 0;
                    screenLocation.X = boundRects[0].Left + 1; // essentially top-left of first rect
                    screenLocation.Y = boundRects[0].Top + 1;
                    break;
                case BoundingRectangleLocation.LastCharInRange:
                    rectIdx = boundRects.Length - 1;
                    screenLocation.X = boundRects[rectIdx].Right - 1;   // essentially bottom-right of last rect
                    screenLocation.Y = boundRects[rectIdx].Bottom - 1;
                    break;
                default:
                    throw new ArgumentException("TS_CreatePoint() has no support for " + ParseType(boundRectLoc));
            }

            Comment("Created Point (" + screenLocation.ToString(CultureInfo.InvariantCulture) + ") at " +
                    Parse(boundRectLoc) +
                    " relative to boundRect " +
                    (boundRectLoc != BoundingRectangleLocation.OutsideAutomationElement ?
                        boundRects[rectIdx].ToString(CultureInfo.InvariantCulture) :
                        autoElementRect.ToString(CultureInfo.InvariantCulture)));
            m_TestStep++;

        }
Exemplo n.º 3
0
 /// ---------------------------------------------------------------------------
 /// <summary>Parses values for enum</summary>
 /// ---------------------------------------------------------------------------
 static public string ParseType(BoundingRectangleLocation value)
 {
     return ParseType(value.GetType().ToString(), value.ToString());
 }
Exemplo n.º 4
0
        //---------------------------------------------------------------------------
        // Helper for RangeFromPoint() test cases
        //---------------------------------------------------------------------------
        internal void RangeFromPointHelper(SampleText sampleText, int expandBy, TextPatternRangeEndpoint endPoint, RangeLocation rangeLocation, BoundingRectangleLocation pointLocation, RangeCompare rangeCompare, Type expectedException)
        {
            Point screenLocation;
            Rect[] boundRects = new Rect[0];
            string actualText = "";
            TextPatternRange callingRange = null;
            TextPatternRange rangeFromPt = null;

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

            // Pre-Condition Create empty calling range @ <<RangeLocation>> of TextPattern.DocumentRange
            TS_CreateEmptyRange(out callingRange, rangeLocation, CheckType.Verification);

            // Pre-Condition Expand <<endPoint>> endPoint by <<expandby>> character(s)
            TS_ExpandRange(ref callingRange, endPoint, TextUnit.Character, expandBy, true, CheckType.Verification);

            // Pre-Condition Scroll range into view
            // Bug 1134054: TextPatternRange.ScrollIntoView fails to scroll horizontally on edit control
            // We need to make sure we scroll off the view so we can scroll back on it.
            // Otherwise the second scrollIntoView call may be a no-op...
            Range_ScrollIntoView(callingRange, false, null, CheckType.Verification);
            TS_ScrollIntoView(callingRange, true, null, CheckType.Verification);

            // Pre-Condition Call GetBoundingRectangles() on that range
            TS_GetBoundingRectangles(callingRange, ref boundRects, false, null, CheckType.Verification);

            // Pre-Condition Create a point <<pointLocation>> of bounding rect
            TS_CreatePoint(ref callingRange, boundRects, out screenLocation, pointLocation, CheckType.Verification);

            // Call RangeFromPoint on point 
            TS_RangeFromPoint(ref rangeFromPt, screenLocation, expectedException, CheckType.Verification);

            // Verify that range returned is  <<rangeCompare>>
            TS_CompareRanges(callingRange, rangeFromPt, rangeCompare, expectedException, CheckType.Verification);
        }
Exemplo n.º 5
0
 static public string Parse(BoundingRectangleLocation value)
 {
     switch (value)
     {
         case BoundingRectangleLocation.InsideTopLeft: return "Inside Top Left";
         case BoundingRectangleLocation.Middle: return "Middle";
         case BoundingRectangleLocation.InsideBottomRight: return "Inside Bottom Right";
         case BoundingRectangleLocation.OutsideTopLeft: return "Outside Top Left";
         case BoundingRectangleLocation.OutsideBottomRight: return "Outside Bottom Right";
         case BoundingRectangleLocation.OutsideAutomationElement: return "Outside Automation Element";
         case BoundingRectangleLocation.FirstChar: return "Within first character";
         case BoundingRectangleLocation.FirstCharInRange: return "Within first character in range";
         case BoundingRectangleLocation.LastCharInRange: return "Within last character in range";
         default:
             throw new ArgumentException("Parse() has no support for " + ParseType(value));
     }
 }