guia2

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2021 License: MIT Imports: 20 Imported by: 2

README

Golang-UIAutomator2

go doc license

使用 Golang 实现 appium/appium-uiautomator2-server 的客户端库

扩展库

如果使用 IOS 设备, 可查看 electricbubble/gwda

安装

go get github.com/electricbubble/guia2

使用

首次使用需要在 Android 设备中安装两个 apk
appium-uiautomator2-server-debug-androidTest.apk
appium-uiautomator2-server-vXX.XX.XX.apk

apk 可以选择通过 appium/appium-uiautomator2-server 进行构建
也可以直接从这里下载 electricbubble/appium-uiautomator2-server-apk

再通过 adb 启动 appium-uiautomator2-server

adb shell am instrument -w io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner
# ⬇️ 后台运行
adb shell "nohup am instrument -w io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner >/sdcard/uia2server.log 2>&1 &"
# or
adb -s $serial shell "nohup am instrument -w io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner >/sdcard/uia2server.log 2>&1 &"
guia2.NewUSBDriver()

该函数使用期间, Android 设备必须一直保持 USB 的连接 (模拟器 也使用该函数)

guia2.NewWiFiDriver("192.168.1.28")
  1. 先通过 USB 连接 Android 设备
  2. 让设备在 5555 端口监听 TCP/IP 连接
    adb tcpip 5555
    # or
    adb -s $serial tcpip 5555
    
  3. 查询 Android 设备的 IP (这一步骤开始可选择断开 USB 连接)
  4. 通过 IP 连接 Android 设备
    adb connect $deviceIP
    
  5. 确认连接状态
    adb devices
    
    看到以下格式的设备, 说明连接成功
    $deviceIP:5555    device
    
package main

import (
	"fmt"
	"github.com/electricbubble/guia2"
	"io/ioutil"
	"log"
	"os"
)

func main() {
	driver, err := guia2.NewUSBDriver()
	// driver, err := guia2.NewWiFiDriver("192.168.1.28")
	checkErr(err)
	defer func() { _ = driver.Dispose() }()

	// err = driver.AppLaunch("tv.danmaku.bili")
	err = driver.AppLaunch("tv.danmaku.bili", guia2.BySelector{ResourceIdID: "tv.danmaku.bili:id/action_bar_root"})
	checkErr(err, "launch the app until the element appears")

	// fmt.Println(driver.Source())
	// return

	deviceSize, err := driver.DeviceSize()
	checkErr(err)

	var startX, startY, endX, endY int
	startX = deviceSize.Width / 2
	startY = deviceSize.Height / 2
	endX = startX
	endY = startY / 2
	err = driver.Swipe(startX, startY, endX, endY)
	checkErr(err)

	var startPoint, endPoint guia2.PointF
	startPoint = guia2.PointF{X: float64(startX), Y: float64(startY)}
	endPoint = guia2.PointF{X: startPoint.X, Y: startPoint.Y * 1.6}
	err = driver.SwipePointF(startPoint, endPoint)
	checkErr(err)

	element, err := driver.FindElement(guia2.BySelector{ResourceIdID: "tv.danmaku.bili:id/expand_search"})
	checkErr(err)

	err = element.Click()
	checkErr(err)

	bySelector := guia2.BySelector{UiAutomator: guia2.NewUiSelectorHelper().Focused(true).String()}
	element, err = waitForElement(driver, bySelector)
	checkErr(err)

	err = element.SendKeys("雾山五行")
	checkErr(err)

	err = driver.PressKeyCode(guia2.KCEnter, guia2.KMEmpty)
	checkErr(err)

	bySelector = guia2.BySelector{UiAutomator: guia2.NewUiSelectorHelper().TextStartsWith("番剧").String()}
	element, err = waitForElement(driver, bySelector)
	checkErr(err)
	checkErr(element.Click())

	bySelector = guia2.BySelector{UiAutomator: guia2.NewUiSelectorHelper().Text("立即观看").String()}
	element, err = waitForElement(driver, bySelector)
	checkErr(err)
	checkErr(element.Click())

	bySelector = guia2.BySelector{ResourceIdID: "tv.danmaku.bili:id/videoview_container_space"}
	element, err = waitForElement(driver, bySelector)
	checkErr(err)

	// time.Sleep(time.Second * 5)

	screenshot, err := element.Screenshot()
	checkErr(err)
	userHomeDir, _ := os.UserHomeDir()
	checkErr(ioutil.WriteFile(userHomeDir+"/Desktop/element.png", screenshot.Bytes(), 0600))

	err = driver.PressKeyCode(guia2.KCMediaPause, guia2.KMEmpty)
	checkErr(err)

	err = driver.PressBack()
	checkErr(err)
}

func waitForElement(driver *guia2.Driver, bySelector guia2.BySelector) (element *guia2.Element, err error) {
	var ce error
	exists := func(d *guia2.Driver) (bool, error) {
		element, ce = d.FindElement(bySelector)
		if ce == nil {
			return true, nil
		}
		// 如果直接返回 error 将直接终止 `driver.Wait`
		return false, nil
	}
	if err = driver.Wait(exists); err != nil {
		return nil, fmt.Errorf("%s: %w", err.Error(), ce)
	}
	return
}

func checkErr(err error, msg ...string) {
	if err == nil {
		return
	}

	var output string
	if len(msg) != 0 {
		output = msg[0] + " "
	}
	output += err.Error()
	log.Fatalln(output)
}

感谢小伙伴提供的 红米 Note 5A

example

Thanks

Thank you JetBrains for providing free open source licenses

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AdbServerHost = "localhost"
View Source
var AdbServerPort = gadb.AdbServerPort
View Source
var DefaultWaitInterval = time.Millisecond * 250
View Source
var DefaultWaitTimeout = time.Second * 60
View Source
var DeviceTempPath = "/data/local/tmp"
View Source
var HTTPClient = http.DefaultClient

HTTPClient is the default client to use to communicate with the WebDriver server.

View Source
var UIA2ServerPort = 6790

Functions

func SetDebug

func SetDebug(debug bool, adbDebug ...bool)

SetDebug set debug mode

Types

type BatteryInfo

type BatteryInfo struct {
	// Battery level in range [0.0, 1.0],
	// where 1.0 means 100% charge.
	Level  float64
	Status BatteryStatus
}

type BatteryStatus

type BatteryStatus int
const (
	BatteryStatusUnknown BatteryStatus = iota
	BatteryStatusCharging
	BatteryStatusDischarging
	BatteryStatusNotCharging
	BatteryStatusFull
)

func (BatteryStatus) String

func (bs BatteryStatus) String() string

type BySelector

type BySelector struct {
	// Set the search criteria to match the given resource ResourceIdID.
	ResourceIdID string `json:"id"`
	// Set the search criteria to match the content-description property for a widget.
	ContentDescription string `json:"accessibility id"`
	XPath              string `json:"xpath"`
	// Set the search criteria to match the class property for a widget (for example, "android.widget.Button").
	ClassName   string `json:"class name"`
	UiAutomator string `json:"-android uiautomator"`
}

type Capabilities

type Capabilities map[string]interface{}

func NewEmptyCapabilities

func NewEmptyCapabilities() Capabilities

type ClipDataType

type ClipDataType string
const ClipDataTypePlaintext ClipDataType = "PLAINTEXT"

type Condition

type Condition func(d *Driver) (bool, error)

type Device added in v0.0.3

type Device = gadb.Device

func DeviceList added in v0.0.3

func DeviceList() (devices []Device, err error)

type DeviceInfo

