//---------------------------------------------------------------------------
// Wrapper for TextPattern.RangeFromChild Method
//---------------------------------------------------------------------------
internal void Pattern_RangeFromChild(TextPattern textPattern, ref TextPatternRange returnedRange, AutomationElement childElem, Type expectedException, CheckType checkType)
{
string call = "TextPattern.RangeFromChild(" + childElem + ")";
Comment("---Calling " + call);
try
{
returnedRange = textPattern.RangeFromChild(childElem);
}
catch (Exception actualException)
{
if (Library.IsCriticalException(actualException))
throw;
if( (actualException is ArgumentException) || (actualException is InvalidOperationException))
{
// Win32 Edit Controls don't support children. InvalidOperationException here is expected
if ((TextLibrary.typeOfProvider == "win32") || (TextLibrary.typeOfProvider == "winform"))
{
if ((childElem != null) && (TextLibrary.IsRichEdit(childElem) == false))
{
// Yes, this is a hard-coded CheckType. This is by-design/a good thing
ThrowMe(CheckType.IncorrectElementConfiguration, "Win32 Edit controls do not support children");
}
}
}
TestException(expectedException, actualException, call, checkType);
return;
}
if (returnedRange == null)
ThrowMe(checkType, call + " should not give a null TextPatternRange");
TestNoExceptionQuiet(expectedException, call, checkType);
}