useractions

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: 13 Imported by: 0

README

UserContext & UserAction

In a test built from user journey, recording the DUT environment information can satisfy more complicated test analysis requirement.

UserContext

UserContext represents the environment along with the test running. It can either be inherited from precondition / fixture, or newly created in the middle of a test script.

UserContext normally contains the platform & system information, such as Board name, Device mode, Keyboard type.

Note: Do not frequently update userContext during a test, which can mess up the data or inconsistency between data and real physical device information.

UserAction

UserAction represents one or more actions performed by the end user. The result of the action is automatically collected on the interest of its creator.

UserAction is not necessary to be a regular test case, it is literally an uiauto.Action with more attached information.

UserAction borrows the idea from Javascript Promise, providing 3 optional functions (ifSuccessFunc,ifFailFunc, finalFunc) to follow up the actual action. They are designed to update UserContext, cleanup environment, etc. Any errors occurring in these functions are informational logged only.

whilst UserContext represents the DUT environment that the action is running in.

Run and Log

Once an UserAction runs by any trigger of below,the action result is automatically logged into user_action_log.csv file under the test output directory s.OutDir().

  • (uc *UserContext) RunAction
  • (ua *UserAction) Run

Attributes and Tags

Both UserContext and UserAction have attributes and tags. Attributes are saved in map to accommodate key values (e.g. KeyboardType: Tablet VK), while Tags uses list to represent key information of the action (e.g. relevant CUJ Names: VKTyping, ARC++ ). Once logging action results, context attributes and tags are merged into action attributes and tags.

Documentation

Overview

Package useractions contains the definition of UserContext and UserAction. It also provides helper functions to use in test cases.

Index

Constants

View Source
const (
	AttributeDeviceMode    string = "DeviceMode"
	AttributeDeviceRegion  string = "DeviceRegion"
	AttributeKeyboardType  string = "KeyboardType"
	AttributeBoardName     string = "BoardName"
	AttributeIncognitoMode string = "IncognitoMode"
	AttributeUserMode      string = "UserMode"
	AttributeInputMethod   string = "InputMethod"
	AttributeInputField    string = "InputField"
	AttributeFloatVK       string = "FloatVK"
)

Attribute keys used to represent DUT environment.

View Source
const (
	DeviceModeClamshell string = "Clamshell"
	DeviceModeTablet    string = "Tablet"
	DeviceModeUnknown   string = "Unknown"
)

Available attribute values of device mode.

View Source
const (
	KeyboardTypePhysicalKeyboard string = "Physical Keyboard"
	KeyboardTypeTabletVK         string = "Tablet Virtual Keyboard"
	KeyboardTypeA11yVK           string = "A11y Virtual Keyboard"
	KeyboardTypeUnknown          string = "Unknown"
)

Available attribute values of keyboard type.

View Source
const (
	FeatureIMEManagement       string = "IME Management"
	FeatureIMESpecific         string = "IME Specific Feature"
	FeaturePKTyping            string = "PK Typing Input"
	FeatureDeadKeys            string = "Dead Keys"
	FeatureVKTyping            string = "VK Typing Input"
	FeatureVKAutoShift         string = "VK AutoShift"
	FeatureVoiceInput          string = "Voice Input"
	FeatureHandWriting         string = "Handwriting"
	FeatureFloatVK             string = "Float VK"
	FeatureGlideTyping         string = "Glide Typing"
	FeatureEmoji               string = "Emoji"
	FeatureEmojiPicker         string = "Emoji Picker"
	FeatureEmojiSuggestion     string = "Emoji Suggestion"
	FeatureGrammarCheck        string = "Grammar Check"
	FeatureMultiPaste          string = "Multi-Paste"
	FeatureMultiwordSuggestion string = "Multiword Suggestion"
	FeatureAutoCorrection      string = "Auto-Correction"
	FeatureAutoCapitalization  string = "Auto-Capitalization"
)

