Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/layers/apz/test/gtest/TestTreeManager.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "APZCTreeManagerTester.h"
8
#include "APZTestCommon.h"
9
#include "InputUtils.h"
10
11
0
TEST_F(APZCTreeManagerTester, ScrollablePaintedLayers) {
12
0
  CreateSimpleMultiLayerTree();
13
0
  ScopedLayerTreeRegistration registration(manager, LayersId{0}, root, mcc);
14
0
15
0
  // both layers have the same scrollId
16
0
  SetScrollableFrameMetrics(layers[1], FrameMetrics::START_SCROLL_ID);
17
0
  SetScrollableFrameMetrics(layers[2], FrameMetrics::START_SCROLL_ID);
18
0
  manager->UpdateHitTestingTree(LayersId{0}, root, false, LayersId{0}, 0);
19
0
20
0
  TestAsyncPanZoomController* nullAPZC = nullptr;
21
0
  // so they should have the same APZC
22
0
  EXPECT_FALSE(layers[0]->HasScrollableFrameMetrics());
23
0
  EXPECT_NE(nullAPZC, ApzcOf(layers[1]));
24
0
  EXPECT_NE(nullAPZC, ApzcOf(layers[2]));
25
0
  EXPECT_EQ(ApzcOf(layers[1]), ApzcOf(layers[2]));
26
0
27
0
  // Change the scrollId of layers[1], and verify the APZC changes
28
0
  SetScrollableFrameMetrics(layers[1], FrameMetrics::START_SCROLL_ID + 1);
29
0
  manager->UpdateHitTestingTree(LayersId{0}, root, false, LayersId{0}, 0);
30
0
  EXPECT_NE(ApzcOf(layers[1]), ApzcOf(layers[2]));
31
0
32
0
  // Change the scrollId of layers[2] to match that of layers[1], ensure we get the same
33
0
  // APZC for both again
34
0
  SetScrollableFrameMetrics(layers[2], FrameMetrics::START_SCROLL_ID + 1);
35
0
  manager->UpdateHitTestingTree(LayersId{0}, root, false, LayersId{0}, 0);
36
0
  EXPECT_EQ(ApzcOf(layers[1]), ApzcOf(layers[2]));
37
0
}
38
39
0
TEST_F(APZCTreeManagerTester, Bug1068268) {
40
0
  CreatePotentiallyLeakingTree();
41
0
  ScopedLayerTreeRegistration registration(manager, LayersId{0}, root, mcc);
42
0
43
0
  manager->UpdateHitTestingTree(LayersId{0}, root, false, LayersId{0}, 0);
44
0
  RefPtr<HitTestingTreeNode> root = manager->GetRootNode();
45
0
  RefPtr<HitTestingTreeNode> node2 = root->GetFirstChild()->GetFirstChild();
46
0
  RefPtr<HitTestingTreeNode> node5 = root->GetLastChild()->GetLastChild();
47
0
48
0
  EXPECT_EQ(ApzcOf(layers[2]), node5->GetApzc());
49
0
  EXPECT_EQ(ApzcOf(layers[2]), node2->GetApzc());
50
0
  EXPECT_EQ(ApzcOf(layers[0]), ApzcOf(layers[2])->GetParent());
51
0
  EXPECT_EQ(ApzcOf(layers[2]), ApzcOf(layers[5]));
52
0
53
0
  EXPECT_EQ(node2->GetFirstChild(), node2->GetLastChild());
54
0
  EXPECT_EQ(ApzcOf(layers[3]), node2->GetLastChild()->GetApzc());
55
0
  EXPECT_EQ(node5->GetFirstChild(), node5->GetLastChild());
56
0
  EXPECT_EQ(ApzcOf(layers[6]), node5->GetLastChild()->GetApzc());
57
0
  EXPECT_EQ(ApzcOf(layers[2]), ApzcOf(layers[3])->GetParent());
58
0
  EXPECT_EQ(ApzcOf(layers[5]), ApzcOf(layers[6])->GetParent());
59
0
}
60
61
0
TEST_F(APZCTreeManagerTester, Bug1194876) {
62
0
  CreateBug1194876Tree();
63
0
  ScopedLayerTreeRegistration registration(manager, LayersId{0}, root, mcc);
64
0
  manager->UpdateHitTestingTree(LayersId{0}, root, false, LayersId{0}, 0);
65
0
66
0
  uint64_t blockId;
67
0
  nsTArray<ScrollableLayerGuid> targets;
68
0
69
0
  // First touch goes down, APZCTM will hit layers[1] because it is on top of
70
0
  // layers[0], but we tell it the real target APZC is layers[0].
71
0
  MultiTouchInput mti;
72
0
  mti = CreateMultiTouchInput(MultiTouchInput::MULTITOUCH_START, mcc->Time());
73
0
  mti.mTouches.AppendElement(SingleTouchData(0, ParentLayerPoint(25, 50), ScreenSize(0, 0), 0, 0));
74
0
  manager->ReceiveInputEvent(mti, nullptr, &blockId);
75
0
  manager->ContentReceivedInputBlock(blockId, false);
76
0
  targets.AppendElement(ApzcOf(layers[0])->GetGuid());
77
0
  manager->SetTargetAPZC(blockId, targets);
78
0
79
0
  // Around here, the above touch will get processed by ApzcOf(layers[0])
80
0
81
0
  // Second touch goes down (first touch remains down), APZCTM will again hit
82
0
  // layers[1]. Again we tell it both touches landed on layers[0], but because
83
0
  // layers[1] is the RCD layer, it will end up being the multitouch target.
84
0
  mti.mTouches.AppendElement(SingleTouchData(1, ParentLayerPoint(75, 50), ScreenSize(0, 0), 0, 0));
85
0
  manager->ReceiveInputEvent(mti, nullptr, &blockId);
86
0
  manager->ContentReceivedInputBlock(blockId, false);
87
0
  targets.AppendElement(ApzcOf(layers[0])->GetGuid());
88
0
  manager->SetTargetAPZC(blockId, targets);
89
0
90
0
  // Around here, the above multi-touch will get processed by ApzcOf(layers[1]).
91
0
  // We want to ensure that ApzcOf(layers[0]) has had its state cleared, because
92
0
  // otherwise it will do things like dispatch spurious long-tap events.
93
0
94
0
  EXPECT_CALL(*mcc, HandleTap(TapType::eLongTap, _, _, _, _)).Times(0);
95
0
}
96
97
0
TEST_F(APZCTreeManagerTester, Bug1198900) {
98
0
  // This is just a test that cancels a wheel event to make sure it doesn't
99
0
  // crash.
100
0
  CreateSimpleDTCScrollingLayer();
101
0
  ScopedLayerTreeRegistration registration(manager, LayersId{0}, root, mcc);
102
0
  manager->UpdateHitTestingTree(LayersId{0}, root, false, LayersId{0}, 0);
103
0
104
0
  ScreenPoint origin(100, 50);
105
0
  ScrollWheelInput swi(MillisecondsSinceStartup(mcc->Time()), mcc->Time(), 0,
106
0
    ScrollWheelInput::SCROLLMODE_INSTANT, ScrollWheelInput::SCROLLDELTA_PIXEL,
107
0
    origin, 0, 10, false, WheelDeltaAdjustmentStrategy::eNone);
108
0
  uint64_t blockId;
109
0
  manager->ReceiveInputEvent(swi, nullptr, &blockId);
110
0
  manager->ContentReceivedInputBlock(blockId, /* preventDefault= */ true);
111
0
}
112