internal static bool ClickablePointUnder(
            this AutomationElement currentElement,
            AutomationElement rectElement,
            ScrollPattern scrollPattern)
        {
            try
            {
                Point point;
                if (!AutomationElementHelper.TryGetClickablePoint(currentElement, out point))
                {
                    if (!AutomationElementHelper.TryGetBoundingRectangleCenter(currentElement, out point))
                    {
                        throw new OperationCanceledException(
                                  "Не удалось определить расположение элемента относительно точки.\n");
                    }
                }

                var rect = rectElement.GetPropertyValue <Rect>(AutomationElement.BoundingRectangleProperty);

                if (scrollPattern == null || scrollPattern.Current.HorizontalScrollPercent < 0)
                {
                    return(point.Y > rect.Bottom);
                }

                return(point.Y > rect.Bottom - CruciatusFactory.Settings.ScrollBarHeight);
            }
            catch (Exception exc)
            {
                throw new OperationCanceledException(
                          "Не удалось определить расположение элемента относительно точки.\n",
                          exc);
            }
        }
Exemple #2
0
        internal static bool ClickablePointRight(
            this AutomationElement currentElement,
            AutomationElement rectElement,
            ScrollPattern scrollPattern)
        {
            try
            {
                Point point;
                if (!AutomationElementHelper.TryGetClickablePoint(currentElement, out point))
                {
                    if (!AutomationElementHelper.TryGetBoundingRectangleCenter(currentElement, out point))
                    {
                        throw new OperationCanceledException(OperationCanceledExceptionText);
                    }
                }

                var rect = rectElement.GetPropertyValue <Rect>(AutomationElement.BoundingRectangleProperty);

                if (scrollPattern == null || scrollPattern.Current.HorizontalScrollPercent < 0)
                {
                    return(point.X > rect.Right);
                }

                return(point.X > rect.Right - CruciatusFactory.Settings.ScrollBarWidth);
            }
            catch (Exception exc)
            {
                throw new OperationCanceledException(OperationCanceledExceptionText, exc);
            }
        }
        protected virtual void Scroll(ScrollAmount amount)
        {
            if (!IsScrollable)
            {
                return;
            }
            switch (amount)
            {
            case ScrollAmount.LargeDecrement:
                ScrollPattern.SetScrollPercent(
                    ScrollPattern.Current.HorizontalScrollPercent,
                    ValidPercentage(ScrollPattern.Current.VerticalScrollPercent - ScrollPercentage));
                break;

            case ScrollAmount.SmallDecrement:
                ScrollPattern.SetScrollPercent(
                    ScrollPattern.Current.HorizontalScrollPercent,
                    ValidPercentage(ScrollPattern.Current.VerticalScrollPercent - SmallPercentage()));
                break;

            case ScrollAmount.LargeIncrement:
                ScrollPattern.SetScrollPercent(
                    ScrollPattern.Current.HorizontalScrollPercent,
                    ValidPercentage(ScrollPattern.Current.VerticalScrollPercent + ScrollPercentage));
                break;

            case ScrollAmount.SmallIncrement:
                ScrollPattern.SetScrollPercent(
                    ScrollPattern.Current.HorizontalScrollPercent,
                    ValidPercentage(ScrollPattern.Current.VerticalScrollPercent + SmallPercentage()));
                break;
            }
            actionListener.ActionPerformed(Action.Scroll);
        }
        // </Snippet102>

        // <Snippet103>
        ///--------------------------------------------------------------------
        /// <summary>
        /// Obtains a ScrollPattern control pattern from an automation
        /// element and attempts to scroll to the top of the
        /// viewfinder.
        /// </summary>
        /// <param name="targetControl">
        /// The automation element of interest.
        /// </param>
        ///--------------------------------------------------------------------
        private void ScrollToTop(AutomationElement targetControl)
        {
            if (targetControl == null)
            {
                throw new ArgumentNullException(
                          "AutomationElement argument cannot be null.");
            }

            ScrollPattern scrollPattern = GetScrollPattern(targetControl);

            try
            {
                scrollPattern.SetScrollPercent(ScrollPattern.NoScroll, 0);
            }
            catch (InvalidOperationException)
            {
                // Control not able to scroll in the direction requested;
                // when scrollable property of that direction is False
                // TO DO: error handling.
            }
            catch (ArgumentOutOfRangeException)
            {
                // A value greater than 100 or less than 0 is passed in
                // (except -1 which is equivalent to NoScroll).
                // TO DO: error handling.
            }
        }
