/
system_tray_items_perf.go
101 lines (88 loc) · 3.51 KB
/
system_tray_items_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
// Copyright 2022 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/local/bundles/cros/ui/perfutil"
"chromiumos/tast/local/chrome"
"chromiumos/tast/local/chrome/uiauto"
"chromiumos/tast/local/chrome/uiauto/nodewith"
"chromiumos/tast/local/chrome/uiauto/role"
"chromiumos/tast/local/input"
"chromiumos/tast/local/power"
"chromiumos/tast/testing"
"chromiumos/tast/testing/hwdep"
)
func init() {
testing.AddTest(&testing.Test{
Func: SystemTrayItemsPerf,
LacrosStatus: testing.LacrosVariantUnknown,
Desc: "Measures animation smoothness of items in the system tray",
Contacts: []string{"leandre@chromium.org", "cros-status-area-eng@google.com", "chromeos-wmp@google.com", "chromeos-sw-engprod@google.com"},
Attr: []string{"group:crosbolt", "crosbolt_perbuild"},
SoftwareDeps: []string{"chrome"},
HardwareDeps: hwdep.D(hwdep.InternalDisplay()),
Fixture: "chromeLoggedIn",
Timeout: 3 * time.Minute,
})
}
func SystemTrayItemsPerf(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)
}
ac := uiauto.New(tconn)
kb, err := input.Keyboard(ctx)
if err != nil {
s.Fatal("Failed to create a keyboard: ", err)
}
defer kb.Close()
topRow, err := input.KeyboardTopRowLayout(ctx, kb)
if err != nil {
s.Fatal("Failed to load the top-row layout: ", err)
}
// Starts full screen recording via UI.
screenRecordToggleButton := nodewith.HasClass("CaptureModeToggleButton").Name("Screen record")
recordFullscreenToggleButton := nodewith.HasClass("CaptureModeToggleButton").Name("Record full screen")
stopRecordButton := nodewith.HasClass("TrayBackgroundView").Name("Stop screen recording")
recordTakenLabel := nodewith.HasClass("Label").Name("Screen recording taken")
popupNotification := nodewith.Role(role.Window).HasClass("ash/message_center/MessagePopup")
pv := perfutil.RunMultiple(ctx, s, cr.Browser(), perfutil.RunAndWaitAll(tconn, func(ctx context.Context) error {
// Take video recording so that the shelf pod bounces up, then click on the shelf pod for it to fade out,
// (at the same time notification counter tray item will do show animation), then we close the notification
// for tray item to perform hide animation.
if err := uiauto.Combine(
"perform screen recording, then close the notification",
// Enter screen capture mode.
kb.AccelAction("Ctrl+Shift+"+topRow.SelectTask),
ac.LeftClick(screenRecordToggleButton),
ac.LeftClick(recordFullscreenToggleButton),
kb.AccelAction("Enter"),
// Records full screen for 2 seconds.
uiauto.Sleep(2*time.Second),
ac.LeftClick(stopRecordButton),
// Checks if the screen record is taken.
ac.WaitUntilExists(recordTakenLabel),
// Close the notification so that tray item performs hide animation.
ac.LeftClick(popupNotification),
)(ctx); err != nil {
return err
}
return nil
},
"Ash.StatusArea.TrayBackgroundView.BounceIn",
"Ash.StatusArea.TrayBackgroundView.Hide",
"Ash.StatusArea.TrayItemView.Show",
"Ash.StatusArea.TrayItemView.Hide"),
perfutil.StoreSmoothness)
if err := pv.Save(ctx, s.OutDir()); err != nil {
s.Fatal("Failed saving perf data: ", err)
}
}