TargetFactory { @VisibleForTesting protected File findImageFile(String imageFile) { File foundImageFile = findImageFile(folderToScan, imageFile); return foundImageFile == null ? new File(imageFile) : foundImageFile; }  void setImagePrefix(String imagePathPrefix); ImageTarget createImageTarget(String imageFile);  }
@Test public void shouldImageFindFile_FullPath() { File f1 = targetFactory.findImageFile(FILE_PATH); assertTrue(f1.exists()); File f2 = targetFactory.findImageFile(FILE_PATH_BACKSLASHED); assertTrue(f2.exists()); }
@Test public void shouldFindFile_SlashAtFullPath() { File f1 = targetFactory.findImageFile("/" + FILE_PATH); assertTrue(f1.exists()); File f2 = targetFactory.findImageFile("\\" + FILE_PATH_BACKSLASHED); assertTrue(f2.exists()); }
@Test public void shouldFindFile_MissingFoldersFromFullPath() { File f1 = targetFactory.findImageFile("rmi/TargetFactory.java"); assertTrue(f1.exists()); File f2 = targetFactory.findImageFile("rmi\\TargetFactory.java"); assertTrue(f2.exists()); }
@Test public void shouldNotFindFile_WhenNotImageFile() { File f1 = targetFactory.findImageFile("sikuli"); assertFalse(f1.exists()); File f2 = targetFactory.findImageFile("sikuli/rmi"); assertFalse(f2.exists()); }
@Test public void shouldFindFile_ByFileName() { File f1 = targetFactory.findImageFile("TargetFactory.java"); assertTrue(f1.exists()); }
@Test public void shouldNotFindFile_FileNameWrong() { File f1 = targetFactory.findImageFile("NonExisting.java"); assertFalse(f1.exists()); f1 = targetFactory.findImageFile("NON_EXISTING_FOLDER/TargetFactory.java"); assertFalse(f1.exists()); f1 = targetFactory.findImageFile("NON_EXISTING_FOLDER\\TargetFactory.java"); assertFalse(f1.exists()); f1 = targetFactory.findImageFile("ikuli/TargetFactory.java"); assertFalse(f1.exists()); f1 = targetFactory.findImageFile("ikuli\\TargetFactory.java"); assertFalse(f1.exists()); }