testutil

package
v0.0.0-...-683b059 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package testutil provides utilities to setup testing environment for camera tests.

Package testutil provides utilities to setup testing environment for camera tests.

Package testutil provides utilities to setup testing environment for camera tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureDevicesFromV4L2Test

func CaptureDevicesFromV4L2Test(ctx context.Context) ([]string, error)

CaptureDevicesFromV4L2Test returns a list of usb camera paths.

func ChromeWithFakeCamera

func ChromeWithFakeCamera() testing.Precondition

ChromeWithFakeCamera returns a precondition that Chrome is already logged in with fake camera.

func CloseApp

func CloseApp(ctx context.Context, cr *chrome.Chrome, appConn *chrome.Conn, useSWAWindow bool) error

CloseApp closes the camera app and ensure the window is closed via autotest private API.

func IsVividDriverLoaded

func IsVividDriverLoaded(ctx context.Context) bool

IsVividDriverLoaded returns whether vivid driver is loaded on the device.

func MIPICamerasFromCrOSCameraTool

func MIPICamerasFromCrOSCameraTool(ctx context.Context) ([]map[string]string, error)

MIPICamerasFromCrOSCameraTool returns a list of MIPI camera information outputted from cros-camera-tool.

func USBCamerasFromV4L2Test

func USBCamerasFromV4L2Test(ctx context.Context) ([]string, error)

USBCamerasFromV4L2Test returns a list of usb camera paths.

Types

type AppLauncher

type AppLauncher struct {
	LaunchApp    func(ctx context.Context, tconn *chrome.TestConn) error
	UseSWAWindow bool
}

AppLauncher is used during the launch process of CCA. We could launch CCA by launchApp event, camera intent or any other ways.

type AppWindow

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

AppWindow is used to comminicate with CCA foreground window.

func LaunchApp

func LaunchApp(ctx context.Context, cr *chrome.Chrome, tb *TestBridge, appLauncher AppLauncher) (*chrome.Conn, *AppWindow, error)

LaunchApp launches the camera app and handles the communication flow between tests and app.

func RefreshApp

func RefreshApp(ctx context.Context, conn *chrome.Conn, tb *TestBridge) (*AppWindow, error)

RefreshApp refreshes the camera app and rebuilds the communication flow between tests and app.

func (*AppWindow) ClosingItself

func (a *AppWindow) ClosingItself(ctx context.Context) (bool, error)

ClosingItself checks if CCA intends to close itself.

func (*AppWindow) Errors

func (a *AppWindow) Errors(ctx context.Context) ([]ErrorInfo, error)

Errors returns the collected error information.

func (*AppWindow) NotifyReady

func (a *AppWindow) NotifyReady(ctx context.Context) error

NotifyReady notifies CCA that the setup on test side is ready so it can continue the execution.

func (*AppWindow) Perfs

func (a *AppWindow) Perfs(ctx context.Context) ([]PerfEntry, error)

Perfs returns the collected perf entries.

func (*AppWindow) Release

func (a *AppWindow) Release(ctx context.Context) error

Release releases the app window instance.

func (*AppWindow) WaitUntilClosed

func (a *AppWindow) WaitUntilClosed(ctx context.Context) error

WaitUntilClosed waits until the corresponding CCA window is closed.

func (*AppWindow) WaitUntilWindowBound

func (a *AppWindow) WaitUntilWindowBound(ctx context.Context) (string, error)

WaitUntilWindowBound waits until CCA binds its window to the AppWindow instance.

type ErrorInfo

type ErrorInfo struct {
	ErrorType string     `json:"type"`
	Level     ErrorLevel `json:"level"`
	Stack     string     `json:"stack"`
	Time      int64      `json:"time"`
	ErrorName string     `json:"name"`
}

ErrorInfo stores the information of an error.

type ErrorLevel

type ErrorLevel string

ErrorLevel represents the severity level of an error.

const (
	// ErrorLevelWarning is used when it should not cause test failure.
	ErrorLevelWarning ErrorLevel = "WARNING"
	// ErrorLevelError is used when it should fail the test.
	ErrorLevelError = "ERROR"
)

type PerfEntry

type PerfEntry struct {
	Event    string  `json:"event"`
	Duration float64 `json:"duration"`
	PerfInfo struct {
		Facing string `json:"facing"`
	} `json:"perfInfo"`
}

PerfEntry stores the information of a perf event.

type TestBridge

type TestBridge struct {

	// TODO(b/177800595): Store this information in fixture.
	CameraType UseCameraType
	// contains filtered or unexported fields
}

TestBridge is used to comminicate with CCA for test specific logic, such as test environment set-up/tear-down flow, performance/error monitoring.

func NewTestBridge

func NewTestBridge(ctx context.Context, cr *chrome.Chrome, cameraType UseCameraType) (*TestBridge, error)

NewTestBridge returns a new test bridge instance.

func NewTestBridgeWithoutTestConfig

func NewTestBridgeWithoutTestConfig(ctx context.Context, cr *chrome.Chrome, cameraType UseCameraType) (*TestBridge, error)

NewTestBridgeWithoutTestConfig returns a new test bridge instance without test config.

func (*TestBridge) AppWindow

func (t *TestBridge) AppWindow(ctx context.Context) (*AppWindow, error)

AppWindow registers and returns the app window which is used to communicate with the foreground window of CCA instance.

func (*TestBridge) TearDown

func (t *TestBridge) TearDown(ctx context.Context) error

TearDown tears down the connection of test bridge.

type UseCameraType

type UseCameraType int

UseCameraType defines what camera type is used in a test.

const (
	// UseRealCamera is used when the test should test with real camera which exercises cros-camera service.
	UseRealCamera UseCameraType = iota
	// UseVividCamera is used when the test should use vivid camera, which is virtual video test driver.
	UseVividCamera
	// UseFakeCamera is used when the test should use fake camera in Chrome stack instead.
	UseFakeCamera
)

Jump to

Keyboard shortcuts

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