type DeviceInfo struct {
	// ANDROID_ID A 64-bit number (as a hex string) that is uniquely generated when the user
	// first sets up the device and should remain constant for the lifetime of the user's device. The value
	// may change if a factory reset is performed on the device.
	AndroidID string `json:"androidId"`
	// Build.MANUFACTURER value
	Manufacturer string `json:"manufacturer"`
	// Build.MODEL value
	Model string `json:"model"`
	// Build.BRAND value
	Brand string `json:"brand"`
	// Current running OS's API VERSION
	APIVersion string `json:"apiVersion"`
	// The current version string, for example "1.0" or "3.4b5"
	PlatformVersion string `json:"platformVersion"`
	// the name of the current celluar network carrier
	CarrierName string `json:"carrierName"`
	// the real size of the default display
	RealDisplaySize string `json:"realDisplaySize"`
	// The logical density of the display in Density Independent Pixel units.
	DisplayDensity int `json:"displayDensity"`
	// available networks
	Networks []networkInfo `json:"networks"`
	// current system locale
	Locale string `json:"locale"`
	// current system timezone
	// e.g. "Asia/Tokyo", "America/Caracas", "Asia/Shanghai"
	TimeZone  string `json:"timeZone"`
	Bluetooth struct {
		State string `json:"state"`
	} `json:"bluetooth"`
}

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

func NewDriver

func NewDriver(capabilities Capabilities, urlPrefix string) (driver *Driver, err error)

func NewUSBDriver added in v0.0.3

func NewUSBDriver(device ...Device) (driver *Driver, err error)

func NewWiFiDriver added in v0.0.4

func NewWiFiDriver(ip string, uia2Port ...int) (driver *Driver, err error)

func (*Driver) ActiveAppActivity added in v0.0.3

func (d *Driver) ActiveAppActivity() (appActivity string, err error)

func (*Driver) ActiveAppPackageName added in v0.0.3

func (d *Driver) ActiveAppPackageName() (appPackageName string, err error)

func (*Driver) ActiveElement added in v0.1.0

func (d *Driver) ActiveElement() (elem *Element, err error)

func (*Driver) ActiveSessionID

func (d *Driver) ActiveSessionID() string

func (*Driver) AlertAccept

func (d *Driver) AlertAccept(buttonLabel ...string) (err error)

func (*Driver) AlertDismiss

func (d *Driver) AlertDismiss(buttonLabel ...string) (err error)

func (*Driver) AlertText

func (d *Driver) AlertText() (text string, err error)

AlertText get text of the on-screen dialog

func (*Driver) AppInstall added in v0.0.6

func (d *Driver) AppInstall(apkPath string, reinstall ...bool) (err error)

func (*Driver) AppLaunch added in v0.0.3

func (d *Driver) AppLaunch(appPackageName string, waitForComplete ...BySelector) (err error)

func (*Driver) AppTerminate added in v0.0.3

func (d *Driver) AppTerminate(appPackageName string) (err error)

func (*Driver) AppUninstall added in v0.0.6

func (d *Driver) AppUninstall(appPackageName string, keepDataAndCache ...bool) (err error)

func (*Driver) BatteryInfo

func (d *Driver) BatteryInfo() (info BatteryInfo, err error)

func (*Driver) DeviceInfo

func (d *Driver) DeviceInfo() (info DeviceInfo, err error)

func (*Driver) DeviceScaleRatio

func (d *Driver) DeviceScaleRatio() (scale float64, err error)

DeviceScaleRatio get device pixel ratio

func (*Driver) DeviceSize

func (d *Driver) DeviceSize() (deviceSize Size, err error)

DeviceSize get window size of the device

func (*Driver) Dispose added in v0.0.3

func (d *Driver) Dispose() (err error)

Dispose corresponds to the command:

adb -s $serial forward --remove $localPort

func (*Driver) Drag

func (d *Driver) Drag(startX, startY, endX, endY int, steps ...int) (err error)

Drag performs a swipe from one coordinate to another coordinate. You can control the smoothness and speed of the swipe by specifying the number of steps. Each step execution is throttled to 5 milliseconds per step, so for a 100 steps, the swipe will take around 0.5 seconds to complete.

func (*Driver) DragFloat

func (d *Driver) DragFloat(startX, startY, endX, endY float64, steps ...int) error

func (*Driver) DragPoint

func (d *Driver) DragPoint(startPoint Point, endPoint Point, steps ...int) error

func (*Driver) DragPointF

func (d *Driver) DragPointF(startPoint PointF, endPoint PointF, steps ...int) (err error)

func (*Driver) FindElement

func (d *Driver) FindElement(by BySelector) (elem *Element, err error)

func (*Driver) FindElements

func (d *Driver) FindElements(by BySelector) (elements []*Element, err error)

func (*Driver) Flick

func (d *Driver) Flick(xSpeed, ySpeed int) (err error)

func (*Driver) GetAppiumSettings

func (d *Driver) GetAppiumSettings() (settings map[string]interface{}, err error)

func (*Driver) GetClipboard

func (d *Driver) GetClipboard(contentType ...ClipDataType) (content string, err error)

func (*Driver) LongPressKeyCode

func (d *Driver) LongPressKeyCode(keyCode KeyCode, metaState KeyMeta, flags ...KeyFlag) (err error)
public class KeyCodeModel extends BaseModel {
   @RequiredField
   public Integer keycode;
   public Integer metastate;
   public Integer flags;
}

func (*Driver) MultiPointerGesture

func (d *Driver) MultiPointerGesture(gesture1 *TouchAction, gesture2 *TouchAction, tas ...*TouchAction) (err error)

func (*Driver) NetworkConnection

func (d *Driver) NetworkConnection(networkType NetworkType) (err error)

NetworkConnection always turn on

func (*Driver) NewSession

func (d *Driver) NewSession(capabilities Capabilities) (sessionID string, err error)

func (*Driver) OpenNotification

func (d *Driver) OpenNotification() (err error)

OpenNotification opens the notification shade.

func (*Driver) Orientation

func (d *Driver) Orientation() (orientation Orientation, err error)

func (*Driver) PerformW3CActions

func (d *Driver) PerformW3CActions(action W3CAction, acts ...W3CAction) (err error)

func (*Driver) PressBack

func (d *Driver) PressBack() (err error)

PressBack simulates a short press on the BACK button.

func (*Driver) PressKeyCode

func (d *Driver) PressKeyCode(keyCode KeyCode, metaState KeyMeta, flags ...KeyFlag) (err error)

func (*Driver) PressKeyCodeAsync

func (d *Driver) PressKeyCodeAsync(keyCode KeyCode, metaState ...KeyMeta) (err error)

PressKeyCodeAsync simulates a short press using a key code.

func (*Driver) Quit

func (d *Driver) Quit() (err error)

func (*Driver) Rotation

func (d *Driver) Rotation() (rotation Rotation, err error)

func (*Driver) Screenshot

func (d *Driver) Screenshot() (raw *bytes.Buffer, err error)

Screenshot grab device screenshot

func (*Driver) ScrollTo

func (d *Driver) ScrollTo(by BySelector, maxSwipes ...int) (err error)

func (*Driver) SendKeys

func (d *Driver) SendKeys(text string, isReplace ...bool) (err error)

func (*Driver) SessionDetails

func (d *Driver) SessionDetails() (scrollData map[string]interface{}, err error)

func (*Driver) SessionIDs

func (d *Driver) SessionIDs() (sessionIDs []string, err error)

func (*Driver) SetAppiumSettings

func (d *Driver) SetAppiumSettings(settings map[string]interface{}) (err error)

func (*Driver) SetClipboard

func (d *Driver) SetClipboard(contentType ClipDataType, content string, label ...string) (err error)

func (*Driver) SetOrientation

func (d *Driver) SetOrientation(orientation Orientation) (err error)

func (*Driver) SetRotation

func (d *Driver) SetRotation(rotation Rotation) (err error)

SetRotation

`x` and `y` are ignored. We only care about `z`
0/90/180/270

func (*Driver) Source

func (d *Driver) Source() (sXML string, err error)

Source get page source

func (*Driver) Status

func (d *Driver) Status() (ready bool, err error)

func (*Driver) StatusBarHeight

func (d *Driver) StatusBarHeight() (height int, err error)

StatusBarHeight get status bar height of the device

func (*Driver) Swipe

func (d *Driver) Swipe(startX, startY, endX, endY int, steps ...int) (err error)

Swipe performs a swipe from one coordinate to another using the number of steps to determine smoothness and speed. Each step execution is throttled to 5ms per step. So for a 100 steps, the swipe will take about 1/2 second to complete.

