browsertest

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2019 License: MIT Imports: 16 Imported by: 0

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

View Source
const (
	TestButtonAction = iota + 1
)
View Source
const TestFormId = "TestForm"
View Source
const TestFormPath = "/test"
View Source
const (
	TestStepAction = iota + 100
)

Variables

This section is empty.

Functions

func GetTestForm

func GetTestForm() page.FormI

GetTestForm returns the test form itself, if its loaded

func NewTestForm

func NewTestForm(ctx context.Context) page.FormI

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

func TestStepEvent

func TestStepEvent() *testStepEvent

RowSelected

Types

type TestController

type TestController struct {
	control.Panel
	// contains filtered or unexported fields
}

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) Init

func (p *TestController) Init(self control.PanelI, parent page.ControlI, id string)

func (*TestController) PutCustomScript

func (p *TestController) PutCustomScript(ctx context.Context, response *page.Response)

func (*TestController) UpdateFormValues

func (p *TestController) UpdateFormValues(ctx *page.Context)

type TestForm

type TestForm struct {
	page.ΩFormBase
	TestList     *SelectList
	RunningLabel *Span
	RunButton    *Button
	Controller   *TestController
	// contains filtered or unexported fields
}

func (*TestForm) Action

func (f *TestForm) Action(ctx context.Context, a page.ActionParams)

func (*TestForm) AddHeadTags

func (form *TestForm) AddHeadTags()

func (*TestForm) AssertEqual

func (f *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) CallJqueryFunction

func (f *TestForm) CallJqueryFunction(id string, funcName string, params []string) string

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

func (f *TestForm) ChangeVal(id string, val interface{})

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) Click

func (f *TestForm) Click(id string)

Click sends a click event to the html object with the given id. 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) CloseWindow

func (f *TestForm) CloseWindow()

func (*TestForm) Done

func (f *TestForm) Done(s string)

Mark the successful end of testing with a message.

func (*TestForm) DrawTemplate

func (form *TestForm) DrawTemplate(ctx context.Context, buf *bytes.Buffer) (err error)

func (*TestForm) Error

func (f *TestForm) Error(message string)

Error will cause the test to error, but will continue performing the test.

func (*TestForm) Fatal

func (f *TestForm) Fatal(message string)

Fail will cause a test to stop with the given messages.

func (*TestForm) Focus

func (f *TestForm) Focus(id string)

func (*TestForm) GetForm

func (f *TestForm) GetForm() page.FormI

GetForm returns the currently loaded form.

func (*TestForm) LoadControls

func (f *TestForm) LoadControls(ctx context.Context)

func (*TestForm) LoadUrl

func (f *TestForm) LoadUrl(url string)

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 prepare to return the form if you call GetForm.

func (*TestForm) Log

func (f *TestForm) Log(s string)

Log will send a message to the log. The message might not draw right away.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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