/// -------------------------------------------------------------------
/// <summary>
/// Test that the element's enable state is the same as 'isEnabled' argument
/// </summary>
/// -------------------------------------------------------------------
internal void TS_ElementEnabled(AutomationElement element, bool isEnabled, CheckType checkType)
{
bool enabled;
if (m_useCurrent)
{
enabled = (bool)element.GetCurrentPropertyValue(AutomationElement.IsEnabledProperty);
}
else
{
enabled = (bool)element.GetCachedPropertyValue(AutomationElement.IsEnabledProperty);
}
if (enabled != isEnabled)
{
string errorStr;
// Adding switch instead of if statements since this is most likely
// an enumeration instead of a t/f such as soft focus states to be add
// later.
switch (isEnabled)
{
case true:
errorStr = "Element is not enabled and is expected to be enabled";
break;
case false:
errorStr = "Element is enabled and is expected not to be enabled";
break;
default:
throw new ArgumentException("Need to handle " + isEnabled);
}
ThrowMe(checkType, errorStr);
}
m_TestStep++;
}