`steps` is the number of move steps sent to the system

func (*Driver) SwipeFloat

func (d *Driver) SwipeFloat(startX, startY, endX, endY float64, steps ...int) (err error)

func (*Driver) SwipePoint

func (d *Driver) SwipePoint(startPoint, endPoint Point, steps ...int) (err error)

func (*Driver) SwipePointF

func (d *Driver) SwipePointF(startPoint, endPoint PointF, steps ...int) (err error)

func (*Driver) Tap

func (d *Driver) Tap(x, y int) (err error)

Tap perform a click at arbitrary coordinates specified

func (*Driver) TapFloat

func (d *Driver) TapFloat(x, y float64) (err error)

func (*Driver) TapPoint

func (d *Driver) TapPoint(point Point) (err error)

func (*Driver) TapPointF

func (d *Driver) TapPointF(point PointF) (err error)

func (*Driver) TouchDown

func (d *Driver) TouchDown(x, y int) (err error)

func (*Driver) TouchDownPoint

func (d *Driver) TouchDownPoint(point Point) error

func (*Driver) TouchLongClick

func (d *Driver) TouchLongClick(x, y int, duration ...float64) (err error)

func (*Driver) TouchLongClickPoint

func (d *Driver) TouchLongClickPoint(point Point, duration ...float64) (err error)

func (*Driver) TouchMove

func (d *Driver) TouchMove(x, y int) (err error)

func (*Driver) TouchMovePoint

func (d *Driver) TouchMovePoint(point Point) error

func (*Driver) TouchUp

func (d *Driver) TouchUp(x, y int) (err error)

func (*Driver) TouchUpPoint

func (d *Driver) TouchUpPoint(point Point) error

func (*Driver) Wait

func (d *Driver) Wait(condition Condition) error

Wait works like WaitWithTimeoutAndInterval, but using the default timeout and polling interval.

func (*Driver) WaitWithTimeout

func (d *Driver) WaitWithTimeout(condition Condition, timeout float64) error

WaitWithTimeout works like WaitWithTimeoutAndInterval, but with default polling interval.

func (*Driver) WaitWithTimeoutAndInterval

func (d *Driver) WaitWithTimeoutAndInterval(condition Condition, timeout, interval float64) (err error)

WaitWithTimeoutAndInterval waits for the condition to evaluate to true.

type Element

type Element struct {
	// contains filtered or unexported fields
}

func (*Element) Clear

func (e *Element) Clear() (err error)

func (*Element) Click

func (e *Element) Click() (err error)

func (*Element) ContentDescription

func (e *Element) ContentDescription() (name string, err error)

func (*Element) Drag

func (e *Element) Drag(endX, endY int, steps ...int) (err error)

func (*Element) DragFloat

func (e *Element) DragFloat(endX, endY float64, steps ...int) error

func (*Element) DragPoint

func (e *Element) DragPoint(endPoint Point, steps ...int) error

func (*Element) DragPointF

func (e *Element) DragPointF(endPoint PointF, steps ...int) (err error)

func (*Element) DragTo

func (e *Element) DragTo(destElem *Element, steps ...int) error

func (*Element) FindElement

func (e *Element) FindElement(by BySelector) (elem *Element, err error)

func (*Element) FindElements

func (e *Element) FindElements(by BySelector) (elements []*Element, err error)

func (*Element) Flick

func (e *Element) Flick(xOffset, yOffset, speed int) (err error)

func (*Element) GetAttribute

func (e *Element) GetAttribute(name string) (attribute string, err error)

func (*Element) Location

func (e *Element) Location() (point Point, err error)

func (*Element) Rect

func (e *Element) Rect() (rect Rect, err error)

func (*Element) Screenshot

func (e *Element) Screenshot() (raw *bytes.Buffer, err error)

func (*Element) ScrollTo

func (e *Element) ScrollTo(by BySelector, maxSwipes ...int) (err error)

func (*Element) ScrollToElement

func (e *Element) ScrollToElement(element *Element) (err error)

func (*Element) SendKeys

func (e *Element) SendKeys(text string, isReplace ...bool) (err error)

func (*Element) Size

func (e *Element) Size() (size Size, err error)

func (*Element) Swipe

func (e *Element) Swipe(startX, startY, endX, endY int, steps ...int) (err error)

func (*Element) SwipeFloat

func (e *Element) SwipeFloat(startX, startY, endX, endY float64, steps ...int) (err error)

func (*Element) SwipePoint

func (e *Element) SwipePoint(startPoint, endPoint Point, steps ...int) (err error)

func (*Element) SwipePointF

func (e *Element) SwipePointF(startPoint, endPoint PointF, steps ...int) (err error)

func (*Element) Text

func (e *Element) Text() (text string, err error)

type KeyCode

