// =====================================================================
// Create Mocks
// =====================================================================
final PaneMock paneMock = LayoutTestHelper.createPaneMock(
"paneMock", expectations, canvasLayoutMock);
final StyleSheetMock styleSheetMock =
new StyleSheetMock("styleSheetMock", expectations);
final StyleSheetCompilerMock styleSheetCompilerMock =
new StyleSheetCompilerMock("styleSheetCompilerMock",
expectations);
final CompiledStyleSheetMock compiledStyleSheetMock =
new CompiledStyleSheetMock("compiledStyleSheetMock",
expectations);
final FragmentMock fragmentMock = LayoutTestHelper.createFragmentMock(
"fragmentMock", expectations, canvasLayoutMock);
final InternalLayoutContentMock layoutContentMock =
new InternalLayoutContentMock("layoutContentMock",
expectations);
final StyleSheetActivatorMock styleSheetActivatorMock =
new StyleSheetActivatorMock("styleSheetActivatorMock",
expectations);
// =====================================================================
// Set Expectations
// =====================================================================
canvasLayoutMock.expects.getDefaultFragmentName()
.returns("DEFAULT FRAGMENT").any();
paneMock.expects.getEnclosingFragment().returns(fragmentMock).any();
canvasLayoutMock.expects.getRootFormat().returns(paneMock).any();
styleSheetBuilderMock.expects.build(canvasLayoutMock)
.returns(styleSheetMock);
styleSheetCompilerFactoryMock.expects.createStyleSheetCompiler()
.returns(styleSheetCompilerMock);
styleSheetCompilerMock.expects.compileStyleSheet(styleSheetMock).
returns(compiledStyleSheetMock);
deviceLayoutUpdaterMock.expects.update(canvasLayoutMock);
layoutContentMock.expects.getLayout().returns(canvasLayoutMock).any();
styleSheetActivatorMock.expects.activate(styleSheetMock);
// =====================================================================
// Test Expectations
// =====================================================================
ActivatedLayoutContent activatedLayoutContent = (ActivatedLayoutContent)
activator.activateLayoutContent(styleSheetActivatorMock,
layoutContentMock);
assertEquals("Compiled Style Sheet", compiledStyleSheetMock,
activatedLayoutContent.getCompiledStyleSheet());
RuntimeDeviceLayout runtimeDeviceLayout = new RuntimeLayoutAdapter(
null, canvasLayoutMock, compiledStyleSheetMock,
activatedLayoutContent.getContainerNameToFragments());
final List fragments =
runtimeDeviceLayout.getEnclosingFragments("paneMock");
assertEquals(1, fragments.size());
final LayoutContentActivator.ContainerPosition containerPosition =
(LayoutContentActivator.ContainerPosition) fragments.get(0);
assertEquals(paneMock.getEnclosingFragment(),
containerPosition.getFragment());
assertEquals(0, containerPosition.getIndex());
}