Ejemplo n.º 1
0
        internal virtual void MakeVisible(VerticalSpanProvider verticalSpanProvider)
        {
            if (verticalScroll == null)
            {
                WhiteLogger.Instance.DebugFormat("Vertical scrollbar not present in parent of {0}", uiItem);
                return;
            }
            if (!verticalScroll.IsScrollable)
            {
                WhiteLogger.Instance.DebugFormat("Vertical scrollbar is not scrollable for parent of {0}", uiItem);
                return;
            }

            VerticalSpan verticalSpan = verticalSpanProvider.VerticalSpan;
            if (verticalScroll.IsNotMinimum)
            {
                verticalScroll.SetToMinimum();
                verticalSpan = verticalSpanProvider.VerticalSpan;
                WhiteLogger.Instance.DebugFormat("Scroll Position set to minimum value.");
            }

            if (verticalSpan.Contains(uiItem.Bounds))
            {
                WhiteLogger.Instance.DebugFormat("UIItem ({0}) whose bounds are ({1}) is within bounds of parent whose vertical span is {2}", uiItem,
                                                 uiItem.Bounds, verticalSpan);
                return;
            }

            WhiteLogger.Instance.DebugFormat("Trying to make visible {0}, item's bounds are {1} and parent's span is {2}", uiItem, uiItem.Bounds,
                                             verticalSpan);
            var clock = new Clock(CoreAppXmlConfiguration.Instance.BusyTimeout, 0);
            clock.RunWhile(() => verticalScroll.ScrollDownLarge(), delegate
                                                                       {
                                                                           Rect bounds = uiItem.Bounds;
                                                                           WhiteLogger.Instance.DebugFormat(
                                                                               "Trying to make     visible {0}, item's bounds are {1} and parent's span is {2}",
                                                                               uiItem, bounds, verticalSpan);
                                                                           return verticalSpan.DoesntContain(bounds);
                                                                       },
                           delegate { throw new UIActionException(string.Format("Could not make the {0} visible{1}", uiItem, Constants.BusyMessage)); });
        }
Ejemplo n.º 2
0
 public virtual void SetToMinimum()
 {
     var clock = new Clock(CoreAppXmlConfiguration.Instance.BusyTimeout, 0);
     clock.RunWhile(() => BackLargeChangeButton.PerformClick(), () => Value > 0,
         delegate { throw new UIActionException(string.Format("Could not set the ScrollBar to minimum visible{0}", Constants.BusyMessage)); });
     WhiteLogger.Instance.DebugFormat("ScrollBar position set to {0}", Value);
 }
Ejemplo n.º 3
0
 private void WaitForWindow()
 {
     try
     {
         WaitForProcess();
         var windowPattern = (WindowPattern) Pattern(WindowPattern.Pattern);
         if (!CoreAppXmlConfiguration.Instance.InProc &&
             !("ConsoleWindowClass".Equals(automationElement.Current.ClassName)) &&
             (windowPattern != null &&
              !windowPattern.WaitForInputIdle(CoreAppXmlConfiguration.Instance.BusyTimeout)))
             throw new Exception(string.Format("Timeout occured{0}", Constants.BusyMessage));
         if (windowPattern == null) return;
         var clock = new Clock(CoreAppXmlConfiguration.Instance.BusyTimeout, 0);
         clock.RunWhile(() => Thread.Sleep(50),
                        () =>
                        windowPattern.Current.WindowInteractionState.Equals(WindowInteractionState.NotResponding),
                        delegate
                            {
                                throw new UIActionException(
                                    string.Format(
                                        "Window didn't come out of WaitState{0} last state known was {1}",
                                        Constants.BusyMessage, windowPattern.Current.WindowInteractionState));
                            });
     }
     catch (Exception e)
     {
         if (!(e is InvalidOperationException || e is ElementNotAvailableException))
             throw new UIActionException(string.Format("Window didn't respond" + Constants.BusyMessage), e);
     }
 }