type KeyCode int
const (

	// KCSoftLeft Soft Left key
	// Usually situated below the display on phones and used as a multi-function
	// feature key for selecting a software defined function shown on the bottom left
	// of the display.
	KCSoftLeft KeyCode = 1

	// KCSoftRight Soft Right key.
	// Usually situated below the display on phones and used as a multi-function
	// feature key for selecting a software defined function shown on the bottom right
	// of the display.
	KCSoftRight KeyCode = 2

	// KCHome Home key.
	// This key is handled by the framework and is never delivered to applications.
	KCHome KeyCode = 3

	KCBack    KeyCode = 4  // Back key
	KCCall    KeyCode = 5  // Call key
	KCEndCall KeyCode = 6  // End Call key
	KC0       KeyCode = 7  // '0' key
	KC1       KeyCode = 8  // '1' key
	KC2       KeyCode = 9  // '2' key
	KC3       KeyCode = 10 // '3' key
	KC4       KeyCode = 11 // '4' key
	KC5       KeyCode = 12 // '5' key
	KC6       KeyCode = 13 // '6' key
	KC7       KeyCode = 14 // '7' key
	KC8       KeyCode = 15 // '8' key
	KC9       KeyCode = 16 // '9' key
	KCStar    KeyCode = 17 // '*' key
	KCPound   KeyCode = 18 // '#' key

	// KCDPadUp KeycodeDPadUp Directional Pad Up key.
	// May also be synthesized from trackball motions.
	KCDPadUp KeyCode = 19

	// KCDPadDown Directional Pad Down key.
	// May also be synthesized from trackball motions.
	KCDPadDown KeyCode = 20

	// KCDPadLeft Directional Pad Left key.
	// May also be synthesized from trackball motions.
	KCDPadLeft KeyCode = 21

	// KCDPadRight Directional Pad Right key.
	// May also be synthesized from trackball motions.
	KCDPadRight KeyCode = 22

	// KCDPadCenter Directional Pad Center key.
	// May also be synthesized from trackball motions.
	KCDPadCenter KeyCode = 23

	// KCVolumeUp Volume Up key.
	// Adjusts the speaker volume up.
	KCVolumeUp KeyCode = 24

	// KCVolumeDown Volume Down key.
	// Adjusts the speaker volume down.
	KCVolumeDown KeyCode = 25

	// KCPower Power key.
	KCPower KeyCode = 26

	// KCCamera Camera key.
	// Used to launch a camera application or take pictures.
	KCCamera KeyCode = 27

	KCClear      KeyCode = 28 // Clear key
	KCa          KeyCode = 29 // 'a' key
	KCb          KeyCode = 30 // 'b' key
	KCc          KeyCode = 31 // 'c' key
	KCd          KeyCode = 32 // 'd' key
	KCe          KeyCode = 33 // 'e' key
	KCf          KeyCode = 34 // 'f' key
	KCg          KeyCode = 35 // 'g' key
	KCh          KeyCode = 36 // 'h' key
	KCi          KeyCode = 37 // 'i' key
	KCj          KeyCode = 38 // 'j' key
	KCk          KeyCode = 39 // 'k' key
	KCl          KeyCode = 40 // 'l' key
	KCm          KeyCode = 41 // 'm' key
	KCn          KeyCode = 42 // 'n' key
	KCo          KeyCode = 43 // 'o' key
	KCp          KeyCode = 44 // 'p' key
	KCq          KeyCode = 45 // 'q' key
	KCr          KeyCode = 46 // 'r' key
	KCs          KeyCode = 47 // 's' key
	KCt          KeyCode = 48 // 't' key
	KCu          KeyCode = 49 // 'u' key
	KCv          KeyCode = 50 // 'v' key
	KCw          KeyCode = 51 // 'w' key
	KCx          KeyCode = 52 // 'x' key
	KCy          KeyCode = 53 // 'y' key
	KCz          KeyCode = 54 // 'z' key
	KCComma      KeyCode = 55 // ',' key
	KCPeriod     KeyCode = 56 // '.' key
	KCAltLeft    KeyCode = 57 // Left Alt modifier key
	KCAltRight   KeyCode = 58 // Right Alt modifier key
	KCShiftLeft  KeyCode = 59 // Left Shift modifier key
	KCShiftRight KeyCode = 60 // Right Shift modifier key
	KCTab        KeyCode = 61 // Tab key
	KCSpace      KeyCode = 62 // Space key

	// KCSym Symbol modifier key.
	// Used to enter alternate symbols.
	KCSym KeyCode = 63

	// KCExplorer Explorer special function key.
	// Used to launch a browser application.
	KCExplorer KeyCode = 64

	// KCEnvelope Envelope special function key.
	// Used to launch a mail application.
	KCEnvelope KeyCode = 65

	// KCEnter Enter key.
	KCEnter KeyCode = 66

	// KCDel Backspace key.
	// Deletes characters before the insertion point, unlike `KCForwardDel`.
	KCDel KeyCode = 67

	KCGrave        KeyCode = 68 // '`' (backtick) key
	KCMinus        KeyCode = 69 // '-'
	KCEquals       KeyCode = 70 // '=' key
	KCLeftBracket  KeyCode = 71 // '[' key
	KCRightBracket KeyCode = 72 // ']' key
	KCBackslash    KeyCode = 73 // '\' key
	KCSemicolon    KeyCode = 74 // ” key
	KCApostrophe   KeyCode = 75 // ”' (apostrophe) key
	KCSlash        KeyCode = 76 // '/' key
	KCAt           KeyCode = 77 // '@' key

	// KCNum Number modifier key.
	// Used to enter numeric symbols.
	// This key is not Num Lock; it is more like `KCAltLeft` and is
	// interpreted as an ALT key by {@link android.text.method.MetaKeyKeyListener}.
	KCNum KeyCode = 78

	// KCHeadsetHook Headset Hook key.
	// Used to hang up calls and stop media.
	KCHeadsetHook KeyCode = 79

	// KCFocus Camera Focus key.
	// Used to focus the camera.
	// *Camera* focus
	KCFocus KeyCode = 80

	KCPlus             KeyCode = 81 // '+' key.
	KCMenu             KeyCode = 82 // Menu key.
	KCNotification     KeyCode = 83 // Notification key.
	KCSearch           KeyCode = 84 // Search key.
	KCMediaPlayPause   KeyCode = 85 // Play/Pause media key.
	KCMediaStop        KeyCode = 86 // Stop media key.
	KCMediaNext        KeyCode = 87 // Play Next media key.
	KCMediaPrevious    KeyCode = 88 // Play Previous media key.
	KCMediaRewind      KeyCode = 89 // Rewind media key.
	KCMediaFastForward KeyCode = 90 // Fast Forward media key.

	// KCMute Mute key.
	// Mutes the microphone, unlike `KCVolumeMute`
	KCMute KeyCode = 91

	// KCPageUp Page Up key.
	KCPageUp KeyCode = 92

	// KCPageDown Page Down key.
	KCPageDown KeyCode = 93

	// KCPictSymbols Picture Symbols modifier key.
	// Used to switch symbol sets (Emoji, Kao-moji).
	// switch symbol-sets (Emoji,Kao-moji)
	KCPictSymbols KeyCode = 94

	// KCSwitchCharset Switch Charset modifier key.
	// Used to switch character sets (Kanji, Katakana).
	// switch char-sets (Kanji,Katakana)
	KCSwitchCharset KeyCode = 95

	// KCButtonA A Button key.
	// On a game controller, the A button should be either the button labeled A
	// or the first button on the bottom row of controller buttons.
	KCButtonA KeyCode = 96

	// KCButtonB B Button key.
	// On a game controller, the B button should be either the button labeled B
	// or the second button on the bottom row of controller buttons.
	KCButtonB KeyCode = 97

	// KCButtonC C Button key.
	// On a game controller, the C button should be either the button labeled C
	// or the third button on the bottom row of controller buttons.
	KCButtonC KeyCode = 98

	// KCButtonX X Button key.
	// On a game controller, the X button should be either the button labeled X
	// or the first button on the upper row of controller buttons.
	KCButtonX KeyCode = 99

	// KCButtonY Y Button key.
	// On a game controller, the Y button should be either the button labeled Y
	// or the second button on the upper row of controller buttons.
	KCButtonY KeyCode = 100

	// KCButtonZ Z Button key.
	// On a game controller, the Z button should be either the button labeled Z
	// or the third button on the upper row of controller buttons.
	KCButtonZ KeyCode = 101

	// KCButtonL1 L1 Button key.
	// On a game controller, the L1 button should be either the button labeled L1 (or L)
	// or the top left trigger button.
	KCButtonL1 KeyCode = 102

	// KCButtonR1 R1 Button key.
	// On a game controller, the R1 button should be either the button labeled R1 (or R)
	// or the top right trigger button.
	KCButtonR1 KeyCode = 103

	// KCButtonL2 L2 Button key.
	// On a game controller, the L2 button should be either the button labeled L2
	// or the bottom left trigger button.
	KCButtonL2 KeyCode = 104

	// KCButtonR2 R2 Button key.
	// On a game controller, the R2 button should be either the button labeled R2
	// or the bottom right trigger button.
	KCButtonR2 KeyCode = 105

	// KCButtonTHUMBL Left Thumb Button key.
	// On a game controller, the left thumb button indicates that the left (or only)
	// joystick is pressed.
	KCButtonTHUMBL KeyCode = 106

	// KCButtonTHUMBR Right Thumb Button key.
	// On a game controller, the right thumb button indicates that the right
	// joystick is pressed.
	KCButtonTHUMBR KeyCode = 107

	// KCButtonStart Start Button key.
	// On a game controller, the button labeled Start.
	KCButtonStart KeyCode = 108

	// KCButtonSelect Select Button key.
	// On a game controller, the button labeled Select.
	KCButtonSelect KeyCode = 109

	// KCButtonMode Mode Button key.
	// On a game controller, the button labeled Mode.
	KCButtonMode KeyCode = 110

	// KCEscape Escape key.
	KCEscape KeyCode = 111

	// KCForwardDel Forward Delete key.
	// Deletes characters ahead of the insertion point, unlike `KCDel`.
	KCForwardDel KeyCode = 112

	KCCtrlLeft   KeyCode = 113 // Left Control modifier key
	KCCtrlRight  KeyCode = 114 // Right Control modifier key
	KCCapsLock   KeyCode = 115 // Caps Lock key
	KCScrollLock KeyCode = 116 // Scroll Lock key
	KCMetaLeft   KeyCode = 117 // Left Meta modifier key
	KCMetaRight  KeyCode = 118 // Right Meta modifier key
	KCFunction   KeyCode = 119 // Function modifier key
	KCSysRq      KeyCode = 120 // System Request / Print Screen key
	KCBreak      KeyCode = 121 // Break / Pause key

	// KCMoveHome Home Movement key.
	// Used for scrolling or moving the cursor around to the start of a line
	// or to the top of a list.
	KCMoveHome KeyCode = 122

	// KCMoveEnd End Movement key.
	// Used for scrolling or moving the cursor around to the end of a line
	// or to the bottom of a list.
	KCMoveEnd KeyCode = 123

	// KCInsert Insert key.
	// Toggles insert / overwrite edit mode.
	KCInsert KeyCode = 124

	// KCForward Forward key.
	// Navigates forward in the history stack.  Complement of `KCBack`.
	KCForward KeyCode = 125

	// KCMediaPlay Play media key.
	KCMediaPlay KeyCode = 126

	// KCMediaPause Pause media key.
	KCMediaPause KeyCode = 127

	// KCMediaClose Close media key.
	// May be used to close a CD tray, for example.
	KCMediaClose KeyCode = 128

	// KCMediaEject Eject media key.
	// May be used to eject a CD tray, for example.
	KCMediaEject KeyCode = 129

	// KCMediaRecord Record media key.
	KCMediaRecord KeyCode = 130

	KCF1  KeyCode = 131 // F1 key.
	KCF2  KeyCode = 132 // F2 key.
	KCF3  KeyCode = 133 // F3 key.
	KCF4  KeyCode = 134 // F4 key.
	KCF5  KeyCode = 135 // F5 key.
	KCF6  KeyCode = 136 // F6 key.
	KCF7  KeyCode = 137 // F7 key.
	KCF8  KeyCode = 138 // F8 key.
	KCF9  KeyCode = 139 // F9 key.
	KCF10 KeyCode = 140 // F10 key.
	KCF11 KeyCode = 141 // F11 key.
	KCF12 KeyCode = 142 // F12 key.

	// KCNumLock Num Lock key.
	// This is the Num Lock key; it is different from `KCNum`.
	// This key alters the behavior of other keys on the numeric keypad.
	KCNumLock KeyCode = 143

	KCNumpad0          KeyCode = 144 // Numeric keypad '0' key
	KCNumpad1          KeyCode = 145 // Numeric keypad '1' key
	KCNumpad2          KeyCode = 146 // Numeric keypad '2' key
	KCNumpad3          KeyCode = 147 // Numeric keypad '3' key
	KCNumpad4          KeyCode = 148 // Numeric keypad '4' key
	KCNumpad5          KeyCode = 149 // Numeric keypad '5' key
	KCNumpad6          KeyCode = 150 // Numeric keypad '6' key
	KCNumpad7          KeyCode = 151 // Numeric keypad '7' key
	KCNumpad8          KeyCode = 152 // Numeric keypad '8' key
	KCNumpad9          KeyCode = 153 // Numeric keypad '9' key
	KCNumpadDivide     KeyCode = 154 // Numeric keypad '/' key (for division)
	KCNumpadMultiply   KeyCode = 155 // Numeric keypad '*' key (for multiplication)
	KCNumpadSubtract   KeyCode = 156 // Numeric keypad '-' key (for subtraction)
	KCNumpadAdd        KeyCode = 157 // Numeric keypad '+' key (for addition)
	KCNumpadDot        KeyCode = 158 // Numeric keypad '.' key (for decimals or digit grouping)
	KCNumpadComma      KeyCode = 159 // Numeric keypad ',' key (for decimals or digit grouping)
	KCNumpadEnter      KeyCode = 160 // Numeric keypad Enter key
	KCNumpadEquals     KeyCode = 161 // Numeric keypad 'KeyCode =' key
	KCNumpadLeftParen  KeyCode = 162 // Numeric keypad '(' key
	KCNumpadRightParen KeyCode = 163 // Numeric keypad ')' key

	// KCVolumeMute Volume Mute key.
	// Mutes the speaker, unlike `KCMute`.
	// This key should normally be implemented as a toggle such that the first press
	// mutes the speaker and the second press restores the original volume.
	KCVolumeMute KeyCode = 164

	// KCInfo Info key.
	// Common on TV remotes to show additional information related to what is
	// currently being viewed.
	KCInfo KeyCode = 165

	// KCChannelUp Channel up key.
	// On TV remotes, increments the television channel.
	KCChannelUp KeyCode = 166

	// KCChannelDown Channel down key.
	// On TV remotes, decrements the television channel.
	KCChannelDown KeyCode = 167

	// KCZoomIn Zoom in key.
	KCZoomIn KeyCode = 168

	// KCZoomOut Zoom out key.
	KCZoomOut KeyCode = 169

	// KCTv TV key.
	// On TV remotes, switches to viewing live TV.
	KCTv KeyCode = 170

	// KCWindow Window key.
	// On TV remotes, toggles picture-in-picture mode or other windowing functions.
	// On Android Wear devices, triggers a display offset.
	KCWindow KeyCode = 171

	// KCGuide Guide key.
	// On TV remotes, shows a programming guide.
	KCGuide KeyCode = 172

	// KCDvr DVR key.
	// On some TV remotes, switches to a DVR mode for recorded shows.
	KCDvr KeyCode = 173

	// KCBookmark Bookmark key.
	// On some TV remotes, bookmarks content or web pages.
	KCBookmark KeyCode = 174

	// KCCaptions Toggle captions key.
	// Switches the mode for closed-captioning text, for example during television shows.
	KCCaptions KeyCode = 175

	// KCSettings Settings key.
	// Starts the system settings activity.
	KCSettings KeyCode = 176

	// KCTvPower TV power key.
	// On TV remotes, toggles the power on a television screen.
	KCTvPower KeyCode = 177

	// KCTvInput TV input key.
	// On TV remotes, switches the input on a television screen.
	KCTvInput KeyCode = 178

	// KCStbPower Set-top-box power key.
	// On TV remotes, toggles the power on an external Set-top-box.
	KCStbPower KeyCode = 179

	// KCStbInput Set-top-box input key.
	// On TV remotes, switches the input mode on an external Set-top-box.
	KCStbInput KeyCode = 180

	// KCAvrPower A/V Receiver power key.
	// On TV remotes, toggles the power on an external A/V Receiver.
	KCAvrPower KeyCode = 181

	// KCAvrInput A/V Receiver input key.
	// On TV remotes, switches the input mode on an external A/V Receiver.
	KCAvrInput KeyCode = 182

	// KCProgRed Red "programmable" key.
	// On TV remotes, acts as a contextual/programmable key.
	KCProgRed KeyCode = 183

	// KCProgGreen Green "programmable" key.
	// On TV remotes, actsas a contextual/programmable key.
	KCProgGreen KeyCode = 184

	// KCProgYellow Yellow "programmable" key.
	// On TV remotes, acts as a contextual/programmable key.
	KCProgYellow KeyCode = 185

	// KCProgBlue Blue "programmable" key.
	// On TV remotes, acts as a contextual/programmable key.
	KCProgBlue KeyCode = 186

	// KCAppSwitch App switch key.
	// Should bring up the application switcher dialog.
	KCAppSwitch KeyCode = 187

	KCButton1  KeyCode = 188 // Generic Game Pad Button #1
	KCButton2  KeyCode = 189 // Generic Game Pad Button #2
	KCButton3  KeyCode = 190 // Generic Game Pad Button #3
	KCButton4  KeyCode = 191 // Generic Game Pad Button #4
	KCButton5  KeyCode = 192 // Generic Game Pad Button #5
	KCButton6  KeyCode = 193 // Generic Game Pad Button #6
	KCButton7  KeyCode = 194 // Generic Game Pad Button #7
	KCButton8  KeyCode = 195 // Generic Game Pad Button #8
	KCButton9  KeyCode = 196 // Generic Game Pad Button #9
	KCButton10 KeyCode = 197 // Generic Game Pad Button #10
	KCButton11 KeyCode = 198 // Generic Game Pad Button #11
	KCButton12 KeyCode = 199 // Generic Game Pad Button #12
	KCButton13 KeyCode = 200 // Generic Game Pad Button #13
	KCButton14 KeyCode = 201 // Generic Game Pad Button #14
	KCButton15 KeyCode = 202 // Generic Game Pad Button #15
	KCButton16 KeyCode = 203 // Generic Game Pad Button #16

	// KCLanguageSwitch Language Switch key.
	// Toggles the current input language such as switching between English and Japanese on
	// a QWERTY keyboard.  On some devices, the same function may be performed by
	// pressing Shift+Spacebar.
	KCLanguageSwitch KeyCode = 204

	// Manner Mode key.
	// Toggles silent or vibrate mode on and off to make the device behave more politely
	// in certain settings such as on a crowded train.  On some devices, the key may only
	// operate when long-pressed.
	KCMannerMode KeyCode = 205

	// 3D Mode key.
	// Toggles the display between 2D and 3D mode.
	KC3dMode KeyCode = 206

	// Contacts special function key.
	// Used to launch an address book application.
	KCContacts KeyCode = 207

	// Calendar special function key.
	// Used to launch a calendar application.
	KCCalendar KeyCode = 208

	// Music special function key.
	// Used to launch a music player application.
	KCMusic KeyCode = 209

	// Calculator special function key.
	// Used to launch a calculator application.
	KCCalculator KeyCode = 210

	// Japanese full-width / half-width key.
	KCZenkakuHankaku KeyCode = 211

	// Japanese alphanumeric key.
	KCEisu KeyCode = 212

	// Japanese non-conversion key.
	KCMuhenkan KeyCode = 213

	// Japanese conversion key.
	KCHenkan KeyCode = 214

	// Japanese katakana / hiragana key.
	KCKatakanaHiragana KeyCode = 215

	// Japanese Yen key.
	KCYen KeyCode = 216

	// Japanese Ro key.
	KCRo KeyCode = 217

	// Japanese kana key.
	KCKana KeyCode = 218

	// Assist key.
	// Launches the global assist activity.  Not delivered to applications.
	KCAssist KeyCode = 219

	// Brightness Down key.
	// Adjusts the screen brightness down.
	KCBrightnessDown KeyCode = 220

	// Brightness Up key.
	// Adjusts the screen brightness up.
	KCBrightnessUp KeyCode = 221

	// Audio Track key.
	// Switches the audio tracks.
	KCMediaAudioTrack KeyCode = 222

	// Sleep key.
	// Puts the device to sleep.  Behaves somewhat like {@link #KEYCODE_POWER} but it
	// has no effect if the device is already asleep.
	KCSleep KeyCode = 223

	// Wakeup key.
	// Wakes up the device.  Behaves somewhat like {@link #KEYCODE_POWER} but it
	// has no effect if the device is already awake.
	KCWakeup KeyCode = 224

	// Pairing key.
	// Initiates peripheral pairing mode. Useful for pairing remote control
	// devices or game controllers, especially if no other input mode is
	// available.
	KCPairing KeyCode = 225

	// Media Top Menu key.
	// Goes to the top of media menu.
	KCMediaTopMenu KeyCode = 226

	// '11' key.
	KC11 KeyCode = 227

	// '12' key.
	KC12 KeyCode = 228

	// Last Channel key.
	// Goes to the last viewed channel.
	KCLastChannel KeyCode = 229

	// TV data service key.
	// Displays data services like weather, sports.
	KCTvDataService KeyCode = 230

	// Voice Assist key.
	// Launches the global voice assist activity. Not delivered to applications.
	KCVoiceAssist KeyCode = 231

	// Radio key.
	// Toggles TV service / Radio service.
	KCTvRadioService KeyCode = 232

	// Teletext key.
	// Displays Teletext service.
	KCTvTeletext KeyCode = 233

	// Number entry key.
	// Initiates to enter multi-digit channel nubmber when each digit key is assigned
	// for selecting separate channel. Corresponds to Number Entry Mode (0x1D) of CEC
	// User Control Code.
	KCTvNumberEntry KeyCode = 234

	// Analog Terrestrial key.
	// Switches to analog terrestrial broadcast service.
	KCTvTerrestrialAnalog KeyCode = 235

	// Digital Terrestrial key.
	// Switches to digital terrestrial broadcast service.
	KCTvTerrestrialDigital KeyCode = 236

	// Satellite key.
	// Switches to digital satellite broadcast service.
	KCTvSatellite KeyCode = 237

	// BS key.
	// Switches to BS digital satellite broadcasting service available in Japan.
	KCTvSatelliteBs KeyCode = 238

	// CS key.
	// Switches to CS digital satellite broadcasting service available in Japan.
	KCTvSatelliteCs KeyCode = 239

	// BS/CS key.
	// Toggles between BS and CS digital satellite services.
	KCTvSatelliteService KeyCode = 240

	// Toggle Network key.
	// Toggles selecting broacast services.
	KCTvNetwork KeyCode = 241

	// Antenna/Cable key.
	// Toggles broadcast input source between antenna and cable.
	KCTvAntennaCable KeyCode = 242

	// HDMI #1 key.
	// Switches to HDMI input #1.
	KCTvInputHdmi1 KeyCode = 243

	// HDMI #2 key.
	// Switches to HDMI input #2.
	KCTvInputHdmi2 KeyCode = 244

	// HDMI #3 key.
	// Switches to HDMI input #3.
	KCTvInputHdmi3 KeyCode = 245

	// HDMI #4 key.
	// Switches to HDMI input #4.
	KCTvInputHdmi4 KeyCode = 246

	// Composite #1 key.
	// Switches to composite video input #1.
	KCTvInputComposite1 KeyCode = 247

	// Composite #2 key.
	// Switches to composite video input #2.
	KCTvInputComposite2 KeyCode = 248

	// Component #1 key.
	// Switches to component video input #1.
	KCTvInputComponent1 KeyCode = 249

	// Component #2 key.
	// Switches to component video input #2.
	KCTvInputComponent2 KeyCode = 250

	// VGA #1 key.
	// Switches to VGA (analog RGB) input #1.
	KCTvInputVga1 KeyCode = 251

	// Audio description key.
	// Toggles audio description off / on.
	KCTvAudioDescription KeyCode = 252

	// Audio description mixing volume up key.
	// Louden audio description volume as compared with normal audio volume.
	KCTvAudioDescriptionMixUp KeyCode = 253

	// Audio description mixing volume down key.
	// Lessen audio description volume as compared with normal audio volume.
	KCTvAudioDescriptionMixDown KeyCode = 254

	// Zoom mode key.
	// Changes Zoom mode (Normal, Full, Zoom, Wide-zoom, etc.)
	KCTvZoomMode KeyCode = 255

	// Contents menu key.
	// Goes to the title list. Corresponds to Contents Menu (0x0B) of CEC User Control
	// Code
	KCTvContentsMenu KeyCode = 256

	// Media context menu key.
	// Goes to the context menu of media contents. Corresponds to Media Context-sensitive
	// Menu (0x11) of CEC User Control Code.
	KCTvMediaContextMenu KeyCode = 257

	// Timer programming key.
	// Goes to the timer recording menu. Corresponds to Timer Programming (0x54) of
	// CEC User Control Code.
	KCTvTimerProgramming KeyCode = 258

	// Help key.
	KCHelp KeyCode = 259

	// Navigate to previous key.
	// Goes backward by one item in an ordered collection of items.
	KCNavigatePrevious KeyCode = 260

	// Navigate to next key.
	// Advances to the next item in an ordered collection of items.
	KCNavigateNext KeyCode = 261

	// Navigate in key.
	// Activates the item that currently has focus or expands to the next level of a navigation
	// hierarchy.
	KCNavigateIn KeyCode = 262

	// Navigate out key.
	// Backs out one level of a navigation hierarchy or collapses the item that currently has
	// focus.
	KCNavigateOut KeyCode = 263

	// Primary stem key for Wear
	// Main power/reset button on watch.
	KCStemPrimary KeyCode = 264

	// Generic stem key 1 for Wear
	KCStem1 KeyCode = 265

	// Generic stem key 2 for Wear
	KCStem2 KeyCode = 266

	// Generic stem key 3 for Wear
	KCStem3 KeyCode = 267

	// Directional Pad Up-Left
	KCDPadUpLeft KeyCode = 268

	// Directional Pad Down-Left
	KCDPadDownLeft KeyCode = 269

	// Directional Pad Up-Right
	KCDPadUpRight KeyCode = 270

	// Directional Pad Down-Right
	KCDPadDownRight KeyCode = 271

	// Skip forward media key.
	KCMediaSkipForward KeyCode = 272

	// Skip backward media key.
	KCMediaSkipBackward KeyCode = 273

	// Step forward media key.
	// Steps media forward, one frame at a time.
	KCMediaStepForward KeyCode = 274

	// Step backward media key.
	// Steps media backward, one frame at a time.
	KCMediaStepBackward KeyCode = 275

	// put device to sleep unless a wakelock is held.
	KCSoftSleep KeyCode = 276

	// Cut key.
	KCCut KeyCode = 277

	// Copy key.
	KCCopy KeyCode = 278

	// Paste key.
	KCPaste KeyCode = 279

	// Consumed by the system for navigation up
	KCSystemNavigationUp KeyCode = 280

	// Consumed by the system for navigation down
	KCSystemNavigationDown KeyCode = 281

	// Consumed by the system for navigation left*/
	KCSystemNavigationLeft KeyCode = 282

	// Consumed by the system for navigation right
	KCSystemNavigationRight KeyCode = 283

	// Show all apps
	KCAllApps KeyCode = 284

	// Refresh key.
	KCRefresh KeyCode = 285
)

