Documentation ¶
Overview ¶
Package uidetection provides image-based UI detections/interactions.
Index ¶
- Constants
- Variables
- type Context
- func (uda *Context) Exists(s *Finder) uiauto.Action
- func (uda *Context) Gone(s *Finder) uiauto.Action
- func (uda *Context) LeftClick(s *Finder) uiauto.Action
- func (uda *Context) Location(ctx context.Context, s *Finder) (*Location, error)
- func (uda *Context) RightClick(s *Finder) uiauto.Action
- func (uda *Context) Tap(s *Finder) uiauto.Action
- func (uda *Context) WaitUntilExists(s *Finder) uiauto.Action
- func (uda *Context) WaitUntilGone(s *Finder) uiauto.Action
- func (uda *Context) WithInterval(interval time.Duration) *Context
- func (uda *Context) WithOptions(optionList ...Option) *Context
- func (uda *Context) WithPollOpts(pollOpts testing.PollOptions) *Context
- func (uda *Context) WithScreenshotStrategy(s ScreenshotStrategy) *Context
- func (uda *Context) WithTimeout(timeout time.Duration) *Context
- type CustomIconParam
- type CustomIconParams
- type Finder
- func (f *Finder) Above(other *Finder) *Finder
- func (f *Finder) AboveA11yNode(other *nodewith.Finder) *Finder
- func (f *Finder) AboveDp(dp int) *Finder
- func (f *Finder) AbovePx(px int) *Finder
- func (f *Finder) Below(other *Finder) *Finder
- func (f *Finder) BelowA11yNode(other *nodewith.Finder) *Finder
- func (f *Finder) BelowDp(dp int) *Finder
- func (f *Finder) BelowPx(px int) *Finder
- func (f *Finder) ExactMatch() *Finder
- func (f *Finder) First() *Finder
- func (f *Finder) LeftOf(other *Finder) *Finder
- func (f *Finder) LeftOfA11yNode(other *nodewith.Finder) *Finder
- func (f *Finder) LeftOfDp(dp int) *Finder
- func (f *Finder) LeftOfPx(px int) *Finder
- func (f *Finder) Nth(nth int) *Finder
- func (f *Finder) RightOf(other *Finder) *Finder
- func (f *Finder) RightOfA11yNode(other *nodewith.Finder) *Finder
- func (f *Finder) RightOfDp(dp int) *Finder
- func (f *Finder) RightOfPx(px int) *Finder
- func (f *Finder) Within(other *Finder) *Finder
- func (f *Finder) WithinA11yNode(other *nodewith.Finder) *Finder
- func (f *Finder) WithinDp(r coords.Rect) *Finder
- func (f *Finder) WithinPx(r coords.Rect) *Finder
- type Location
- type Option
- type Options
- type ScreenshotStrategy
- type TextParam
- type TextParams
Constants ¶
const ( // KeyType represents the var name of the key type used for UI detection API. KeyType = "uidetection.key_type" // Key represents the var name of the key used for UI detection API. Key = "uidetection.key" // Server represents the var name of the server address used for UI detection API. Server = "uidetection.server" )
const ( // ErrNotFound is the error when there is no matching elements found. ErrNotFound = "no matching elements found" // ErrMultipleMatch is the error when there are multiple matching elements found. ErrMultipleMatch = "there are multiple matches" // ErrNthNotFound is the error when the Nth element doesn't exist. ErrNthNotFound = "Nth element not found" // ErrEmptyBoundingBox is the error when the relative matchers create a // screenshot of zero size. ErrEmptyBoundingBox = "The element you're trying to screenshot has zero size" )
Variables ¶
var UIDetectionVars = []string{ KeyType, Key, Server, }
UIDetectionVars contains a list of all variables used by the UI detection library.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context provides functionalities for image-based UI automation.
func NewDefault ¶
NewDefault returns a new UI Detection automation instance with default params.
func (*Context) Gone ¶
Gone returns an action that returns nil if the specified element doesn't exist.
func (*Context) RightClick ¶
RightClick returns an action that right-clicks a finder.
func (*Context) WaitUntilExists ¶
WaitUntilExists returns an action that waits until the specified element exists.
func (*Context) WaitUntilGone ¶
WaitUntilGone returns an action that waits until the specified element doesnt exist.
func (*Context) WithInterval ¶
WithInterval returns a new Context with the specified polling interval.
func (*Context) WithOptions ¶
WithOptions returns a new Context with the specified detection options.
func (*Context) WithPollOpts ¶
func (uda *Context) WithPollOpts(pollOpts testing.PollOptions) *Context
WithPollOpts returns a new Context with the specified polling options.
func (*Context) WithScreenshotStrategy ¶
func (uda *Context) WithScreenshotStrategy(s ScreenshotStrategy) *Context
WithScreenshotStrategy returns a new Context with the specified screenshot strategy.
type CustomIconParam ¶
type CustomIconParam = func(*CustomIconParams)
CustomIconParam is a modifier to apply to CustomIconParams.
func MatchCount ¶
func MatchCount(matchCount int32) CustomIconParam
MatchCount controls the MatchCount param.
func MinConfidence ¶
func MinConfidence(minConfidence float64) CustomIconParam
MinConfidence controls the min confidence threshold.
type CustomIconParams ¶
type CustomIconParams struct { // MatchCount is the limit of number of matches. // Set to -1 to not limit the number of matches. MatchCount int32 // MinConfidence is the threshold in the range [0.0, 1.0] below which // the matches will be considered as non-existent. MinConfidence float64 }
CustomIconParams provides all of the ways which you can configure a custom icon detection.
NOTE: The default values are the recommended values. The users are not expected to modify them if the test is passing with the defaults. If the defaults are not working, the users will need to find a proper value with the trial and error method.
See https://chromium.googlesource.com/chromiumos/platform/tast/+/HEAD/docs/using_uidetection.md for more details.
func DefaultCustomIconParams ¶
func DefaultCustomIconParams() *CustomIconParams
DefaultCustomIconParams return params with default values.
type Finder ¶
type Finder struct {
// contains filtered or unexported fields
}
Finder represents a data structure that consists of arguments to find a UI element.
func CustomIcon ¶
func CustomIcon(iconFile string, paramList ...CustomIconParam) *Finder
CustomIcon returns a finder for a given icon.
func TextBlock ¶
TextBlock returns a finder for a given textblock. Use TextBlock if you want to find a group of nearby text, generally representing an entire text element. E.g. use uidetection.TextBlock([]string{"Save", "As"}) to find the "Save As" menu item.
func (*Finder) Above ¶
Above ensures that the element returned must be above the element returned by the finder on the screen.
func (*Finder) AboveA11yNode ¶
AboveA11yNode ensures that the element returned must be above the element returned by the a11y node finder on the screen.
func (*Finder) AboveDp ¶
AboveDp ensures that the element returned must be above dp display pixels on the screen.
func (*Finder) AbovePx ¶
AbovePx ensures that the element returned must be above px pixels on the screen.
func (*Finder) Below ¶
Below ensures that the element returned must be below the element returned by the finder on the screen.
func (*Finder) BelowA11yNode ¶
BelowA11yNode ensures that the element returned must be below the element returned by the a11y node finder on the screen.
func (*Finder) BelowDp ¶
BelowDp ensures that the element returned must be below dp display pixels on the screen.
func (*Finder) BelowPx ¶
BelowPx ensures that the element returned must be below px pixels on the screen.
func (*Finder) ExactMatch ¶
ExactMatch turns off the approximate match for the word finder. The results will be filtered by exact string matching. USE WITH CAUTION. Due to the performance of the OCR (optical character recognition) model, approximate match is the default behavior for error-tolerance. An example use case is when the matching word is short with two or three letters. TODO(b/211937254): Allow exact matches with max_edit_distance in new proto.
func (*Finder) First ¶
First enables the finder to choose the first match of a UI element if there are multiple matches.
func (*Finder) LeftOf ¶
LeftOf ensures that the element returned must be left of the element returned by the finder on the screen.
func (*Finder) LeftOfA11yNode ¶
LeftOfA11yNode ensures that the element returned must be left of the element returned by the a11y node finder on the screen.
func (*Finder) LeftOfDp ¶
LeftOfDp ensures that the element returned must be left of dp display pixels on the screen.
func (*Finder) LeftOfPx ¶
LeftOfPx ensures that the element returned must be left of px pixels on the screen.
func (*Finder) Nth ¶
Nth enables the finder to choose the n-th match of a UI element. if there are multiple matches.
func (*Finder) RightOf ¶
RightOf ensures that the element returned must be right of the element returned by the finder on the screen.
func (*Finder) RightOfA11yNode ¶
RightOfA11yNode ensures that the element returned must be right of the element returned by the a11y node finder on the screen.
func (*Finder) RightOfDp ¶
RightOfDp ensures that the element returned must be right of dp display pixels on the screen.
func (*Finder) RightOfPx ¶
RightOfPx ensures that the element returned must be right of px pixels on the screen.
func (*Finder) Within ¶
Within ensures that the element returned must be within the element returned by the finder on the screen.
func (*Finder) WithinA11yNode ¶
WithinA11yNode ensures that the element returned must be above the element returned by the a11y node finder on the screen.
type Location ¶
type Location struct { // Rectangle of the location. coords.Rect // Text associated with the element, if any. Text string }
Location represents the location of a matching UI element.
type Option ¶
type Option = func(*Options)
Option is a modifier to apply to Options.
func RetryInterval ¶
RetryInterval controls the interval between retries.
type Options ¶
type Options struct { // The number of times of retries. Retries int // The interval between retries. RetryInterval time.Duration }
Options provides all of the ways which you can configure the UI detection API.
func DefaultOptions ¶
func DefaultOptions() *Options
DefaultOptions return options with default values.
type ScreenshotStrategy ¶
type ScreenshotStrategy int
ScreenshotStrategy holds the different screenshot strategies that can be used for image-based UI detection.
const ( StableScreenshot ScreenshotStrategy = iota ImmediateScreenshot )
Holds all the screenshot types that can be used.
type TextParam ¶
type TextParam = func(*TextParams)
TextParam is a modifier to apply to TextParams.
func DisableApproxMatch ¶
DisableApproxMatch controls the DisableApproxMatch param.
func MaxEditDistance ¶
MaxEditDistance controls the MaxEditDistance param.
type TextParams ¶
type TextParams struct { // RegexMode indicates whether the query string is a regex or not. RegexMode bool // DisableApproxMatch disables the approximate match. // approxmiate match is enabled by default to tolerate recognition errors, // so that some similar characters (i.e., "5" and "s") are treated the same. // Normally, you don't want to turn the approxmiate match off. DisableApproxMatch bool // MaxEditDistance is the Levenshtein distance threshold. // For example "string" and "sting" is the same match if MaxEditDistance=1. // NOTE: this param is applicable only if RegexMode is False. MaxEditDistance int32 }
TextParams provides all of the ways which you can configure a word detection or a textblock detection.
NOTE: The default values are the recommended values. The users are not expected to modify them if the test is passing with the defaults. If the defaults are not working, the users will need to find a proper value with the trial and error method.
See https://chromium.googlesource.com/chromiumos/platform/tast/+/HEAD/docs/using_uidetection.md for more details.
func DefaultTextParams ¶
func DefaultTextParams() *TextParams
DefaultTextParams return params with default values.