Exemple #5
0
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        internal ScrollItemPatternWrapper(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)
        {
            Comment("Creating ScrollItemTests");

            _pattern = (ScrollItemPattern)GetPattern(m_le, m_useCurrent, ScrollItemPattern.Pattern);
            if (_pattern == null)
            {
                ThrowMe(CheckType.IncorrectElementConfiguration, Helpers.PatternNotSupported + ": ScrollItemPattern");
            }

            // Find the ScrollPattern
            _container = m_le;

            while (_container != null && !(bool)_container.GetCurrentPropertyValue(AutomationElement.IsScrollPatternAvailableProperty))
            {
                _container = TreeWalker.ControlViewWalker.GetParent(_container);
            }

            // Check to see if we actual found the container of the scrollitem
            if (_container == null)
            {
                ThrowMe(CheckType.IncorrectElementConfiguration, "Element does not have a container with ScrollPattern");
            }

            Comment("Found scroll container: " + Library.GetUISpyLook(_container));

            _scrollPattern = (ScrollPattern)_container.GetCurrentPattern(ScrollPattern.Pattern) as ScrollPattern;
        }
Exemple #6
0
 protected override void CustomFixtureSetUp()
 {
     base.CustomFixtureSetUp();
     scrollPattern = (ScrollPattern)
                     listView1Element.GetCurrentPattern(ScrollPattern.Pattern);
     listItem0Element = FindItem("Item 0");
     listItem9Element = FindItem("Item 9");
 }
Exemple #7
0
 protected virtual void Scroll(ScrollAmount amount)
 {
     if (!IsScrollable)
     {
         return;
     }
     ScrollPattern.ScrollVertical(amount);
     actionListener.ActionPerformed(Action.Scroll);
 }
 protected virtual void Scroll(ScrollAmount amount)
 {
     if (!IsScrollable)
     {
         return;
     }
     ScrollPattern.ScrollHorizontal(amount);
     actionListener.ActionPerformed(Action.WindowMessage);
 }
Exemple #9
0
        internal void ScrollVertical(double verticalPercent)
        {
            ScrollPattern sp = (ScrollPattern)control.GetCurrentPattern(ScrollPattern.Pattern);

            if (sp.Current.VerticallyScrollable && sp.Current.VerticalScrollPercent != verticalPercent)
            {
                sp.SetScrollPercent(System.Windows.Automation.ScrollPattern.NoScroll, verticalPercent);
            }
        }
Exemple #10
0
 protected virtual void Scroll(ScrollAmount amount)
 {
     if (!IsScrollable)
     {
         return;
     }
     ScrollPattern.Scroll(amount, 0);
     actionListener.ActionPerformed(Action.WindowMessage);
     throw new InvalidOperationException("Verify the above, we scroll by enum value instead of actula value?");
 }
Exemple #11
0
 protected virtual void Scroll(ScrollAmount amount)
 {
     if (!IsScrollable)
     {
         return;
     }
     ScrollPattern.Scroll(0, amount);
     actionListener.ActionPerformed(Action.Scroll);
     throw new InvalidOperationException("Verifyu this (amount vs value)");
 }