E14s feature definition.

View Source
const AttributeFeature string = "Feature"

AttributeFeature describes the feature that the user action is using.

View Source
const AttributeTestScenario string = "TestScenario"

AttributeTestScenario describes the test scenario that the user action is running in.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionTag

type ActionTag string

ActionTag is a string type to represent tag type of UserAction.

const (
	ActionTagEssentialInputs ActionTag = "Essential Inputs"
	ActionTagARC             ActionTag = "ARC++"
	ActionTagOSSettings      ActionTag = "OS Settings"
	ActionTagIMESettings     ActionTag = "IME Settings"
	ActionTagIMEShelf        ActionTag = "IME Shelf"
)

Action tags to indicate interested products / teams.

type UserAction

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

UserAction represents the user action.

func NewUserAction

func NewUserAction(name string, action action.Action, uc *UserContext, uac *UserActionCfg) *UserAction

NewUserAction returns a new user action.

func (*UserAction) AddTags

func (ua *UserAction) AddTags(actionTags []ActionTag)

AddTags adds tags to the user action.

func (*UserAction) Name

func (ua *UserAction) Name() string

Name returns the name of the user action.

func (*UserAction) Run

func (ua *UserAction) Run(ctx context.Context) (err error)

Run runs a user action and records detailed running information.

func (*UserAction) SetAttribute

func (ua *UserAction) SetAttribute(key, value string)

SetAttribute set the value of an attribute of the user action.

func (*UserAction) UserContext

func (ua *UserAction) UserContext() *UserContext

UserContext returns the user context instance of the user action.

type UserActionCfg

type UserActionCfg struct {
	Attributes     map[string]string
	Tags           []ActionTag
	ValidateResult action.Action                                    // validateResult should only check the outcome of the user action.
	Callback       func(ctx context.Context, actionErr error) error // callback takes action error as input.
}

UserActionCfg represents optional configurations of a user action.

type UserContext

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

UserContext represents the user context in the test.

func NewUserContext

func NewUserContext(testName string, cr *chrome.Chrome, tconn *chrome.TestConn, outputDir string, attributes map[string]string, tags []ActionTag) *UserContext

NewUserContext returns a new user context.

func (*UserContext) AddTags

func (uc *UserContext) AddTags(actionTags []ActionTag)

AddTags adds tags to the user context.

func (*UserContext) Attributes

func (uc *UserContext) Attributes() map[string]string

Attributes returns all attributes of the user context.

func (*UserContext) Chrome

func (uc *UserContext) Chrome() *chrome.Chrome

Chrome returns the Chrome instance from the user context.

func (*UserContext) InvalidUserAction

func (uc *UserContext) InvalidUserAction(err error) *UserAction

InvalidUserAction creates a user action to return error directly.

func (*UserContext) NewUserAction

func (uc *UserContext) NewUserAction(name string, action action.Action, uac *UserActionCfg) *UserAction

NewUserAction returns a new user action.

func (*UserContext) RemoveAttribute

func (uc *UserContext) RemoveAttribute(name string)

RemoveAttribute removes an attribute of the user context.

func (*UserContext) RemoveTags

func (uc *UserContext) RemoveTags(actionTags []ActionTag)

RemoveTags removes tags from the user context.

func (*UserContext) RunAction

func (uc *UserContext) RunAction(ctx context.Context, name string, action action.Action, uac *UserActionCfg) error

RunAction runs a action.Action as a user action and records detailed running information.

func (*UserContext) SetAttribute

func (uc *UserContext) SetAttribute(name, value string)

SetAttribute set the value of an attribute of the user context.

func (*UserContext) SetTestName

func (uc *UserContext) SetTestName(testName string)

SetTestName sets the test name of the user context.

func (*UserContext) TestAPIConn

func (uc *UserContext) TestAPIConn() *chrome.TestConn

TestAPIConn returns the test connection from the user context.

Jump to

Keyboard shortcuts

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