/** * Class constructor specifying the evaluator to use and the id of the fileDialog we want to test. * The constructor checks if the given id does correspond to a fileDialog. * * @param evaluator a technology specific evaluator * @param id the id (unique) of the fileDialog */ public FileDialog(Evaluator evaluator, String id) { super(evaluator, id); checkIsExpectedComponent(FileDialog); }
/** * @see Component */ @Override public String toString() { return super.toString() + ", selectedFilePath:" + selectedFilePath(); } }
@Test public void can_select_file_path() { FileDialog fileDialog = new FileDialog(evaluator, id); fileDialog.selectFilePath("/some/file/path"); verify(evaluator, times(1)).selectFilePath("/some/file/path", fileDialog); }
@Test public void test_toString() { FileDialog fileDialog = new FileDialog(evaluator, id); when(evaluator.isVisible(any(Component.class))).thenReturn(true); when(evaluator.isEnabled(any(Component.class))).thenReturn(true); when(evaluator.title(fileDialog)).thenReturn("title"); when(evaluator.selectedFilePath(fileDialog)).thenReturn("/home/testatoo/file.txt"); assertThat(fileDialog.toString(), is("class org.testatoo.core.component.FileDialog with state : enabled:true, visible:true, title:title, selectedFilePath:/home/testatoo/file.txt")); } }
@Test public void test_component_type() { evaluator = mock(Evaluator.class); when(evaluator.existComponent(id)).thenReturn(true); when(evaluator.componentType(id)).thenReturn(Radio); try { new FileDialog(evaluator, id); fail(); } catch (ComponentException e) { assertThat(e.getMessage(), is("The component with id=" + id + " is not a FileDialog but a Radio")); } }