atest

package
v0.2.0-preview.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

This package provides functionality for running automated tests, that require the Amphion engine to be running. During the test the frontend is not run. So, no UI is rendered and you can only simulate frontend callbacks (like click).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeTestScene

func MakeTestScene(delegate TestingDelegate) (*engine.SceneObject, *engine.SceneObject)

MakeTestScene creates the default testing scene, that contains only one child object of size (100; 100; 100) located in the center with the TestingComponent attached to it.

func RunEngineTest

func RunEngineTest(t *testing.T, delegate TestingDelegate)

RunEngineTest starts the Amphion engine and the calls the specified delegate.

func RunEngineTestWithScene

func RunEngineTestWithScene(t *testing.T, prepareDelegate, testingDelegate SceneTestingDelegate)

RunEngineTestWithScene first starts the Amphion engine. It then creates the default testing scene (See MakeTestScene). The prepareDelegate is called before the scene is shown. Here you can perform some setup like adding new objects and components to the scene. The testingDelegate is where you actually call the tested code.

func SimulateCallback

func SimulateCallback(code int, data string)

SimulateCallback simulates a frontend callback with the specified code and data.

func SimulateClick

func SimulateClick(x, y int)

SimulateClick simulates user's click at the specified position on the screen.

func SimulateClickOnObject

func SimulateClickOnObject(o *engine.SceneObject)

SimulateClickOnObject simulates user's click in the center of the specified object.

func Stop

func Stop()

Stops the testing instance of Amphion engine.

func WaitForStop

func WaitForStop()

Blocks the calling goroutine until the engine is stopped.

Types

type Frontend

type Frontend struct {
	*pc.Frontend
	// contains filtered or unexported fields
}

The testing frontend.

func (*Frontend) GetPlatform

func (f *Frontend) GetPlatform() common.Platform

func (*Frontend) Init

func (f *Frontend) Init()

func (*Frontend) SetCallback

func (f *Frontend) SetCallback(handler frontend.CallbackHandler)

type SceneTestingDelegate

type SceneTestingDelegate func(e *engine.AmphionEngine, testScene, testObject *engine.SceneObject)

type TestingComponent

type TestingComponent struct {
	engine.ComponentImpl
	// contains filtered or unexported fields
}

Component for running testing code in scene. It calls the specified delegate in OnStart method.

func NewTestingComponent

func NewTestingComponent(testingDelegate TestingDelegate) *TestingComponent

func (*TestingComponent) GetName

func (t *TestingComponent) GetName() string

func (*TestingComponent) OnStart

func (t *TestingComponent) OnStart()

type TestingDelegate

type TestingDelegate func(e *engine.AmphionEngine)

Jump to

Keyboard shortcuts

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