Documentation ¶
Overview ¶
Package cca provides utilities to interact with Chrome Camera App.
Package cca provides utilities to interact with Chrome Camera App.
Package cca provides utilities to interact with Chrome Camera App.
Package cca provides utilities to interact with Chrome Camera App.
Package cca provides utilities to interact with Chrome Camera App.
Index ¶
- Constants
- Variables
- func CheckVideoProfile(path string, profile Profile) error
- func ClearSavedDir(ctx context.Context, cr *chrome.Chrome) error
- func InstanceExists(ctx context.Context, cr *chrome.Chrome) (bool, error)
- func IsUINotExist(err error) bool
- func MeasureGifRecordingPerformance(ctx context.Context, app *App) error
- func MeasurePreviewPerformance(ctx context.Context, app *App, perfData *PerfData, facing Facing) error
- func MeasureRecordingPerformance(ctx context.Context, app *App, perfData *PerfData, facing Facing) error
- func MeasureTakingPicturePerformance(ctx context.Context, app *App) error
- func RunPortraitModeTesting(ctx context.Context, scriptPaths []string, outDir string, facing Facing) (retErr error)
- type App
- func (a *App) AttributeWithIndex(ctx context.Context, ui UIComponent, index int, attr string) (string, error)
- func (a *App) CheckCameraFacing(ctx context.Context, facing Facing) error
- func (a *App) CheckConfirmUIExists(ctx context.Context, mode Mode) error
- func (a *App) CheckFacing(ctx context.Context, expected Facing) error
- func (a *App) CheckGridOption(ctx context.Context, expected bool) error
- func (a *App) CheckMetadataVisibility(ctx context.Context, enabled bool) error
- func (a *App) CheckMode(ctx context.Context, mode Mode) error
- func (a *App) CheckMojoConnection(ctx context.Context) error
- func (a *App) CheckVideoInactive(ctx context.Context) error
- func (a *App) CheckVisible(ctx context.Context, ui UIComponent, expected bool) error
- func (a *App) Click(ctx context.Context, ui UIComponent) error
- func (a *App) ClickChildIfContain(ctx context.Context, ui UIComponent, text string) error
- func (a *App) ClickPTZButton(ctx context.Context, ui UIComponent) error
- func (a *App) ClickShutter(ctx context.Context) error
- func (a *App) ClickWithIndex(ctx context.Context, ui UIComponent, index int) error
- func (a *App) ClickWithSelector(ctx context.Context, selector string) error
- func (a *App) Close(ctx context.Context) error
- func (a *App) CloseWithDebugParams(ctx context.Context, params DebugParams) (retErr error)
- func (a *App) ClosingItself(ctx context.Context) (bool, error)
- func (a *App) CollectPerfEvents(ctx context.Context, perfData *PerfData) error
- func (a *App) ConfirmResult(ctx context.Context, isConfirmed bool, mode Mode) error
- func (a *App) CountUI(ctx context.Context, ui UIComponent) (int, error)
- func (a *App) DisableQRCodeDetection(ctx context.Context) error
- func (a *App) Disabled(ctx context.Context, ui UIComponent) (bool, error)
- func (a *App) EnableDocumentMode(ctx context.Context) error
- func (a *App) EnableExpertMode(ctx context.Context) error
- func (a *App) EnableQRCodeDetection(ctx context.Context) error
- func (a *App) EnsureTabletModeEnabled(ctx context.Context, enabled bool) (func(ctx context.Context) error, error)
- func (a *App) Exist(ctx context.Context, ui UIComponent) (bool, error)
- func (a *App) FilePathInSavedDir(ctx context.Context, name string) (string, error)
- func (a *App) Focus(ctx context.Context) error
- func (a *App) FullscreenWindow(ctx context.Context) error
- func (a *App) GetDeviceID(ctx context.Context) (DeviceID, error)
- func (a *App) GetFacing(ctx context.Context) (Facing, error)
- func (a *App) GetNumOfCameras(ctx context.Context) (int, error)
- func (a *App) GetPhotoResolutions(ctx context.Context) ([]Resolution, error)
- func (a *App) GetPreviewResolution(ctx context.Context) (Resolution, error)
- func (a *App) GetPreviewViewportSize(ctx context.Context) (Resolution, error)
- func (a *App) GetScreenOrientation(ctx context.Context) (Orientation, error)
- func (a *App) GetVideoResolutions(ctx context.Context) ([]Resolution, error)
- func (a *App) HasClass(ctx context.Context, ui UIComponent, className string) (bool, error)
- func (a *App) Hold(ctx context.Context, ui UIComponent, d time.Duration) error
- func (a *App) InnerResolutionSetting(ctx context.Context, facing Facing, rt ResolutionType) (*SettingMenu, error)
- func (a *App) InputRange(ctx context.Context, ui UIComponent) (*Range, error)
- func (a *App) IsCheckedWithIndex(ctx context.Context, ui UIComponent, index int) (bool, error)
- func (a *App) IsWindowMinimized(ctx context.Context) (bool, error)
- func (a *App) MaximizeWindow(ctx context.Context) error
- func (a *App) MinimizeWindow(ctx context.Context) error
- func (a *App) Mirrored(ctx context.Context) (bool, error)
- func (a *App) OptionExist(ctx context.Context, option Option) (bool, error)
- func (a *App) OutputCodeCoverage(ctx context.Context) error
- func (a *App) PortraitModeSupported(ctx context.Context) (bool, error)
- func (a *App) PreviewFrame(ctx context.Context) (*Frame, error)
- func (a *App) RecordGif(ctx context.Context, save bool) (os.FileInfo, error)
- func (a *App) RecordVideo(ctx context.Context, timerState TimerState, duration time.Duration) (os.FileInfo, error)
- func (a *App) Refresh(ctx context.Context, tb *testutil.TestBridge) error
- func (a *App) Restart(ctx context.Context, tb *testutil.TestBridge) error
- func (a *App) RestoreWindow(ctx context.Context) error
- func (a *App) RunThroughCameras(ctx context.Context, f func(Facing) error) error
- func (a *App) SaveCameraFolder(ctx context.Context) error
- func (a *App) SaveScreenshot(ctx context.Context) error
- func (a *App) SavedDir(ctx context.Context) (string, error)
- func (a *App) ScreenXYWithIndex(ctx context.Context, ui UIComponent, index int) (*coords.Point, error)
- func (a *App) SelectOption(ctx context.Context, ui UIComponent, value string) error
- func (a *App) SetEnableMultiStreamRecording(ctx context.Context, enabled bool) error
- func (a *App) SetRangeInput(ctx context.Context, ui UIComponent, value int) error
- func (a *App) SetTimerOption(ctx context.Context, state TimerState) error
- func (a *App) Size(ctx context.Context, ui UIComponent) (*Resolution, error)
- func (a *App) StartRecording(ctx context.Context, timerState TimerState) (time.Time, error)
- func (a *App) State(ctx context.Context, state string) (bool, error)
- func (a *App) StopRecording(ctx context.Context, timerState TimerState, startTime time.Time) (os.FileInfo, time.Time, error)
- func (a *App) Style(ctx context.Context, ui UIComponent, attribute string) (string, error)
- func (a *App) SwitchCamera(ctx context.Context) error
- func (a *App) SwitchMode(ctx context.Context, mode Mode) error
- func (a *App) TakeSinglePhoto(ctx context.Context, timerState TimerState) ([]os.FileInfo, error)
- func (a *App) ToggleExpertMode(ctx context.Context) (bool, error)
- func (a *App) ToggleOption(ctx context.Context, option Option) (bool, error)
- func (a *App) TriggerConfiguration(ctx context.Context, trigger func() error) error
- func (a *App) TriggerStateChange(ctx context.Context, state string, expected bool, trigger func() error) (time.Time, error)
- func (a *App) Visible(ctx context.Context, ui UIComponent) (bool, error)
- func (a *App) WaitForDisabled(ctx context.Context, ui UIComponent, expected bool) error
- func (a *App) WaitForFileSaved(ctx context.Context, dir string, pat *regexp.Regexp, ts time.Time) (os.FileInfo, error)
- func (a *App) WaitForMinimized(ctx context.Context, minimized bool) error
- func (a *App) WaitForState(ctx context.Context, state string, active bool) error
- func (a *App) WaitForVideoActive(ctx context.Context) error
- func (a *App) WaitForVisibleState(ctx context.Context, ui UIComponent, expected bool) error
- type DebugParams
- type DeviceID
- type ErrJS
- type Facing
- type FixtureData
- type Frame
- type Mode
- type Option
- type Orientation
- type PerfData
- type PixelTarget
- type Profile
- type Range
- type ResetChromeFunc
- type ResetTestBridgeFunc
- type Resolution
- type ResolutionType
- type SettingMenu
- type StartAppFunc
- type StopAppFunc
- type TestWithAppFunc
- type TestWithAppParams
- type TimerState
- type UIComponent
Constants ¶
const ( // ID is the app id of CCA. ID string = "hfhhnacclhffhdffklopdkcgdhifgngh" // Video is the mode used to record video. Video Mode = "video" // Photo is the mode used to take photo. Photo Mode = "photo" // Square is the mode used to take square photo. // TODO(b/215484798): Removed since there is no square mode in new UI. Square = "square" // Portrait is the mode used to take portrait photo. Portrait = "portrait" // Scan is the mode used to scan barcode/document. Scan = "scan" // Expert is the state used to indicate expert mode. Expert string = "expert" // SaveMetadata is the state used to indicate save metadata. SaveMetadata = "save-metadata" )
const TimerDelay time.Duration = 3 * time.Second
TimerDelay is default timer delay of CCA.
Variables ¶
var ( // PhotoPattern is the filename format of photos taken by CCA. PhotoPattern = regexp.MustCompile(`^IMG_\d{8}_\d{6}[^.]*\.jpg$`) // VideoPattern is the filename format of videos recorded by CCA. VideoPattern = regexp.MustCompile(`^VID_\d{8}_\d{6}[^.]*\.mp4$`) // DocumentPDFPattern is the filename format of the document PDF file. DocumentPDFPattern = regexp.MustCompile(`^SCN_\d{8}_\d{6}[^.]*\.pdf$`) // DocumentPhotoPattern is the filename format of the document photo file. DocumentPhotoPattern = regexp.MustCompile(`^SCN_\d{8}_\d{6}[^.]*\.jpg$`) // ErrVideoNotActive indicates that video is not active. ErrVideoNotActive = "Video is not active within given time" )
var ( // ProfileH264Baseline is h264 baseline profile. ProfileH264Baseline = Profile{"baseline", 66} // ProfileH264Main is h264 main profile. ProfileH264Main = Profile{"main", 77} // ProfileH264High is h264 high profile. ProfileH264High = Profile{"high", 100} )
var ( // FirstBlack is the first black pixel met when scans frame pixels from first to last row. FirstBlack = PixelTarget{`function() { const {width, height} = this.canvas; const {data} = this.getImageData(0, 0, width, height); let idx = 0; for (let y = 0 ; y < height ; y ++) { for (let x = 0 ; x < width ; x ++) { if (data[idx] === 0) { return {x, y}; } idx += 4; } } throw new Error('Cannot find point'); }`} // LastBlack is the last black pixel met when scans frame pixels from first to last row. LastBlack = PixelTarget{`function() { const {width, height} = this.canvas; const {data} = this.getImageData(0, 0, width, height); let idx = data.length - 4; for (let y = height-1 ; y >= 0 ; y --) { for (let x = width-1 ; x >= 0 ; x --) { if (data[idx] === 0) { return {x, y}; } idx -= 4; } } throw new Error('Cannot find point'); }`} )
var ( // MainMenu is the main setting menu. MainMenu = &SettingMenu{"view-settings", &SettingsButton} // GridTypeMenu is the grid settings menu. GridTypeMenu = &SettingMenu{"view-grid-settings", &GridTypeSettingsButton} // TimerMenu is the timer settings menu. TimerMenu = &SettingMenu{"view-timer-settings", &TimerSettingsButton} // ResolutionMenu is the resolution settings menu. ResolutionMenu = &SettingMenu{"view-resolution-settings", &ResolutionSettingButton} // PhotoResolutionMenu is the photo resolution settings menu. PhotoResolutionMenu = &SettingMenu{"view-photo-resolution-settings", &PhotoResolutionSettingButton} // PhotoAspectRatioMenu is the photo aspect ratio settings menu. PhotoAspectRatioMenu = &SettingMenu{"view-photo-aspect-ratio-settings", &PhotoAspectRatioSettingButton} // VideoResolutionMenu is the video resolution settings menu. VideoResolutionMenu = &SettingMenu{"view-video-resolution-settings", &VideoResolutionSettingButton} // ExpertMenu is the expert settings menu. ExpertMenu = &SettingMenu{"view-expert-settings", &ExpertModeButton} )
var ( // CancelResultButton is button for canceling intent review result. CancelResultButton = UIComponent{"cancel result button", []string{"#cancel-result", "button[i18n-label=cancel_review_button]"}} // ConfirmResultButton is button for confirming intent review result. ConfirmResultButton = UIComponent{"confirm result button", []string{"#confirm-result", "button[i18n-label=confirm_review_button]"}} // MirrorButton is button used for toggling preview mirroring option. MirrorButton = UIComponent{"mirror button", []string{"#toggle-mirror"}} // ModeSelector is selection bar for different capture modes. ModeSelector = UIComponent{"mode selector", []string{"#modes-group"}} // SettingsButton is button for opening primary setting menu. SettingsButton = UIComponent{"settings", []string{"#open-settings"}} // SwitchDeviceButton is button for switching camera device. SwitchDeviceButton = UIComponent{"switch device button", []string{"#switch-device"}} // VideoSnapshotButton is button for taking video snapshot during recording. VideoSnapshotButton = UIComponent{"video snapshot button", []string{"#video-snapshot"}} // VideoPauseResumeButton is button for pausing or resuming video recording. VideoPauseResumeButton = UIComponent{"video pause/resume button", []string{"#pause-recordvideo"}} // GalleryButton is button for entering the Backlight app as a gallery for captured files. GalleryButton = UIComponent{"gallery button", []string{"#gallery-enter"}} // GalleryButtonCover is cover photo of gallery button. GalleryButtonCover = UIComponent{"gallery button cover", []string{"#gallery-enter>img"}} // PhotoResolutionSettingButton is button for opening photo resolution setting menu. PhotoResolutionSettingButton = UIComponent{"photo resolution setting button", []string{"#settings-photo-resolution"}} // PhotoAspectRatioSettingButton is button for opening photo aspect ratio setting menu. PhotoAspectRatioSettingButton = UIComponent{"photo aspect ratio setting button", []string{"#settings-photo-aspect-ratio"}} // VideoResolutionSettingButton is button for opening video resolution setting menu. VideoResolutionSettingButton = UIComponent{"video resolution setting button", []string{"#settings-video-resolution"}} // ResolutionSettingButton is button for opening resolution setting menu. ResolutionSettingButton = UIComponent{"resolution setting button", []string{"#settings-resolution"}} // ExpertModeButton is button used for opening expert mode setting menu. ExpertModeButton = UIComponent{"expert mode button", []string{"#settings-expert"}} // PhotoResolutionOption is option for each available photo capture resolution. PhotoResolutionOption = UIComponent{"photo resolution option", []string{ "#view-photo-resolution-settings input"}} // VideoResolutionOption is option for each available video capture resolution. VideoResolutionOption = UIComponent{"video resolution option", []string{ "#view-video-resolution-settings input"}} // FeedbackButton is the feedback button showing in the settings menu. FeedbackButton = UIComponent{"feedback button", []string{"#settings-feedback"}} // HelpButton is the help button showing in the settings menu. HelpButton = UIComponent{"help button", []string{"#settings-help"}} // GridTypeSettingsButton is the button showing in the settings menu which is used for entering the grid type settings menu. GridTypeSettingsButton = UIComponent{"grid type settings button", []string{"#settings-gridtype"}} // GoldenGridButton is the button to enable golden grid type. GoldenGridButton = UIComponent{"golden grid type button", []string{"#grid-golden"}} // TimerSettingsButton is the button showing in the settings menu which is used for entering the timer settings menu. TimerSettingsButton = UIComponent{"timer settings button", []string{"#settings-timerdur"}} // Timer10sButton is the button to enable 10s timer. Timer10sButton = UIComponent{"timer 10s button", []string{"#timer-10s"}} // BarcodeChipURL is chip for url detected from barcode. BarcodeChipURL = UIComponent{"barcode chip url", []string{".barcode-chip-url a"}} // BarcodeChipText is chip for text detected from barcode. BarcodeChipText = UIComponent{"barcode chip text", []string{".barcode-chip-text"}} // BarcodeCopyURLButton is button to copy url detected from barcode. BarcodeCopyURLButton = UIComponent{"barcode copy url button", []string{"#barcode-chip-url-container .barcode-copy-button"}} // BarcodeCopyTextButton is button to copy text detected from barcode. BarcodeCopyTextButton = UIComponent{"barcode copy text button", []string{"#barcode-chip-text-container .barcode-copy-button"}} // VideoProfileSelect is select-options for selecting video profile. VideoProfileSelect = UIComponent{"video profile select", []string{"#video-profile"}} // BitrateMultiplierRangeInput is range input for selecting bitrate multiplier. BitrateMultiplierRangeInput = UIComponent{"bitrate multiplier range input", []string{"#bitrate-slider input[type=range]"}} // OptionsContainer is the container for all options for opening option panel. OptionsContainer = UIComponent{"container of options", []string{"#options-container"}} // OpenMirrorPanelButton is the button which is used for opening the mirror state settings panel. OpenMirrorPanelButton = UIComponent{"mirror state option button", []string{"#open-mirror-panel"}} // OpenGridPanelButton is the button which is used for opening the grid type settings panel. OpenGridPanelButton = UIComponent{"grid type option button", []string{"#open-grid-panel"}} // OpenTimerPanelButton is the button which is used for opening the timer type settings panel. OpenTimerPanelButton = UIComponent{"timer type option button", []string{"#open-timer-panel"}} // OpenPTZPanelButton is the button for opening PTZ panel. OpenPTZPanelButton = UIComponent{"open ptz panel button", []string{"#open-ptz-panel"}} // PanLeftButton is the button for panning left preview. PanLeftButton = UIComponent{"pan left button", []string{"#pan-left"}} // PanRightButton is the button for panning right preview. PanRightButton = UIComponent{"pan right button", []string{"#pan-right"}} // TiltUpButton is the button for tilting up preview. TiltUpButton = UIComponent{"tilt up button", []string{"#tilt-up"}} // TiltDownButton is the button for tilting down preview. TiltDownButton = UIComponent{"tilt down button", []string{"#tilt-down"}} // ZoomInButton is the button for zoom in preview. ZoomInButton = UIComponent{"zoom in button", []string{"#zoom-in"}} // ZoomOutButton is the button for zoom out preview. ZoomOutButton = UIComponent{"zoom out button", []string{"#zoom-out"}} // PTZResetAllButton is the button for reset PTZ to default value. PTZResetAllButton = UIComponent{"ptz reset all button", []string{"#ptz-reset-all"}} // SquareModeButton is the button to enter square mode. SquareModeButton = UIComponent{"square mode button", []string{".mode-item>input[data-mode=\"square\"]"}} // ScanModeButton is the button to enter scan mode. ScanModeButton = UIComponent{"scan mode button", []string{".mode-item>input[data-mode=\"scan\"]"}} // ScanBarcodeOption is the option button to switch to QR code detection mode in scan mode. ScanBarcodeOption = UIComponent{"scan barcode option", []string{"#scan-barcode"}} // ScanDocumentModeOption is the document mode option of scan mode. ScanDocumentModeOption = UIComponent{"document mode button", []string{"#scan-document"}} // ReviewView is the review view after taking a photo under document mode. ReviewView = UIComponent{"document review view", []string{"#view-review"}} // ReviewImage is the image to be reviewed. ReviewImage = UIComponent{"reivew image", []string{"#view-review .review-image"}} // SaveAsPDFButton is the button to save document as PDF. SaveAsPDFButton = UIComponent{"save document as pdf button", []string{"#view-review button[i18n-text=label_save_pdf_document]"}} // SaveAsPhotoButton is the button to save document as photo. SaveAsPhotoButton = UIComponent{"save document as photo button", []string{"#view-review button[i18n-text=label_save_photo_document]"}} // RetakeButton is the button to retake the document photo. RetakeButton = UIComponent{"retake document photo button", []string{ "#review-retake", "#view-review button[i18n-text=label_retake]"}} // FixCropButton is the button to fix document crop area. FixCropButton = UIComponent{"fix document crop area button", []string{"#view-review button[i18n-text=label_fix_document]"}} // CropDocumentView is the view for fix document crop area. CropDocumentView = UIComponent{"crop document view", []string{"#view-crop-document"}} // CropDocumentImage is the image to be cropped document from. CropDocumentImage = UIComponent{"crop document image", []string{"#view-crop-document .review-image"}} // CropDoneButton is the button clicked after fix document crop area. CropDoneButton = UIComponent{"crop document done button", []string{"#view-crop-document button[i18n-text=label_crop_done]"}} // DocumentCorner is the dragging point of document corner in crop area page. DocumentCorner = UIComponent{"document corner dragging point", []string{"#view-crop-document .dot"}} // DocumentCornerOverlay is the overlay that CCA used to draw document corners on. DocumentCornerOverlay = UIComponent{"document corner overlay", []string{ "#preview-document-corner-overlay"}} // GifRecordingOption is the radio button to toggle gif recording option. GifRecordingOption = UIComponent{"gif recording button", []string{ "input[type=radio][data-state=record-type-gif]"}} // GifReviewSaveButton is the save button in gif review page. GifReviewSaveButton = UIComponent{"save gif button", []string{ "#view-review button[i18n-text=label_save]"}} // GifReviewRetakeButton is the retake button in gif review page. GifReviewRetakeButton = UIComponent{"retake gif button", []string{"#review-retake"}} // FrontAspectRatioOptions are the buttons of aspect ratio options for the front camera. FrontAspectRatioOptions = UIComponent{"front aspect ratio options", []string{"#view-photo-aspect-ratio-settings .menu-item>input[data-facing=\"user\"]"}} // BackAspectRatioOptions are the buttons of aspect ratio options for the back camera. BackAspectRatioOptions = UIComponent{"back aspect ratio options", []string{"#view-photo-aspect-ratio-settings .menu-item>input[data-facing=\"environment\"]"}} // FrontPhotoResolutionOptions are the buttons of photo resolution options for the front camera. FrontPhotoResolutionOptions = UIComponent{"front photo resolution options", []string{"#view-photo-resolution-settings .menu-item>input[data-facing=\"user\"]"}} // BackPhotoResolutionOptions are the buttons of photo resolution options for the back camera. BackPhotoResolutionOptions = UIComponent{"back photo resolution options", []string{"#view-photo-resolution-settings .menu-item>input[data-facing=\"environment\"]"}} // FrontVideoResolutionOptions are the buttons of video resolution options for the front camera. FrontVideoResolutionOptions = UIComponent{"front video resolution options", []string{"#view-video-resolution-settings .menu-item>input[data-facing=\"user\"]"}} // BackVideoResolutionOptions are the buttons of video resolution options for the back camera. BackVideoResolutionOptions = UIComponent{"back video resolution options", []string{"#view-video-resolution-settings .menu-item>input[data-facing=\"environment\"]"}} )
var ( // CustomVideoParametersOption is the option to enable custom video parameters. CustomVideoParametersOption = newOption("custom-video-parameters", "#custom-video-parameters") // ExpertModeOption is the option to enable expert mode. ExpertModeOption = newOption("expert", "#expert-enable-expert-mode") // GridOption is the option to show grid lines on preview. GridOption = newOption("grid", "#toggle-grid") // MirrorOption is the option to flip preview horizontally. MirrorOption = newOption("mirror", "#toggle-mirror") // SaveMetadataOption is the option to save metadata of capture result. SaveMetadataOption = newOption("save-metadata", "#expert-save-metadata") // ShowMetadataOption is the option to show preview metadata. ShowMetadataOption = newOption("show-metadata", "#expert-show-metadata") // EnableDocumentModeOnAllCamerasOption is the option to enable document scanning on all cameras. EnableDocumentModeOnAllCamerasOption = newOption("enable-document-mode-on-all-cameras", "#expert-enable-document-mode-on-all-cameras") // EnableMultistreamRecordingOption is the option to enable document scanning on all cameras. EnableMultistreamRecordingOption = newOption("enable-multistream-recording", "#expert-enable-multistream-recording") // ScanBarcodeOptionInPhotoMode is the option to enable barcode scanning in photo mode. ScanBarcodeOptionInPhotoMode = newOption("enable-scan-barcode", "#toggle-barcode") // ShowGifRecordingOption is the option to enable gif recording. ShowGifRecordingOption = newOption("show-gif-recording-option", "#expert-enable-gif-recording") // TimerOption is the option to enable countdown timer. TimerOption = newOption("timer", "#toggle-timer") )
Functions ¶
func CheckVideoProfile ¶
CheckVideoProfile checks profile of video file recorded by CCA.
func ClearSavedDir ¶
ClearSavedDir clears all files in the folder where captured files might be saved.
func InstanceExists ¶
InstanceExists checks if there is any running CCA instance.
func IsUINotExist ¶
IsUINotExist returns true if the given error is from errorUINotExist error type.
func MeasureGifRecordingPerformance ¶
MeasureGifRecordingPerformance records a gif and measure the performance of UI operations.
func MeasurePreviewPerformance ¶
func MeasurePreviewPerformance(ctx context.Context, app *App, perfData *PerfData, facing Facing) error
MeasurePreviewPerformance measures the performance of preview with QR code detection on and off.
func MeasureRecordingPerformance ¶
func MeasureRecordingPerformance(ctx context.Context, app *App, perfData *PerfData, facing Facing) error
MeasureRecordingPerformance measures the performance of video recording.
func MeasureTakingPicturePerformance ¶
MeasureTakingPicturePerformance takes a picture and measure the performance of UI operations.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App represents a CCA (Chrome Camera App) instance.
func Init ¶
func Init(ctx context.Context, cr *chrome.Chrome, scriptPaths []string, outDir string, appLauncher testutil.AppLauncher, tb *testutil.TestBridge) (_ *App, retErr error)
Init launches a CCA instance, evaluates the helper script within it and waits until its AppWindow interactable. The scriptPath should be the data path to the helper script cca_ui.js. The returned App instance must be closed when the test is finished.
func New ¶
func New(ctx context.Context, cr *chrome.Chrome, scriptPaths []string, outDir string, tb *testutil.TestBridge) (*App, error)
New launches a CCA instance. The returned App instance must be closed when the test is finished.
func (*App) AttributeWithIndex ¶
func (a *App) AttributeWithIndex(ctx context.Context, ui UIComponent, index int, attr string) (string, error)
AttributeWithIndex returns the attr attribute of the index th ui.
func (*App) CheckCameraFacing ¶
CheckCameraFacing checks whether CCA is in correct facing if there's a camera with that facing.
func (*App) CheckConfirmUIExists ¶
CheckConfirmUIExists returns whether the confirm UI exists.
func (*App) CheckFacing ¶
CheckFacing returns an error if the active camera facing is not expected.
func (*App) CheckGridOption ¶
CheckGridOption checks whether grid option enable state is as expected.
func (*App) CheckMetadataVisibility ¶
CheckMetadataVisibility checks if metadata is shown/hidden on screen given enabled.
func (*App) CheckMojoConnection ¶
CheckMojoConnection checks if mojo connection works.
func (*App) CheckVideoInactive ¶
CheckVideoInactive checks the video is inactive for 1 second.
func (*App) CheckVisible ¶
CheckVisible returns an error if visibility state of ui is not expected.
func (*App) Click ¶
func (a *App) Click(ctx context.Context, ui UIComponent) error
Click clicks on ui.
func (*App) ClickChildIfContain ¶
ClickChildIfContain clicks the child which contains the given string in its text content.
func (*App) ClickPTZButton ¶
func (a *App) ClickPTZButton(ctx context.Context, ui UIComponent) error
ClickPTZButton clicks on PTZ Button.
func (*App) ClickShutter ¶
ClickShutter clicks the shutter button.
func (*App) ClickWithIndex ¶
ClickWithIndex clicks nth ui.
func (*App) ClickWithSelector ¶
ClickWithSelector clicks an element with given selector.
func (*App) CloseWithDebugParams ¶
func (a *App) CloseWithDebugParams(ctx context.Context, params DebugParams) (retErr error)
CloseWithDebugParams closes the App and the associated connection with the debug parameters.
func (*App) ClosingItself ¶
ClosingItself checks if CCA intends to close itself.
func (*App) CollectPerfEvents ¶
CollectPerfEvents returns a map containing all perf events collected since app launch. The returned map maps from event name to a list of durations for each time that event happened.
func (*App) ConfirmResult ¶
ConfirmResult clicks the confirm button or the cancel button according to the given isConfirmed.
func (*App) DisableQRCodeDetection ¶
DisableQRCodeDetection disables the QR code detection.
func (*App) EnableDocumentMode ¶
EnableDocumentMode enables the document mode via expert mode.
func (*App) EnableExpertMode ¶
EnableExpertMode enables expert mode.
func (*App) EnableQRCodeDetection ¶
EnableQRCodeDetection enables the QR code detection.
func (*App) EnsureTabletModeEnabled ¶
func (a *App) EnsureTabletModeEnabled(ctx context.Context, enabled bool) (func(ctx context.Context) error, error)
EnsureTabletModeEnabled makes sure that the tablet mode states of both device and app are enabled, and returns a function which reverts back to the original state.
func (*App) FilePathInSavedDir ¶
FilePathInSavedDir finds and returns the path of the target file in saved directory.
func (*App) FullscreenWindow ¶
FullscreenWindow fullscreens the window.
func (*App) GetDeviceID ¶
GetDeviceID returns the active camera device id.
func (*App) GetNumOfCameras ¶
GetNumOfCameras returns number of camera devices.
func (*App) GetPhotoResolutions ¶
func (a *App) GetPhotoResolutions(ctx context.Context) ([]Resolution, error)
GetPhotoResolutions returns available photo resolutions of active camera on HALv3 device.
func (*App) GetPreviewResolution ¶
func (a *App) GetPreviewResolution(ctx context.Context) (Resolution, error)
GetPreviewResolution returns resolution of preview video.
func (*App) GetPreviewViewportSize ¶
func (a *App) GetPreviewViewportSize(ctx context.Context) (Resolution, error)
GetPreviewViewportSize returns resolution of the preview view port.
func (*App) GetScreenOrientation ¶
func (a *App) GetScreenOrientation(ctx context.Context) (Orientation, error)
GetScreenOrientation returns screen orientation.
func (*App) GetVideoResolutions ¶
func (a *App) GetVideoResolutions(ctx context.Context) ([]Resolution, error)
GetVideoResolutions returns available video resolutions of active camera on HALv3 device.
func (*App) InnerResolutionSetting ¶
func (a *App) InnerResolutionSetting(ctx context.Context, facing Facing, rt ResolutionType) (*SettingMenu, error)
InnerResolutionSetting returns setting menu for toggle |rt| resolution of |facing| camera.
func (*App) InputRange ¶
InputRange returns the range of valid value for range type input element.
func (*App) IsCheckedWithIndex ¶
IsCheckedWithIndex gets checked state of nth ui.
func (*App) IsWindowMinimized ¶
IsWindowMinimized returns true if the current app window is minimized.
func (*App) MaximizeWindow ¶
MaximizeWindow maximizes the window.
func (*App) MinimizeWindow ¶
MinimizeWindow minimizes the window.
func (*App) OptionExist ¶
OptionExist returns if the option exists.
func (*App) OutputCodeCoverage ¶
OutputCodeCoverage stops the profiling and output the code coverage information to the output directory.
func (*App) PortraitModeSupported ¶
PortraitModeSupported returns whether portrait mode is supported by the current active video device.
func (*App) PreviewFrame ¶
PreviewFrame grabs a frame from preview. The caller should be responsible for releasing the frame.
func (*App) RecordGif ¶
RecordGif records a gif with maximal duration and |save| specify whether to save result gif in review page.
func (*App) RecordVideo ¶
func (a *App) RecordVideo(ctx context.Context, timerState TimerState, duration time.Duration) (os.FileInfo, error)
RecordVideo records a video with duration length and save to default location.
func (*App) RestoreWindow ¶
RestoreWindow restores the window, exiting a maximized, minimized, or fullscreen state.
func (*App) RunThroughCameras ¶
RunThroughCameras runs function f in app after switching to each available camera. The f is called with paramter of the switched camera facing. The error returned by f is passed to caller of this function.
func (*App) SaveCameraFolder ¶
SaveCameraFolder saves the camera folder to the output directory to make debug easier.
func (*App) SaveScreenshot ¶
SaveScreenshot saves a screenshot in the outDir.
func (*App) ScreenXYWithIndex ¶
func (a *App) ScreenXYWithIndex(ctx context.Context, ui UIComponent, index int) (*coords.Point, error)
ScreenXYWithIndex returns the screen coordinates of the left-top corner of the |index|'th |ui|.
func (*App) SelectOption ¶
SelectOption selects the target option in HTMLSelectElement.
func (*App) SetEnableMultiStreamRecording ¶
SetEnableMultiStreamRecording enables/disables recording videos with multiple streams via expert mode.
func (*App) SetRangeInput ¶
SetRangeInput set value of range input.
func (*App) SetTimerOption ¶
func (a *App) SetTimerOption(ctx context.Context, state TimerState) error
SetTimerOption sets the timer option to on/off.
func (*App) Size ¶
func (a *App) Size(ctx context.Context, ui UIComponent) (*Resolution, error)
Size returns size of the |ui|.
func (*App) StartRecording ¶
StartRecording starts recording a video.
func (*App) StopRecording ¶
func (a *App) StopRecording(ctx context.Context, timerState TimerState, startTime time.Time) (os.FileInfo, time.Time, error)
StopRecording stops recording a video.
func (*App) SwitchCamera ¶
SwitchCamera switches to next camera device.
func (*App) SwitchMode ¶
SwitchMode switches to specified capture mode.
func (*App) TakeSinglePhoto ¶
TakeSinglePhoto takes a photo and save to default location.
func (*App) ToggleExpertMode ¶
ToggleExpertMode toggles expert mode and returns whether it's enabled after toggling.
func (*App) ToggleOption ¶
ToggleOption toggles on/off of the |option|.
func (*App) TriggerConfiguration ¶
TriggerConfiguration triggers configuration by calling trigger() and waits for camera configuration finishing.
func (*App) TriggerStateChange ¶
func (a *App) TriggerStateChange(ctx context.Context, state string, expected bool, trigger func() error) (time.Time, error)
TriggerStateChange triggers |state| change by calling |trigger()|, waits for its value changing from |!expected| to |expected| and returns when the change happens.
func (*App) WaitForDisabled ¶
WaitForDisabled waits until the disabled state of ui becomes |expected|.
func (*App) WaitForFileSaved ¶
func (a *App) WaitForFileSaved(ctx context.Context, dir string, pat *regexp.Regexp, ts time.Time) (os.FileInfo, error)
WaitForFileSaved waits for the presence of the captured file with file name matching the specified pattern, size larger than zero, and modified time after the specified timestamp.
func (*App) WaitForMinimized ¶
WaitForMinimized waits for app window to be minimized/restored.
func (*App) WaitForState ¶
WaitForState waits until state become active/inactive.
func (*App) WaitForVideoActive ¶
WaitForVideoActive waits for the video to become active for 1 second.
func (*App) WaitForVisibleState ¶
WaitForVisibleState waits until the visibility of ui becomes expected.
type DebugParams ¶
DebugParams defines some useful flags for debug CCA tests.
type DeviceID ¶
type DeviceID string
DeviceID is video device id from JavaScript navigator.mediaDevices.enumerateDevices.
type ErrJS ¶
type ErrJS struct {
// contains filtered or unexported fields
}
ErrJS represents an error occurs when executing JavaScript.
type Facing ¶
type Facing string
Facing is camera facing from JavaScript VideoFacingModeEnum.
const ( // FacingBack is the constant string from JavaScript VideoFacingModeEnum. FacingBack Facing = "environment" // FacingFront is the constant string from JavaScript VideoFacingModeEnum. FacingFront Facing = "user" // FacingExternal is the constant string indicating external camera facing. FacingExternal Facing = "external" )
type FixtureData ¶
type FixtureData struct { Chrome *chrome.Chrome BrowserType browser.Type ARC *arc.ARC TestBridge func() *testutil.TestBridge // App returns the CCA instance which lives through the test. App func() *App // ResetChrome resets chrome used by this fixture. ResetChrome ResetChromeFunc // StartApp starts CCA which can be used between subtests. StartApp StartAppFunc // StopApp stops CCA which can be used between subtests. StopApp StopAppFunc // ResetTestBridgeFunc resets the test bridge. Usually we don't need to call // it explicitly unless the sub test launch/tear-down the app itself. ResetTestBridge ResetTestBridgeFunc // SwitchScene switches the camera scene to the given scene. This only works // for fixtures using fake camera stream. SwitchScene func(string) error // RunTestWithApp runs the given function with the handling of the app // start/stop. RunTestWithApp func(context.Context, TestWithAppFunc, TestWithAppParams) error // PrepareChart prepares chart by loading the given scene. It only works for // CameraBox. PrepareChart func(ctx context.Context, addr, keyFile, contentPath string) error // SetDebugParams sets the debug parameters for current test. SetDebugParams func(params DebugParams) }
FixtureData is the struct exposed to tests.
type Frame ¶
type Frame struct {
// contains filtered or unexported fields
}
Frame is the frame grabbed from preview.
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
Option is the option for toggling state.
type Orientation ¶
type Orientation string
Orientation is the screen orientation from JavaScript window.screen.orientation.type.
const ( // PortraitPrimary is the primary portrait orientation. PortraitPrimary Orientation = "portrait-primary" // PortraitSecondary is the secondary portrait orientation. PortraitSecondary Orientation = "portrait-secondary" // LandscapePrimary is the primary landscape orientation. LandscapePrimary Orientation = "landscape-primary" // LandscapeSecondary is the secondary landscape orientation. LandscapeSecondary Orientation = "landscape-secondary" )
type PerfData ¶
type PerfData struct {
// contains filtered or unexported fields
}
PerfData saves performance record collected by performance test.
func (*PerfData) SetDuration ¶
SetDuration sets perf event name and the duration that event takes.
type PixelTarget ¶
type PixelTarget struct {
// contains filtered or unexported fields
}
PixelTarget specifies the target pixel to be found in frame.
type ResetChromeFunc ¶
ResetChromeFunc reset chrome used in this fixture.
type ResetTestBridgeFunc ¶
ResetTestBridgeFunc resets the test bridge.
type Resolution ¶
Resolution represents dimension of video or photo.
func (*Resolution) AspectRatio ¶
func (r *Resolution) AspectRatio() float64
AspectRatio returns width divided by height as the aspect ratio of the resolution.
type ResolutionType ¶
type ResolutionType string
ResolutionType is different capture resolution type.
const ( // PhotoResolution represents photo resolution type. PhotoResolution ResolutionType = "photo" // VideoResolution represents video resolution type. VideoResolution = "video" )
type SettingMenu ¶
type SettingMenu struct {
// contains filtered or unexported fields
}
SettingMenu is the setting menu in CCA.
type TestWithAppFunc ¶
TestWithAppFunc is the function to run with app.
type TestWithAppParams ¶
type TestWithAppParams struct {
StopAppOnlyIfExist bool
}
TestWithAppParams defines parameters to control behaviors of running test with app.
type TimerState ¶
type TimerState bool
TimerState is the information of whether shutter timer is on.
const ( // TimerOn means shutter timer is on. TimerOn TimerState = true // TimerOff means shutter timer is off. TimerOff = false )
type UIComponent ¶
UIComponent represents a CCA UI component.