type KeyFlag

type KeyFlag int
const (
	// KFWokeHere This mask is set if the device woke because of this key event.
	// Deprecated
	KFWokeHere KeyFlag = 0x1

	// KFSoftKeyboard This mask is set if the key event was generated by a software keyboard.
	KFSoftKeyboard KeyFlag = 0x2

	// KFKeepTouchMode This mask is set if we don't want the key event to cause us to leave touch mode.
	KFKeepTouchMode KeyFlag = 0x4

	// KFFromSystem This mask is set if an event was known to come from a trusted part
	// of the system.  That is, the event is known to come from the user,
	// and could not have been spoofed by a third party component.
	KFFromSystem KeyFlag = 0x8

	// KFEditorAction This mask is used for compatibility, to identify enter keys that are
	// coming from an IME whose enter key has been auto-labelled "next" or
	// "done".  This allows TextView to dispatch these as normal enter keys
	// for old applications, but still do the appropriate action when receiving them.
	KFEditorAction KeyFlag = 0x10

	// KFCanceled When associated with up key events, this indicates that the key press
	// has been canceled.  Typically this is used with virtual touch screen
	// keys, where the user can slide from the virtual key area on to the
	// display: in that case, the application will receive a canceled up
	// event and should not perform the action normally associated with the
	// key.  Note that for this to work, the application can not perform an
	// action for a key until it receives an up or the long press timeout has expired.
	KFCanceled KeyFlag = 0x20

	// KFVirtualHardKey This key event was generated by a virtual (on-screen) hard key area.
	// Typically this is an area of the touchscreen, outside of the regular
	// display, dedicated to "hardware" buttons.
	KFVirtualHardKey KeyFlag = 0x40

	// KFLongPress This flag is set for the first key repeat that occurs after the long press timeout.
	KFLongPress KeyFlag = 0x80

	// KFCanceledLongPress Set when a key event has `KFCanceled` set because a long
	// press action was executed while it was down.
	KFCanceledLongPress KeyFlag = 0x100

	// KFTracking Set for `ACTION_UP` when this event's key code is still being
	// tracked from its initial down.  That is, somebody requested that tracking
	// started on the key down and a long press has not caused
	// the tracking to be canceled.
	KFTracking KeyFlag = 0x200

	// KFFallback Set when a key event has been synthesized to implement default behavior
	// for an event that the application did not handle.
	// Fallback key events are generated by unhandled trackball motions
	// (to emulate a directional keypad) and by certain unhandled key presses
	// that are declared in the key map (such as special function numeric keypad
	// keys when numlock is off).
	KFFallback KeyFlag = 0x400
)

