/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
class APZCFlingAccelerationTester : public APZCTreeManagerTester { protected: void SetUp() {
APZCTreeManagerTester::SetUp(); constchar* treeShape = "x";
LayerIntRect layerVisibleRect[] = {
LayerIntRect(0, 0, 800, 1000),
};
CreateScrollData(treeShape, layerVisibleRect);
SetScrollableFrameMetrics(root, ScrollableLayerGuid::START_SCROLL_ID,
CSSRect(0, 0, 800, 50000)); // Scroll somewhere into the middle of the scroll range, so that we have // lots of space to scroll in both directions.
ModifyFrameMetrics(root, [](ScrollMetadata& aSm, FrameMetrics& aMetrics) {
aMetrics.SetVisualScrollUpdateType(
FrameMetrics::ScrollOffsetUpdateType::eMainThread);
aMetrics.SetVisualDestination(CSSPoint(0, 25000));
});
// Allowed touch behaviours must be set after sending touch-start. if (result.GetStatus() != nsEventStatus_eConsumeNoDefault) {
SetDefaultAllowedTouchBehavior(apzc, result.mInputBlockId);
}
// This is a macro so that the assertions print useful line numbers. #define CHECK_VELOCITY(aUpOrDown, aLowerBound, aUpperBound) \ do { \ auto vel = apzc->GetVelocityVector(); \ if (UpOrDown::aUpOrDown == UpOrDown::Up) { \
EXPECT_LT(vel.y, 0.0); \
} else { \
EXPECT_GT(vel.y, 0.0); \
} \
EXPECT_GE(vel.Length(), aLowerBound); \
EXPECT_LE(vel.Length(), aUpperBound); \
} while (0)
// These tests have the following pattern: Two flings are executed, with a bit // of wait time in between. The deltas in each pan gesture have been captured // from a real phone, from touch events triggered by real fingers. // We check the velocity at the end to detect whether the fling was accelerated // or not. As an additional safety precaution, we also check the velocities for // the first fling, so that changes in behavior are easier to analyze. // One added challenge of this test is the fact that it has to work with on // multiple platforms, and we use different velocity estimation strategies and // different fling physics depending on the platform. // The upper and lower bounds for the velocities were chosen in such a way that // the test passes on all platforms. At the time of writing, we usually end up // with higher velocities on Android than on Desktop, so the observed velocities // on Android became the upper bounds and the observed velocities on Desktop // becaume the lower bounds, each rounded out to a multiple of 0.1.
TEST_F(APZCFlingAccelerationTester,
ShouldAccelerateAfterLongWaitIfVelocityStillHigh) { // Reduce friction with the "Desktop" fling physics a little, so that it // behaves more similarly to the Android fling physics, and has enough // velocity after the wait time to allow for acceleration.
SCOPED_GFX_PREF_FLOAT("apz.fling_friction", 0.0012);
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.