Bug 1194876 - Add test. r=botond

--HG--
extra : commitid : Cg9fRSjAKgj
This commit is contained in:
Kartikaya Gupta 2015-08-25 07:50:01 -04:00
Родитель 4675a280c5
Коммит b9032e3705
1 изменённых файлов: 60 добавлений и 0 удалений

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

@ -1972,6 +1972,30 @@ protected:
SetScrollableFrameMetrics(layers[3], FrameMetrics::START_SCROLL_ID + 2);
SetScrollableFrameMetrics(layers[6], FrameMetrics::START_SCROLL_ID + 3);
}
void CreateBug1194876Tree() {
const char* layerTreeSyntax = "c(t)";
// LayerID 0 1
nsIntRegion layerVisibleRegion[] = {
nsIntRegion(IntRect(0,0,100,100)),
nsIntRegion(IntRect(0,0,100,100)),
};
root = CreateLayerTree(layerTreeSyntax, layerVisibleRegion, nullptr, lm, layers);
SetScrollableFrameMetrics(layers[0], FrameMetrics::START_SCROLL_ID);
SetScrollableFrameMetrics(layers[1], FrameMetrics::START_SCROLL_ID + 1);
// Make layers[1] the root content
FrameMetrics childMetrics = layers[1]->GetFrameMetrics(0);
childMetrics.SetIsRootContent(true);
layers[1]->SetFrameMetrics(childMetrics);
// Both layers are fully dispatch-to-content
EventRegions regions;
regions.mHitRegion = nsIntRegion(IntRect(0, 0, 100, 100));
regions.mDispatchToContentHitRegion = regions.mHitRegion;
layers[0]->SetEventRegions(regions);
layers[1]->SetEventRegions(regions);
}
};
class APZHitTestingTester : public APZCTreeManagerTester {
@ -2289,6 +2313,42 @@ TEST_F(APZCTreeManagerTester, Bug1068268) {
EXPECT_EQ(ApzcOf(layers[5]), ApzcOf(layers[6])->GetParent());
}
TEST_F(APZCTreeManagerTester, Bug1194876) {
CreateBug1194876Tree();
ScopedLayerTreeRegistration registration(0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
uint64_t blockId;
nsTArray<ScrollableLayerGuid> targets;
// First touch goes down, APZCTM will hit layers[1] because it is on top of
// layers[0], but we tell it the real target APZC is layers[0].
MultiTouchInput mti;
mti = CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_START, mcc->Time());
mti.mTouches.AppendElement(SingleTouchData(0, ParentLayerPoint(25, 50), ScreenSize(0, 0), 0, 0));
manager->ReceiveInputEvent(mti, nullptr, &blockId);
manager->ContentReceivedInputBlock(blockId, false);
targets.AppendElement(ApzcOf(layers[0])->GetGuid());
manager->SetTargetAPZC(blockId, targets);
// Around here, the above touch will get processed by ApzcOf(layers[0])
// Second touch goes down (first touch remains down), APZCTM will again hit
// layers[1]. Again we tell it both touches landed on layers[0], but because
// layers[1] is the RCD layer, it will end up being the multitouch target.
mti.mTouches.AppendElement(SingleTouchData(1, ParentLayerPoint(75, 50), ScreenSize(0, 0), 0, 0));
manager->ReceiveInputEvent(mti, nullptr, &blockId);
manager->ContentReceivedInputBlock(blockId, false);
targets.AppendElement(ApzcOf(layers[0])->GetGuid());
manager->SetTargetAPZC(blockId, targets);
// Around here, the above multi-touch will get processed by ApzcOf(layers[1]).
// We want to ensure that ApzcOf(layers[0]) has had its state cleared, because
// otherwise it will do things like dispatch spurious long-tap events.
EXPECT_CALL(*mcc, HandleLongTap(_, _, _, _)).Times(0);
}
TEST_F(APZHitTestingTester, ComplexMultiLayerTree) {
CreateComplexMultiLayerTree();
ScopedLayerTreeRegistration registration(0, root, mcc);