15
15
#include " third_party/blink/renderer/platform/testing/testing_platform_support.h"
16
16
#include " third_party/blink/renderer/platform/testing/unit_test_helpers.h"
17
17
18
- #define EXPECT_WHEEL_BUCKET (reason, count ) \
19
- histogram_tester.ExpectBucketCount( \
20
- " Renderer4.MainThreadWheelScrollReason" , \
21
- GetBucketIndex (cc::MainThreadScrollingReason::reason), count);
22
-
23
- #define EXPECT_TOUCH_BUCKET (reason, count ) \
24
- histogram_tester.ExpectBucketCount( \
25
- " Renderer4.MainThreadGestureScrollReason" , \
26
- GetBucketIndex (cc::MainThreadScrollingReason::reason), count);
27
-
28
- #define EXPECT_WHEEL_TOTAL (count ) \
29
- histogram_tester.ExpectTotalCount(" Renderer4.MainThreadWheelScrollReason" , \
30
- count);
18
+ #define EXPECT_WHEEL_BUCKET (index, count ) \
19
+ histogram_tester.ExpectBucketCount(" Renderer4.MainThreadWheelScrollReason2" , \
20
+ index, count);
21
+
22
+ #define EXPECT_TOUCH_BUCKET (index, count ) \
23
+ histogram_tester.ExpectBucketCount( \
24
+ " Renderer4.MainThreadGestureScrollReason2" , index, count);
31
25
32
- #define EXPECT_TOUCH_TOTAL (count ) \
33
- histogram_tester.ExpectTotalCount(" Renderer4.MainThreadGestureScrollReason " , \
26
+ #define EXPECT_WHEEL_TOTAL (count ) \
27
+ histogram_tester.ExpectTotalCount(" Renderer4.MainThreadWheelScrollReason2 " , \
34
28
count);
35
29
30
+ #define EXPECT_TOUCH_TOTAL (count ) \
31
+ histogram_tester.ExpectTotalCount( \
32
+ " Renderer4.MainThreadGestureScrollReason2" , count);
33
+
36
34
namespace blink {
37
35
38
36
namespace {
@@ -46,12 +44,6 @@ class ScrollMetricsTest : public SimTest {
46
44
}
47
45
};
48
46
49
- class NonCompositedMainThreadScrollingReasonRecordTest
50
- : public ScrollMetricsTest {
51
- protected:
52
- int GetBucketIndex (uint32_t reason);
53
- };
54
-
55
47
class ScrollBeginEventBuilder : public WebGestureEvent {
56
48
public:
57
49
ScrollBeginEventBuilder (gfx::PointF position,
@@ -88,13 +80,8 @@ class ScrollEndEventBuilder : public WebGestureEvent {
88
80
}
89
81
};
90
82
91
- int NonCompositedMainThreadScrollingReasonRecordTest::GetBucketIndex (
92
- uint32_t reason) {
93
- int index = 0 ;
94
- while (reason >>= 1 )
95
- ++index;
96
- DCHECK_NE (index, 0 );
97
- return index;
83
+ int BucketIndex (uint32_t reason) {
84
+ return cc::MainThreadScrollingReason::BucketIndexForTesting (reason);
98
85
}
99
86
100
87
void ScrollMetricsTest::Scroll (Element* element,
@@ -120,10 +107,13 @@ void ScrollMetricsTest::SetUpHtml(const char* html_content) {
120
107
LoadURL (" https://example.com/test.html" );
121
108
request.Complete (html_content);
122
109
Compositor ().BeginFrame ();
110
+
111
+ GetDocument ().View ()->SetParentVisible (true );
112
+ GetDocument ().View ()->SetSelfVisible (true );
113
+ UpdateAllLifecyclePhases ();
123
114
}
124
115
125
- TEST_F (NonCompositedMainThreadScrollingReasonRecordTest,
126
- TouchAndWheelGeneralTest) {
116
+ TEST_F (ScrollMetricsTest, TouchAndWheelGeneralTest) {
127
117
SetUpHtml (R"HTML(
128
118
<style>
129
119
.box { overflow:scroll; width: 100px; height: 100px; }
@@ -134,27 +124,37 @@ TEST_F(NonCompositedMainThreadScrollingReasonRecordTest,
134
124
</div>
135
125
)HTML" );
136
126
137
- UpdateAllLifecyclePhases ();
138
-
139
127
Element* box = GetDocument ().getElementById (" box" );
140
128
HistogramTester histogram_tester;
141
129
142
130
// Test touch scroll.
143
131
Scroll (box, WebGestureDevice::kTouchscreen );
144
- EXPECT_TOUCH_BUCKET (kNotOpaqueForTextAndLCDText , 1 );
132
+ EXPECT_TOUCH_BUCKET (
133
+ BucketIndex (cc::MainThreadScrollingReason::kNotOpaqueForTextAndLCDText ),
134
+ 1 );
135
+ EXPECT_TOUCH_BUCKET (
136
+ cc::MainThreadScrollingReason::kScrollingOnMainForAnyReason , 1 );
137
+ EXPECT_TOUCH_TOTAL (2 );
145
138
146
139
Scroll (box, WebGestureDevice::kTouchscreen );
147
- EXPECT_TOUCH_BUCKET (kNotOpaqueForTextAndLCDText , 2 );
148
- EXPECT_TOUCH_TOTAL (2 );
140
+ EXPECT_TOUCH_BUCKET (
141
+ BucketIndex (cc::MainThreadScrollingReason::kNotOpaqueForTextAndLCDText ),
142
+ 2 );
143
+ EXPECT_TOUCH_BUCKET (
144
+ cc::MainThreadScrollingReason::kScrollingOnMainForAnyReason , 2 );
145
+ EXPECT_TOUCH_TOTAL (4 );
149
146
150
147
// Test wheel scroll.
151
148
Scroll (box, WebGestureDevice::kTouchpad );
152
- EXPECT_WHEEL_BUCKET (kNotOpaqueForTextAndLCDText , 1 );
153
- EXPECT_WHEEL_TOTAL (1 );
149
+ EXPECT_WHEEL_BUCKET (
150
+ BucketIndex (cc::MainThreadScrollingReason::kNotOpaqueForTextAndLCDText ),
151
+ 1 );
152
+ EXPECT_WHEEL_BUCKET (
153
+ cc::MainThreadScrollingReason::kScrollingOnMainForAnyReason , 1 );
154
+ EXPECT_WHEEL_TOTAL (2 );
154
155
}
155
156
156
- TEST_F (NonCompositedMainThreadScrollingReasonRecordTest,
157
- CompositedScrollableAreaTest) {
157
+ TEST_F (ScrollMetricsTest, CompositedScrollableAreaTest) {
158
158
SetUpHtml (R"HTML(
159
159
<style>
160
160
.box { overflow:scroll; width: 100px; height: 100px; }
@@ -166,29 +166,31 @@ TEST_F(NonCompositedMainThreadScrollingReasonRecordTest,
166
166
</div>
167
167
)HTML" );
168
168
169
- GetDocument ().View ()->SetParentVisible (true );
170
- GetDocument ().View ()->SetSelfVisible (true );
171
- UpdateAllLifecyclePhases ();
172
-
173
169
Element* box = GetDocument ().getElementById (" box" );
174
170
HistogramTester histogram_tester;
175
171
176
172
Scroll (box, WebGestureDevice::kTouchpad );
177
- EXPECT_WHEEL_BUCKET (kNotOpaqueForTextAndLCDText , 1 );
178
- EXPECT_WHEEL_TOTAL (1 );
173
+ EXPECT_WHEEL_BUCKET (
174
+ BucketIndex (cc::MainThreadScrollingReason::kNotOpaqueForTextAndLCDText ),
175
+ 1 );
176
+ EXPECT_WHEEL_BUCKET (
177
+ cc::MainThreadScrollingReason::kScrollingOnMainForAnyReason , 1 );
178
+ EXPECT_WHEEL_TOTAL (2 );
179
179
180
180
box->setAttribute (" class" , " composited transform box" );
181
181
UpdateAllLifecyclePhases ();
182
182
Scroll (box, WebGestureDevice::kTouchpad );
183
183
EXPECT_FALSE (To<LayoutBox>(box->GetLayoutObject ())
184
184
->GetScrollableArea ()
185
185
->GetNonCompositedMainThreadScrollingReasons ());
186
- EXPECT_WHEEL_BUCKET (kNotOpaqueForTextAndLCDText , 1 );
187
- EXPECT_WHEEL_TOTAL (1 );
186
+ EXPECT_WHEEL_BUCKET (
187
+ BucketIndex (cc::MainThreadScrollingReason::kNotOpaqueForTextAndLCDText ),
188
+ 1 );
189
+ // EXPECT_WHEEL_BUCKET(cc::MainThreadScrollingReason::kNotScrollingOnMain, 1);
190
+ EXPECT_WHEEL_TOTAL (2 );
188
191
}
189
192
190
- TEST_F (NonCompositedMainThreadScrollingReasonRecordTest,
191
- NotScrollableAreaTest) {
193
+ TEST_F (ScrollMetricsTest, NotScrollableAreaTest) {
192
194
SetUpHtml (R"HTML(
193
195
<style>.box { overflow:scroll; width: 100px; height: 100px; }
194
196
.hidden { overflow: hidden; }
@@ -199,23 +201,29 @@ TEST_F(NonCompositedMainThreadScrollingReasonRecordTest,
199
201
</div>
200
202
)HTML" );
201
203
202
- UpdateAllLifecyclePhases ();
203
-
204
204
Element* box = GetDocument ().getElementById (" box" );
205
205
HistogramTester histogram_tester;
206
206
207
207
Scroll (box, WebGestureDevice::kTouchpad );
208
- EXPECT_WHEEL_BUCKET (kNotOpaqueForTextAndLCDText , 1 );
209
- EXPECT_WHEEL_TOTAL (1 );
208
+ EXPECT_WHEEL_BUCKET (
209
+ BucketIndex (cc::MainThreadScrollingReason::kNotOpaqueForTextAndLCDText ),
210
+ 1 );
211
+ EXPECT_WHEEL_BUCKET (
212
+ cc::MainThreadScrollingReason::kScrollingOnMainForAnyReason , 1 );
213
+ EXPECT_WHEEL_TOTAL (2 );
210
214
211
215
box->setAttribute (" class" , " hidden transform box" );
212
216
UpdateAllLifecyclePhases ();
213
217
Scroll (box, WebGestureDevice::kTouchpad );
214
- EXPECT_WHEEL_BUCKET (kNotOpaqueForTextAndLCDText , 1 );
215
- EXPECT_WHEEL_TOTAL (1 );
218
+ EXPECT_WHEEL_BUCKET (
219
+ BucketIndex (cc::MainThreadScrollingReason::kNotOpaqueForTextAndLCDText ),
220
+ 1 );
221
+ EXPECT_WHEEL_BUCKET (
222
+ cc::MainThreadScrollingReason::kScrollingOnMainForAnyReason , 1 );
223
+ EXPECT_WHEEL_TOTAL (2 );
216
224
}
217
225
218
- TEST_F (NonCompositedMainThreadScrollingReasonRecordTest , NestedScrollersTest) {
226
+ TEST_F (ScrollMetricsTest , NestedScrollersTest) {
219
227
SetUpHtml (R"HTML(
220
228
<style>
221
229
.container { overflow:scroll; width: 200px; height: 200px; }
@@ -236,19 +244,19 @@ TEST_F(NonCompositedMainThreadScrollingReasonRecordTest, NestedScrollersTest) {
236
244
</div>
237
245
)HTML" );
238
246
239
- GetDocument ().View ()->SetParentVisible (true );
240
- GetDocument ().View ()->SetSelfVisible (true );
241
- UpdateAllLifecyclePhases ();
242
-
243
247
Element* box = GetDocument ().getElementById (" inner" );
244
248
HistogramTester histogram_tester;
245
249
246
250
Scroll (box, WebGestureDevice::kTouchpad );
247
251
// Scrolling the inner box will gather reasons from the scrolling chain. The
248
252
// inner box itself has no reason because it's composited. Other scrollable
249
253
// areas from the chain have corresponding reasons.
250
- EXPECT_WHEEL_BUCKET (kNotOpaqueForTextAndLCDText , 1 );
251
- EXPECT_WHEEL_TOTAL (1 );
254
+ EXPECT_WHEEL_BUCKET (
255
+ BucketIndex (cc::MainThreadScrollingReason::kNotOpaqueForTextAndLCDText ),
256
+ 1 );
257
+ EXPECT_WHEEL_BUCKET (
258
+ cc::MainThreadScrollingReason::kScrollingOnMainForAnyReason , 1 );
259
+ EXPECT_WHEEL_TOTAL (2 );
252
260
}
253
261
254
262
} // namespace
0 commit comments