Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
mockRenderContext(applicationContextTestValues, environmentContextTestValues)
Signature
public static Canvas.RenderContext mockRenderContext(Map<String,String> applicationContextTestValues, Map<String,String> environmentContextTestValues)
Parameters
-
applicationContextTestValues:
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 generates some default mock application context values.
-
environmentContextTestValues:
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 generates 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).
1Map<String,String> appValues = new Map<String,String>();
2appValues.put(Canvas.Test.KEY_NAMESPACE,'alternateNamespace');
3appValues.put(Canvas.Test.KEY_VERSION,'3.0');
4
5Map<String,String> envValues = new Map<String,String>();
6envValues.put(Canvas.Test.KEY_DISPLAY_LOCATION,'Chatter');
7envValues.put(Canvas.Test.KEY_LOCATION_URL,'https://MyDomainName.my.salesforce.com/_ui/core/chatter/ui/ChatterPage');
8
9Canvas.RenderContext mock = Canvas.Test.mockRenderContext(appValues,envValues);