/** * Class constructor specifying the evaluator to use and the id of the panel we want to test. * The constructor checks if the given id does correspond to a panel. * * @param evaluator a technology specific evaluator * @param id the id (unique) of the panel */ public Panel(Evaluator evaluator, String id) { super(evaluator, id); checkIsExpectedComponent(Panel); }
/** * @see Component */ @Override public String toString() { return super.toString() + ", title:" + title(); } }
@Test public void test_panel_as_container() { when(evaluator.existComponent("myId2")).thenReturn(true); when(evaluator.componentType("myId2")).thenReturn(Panel); Panel panel_1 = new Panel(evaluator, id); Panel panel_2 = new Panel(evaluator, "myId2"); when(evaluator.contains(panel_1, panel_2)).thenReturn(true); when(evaluator.contains(panel_2, panel_1)).thenReturn(false); assertThat(panel_1.contains(panel_2), is(true)); assertThat(panel_2.contains(panel_1), is(false)); }
public static Panel panel() { Evaluator evaluator = mock(Evaluator.class); when(evaluator.existComponent(id)).thenReturn(true); when(evaluator.isVisible(any(Component.class))).thenReturn(true); when(evaluator.isEnabled(any(Component.class))).thenReturn(true); when(evaluator.componentType(id)).thenReturn(Panel); when(evaluator.title(any(Panel.class))).thenReturn("myPanelTitle"); return new Panel(evaluator, id); }
@Test public void test_component_type() { evaluator = mock(Evaluator.class); when(evaluator.existComponent(id)).thenReturn(true); when(evaluator.componentType(id)).thenReturn(Radio); try { new Panel(evaluator, id); fail(); } catch (ComponentException e) { assertThat(e.getMessage(), is("The component with id=" + id + " is not a Panel but a Radio")); } }