/
overview_scroll_perf.go
119 lines (100 loc) · 3.93 KB
/
overview_scroll_perf.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// Copyright 2019 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package ui
import (
"context"
"time"
"chromiumos/tast/errors"
"chromiumos/tast/local/bundles/cros/ui/perfutil"
"chromiumos/tast/local/chrome"
"chromiumos/tast/local/chrome/ash"
"chromiumos/tast/local/chrome/display"
"chromiumos/tast/local/input"
"chromiumos/tast/local/power"
"chromiumos/tast/local/ui"
"chromiumos/tast/testing"
"chromiumos/tast/testing/hwdep"
)
func init() {
testing.AddTest(&testing.Test{
Func: OverviewScrollPerf,
LacrosStatus: testing.LacrosVariantUnneeded,
Desc: "Measures the presentation time of scrolling the overview grid in tablet mode",
Contacts: []string{"sammiequon@chromium.org", "chromeos-wmp@google.com"},
Attr: []string{"group:crosbolt", "crosbolt_perbuild"},
SoftwareDeps: []string{"chrome"},
HardwareDeps: hwdep.D(hwdep.InternalDisplay()),
Fixture: "chromeLoggedIn",
})
}
func OverviewScrollPerf(ctx context.Context, s *testing.State) {
// Ensure display on to record ui performance correctly.
if err := power.TurnOnDisplay(ctx); err != nil {
s.Fatal("Failed to turn on display: ", err)
}
cr := s.FixtValue().(*chrome.Chrome)
tconn, err := cr.TestAPIConn(ctx)
if err != nil {
s.Fatal("Failed to connect to test API: ", err)
}
orientation, err := display.GetOrientation(ctx, tconn)
if err != nil {
s.Fatal("Failed to obtain the display rotation: ", err)
}
cleanup, err := ash.EnsureTabletModeEnabled(ctx, tconn, true)
if err != nil {
s.Fatal("Failed to ensure in tablet mode: ", err)
}
defer cleanup(ctx)
// Prepare the touch screen as this test requires touch scroll events.
tsew, err := input.Touchscreen(ctx)
if err != nil {
s.Fatal("Failed to create touch screen event writer: ", err)
}
defer tsew.Close()
if err = tsew.SetRotation(-orientation.Angle); err != nil {
s.Fatal("Failed to set rotation: ", err)
}
stw, err := tsew.NewSingleTouchWriter()
if err != nil {
s.Fatal("Failed to create single touch writer: ", err)
}
defer stw.Close()
// Use a total of 16 windows for this test, so that scrolling can happen.
const numWindows = 16
if err := ash.CreateWindows(ctx, tconn, cr, ui.PerftestURL, numWindows); err != nil {
s.Fatal("Failed to open browser windows: ", err)
}
if err = ash.SetOverviewModeAndWait(ctx, tconn, true); err != nil {
s.Fatal("It does not appear to be in the overview mode: ", err)
}
defer ash.SetOverviewModeAndWait(ctx, tconn, false)
pv := perfutil.RunMultiple(ctx, s, cr.Browser(), perfutil.RunAndWaitAll(tconn, func(ctx context.Context) error {
// Scroll from the top right of the screen to the top middle (1/4 of the
// screen width). The destination position should match with the next swipe
// to make the same amount of scrolling.
if err := stw.Swipe(ctx, tsew.Width()-10, 10, tsew.Width()/4, 10, 500*time.Millisecond); err != nil {
return errors.Wrap(err, "failed to execute a swipe gesture")
}
if err := stw.End(); err != nil {
return errors.Wrap(err, "failed to finish the swipe gesture")
}
// Scroll back from the top middle to the top right so that the test returns
// back to the original status. Note that this can't be starting from the
// top left, since it can be recognized as another gesture (back gesture).
if err := stw.Swipe(ctx, tsew.Width()/4, 10, tsew.Width()-10, 10, 500*time.Millisecond); err != nil {
return errors.Wrap(err, "failed to execute a swipe gesture")
}
if err := stw.End(); err != nil {
return errors.Wrap(err, "failed to finish the swipe gesture")
}
return nil
}, "Ash.Overview.Scroll.PresentationTime.TabletMode"), perfutil.StoreLatency)
if err = ash.SetOverviewModeAndWait(ctx, tconn, false); err != nil {
s.Fatal("It does not appear to be in the overview mode: ", err)
}
if err := pv.Save(ctx, s.OutDir()); err != nil {
s.Error("Failed saving perf data: ", err)
}
}