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 ¶
- func MakeTestScene(delegate TestingDelegate) (*engine.SceneObject, *engine.SceneObject)
- func RunEngineTest(t *testing.T, delegate TestingDelegate)
- func RunEngineTestWithScene(t *testing.T, prepareDelegate, testingDelegate SceneTestingDelegate)
- func SimulateCallback(code int, data string)
- func SimulateClick(x, y int, button engine.MouseButton)
- func SimulateClickOnObject(o *engine.SceneObject, button engine.MouseButton)
- func Stop()
- func WaitForStop()
- type Frontend
- func (f *Frontend) CommencePanic(reason, msg string)
- func (f *Frontend) Execute(item dispatch.WorkItem)
- func (f *Frontend) GetApp() *frontend.App
- func (f *Frontend) GetContext() frontend.Context
- func (f *Frontend) GetLaunchArgs() a.SiMap
- func (f *Frontend) GetMessageDispatcher() dispatch.MessageDispatcher
- func (f *Frontend) GetPlatform() common.Platform
- func (f *Frontend) GetRenderer() *rendering.ARenderer
- func (f *Frontend) GetResourceManager() frontend.ResourceManager
- func (f *Frontend) GetWorkDispatcher() dispatch.WorkDispatcher
- func (f *Frontend) Init()
- func (f *Frontend) Run()
- func (f *Frontend) SendMessage(message *dispatch.Message)
- func (f *Frontend) SetEngineDispatcher(disp dispatch.MessageDispatcher)
- type RendererDelegate
- type ResourceManager
- type SceneTestingDelegate
- type TestingComponent
- type TestingDelegate
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 ¶
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.
Types ¶
type Frontend ¶
type Frontend struct {
// contains filtered or unexported fields
}
The testing frontend.
func (*Frontend) CommencePanic ¶ added in v0.2.5
func (*Frontend) GetContext ¶ added in v0.2.5
func (*Frontend) GetLaunchArgs ¶ added in v0.2.5
func (*Frontend) GetMessageDispatcher ¶ added in v0.2.5
func (f *Frontend) GetMessageDispatcher() dispatch.MessageDispatcher
func (*Frontend) GetPlatform ¶
func (*Frontend) GetRenderer ¶ added in v0.2.5
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) SendMessage ¶ added in v0.2.5
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) 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)