ComponentWrapper { public UI wrap(Component component) { if (component instanceof UI) { return (UI) component; } if (component instanceof Window) { return wrapWindow((Window) component); } if (component instanceof Layout) { return wrapLayout((Layout) component); } final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSizeFull(); layout.addComponent(component); layout.setExpandRatio(component, 1); return wrapLayout(layout); } ComponentWrapper(ComponentBasedVaadinServer server); UI wrap(Component component); UI wrapLayout(Layout layout); UI wrapWindow(Window window);  }
@Test public void wrapUI() { final UI ui = new UI() { @Override protected void init(VaadinRequest request) { setContent(new VerticalLayout()); } }; final UI app = instance.wrap(ui); assertEquals("ui was not set properly", ui, app); }
@Test public void wrapLayoutWithDevelopmentHeader() { final EmbedComponentConfig config = EmbedComponentConfig.defaultConfig(); config.setDevelopmentHeader(true); final ComponentWrapper wrapper = createWrapper(config); final HorizontalLayout layout = new HorizontalLayout(); final UI app = wrapper.wrap(layout); final Layout l = assertWrappingLayout(app); assertEquals("Layout was not set properly", layout, l); }
@Test public void wrapLayoutWithoutDevelopmentHeader() { final HorizontalLayout layout = new HorizontalLayout(); final UI app = instance.wrap(layout); assertNotNull("Main content must not be null", app.getContent()); assertEquals("Layout should be set as the main layout since no header was expected", layout, app.getContent()); }
@Test public void wrapSimpleComponent() { final Button component = new Button("Hello"); final UI app = instance.wrap(component); final Component content = app.getUI().getContent(); assertEquals("Main content must be vertical layout", VerticalLayout.class, content.getClass()); final VerticalLayout layout = (VerticalLayout) content; assertEquals("Should have a single component", 1, layout.getComponentCount()); assertEquals("Component was not set properly", component, layout.getComponent(0)); }