public void InvokeButton(AddinRibbonButton button) { if ( (button == AddinRibbonButton.Create && ! _app.IsVersion2010OrAbove() ) //2007 create button does not support invoke pattern || ! WindowsUtility.WindowsVerSupportsModalInvokeWithoutHang() ) { //Special-cases which lead to blocking modal dialog when using InvokePattern - must instead use mouse click UIAUtility.FindElementByNameFilteredByControlTypeAndMouseClick(_addinRibbonCtl, _buttonNameLookup[button], ControlType.Button, ControlType.Custom, AddinTestUtility.RibbonMouseMoveToClickDelayAllowForTooltip, TreeScope.Descendants); } else { var el = UIAUtility.FindElementByControlTypeAndNameWithTimeout(_addinRibbonCtl, ControlType.Button, ControlType.Custom, _buttonNameLookup[button], AddinTestUtility.FindRibbonButtonsTimeout, TreeScope.Descendants); UIAUtility.WaitForElementEnabledWithTimeout(el, AddinTestUtility.RibbonButtonsBecomeActivatedTimeout); UIAUtility.PressButton(el); if (button == AddinRibbonButton.Logout) { //Special case force ribbon refresh when logout button invoked ForceRibbonRefresh(); } } }
public void InvokeButton(AddinRibbonButton button) { if ((button == AddinRibbonButton.Create && !_app.IsVersion2010OrAbove()) || //2007 create button does not support invoke pattern !WindowsUtility.WindowsVerSupportsModalInvokeWithoutHang()) { //Special-cases which lead to blocking modal dialog when using InvokePattern - must instead use mouse click UIAUtility.FindElementByNameFilteredByControlTypeAndMouseClick(_addinRibbonCtl, _buttonNameLookup[button], ControlType.Button, ControlType.Custom, AddinTestUtility.RibbonMouseMoveToClickDelayAllowForTooltip, TreeScope.Descendants); } else { var el = UIAUtility.FindElementByControlTypeAndNameWithTimeout(_addinRibbonCtl, ControlType.Button, ControlType.Custom, _buttonNameLookup[button], AddinTestUtility.FindRibbonButtonsTimeout, TreeScope.Descendants); UIAUtility.WaitForElementEnabledWithTimeout(el, AddinTestUtility.RibbonButtonsBecomeActivatedTimeout); UIAUtility.PressButton(el); if (button == AddinRibbonButton.Logout) { //Special case force ribbon refresh when logout button invoked ForceRibbonRefresh(); } } }
private RibbonButtonState GetButtonStateRaw(AddinRibbonButton button) { var el = _addinRibbonCtl.FindFirst(TreeScope.Descendants, new AndCondition( new OrCondition( new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button), new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Custom)), new PropertyCondition(AutomationElement.NameProperty, _buttonNameLookup[button]))); if (el == null) { return(RibbonButtonState.NonVisible); } if (el.Current.IsEnabled) { if (el.Current.IsOffscreen) { return(RibbonButtonState.EnabledNotVisible); } return(RibbonButtonState.Enabled); } if (el.Current.IsOffscreen) { return(RibbonButtonState.NonVisible); } return(RibbonButtonState.VisibleNotEnabled); }
/// <summary> /// Determine if specified button states match, using timeout to allow for event updating /// </summary> /// <param name="button"></param> /// <param name="expectedState"></param> /// <param name="timeOutToUse"></param> /// <exception cref="">if state still does not match after timeout</exception> public void ValidateSingleButtonState(AddinRibbonButton button, RibbonButtonState expectedState, TimeSpan timeOutToUse) { RefreshRibbonPreRead(); var sw = Stopwatch.StartNew(); do { if (GetButtonStateRaw(button) == expectedState) { return; } Thread.Sleep(TimeSpan.FromMilliseconds(100)); //be cpu-friendly }while (sw.Elapsed < timeOutToUse); throw new ApplicationException("Button '" + button + "' did not get to expected state '" + expectedState + "' within " + AddinTestUtility.DialogControlEventStateUpdateTimeout.TotalSeconds + "sec"); }
/// <summary> /// Determine if specified button states match, using timeout to allow for event updating /// </summary> /// <param name="button"></param> /// <param name="expectedState"></param> /// <param name="timeOutToUse"></param> /// <exception cref="">if state still does not match after timeout</exception> public void ValidateSingleButtonState(AddinRibbonButton button, RibbonButtonState expectedState, TimeSpan timeOutToUse) { RefreshRibbonPreRead(); var sw = Stopwatch.StartNew(); do { if (GetButtonStateRaw(button) == expectedState) { return; } Thread.Sleep(TimeSpan.FromMilliseconds(100)); //be cpu-friendly } while (sw.Elapsed < timeOutToUse); throw new ApplicationException("Button '" + button + "' did not get to expected state '" + expectedState + "' within " + AddinTestUtility.DialogControlEventStateUpdateTimeout.TotalSeconds + "sec"); }
public void ValidateSingleButtonState(AddinRibbonButton button, RibbonButtonState expectedState) { ValidateSingleButtonState(button, expectedState, AddinTestUtility.RibbonButtonsBecomeActivatedTimeout); }
private RibbonButtonState GetButtonStateRaw(AddinRibbonButton button) { var el = _addinRibbonCtl.FindFirst(TreeScope.Descendants, new AndCondition( new OrCondition( new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button), new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Custom)), new PropertyCondition(AutomationElement.NameProperty, _buttonNameLookup[button]))); if (el == null) { return RibbonButtonState.NonVisible; } if (el.Current.IsEnabled) { if (el.Current.IsOffscreen) { return RibbonButtonState.EnabledNotVisible; } return RibbonButtonState.Enabled; } if (el.Current.IsOffscreen) { return RibbonButtonState.NonVisible; } return RibbonButtonState.VisibleNotEnabled; }
public RibbonButtonState GetButtonState(AddinRibbonButton button) { RefreshRibbonPreRead(); return GetButtonStateRaw(button); }
public string GetButtonName(AddinRibbonButton button) { return _buttonNameLookup[button]; }
public void ValidateSingleButtonState(AddinRibbonButton button, RibbonButtonState expectedState) { ValidateSingleButtonState(button, expectedState, AddinTestUtility.RibbonButtonsBecomeActivatedTimeout); }
public RibbonButtonState GetButtonState(AddinRibbonButton button) { RefreshRibbonPreRead(); return(GetButtonStateRaw(button)); }
public string GetButtonName(AddinRibbonButton button) { return(_buttonNameLookup[button]); }