Documentation ¶
Overview ¶
Package test contains the test harness, which controls browser based tests. Tests should call RegisterTestFunction to register a particular test. These tests get presented to the user in the test form available at the address "/test", and the user can select a test and execute it. The form is also a repository for operations you can perform on the form being tested. A test generally should start with a call to LoadURL. Follow that with calls to control the form and check for expected results. page/test contains a variety of tests that serve to unit test the form framework.
Index ¶
- Constants
- func GetTestForm() page.FormI
- func NewTestForm(ctx context.Context) page.FormI
- func RegisterTestFunction(name string, f testRunnerFunction)
- func TestAssets() string
- func TestStepEvent() *testStepEvent
- type TestController
- func (p *TestController) Action(ctx context.Context, a page.ActionParams)
- func (p *TestController) Init(self control.PanelI, parent page.ControlI, id string)
- func (p *TestController) ΩPutCustomScript(ctx context.Context, response *page.Response)
- func (p *TestController) ΩUpdateFormValues(ctx *page.Context)
- type TestForm
- func (form *TestForm) Action(ctx context.Context, a page.ActionParams)
- func (form *TestForm) AddHeadTags()
- func (form *TestForm) AssertEqual(expected, actual interface{})
- func (form *TestForm) AssertNil(v interface{})
- func (form *TestForm) AssertNotNil(v interface{})
- func (form *TestForm) CallJqueryFunction(id string, funcName string, params ...interface{}) interface{}
- func (form *TestForm) ChangeVal(id string, val interface{})
- func (form *TestForm) CheckGroup(id string, values ...string)
- func (form *TestForm) Click(c page.ControlI)
- func (form *TestForm) ClickHtmlItem(id string)
- func (form *TestForm) ClickSubItem(c page.ControlI, subId string)
- func (form *TestForm) CloseWindow()
- func (form *TestForm) Done(s string)
- func (form *TestForm) DrawTemplate(ctx context.Context, buf *bytes.Buffer) (err error)
- func (form *TestForm) Error(message string)
- func (form *TestForm) Fatal(message string)
- func (form *TestForm) Focus(id string)
- func (form *TestForm) GetForm() page.FormI
- func (form *TestForm) HasClass(id string, needle string) bool
- func (form *TestForm) InnerHtml(id string) string
- func (form *TestForm) JqueryAttribute(id string, attribute string) interface{}
- func (form *TestForm) JqueryValue(id string) interface{}
- func (form *TestForm) LoadControls(ctx context.Context)
- func (form *TestForm) LoadUrl(url string) page.FormI
- func (form *TestForm) Log(s string)
- func (form *TestForm) SetCheckbox(id string, val bool)
- func (form *TestForm) WaitSubmit()
Constants ¶
const ( TestButtonAction = iota + 1 TestAllAction )
const StepTimeoutSeconds = 10
const TestFormId = "TestForm"
const TestFormPath = "/test"
const (
TestStepAction = iota + 100
)
Variables ¶
This section is empty.
Functions ¶
func GetTestForm ¶
GetTestForm returns the test form itself, if its loaded
func RegisterTestFunction ¶
func RegisterTestFunction(name string, f testRunnerFunction)
RegisterTestFunction registers the test and presents it in the list of tests that can be performed.
func TestAssets ¶
func TestAssets() string
Types ¶
type TestController ¶
func NewTestController ¶
func NewTestController(parent page.ControlI, id string) *TestController
func (*TestController) Action ¶
func (p *TestController) Action(ctx context.Context, a page.ActionParams)
func (*TestController) ΩPutCustomScript ¶ added in v0.0.3
func (p *TestController) ΩPutCustomScript(ctx context.Context, response *page.Response)
func (*TestController) ΩUpdateFormValues ¶ added in v0.0.3
func (p *TestController) ΩUpdateFormValues(ctx *page.Context)
type TestForm ¶
type TestForm struct { FormBase TestList *SelectList RunningLabel *Span RunButton *Button Controller *TestController // contains filtered or unexported fields }
func (*TestForm) AddHeadTags ¶
func (form *TestForm) AddHeadTags()
func (*TestForm) AssertEqual ¶
func (form *TestForm) AssertEqual(expected, actual interface{})
AssertEqual will test that the two values are equal, and will error if they are not equal. The test will continue after this.
func (*TestForm) AssertNotNil ¶ added in v0.0.3
func (form *TestForm) AssertNotNil(v interface{})
func (*TestForm) CallJqueryFunction ¶
func (form *TestForm) CallJqueryFunction(id string, funcName string, params ...interface{}) interface{}
CallJqueryFunction will call the given function with the given parameters on the jQuery object specified by the id. It will return the javascript result of the function call.
func (*TestForm) ChangeVal ¶
ChangeVal will change the value of a form object. It essentially calls the jQuery .val() function on the html object with the given id, followed by sending a change event to the object. This is not quite the same thing as what happens when a user changes a value, as text boxes may send input events, and change is fired on some objects only when losing focus. However, this will simulate changing a value adequately for most situations.
func (*TestForm) CheckGroup ¶ added in v0.0.3
CheckGroup sets the a checkbox group to a list of values. Radio groups should only be given one value to check. Will uncheck anything checked in the group before checking the given values. Specify nil to uncheck everything.
func (*TestForm) Click ¶
Click sends a click event to the goradd control. Note that this is not the same as simulating a click but for buttons, it will essentially be the same thing. More complex web objects will need a different mechanism for clicking, likely a chromium driver or something similar.
func (*TestForm) ClickHtmlItem ¶ added in v0.0.5
func (*TestForm) ClickSubItem ¶ added in v0.0.4
ClickSubItem sends a click event to the html object with the given sub-id inside the given control. Note that this is not the same as simulating a click
func (*TestForm) CloseWindow ¶
func (form *TestForm) CloseWindow()
func (*TestForm) DrawTemplate ¶
func (*TestForm) JqueryAttribute ¶ added in v0.0.3
Attribute will call the jquery .attr("attribute") function on the given html object looking for the given attribute name and will return the value.
func (*TestForm) JqueryValue ¶ added in v0.0.3
Value will call the jquery .val() function on the given html object and return the result.
func (*TestForm) LoadControls ¶
func (*TestForm) LoadUrl ¶
LoadUrl will launch a new window controlled by the test form. It will wait for the new url to be loaded in the window, and if the new url contains a goradd form, it will return the form.
func (*TestForm) SetCheckbox ¶ added in v0.0.3
SetCheckbox sets the given checkbox control to the given value. Use this instead of ChangeVal on checkboxes.
func (*TestForm) WaitSubmit ¶ added in v0.0.3
func (form *TestForm) WaitSubmit()