Documentation ¶
Overview ¶
Package cuj has utilities for CUJ-style UI performance tests.
Index ¶
- Constants
- func CPUCoolDownConfig() cpu.CoolDownConfig
- func ClickIfExist(obj *ui.Object, timeout time.Duration) action.Action
- func CloseAllWindows(ctx context.Context, tconn *chrome.TestConn) error
- func CloseBrowserTabs(ctx context.Context, tconn *chrome.TestConn) error
- func CloseBrowserTabsByID(ctx context.Context, tconn *chrome.TestConn, tabIDs []int) error
- func CloseChrome(ctx context.Context, tconn *chrome.TestConn) error
- func DismissMobilePrompt(ctx context.Context, tconn *chrome.TestConn) error
- func ExpandMenu(tconn *chrome.TestConn, button, menu *nodewith.Finder, height int) action.Action
- func FindAndClick(obj *ui.Object, timeout time.Duration) action.Action
- func GetBrowserStartTime(ctx context.Context, tconn *chrome.TestConn, ...) (*lacros.Lacros, time.Duration, error)
- func InitializeSetting(ctx context.Context, tconn *chrome.TestConn) (action.Action, error)
- func KeepNewTab(ctx context.Context, tconn *chrome.TestConn) error
- func LaunchAppFromHotseat(ctx context.Context, tconn *chrome.TestConn, appName string, ...) (time.Time, error)
- func LaunchAppFromShelf(ctx context.Context, tconn *chrome.TestConn, appName string, ...) (time.Time, error)
- func OpenAppAndGetStartTime(ctx context.Context, tconn *chrome.TestConn, a *arc.ARC, ...) (time.Duration, *arc.Activity, error)
- func SetAudioVolume(ctx context.Context, expectedVolumePercent int) (action.Action, error)
- func SwitchWindowToDisplay(ctx context.Context, tconn *chrome.TestConn, kb *input.KeyboardEventWriter, ...) action.Action
- func UnsetMirrorDisplay(ctx context.Context, tconn *chrome.TestConn) error
- type ClamshellActionHandler
- func (cl *ClamshellActionHandler) Click(finder *nodewith.Finder) action.Action
- func (cl *ClamshellActionHandler) ClickUntil(finder *nodewith.Finder, condition func(context.Context) error) action.Action
- func (cl *ClamshellActionHandler) Close()
- func (cl *ClamshellActionHandler) LaunchChrome(ctx context.Context) (time.Time, error)
- func (cl *ClamshellActionHandler) MinimizeAllWindow() action.Action
- func (cl *ClamshellActionHandler) NewChromeTab(ctx context.Context, br *browser.Browser, url string, newWindow bool) (*chrome.Conn, error)
- func (cl *ClamshellActionHandler) ScrollChromePage(ctx context.Context) []action.Action
- func (cl *ClamshellActionHandler) SwipeDown() action.Action
- func (cl *ClamshellActionHandler) SwipeUp() action.Action
- func (cl *ClamshellActionHandler) SwitchToAppWindow(appName string) action.Action
- func (cl *ClamshellActionHandler) SwitchToAppWindowByIndex(appName string, targetIdx int) action.Action
- func (cl *ClamshellActionHandler) SwitchToAppWindowByName(appName, targetName string) action.Action
- func (cl *ClamshellActionHandler) SwitchToChromeTabByIndex(tabIdxDest int) action.Action
- func (cl *ClamshellActionHandler) SwitchToChromeTabByName(tabNameDest string) action.Action
- func (cl *ClamshellActionHandler) SwitchToLRUWindow(opt SwitchWindowOption) action.Action
- func (cl *ClamshellActionHandler) SwitchToNextChromeTab() action.Action
- func (cl *ClamshellActionHandler) SwitchWindow() action.Action
- type FixtureData
- type MetricConfig
- func MetricConfigs(tconns []*chrome.TestConn) []MetricConfig
- func NewCustomMetricConfig(histogramName, unit string, direction perf.Direction, jankCriteria []int64) MetricConfig
- func NewCustomMetricConfigWithTestConn(histogramName, unit string, direction perf.Direction, jankCriteria []int64, ...) MetricConfigdeprecated
- func NewCustomMetricConfigWithTestConns(histogramName, unit string, direction perf.Direction, jankCriteria []int64, ...) MetricConfig
- func NewLatencyMetricConfig(histogramName string) MetricConfig
- func NewLatencyMetricConfigWithTestConn(histogramName string, tconn *chrome.TestConn) MetricConfigdeprecated
- func NewLatencyMetricConfigWithTestConns(histogramName string, tconns []*chrome.TestConn) MetricConfig
- func NewSmoothnessMetricConfig(histogramName string) MetricConfig
- func NewSmoothnessMetricConfigWithTestConn(histogramName string, tconn *chrome.TestConn) MetricConfigdeprecated
- func NewSmoothnessMetricConfigWithTestConns(histogramName string, tconns []*chrome.TestConn) MetricConfig
- type Recorder
- func (r *Recorder) Close(ctx context.Context) error
- func (r *Recorder) EnableTracing(traceDir string)
- func (r *Recorder) Record(ctx context.Context, pv *perf.Values) error
- func (r *Recorder) Run(ctx context.Context, f func(ctx context.Context) error) (e error)
- func (r *Recorder) RunFor(ctx context.Context, f func(ctx context.Context) error, ...) error
- func (r *Recorder) SaveHistograms(outDir string) error
- func (r *Recorder) StartRecording(ctx context.Context) (runCtx context.Context, e error)
- func (r *Recorder) StopRecording(ctx, runCtx context.Context) (e error)
- type RecorderOptions
- type SwitchWindowOption
- type TPSValidationHelper
- type Tab
- type TabCrashChecker
- type TabletActionHandler
- func (t *TabletActionHandler) Click(finder *nodewith.Finder) action.Action
- func (t *TabletActionHandler) ClickUntil(finder *nodewith.Finder, condition func(context.Context) error) action.Action
- func (t *TabletActionHandler) Close()
- func (t *TabletActionHandler) LaunchChrome(ctx context.Context) (time.Time, error)
- func (t *TabletActionHandler) MinimizeAllWindow() action.Action
- func (t *TabletActionHandler) NewChromeTab(ctx context.Context, br *browser.Browser, url string, newWindow bool) (*chrome.Conn, error)
- func (t *TabletActionHandler) ScrollChromePage(ctx context.Context) []action.Action
- func (t *TabletActionHandler) SwipeDown() action.Action
- func (t *TabletActionHandler) SwipeUp() action.Action
- func (t *TabletActionHandler) SwitchToAppWindow(appName string) action.Action
- func (t *TabletActionHandler) SwitchToAppWindowByIndex(appName string, targetIdx int) action.Action
- func (t *TabletActionHandler) SwitchToAppWindowByName(appName, targetName string) action.Action
- func (t *TabletActionHandler) SwitchToChromeTabByIndex(tabIdxDest int) action.Action
- func (t *TabletActionHandler) SwitchToChromeTabByName(tabNameDest string) action.Action
- func (t *TabletActionHandler) SwitchToLRUWindow(opt SwitchWindowOption) action.Action
- func (t *TabletActionHandler) SwitchToNextChromeTab() action.Action
- func (t *TabletActionHandler) SwitchWindow() action.Action
- type Tier
- type UIActionHandler
Constants ¶
const ( // CPUCoolDownTimeout is the time to wait for cpu cool down. CPUCoolDownTimeout = 10 * time.Minute // CPUIdleTimeout is the time to wait for cpu utilization to go down. // This value should match waitIdleCPUTimeout in cpu/idle.go. CPUIdleTimeout = 2 * time.Minute // CPUStablizationTimeout is the time to wait for cpu stablization, which // is the sum of cpu cool down time and cpu idle time. CPUStablizationTimeout = CPUCoolDownTimeout + CPUIdleTimeout )
const ( // CnnAmericasURL specifies the URL for CNN's page covering news from Americas. CnnAmericasURL = "https://edition.cnn.com/americas" // CnnAustraliaURL specifies the URL for CNN's page covering news from Australia. CnnAustraliaURL = "https://edition.cnn.com/australia" // CnnEuropeURL specifies the URL for CNN's page covering news from Europe. CnnEuropeURL = "https://edition.cnn.com/europe" // CnnMiddleEastURL specifies the URL for CNN's page covering news from Middle-East. CnnMiddleEastURL = "https://edition.cnn.com/middle-east" // CnnWorldURL specifies the URL for CNN's covering news from the world. CnnWorldURL = "https://edition.cnn.com/world" // EspnCollegeBasketballURL specifies the URL for ESPN's college basketball page. EspnCollegeBasketballURL = "https://www.espn.com/mens-college-basketball/" // EspnNbaURL specifies the URL for ESPN's NBA page. EspnNbaURL = "https://www.espn.com/nba/" // EspnNflURL specifies the URL for ESPN's NFL page. EspnNflURL = "https://www.espn.com/nfl/" // EspnSoccerURL specifies the URL for ESPN's soccer page. EspnSoccerURL = "https://www.espn.com/soccer/" // EspnTennisURL specifies the URL for ESPN's tennis page. EspnTennisURL = "https://www.espn.com/tennis/" // HuluKidsURL specifies the URL for Hulu's Kids page. HuluKidsURL = "https://www.hulu.com/hub/kids" // HuluMoviesURL specifies the URL for Hulu's movies page. HuluMoviesURL = "https://www.hulu.com/hub/movies" // MediumAIURL specifies the URL for Medium's artificial-intelligence tag. MediumAIURL = "https://medium.com/tag/artificial-intelligence" // MediumBusinessURL specifies the URL for Medium's business tag. MediumBusinessURL = "https://medium.com/tag/business" // MediumSoftwareURL specifies the URL for Medium's software-engineering tag. MediumSoftwareURL = "https://medium.com/tag/software-engineering" // MediumStartupURL specifies the URL for Medium's startup tag. MediumStartupURL = "https://medium.com/tag/startup" // MediumWorkURL specifies the URL for Medium's work tag. MediumWorkURL = "https://medium.com/tag/work" // NetflixURL specifies the URL for Netflix's home page. NetflixURL = "https://help.netflix.com/en/" // PinterestURL specifies the URL for Pinterest's ideas page. PinterestURL = "https://www.pinterest.com/ideas/" // RedditAppleURL specifies the URL for Reddit's Apple page. RedditAppleURL = "https://www.reddit.com/r/apple" // RedditBrooklynURL specifies the URL for Reddit's Brooklyn Nine-Nine page. RedditBrooklynURL = "https://www.reddit.com/r/brooklynninenine" // RedditOlympicsURL specifies the URL for Reddit's Olympics page. RedditOlympicsURL = "https://www.reddit.com/r/olympics" // RedditProgrammingURL specifies the URL for Reddit's programming page. RedditProgrammingURL = "https://www.reddit.com/r/programming" // RedditTechNewsURL specifies the URL for Reddit's tech news. RedditTechNewsURL = "https://www.reddit.com/r/technews" // RedditWallstreetURL specifies the URL for Reddit's Wallstreetbets page. RedditWallstreetURL = "https://www.reddit.com/r/wallstreetbets" // WikipediaAboutURL specifies the URL for Wikipedia's about page. WikipediaAboutURL = "https://en.wikipedia.org/wiki/Wikipedia:About" // WikipediaCommunityURL specifies the URL for Wikipedia's community page. WikipediaCommunityURL = "https://en.wikipedia.org/wiki/Wikipedia:Community_portal" // WikipediaCurrentEventsURL specifies the URL for Wikipedia's current events page. WikipediaCurrentEventsURL = "https://en.wikipedia.org/wiki/Portal:Current_events" // WikipediaMainURL specifies the URL for Wikipedia's main page. WikipediaMainURL = "https://en.wikipedia.org/wiki/Main_Page" // WikipediaHelpURL specifies the URL for Wikipedia's help page. WikipediaHelpURL = "https://en.wikipedia.org/wiki/Help:Contents" // WikipediaPandemicURL specifies the URL for Wikipedia's pandemic page. WikipediaPandemicURL = "https://en.wikipedia.org/wiki/COVID-19_pandemic" // YahooOriginalsURL specifies the URL for Yahoo's originals page. YahooOriginalsURL = "https://news.yahoo.com/originals/" // YahooScienceURL specifies the URL for Yahoo's science page. YahooScienceURL = "https://news.yahoo.com/science/" // YahooUsURL specifies the URL for Yahoo's US page. YahooUsURL = "https://news.yahoo.com/us/" // YahooWorldURL specifies the URL for Yahoo's world page. YahooWorldURL = "https://news.yahoo.com/world/" // YoutubeURL specifies the URL for YouTube's home page. YoutubeURL = "https://www.youtube.com" // GoogleNewsURL specifies the URL for Google News. GoogleNewsURL = "https://news.google.com/" // GooglePhotosURL specifies the URL for Google Photos. GooglePhotosURL = "https://photos.google.com" // CnnURL specifies the URL for CNN's main page. CnnURL = "https://edition.cnn.com/" // GmailURL specifies the URL for Gmail. GmailURL = "https://mail.google.com" // GoogleCalendarURL specifies the URL for Google Calendar. GoogleCalendarURL = "https://calendar.google.com/" // HuluURL specifies the URL for Hulu's home page. HuluURL = "https://www.hulu.com/" // RedditURL specifies the URL for Reddit's home page. RedditURL = "https://www.reddit.com/" // WikipediaURL specifies the URL for Wikipedia's home page. WikipediaURL = "https://www.wikipedia.org/" // YoutubeMusicURL specifies the URL for a YouTube Music channel. YoutubeMusicURL = "https://music.youtube.com/playlist?list=RDCLAK5uy_nZiG9ehz_MQoWQxY5yElsLHCcG0tv9PRg" // YoutubeGoogleTVVideoURL specifies the URL of the YouTube video for Google TV. YoutubeGoogleTVVideoURL = "https://youtu.be/g309_g-RF_s" // YoutubeDeveloperKeynoteVideoURL specifies the URL of the YouTube video for Google I/O ‘21. YoutubeDeveloperKeynoteVideoURL = "https://youtu.be/D_mVOAXcrtc" // YoutubeStadiaGDCVideoURL specifies the URL of the YouTube video for Stadia GDC 2019. YoutubeStadiaGDCVideoURL = "https://youtu.be/nUih5C5rOrA" // GoogleDocsURL specifies the URL for Google Docs. GoogleDocsURL = "https://docs.google.com/document" // GoogleSlidesURL specifies the URL for Google Slides. GoogleSlidesURL = "http://docs.google.com/slides" // GoogleSheetsURL specifies the URL for Google Sheets. GoogleSheetsURL = "http://docs.google.com/spreadsheets" // MicrosoftOfficeURL specifies the URL of Microsoft Office Home. MicrosoftOfficeURL = "https://www.office.com/" // GoogleURL specifies the URL for Google. GoogleURL = "https://google.com" // GoogleChatURL specifies the URL for Google Chat. GoogleChatURL = "https://chat.google.com" // ZoomURL specifies the URL for Zoom. ZoomURL = "https://zoom.us/" // ZoomSignInURL specifies the URL for Zoom sign in. ZoomSignInURL = "https://zoom.us/google_oauth_signin" )
Variables ¶
This section is empty.
Functions ¶
func CPUCoolDownConfig ¶
func CPUCoolDownConfig() cpu.CoolDownConfig
CPUCoolDownConfig returns a cpu.CoolDownConfig to be used for CUJ tests.
func ClickIfExist ¶
ClickIfExist returns an action function which clicks the UI object if it exists.
func CloseAllWindows ¶
CloseAllWindows closes all currently open windows by iterating over the shelf icons and calling apps.closeApp on each one.
func CloseBrowserTabs ¶
CloseBrowserTabs closes all browser tabs through chrome.tabs API.
func CloseBrowserTabsByID ¶
CloseBrowserTabsByID closes browser tabs by ID through chrome.tabs API.
func CloseChrome ¶
CloseChrome closes Chrome browser application properly. If there exist unsave changes on web page, e.g. media content is playing or online document is editing, "leave site" prompt will prevent the tab from closing. This function confirms the "leave site" prompts so browser can be closed.
func DismissMobilePrompt ¶
DismissMobilePrompt dismisses the prompt of "This app is designed for mobile".
func ExpandMenu ¶
ExpandMenu returns a function that clicks the button and waits for the menu to expand to the given height. This function is useful when the target menu will expand to its full size with animation. On Low end DUTs the expansion animation might stuck for some time. The node might have returned a stable location if checking with a fixed interval before the animiation completes. This function ensures animation completes by checking the menu height.
func FindAndClick ¶
FindAndClick returns an action function which finds and clicks Android ui object.
func GetBrowserStartTime ¶
func GetBrowserStartTime(ctx context.Context, tconn *chrome.TestConn, closeTabs, tabletMode, isLacros bool) (*lacros.Lacros, time.Duration, error)
GetBrowserStartTime opens chrome browser and returns the browser start time. If lfixtVal is given, it will open the lacros-Chrome, and return the lacros instance.
func InitializeSetting ¶
InitializeSetting sets all initial settings to DUT before performing CUJ testing.
func KeepNewTab ¶
KeepNewTab closes all other browser tabs and leave only one new tab. Leaving a new tab is critical to keep lacros-Chrome process running. See crbug.com/1268743 for the chrome arg --disable-lacros-keep-alive.
func LaunchAppFromHotseat ¶
func LaunchAppFromHotseat(ctx context.Context, tconn *chrome.TestConn, appName string, appOtherPossibleNames ...string) (time.Time, error)
LaunchAppFromHotseat opens an app by name which is currently pinned to the hotseat. Which it is also support multiple names for a single app (e.g. "Chrome"||"Chromium" for Google Chrome, the browser). It returns the time when a touch event is injected to the app icon.
func LaunchAppFromShelf ¶
func LaunchAppFromShelf(ctx context.Context, tconn *chrome.TestConn, appName string, appOtherPossibleNames ...string) (time.Time, error)
LaunchAppFromShelf opens an app by name which is currently pinned to the shelf. Which it is also support multiple names for a single app (e.g. "Chrome"||"Chromium" for Google Chrome, the browser). It returns the time when a mouse click event is injected to the app icon.
func OpenAppAndGetStartTime ¶
func OpenAppAndGetStartTime(ctx context.Context, tconn *chrome.TestConn, a *arc.ARC, pkgName, appName, startActivity string) (time.Duration, *arc.Activity, error)
OpenAppAndGetStartTime launches a new activity, starts it and records start time. The caller must close the returned activity when the test is done.
func SetAudioVolume ¶
SetAudioVolume sets the audio volume to the expected percentage of the maximum volume and returns a function that restores the original volume.
Types ¶
type ClamshellActionHandler ¶
type ClamshellActionHandler struct {
// contains filtered or unexported fields
}
ClamshellActionHandler define the action on clamshell devices.
func NewClamshellActionHandler ¶
func NewClamshellActionHandler(ctx context.Context, tconn *chrome.TestConn) (*ClamshellActionHandler, error)
NewClamshellActionHandler returns the action handler which is responsible for handling UI actions on clamshell.
func (*ClamshellActionHandler) Click ¶
func (cl *ClamshellActionHandler) Click(finder *nodewith.Finder) action.Action
Click returns a function that does left-click on the node found by input finder on clamshell.
func (*ClamshellActionHandler) ClickUntil ¶
func (cl *ClamshellActionHandler) ClickUntil(finder *nodewith.Finder, condition func(context.Context) error) action.Action
ClickUntil returns a function that repeatedly left clicks the node until the condition returns no error. It will try to click the node once before it checks the condition.
func (*ClamshellActionHandler) Close ¶
func (cl *ClamshellActionHandler) Close()
Close releases the underlying resouses. Tests should always defer calls to this once the UIActionHandler instance been created.
func (*ClamshellActionHandler) LaunchChrome ¶
LaunchChrome launches the Chrome browser.
func (*ClamshellActionHandler) MinimizeAllWindow ¶
func (cl *ClamshellActionHandler) MinimizeAllWindow() action.Action
MinimizeAllWindow returns a function which minimizes all window.
func (*ClamshellActionHandler) NewChromeTab ¶
func (cl *ClamshellActionHandler) NewChromeTab(ctx context.Context, br *browser.Browser, url string, newWindow bool) (*chrome.Conn, error)
NewChromeTab creates a new tab of Google Chrome. newWindow indicates this new tab should open in current Chrome window or open in new Chrome window.
func (*ClamshellActionHandler) ScrollChromePage ¶
func (cl *ClamshellActionHandler) ScrollChromePage(ctx context.Context) []action.Action
ScrollChromePage generate the scroll action.
func (*ClamshellActionHandler) SwipeDown ¶
func (cl *ClamshellActionHandler) SwipeDown() action.Action
SwipeDown returns a function which swipes down the page.
func (*ClamshellActionHandler) SwipeUp ¶
func (cl *ClamshellActionHandler) SwipeUp() action.Action
SwipeUp returns a function which swipes up the page.
func (*ClamshellActionHandler) SwitchToAppWindow ¶
func (cl *ClamshellActionHandler) SwitchToAppWindow(appName string) action.Action
SwitchToAppWindow returns a function which switches to the window of the given app. If the APP has multiple windows, it will switch to the first window.
func (*ClamshellActionHandler) SwitchToAppWindowByIndex ¶
func (cl *ClamshellActionHandler) SwitchToAppWindowByIndex(appName string, targetIdx int) action.Action
SwitchToAppWindowByIndex returns a function which switches to the specific window identified by the window name of the given APP. It is used when the APP has multiple windows.
func (*ClamshellActionHandler) SwitchToAppWindowByName ¶
func (cl *ClamshellActionHandler) SwitchToAppWindowByName(appName, targetName string) action.Action
SwitchToAppWindowByName switches to the specific window identified by the window name of the given APP. It is used when the APP has multiple windows.
func (*ClamshellActionHandler) SwitchToChromeTabByIndex ¶
func (cl *ClamshellActionHandler) SwitchToChromeTabByIndex(tabIdxDest int) action.Action
SwitchToChromeTabByIndex returns a function which switches to the tab identified by the tab index in the current chrome window.
func (*ClamshellActionHandler) SwitchToChromeTabByName ¶
func (cl *ClamshellActionHandler) SwitchToChromeTabByName(tabNameDest string) action.Action
SwitchToChromeTabByName returns a function which switches the Chrome tab to the one with the given name through UI operation. The tab name must exact match. If multiple tabs with same name, it goes to the first one.
func (*ClamshellActionHandler) SwitchToLRUWindow ¶
func (cl *ClamshellActionHandler) SwitchToLRUWindow(opt SwitchWindowOption) action.Action
SwitchToLRUWindow returns a function which switches the window to LRU (Least Recently Used) one. opt specifies the way of switching.
func (*ClamshellActionHandler) SwitchToNextChromeTab ¶
func (cl *ClamshellActionHandler) SwitchToNextChromeTab() action.Action
SwitchToNextChromeTab returns a function which switches to the next Chrome tab by key event.
func (*ClamshellActionHandler) SwitchWindow ¶
func (cl *ClamshellActionHandler) SwitchWindow() action.Action
SwitchWindow returns a function which switches to the next window by key event.
type FixtureData ¶
type FixtureData struct { ARC *arc.ARC LacrosFixt lacrosfixt.FixtValue // contains filtered or unexported fields }
FixtureData is the struct returned by the preconditions.
func (FixtureData) Chrome ¶
func (f FixtureData) Chrome() *chrome.Chrome
Chrome gets the CrOS-chrome instance.
type MetricConfig ¶
type MetricConfig struct {
// contains filtered or unexported fields
}
MetricConfig is the configuration for the recorder.
func MetricConfigs ¶
func MetricConfigs(tconns []*chrome.TestConn) []MetricConfig
MetricConfigs returns metrics which are required to be collected by CUJ tests. tconns specifies which test API connections (ash-Chrome or lacros-Chrome) the metric should be collected from. Refer to go/speara-metrics.
func NewCustomMetricConfig ¶
func NewCustomMetricConfig(histogramName, unit string, direction perf.Direction, jankCriteria []int64) MetricConfig
NewCustomMetricConfig creates a new MetricConfig for the given histogram name, unit, direction, and jankCriteria. The data are reported as-is but not aggregated with other histograms.
func NewCustomMetricConfigWithTestConn
deprecated
func NewCustomMetricConfigWithTestConn(histogramName, unit string, direction perf.Direction, jankCriteria []int64, tconn *chrome.TestConn) MetricConfig
NewCustomMetricConfigWithTestConn works like NewCustomMetricConfig but allows specifying a TestConn to pull histogram data.
Deprecated: Use NewCustomMetricConfigWithTestConns instead.
func NewCustomMetricConfigWithTestConns ¶
func NewCustomMetricConfigWithTestConns(histogramName, unit string, direction perf.Direction, jankCriteria []int64, tconns []*chrome.TestConn) MetricConfig
NewCustomMetricConfigWithTestConns works like NewCustomMetricConfig but allows specifying one or multiple test API connections to pull histogram data.
func NewLatencyMetricConfig ¶
func NewLatencyMetricConfig(histogramName string) MetricConfig
NewLatencyMetricConfig creates a new MetricConfig instance for collecting input latency data for the given histogram name. The whole data of all input latency metrics will be aggregated into the "InputLatency" entry at the end.
func NewLatencyMetricConfigWithTestConn
deprecated
func NewLatencyMetricConfigWithTestConn(histogramName string, tconn *chrome.TestConn) MetricConfig
NewLatencyMetricConfigWithTestConn works like NewLatencyMetricConfig but allows specifying a TestConn to pull histogram data.
Deprecated: Use NewLatencyMetricConfigWithTestConns instead.
func NewLatencyMetricConfigWithTestConns ¶
func NewLatencyMetricConfigWithTestConns(histogramName string, tconns []*chrome.TestConn) MetricConfig
NewLatencyMetricConfigWithTestConns works like NewLatencyMetricConfig but allows specifying one or multiple test API conns to pull histogram data.
func NewSmoothnessMetricConfig ¶
func NewSmoothnessMetricConfig(histogramName string) MetricConfig
NewSmoothnessMetricConfig creates a new MetricConfig instance for collecting animation smoothness data for the given histogram name. The whole data of all smoothness metrics will be aggregated into the "AnimationSmoothness" entry at the end.
func NewSmoothnessMetricConfigWithTestConn
deprecated
func NewSmoothnessMetricConfigWithTestConn(histogramName string, tconn *chrome.TestConn) MetricConfig
NewSmoothnessMetricConfigWithTestConn works like NewSmoothnessMetricConfig but allows specifying a TestConn to pull histogram data.
Deprecated: Use NewSmoothnessMetricConfigWithTestConns instead.
func NewSmoothnessMetricConfigWithTestConns ¶
func NewSmoothnessMetricConfigWithTestConns(histogramName string, tconns []*chrome.TestConn) MetricConfig
NewSmoothnessMetricConfigWithTestConns works like NewSmoothnessMetricConfig but allows specifying one or multiple test API conns to pull histogram data.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder is a utility to measure various metrics for CUJ-style tests.
func NewRecorder ¶
func NewRecorder(ctx context.Context, cr *chrome.Chrome, a *arc.ARC, options RecorderOptions, configs ...MetricConfig) (*Recorder, error)
NewRecorder creates a Recorder based on the configs. It also aggregates the metrics of each category (animation smoothness and input latency) and creates the aggregated reports.
func (*Recorder) EnableTracing ¶
EnableTracing enables tracing when the recorder running test scenario.
func (*Recorder) Record ¶
Record creates the reporting values from the currently stored data points and sets the values into pv.
func (*Recorder) Run ¶
Run conducts the test scenario f, and collects the related metrics for the test scenario, and updates the internal data.
This function should be kept to the bare minimum, all relevant changes should go into StartRecording()/StopRecording() to allow tests with different runners to accommodate them.
This function also serves as an example for test developers on how to incorporate CUJ data recording into other tests.
func (*Recorder) RunFor ¶
func (r *Recorder) RunFor(ctx context.Context, f func(ctx context.Context) error, minimumDuration time.Duration) error
RunFor conducts the test scenario f repeatedly for a given minimum duration. It may exceed that duration to complete the last call to f.
func (*Recorder) SaveHistograms ¶
SaveHistograms saves histogram raw data to a given directory in a file named "recorder_histograms.json" by marshal the recorders.
func (*Recorder) StartRecording ¶
StartRecording starts to record CUJ data.
In: * context to initialize data recording (and tracing if needed).
Out:
- New context (with reduced timeout) that should be used to run the test function.
- Error
func (*Recorder) StopRecording ¶
StopRecording stops CUJ data recording.
In:
- context used to initialise recording (the one that was passed to the StartRecording above).
- shorted context returned from the StartRecording()
Out: * Error
type RecorderOptions ¶
type RecorderOptions struct { DoNotChangeWifi bool DoNotChangePowerd bool DoNotChangeDPTF bool DoNotChangeAudio bool DoNotChangeBluetooth bool }
RecorderOptions indicates whether the services should not be changed. The following options are allowed the status of which is determined based on the test.
func NewPerformanceCUJOptions ¶
func NewPerformanceCUJOptions() RecorderOptions
NewPerformanceCUJOptions indicates the power test settings for performance CUJs run by partners.
type SwitchWindowOption ¶
type SwitchWindowOption int
SwitchWindowOption defines types of operations of switching window.
const ( // SwitchWindowThroughHotseat specifies switch window through hotseat. SwitchWindowThroughHotseat SwitchWindowOption = iota // SwitchWindowThroughOverview specifies switch window through overview. SwitchWindowThroughOverview // SwitchWindowThroughKeyEvent specifies switch window through key event. SwitchWindowThroughKeyEvent // SwitchWindowThroughShelf specifies switch window through shelf. SwitchWindowThroughShelf = SwitchWindowThroughHotseat )
type TPSValidationHelper ¶
type TPSValidationHelper struct {
// contains filtered or unexported fields
}
TPSValidationHelper is a helper to produce extra CPU/memory load.
func NewTPSValidationHelper ¶
func NewTPSValidationHelper(ctx context.Context) *TPSValidationHelper
NewTPSValidationHelper creates a new instance of TPSValidationHelper.
func (*TPSValidationHelper) Release ¶
func (vh *TPSValidationHelper) Release() error
Release kills the extra load process.
func (*TPSValidationHelper) Stress ¶
func (vh *TPSValidationHelper) Stress() error
Stress starts to run the bash script to increase CPU/memory load.
type Tab ¶
type Tab struct { ID int `json:"ID"` Index int `json:"index"` Title string `json:"title"` URL string `json:"url"` Active bool `json:"active"` }
Tab holds information obtained from the chrome.tabs API. See https://developer.chrome.com/docs/extensions/reference/tabs/#type-Tab
type TabCrashChecker ¶
type TabCrashChecker struct {
// contains filtered or unexported fields
}
TabCrashChecker is used to check if any Chrome tab is crashed during CUJ test.
func NewTabCrashChecker ¶
NewTabCrashChecker creates a TabCrashChecker and starts recording tab-crash metrics.
type TabletActionHandler ¶
type TabletActionHandler struct {
// contains filtered or unexported fields
}
TabletActionHandler defines the action on tablet devices.
func NewTabletActionHandler ¶
func NewTabletActionHandler(ctx context.Context, tconn *chrome.TestConn) (*TabletActionHandler, error)
NewTabletActionHandler returns the action handler which is responsible for handling UI actions on tablet.
func (*TabletActionHandler) Click ¶
func (t *TabletActionHandler) Click(finder *nodewith.Finder) action.Action
Click returns a function that taps the node found by input finder on tablet.
func (*TabletActionHandler) ClickUntil ¶
func (t *TabletActionHandler) ClickUntil(finder *nodewith.Finder, condition func(context.Context) error) action.Action
ClickUntil returns a function that repeatedly left clicks the node until the condition returns no error. It will try to click the node once before it checks the condition.
func (*TabletActionHandler) Close ¶
func (t *TabletActionHandler) Close()
Close releases the underlying resouses. Tests should always defer calls to this once the UIActionHandler instance been created.
func (*TabletActionHandler) LaunchChrome ¶
LaunchChrome launches the Chrome browser.
func (*TabletActionHandler) MinimizeAllWindow ¶
func (t *TabletActionHandler) MinimizeAllWindow() action.Action
MinimizeAllWindow returns a function which minimizes all window.
func (*TabletActionHandler) NewChromeTab ¶
func (t *TabletActionHandler) NewChromeTab(ctx context.Context, br *browser.Browser, url string, newWindow bool) (*chrome.Conn, error)
NewChromeTab creates a new tab of Google Chrome. newWindow indicates whether this new tab should open in current Chrome window or in new Chrome window. TODO (b/227525974): Support lacros-Chrome.
func (*TabletActionHandler) ScrollChromePage ¶
func (t *TabletActionHandler) ScrollChromePage(ctx context.Context) []action.Action
ScrollChromePage generate the scroll action.
func (*TabletActionHandler) SwipeDown ¶
func (t *TabletActionHandler) SwipeDown() action.Action
SwipeDown returns a function which swipes down the page.
func (*TabletActionHandler) SwipeUp ¶
func (t *TabletActionHandler) SwipeUp() action.Action
SwipeUp returns a function which swipes up the page.
func (*TabletActionHandler) SwitchToAppWindow ¶
func (t *TabletActionHandler) SwitchToAppWindow(appName string) action.Action
SwitchToAppWindow returns a function which switches to the window of the given app. It is used when the APP has only one window.
func (*TabletActionHandler) SwitchToAppWindowByIndex ¶
func (t *TabletActionHandler) SwitchToAppWindowByIndex(appName string, targetIdx int) action.Action
SwitchToAppWindowByIndex returns a function which switches to the specific window identified by the window index of the given APP. It is used when the APP has multiple windows.
func (*TabletActionHandler) SwitchToAppWindowByName ¶
func (t *TabletActionHandler) SwitchToAppWindowByName(appName, targetName string) action.Action
SwitchToAppWindowByName returns a function which switches to the specific window identified by the window name of the given APP. It is used when the APP has multiple windows.
func (*TabletActionHandler) SwitchToChromeTabByIndex ¶
func (t *TabletActionHandler) SwitchToChromeTabByIndex(tabIdxDest int) action.Action
SwitchToChromeTabByIndex returns a function which switches to the tab identified by the tab index in the current chrome window.
func (*TabletActionHandler) SwitchToChromeTabByName ¶
func (t *TabletActionHandler) SwitchToChromeTabByName(tabNameDest string) action.Action
SwitchToChromeTabByName returns a function which switches the Chrome tab to the one with the given name through UI operation. The tab name must exact match. If multiple tabs with same name, it goes to the first one.
func (*TabletActionHandler) SwitchToLRUWindow ¶
func (t *TabletActionHandler) SwitchToLRUWindow(opt SwitchWindowOption) action.Action
SwitchToLRUWindow returns a function which switches to the LRU (Least Recently Used) window. opt specifies the way of switching.
func (*TabletActionHandler) SwitchToNextChromeTab ¶
func (t *TabletActionHandler) SwitchToNextChromeTab() action.Action
SwitchToNextChromeTab returns a function which switches to the next Chrome tab by key event.
func (*TabletActionHandler) SwitchWindow ¶
func (t *TabletActionHandler) SwitchWindow() action.Action
SwitchWindow returns a function which switches to the next window by key event.
type Tier ¶
type Tier int
Tier defines the complexity level of a CUJ test scenario.
const ( // Basic is the test tier covering some simple CUJ test scenarios. Basic tier CUJ tests are supposed // to run on most of the DUT models (both high-end and low-end), if not all. Basic Tier = iota // Plus is the test tier covering more test scenarios than basic tier. Plus // Premium is the test tier covering the most complex test scenarios. CUJ tests in premium tier will // drive the DUT to use more of its system resources. Premium )
type UIActionHandler ¶
type UIActionHandler interface { // Close releases the underlying resouses. // Tests should always defer calls to this once the UIActionHandler instance been created. Close() // Click returns a function that clicks or taps the node found by input finder. Click(finder *nodewith.Finder) action.Action // ClickUntil returns a function that repeatedly left clicks the node until the condition returns no error. // It will try to click the node once before it checks the condition. ClickUntil(finder *nodewith.Finder, condition func(context.Context) error) action.Action // LaunchChrome launches the Chrome browser. LaunchChrome(ctx context.Context) (time.Time, error) // NewChromeTab creates a new tab of Google Chrome. NewChromeTab(ctx context.Context, br *browser.Browser, url string, newWindow bool) (*chrome.Conn, error) // SwitchWindow returns a function which switches to the next window by key event. SwitchWindow() action.Action // SwitchToLRUWindow returns a function which switches the window to LRU (Least Recently Used) one. // opt specifies the way of switching. SwitchToLRUWindow(opt SwitchWindowOption) action.Action // SwitchToAppWindow returns a function which switches to the window of the given app. // If the APP has multiple windows, it will switch to the first window. SwitchToAppWindow(appName string) action.Action // SwitchToAppWindowByIndex returns a function which switches to // the specific window identified by the window index of the given APP. // It is used when the APP has multiple windows. SwitchToAppWindowByIndex(appName string, targetIdx int) action.Action // SwitchToAppWindowByName returns a function which switches to // the specific window identified by the window name of the given APP. // It is used when the APP has multiple windows. SwitchToAppWindowByName(appName, targetName string) action.Action // SwitchToNextChromeTab returns a function which switches to the next Chrome tab by key event. SwitchToNextChromeTab() action.Action // SwitchToChromeTabByIndex returns a function which switches to // the tab identified by the tab index in the current chrome window. SwitchToChromeTabByIndex(tabIdxDest int) action.Action // SwitchToChromeTabByName returns a function which switches the Chrome tab to // the one with the given name through UI operation. // The tab name must exact match. // If multiple tabs with same name, it goes to the first one. SwitchToChromeTabByName(tabNameDest string) action.Action // ScrollChromePage generate the scroll actions. ScrollChromePage(ctx context.Context) []action.Action // SwipeDown returns a function which swipes down the page. SwipeDown() action.Action // SwipeUp returns a function which swipes up the page. SwipeUp() action.Action // MinimizeAllWindow returns a function which minimizes all window. MinimizeAllWindow() action.Action }
UIActionHandler defines UI actions performed either on a tablet or on a clamshell UI.