//--------------------------------------------------------------------------- // 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); }
/// --------------------------------------------------------------------------- /// <summary>Parses values for enum</summary> /// --------------------------------------------------------------------------- static public string ParseType(ScrollLocation value) { return ParseType(value.GetType().ToString(), value.ToString()); }
internal void TS_ScrollViewPort(ScrollLocation scrollLocation, bool scrollRequired, CheckType checkType) { bool isHorizScrollable; bool isVertScrollable; const double NoScroll = -1L; const double ScrollLeft = 0L; const double ScrollTop = 0L; const double ScrollMiddle = 50L; const double ScrollRight = 100L; const double ScrollBottom = 100L; double horizontalPercent = 0; double verticalPercent = 0; ScrollPattern scrollPattern = null; if (scrollLocation == ScrollLocation.NotApplicable) { Comment("Viewport location is not important to this test"); } else { try { // can we get the scroll pattern? bool isScrollPatternAvailable = (bool)m_le.GetCurrentPropertyValue(AutomationElement.IsScrollPatternAvailableProperty); // Apparently so... if (isScrollPatternAvailable) { scrollPattern = m_le.GetCurrentPattern(ScrollPattern.Pattern) as ScrollPattern; } } catch (Exception exception) { if (Library.IsCriticalException(exception)) throw; ThrowMe(checkType, "Exception raised trying to obtain ScrollPattern. Error = " + exception.Message); } // Now we determine if null scroll pattern is bad or not if (scrollPattern == null) { if (scrollRequired == true) ThrowMe(checkType, "ScrollPattern required for test"); else { m_TestStep++; Comment("Unable to acquire ScrollPattern, continuing with test"); return; } } // can we scroll on either axis? isHorizScrollable = scrollPattern.Current.HorizontallyScrollable; isVertScrollable = scrollPattern.Current.VerticallyScrollable; Comment("ScrollPattern.HorizontallyScrollable = " + isHorizScrollable.ToString()); Comment("ScrollPattern.VerticallyScrollable = " + isVertScrollable.ToString()); // Calcualte how we want to scroll. And if we can't do the scroll we want, reflect that too. switch (scrollLocation) { case ScrollLocation.LeftTop: // Do nothing, default. horizontalPercent = ScrollLeft; verticalPercent = ScrollTop; break; case ScrollLocation.RightTop: if (isHorizScrollable == false) ThrowMe(checkType, "Unable to scroll viewport horizontally to the right"); horizontalPercent = ScrollRight; verticalPercent = ScrollTop; break; case ScrollLocation.LeftCenter: if (isVertScrollable == false) ThrowMe(checkType, "Unable to scroll viewport vertically to the middle"); horizontalPercent = ScrollLeft; verticalPercent = ScrollMiddle; break; case ScrollLocation.Center: if (isHorizScrollable == false) ThrowMe(checkType, "Unable to scroll viewport horizontally to the right"); if (isVertScrollable == false) ThrowMe(checkType, "Unable to scroll viewport vertically to the middle"); horizontalPercent = ScrollMiddle; verticalPercent = ScrollMiddle; break; case ScrollLocation.RightCenter: if (isHorizScrollable == false) ThrowMe(checkType, "Unable to scroll viewport horizontally to the right"); if (isVertScrollable == false) ThrowMe(checkType, "Unable to scroll viewport vertically to the middle"); horizontalPercent = ScrollRight; verticalPercent = ScrollMiddle; break; case ScrollLocation.LeftBottom: if (isVertScrollable == false) ThrowMe(checkType, "Unable to scroll viewport vertically to the middle"); horizontalPercent = ScrollLeft; verticalPercent = ScrollBottom; break; case ScrollLocation.RightBottom: if (isHorizScrollable == false) ThrowMe(checkType, "Unable to scroll viewport horizontally to the right"); if (isVertScrollable == false) ThrowMe(checkType, "Unable to scroll viewport vertically to the middle"); horizontalPercent = ScrollLeft; verticalPercent = ScrollBottom; break; case ScrollLocation.NotApplicable: // should not get here... default: throw new ArgumentException("TS_ScrollViewPort() has no support for " + ParseType(scrollLocation)); } // If we're not scrollable, adjust our scroll values if (isHorizScrollable == false) { Comment("Unable to scroll horizontally"); horizontalPercent = NoScroll; } if (isVertScrollable == false) { Comment("Unable to scroll vertically"); verticalPercent = NoScroll; } if ( (isHorizScrollable == false) && (isVertScrollable == false) ) { ThrowMe(checkType, "Unable to scroll, perhaps text isn't right width (height?) or control doesn't support scrolling"); } Comment("---Calling ScrollPattern.SetScrollPercent( " + horizontalPercent + ", " + verticalPercent + ")"); scrollPattern.SetScrollPercent(horizontalPercent, verticalPercent); Comment("Viewport is in " + Parse(scrollLocation)); } m_TestStep++; }
static public string Parse(ScrollLocation value) { switch (value) { case ScrollLocation.LeftTop: return "LEFT-TOP of viewport"; case ScrollLocation.RightTop: return "RIGHT-TOP of viewport"; case ScrollLocation.LeftCenter: return "LEFT-CENTER of viewport"; case ScrollLocation.Center: return "MIDDLE (horiz & vert) of viewport"; case ScrollLocation.RightCenter: return "RIGHT-MIDDLE of viewport"; case ScrollLocation.LeftBottom: return "LEFT-BOTTOM of viewport"; case ScrollLocation.RightBottom: return "RIGHT-BOTTOM of viewport"; case ScrollLocation.NotApplicable: return "NOT APPLICABLE: viewport location is not relevant"; default: throw new ArgumentException("Parse() has no support for " + ParseType(value)); } }