Bug 1163845 - Unify handling of time in APZ gtests. r=kats

--HG--
extra : rebase_source : f7b50c31bc39ed0a2d2d26250a0dc36355c0cf05
extra : source : 64cabb256acb8b30e4d67f78e94b8f6187e0e58d
This commit is contained in:
Botond Ballo 2015-05-15 12:45:27 -04:00
Родитель 4ca85adc7e
Коммит 0fd5163a65
4 изменённых файлов: 175 добавлений и 187 удалений

Просмотреть файл

@ -382,18 +382,13 @@ static inline void LogRendertraceRect(const ScrollableLayerGuid& aGuid, const ch
#endif
}
static TimeStamp sFrameTime;
// Counter used to give each APZC a unique id
static uint32_t sAsyncPanZoomControllerCount = 0;
TimeStamp
AsyncPanZoomController::GetFrameTime()
AsyncPanZoomController::GetFrameTime() const
{
if (sFrameTime.IsNull()) {
return TimeStamp::Now();
}
return sFrameTime;
return TimeStamp::Now();
}
class MOZ_STACK_CLASS StateChangeNotificationBlocker {
@ -432,7 +427,7 @@ public:
, mOverscrollHandoffChain(aOverscrollHandoffChain)
{
MOZ_ASSERT(mOverscrollHandoffChain);
TimeStamp now = AsyncPanZoomController::GetFrameTime();
TimeStamp now = aApzc.GetFrameTime();
// Drop any velocity on axes where we don't have room to scroll anyways
// (in this APZC, or an APZC further in the handoff chain).
@ -775,11 +770,6 @@ private:
AxisPhysicsMSDModel mXAxisModel, mYAxisModel;
};
void
AsyncPanZoomController::SetFrameTime(const TimeStamp& aTime) {
sFrameTime = aTime;
}
/*static*/ void
AsyncPanZoomController::InitializeGlobalState()
{

Просмотреть файл

@ -377,9 +377,15 @@ public:
void NotifyMozMouseScrollEvent(const nsString& aString) const;
protected:
// These functions are protected virtual so test code can override them.
// Returns the cached current frame time.
virtual TimeStamp GetFrameTime() const;
protected:
// Protected destructor, to discourage deletion outside of Release():
~AsyncPanZoomController();
virtual ~AsyncPanZoomController();
/**
* Helper method for touches beginning. Sets everything up for panning and any
@ -845,9 +851,6 @@ private:
friend class SmoothScrollAnimation;
friend class WheelScrollAnimation;
// Returns the cached current frame time.
static TimeStamp GetFrameTime();
// The initial velocity of the most recent fling.
ParentLayerPoint mLastFlingVelocity;
// The time at which the most recent fling started.
@ -1054,12 +1057,6 @@ private:
* and assertion purposes only.
*/
public:
/**
* Sync panning and zooming animation using a fixed frame time.
* This will ensure that we animate the APZC correctly with other external
* animations to the same timestamp.
*/
static void SetFrameTime(const TimeStamp& aMilliseconds);
/**
* Set an extra offset for testing async scrolling.
*/

Просмотреть файл

@ -36,7 +36,7 @@ WheelScrollAnimation::Update(TimeStamp aTime, nsPoint aDelta, const nsSize& aCur
bool
WheelScrollAnimation::DoSample(FrameMetrics& aFrameMetrics, const TimeDuration& aDelta)
{
TimeStamp now = AsyncPanZoomController::GetFrameTime();
TimeStamp now = mApzc.GetFrameTime();
CSSToParentLayerScale2D zoom = aFrameMetrics.GetZoom();
// If the animation is finished, make sure the final position is correct by

Просмотреть файл

@ -124,21 +124,27 @@ private:
class TestAPZCTreeManager : public APZCTreeManager {
public:
explicit TestAPZCTreeManager(TimeStamp& aTime) : mTime(aTime) {}
nsRefPtr<InputQueue> GetInputQueue() const {
return mInputQueue;
}
protected:
AsyncPanZoomController* MakeAPZCInstance(uint64_t aLayersId, GeckoContentController* aController) override;
private:
TimeStamp& mTime;
};
class TestAsyncPanZoomController : public AsyncPanZoomController {
public:
TestAsyncPanZoomController(uint64_t aLayersId, GeckoContentController* aMcc,
TestAPZCTreeManager* aTreeManager,
TimeStamp& aTime,
GestureBehavior aBehavior = DEFAULT_GESTURES)
: AsyncPanZoomController(aLayersId, aTreeManager, aTreeManager->GetInputQueue(), aMcc, aBehavior)
, mWaitForMainThread(false)
, mTime(aTime)
{}
nsEventStatus ReceiveInputEvent(const InputData& aEvent, ScrollableLayerGuid* aDummy, uint64_t* aOutInputBlockId) {
@ -211,14 +217,25 @@ public:
mWaitForMainThread = true;
}
TimeStamp GetFrameTime() const {
return mTime;
}
static TimeStamp GetStartupTime() {
static TimeStamp sStartupTime = TimeStamp::Now();
return sStartupTime;
}
private:
bool mWaitForMainThread;
TimeStamp& mTime;
};
AsyncPanZoomController*
TestAPZCTreeManager::MakeAPZCInstance(uint64_t aLayersId, GeckoContentController* aController)
{
return new TestAsyncPanZoomController(aLayersId, aController, this, AsyncPanZoomController::USE_GESTURE_DETECTOR);
return new TestAsyncPanZoomController(aLayersId, aController, this,
mTime, AsyncPanZoomController::USE_GESTURE_DETECTOR);
}
static FrameMetrics
@ -248,12 +265,11 @@ protected:
APZThreadUtils::SetThreadAssertionsEnabled(false);
APZThreadUtils::SetControllerThread(MessageLoop::current());
testStartTime = TimeStamp::Now();
AsyncPanZoomController::SetFrameTime(testStartTime);
mTime = TimeStamp::Now();
mcc = new NiceMock<MockContentControllerDelayed>();
tm = new TestAPZCTreeManager();
apzc = new TestAsyncPanZoomController(0, mcc, tm, mGestureBehavior);
tm = new TestAPZCTreeManager(mTime);
apzc = new TestAsyncPanZoomController(0, mcc, tm, mTime, mGestureBehavior);
apzc->SetFrameMetrics(TestFrameMetrics());
}
@ -288,7 +304,7 @@ protected:
apzc->UpdateZoomConstraints(ZoomConstraints(false, false, CSSToParentLayerScale(1.0f), CSSToParentLayerScale(1.0f)));
}
void PanIntoOverscroll(int& aTime);
void PanIntoOverscroll();
/**
* Sample animations once, 1 ms later than the last sample.
@ -298,8 +314,8 @@ protected:
const TimeDuration increment = TimeDuration::FromMilliseconds(1);
ParentLayerPoint pointOut;
ViewTransform viewTransformOut;
testStartTime += increment;
apzc->SampleContentTransformForFrame(testStartTime, &viewTransformOut, pointOut);
mTime += increment;
apzc->SampleContentTransformForFrame(mTime, &viewTransformOut, pointOut);
}
/**
@ -313,7 +329,7 @@ protected:
bool recoveredFromOverscroll = false;
ParentLayerPoint pointOut;
ViewTransform viewTransformOut;
while (apzc->SampleContentTransformForFrame(testStartTime, &viewTransformOut, pointOut)) {
while (apzc->SampleContentTransformForFrame(mTime, &viewTransformOut, pointOut)) {
// The reported scroll offset should be the same throughout.
EXPECT_EQ(aExpectedScrollOffset, pointOut);
@ -325,7 +341,7 @@ protected:
recoveredFromOverscroll = true;
}
testStartTime += increment;
mTime += increment;
}
EXPECT_TRUE(recoveredFromOverscroll);
apzc->AssertStateIsReset();
@ -334,7 +350,7 @@ protected:
void TestOverscroll();
AsyncPanZoomController::GestureBehavior mGestureBehavior;
TimeStamp testStartTime;
TimeStamp mTime;
nsRefPtr<MockContentControllerDelayed> mcc;
nsRefPtr<TestAPZCTreeManager> tm;
nsRefPtr<TestAsyncPanZoomController> apzc;
@ -399,32 +415,45 @@ SetDefaultAllowedTouchBehavior(const nsRefPtr<InputReceiver>& aTarget,
aTarget->SetAllowedTouchBehavior(aInputBlockId, defaultBehaviors);
}
template<class InputReceiver> static nsEventStatus
TouchDown(const nsRefPtr<InputReceiver>& aTarget, int aX, int aY, int aTime, uint64_t* aOutInputBlockId = nullptr)
static uint32_t
MillisecondsSinceStartup(TimeStamp aTime)
{
MultiTouchInput mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_START, aTime, TimeStamp(), 0);
return (aTime - TestAsyncPanZoomController::GetStartupTime()).ToMilliseconds();
}
static MultiTouchInput
CreateMultiTouchInput(MultiTouchInput::MultiTouchType aType, TimeStamp aTime)
{
return MultiTouchInput(aType, MillisecondsSinceStartup(aTime), aTime, 0);
}
template<class InputReceiver> static nsEventStatus
TouchDown(const nsRefPtr<InputReceiver>& aTarget, int aX, int aY, TimeStamp aTime, uint64_t* aOutInputBlockId = nullptr)
{
MultiTouchInput mti = CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_START, aTime);
mti.mTouches.AppendElement(CreateSingleTouchData(0, aX, aY));
return aTarget->ReceiveInputEvent(mti, nullptr, aOutInputBlockId);
}
template<class InputReceiver> static nsEventStatus
TouchMove(const nsRefPtr<InputReceiver>& aTarget, int aX, int aY, int aTime)
TouchMove(const nsRefPtr<InputReceiver>& aTarget, int aX, int aY, TimeStamp aTime)
{
MultiTouchInput mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, aTime, TimeStamp(), 0);
MultiTouchInput mti = CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, aTime);
mti.mTouches.AppendElement(CreateSingleTouchData(0, aX, aY));
return aTarget->ReceiveInputEvent(mti, nullptr, nullptr);
}
template<class InputReceiver> static nsEventStatus
TouchUp(const nsRefPtr<InputReceiver>& aTarget, int aX, int aY, int aTime)
TouchUp(const nsRefPtr<InputReceiver>& aTarget, int aX, int aY, TimeStamp aTime)
{
MultiTouchInput mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_END, aTime, TimeStamp(), 0);
MultiTouchInput mti = CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_END, aTime);
mti.mTouches.AppendElement(CreateSingleTouchData(0, aX, aY));
return aTarget->ReceiveInputEvent(mti, nullptr, nullptr);
}
template<class InputReceiver> static void
Tap(const nsRefPtr<InputReceiver>& aTarget, int aX, int aY, int& aTime, int aTapLength,
Tap(const nsRefPtr<InputReceiver>& aTarget, int aX, int aY, TimeStamp& aTime,
TimeDuration aTapLength,
nsEventStatus (*aOutEventStatuses)[2] = nullptr,
uint64_t* aOutInputBlockId = nullptr)
{
@ -454,7 +483,8 @@ Tap(const nsRefPtr<InputReceiver>& aTarget, int aX, int aY, int& aTime, int aTap
}
template<class InputReceiver> static void
TapAndCheckStatus(const nsRefPtr<InputReceiver>& aTarget, int aX, int aY, int& aTime, int aTapLength)
TapAndCheckStatus(const nsRefPtr<InputReceiver>& aTarget, int aX, int aY,
TimeStamp& aTime, TimeDuration aTapLength)
{
nsEventStatus statuses[2];
Tap(aTarget, aX, aY, aTime, aTapLength, &statuses);
@ -464,7 +494,7 @@ TapAndCheckStatus(const nsRefPtr<InputReceiver>& aTarget, int aX, int aY, int& a
template<class InputReceiver> static void
Pan(const nsRefPtr<InputReceiver>& aTarget,
int& aTime,
TimeStamp& aTime,
int aTouchStartY,
int aTouchEndY,
bool aKeepFingerDown = false,
@ -479,7 +509,7 @@ Pan(const nsRefPtr<InputReceiver>& aTarget,
gfxPrefs::SetAPZTouchStartTolerance(1.0f / 1000.0f);
const int OVERCOME_TOUCH_TOLERANCE = 1;
const int TIME_BETWEEN_TOUCH_EVENT = 100;
const TimeDuration TIME_BETWEEN_TOUCH_EVENT = TimeDuration::FromMilliseconds(100);
// Even if the caller doesn't care about the block id, we need it to set the
// allowed touch behaviour below, so make sure aOutInputBlockId is non-null.
@ -529,7 +559,9 @@ Pan(const nsRefPtr<InputReceiver>& aTarget,
(*aOutEventStatuses)[3] = status;
}
aTime += TIME_BETWEEN_TOUCH_EVENT;
// Don't increment the time here. Animations started on touch-up, such as
// flings, are affected by elapsed time, and we want to be able to sample
// them immediately after they start, without time having elapsed.
}
/*
@ -538,7 +570,7 @@ Pan(const nsRefPtr<InputReceiver>& aTarget,
*/
template<class InputReceiver> static void
PanAndCheckStatus(const nsRefPtr<InputReceiver>& aTarget,
int& aTime,
TimeStamp& aTime,
int aTouchStartY,
int aTouchEndY,
bool aExpectConsumed,
@ -562,7 +594,7 @@ PanAndCheckStatus(const nsRefPtr<InputReceiver>& aTarget,
static void
ApzcPanNoFling(const nsRefPtr<TestAsyncPanZoomController>& aApzc,
int& aTime,
TimeStamp& aTime,
int aTouchStartY,
int aTouchEndY,
uint64_t* aOutInputBlockId = nullptr)
@ -877,7 +909,7 @@ TEST_F(APZCBasicTester, Overzoom) {
TEST_F(APZCBasicTester, SimpleTransform) {
ParentLayerPoint pointOut;
ViewTransform viewTransformOut;
apzc->SampleContentTransformForFrame(testStartTime, &viewTransformOut, pointOut);
apzc->SampleContentTransformForFrame(mTime, &viewTransformOut, pointOut);
EXPECT_EQ(ParentLayerPoint(), pointOut);
EXPECT_EQ(ViewTransform(), viewTransformOut);
@ -900,7 +932,8 @@ TEST_F(APZCBasicTester, ComplexTransform) {
// CSS pixels). The displayport is 1 extra CSS pixel on all
// sides.
nsRefPtr<TestAsyncPanZoomController> childApzc = new TestAsyncPanZoomController(0, mcc, tm);
nsRefPtr<TestAsyncPanZoomController> childApzc =
new TestAsyncPanZoomController(0, mcc, tm, mTime);
const char* layerTreeSyntax = "c(c)";
// LayerID 0 1
@ -945,39 +978,39 @@ TEST_F(APZCBasicTester, ComplexTransform) {
// initial transform
apzc->SetFrameMetrics(metrics);
apzc->NotifyLayersUpdated(metrics, true);
apzc->SampleContentTransformForFrame(testStartTime, &viewTransformOut, pointOut);
apzc->SampleContentTransformForFrame(mTime, &viewTransformOut, pointOut);
EXPECT_EQ(ViewTransform(LayerToParentLayerScale(1), ParentLayerPoint()), viewTransformOut);
EXPECT_EQ(ParentLayerPoint(60, 60), pointOut);
childApzc->SetFrameMetrics(childMetrics);
childApzc->NotifyLayersUpdated(childMetrics, true);
childApzc->SampleContentTransformForFrame(testStartTime, &viewTransformOut, pointOut);
childApzc->SampleContentTransformForFrame(mTime, &viewTransformOut, pointOut);
EXPECT_EQ(ViewTransform(LayerToParentLayerScale(1), ParentLayerPoint()), viewTransformOut);
EXPECT_EQ(ParentLayerPoint(60, 60), pointOut);
// do an async scroll by 5 pixels and check the transform
metrics.ScrollBy(CSSPoint(5, 0));
apzc->SetFrameMetrics(metrics);
apzc->SampleContentTransformForFrame(testStartTime, &viewTransformOut, pointOut);
apzc->SampleContentTransformForFrame(mTime, &viewTransformOut, pointOut);
EXPECT_EQ(ViewTransform(LayerToParentLayerScale(1), ParentLayerPoint(-30, 0)), viewTransformOut);
EXPECT_EQ(ParentLayerPoint(90, 60), pointOut);
childMetrics.ScrollBy(CSSPoint(5, 0));
childApzc->SetFrameMetrics(childMetrics);
childApzc->SampleContentTransformForFrame(testStartTime, &viewTransformOut, pointOut);
childApzc->SampleContentTransformForFrame(mTime, &viewTransformOut, pointOut);
EXPECT_EQ(ViewTransform(LayerToParentLayerScale(1), ParentLayerPoint(-30, 0)), viewTransformOut);
EXPECT_EQ(ParentLayerPoint(90, 60), pointOut);
// do an async zoom of 1.5x and check the transform
metrics.ZoomBy(1.5f);
apzc->SetFrameMetrics(metrics);
apzc->SampleContentTransformForFrame(testStartTime, &viewTransformOut, pointOut);
apzc->SampleContentTransformForFrame(mTime, &viewTransformOut, pointOut);
EXPECT_EQ(ViewTransform(LayerToParentLayerScale(1.5), ParentLayerPoint(-45, 0)), viewTransformOut);
EXPECT_EQ(ParentLayerPoint(135, 90), pointOut);
childMetrics.ZoomBy(1.5f);
childApzc->SetFrameMetrics(childMetrics);
childApzc->SampleContentTransformForFrame(testStartTime, &viewTransformOut, pointOut);
childApzc->SampleContentTransformForFrame(mTime, &viewTransformOut, pointOut);
EXPECT_EQ(ViewTransform(LayerToParentLayerScale(1.5), ParentLayerPoint(-45, 0)), viewTransformOut);
EXPECT_EQ(ParentLayerPoint(135, 90), pointOut);
@ -996,7 +1029,6 @@ protected:
EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(0);
}
int time = 0;
int touchStart = 50;
int touchEnd = 10;
ParentLayerPoint pointOut;
@ -1006,8 +1038,8 @@ protected:
allowedTouchBehaviors.AppendElement(aBehavior);
// Pan down
PanAndCheckStatus(apzc, time, touchStart, touchEnd, aShouldBeConsumed, &allowedTouchBehaviors);
apzc->SampleContentTransformForFrame(testStartTime, &viewTransformOut, pointOut);
PanAndCheckStatus(apzc, mTime, touchStart, touchEnd, aShouldBeConsumed, &allowedTouchBehaviors);
apzc->SampleContentTransformForFrame(mTime, &viewTransformOut, pointOut);
if (aShouldTriggerScroll) {
EXPECT_EQ(ParentLayerPoint(0, -(touchEnd-touchStart)), pointOut);
@ -1022,8 +1054,8 @@ protected:
apzc->CancelAnimation();
// Pan back
PanAndCheckStatus(apzc, time, touchEnd, touchStart, aShouldBeConsumed, &allowedTouchBehaviors);
apzc->SampleContentTransformForFrame(testStartTime, &viewTransformOut, pointOut);
PanAndCheckStatus(apzc, mTime, touchEnd, touchStart, aShouldBeConsumed, &allowedTouchBehaviors);
apzc->SampleContentTransformForFrame(mTime, &viewTransformOut, pointOut);
EXPECT_EQ(ParentLayerPoint(), pointOut);
EXPECT_EQ(ViewTransform(), viewTransformOut);
@ -1033,7 +1065,6 @@ protected:
{
MakeApzcWaitForMainThread();
int time = 0;
int touchStart = 50;
int touchEnd = 10;
ParentLayerPoint pointOut;
@ -1043,7 +1074,7 @@ protected:
// Pan down
nsTArray<uint32_t> allowedTouchBehaviors;
allowedTouchBehaviors.AppendElement(mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN);
PanAndCheckStatus(apzc, time, touchStart, touchEnd, true, &allowedTouchBehaviors, &blockId);
PanAndCheckStatus(apzc, mTime, touchStart, touchEnd, true, &allowedTouchBehaviors, &blockId);
// Send the signal that content has handled and preventDefaulted the touch
// events. This flushes the event queue.
@ -1052,7 +1083,7 @@ protected:
// prevent-default timer).
EXPECT_LE(1, mcc->RunThroughDelayedTasks());
apzc->SampleContentTransformForFrame(testStartTime, &viewTransformOut, pointOut);
apzc->SampleContentTransformForFrame(mTime, &viewTransformOut, pointOut);
EXPECT_EQ(ParentLayerPoint(), pointOut);
EXPECT_EQ(ViewTransform(), viewTransformOut);
@ -1108,17 +1139,16 @@ TEST_F(APZCBasicTester, Fling) {
EXPECT_CALL(*mcc, SendAsyncScrollDOMEvent(_,_,_)).Times(AtLeast(1));
EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(1);
int time = 0;
int touchStart = 50;
int touchEnd = 10;
ParentLayerPoint pointOut;
ViewTransform viewTransformOut;
// Fling down. Each step scroll further down
Pan(apzc, time, touchStart, touchEnd);
Pan(apzc, mTime, touchStart, touchEnd);
ParentLayerPoint lastPoint;
for (int i = 1; i < 50; i+=1) {
apzc->SampleContentTransformForFrame(testStartTime+TimeDuration::FromMilliseconds(i), &viewTransformOut, pointOut);
apzc->SampleContentTransformForFrame(mTime+TimeDuration::FromMilliseconds(i), &viewTransformOut, pointOut);
EXPECT_GT(pointOut.y, lastPoint.y);
lastPoint = pointOut;
}
@ -1129,24 +1159,23 @@ TEST_F(APZCBasicTester, FlingIntoOverscroll) {
SCOPED_GFX_PREF(APZOverscrollEnabled, bool, true);
// Scroll down by 25 px. Don't fling for simplicity.
int time = 0;
ApzcPanNoFling(apzc, time, 50, 25);
ApzcPanNoFling(apzc, mTime, 50, 25);
// Now scroll back up by 20px, this time flinging after.
// The fling should cover the remaining 5 px of room to scroll, then
// go into overscroll, and finally snap-back to recover from overscroll.
Pan(apzc, time, 25, 45);
Pan(apzc, mTime, 25, 45);
const TimeDuration increment = TimeDuration::FromMilliseconds(1);
bool reachedOverscroll = false;
bool recoveredFromOverscroll = false;
while (apzc->AdvanceAnimations(testStartTime)) {
while (apzc->AdvanceAnimations(mTime)) {
if (!reachedOverscroll && apzc->IsOverscrolled()) {
reachedOverscroll = true;
}
if (reachedOverscroll && !apzc->IsOverscrolled()) {
recoveredFromOverscroll = true;
}
testStartTime += increment;
mTime += increment;
}
EXPECT_TRUE(reachedOverscroll);
EXPECT_TRUE(recoveredFromOverscroll);
@ -1182,28 +1211,26 @@ TEST_F(APZCBasicTester, PanningTransformNotifications) {
EXPECT_CALL(check, Call("Done"));
}
int time = 0;
check.Call("Simple pan");
ApzcPanNoFling(apzc, time, 50, 25);
ApzcPanNoFling(apzc, mTime, 50, 25);
check.Call("Complex pan");
Pan(apzc, time, 25, 45);
apzc->AdvanceAnimationsUntilEnd(testStartTime);
Pan(apzc, mTime, 25, 45);
apzc->AdvanceAnimationsUntilEnd(mTime);
check.Call("Done");
}
void APZCBasicTester::PanIntoOverscroll(int& aTime)
void APZCBasicTester::PanIntoOverscroll()
{
int touchStart = 500;
int touchEnd = 10;
Pan(apzc, aTime, touchStart, touchEnd);
Pan(apzc, mTime, touchStart, touchEnd);
EXPECT_TRUE(apzc->IsOverscrolled());
}
void APZCBasicTester::TestOverscroll()
{
// Pan sufficiently to hit overscroll behavior
int time = 0;
PanIntoOverscroll(time);
PanIntoOverscroll();
// Check that we recover from overscroll via an animation.
ParentLayerPoint expectedScrollOffset(0, GetScrollRange().YMost());
@ -1246,8 +1273,7 @@ TEST_F(APZCBasicTester, OverScroll_Bug1152051b) {
SCOPED_GFX_PREF(APZOverscrollStopDistanceThreshold, float, 0.1f);
// Pan sufficiently to hit overscroll behavior
int time = 0;
PanIntoOverscroll(time);
PanIntoOverscroll();
// Sample animations once, to give the fling animation started on touch-up
// a chance to realize it's overscrolled, and schedule a call to
@ -1266,8 +1292,8 @@ TEST_F(APZCBasicTester, OverScroll_Bug1152051b) {
// to schedule a new one since we're still overscrolled. We don't pan because
// panning can trigger functions that clear the overscroll animation state
// in other ways.
TouchDown(apzc, 10, 10, time, nullptr);
TouchUp(apzc, 10, 10, time);
TouchDown(apzc, 10, 10, mTime, nullptr);
TouchUp(apzc, 10, 10, mTime);
// Sample the second overscroll animation to its end.
// If the ending of the first overscroll animation fails to clear state
@ -1280,10 +1306,9 @@ TEST_F(APZCBasicTester, OverScrollAbort) {
SCOPED_GFX_PREF(APZOverscrollEnabled, bool, true);
// Pan sufficiently to hit overscroll behavior
int time = 0;
int touchStart = 500;
int touchEnd = 10;
Pan(apzc, time, touchStart, touchEnd);
Pan(apzc, mTime, touchStart, touchEnd);
EXPECT_TRUE(apzc->IsOverscrolled());
ParentLayerPoint pointOut;
@ -1291,7 +1316,7 @@ TEST_F(APZCBasicTester, OverScrollAbort) {
// This sample call will run to the end of the fling animation
// and will schedule the overscroll animation.
apzc->SampleContentTransformForFrame(testStartTime + TimeDuration::FromMilliseconds(10000), &viewTransformOut, pointOut);
apzc->SampleContentTransformForFrame(mTime + TimeDuration::FromMilliseconds(10000), &viewTransformOut, pointOut);
EXPECT_TRUE(apzc->IsOverscrolled());
// At this point, we have an active overscroll animation.
@ -1306,10 +1331,9 @@ TEST_F(APZCBasicTester, OverScrollPanningAbort) {
// Pan sufficiently to hit overscroll behaviour. Keep the finger down so
// the pan does not end.
int time = 0;
int touchStart = 500;
int touchEnd = 10;
Pan(apzc, time, touchStart, touchEnd, true); // keep finger down
Pan(apzc, mTime, touchStart, touchEnd, true); // keep finger down
EXPECT_TRUE(apzc->IsOverscrolled());
// Check that calling CancelAnimation() while the user is still panning
@ -1330,12 +1354,11 @@ protected:
// is at a slow velocity, and we check that the tap does trigger sending
// a tap to content. See bug 1022956.
void DoFlingStopTest(bool aSlow) {
int time = 0;
int touchStart = 50;
int touchEnd = 10;
// Start the fling down.
Pan(apzc, time, touchStart, touchEnd);
Pan(apzc, mTime, touchStart, touchEnd);
// The touchstart from the pan will leave some cancelled tasks in the queue, clear them out
while (mcc->RunThroughDelayedTasks());
@ -1348,23 +1371,23 @@ protected:
// Advance the fling animation by timeDelta milliseconds.
ParentLayerPoint pointOut;
ViewTransform viewTransformOut;
apzc->SampleContentTransformForFrame(testStartTime + TimeDuration::FromMilliseconds(timeDelta), &viewTransformOut, pointOut);
apzc->SampleContentTransformForFrame(mTime + TimeDuration::FromMilliseconds(timeDelta), &viewTransformOut, pointOut);
// Deliver a tap to abort the fling. Ensure that we get a HandleSingleTap
// call out of it if and only if the fling is slow.
EXPECT_CALL(*mcc, HandleSingleTap(_, 0, apzc->GetGuid())).Times(tapCallsExpected);
Tap(apzc, 10, 10, time, 0);
Tap(apzc, 10, 10, mTime, 0);
while (mcc->RunThroughDelayedTasks());
// Deliver another tap, to make sure that taps are flowing properly once
// the fling is aborted.
time += 500;
Tap(apzc, 100, 100, time, 0);
mTime += TimeDuration::FromMilliseconds(500);
Tap(apzc, 100, 100, mTime, 0);
while (mcc->RunThroughDelayedTasks());
// Verify that we didn't advance any further after the fling was aborted, in either case.
ParentLayerPoint finalPointOut;
apzc->SampleContentTransformForFrame(testStartTime + TimeDuration::FromMilliseconds(timeDelta + 1000), &viewTransformOut, finalPointOut);
apzc->SampleContentTransformForFrame(mTime + TimeDuration::FromMilliseconds(timeDelta + 1000), &viewTransformOut, finalPointOut);
EXPECT_EQ(pointOut.x, finalPointOut.x);
EXPECT_EQ(pointOut.y, finalPointOut.y);
@ -1374,28 +1397,27 @@ protected:
void DoFlingStopWithSlowListener(bool aPreventDefault) {
MakeApzcWaitForMainThread();
int time = 0;
int touchStart = 50;
int touchEnd = 10;
uint64_t blockId = 0;
// Start the fling down.
Pan(apzc, time, touchStart, touchEnd, false, nullptr, nullptr, &blockId);
Pan(apzc, mTime, touchStart, touchEnd, false, nullptr, nullptr, &blockId);
apzc->ContentReceivedInputBlock(blockId, false);
while (mcc->RunThroughDelayedTasks());
// Sample the fling a couple of times to ensure it's going.
ParentLayerPoint point, finalPoint;
ViewTransform viewTransform;
apzc->SampleContentTransformForFrame(testStartTime + TimeDuration::FromMilliseconds(10), &viewTransform, point);
apzc->SampleContentTransformForFrame(testStartTime + TimeDuration::FromMilliseconds(20), &viewTransform, finalPoint);
apzc->SampleContentTransformForFrame(mTime + TimeDuration::FromMilliseconds(10), &viewTransform, point);
apzc->SampleContentTransformForFrame(mTime + TimeDuration::FromMilliseconds(20), &viewTransform, finalPoint);
EXPECT_GT(finalPoint.y, point.y);
// Now we put our finger down to stop the fling
TouchDown(apzc, 10, 10, time, &blockId);
TouchDown(apzc, 10, 10, mTime, &blockId);
// Re-sample to make sure it hasn't moved
apzc->SampleContentTransformForFrame(testStartTime + TimeDuration::FromMilliseconds(30), &viewTransform, point);
apzc->SampleContentTransformForFrame(mTime + TimeDuration::FromMilliseconds(30), &viewTransform, point);
EXPECT_EQ(finalPoint.x, point.x);
EXPECT_EQ(finalPoint.y, point.y);
@ -1405,12 +1427,12 @@ protected:
while (mcc->RunThroughDelayedTasks());
// Verify the page hasn't moved
apzc->SampleContentTransformForFrame(testStartTime + TimeDuration::FromMilliseconds(100), &viewTransform, point);
apzc->SampleContentTransformForFrame(mTime + TimeDuration::FromMilliseconds(100), &viewTransform, point);
EXPECT_EQ(finalPoint.x, point.x);
EXPECT_EQ(finalPoint.y, point.y);
// clean up
TouchUp(apzc, 10, 10, time);
TouchUp(apzc, 10, 10, mTime);
while (mcc->RunThroughDelayedTasks());
apzc->AssertStateIsReset();
@ -1436,8 +1458,7 @@ TEST_F(APZCFlingStopTester, FlingStopPreventDefault) {
TEST_F(APZCGestureDetectorTester, ShortPress) {
MakeApzcUnzoomable();
int time = 0;
TapAndCheckStatus(apzc, 10, 10, time, 100);
TapAndCheckStatus(apzc, 10, 10, mTime, TimeDuration::FromMilliseconds(100));
// There will be delayed tasks posted for the long-tap and MAX_TAP timeouts, but
// we want to clear those.
mcc->ClearDelayedTask();
@ -1456,8 +1477,7 @@ TEST_F(APZCGestureDetectorTester, ShortPress) {
TEST_F(APZCGestureDetectorTester, MediumPress) {
MakeApzcUnzoomable();
int time = 0;
TapAndCheckStatus(apzc, 10, 10, time, 400);
TapAndCheckStatus(apzc, 10, 10, mTime, TimeDuration::FromMilliseconds(400));
// There will be delayed tasks posted for the long-tap and MAX_TAP timeouts, but
// we want to clear those.
mcc->ClearDelayedTask();
@ -1478,10 +1498,9 @@ protected:
void DoLongPressTest(uint32_t aBehavior) {
MakeApzcUnzoomable();
int time = 0;
uint64_t blockId = 0;
nsEventStatus status = TouchDown(apzc, 10, 10, time, &blockId);
nsEventStatus status = TouchDown(apzc, 10, 10, mTime, &blockId);
EXPECT_EQ(nsEventStatus_eConsumeDoDefault, status);
if (gfxPrefs::TouchActionEnabled() && status != nsEventStatus_eConsumeNoDefault) {
@ -1528,12 +1547,12 @@ protected:
mcc->CheckHasDelayedTask();
mcc->RunDelayedTask();
time += 1000;
mTime += TimeDuration::FromMilliseconds(1000);
// Finally, simulate lifting the finger. Since the long-press wasn't
// prevent-defaulted, we should get a long-tap-up event.
check.Call("preHandleSingleTap");
status = TouchUp(apzc, 10, 10, time);
status = TouchUp(apzc, 10, 10, mTime);
mcc->RunDelayedTask();
EXPECT_EQ(nsEventStatus_eConsumeDoDefault, status);
check.Call("postHandleSingleTap");
@ -1551,9 +1570,8 @@ protected:
touchStartY = 10,
touchEndY = 50;
int time = 0;
uint64_t blockId = 0;
nsEventStatus status = TouchDown(apzc, touchX, touchStartY, time, &blockId);
nsEventStatus status = TouchDown(apzc, touchX, touchStartY, mTime, &blockId);
EXPECT_EQ(nsEventStatus_eConsumeDoDefault, status);
if (gfxPrefs::TouchActionEnabled() && status != nsEventStatus_eConsumeNoDefault) {
@ -1595,20 +1613,20 @@ protected:
mcc->CheckHasDelayedTask();
mcc->RunDelayedTask();
time += 1000;
mTime += TimeDuration::FromMilliseconds(1000);
MultiTouchInput mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, time, TimeStamp(), 0);
MultiTouchInput mti = CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, mTime);
mti.mTouches.AppendElement(SingleTouchData(0, ParentLayerPoint(touchX, touchEndY), ScreenSize(0, 0), 0, 0));
status = apzc->ReceiveInputEvent(mti, nullptr);
EXPECT_EQ(nsEventStatus_eConsumeDoDefault, status);
EXPECT_CALL(*mcc, HandleSingleTap(CSSPoint(touchX, touchEndY), 0, apzc->GetGuid())).Times(0);
status = TouchUp(apzc, touchX, touchEndY, time);
status = TouchUp(apzc, touchX, touchEndY, mTime);
EXPECT_EQ(nsEventStatus_eConsumeDoDefault, status);
ParentLayerPoint pointOut;
ViewTransform viewTransformOut;
apzc->SampleContentTransformForFrame(testStartTime, &viewTransformOut, pointOut);
apzc->SampleContentTransformForFrame(mTime, &viewTransformOut, pointOut);
EXPECT_EQ(ParentLayerPoint(), pointOut);
EXPECT_EQ(ViewTransform(), viewTransformOut);
@ -1642,7 +1660,7 @@ TEST_F(APZCLongPressTester, LongPressPreventDefaultWithTouchAction) {
}
template<class InputReceiver> static void
DoubleTap(const nsRefPtr<InputReceiver>& aTarget, int aX, int aY, int& aTime,
DoubleTap(const nsRefPtr<InputReceiver>& aTarget, int aX, int aY, TimeStamp& aTime,
nsEventStatus (*aOutEventStatuses)[4] = nullptr,
uint64_t (*aOutInputBlockIds)[2] = nullptr)
{
@ -1654,7 +1672,7 @@ DoubleTap(const nsRefPtr<InputReceiver>& aTarget, int aX, int aY, int& aTime,
if (aOutInputBlockIds) {
(*aOutInputBlockIds)[0] = blockId;
}
aTime += 10;
aTime += TimeDuration::FromMilliseconds(10);
// If touch-action is enabled then simulate the allowed touch behaviour
// notification that the main thread is supposed to deliver.
@ -1666,7 +1684,7 @@ DoubleTap(const nsRefPtr<InputReceiver>& aTarget, int aX, int aY, int& aTime,
if (aOutEventStatuses) {
(*aOutEventStatuses)[1] = status;
}
aTime += 10;
aTime += TimeDuration::FromMilliseconds(10);
status = TouchDown(aTarget, aX, aY, aTime, &blockId);
if (aOutEventStatuses) {
(*aOutEventStatuses)[2] = status;
@ -1674,7 +1692,7 @@ DoubleTap(const nsRefPtr<InputReceiver>& aTarget, int aX, int aY, int& aTime,
if (aOutInputBlockIds) {
(*aOutInputBlockIds)[1] = blockId;
}
aTime += 10;
aTime += TimeDuration::FromMilliseconds(10);
if (gfxPrefs::TouchActionEnabled() && status != nsEventStatus_eConsumeNoDefault) {
SetDefaultAllowedTouchBehavior(aTarget, blockId);
@ -1687,7 +1705,8 @@ DoubleTap(const nsRefPtr<InputReceiver>& aTarget, int aX, int aY, int& aTime,
}
template<class InputReceiver> static void
DoubleTapAndCheckStatus(const nsRefPtr<InputReceiver>& aTarget, int aX, int aY, int& aTime, uint64_t (*aOutInputBlockIds)[2] = nullptr)
DoubleTapAndCheckStatus(const nsRefPtr<InputReceiver>& aTarget, int aX, int aY,
TimeStamp& aTime, uint64_t (*aOutInputBlockIds)[2] = nullptr)
{
nsEventStatus statuses[4];
DoubleTap(aTarget, aX, aY, aTime, &statuses, aOutInputBlockIds);
@ -1704,9 +1723,8 @@ TEST_F(APZCGestureDetectorTester, DoubleTap) {
EXPECT_CALL(*mcc, HandleSingleTap(CSSPoint(10, 10), 0, apzc->GetGuid())).Times(0);
EXPECT_CALL(*mcc, HandleDoubleTap(CSSPoint(10, 10), 0, apzc->GetGuid())).Times(1);
int time = 0;
uint64_t blockIds[2];
DoubleTapAndCheckStatus(apzc, 10, 10, time, &blockIds);
DoubleTapAndCheckStatus(apzc, 10, 10, mTime, &blockIds);
// responses to the two touchstarts
apzc->ContentReceivedInputBlock(blockIds[0], false);
@ -1724,9 +1742,8 @@ TEST_F(APZCGestureDetectorTester, DoubleTapNotZoomable) {
EXPECT_CALL(*mcc, HandleSingleTap(CSSPoint(10, 10), 0, apzc->GetGuid())).Times(2);
EXPECT_CALL(*mcc, HandleDoubleTap(CSSPoint(10, 10), 0, apzc->GetGuid())).Times(0);
int time = 0;
uint64_t blockIds[2];
DoubleTapAndCheckStatus(apzc, 10, 10, time, &blockIds);
DoubleTapAndCheckStatus(apzc, 10, 10, mTime, &blockIds);
// responses to the two touchstarts
apzc->ContentReceivedInputBlock(blockIds[0], false);
@ -1744,9 +1761,8 @@ TEST_F(APZCGestureDetectorTester, DoubleTapPreventDefaultFirstOnly) {
EXPECT_CALL(*mcc, HandleSingleTap(CSSPoint(10, 10), 0, apzc->GetGuid())).Times(1);
EXPECT_CALL(*mcc, HandleDoubleTap(CSSPoint(10, 10), 0, apzc->GetGuid())).Times(0);
int time = 0;
uint64_t blockIds[2];
DoubleTapAndCheckStatus(apzc, 10, 10, time, &blockIds);
DoubleTapAndCheckStatus(apzc, 10, 10, mTime, &blockIds);
// responses to the two touchstarts
apzc->ContentReceivedInputBlock(blockIds[0], true);
@ -1764,9 +1780,8 @@ TEST_F(APZCGestureDetectorTester, DoubleTapPreventDefaultBoth) {
EXPECT_CALL(*mcc, HandleSingleTap(CSSPoint(10, 10), 0, apzc->GetGuid())).Times(0);
EXPECT_CALL(*mcc, HandleDoubleTap(CSSPoint(10, 10), 0, apzc->GetGuid())).Times(0);
int time = 0;
uint64_t blockIds[2];
DoubleTapAndCheckStatus(apzc, 10, 10, time, &blockIds);
DoubleTapAndCheckStatus(apzc, 10, 10, mTime, &blockIds);
// responses to the two touchstarts
apzc->ContentReceivedInputBlock(blockIds[0], true);
@ -1784,17 +1799,16 @@ TEST_F(APZCGestureDetectorTester, TapFollowedByPinch) {
EXPECT_CALL(*mcc, HandleSingleTap(CSSPoint(10, 10), 0, apzc->GetGuid())).Times(1);
int time = 0;
Tap(apzc, 10, 10, time, 100);
Tap(apzc, 10, 10, mTime, TimeDuration::FromMilliseconds(100));
int inputId = 0;
MultiTouchInput mti;
mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_START, time, TimeStamp(), 0);
mti = CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_START, mTime);
mti.mTouches.AppendElement(SingleTouchData(inputId, ParentLayerPoint(20, 20), ScreenSize(0, 0), 0, 0));
mti.mTouches.AppendElement(SingleTouchData(inputId + 1, ParentLayerPoint(10, 10), ScreenSize(0, 0), 0, 0));
apzc->ReceiveInputEvent(mti, nullptr);
mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_END, time, TimeStamp(), 0);
mti = CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_END, mTime);
mti.mTouches.AppendElement(SingleTouchData(inputId, ParentLayerPoint(20, 20), ScreenSize(0, 0), 0, 0));
mti.mTouches.AppendElement(SingleTouchData(inputId + 1, ParentLayerPoint(10, 10), ScreenSize(0, 0), 0, 0));
apzc->ReceiveInputEvent(mti, nullptr);
@ -1809,21 +1823,20 @@ TEST_F(APZCGestureDetectorTester, TapFollowedByMultipleTouches) {
EXPECT_CALL(*mcc, HandleSingleTap(CSSPoint(10, 10), 0, apzc->GetGuid())).Times(1);
int time = 0;
Tap(apzc, 10, 10, time, 100);
Tap(apzc, 10, 10, mTime, TimeDuration::FromMilliseconds(100));
int inputId = 0;
MultiTouchInput mti;
mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_START, time, TimeStamp(), 0);
mti = CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_START, mTime);
mti.mTouches.AppendElement(SingleTouchData(inputId, ParentLayerPoint(20, 20), ScreenSize(0, 0), 0, 0));
apzc->ReceiveInputEvent(mti, nullptr);
mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_START, time, TimeStamp(), 0);
mti = CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_START, mTime);
mti.mTouches.AppendElement(SingleTouchData(inputId, ParentLayerPoint(20, 20), ScreenSize(0, 0), 0, 0));
mti.mTouches.AppendElement(SingleTouchData(inputId + 1, ParentLayerPoint(10, 10), ScreenSize(0, 0), 0, 0));
apzc->ReceiveInputEvent(mti, nullptr);
mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_END, time, TimeStamp(), 0);
mti = CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_END, mTime);
mti.mTouches.AppendElement(SingleTouchData(inputId, ParentLayerPoint(20, 20), ScreenSize(0, 0), 0, 0));
mti.mTouches.AppendElement(SingleTouchData(inputId + 1, ParentLayerPoint(10, 10), ScreenSize(0, 0), 0, 0));
apzc->ReceiveInputEvent(mti, nullptr);
@ -1840,18 +1853,17 @@ protected:
APZThreadUtils::SetThreadAssertionsEnabled(false);
APZThreadUtils::SetControllerThread(MessageLoop::current());
testStartTime = TimeStamp::Now();
AsyncPanZoomController::SetFrameTime(testStartTime);
mTime = TimeStamp::Now();
mcc = new NiceMock<MockContentControllerDelayed>();
manager = new TestAPZCTreeManager();
manager = new TestAPZCTreeManager(mTime);
}
virtual void TearDown() {
manager->ClearTree();
}
TimeStamp testStartTime;
TimeStamp mTime;
nsRefPtr<MockContentControllerDelayed> mcc;
nsTArray<nsRefPtr<Layer> > layers;
@ -2139,13 +2151,12 @@ TEST_F(APZHitTestingTester, HitTesting2) {
// Pan the root layer upward by 50 pixels.
// This causes layers[1] to scroll out of view, and an async transform
// of -50 to be set on the root layer.
int time = 0;
EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(1);
// This first pan will move the APZC by 50 pixels, and dispatch a paint request.
// Since this paint request is in the queue to Gecko, transformToGecko will
// take it into account.
ApzcPanNoFling(apzcroot, time, 100, 50);
ApzcPanNoFling(apzcroot, mTime, 100, 50);
// Hit where layers[3] used to be. It should now hit the root.
hit = GetTargetAPZC(ScreenPoint(75, 75));
@ -2171,7 +2182,7 @@ TEST_F(APZHitTestingTester, HitTesting2) {
// request dispatched above has not "completed", we will not dispatch another
// one yet. Now we have an async transform on top of the pending paint request
// transform.
ApzcPanNoFling(apzcroot, time, 100, 50);
ApzcPanNoFling(apzcroot, mTime, 100, 50);
// Hit where layers[3] used to be. It should now hit the root.
hit = GetTargetAPZC(ScreenPoint(75, 75));
@ -2354,13 +2365,12 @@ TEST_F(APZHitTestingTester, TestRepaintFlushOnNewInputBlock) {
EXPECT_CALL(check, Call("post-second-touch-start"));
}
int time = 0;
// This first pan will move the APZC by 50 pixels, and dispatch a paint request.
ApzcPanNoFling(apzcroot, time, 100, 50);
ApzcPanNoFling(apzcroot, mTime, 100, 50);
// Verify that a touch start doesn't get untransformed
ScreenIntPoint touchPoint(50, 50);
MultiTouchInput mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_START, time, TimeStamp(), 0);
MultiTouchInput mti = CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_START, mTime);
mti.mTouches.AppendElement(SingleTouchData(0, touchPoint, ScreenSize(0, 0), 0, 0));
EXPECT_EQ(nsEventStatus_eConsumeDoDefault, manager->ReceiveInputEvent(mti, nullptr, nullptr));
@ -2371,7 +2381,7 @@ TEST_F(APZHitTestingTester, TestRepaintFlushOnNewInputBlock) {
mti.mType = MultiTouchInput::MULTITOUCH_END;
manager->ReceiveInputEvent(mti, nullptr, nullptr);
AsyncPanZoomController::SetFrameTime(testStartTime + TimeDuration::FromMilliseconds(1000));
mTime += TimeDuration::FromMilliseconds(1000);
// Now do two pans. The first of these will dispatch a repaint request, as above.
// The second will get stuck in the paint throttler because the first one doesn't
@ -2379,9 +2389,9 @@ TEST_F(APZHitTestingTester, TestRepaintFlushOnNewInputBlock) {
// (Note that any outstanding repaint requests from the first half of this test
// don't impact this half because we advance the time by 1 second, which will trigger
// the max-wait-exceeded codepath in the paint throttler).
ApzcPanNoFling(apzcroot, time, 100, 50);
ApzcPanNoFling(apzcroot, mTime, 100, 50);
check.Call("post-second-fling");
ApzcPanNoFling(apzcroot, time, 100, 50);
ApzcPanNoFling(apzcroot, mTime, 100, 50);
// Ensure that a touch start again doesn't get untransformed by flushing
// a repaint
@ -2411,23 +2421,22 @@ TEST_F(APZHitTestingTester, Bug1148350) {
EXPECT_CALL(check, Call("Tapped with interleaved transform"));
}
int time = 0;
Tap(manager, 100, 100, time, 100);
Tap(manager, 100, 100, mTime, TimeDuration::FromMilliseconds(100));
mcc->RunThroughDelayedTasks();
check.Call("Tapped without transform");
uint64_t blockId;
TouchDown(manager, 100, 100, time, &blockId);
TouchDown(manager, 100, 100, mTime, &blockId);
if (gfxPrefs::TouchActionEnabled()) {
SetDefaultAllowedTouchBehavior(manager, blockId);
}
time += 100;
mTime += TimeDuration::FromMilliseconds(100);
layers[0]->SetVisibleRegion(nsIntRegion(IntRect(0,50,200,150)));
layers[0]->SetBaseTransform(Matrix4x4::Translation(0, 50, 0));
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
TouchUp(manager, 100, 100, time);
TouchUp(manager, 100, 100, mTime);
mcc->RunThroughDelayedTasks();
check.Call("Tapped with interleaved transform");
}
@ -2523,9 +2532,8 @@ TEST_F(APZOverscrollHandoffTester, DeferredInputEventProcessing) {
childApzc->SetWaitForMainThread();
// Queue input events for a pan.
int time = 0;
uint64_t blockId = 0;
ApzcPanNoFling(childApzc, time, 90, 30, &blockId);
ApzcPanNoFling(childApzc, mTime, 90, 30, &blockId);
// Allow the pan to be processed.
childApzc->ContentReceivedInputBlock(blockId, false);
@ -2552,9 +2560,8 @@ TEST_F(APZOverscrollHandoffTester, LayerStructureChangesWhileEventsArePending) {
childApzc->SetWaitForMainThread();
// Queue input events for a pan.
int time = 0;
uint64_t blockId = 0;
ApzcPanNoFling(childApzc, time, 90, 30, &blockId);
ApzcPanNoFling(childApzc, mTime, 90, 30, &blockId);
// Modify the APZC tree to insert a new APZC 'middle' into the handoff chain
// between the child and the root.
@ -2565,7 +2572,7 @@ TEST_F(APZOverscrollHandoffTester, LayerStructureChangesWhileEventsArePending) {
// Queue input events for another pan.
uint64_t secondBlockId = 0;
ApzcPanNoFling(childApzc, time, 30, 90, &secondBlockId);
ApzcPanNoFling(childApzc, mTime, 30, 90, &secondBlockId);
// Allow the first pan to be processed.
childApzc->ContentReceivedInputBlock(blockId, false);
@ -2599,8 +2606,7 @@ TEST_F(APZOverscrollHandoffTester, StuckInOverscroll_Bug1073250) {
TestAsyncPanZoomController* child = ApzcOf(layers[1]);
// Pan, causing the parent APZC to overscroll.
int time = 0;
Pan(manager, time, 10, 40, true /* keep finger down */);
Pan(manager, mTime, 10, 40, true /* keep finger down */);
EXPECT_FALSE(child->IsOverscrolled());
EXPECT_TRUE(rootApzc->IsOverscrolled());
@ -2617,8 +2623,8 @@ TEST_F(APZOverscrollHandoffTester, StuckInOverscroll_Bug1073250) {
manager->ReceiveInputEvent(fingersUp, nullptr, nullptr);
// Allow any animations to run their course.
child->AdvanceAnimationsUntilEnd(testStartTime);
rootApzc->AdvanceAnimationsUntilEnd(testStartTime);
child->AdvanceAnimationsUntilEnd(mTime);
rootApzc->AdvanceAnimationsUntilEnd(mTime);
// Make sure nothing is overscrolled.
EXPECT_FALSE(child->IsOverscrolled());
@ -2637,11 +2643,10 @@ TEST_F(APZOverscrollHandoffTester, SimultaneousFlings) {
nsRefPtr<TestAsyncPanZoomController> child2 = ApzcOf(layers[4]);
// Pan on the lower child.
int time = 0;
Pan(child2, time, 45, 5);
Pan(child2, mTime, 45, 5);
// Pan on the upper child.
Pan(child1, time, 95, 55);
Pan(child1, mTime, 95, 55);
// Check that child1 and child2 are in a FLING state.
child1->AssertStateIsFling();
@ -2667,8 +2672,7 @@ TEST_F(APZOverscrollHandoffTester, Scrollgrab) {
// Pan on the child, enough to fully scroll the scrollgrab parent (20 px)
// and leave some more (another 15 px) for the child.
int time = 0;
Pan(childApzc, time, 80, 45);
Pan(childApzc, mTime, 80, 45);
// Check that the parent and child have scrolled as much as we expect.
EXPECT_EQ(20, rootApzc->GetFrameMetrics().GetScrollOffset().y);
@ -2682,8 +2686,7 @@ TEST_F(APZOverscrollHandoffTester, ScrollgrabFling) {
nsRefPtr<TestAsyncPanZoomController> childApzc = ApzcOf(layers[1]);
// Pan on the child, not enough to fully scroll the scrollgrab parent.
int time = 0;
Pan(childApzc, time, 80, 70);
Pan(childApzc, mTime, 80, 70);
// Check that it is the scrollgrab parent that's in a fling, not the child.
rootApzc->AssertStateIsFling();
@ -2862,21 +2865,22 @@ TEST_F(APZEventRegionsTester, HitRegionImmediateResponse) {
EXPECT_CALL(check, Call("Tapped on left this time"));
}
int time = 0;
TimeDuration tapDuration = TimeDuration::FromMilliseconds(100);
// Tap in the exposed hit regions of each of the layers once and ensure
// the clicks are dispatched right away
Tap(manager, 10, 10, time, 100);
Tap(manager, 10, 10, mTime, tapDuration);
mcc->RunThroughDelayedTasks(); // this runs the tap event
check.Call("Tapped on left");
Tap(manager, 110, 110, time, 100);
Tap(manager, 110, 110, mTime, tapDuration);
mcc->RunThroughDelayedTasks(); // this runs the tap event
check.Call("Tapped on bottom");
Tap(manager, 110, 10, time, 100);
Tap(manager, 110, 10, mTime, tapDuration);
mcc->RunThroughDelayedTasks(); // this runs the tap event
check.Call("Tapped on root");
// Now tap on the dispatch-to-content region where the layers overlap
Tap(manager, 10, 110, time, 100);
Tap(manager, 10, 110, mTime, tapDuration);
mcc->RunThroughDelayedTasks(); // this runs the main-thread timeout
check.Call("Tap pending on d-t-c region");
mcc->RunThroughDelayedTasks(); // this runs the tap event
@ -2884,7 +2888,7 @@ TEST_F(APZEventRegionsTester, HitRegionImmediateResponse) {
// Now let's do that again, but simulate a main-thread response
uint64_t inputBlockId = 0;
Tap(manager, 10, 110, time, 100, nullptr, &inputBlockId);
Tap(manager, 10, 110, mTime, tapDuration, nullptr, &inputBlockId);
nsTArray<ScrollableLayerGuid> targets;
targets.AppendElement(left->GetGuid());
manager->SetTargetAPZC(inputBlockId, targets);
@ -2895,13 +2899,12 @@ TEST_F(APZEventRegionsTester, HitRegionImmediateResponse) {
TEST_F(APZEventRegionsTester, HitRegionAccumulatesChildren) {
CreateEventRegionsLayerTree2();
int time = 0;
// Tap in the area of the child layer that's not directly included in the
// parent layer's hit region. Verify that it comes out of the APZC's
// content controller, which indicates the input events got routed correctly
// to the APZC.
EXPECT_CALL(*mcc, HandleSingleTap(_, _, rootApzc->GetGuid())).Times(1);
Tap(manager, 10, 160, time, 100);
Tap(manager, 10, 160, mTime, TimeDuration::FromMilliseconds(100));
mcc->RunThroughDelayedTasks(); // this runs the tap event
}
@ -2914,8 +2917,7 @@ TEST_F(APZEventRegionsTester, Obscuration) {
TestAsyncPanZoomController* parent = ApzcOf(layers[1]);
TestAsyncPanZoomController* child = ApzcOf(layers[2]);
int time = 0;
ApzcPanNoFling(parent, time, 75, 25);
ApzcPanNoFling(parent, mTime, 75, 25);
HitTestResult result;
nsRefPtr<AsyncPanZoomController> hit = manager->GetTargetAPZC(ScreenPoint(50, 75), &result);
@ -2941,9 +2943,8 @@ TEST_F(APZEventRegionsTester, Bug1117712) {
// These touch events should hit the dispatch-to-content region of layers[3]
// and so get queued with that APZC as the tentative target.
int time = 0;
uint64_t inputBlockId = 0;
Tap(manager, 55, 5, time, 100, nullptr, &inputBlockId);
Tap(manager, 55, 5, mTime, TimeDuration::FromMilliseconds(100), nullptr, &inputBlockId);
// But now we tell the APZ that really it hit layers[2], and expect the tap
// to be delivered at the correct coordinates.
EXPECT_CALL(*mcc, HandleSingleTap(CSSPoint(55, 5), 0, apzc2->GetGuid())).Times(1);