in dev/ScrollPresenter/InteractionTests/ScrollPresenterTestsWithInputHelper.cs [762:902]
private void OverpanWithAnchoredSkrinkingContent(bool isForHorizontalDirection)
{
if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5))
{
Log.Warning("This test relies on touch input, the injection of which is only supported in RS5 and up. Test is disabled.");
return;
}
Log.Comment("Selecting ScrollPresenter tests");
using (var setup = new TestSetupHelper("ScrollPresenter Tests"))
{
SetOutputDebugStringLevel("Verbose");
GoToSimpleContentsPage();
SetLoggingLevel(isPrivateLoggingEnabled: true);
Log.Comment("Retrieving cmbShowScrollPresenter");
ComboBox cmbShowScrollPresenter = new ComboBox(FindElement.ByName("cmbShowScrollPresenter"));
Log.Comment("Changing ScrollPresenter selection to scrollPresenter51");
cmbShowScrollPresenter.SelectItemByName("scrollPresenter51");
Log.Comment("Selection is now {0}", cmbShowScrollPresenter.Selection[0].Name);
Log.Comment("Retrieving ScrollPresenter");
UIObject scrollPresenter51UIObject = FindElement.ByName("ScrollPresenter51");
Verify.IsNotNull(scrollPresenter51UIObject, "Verifying that ScrollPresenter was found");
WaitForScrollPresenterFinalSize(scrollPresenter51UIObject, expectedWidth: 300.0, expectedHeight: 400.0);
// Tapping button before attempting pan operation to guarantee effective touch input
TapResetViewsButton();
Log.Comment("Panning ScrollPresenter close to the Content's end");
PrepareForScrollPresenterManipulationStart("scrollPresenter51");
Point startPoint = isForHorizontalDirection ?
new Point(scrollPresenter51UIObject.BoundingRectangle.Left + 105, scrollPresenter51UIObject.BoundingRectangle.Top + 100) :
new Point(scrollPresenter51UIObject.BoundingRectangle.Left + 100, scrollPresenter51UIObject.BoundingRectangle.Top + 100);
Point endPoint = isForHorizontalDirection ?
new Point(scrollPresenter51UIObject.BoundingRectangle.Left + 50, scrollPresenter51UIObject.BoundingRectangle.Top + 100) :
new Point(scrollPresenter51UIObject.BoundingRectangle.Left + 100, scrollPresenter51UIObject.BoundingRectangle.Top + 50);
InputHelper.Pan(obj: scrollPresenter51UIObject, start: startPoint, end: endPoint);
Log.Comment("Waiting for scrollPresenter51 pan completion");
bool success = WaitForManipulationEnd("scrollPresenter51", "txtScrollPresenterState");
ScrollPresenter scrollPresenter51 = new ScrollPresenter(scrollPresenter51UIObject);
Log.Comment("scrollPresenter51.HorizontalScrollPercent={0}", scrollPresenter51.HorizontalScrollPercent);
Log.Comment("scrollPresenter51.VerticalScrollPercent={0}", scrollPresenter51.VerticalScrollPercent);
// No layout offset is expected
double contentLayoutOffsetX = 0.0;
double contentLayoutOffsetY = 0.0;
GetScrollPresenterContentLayoutOffset(out contentLayoutOffsetX, out contentLayoutOffsetY);
if (!success ||
(isForHorizontalDirection && (scrollPresenter51.HorizontalScrollPercent == 0.0 || scrollPresenter51.HorizontalScrollPercent == 100.0)) ||
(isForHorizontalDirection && scrollPresenter51.VerticalScrollPercent != 0.0) ||
(!isForHorizontalDirection && scrollPresenter51.HorizontalScrollPercent != 0.0) ||
(!isForHorizontalDirection && (scrollPresenter51.VerticalScrollPercent == 0.0 || scrollPresenter51.VerticalScrollPercent == 100.0)) ||
contentLayoutOffsetX != 0.0 ||
contentLayoutOffsetY != 0.0)
{
LogAndClearTraces(recordWarning: false);
}
Log.Comment("Overpan ScrollPresenter to trigger content shrinkage");
PrepareForScrollPresenterManipulationStart("scrollPresenter51");
startPoint = isForHorizontalDirection ?
new Point(scrollPresenter51UIObject.BoundingRectangle.Left + 240, scrollPresenter51UIObject.BoundingRectangle.Top + 100) :
new Point(scrollPresenter51UIObject.BoundingRectangle.Left + 100, scrollPresenter51UIObject.BoundingRectangle.Top + 240);
endPoint = isForHorizontalDirection ?
new Point(scrollPresenter51UIObject.BoundingRectangle.Left + 10, scrollPresenter51UIObject.BoundingRectangle.Top + 100) :
new Point(scrollPresenter51UIObject.BoundingRectangle.Left + 100, scrollPresenter51UIObject.BoundingRectangle.Top + 10);
InputHelper.Pan(obj: scrollPresenter51UIObject, start: startPoint, end: endPoint);
Log.Comment("Waiting for scrollPresenter51 pan completion");
success = WaitForManipulationEnd("scrollPresenter51", "txtScrollPresenterState");
Log.Comment("scrollPresenter51.HorizontalScrollPercent={0}", scrollPresenter51.HorizontalScrollPercent);
Log.Comment("scrollPresenter51.VerticalScrollPercent={0}", scrollPresenter51.VerticalScrollPercent);
// Layout offset is expected
GetScrollPresenterContentLayoutOffset(out contentLayoutOffsetX, out contentLayoutOffsetY);
if (!success ||
(isForHorizontalDirection && scrollPresenter51.HorizontalScrollPercent != 100.0) ||
(isForHorizontalDirection && scrollPresenter51.VerticalScrollPercent != 0.0) ||
(!isForHorizontalDirection && scrollPresenter51.HorizontalScrollPercent != 0.0) ||
(!isForHorizontalDirection && scrollPresenter51.VerticalScrollPercent != 100.0) ||
(isForHorizontalDirection && contentLayoutOffsetX != 30.0) ||
(isForHorizontalDirection && contentLayoutOffsetY != 0.0) ||
(!isForHorizontalDirection && contentLayoutOffsetX != 0.0) ||
(!isForHorizontalDirection && contentLayoutOffsetY != 40.0))
{
LogAndClearTraces(recordWarning: false);
}
SetLoggingLevel(isPrivateLoggingEnabled: false);
Verify.AreEqual(scrollPresenter51.HorizontalScrollPercent, isForHorizontalDirection ? 100.0 : 0.0, "Verifying scrollPresenter51 HorizontalScrollPercent");
Verify.AreEqual(scrollPresenter51.VerticalScrollPercent, isForHorizontalDirection ? 0.0 : 100.0, "Verifying scrollPresenter51 VerticalScrollPercent");
double horizontalOffset;
double verticalOffset;
float zoomFactor;
GetScrollPresenterView(out horizontalOffset, out verticalOffset, out zoomFactor);
Log.Comment("horizontalOffset={0}", horizontalOffset);
Log.Comment("verticalOffset={0}", verticalOffset);
Log.Comment("zoomFactor={0}", zoomFactor);
if (isForHorizontalDirection)
{
Verify.AreEqual(contentLayoutOffsetX, 30.0, "Verifying contentLayoutOffsetX is 30.0");
Verify.AreEqual(contentLayoutOffsetY, 0.0, "Verifying contentLayoutOffsetY is 0.0");
Verify.AreEqual(horizontalOffset, 470.0, "Verifying horizontalOffset is 470.0");
Verify.AreEqual(verticalOffset, 0.0, "Verifying verticalOffset is 0.0");
}
else
{
Verify.AreEqual(contentLayoutOffsetX, 0.0, "Verifying contentLayoutOffsetX is 0.0");
Verify.AreEqual(contentLayoutOffsetY, 40.0, "Verifying contentLayoutOffsetY is 40.0");
Verify.AreEqual(horizontalOffset, 0.0, "Verifying horizontalOffset is 0.0");
Verify.AreEqual(verticalOffset, 360.0, "Verifying verticalOffset is 360.0");
}
Verify.AreEqual(zoomFactor, 1.0f, "Verifying zoomFactor is 1.0f");
Log.Comment("Returning to the main ScrollPresenter test page");
TestSetupHelper.GoBack();
// Output-debug-string-level "None" is automatically restored when landing back on the ScrollPresenter test page.
}
}