Newer Version Available
testCanvasLifecycle(lifecycleHandler, mockRenderContext)
Signature
public static Void testCanvasLifecycle(Canvas.CanvasLifecycleHandler lifecycleHandler,Canvas.RenderContext mockRenderContext)
Parameters
- lifecycleHandler
- Type: Canvas.CanvasLifecycleHandler
- Specifies the CanvasLifecycleHandler implementation that you need to invoke.
- mockRenderContext
- Type: Canvas.RenderContext
- Specifies the RenderContext information that you need to provide to the invoked CanvasLifecycleHandler. If null is provided for this parameter, the canvas framework will generate and use a default mock RenderContext.
Return Value
Type: Void
Usage
Use this method to invoke an implementation of Canvas.CanvasLifecycleHandler.onRender(renderContext) with a mock Canvas.RenderContext that you provide.
Example
The following example creates maps to represent mock application and environment context data and generates a test Canvas.RenderContext. This test RenderContext is then used to invoke a Canvas.CanvasLifecycleHandler.
1swfobject.registerObject("clippy.codeblock-0", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17// Set some application context data in a Map
18Map<String,String> appValues = new Map<String,String>();
19appValues.put(Canvas.Test.KEY_NAMESPACE,'alternateNamespace');
20appValues.put(Canvas.Test.KEY_VERSION,'3.0');
21
22// Set some environment context data in a MAp
23Map<String,String> envValues = new Map<String,String>();
24envValues.put(Canvas.Test.KEY_DISPLAY_LOCATION,'Chatter');
25envValues.put(Canvas.Test.KEY_LOCATION_URL,'https://na1.salesforce.com/_ui/core/chatter/ui/ChatterPage');
26
27// Create a mock RenderContext using the test application and environment context data Maps
28Canvas.RenderContext mock = Canvas.Test.mockRenderContext(appValues,envValues);
29
30// Set some custom params on the mock RenderContext
31mock.getEnvironmentContext().setParametersAsJSON('{\"param1\":1,\"boolParam\":true,\"stringParam\":\"test string\"}');
32
33// Use the mock RenderContext to invoke a CanvasLifecycleHandler
34Canvas.Test.testCanvasLifecycle(handler,mock)