* Set expectations on MarinerPageContext Mock
*/
marinerPageContextMock.expects.getRequestURL(false).returns(
requestURL).any();
marinerPageContextMock.expects.getDeviceLayoutContext().does(new MethodAction() {
public Object perform(MethodActionEvent event) throws Throwable {
Object result = null;
if (!deviceLayoutContextStack.empty()) {
result = deviceLayoutContextStack.peek();
}
return result;
}
}).any();
marinerPageContextMock.fuzzy.pushDeviceLayoutContext(
mockFactory.expectsInstanceOf(DeviceLayoutContext.class))
.does(new MethodAction() {
public Object perform(MethodActionEvent event)
throws Throwable {
Object context = event.getArgument(
DeviceLayoutContext.class);
deviceLayoutContextStack.push(context);
return null;
}
}).any();
// optional for XDIME2
marinerPageContextMock.expects.setCanvasHasChildren(false).any();
marinerPageContextMock.fuzzy.getFormatInstance(
mockFactory.expectsInstanceOf(Pane.class),
NDimensionalIndex.ZERO_DIMENSIONS)
.returns(paneInstance)
.any();
InternalProjectFactory factory =
InternalProjectFactory.getInternalInstance();
// ProjectMock project = new ProjectMock("project mock", expectations);
final RuntimeProjectMock project =
new RuntimeProjectMock("projectMock", expectations);
project.expects.getPolicySource()
.returns(factory.createXMLPolicySource(null, ".")).any();
MethodAction initialiseCanvasAction = new MethodAction() {
public Object perform(MethodActionEvent event) throws Throwable {
// Optional for XDIME2.
marinerPageContextMock.expects.initialisedCanvas().returns(true).any();
return null;
}
};
marinerPageContextMock.fuzzy.initialise(Boolean.FALSE,
Boolean.FALSE,
null,
null,
mockFactory.expectsInstanceOf(CompiledStyleSheetCollection.class),
LAYOUT_NAME).does(initialiseCanvasAction);
marinerPageContextMock.expects.peekCanvasType().does(new MethodAction() {
public Object perform(MethodActionEvent event) throws Throwable {
Object result = null;
if (!canvasTypeStack.empty()) {
result = canvasTypeStack.peek();
}
return result;
}
}).any();
marinerPageContextMock.expects.popCanvasType().does(new MethodAction() {
public Object perform(MethodActionEvent event) throws Throwable {
Object result = null;
if (!canvasTypeStack.empty()) {
result = canvasTypeStack.pop();
}
return result;
}
}).any();
marinerPageContextMock.fuzzy.pushCanvasType(
mockFactory.expectsInstanceOf(String.class))
.does(new MethodAction() {
public Object perform(MethodActionEvent event)
throws Throwable {
Object context = event.getArgument(String.class);
canvasTypeStack.push(context);
return null;
}
}).any();
// Since we have pane set for XDIMECP via cdm:pane and for XDIME2 via
// mcs-container these two will be called twice as we cannot vary the
// stylesheet per test.
marinerPageContextMock.expects.pushContainerInstance(paneInstance).any();
marinerPageContextMock.expects.popContainerInstance(paneInstance).any();
marinerPageContextMock.expects.getCurrentContainerInstance().returns(paneInstance).any();
marinerPageContextMock.expects.getCurrentPane().returns(pane).any();
marinerPageContextMock.expects.updateFragmentationState();
marinerPageContextMock.expects.getProtocol().returns(protocol).any();
marinerPageContextMock.expects.getDeviceName().returns("Master");
marinerPageContextMock.expects.getDevice().returns(device).any();
// optional for XDIME1?
marinerPageContextMock.fuzzy.getFormat("pane",
mockFactory.expectsInstanceOf(FormatNamespace.class))
.returns(pane).any();
// optional for XDIME2.
marinerPageContextMock.expects.getPane("pane").returns(pane).any();
marinerPageContextMock.fuzzy.pushOutputBuffer(
mockFactory.expectsInstanceOf(DOMOutputBuffer.class))
.does(new MethodAction() {
public Object perform(MethodActionEvent event)
throws Throwable {
Object buffer = event.getArgument(OutputBuffer.class);
outputBufferStack.push(buffer);
return null;
}
}).any();
marinerPageContextMock.fuzzy.popOutputBuffer(
mockFactory.expectsInstanceOf(DOMOutputBuffer.class))
.does(new MethodAction() {
public Object perform(MethodActionEvent event)
throws Throwable {
return outputBufferStack.pop();
}
}).any();
marinerPageContextMock.expects.getCurrentOutputBuffer().does(new MethodAction() {
public Object perform(MethodActionEvent event) throws Throwable {
return outputBufferStack.peek();
}
}).any();
RuntimeDeviceTheme runtimeDeviceTheme = createRuntimeDeviceTheme();
marinerPageContextMock.expects.retrieveThemeStyleSheet(THEME_NAME).
returns(runtimeDeviceTheme.getCompiledStyleSheet());
marinerPageContextMock.expects.enteringXDIMECPElement().any();
marinerPageContextMock.expects.insideXDIMECPElement()
.returns(false).any();
marinerPageContextMock.expects.exitingXDIMECPElement().any();
marinerPageContextMock.expects.getEnclosingRegionInstance()
.returns(null).any();
marinerPageContextMock.expects.popDeviceLayoutContext()
.does(new MethodAction() {
public Object perform(MethodActionEvent methodActionEvent)
throws Throwable {
// Don't actually pop this as it prevents the markup
// from being generated at the end. NASTY.