type KeyMeta

type KeyMeta int
const (
	KMEmpty     KeyMeta = 0     // As a `null`
	KMCapLocked KeyMeta = 0x100 // SHIFT key locked in CAPS mode.
	KMAltLocked KeyMeta = 0x200 // ALT key locked.
	KMSymLocked KeyMeta = 0x400 // SYM key locked.
	KMSelecting KeyMeta = 0x800 // Text is in selection mode.

)

type NetworkType

type NetworkType int
const (
	NetworkTypeWifi NetworkType = 2
)

type Orientation

type Orientation string
const (
	OrientationLandscape Orientation = "LANDSCAPE"
	OrientationPortrait  Orientation = "PORTRAIT"
)

type Point

type Point struct {
	X int `json:"x"`
	Y int `json:"y"`
}

type PointF

type PointF struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
}

type RawResponse

type RawResponse []byte

type Rect

type Rect struct {
	Point
	Size
}

type Rotation

type Rotation struct {
	X, Y, Z int
}

type Size

type Size struct {
	Width, Height int
}

type TouchAction

type TouchAction []touchGesture

func NewTouchAction

func NewTouchAction(cap ...int) *TouchAction

func (*TouchAction) Add

func (ta *TouchAction) Add(x, y int, startTime ...float64) *TouchAction

