auto childBounds = xChildComponent->getBounds(); if (childBounds.X == -1) continue;
std::cout << " bounds: " << childBounds.Width << "x" << childBounds.Height << std::showpos
<< childBounds.X << childBounds.Y << std::noshowpos << std::endl;
std::cout << "finding the point which lies on the component" << std::endl; int curX = 0; int curY = 0; while (!xChildComponent->containsPoint(awt::Point(curX, curY)) && curX < childBounds.Width)
{
curX++;
curY++;
} if (curX >= childBounds.Width)
{
std::cout << "Couldn't find a point with contains" << std::endl; continue;
} else
{
std::cout << "Child found at point +" << childBounds.X + curX << "+"
<< childBounds.Y + curY << std::endl;
}
// trying the point laying on child auto xAccAtPoint
= mxComponent->getAccessibleAtPoint(awt::Point(childBounds.X, childBounds.Y));
CPPUNIT_ASSERT_MESSAGE("Child not found at point", xAccAtPoint.is()); if (!AccessibilityTools::equals(child, xAccAtPoint))
{
std::cout << "The child found (" << AccessibilityTools::debugString(xAccAtPoint)
<< ") is not the expected one (" << AccessibilityTools::debugString(child)
<< ")" << std::endl;
constbool bDirectChild
= xAccAtPoint->getAccessibleContext()->getAccessibleParent()->getAccessibleContext()
== mxContext;
CPPUNIT_ASSERT_MESSAGE("Accessible returned by " "XAccessibleComponent::getAccessibleAtPoint has different " "parent",
bDirectChild);
css::uno::Reference<css::accessibility::XAccessibleComponent> xComponentAtPoint(
xAccAtPoint->getAccessibleContext(), css::uno::UNO_QUERY_THROW); constbool bContainsPoint
= vcl::unohelper::ConvertToVCLRect(xComponentAtPoint->getBounds())
.Contains(Point(childBounds.X, childBounds.Y));
CPPUNIT_ASSERT_MESSAGE("Accessible returned by " "XAccessibleComponent::getAccessibleAtPoint doesn't contain the " "point",
bContainsPoint);
if (bContainsPoint)
{
std::cout << "-- it probably is hidden behind? Skipping." << std::endl;
} else
{
CPPUNIT_ASSERT_EQUAL_MESSAGE("The child found is NOT the expected one", child,
xAccAtPoint);
}
}
// trying the point NOT laying on child
xAccAtPoint
= mxComponent->getAccessibleAtPoint(awt::Point(childBounds.X - 1, childBounds.Y - 1)); if (xAccAtPoint.is())
{
CPPUNIT_ASSERT_MESSAGE("Child found OUTSIDE its bounds",
!AccessibilityTools::equals(child, xAccAtPoint));
}
}
}
/** *@briefTestsresultsofXAccessibleComponent::getLocation() * *Succeedsifthelocationisthesameaslocationofboundaryobtainedby *the<code>getBounds()</code>method.
*/ void XAccessibleComponentTester::testLocation()
{ auto bounds = mxComponent->getBounds(); auto location = mxComponent->getLocation();
CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid X location", bounds.X, location.X);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid Y location", bounds.Y, location.Y);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.