DisplayerDragComponent implements PerspectiveEditorCoreComponent, HasModalConfiguration { protected void adjustSize( DisplayerSettings settings, int containerWidth ) { int displayerWidth = settings.getChartWidth(); int tableWidth = settings.getTableWidth(); if ( containerWidth > 0 && displayerWidth > containerWidth ) { int ratio = containerWidth * 100 / displayerWidth; settings.setChartWidth( containerWidth ); settings.setChartHeight( settings.getChartHeight() * ratio / 100 ); } if ( tableWidth == 0 || tableWidth > containerWidth ) { settings.setTableWidth( containerWidth > 20 ? containerWidth - 20 : 0 ); } } @Inject  DisplayerDragComponent( SyncBeanManager beanManager,
                                   DisplayerViewer viewer,
                                   PlaceManager placeManager,
                                   PerspectiveCoordinator perspectiveCoordinator ); @Override String getDragComponentTitle(); @Override IsWidget getPreviewWidget( final RenderingContext ctx ); @Override IsWidget getShowWidget( final RenderingContext ctx ); @Override Modal getConfigurationModal( final ModalConfigurationContext ctx );  }
@Test public void testAdjustSize(){ final DisplayerSettings settings = mock(DisplayerSettings.class); when(settings.getChartWidth()).thenReturn(0); when(settings.getTableWidth()).thenReturn(0); displayerDragComponent.adjustSize(settings, 0); verify(settings).setTableWidth(0); displayerDragComponent.adjustSize(settings, 30); verify(settings).setTableWidth(10); }