func (*TouchAction) AddFloat

func (ta *TouchAction) AddFloat(x, y float64, startTime ...float64) *TouchAction

func (*TouchAction) AddPoint

func (ta *TouchAction) AddPoint(point Point, startTime ...float64) *TouchAction

func (*TouchAction) AddPointF

func (ta *TouchAction) AddPointF(point PointF, startTime ...float64) *TouchAction

type UiSelectorHelper added in v0.0.2

type UiSelectorHelper struct {
	// contains filtered or unexported fields
}

func NewUiSelectorHelper added in v0.0.2

func NewUiSelectorHelper() UiSelectorHelper

func (UiSelectorHelper) Checkable added in v0.0.2

func (s UiSelectorHelper) Checkable(b bool) UiSelectorHelper

Checkable Set the search criteria to match widgets that are checkable.

Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text, content-description, or the class name for a widget.

If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.

func (UiSelectorHelper) Checked added in v0.0.2

func (s UiSelectorHelper) Checked(b bool) UiSelectorHelper

Checked Set the search criteria to match widgets that are currently checked (usually for checkboxes).

Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text, content-description, or the class name for a widget.

If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.

func (UiSelectorHelper) ChildSelector added in v0.0.2

func (s UiSelectorHelper) ChildSelector(selector UiSelectorHelper) UiSelectorHelper

ChildSelector Adds a child UiSelector criteria to this selector.

Use this selector to narrow the search scope to child widgets under a specific parent widget.

func (UiSelectorHelper) ClassName added in v0.0.2

func (s UiSelectorHelper) ClassName(className string) UiSelectorHelper

ClassName Set the search criteria to match the class property for a widget (for example, "android.widget.Button").

func (UiSelectorHelper) ClassNameMatches added in v0.0.2

func (s UiSelectorHelper) ClassNameMatches(regex string) UiSelectorHelper

ClassNameMatches Set the search criteria to match the class property for a widget, using a regular expression.

func (UiSelectorHelper) Clickable added in v0.0.2

func (s UiSelectorHelper) Clickable(b bool) UiSelectorHelper

Clickable Set the search criteria to match widgets that are clickable.

Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text, content-description, or the class name for a widget.

If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.

func (UiSelectorHelper) ContainerSelector added in v0.0.2

func (s UiSelectorHelper) ContainerSelector(selector UiSelectorHelper) UiSelectorHelper

func (UiSelectorHelper) Description added in v0.0.2

func (s UiSelectorHelper) Description(desc string) UiSelectorHelper

Description Set the search criteria to match the content-description property for a widget.

The content-description is typically used by the Android Accessibility framework to provide an audio prompt for the widget when the widget is selected. The content-description for the widget must match exactly with the string in your input argument.

Matching is case-sensitive.

func (UiSelectorHelper) DescriptionContains added in v0.0.2

func (s UiSelectorHelper) DescriptionContains(desc string) UiSelectorHelper

DescriptionContains Set the search criteria to match the content-description property for a widget.

The content-description is typically used by the Android Accessibility framework to provide an audio prompt for the widget when the widget is selected. The content-description for the widget must contain the string in your input argument.