Exemple #12
0
        private void ScrollIntoView(IElement container, ScrollPattern scrollbar, bool horizontally, bool increasing)
        {
            // TODO To make scrolling more efficient, make big steps in the beginning.
            var step = increasing ? ScrollAmount.SmallIncrement : ScrollAmount.SmallDecrement;

            bool done = false;

            do
            {
                // dimensions of partially displayed elements only reveal visible parts. (XAML-based only)
                int?before = horizontally ? this.Width : this.Height;
                if (horizontally)
                {
                    scrollbar.Scroll(step, ScrollAmount.NoAmount);
                }
                else
                {
                    scrollbar.Scroll(ScrollAmount.NoAmount, step);
                }

                System.Threading.Thread.Sleep(20); // or the following readings could be stale
                this.ResetCache();
                int?after = horizontally ? this.Width : this.Height;

                if (horizontally)
                {
                    if (increasing)
                    {
                        done = this.X + this.Width <= container.X + container.Width;
                    }
                    else
                    {
                        done = this.X >= container.X;
                    }
                }
                else
                {
                    if (increasing)
                    {
                        done = this.Y + this.Height <= container.Y + container.Height;
                    }
                    else
                    {
                        done = this.Y >= container.Y;
                    }
                }

                done = done && (after <= before); // leaving the element

                logger.Debug(
                    "Done? {0}; element [{1},{2}][{3},{4}] in the scrollable container [{5},{6}][{7},{8}]",
                    done, this.X, this.Y, this.Width, this.Height, container.X, container.Y, container.Width, container.Height);
            }while (!done);
        }
Exemple #13
0
        public void ScrollVertical(ScrollAmount amount, bool log)
        {
            if (log)
            {
                procedureLogger.Action(string.Format("Scroll {0} vertically..", amount.ToString()));
            }

            ScrollPattern sp = (ScrollPattern)element.GetCurrentPattern(ScrollPattern.Pattern);

            sp.ScrollVertical(amount);
        }
Exemple #14
0
        public static bool TryGetScrollPattern(this AutomationElement element, out ScrollPattern result)
        {
            if (element.TryGetCurrentPattern(System.Windows.Automation.ScrollPattern.Pattern, out var pattern))
            {
                result = (ScrollPattern)pattern;
                return(true);
            }

            result = null;
            return(false);
        }
Exemple #15
0
        public void Scroll(ScrollAmount horizontalAmount, ScrollAmount verticalAmount, bool log)
        {
            if (log)
            {
                procedureLogger.Action(string.Format("Scroll {0} horizontally and {1} vertically.",
                                                     horizontalAmount.ToString(), verticalAmount.ToString()));
            }

            ScrollPattern sp = (ScrollPattern)element.GetCurrentPattern(ScrollPattern.Pattern);

            sp.Scroll(horizontalAmount, verticalAmount);
        }
Exemple #16
0
        public void SetScrollPercent(double horizontalPercent, double verticalPercent, bool log)
        {
            if (log)
            {
                procedureLogger.Action(string.Format("Set scroll {0} percent horizontally and {1} percent vertically.",
                                                     horizontalPercent, verticalPercent));
            }

            ScrollPattern sp = (ScrollPattern)element.GetCurrentPattern(ScrollPattern.Pattern);

            sp.SetScrollPercent(horizontalPercent, verticalPercent);
        }
Exemple #17
0
        public void SetScrollPercent(double horizontalPercent, double verticalPercent, bool log)
        {
            if (log)
            {
                procedureLogger.Action(string.Format("Set {0} {1}% horizontally and {2}% vertically.",
                                                     this.NameAndType, horizontalPercent, verticalPercent));
            }

            ScrollPattern sp = (ScrollPattern)element.GetCurrentPattern(ScrollPattern.Pattern);

            sp.SetScrollPercent(horizontalPercent, verticalPercent);
        }
Exemple #18
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="atObj"></param>
 public ScrollEvents(AT atObj)
 {
     _elePara = atObj;
     try
     {
         _scrollPattern = (ScrollPattern)atObj.AutomationElement.GetCurrentPattern(ScrollPattern.Pattern);
     }
     catch (Exception)
     {
         //throw new Exception("Failed to get scrollable item.");
     }
 }
