atest

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package atest 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, button engine.MouseButton)

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

func SimulateClickOnObject

func SimulateClickOnObject(o *engine.SceneObject, button engine.MouseButton)

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 {
	// contains filtered or unexported fields
}

The testing frontend.

func (*Frontend) CommencePanic added in v0.2.5

func (f *Frontend) CommencePanic(reason, msg string)

func (*Frontend) Execute added in v0.2.5

func (f *Frontend) Execute(item dispatch.WorkItem)

func (*Frontend) GetApp added in v0.2.5

func (f *Frontend) GetApp() *frontend.App

func (*Frontend) GetContext added in v0.2.5

func (f *Frontend) GetContext() frontend.Context

func (*Frontend) GetLaunchArgs added in v0.2.5

func (f *Frontend) GetLaunchArgs() a.SiMap

func (*Frontend) GetMessageDispatcher added in v0.2.5

func (f *Frontend) GetMessageDispatcher() dispatch.MessageDispatcher

func (*Frontend) GetPlatform

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

func (*Frontend) GetRenderer added in v0.2.5

func (f *Frontend) GetRenderer() *rendering.ARenderer

func (*Frontend) GetResourceManager added in v0.2.5

func (f *Frontend) GetResourceManager() frontend.ResourceManager

func (*Frontend) GetWorkDispatcher added in v0.2.5

func (f *Frontend) GetWorkDispatcher() dispatch.WorkDispatcher

func (*Frontend) Init

func (f *Frontend) Init()

func (*Frontend) Run added in v0.2.5

func (f *Frontend) Run()

func (*Frontend) SendMessage added in v0.2.5

func (f *Frontend) SendMessage(message *dispatch.Message)

func (*Frontend) SetEngineDispatcher added in v0.2.5

func (f *Frontend) SetEngineDispatcher(disp dispatch.MessageDispatcher)

type RendererDelegate added in v0.2.5

type RendererDelegate struct {
}

func (*RendererDelegate) OnClear added in v0.2.5

func (r *RendererDelegate) OnClear()

func (*RendererDelegate) OnPerformRenderingEnd added in v0.2.5

func (r *RendererDelegate) OnPerformRenderingEnd()

func (*RendererDelegate) OnPerformRenderingStart added in v0.2.5

func (r *RendererDelegate) OnPerformRenderingStart()

func (*RendererDelegate) OnPrepare added in v0.2.5

func (r *RendererDelegate) OnPrepare()

func (*RendererDelegate) OnStop added in v0.2.5

func (r *RendererDelegate) OnStop()

type ResourceManager added in v0.2.5

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

func (*ResourceManager) FullPathOf added in v0.2.5

func (r *ResourceManager) FullPathOf(id a.ResId) string

func (*ResourceManager) IdOf added in v0.2.5

func (r *ResourceManager) IdOf(path string) a.ResId

func (*ResourceManager) PathOf added in v0.2.5

func (r *ResourceManager) PathOf(id a.ResId) string

func (*ResourceManager) ReadFile added in v0.2.5

func (r *ResourceManager) ReadFile(id a.ResId) ([]byte, error)

func (*ResourceManager) RegisterResource added in v0.2.5

func (r *ResourceManager) RegisterResource(path string)

type SceneTestingDelegate

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

type TestingComponent

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

TestingComponent is a 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