Matching is case-insensitive.

func (UiSelectorHelper) DescriptionMatches added in v0.0.2

func (s UiSelectorHelper) DescriptionMatches(regex string) UiSelectorHelper

DescriptionMatches Set the search criteria to match the content-description property for a widget.

The content-description is typically used by the Android Accessibility framework to provide an audio prompt for the widget when the widget is selected. The content-description for the widget must match exactly with the string in your input argument.

func (UiSelectorHelper) DescriptionStartsWith added in v0.0.2

func (s UiSelectorHelper) DescriptionStartsWith(desc string) UiSelectorHelper

DescriptionStartsWith Set the search criteria to match the content-description property for a widget.

The content-description is typically used by the Android Accessibility framework to provide an audio prompt for the widget when the widget is selected. The content-description for the widget must start with the string in your input argument.

Matching is case-insensitive.

func (UiSelectorHelper) Enabled added in v0.0.2

func (s UiSelectorHelper) Enabled(b bool) UiSelectorHelper

Enabled Set the search criteria to match widgets that are enabled.

Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text, content-description, or the class name for a widget.

If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.

func (UiSelectorHelper) Focusable added in v0.0.2

func (s UiSelectorHelper) Focusable(b bool) UiSelectorHelper

Focusable Set the search criteria to match widgets that are focusable.

Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text, content-description, or the class name for a widget.

If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.

func (UiSelectorHelper) Focused added in v0.0.2

func (s UiSelectorHelper) Focused(b bool) UiSelectorHelper

Focused Set the search criteria to match widgets that have focus.

Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text, content-description, or the class name for a widget.

If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.

func (UiSelectorHelper) FromParent added in v0.0.2

func (s UiSelectorHelper) FromParent(selector UiSelectorHelper) UiSelectorHelper

FromParent Adds a child UiSelector criteria to this selector which is used to start search from the parent widget.

Use this selector to narrow the search scope to sibling widgets as well all child widgets under a parent.

func (UiSelectorHelper) Index added in v0.0.2

func (s UiSelectorHelper) Index(index int) UiSelectorHelper

Index Set the search criteria to match the widget by its node index in the layout hierarchy.

The index value must be 0 or greater.

Using the index can be unreliable and should only be used as a last resort for matching. Instead, consider using the `Instance(int)` method.

func (UiSelectorHelper) Instance added in v0.0.2

func (s UiSelectorHelper) Instance(instance int) UiSelectorHelper

Instance Set the search criteria to match the widget by its instance number.

The instance value must be 0 or greater, where the first instance is 0.

For example, to simulate a user click on the third image that is enabled in a UI screen, you could specify a a search criteria where the instance is 2, the `className(String)` matches the image widget class, and `enabled(boolean)` is true. The code would look like this:

`new UiSelector().className("android.widget.ImageView")
  .enabled(true).instance(2);`

func (UiSelectorHelper) LongClickable added in v0.0.2

func (s UiSelectorHelper) LongClickable(b bool) UiSelectorHelper

LongClickable Set the search criteria to match widgets that are long-clickable.

Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text, content-description, or the class name for a widget.

If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.

func (UiSelectorHelper) PackageNameMatches added in v0.0.2

func (s UiSelectorHelper) PackageNameMatches(regex string) UiSelectorHelper

PackageNameMatches Set the search criteria to match the package name of the application that contains the widget.

func (UiSelectorHelper) PatternSelector added in v0.0.2

func (s UiSelectorHelper) PatternSelector(selector UiSelectorHelper) UiSelectorHelper

func (UiSelectorHelper) ResourceId added in v0.0.2

func (s UiSelectorHelper) ResourceId(id string) UiSelectorHelper

ResourceId Set the search criteria to match the given resource ID.

func (UiSelectorHelper) ResourceIdMatches added in v0.0.2

func (s UiSelectorHelper) ResourceIdMatches(regex string) UiSelectorHelper

ResourceIdMatches Set the search criteria to match the resource ID of the widget, using a regular expression.

func (UiSelectorHelper) Scrollable added in v0.0.2

func (s UiSelectorHelper) Scrollable(b bool) UiSelectorHelper

Scrollable Set the search criteria to match widgets that are scrollable.

Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text, content-description, or the class name for a widget.

If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.

func (UiSelectorHelper) Selected added in v0.0.2

func (s UiSelectorHelper) Selected(b bool) UiSelectorHelper

Selected Set the search criteria to match widgets that are currently selected.

Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text, content-description, or the class name for a widget.

If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.

func (UiSelectorHelper) String added in v0.0.2

func (s UiSelectorHelper) String() string

func (UiSelectorHelper) Text added in v0.0.2

Text Set the search criteria to match the visible text displayed in a widget (for example, the text label to launch an app).

The text for the element must match exactly with the string in your input argument. Matching is case-sensitive.

func (UiSelectorHelper) TextContains added in v0.0.2

func (s UiSelectorHelper) TextContains(text string) UiSelectorHelper

TextContains Set the search criteria to match the visible text in a widget where the visible text must contain the string in your input argument.

The matching is case-sensitive.

func (UiSelectorHelper) TextMatches added in v0.0.2

func (s UiSelectorHelper) TextMatches(regex string) UiSelectorHelper

TextMatches Set the search criteria to match the visible text displayed in a layout element, using a regular expression.

The text in the widget must match exactly with the string in your input argument.

func (UiSelectorHelper) TextStartsWith added in v0.0.2

func (s UiSelectorHelper) TextStartsWith(text string) UiSelectorHelper

TextStartsWith Set the search criteria to match visible text in a widget that is prefixed by the text parameter.

The matching is case-insensitive.

type W3CAction

type W3CAction map[string]interface{}

func NewW3CAction

func NewW3CAction(actionType W3CActionType, gestures *W3CGestures, pointerType ...W3CPointerType) W3CAction

type W3CActionType

type W3CActionType string
const (
	ATKey     W3CActionType = "key"
	ATPointer W3CActionType = "pointer"
)

type W3CGestures

type W3CGestures []w3cGesture

func NewW3CGestures

func NewW3CGestures(cap ...int) *W3CGestures

func (*W3CGestures) KeyDown

func (g *W3CGestures) KeyDown(value string) *W3CGestures

func (*W3CGestures) KeyUp

func (g *W3CGestures) KeyUp(value string) *W3CGestures

func (*W3CGestures) Pause

func (g *W3CGestures) Pause(duration ...float64) *W3CGestures

func (*W3CGestures) PointerDown

func (g *W3CGestures) PointerDown(button ...W3CMouseButtonType) *W3CGestures

func (*W3CGestures) PointerMouseOver

func (g *W3CGestures) PointerMouseOver(x, y float64, element *Element, duration ...float64) *W3CGestures

func (*W3CGestures) PointerMove

func (g *W3CGestures) PointerMove(x, y float64, origin interface{}, duration float64, pressure, size float64) *W3CGestures

func (*W3CGestures) PointerMoveRelative

func (g *W3CGestures) PointerMoveRelative(x, y float64, duration ...float64) *W3CGestures

func (*W3CGestures) PointerMoveTo

func (g *W3CGestures) PointerMoveTo(x, y float64, duration ...float64) *W3CGestures

func (*W3CGestures) PointerUp

func (g *W3CGestures) PointerUp(button ...W3CMouseButtonType) *W3CGestures

func (*W3CGestures) SendKeys

func (g *W3CGestures) SendKeys(text string) *W3CGestures

type W3CMouseButtonType

type W3CMouseButtonType int
const (
	MBTLeft   W3CMouseButtonType = 0
	MBTMiddle W3CMouseButtonType = 1
	MBTRight  W3CMouseButtonType = 2
)

type W3CPointerMoveType

type W3CPointerMoveType string
const (
	PMTViewport W3CPointerMoveType = "viewport"
	PMTPointer  W3CPointerMoveType = "pointer"
)

type W3CPointerType

type W3CPointerType string
const (
	PTMouse W3CPointerType = "mouse"
	PTPen   W3CPointerType = "pen"
	PTTouch W3CPointerType = "touch"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL