• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# Copyright (C) 2023 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16# Discarded events that do not get to GPU are invisible for UMA metric and
17# therefore should be excluded in trace-based metric. This tests ensures that's
18# the case.
19
20from os import sys
21
22import synth_common
23
24from synth_common import ms_to_ns
25trace = synth_common.create_trace()
26
27from chrome_scroll_helper import ChromeScrollHelper
28
29helper = ChromeScrollHelper(trace, start_id=1234, start_gesture_id=5678)
30
31# First scroll
32helper.begin(from_ms=0, dur_ms=10)
33helper.update(from_ms=15, dur_ms=10)
34helper.update(from_ms=30, dur_ms=10)
35helper.end(from_ms=45, dur_ms=10)
36
37# Second scroll
38helper.begin(from_ms=60, dur_ms=10)
39helper.update(from_ms=75, dur_ms=10)
40helper.end(from_ms=90, dur_ms=10)
41
42# Third scroll, won't have a GestureScrollEnd value.
43helper.begin(from_ms=120, dur_ms=10)
44helper.update(from_ms=135, dur_ms=10)
45helper.update(from_ms=150, dur_ms=10)
46helper.update(from_ms=150, dur_ms=10)
47helper.update(from_ms=180, dur_ms=10)
48
49sys.stdout.buffer.write(trace.trace.SerializeToString())
50