Exemple #19
0
        private double ScrollList(AutomationWrapper items, ScrollAmount amount)
        {
            ScrollPattern sp = items.AutomationElement.GetCurrentPattern(ScrollPattern.Pattern) as ScrollPattern;

            if (sp.Current.VerticallyScrollable)
            {
                sp.ScrollVertical(amount);
            }
            double percent = sp.Current.VerticalScrollPercent;

            return(percent);
        }
Exemple #20
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="elePara"></param>
 public ScrollEvents(AT elePara)
 {
     this.elePara = elePara;
     try
     {
         scrollPattern = (ScrollPattern)elePara.GetMe().GetCurrentPattern(ScrollPattern.Pattern);
     }
     catch (Exception)
     {
         //throw new Exception("Failed to get scrollable item.");
     }
 }
        // </Snippet105>

        // <Snippet1055>
        ///--------------------------------------------------------------------
        /// <summary>
        /// Obtains the current vertical and horizontal sizes of the viewable
        /// region as percentages of the total content area.
        /// </summary>
        /// <param name="scrollPattern">
        /// The ScrollPattern control pattern obtained from the
        /// element of interest.
        /// </param>
        /// <returns>
        /// The horizontal and vertical view sizes.
        /// </returns>
        ///--------------------------------------------------------------------
        private double[] GetViewSizes(ScrollPattern scrollPattern)
        {
            if (scrollPattern == null)
            {
                throw new ArgumentNullException(
                          "ScrollPattern argument cannot be null.");
            }

            double[] viewSizes = new double[2];

            viewSizes[0] =
                scrollPattern.Current.HorizontalViewSize;

            viewSizes[1] =
                scrollPattern.Current.VerticalViewSize;

            return(viewSizes);
        }
        public bool IsResourcePermissionScrollbarVisible()
        {
            UITestControl control  = _activeTab.GetChildByAutomationIDPath(_resourceGridPath);
            WpfTable      wpfTable = control as WpfTable;

            if (wpfTable != null)
            {
                AutomationElement automationElement = wpfTable.NativeElement as AutomationElement;
                if (automationElement != null)
                {
                    ScrollPattern scrollPattern = automationElement.GetCurrentPattern(ScrollPattern.Pattern) as ScrollPattern;
                    if (scrollPattern != null && scrollPattern.Current.VerticalScrollPercent >= 0)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
        // </Snippet104>

        // <Snippet1045>
        ///--------------------------------------------------------------------
        /// <summary>
        /// Obtains the current scroll positions of the viewable region
        /// within the content area.
        /// </summary>
        /// <param name="scrollPattern">
        /// The ScrollPattern control pattern obtained from the
        /// element of interest.
        /// </param>
        /// <returns>
        /// The horizontal and vertical scroll percentages.
        /// </returns>
        ///--------------------------------------------------------------------
        private double[] GetScrollPercentagesFromPattern(
            ScrollPattern scrollPattern)
        {
            if (scrollPattern == null)
            {
                throw new ArgumentNullException(
                          "ScrollPattern argument cannot be null.");
            }

            double[] percentage = new double[2];

            percentage[0] =
                scrollPattern.Current.HorizontalScrollPercent;

            percentage[1] =
                scrollPattern.Current.VerticalScrollPercent;

            return(percentage);
        }
        // </Snippet100>

        // <Snippet101>
        ///--------------------------------------------------------------------
        /// <summary>
        /// Obtains a ScrollPattern control pattern from an
        /// automation element.
        /// </summary>
        /// <param name="targetControl">
        /// The automation element of interest.
        /// </param>
        /// <returns>
        /// A ScrollPattern object.
        /// </returns>
        ///--------------------------------------------------------------------
        private ScrollPattern GetScrollPattern(
            AutomationElement targetControl)
        {
            ScrollPattern scrollPattern = null;

            try
            {
                scrollPattern =
                    targetControl.GetCurrentPattern(
                        ScrollPattern.Pattern)
                    as ScrollPattern;
            }
            // Object doesn't support the ScrollPattern control pattern
            catch (InvalidOperationException)
            {
                return(null);
            }

            return(scrollPattern);
        }
        // </Snippet107>

        // <Snippet108>
        ///--------------------------------------------------------------------
        /// <summary>
        /// Obtains a ScrollPattern control pattern from an automation
        /// element and attempts to horizontally scroll the requested amount.
        /// </summary>
        /// <param name="targetControl">
        /// The automation element of interest.
        /// </param>
        /// <param name="vScrollAmount">
        /// The requested vertical scroll amount.
        /// </param>
        ///--------------------------------------------------------------------
        private void ScrollElementVertically(
            AutomationElement targetControl,
            ScrollAmount vScrollAmount)
        {
            if (targetControl == null)
            {
                throw new ArgumentNullException(
                          "AutomationElement argument cannot be null.");
            }

            ScrollPattern scrollPattern = GetScrollPattern(targetControl);

            if (scrollPattern == null)
            {
                return;
            }

            if (!scrollPattern.Current.VerticallyScrollable)
            {
                return;
            }

            try
            {
                scrollPattern.ScrollVertical(vScrollAmount);
            }
            catch (InvalidOperationException)
            {
                // Control not able to scroll in the direction requested;
                // when scrollable property of that direction is False
                // TO DO: error handling.
            }
            catch (ArgumentException)
            {
                // If a control supports SmallIncrement values exclusively
                // for horizontal or vertical scrolling but a LargeIncrement
                // value (NaN if not supported) is passed in.
                // TO DO: error handling.
            }
        }
 public override void SetToMaximum()
 {
     ScrollPattern.SetScrollPercent(ScrollPattern.Current.HorizontalScrollPercent, 100);
 }
Exemple #27
0
 protected WpfScrollBar(AutomationElement parent)
 {
     ScrollPattern = (ScrollPattern)parent.GetCurrentPattern(ScrollPattern.Pattern);
 }
Exemple #28
0
 public ScrollPatternAxis(ScrollPattern scrollPattern, OrientationType orientation)
 {
     this.scrollPattern = scrollPattern;
     this.orientation   = orientation;
 }
        public void PatternController(AutomationPattern pat, AutomationElement selectedItem, ListView listView2)
        {
            if (pat == ScrollPattern.Pattern)
            {
                ScrollPattern scrollPattern = selectedItem.GetCurrentPattern(ScrollPattern.Pattern) as ScrollPattern;

                ListViewItem lvi = new ListViewItem();
                lvi.Content = "Scroll - not implemented";
                lvi.Tag     = new PatternInfo(1, 1, selectedItem, scrollPattern);
                listView2.Items.Add(lvi);
            }
            else if (pat == DockPattern.Pattern)
            {
                DockPattern dockPattern = selectedItem.GetCurrentPattern(DockPattern.Pattern) as DockPattern;

                ListViewItem lvi = new ListViewItem();
                lvi.Content = "SetDockPosition - not implemented";
                lvi.Tag     = new PatternInfo(2, 1, selectedItem, dockPattern);
                listView2.Items.Add(lvi);
            }
            else if (pat == ExpandCollapsePattern.Pattern)
            {
                ExpandCollapsePattern expandCollapsePattern = selectedItem.GetCurrentPattern(ExpandCollapsePattern.Pattern) as ExpandCollapsePattern;

                ListViewItem lvi1 = new ListViewItem();
                lvi1.Content = "Expand";
                lvi1.Tag     = new PatternInfo(3, 1, selectedItem, expandCollapsePattern);
                listView2.Items.Add(lvi1);

                ListViewItem lvi2 = new ListViewItem();
                lvi2.Content = "Collapse";
                lvi2.Tag     = new PatternInfo(3, 2, selectedItem, expandCollapsePattern);
                listView2.Items.Add(lvi2);
            }
            else if (pat == GridPattern.Pattern)
            {
                GridPattern gridPattern = selectedItem.GetCurrentPattern(GridPattern.Pattern) as GridPattern;

                ListViewItem lvi = new ListViewItem();
                lvi.Content = "GetItem - not implemented";
                lvi.Tag     = new PatternInfo(4, 1, selectedItem, gridPattern);
                listView2.Items.Add(lvi);
            }
            else if (pat == GridItemPattern.Pattern)
            {
            }
            else if (pat == InvokePattern.Pattern)
            {
                InvokePattern invokePattern = selectedItem.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;

                ListViewItem lvi = new ListViewItem();
                lvi.Content = "Invoke";
                lvi.Tag     = new PatternInfo(6, 1, selectedItem, invokePattern);
                listView2.Items.Add(lvi);
            }
            else if (pat == ItemContainerPattern.Pattern)
            {
            }
            else if (pat == MultipleViewPattern.Pattern)
            {
            }
            else if (pat == RangeValuePattern.Pattern)
            {
                RangeValuePattern rangeValuePattern = selectedItem.GetCurrentPattern(RangeValuePattern.Pattern) as RangeValuePattern;

                ListViewItem lvi = new ListViewItem();
                lvi.Content = "SetValue - not implemented";
                lvi.Tag     = new PatternInfo(9, 1, selectedItem, rangeValuePattern);
                listView2.Items.Add(lvi);
            }
            else if (pat == ScrollItemPattern.Pattern)
            {
            }
            else if (pat == SelectionItemPattern.Pattern)
            {
            }
            else if (pat == SelectionPattern.Pattern)
            {
            }
            else if (pat == SynchronizedInputPattern.Pattern)
            {
            }
            else if (pat == TextPattern.Pattern)
            {
            }
            else if (pat == TogglePattern.Pattern)
            {
                TogglePattern togglePattern = selectedItem.GetCurrentPattern(TogglePattern.Pattern) as TogglePattern;

                ListViewItem lvi = new ListViewItem();
                lvi.Content = "Toggle";
                lvi.Tag     = new PatternInfo(15, 1, selectedItem, togglePattern);
                listView2.Items.Add(lvi);
            }
            else if (pat == TransformPattern.Pattern)
            {
                TransformPattern transformPattern = selectedItem.GetCurrentPattern(TransformPattern.Pattern) as TransformPattern;

                ListViewItem lvi = new ListViewItem();
                lvi.Content = "Move - not implemented";
                lvi.Tag     = new PatternInfo(16, 1, selectedItem, transformPattern);
                listView2.Items.Add(lvi);

                ListViewItem lvi2 = new ListViewItem();
                lvi2.Content = "Resize - not implemented";
                lvi2.Tag     = new PatternInfo(16, 2, selectedItem, transformPattern);
                listView2.Items.Add(lvi2);

                ListViewItem lvi3 = new ListViewItem();
                lvi3.Content = "Rotate - not implemented";
                lvi3.Tag     = new PatternInfo(16, 3, selectedItem, transformPattern);
                listView2.Items.Add(lvi3);
            }
            else if (pat == ValuePattern.Pattern)
            {
                ValuePattern valuePattern = selectedItem.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern;

                ListViewItem lvi = new ListViewItem();
                lvi.Content = "setValue";
                lvi.Tag     = new PatternInfo(17, 1, selectedItem, valuePattern);
                listView2.Items.Add(lvi);
            }
            else if (pat == VirtualizedItemPattern.Pattern)
            {
            }
            else if (pat == WindowPattern.Pattern)
            {
                WindowPattern windowPattern = selectedItem.GetCurrentPattern(WindowPattern.Pattern) as WindowPattern;

                ListViewItem lvi = new ListViewItem();
                lvi.Content = "SetWindowVisualState - not implemented";
                lvi.Tag     = new PatternInfo(19, 1, selectedItem, windowPattern);
                listView2.Items.Add(lvi);
            }
            else
            {
                listView2.Items.Add("else");
            }
        }
 public override void SetToMaximum()
 {
     ScrollPattern.SetScrollPercent(100, ScrollPattern.Current.VerticalScrollPercent);
 }