mockRenderContext(applicationContextTestValues, environmentContextTestValues)

Creates and returns a test Canvas.RenderContext based on the provided application and environment context parameters.

Signature

public static Canvas.RenderContext mockRenderContext(Map<String,String> applicationContextTestValues, Map<String,String> environmentContextTestValues)

Parameters

applicationContextTestValues
Type: Map<String,String>
Specifies a map of key-value pairs that provide mock application context data. Use constants that are provided by Canvas.Test as keys. If null is provided for this parameter, the canvas framework will generate some default mock application context values.
environmentContextTestValues
Type: Map<String,String>
Specifies a map of key-value pairs that provide mock environment context data. Use constants provided by Canvas.Test as keys. If null is provided for this parameter, the canvas framework will generate some default mock environment context values.

Return Value

Type: Canvas.RenderContext

Usage

Use this method to create a mock Canvas.RenderContext. Use the returned RenderContext in calls to Canvas.Test.testCanvasLifecycle(lifecycleHandler, mockRenderContext) for testing Canvas.CanvasLifecycleHandler implementations.

Example

The following example creates maps to represent mock application and environment context data and generates a test Canvas.RenderContext. This test RenderContext can be used in a call to Canvas.Test.testCanvasLifecycle(lifecycleHandler, mockRenderContext).

Map<String,String> appValues = new Map<String,String>();
appValues.put(Canvas.Test.KEY_NAMESPACE,'alternateNamespace');
appValues.put(Canvas.Test.KEY_VERSION,'3.0');

Map<String,String> envValues = new Map<String,String>();
envValues.put(Canvas.Test.KEY_DISPLAY_LOCATION,'Chatter');
envValues.put(Canvas.Test.KEY_LOCATION_URL,'https://na1.salesforce.com/_ui/core/chatter/ui/ChatterPage');

Canvas.RenderContext mock = Canvas.Test.mockRenderContext(appValues,envValues);
Previous
Next